diff options
author | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2009-12-08 20:36:24 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-12-09 15:45:30 -0500 |
commit | 347a26860e2293b1347996876d3550499c7bb31f (patch) | |
tree | edd7781ecd31f9771b8adf4458eecdd6ed0e9607 /drivers | |
parent | 90765c6aee568137521ba19347c744b5abde8161 (diff) |
thinkpad-acpi: issue backlight class events
Take advantage of the new events capabilities of the backlight class to
notify userspace of backlight changes.
This depends on "backlight: Allow drivers to update the core, and
generate events on changes", by Matthew Garrett.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Richard Purdie <rpurdie@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 6160813d906a..44061367a10d 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
@@ -22,7 +22,7 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #define TPACPI_VERSION "0.23" | 24 | #define TPACPI_VERSION "0.23" |
25 | #define TPACPI_SYSFS_VERSION 0x020500 | 25 | #define TPACPI_SYSFS_VERSION 0x020600 |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * Changelog: | 28 | * Changelog: |
@@ -6073,6 +6073,12 @@ static int brightness_get(struct backlight_device *bd) | |||
6073 | return status & TP_EC_BACKLIGHT_LVLMSK; | 6073 | return status & TP_EC_BACKLIGHT_LVLMSK; |
6074 | } | 6074 | } |
6075 | 6075 | ||
6076 | static void tpacpi_brightness_notify_change(void) | ||
6077 | { | ||
6078 | backlight_force_update(ibm_backlight_device, | ||
6079 | BACKLIGHT_UPDATE_HOTKEY); | ||
6080 | } | ||
6081 | |||
6076 | static struct backlight_ops ibm_backlight_data = { | 6082 | static struct backlight_ops ibm_backlight_data = { |
6077 | .get_brightness = brightness_get, | 6083 | .get_brightness = brightness_get, |
6078 | .update_status = brightness_update_status, | 6084 | .update_status = brightness_update_status, |
@@ -6227,6 +6233,12 @@ static int __init brightness_init(struct ibm_init_struct *iibm) | |||
6227 | ibm_backlight_device->props.brightness = b & TP_EC_BACKLIGHT_LVLMSK; | 6233 | ibm_backlight_device->props.brightness = b & TP_EC_BACKLIGHT_LVLMSK; |
6228 | backlight_update_status(ibm_backlight_device); | 6234 | backlight_update_status(ibm_backlight_device); |
6229 | 6235 | ||
6236 | vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_BRGHT, | ||
6237 | "brightness: registering brightness hotkeys " | ||
6238 | "as change notification\n"); | ||
6239 | tpacpi_hotkey_driver_mask_set(hotkey_driver_mask | ||
6240 | | TP_ACPI_HKEY_BRGHTUP_MASK | ||
6241 | | TP_ACPI_HKEY_BRGHTDWN_MASK);; | ||
6230 | return 0; | 6242 | return 0; |
6231 | } | 6243 | } |
6232 | 6244 | ||
@@ -6303,6 +6315,9 @@ static int brightness_write(char *buf) | |||
6303 | * Doing it this way makes the syscall restartable in case of EINTR | 6315 | * Doing it this way makes the syscall restartable in case of EINTR |
6304 | */ | 6316 | */ |
6305 | rc = brightness_set(level); | 6317 | rc = brightness_set(level); |
6318 | if (!rc && ibm_backlight_device) | ||
6319 | backlight_force_update(ibm_backlight_device, | ||
6320 | BACKLIGHT_UPDATE_SYSFS); | ||
6306 | return (rc == -EINTR)? -ERESTARTSYS : rc; | 6321 | return (rc == -EINTR)? -ERESTARTSYS : rc; |
6307 | } | 6322 | } |
6308 | 6323 | ||
@@ -7702,6 +7717,13 @@ static struct ibm_struct fan_driver_data = { | |||
7702 | */ | 7717 | */ |
7703 | static void tpacpi_driver_event(const unsigned int hkey_event) | 7718 | static void tpacpi_driver_event(const unsigned int hkey_event) |
7704 | { | 7719 | { |
7720 | if (ibm_backlight_device) { | ||
7721 | switch (hkey_event) { | ||
7722 | case TP_HKEY_EV_BRGHT_UP: | ||
7723 | case TP_HKEY_EV_BRGHT_DOWN: | ||
7724 | tpacpi_brightness_notify_change(); | ||
7725 | } | ||
7726 | } | ||
7705 | } | 7727 | } |
7706 | 7728 | ||
7707 | 7729 | ||