aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/video.c')
-rw-r--r--drivers/acpi/video.c49
1 files changed, 42 insertions, 7 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index eab9c4213b49..82815cff15a9 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -294,18 +294,26 @@ static int acpi_video_device_set_state(struct acpi_video_device *device, int sta
294static int acpi_video_get_brightness(struct backlight_device *bd) 294static int acpi_video_get_brightness(struct backlight_device *bd)
295{ 295{
296 unsigned long cur_level; 296 unsigned long cur_level;
297 int i;
297 struct acpi_video_device *vd = 298 struct acpi_video_device *vd =
298 (struct acpi_video_device *)bl_get_data(bd); 299 (struct acpi_video_device *)bl_get_data(bd);
299 acpi_video_device_lcd_get_level_current(vd, &cur_level); 300 acpi_video_device_lcd_get_level_current(vd, &cur_level);
300 return (int) cur_level; 301 for (i = 2; i < vd->brightness->count; i++) {
302 if (vd->brightness->levels[i] == cur_level)
303 /* The first two entries are special - see page 575
304 of the ACPI spec 3.0 */
305 return i-2;
306 }
307 return 0;
301} 308}
302 309
303static int acpi_video_set_brightness(struct backlight_device *bd) 310static int acpi_video_set_brightness(struct backlight_device *bd)
304{ 311{
305 int request_level = bd->props.brightness; 312 int request_level = bd->props.brightness+2;
306 struct acpi_video_device *vd = 313 struct acpi_video_device *vd =
307 (struct acpi_video_device *)bl_get_data(bd); 314 (struct acpi_video_device *)bl_get_data(bd);
308 acpi_video_device_lcd_set_level(vd, request_level); 315 acpi_video_device_lcd_set_level(vd,
316 vd->brightness->levels[request_level]);
309 return 0; 317 return 0;
310} 318}
311 319
@@ -702,7 +710,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
702 kfree(obj); 710 kfree(obj);
703 711
704 if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){ 712 if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){
705 unsigned long tmp;
706 int result; 713 int result;
707 static int count = 0; 714 static int count = 0;
708 char *name; 715 char *name;
@@ -711,11 +718,10 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
711 return; 718 return;
712 719
713 sprintf(name, "acpi_video%d", count++); 720 sprintf(name, "acpi_video%d", count++);
714 acpi_video_device_lcd_get_level_current(device, &tmp);
715 device->backlight = backlight_device_register(name, 721 device->backlight = backlight_device_register(name,
716 NULL, device, &acpi_backlight_ops); 722 NULL, device, &acpi_backlight_ops);
717 device->backlight->props.max_brightness = max_level; 723 device->backlight->props.max_brightness = device->brightness->count-3;
718 device->backlight->props.brightness = (int)tmp; 724 device->backlight->props.brightness = acpi_video_get_brightness(device->backlight);
719 backlight_update_status(device->backlight); 725 backlight_update_status(device->backlight);
720 kfree(name); 726 kfree(name);
721 727
@@ -1324,8 +1330,37 @@ acpi_video_bus_write_DOS(struct file *file,
1324 1330
1325static int acpi_video_bus_add_fs(struct acpi_device *device) 1331static int acpi_video_bus_add_fs(struct acpi_device *device)
1326{ 1332{
1333 long device_id;
1334 int status;
1327 struct proc_dir_entry *entry = NULL; 1335 struct proc_dir_entry *entry = NULL;
1328 struct acpi_video_bus *video; 1336 struct acpi_video_bus *video;
1337 struct device *dev;
1338
1339 status =
1340 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
1341
1342 if (!ACPI_SUCCESS(status))
1343 return -ENODEV;
1344
1345 /* We need to attempt to determine whether the _ADR refers to a
1346 PCI device or not. There's no terribly good way to do this,
1347 so the best we can hope for is to assume that there'll never
1348 be a video device in the host bridge */
1349 if (device_id >= 0x10000) {
1350 /* It looks like a PCI device. Does it exist? */
1351 dev = acpi_get_physical_device(device->handle);
1352 } else {
1353 /* It doesn't look like a PCI device. Does its parent
1354 exist? */
1355 acpi_handle phandle;
1356 if (acpi_get_parent(device->handle, &phandle))
1357 return -ENODEV;
1358 dev = acpi_get_physical_device(phandle);
1359 }
1360 if (!dev)
1361 return -ENODEV;
1362 put_device(dev);
1363
1329 1364
1330 1365
1331 video = acpi_driver_data(device); 1366 video = acpi_driver_data(device);