Add generic backlight support to toshiba_acpi driver
PATCH 1/1 Add generic backlight support to toshiba_acpi driver
The included patch adds support for interacting with the toshiba_acpi backlight control through the generic backlight interface (/sys/class/backlight).
ACPI folk: this gives us the benefit of a consistent interface to LCD brightness. Is it worth me converting the other drivers over?
drivers/acpi/Kconfig +1 -1
@@ -215,7 +215,7 @@ config ACPI_IBM config ACPI_TOSHIBA tristate "Toshiba Laptop Extras" - depends on X86 + depends on X86 && BACKLIGHT_DEVICE default y ---help--- This driver adds support for access to certain system settings
drivers/acpi/toshiba_acpi.c +47 -0
89 lines not on this page · raw message
Signature · 1 line
Matthew Garrett | [email protected]
Hi!
Quoted 6 lines
The included patch adds support for interacting with the
toshiba_acpibacklight control through the generic backlight interface (/sys/class/backlight).ACPI folk: this gives us the benefit of a consistent interface to LCD brightness. Is it worth me converting the other drivers over?
Not sure if I'm ACPI folk but yes, consistent interface would be nice.
Pavel
Signature · 1 line
Web maintainer for suspend.sf.net (www.sf.net/projects/suspend) wanted...
Quoted 9 lines
Quoted 6 lines
The included patch adds support for interacting with the
toshiba_acpibacklight control through the generic backlight interface (/sys/class/backlight).ACPI folk: this gives us the benefit of a consistent interface to LCD brightness. Is it worth me converting the other drivers over?
Not sure if I'm ACPI folk but yes, consistent interface would be nice.
Note to self: Don't forget to change 2.6-sony-acpi?.diff from -mm to use this /sys/class/backlight instead of /proc/acpi/sony/brightness when it's ready.
Jan Engelhardt
Quoted 3 lines · Jan Engelhardt
Note to self: Don't forget to change 2.6-sony-acpi?.diff from -mm to use this
/sys/class/backlightinstead of/proc/acpi/sony/brightnesswhen it's ready.
Ah, you're maintaining that now. Here you go (Stelian took a look and seemed happy with it - the /sys/class/backlight stuff is in mainstream)
drivers/acpi/sony_acpi.c +41 -0
@@ -27,6 +27,8 @@#include <linux/moduleparam.h> #include <linux/init.h> #include <linux/types.h> +#include <linux/backlight.h> +#include <linux/err.h> #include <acpi/acpi_drivers.h> #include <acpi/acpi_bus.h> #include <asm/uaccess.h>
@@ -62,6 +64,8 @@ static struct acpi_driver sony_acpi_drivstatic acpi_handle sony_acpi_handle;static struct proc_dir_entry *sony_acpi_dir; +static struct backlight_device *sony_backlight_device; + static struct sony_acpi_value { char *name; /* name of the entry */ struct proc_dir_entry *proc; /* /proc entry */
@@ -258,6 +262,31 @@ static acpi_status sony_walk_callback(acreturn AE_OK ; } +static int sony_brightness_get (struct backlight_device *bd) +{ +int value; + +if (acpi_callgetfunc (sony_acpi_handle,"GBRT" , &value)) +return 0 ; + +return value-1 ; +} + + +static int sony_brightness_set (struct backlight_device *bd,int value) { + value &=0x7 ; + value++; + +return acpi_callsetfunc (sony_acpi_handle,"SBRT" , value,NULL ); +} + +static struct backlight_properties sonybl_data = { + .owner =THIS_MODULE , + .get_brightness = sony_brightness_get, + .set_brightness = sony_brightness_set, + .max_brightness =7 , +}; +static int __init sony_acpi_add (struct acpi_device *device) {acpi_status status;
@@ -378,12 +407,24 @@ static int __init sony_acpi_init(void)remove_proc_entry ("sony" , acpi_root_dir);return -ENODEV ; } + + sony_backlight_device =backlight_device_register ("sony_bl" ,NULL , + &sonybl_data); + +if (IS_ERR (sony_backlight_device)) { +printk ("Unable to register backlight\n" ); +acpi_bus_unregister_driver (&sony_acpi_driver); +remove_proc_entry ("sony" , acpi_root_dir); +return -ENODEV ; + } +return 0 ; } static void __exit sony_acpi_exit(void) { +backlight_device_unregister (sony_backlight_device);acpi_bus_unregister_driver (&sony_acpi_driver);remove_proc_entry ("sony" , acpi_root_dir); }
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 8 lines
Quoted 4 lines
Note to self: Don't forget to change 2.6-sony-acpi?.diff from -mm to use this
/sys/class/backlightinstead of/proc/acpi/sony/brightnesswhen it's ready.Ah, you're maintaining that now. Here you go (Stelian took a look and seemed happy with it - the
/sys/class/backlightstuff is in mainstream)
Well, I am not. At least not-yet-officially. But since I happen to have that hardware, I use it. (And I even have to postpatch the SUSE KOTD ATM to get there, heh, heh.)
Jan Engelhardt
drivers/acpi/Kconfig config ACPI_IBM · line 221
Quoted 11 lines · Matthew Garrett
drivers/acpi/Kconfig +1
-1@@ -215,7 +215,7 @@ config ACPI_IBM config ACPI_TOSHIBA tristate "Toshiba Laptop Extras" - depends on X86 + depends on X86 && BACKLIGHT_DEVICE default y ---help--- This driver adds support for access to certain system settings
Might this work better:
config ACPI_TOSHIBA
depends on X86
select BACKLIGHT_DEVICE
-
-Ben
Signature · 4 lines
Ben Slusky | It was only after their population [email protected] | of 50 mysteriously shrank to eight [email protected] | that the other seven dwarfs began PGP keyID ADA44B3B | to suspect Hungry.