Pull video into release branch
authorLen Brown <len.brown@intel.com>
Wed, 10 Oct 2007 04:29:11 +0000 (00:29 -0400)
committerLen Brown <len.brown@intel.com>
Wed, 10 Oct 2007 04:29:11 +0000 (00:29 -0400)
Conflicts:

drivers/acpi/video.c

Signed-off-by: Len Brown <len.brown@intel.com>
1  2 
drivers/acpi/video.c

diff --combined drivers/acpi/video.c
index d05891f16282338d96d5cf5a5f3f22d30d6cd5c0,8a60a3d7001cdbb02c332911ee23326e583197be..f31e3c8749e0ae48f805489538346882eaf79ee8
@@@ -409,14 -409,17 +409,17 @@@ acpi_video_device_lcd_query_levels(stru
  static int
  acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
  {
-       int status;
+       int status = AE_OK;
        union acpi_object arg0 = { ACPI_TYPE_INTEGER };
        struct acpi_object_list args = { 1, &arg0 };
  
  
        arg0.integer.value = level;
-       status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
 +
+       if (device->cap._BCM)
+               status = acpi_evaluate_object(device->dev->handle, "_BCM",
+                                             &args, NULL);
+       device->brightness->curr = level;
 -      printk(KERN_DEBUG "set_level status: %x\n", status);
        return status;
  }
  
@@@ -424,11 -427,11 +427,11 @@@ static in
  acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
                                        unsigned long *level)
  {
-       int status;
-       status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
-       return status;
+       if (device->cap._BQC)
+               return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL,
+                                            level);
+       *level = device->brightness->curr;
+       return AE_OK;
  }
  
  static int
@@@ -1633,9 -1636,20 +1636,20 @@@ static in
  acpi_video_get_next_level(struct acpi_video_device *device,
                          u32 level_current, u32 event)
  {
-       int min, max, min_above, max_below, i, l;
+       int min, max, min_above, max_below, i, l, delta = 255;
        max = max_below = 0;
        min = min_above = 255;
+       /* Find closest level to level_current */
+       for (i = 0; i < device->brightness->count; i++) {
+               l = device->brightness->levels[i];
+               if (abs(l - level_current) < abs(delta)) {
+                       delta = l - level_current;
+                       if (!delta)
+                               break;
+               }
+       }
+       /* Ajust level_current to closest available level */
+       level_current += delta;
        for (i = 0; i < device->brightness->count; i++) {
                l = device->brightness->levels[i];
                if (l < min)
@@@ -1753,7 -1767,7 +1767,7 @@@ static int acpi_video_bus_put_devices(s
  
  static int acpi_video_bus_start_devices(struct acpi_video_bus *video)
  {
 -      return acpi_video_bus_DOS(video, 1, 0);
 +      return acpi_video_bus_DOS(video, 0, 0);
  }
  
  static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)