diff options
author | Holger Macht <hmacht@suse.de> | 2006-10-20 17:30:29 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2006-10-21 01:36:00 -0400 |
commit | 2039a6eb72d4b5d0dd71de5c4dff5db129848c44 (patch) | |
tree | dd26066fec8fd8dd9b0a18f2b326c39ce4ee1a3e /drivers/acpi | |
parent | 8acb025085aa88c41063bfa0f2c3b4d0a3f2ef11 (diff) |
ACPI: asus_acpi: Add support for the generic backlight device
Add support for the generic backlight interface below /sys/class/backlight.
Keep the procfs brightness handling for backward compatibility.
[apw@shadowen.org: backlight users need to select BACKLIGHT_CLASS_DEVICE]
Signed-off-by: Holger Macht <hmacht@suse.de>
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/Kconfig | 1 | ||||
-rw-r--r-- | drivers/acpi/asus_acpi.c | 62 |
2 files changed, 47 insertions, 16 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index bc58a3b18e06..9b64c4e6c63e 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -172,6 +172,7 @@ config ACPI_NUMA | |||
172 | config ACPI_ASUS | 172 | config ACPI_ASUS |
173 | tristate "ASUS/Medion Laptop Extras" | 173 | tristate "ASUS/Medion Laptop Extras" |
174 | depends on X86 | 174 | depends on X86 |
175 | select BACKLIGHT_CLASS_DEVICE | ||
175 | ---help--- | 176 | ---help--- |
176 | This driver provides support for extra features of ACPI-compatible | 177 | This driver provides support for extra features of ACPI-compatible |
177 | ASUS laptops. As some of Medion laptops are made by ASUS, it may also | 178 | ASUS laptops. As some of Medion laptops are made by ASUS, it may also |
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index c7ac9297a204..bf7bc25e680e 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/types.h> | 36 | #include <linux/types.h> |
37 | #include <linux/proc_fs.h> | 37 | #include <linux/proc_fs.h> |
38 | #include <linux/backlight.h> | ||
38 | #include <acpi/acpi_drivers.h> | 39 | #include <acpi/acpi_drivers.h> |
39 | #include <acpi/acpi_bus.h> | 40 | #include <acpi/acpi_bus.h> |
40 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
@@ -402,6 +403,8 @@ static struct model_data model_conf[END_MODEL] = { | |||
402 | /* procdir we use */ | 403 | /* procdir we use */ |
403 | static struct proc_dir_entry *asus_proc_dir; | 404 | static struct proc_dir_entry *asus_proc_dir; |
404 | 405 | ||
406 | static struct backlight_device *asus_backlight_device; | ||
407 | |||
405 | /* | 408 | /* |
406 | * This header is made available to allow proper configuration given model, | 409 | * This header is made available to allow proper configuration given model, |
407 | * revision number , ... this info cannot go in struct asus_hotk because it is | 410 | * revision number , ... this info cannot go in struct asus_hotk because it is |
@@ -779,7 +782,7 @@ proc_write_lcd(struct file *file, const char __user * buffer, | |||
779 | return rv; | 782 | return rv; |
780 | } | 783 | } |
781 | 784 | ||
782 | static int read_brightness(void) | 785 | static int read_brightness(struct backlight_device *bd) |
783 | { | 786 | { |
784 | int value; | 787 | int value; |
785 | 788 | ||
@@ -801,9 +804,10 @@ static int read_brightness(void) | |||
801 | /* | 804 | /* |
802 | * Change the brightness level | 805 | * Change the brightness level |
803 | */ | 806 | */ |
804 | static void set_brightness(int value) | 807 | static int set_brightness(int value) |
805 | { | 808 | { |
806 | acpi_status status = 0; | 809 | acpi_status status = 0; |
810 | int ret = 0; | ||
807 | 811 | ||
808 | /* SPLV laptop */ | 812 | /* SPLV laptop */ |
809 | if (hotk->methods->brightness_set) { | 813 | if (hotk->methods->brightness_set) { |
@@ -811,11 +815,12 @@ static void set_brightness(int value) | |||
811 | value, NULL)) | 815 | value, NULL)) |
812 | printk(KERN_WARNING | 816 | printk(KERN_WARNING |
813 | "Asus ACPI: Error changing brightness\n"); | 817 | "Asus ACPI: Error changing brightness\n"); |
814 | return; | 818 | ret = -EIO; |
819 | goto out; | ||
815 | } | 820 | } |
816 | 821 | ||
817 | /* No SPLV method if we are here, act as appropriate */ | 822 | /* No SPLV method if we are here, act as appropriate */ |
818 | value -= read_brightness(); | 823 | value -= read_brightness(NULL); |
819 | while (value != 0) { | 824 | while (value != 0) { |
820 | status = acpi_evaluate_object(NULL, (value > 0) ? | 825 | status = acpi_evaluate_object(NULL, (value > 0) ? |
821 | hotk->methods->brightness_up : | 826 | hotk->methods->brightness_up : |
@@ -825,15 +830,22 @@ static void set_brightness(int value) | |||
825 | if (ACPI_FAILURE(status)) | 830 | if (ACPI_FAILURE(status)) |
826 | printk(KERN_WARNING | 831 | printk(KERN_WARNING |
827 | "Asus ACPI: Error changing brightness\n"); | 832 | "Asus ACPI: Error changing brightness\n"); |
833 | ret = -EIO; | ||
828 | } | 834 | } |
829 | return; | 835 | out: |
836 | return ret; | ||
837 | } | ||
838 | |||
839 | static int set_brightness_status(struct backlight_device *bd) | ||
840 | { | ||
841 | return set_brightness(bd->props->brightness); | ||
830 | } | 842 | } |
831 | 843 | ||
832 | static int | 844 | static int |
833 | proc_read_brn(char *page, char **start, off_t off, int count, int *eof, | 845 | proc_read_brn(char *page, char **start, off_t off, int count, int *eof, |
834 | void *data) | 846 | void *data) |
835 | { | 847 | { |
836 | return sprintf(page, "%d\n", read_brightness()); | 848 | return sprintf(page, "%d\n", read_brightness(NULL)); |
837 | } | 849 | } |
838 | 850 | ||
839 | static int | 851 | static int |
@@ -1333,6 +1345,26 @@ static int asus_hotk_remove(struct acpi_device *device, int type) | |||
1333 | return 0; | 1345 | return 0; |
1334 | } | 1346 | } |
1335 | 1347 | ||
1348 | static struct backlight_properties asus_backlight_data = { | ||
1349 | .owner = THIS_MODULE, | ||
1350 | .get_brightness = read_brightness, | ||
1351 | .update_status = set_brightness_status, | ||
1352 | .max_brightness = 15, | ||
1353 | }; | ||
1354 | |||
1355 | static void __exit asus_acpi_exit(void) | ||
1356 | { | ||
1357 | if (asus_backlight_device) | ||
1358 | backlight_device_unregister(asus_backlight_device); | ||
1359 | |||
1360 | acpi_bus_unregister_driver(&asus_hotk_driver); | ||
1361 | remove_proc_entry(PROC_ASUS, acpi_root_dir); | ||
1362 | |||
1363 | kfree(asus_info); | ||
1364 | |||
1365 | return; | ||
1366 | } | ||
1367 | |||
1336 | static int __init asus_acpi_init(void) | 1368 | static int __init asus_acpi_init(void) |
1337 | { | 1369 | { |
1338 | int result; | 1370 | int result; |
@@ -1370,17 +1402,15 @@ static int __init asus_acpi_init(void) | |||
1370 | return result; | 1402 | return result; |
1371 | } | 1403 | } |
1372 | 1404 | ||
1373 | return 0; | 1405 | asus_backlight_device = backlight_device_register("asus", NULL, |
1374 | } | 1406 | &asus_backlight_data); |
1375 | 1407 | if (IS_ERR(asus_backlight_device)) { | |
1376 | static void __exit asus_acpi_exit(void) | 1408 | printk(KERN_ERR "Could not register asus backlight device\n"); |
1377 | { | 1409 | asus_backlight_device = NULL; |
1378 | acpi_bus_unregister_driver(&asus_hotk_driver); | 1410 | asus_acpi_exit(); |
1379 | remove_proc_entry(PROC_ASUS, acpi_root_dir); | 1411 | } |
1380 | |||
1381 | kfree(asus_info); | ||
1382 | 1412 | ||
1383 | return; | 1413 | return 0; |
1384 | } | 1414 | } |
1385 | 1415 | ||
1386 | module_init(asus_acpi_init); | 1416 | module_init(asus_acpi_init); |