[lkml]   [2010]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[066/197] thinkpad-acpi: issue backlight class events
2.6.32-stable review patch.  If anyone has any objections, please let us know.


From: Henrique de Moraes Holschuh <>

commit 347a26860e2293b1347996876d3550499c7bb31f upstream.

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 <>
Cc: Matthew Garrett <>
Cc: Richard Purdie <>
Signed-off-by: Len Brown <>

Documentation/laptops/thinkpad-acpi.txt | 51 +++++++-------------------------
drivers/platform/x86/thinkpad_acpi.c | 24 ++++++++++++++-
2 files changed, 35 insertions(+), 40 deletions(-)

--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -460,6 +460,8 @@ event code Key Notes
For Lenovo ThinkPads with a new
BIOS, it has to be handled either
by the ACPI OSI, or by userspace.
+ The driver does the right thing,
+ never mess with this.
0x1011 0x10 FN+END Brightness down. See brightness
up for details.

@@ -582,46 +584,15 @@ with hotkey_report_mode.

Brightness hotkey notes:

-These are the current sane choices for brightness key mapping in
+Don't mess with the brightness hotkeys in a Thinkpad. If you want
+notifications for OSD, use the sysfs backlight class event support.

-For IBM and Lenovo models *without* ACPI backlight control (the ones on
-which thinkpad-acpi will autoload its backlight interface by default,
-and on which ACPI video does not export a backlight interface):
-1. Don't enable or map the brightness hotkeys in thinkpad-acpi, as
- these older firmware versions unfortunately won't respect the hotkey
- mask for brightness keys anyway, and always reacts to them. This
- usually work fine, unless drivers are doing something to block
- the BIOS. In that case, use (3) below. This is the default mode of
- operation.
-2. Enable the hotkeys, but map them to something else that is NOT
- KEY_BRIGHTNESS_UP/DOWN or any other keycode that would cause
- userspace to try to change the backlight level, and use that as an
- on-screen-display hint.
-3. IF AND ONLY IF drivers find a way to block the firmware from
- automatically changing the brightness, enable the hotkeys and map
- them to KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN, and feed that to
- something that calls xbacklight. thinkpad-acpi will not be able to
- change brightness in that case either, so you should disable its
- backlight interface.
-For Lenovo models *with* ACPI backlight control:
-1. Load up ACPI video and use that. ACPI video will report ACPI
- events for brightness change keys. Do not mess with thinkpad-acpi
- defaults in this case. thinkpad-acpi should not have anything to do
- with backlight events in a scenario where ACPI video is loaded:
- brightness hotkeys must be disabled, and the backlight interface is
- to be kept disabled as well. This is the default mode of operation.
-2. Do *NOT* load up ACPI video, enable the hotkeys in thinkpad-acpi,
- and map them to KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN. Process
- these keys on userspace somehow (e.g. by calling xbacklight).
- The driver will do this automatically if it detects that ACPI video
- has been disabled.
+The driver will issue KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN events
+automatically for the cases were userspace has to do something to
+implement brightness changes. When you override these events, you will
+either fail to handle properly the ThinkPads that require explicit
+action to change backlight brightness, or the ThinkPads that require
+that no action be taken to work properly.

@@ -1465,3 +1436,5 @@ Sysfs interface changelog:
and it is always able to disable hot keys. Very old
thinkpads are properly supported. hotkey_bios_mask
is deprecated and marked for removal.
+0x020600: Marker for backlight change event support.
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -22,7 +22,7 @@

#define TPACPI_VERSION "0.23"
-#define TPACPI_SYSFS_VERSION 0x020500
+#define TPACPI_SYSFS_VERSION 0x020600

* Changelog:
@@ -6083,6 +6083,12 @@ static int brightness_get(struct backlig
return status & TP_EC_BACKLIGHT_LVLMSK;

+static void tpacpi_brightness_notify_change(void)
+ backlight_force_update(ibm_backlight_device,
static struct backlight_ops ibm_backlight_data = {
.get_brightness = brightness_get,
.update_status = brightness_update_status,
@@ -6237,6 +6243,12 @@ static int __init brightness_init(struct
ibm_backlight_device->props.brightness = b & TP_EC_BACKLIGHT_LVLMSK;

+ "brightness: registering brightness hotkeys "
+ "as change notification\n");
+ tpacpi_hotkey_driver_mask_set(hotkey_driver_mask
return 0;

@@ -6313,6 +6325,9 @@ static int brightness_write(char *buf)
* Doing it this way makes the syscall restartable in case of EINTR
rc = brightness_set(level);
+ if (!rc && ibm_backlight_device)
+ backlight_force_update(ibm_backlight_device,
return (rc == -EINTR)? -ERESTARTSYS : rc;

@@ -7712,6 +7727,13 @@ static struct ibm_struct fan_driver_data
static void tpacpi_driver_event(const unsigned int hkey_event)
+ if (ibm_backlight_device) {
+ switch (hkey_event) {
+ tpacpi_brightness_notify_change();
+ }
+ }

 \ /
  Last update: 2010-04-22 22:21    [W:0.653 / U:1.124 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site