diff options
author | Alessandro Guido <alessandro.guido@gmail.com> | 2007-01-13 17:04:34 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-02-13 03:05:35 -0500 |
commit | 50f62afb114ffcf052cf07d4b49b2d148b749955 (patch) | |
tree | e0db235d30af047359a2219faa21e24e91f098ba /drivers | |
parent | fac3506100c19391bc5474084dd838f0fb87bf26 (diff) |
sony_acpi: Add backlight support to the sony_acpi
Make the sony_acpi use the backlight subsystem to adjust brightness value
instead of using the /proc/sony/brightness file. (Other settings will
still have a /proc/sony/... entry)
Signed-off-by: Alessandro Guido <alessandro.guido@gmail.com>
Cc: Stelian Pop <stelian@popies.net>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/acpi/Kconfig | 1 | ||||
-rw-r--r-- | drivers/acpi/sony_acpi.c | 59 |
2 files changed, 48 insertions, 12 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index e11371fb9191..364e6fe8ec35 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -255,6 +255,7 @@ config ACPI_TOSHIBA | |||
255 | config ACPI_SONY | 255 | config ACPI_SONY |
256 | tristate "Sony Laptop Extras" | 256 | tristate "Sony Laptop Extras" |
257 | depends on X86 && ACPI | 257 | depends on X86 && ACPI |
258 | select BACKLIGHT_CLASS_DEVICE | ||
258 | default m | 259 | default m |
259 | ---help--- | 260 | ---help--- |
260 | This mini-driver drives the ACPI SNC device present in the | 261 | This mini-driver drives the ACPI SNC device present in the |
diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c index f323c2c40a11..d509468a58a2 100644 --- a/drivers/acpi/sony_acpi.c +++ b/drivers/acpi/sony_acpi.c | |||
@@ -27,13 +27,19 @@ | |||
27 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/backlight.h> | ||
31 | #include <linux/err.h> | ||
30 | #include <acpi/acpi_drivers.h> | 32 | #include <acpi/acpi_drivers.h> |
31 | #include <acpi/acpi_bus.h> | 33 | #include <acpi/acpi_bus.h> |
32 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
33 | 35 | ||
34 | #define ACPI_SNC_CLASS "sony" | 36 | #define ACPI_SNC_CLASS "sony" |
35 | #define ACPI_SNC_HID "SNY5001" | 37 | #define ACPI_SNC_HID "SNY5001" |
36 | #define ACPI_SNC_DRIVER_NAME "ACPI Sony Notebook Control Driver v0.2" | 38 | #define ACPI_SNC_DRIVER_NAME "ACPI Sony Notebook Control Driver v0.3" |
39 | |||
40 | /* the device uses 1-based values, while the backlight subsystem uses | ||
41 | 0-based values */ | ||
42 | #define SONY_MAX_BRIGHTNESS 8 | ||
37 | 43 | ||
38 | #define LOG_PFX KERN_WARNING "sony_acpi: " | 44 | #define LOG_PFX KERN_WARNING "sony_acpi: " |
39 | 45 | ||
@@ -49,6 +55,16 @@ MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help " | |||
49 | static acpi_handle sony_acpi_handle; | 55 | static acpi_handle sony_acpi_handle; |
50 | static struct proc_dir_entry *sony_acpi_dir; | 56 | static struct proc_dir_entry *sony_acpi_dir; |
51 | 57 | ||
58 | static int sony_backlight_update_status(struct backlight_device *bd); | ||
59 | static int sony_backlight_get_brightness(struct backlight_device *bd); | ||
60 | static struct backlight_device *sony_backlight_device; | ||
61 | static struct backlight_properties sony_backlight_properties = { | ||
62 | .owner = THIS_MODULE, | ||
63 | .update_status = sony_backlight_update_status, | ||
64 | .get_brightness = sony_backlight_get_brightness, | ||
65 | .max_brightness = SONY_MAX_BRIGHTNESS - 1, | ||
66 | }; | ||
67 | |||
52 | static struct sony_acpi_value { | 68 | static struct sony_acpi_value { |
53 | char *name; /* name of the entry */ | 69 | char *name; /* name of the entry */ |
54 | struct proc_dir_entry *proc; /* /proc entry */ | 70 | struct proc_dir_entry *proc; /* /proc entry */ |
@@ -61,19 +77,11 @@ static struct sony_acpi_value { | |||
61 | int debug; /* active only in debug mode ? */ | 77 | int debug; /* active only in debug mode ? */ |
62 | } sony_acpi_values[] = { | 78 | } sony_acpi_values[] = { |
63 | { | 79 | { |
64 | .name = "brightness", | ||
65 | .acpiget = "GBRT", | ||
66 | .acpiset = "SBRT", | ||
67 | .min = 1, | ||
68 | .max = 8, | ||
69 | .debug = 0, | ||
70 | }, | ||
71 | { | ||
72 | .name = "brightness_default", | 80 | .name = "brightness_default", |
73 | .acpiget = "GPBR", | 81 | .acpiget = "GPBR", |
74 | .acpiset = "SPBR", | 82 | .acpiset = "SPBR", |
75 | .min = 1, | 83 | .min = 1, |
76 | .max = 8, | 84 | .max = SONY_MAX_BRIGHTNESS, |
77 | .debug = 0, | 85 | .debug = 0, |
78 | }, | 86 | }, |
79 | { | 87 | { |
@@ -276,6 +284,7 @@ static int sony_acpi_add(struct acpi_device *device) | |||
276 | { | 284 | { |
277 | acpi_status status; | 285 | acpi_status status; |
278 | int result; | 286 | int result; |
287 | acpi_handle handle; | ||
279 | struct sony_acpi_value *item; | 288 | struct sony_acpi_value *item; |
280 | 289 | ||
281 | sony_acpi_handle = device->handle; | 290 | sony_acpi_handle = device->handle; |
@@ -303,9 +312,15 @@ static int sony_acpi_add(struct acpi_device *device) | |||
303 | } | 312 | } |
304 | } | 313 | } |
305 | 314 | ||
306 | for (item = sony_acpi_values; item->name; ++item) { | 315 | if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) { |
307 | acpi_handle handle; | 316 | sony_backlight_device = backlight_device_register("sony", NULL, |
317 | &sony_backlight_properties); | ||
318 | if (IS_ERR(sony_backlight_device)) { | ||
319 | printk(LOG_PFX "unable to register backlight device\n"); | ||
320 | } | ||
321 | } | ||
308 | 322 | ||
323 | for (item = sony_acpi_values; item->name; ++item) { | ||
309 | if (!debug && item->debug) | 324 | if (!debug && item->debug) |
310 | continue; | 325 | continue; |
311 | 326 | ||
@@ -358,6 +373,9 @@ static int sony_acpi_remove(struct acpi_device *device, int type) | |||
358 | acpi_status status; | 373 | acpi_status status; |
359 | struct sony_acpi_value *item; | 374 | struct sony_acpi_value *item; |
360 | 375 | ||
376 | if (sony_backlight_device) | ||
377 | backlight_device_unregister(sony_backlight_device); | ||
378 | |||
361 | if (debug) { | 379 | if (debug) { |
362 | status = acpi_remove_notify_handler(sony_acpi_handle, | 380 | status = acpi_remove_notify_handler(sony_acpi_handle, |
363 | ACPI_DEVICE_NOTIFY, | 381 | ACPI_DEVICE_NOTIFY, |
@@ -375,6 +393,23 @@ static int sony_acpi_remove(struct acpi_device *device, int type) | |||
375 | return 0; | 393 | return 0; |
376 | } | 394 | } |
377 | 395 | ||
396 | static int sony_backlight_update_status(struct backlight_device *bd) | ||
397 | { | ||
398 | return acpi_callsetfunc(sony_acpi_handle, "SBRT", | ||
399 | bd->props->brightness + 1, | ||
400 | NULL); | ||
401 | } | ||
402 | |||
403 | static int sony_backlight_get_brightness(struct backlight_device *bd) | ||
404 | { | ||
405 | int value; | ||
406 | |||
407 | if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value)) | ||
408 | return 0; | ||
409 | /* brightness levels are 1-based, while backlight ones are 0-based */ | ||
410 | return value - 1; | ||
411 | } | ||
412 | |||
378 | static struct acpi_driver sony_acpi_driver = { | 413 | static struct acpi_driver sony_acpi_driver = { |
379 | .name = ACPI_SNC_DRIVER_NAME, | 414 | .name = ACPI_SNC_DRIVER_NAME, |
380 | .class = ACPI_SNC_CLASS, | 415 | .class = ACPI_SNC_CLASS, |