]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.12/thinkpad-acpi-issue-backlight-class-events.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.12 / thinkpad-acpi-issue-backlight-class-events.patch
1 From 347a26860e2293b1347996876d3550499c7bb31f Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Wed, 9 Dec 2009 01:36:24 +0000
4 Subject: thinkpad-acpi: issue backlight class events
5
6 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
7
8 commit 347a26860e2293b1347996876d3550499c7bb31f upstream.
9
10 Take advantage of the new events capabilities of the backlight class to
11 notify userspace of backlight changes.
12
13 This depends on "backlight: Allow drivers to update the core, and
14 generate events on changes", by Matthew Garrett.
15
16 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
17 Cc: Matthew Garrett <mjg@redhat.com>
18 Cc: Richard Purdie <rpurdie@linux.intel.com>
19 Signed-off-by: Len Brown <len.brown@intel.com>
20
21 ---
22 Documentation/laptops/thinkpad-acpi.txt | 51 +++++++-------------------------
23 drivers/platform/x86/thinkpad_acpi.c | 24 ++++++++++++++-
24 2 files changed, 35 insertions(+), 40 deletions(-)
25
26 --- a/Documentation/laptops/thinkpad-acpi.txt
27 +++ b/Documentation/laptops/thinkpad-acpi.txt
28 @@ -460,6 +460,8 @@ event code Key Notes
29 For Lenovo ThinkPads with a new
30 BIOS, it has to be handled either
31 by the ACPI OSI, or by userspace.
32 + The driver does the right thing,
33 + never mess with this.
34 0x1011 0x10 FN+END Brightness down. See brightness
35 up for details.
36
37 @@ -582,46 +584,15 @@ with hotkey_report_mode.
38
39 Brightness hotkey notes:
40
41 -These are the current sane choices for brightness key mapping in
42 -thinkpad-acpi:
43 +Don't mess with the brightness hotkeys in a Thinkpad. If you want
44 +notifications for OSD, use the sysfs backlight class event support.
45
46 -For IBM and Lenovo models *without* ACPI backlight control (the ones on
47 -which thinkpad-acpi will autoload its backlight interface by default,
48 -and on which ACPI video does not export a backlight interface):
49 -
50 -1. Don't enable or map the brightness hotkeys in thinkpad-acpi, as
51 - these older firmware versions unfortunately won't respect the hotkey
52 - mask for brightness keys anyway, and always reacts to them. This
53 - usually work fine, unless X.org drivers are doing something to block
54 - the BIOS. In that case, use (3) below. This is the default mode of
55 - operation.
56 -
57 -2. Enable the hotkeys, but map them to something else that is NOT
58 - KEY_BRIGHTNESS_UP/DOWN or any other keycode that would cause
59 - userspace to try to change the backlight level, and use that as an
60 - on-screen-display hint.
61 -
62 -3. IF AND ONLY IF X.org drivers find a way to block the firmware from
63 - automatically changing the brightness, enable the hotkeys and map
64 - them to KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN, and feed that to
65 - something that calls xbacklight. thinkpad-acpi will not be able to
66 - change brightness in that case either, so you should disable its
67 - backlight interface.
68 -
69 -For Lenovo models *with* ACPI backlight control:
70 -
71 -1. Load up ACPI video and use that. ACPI video will report ACPI
72 - events for brightness change keys. Do not mess with thinkpad-acpi
73 - defaults in this case. thinkpad-acpi should not have anything to do
74 - with backlight events in a scenario where ACPI video is loaded:
75 - brightness hotkeys must be disabled, and the backlight interface is
76 - to be kept disabled as well. This is the default mode of operation.
77 -
78 -2. Do *NOT* load up ACPI video, enable the hotkeys in thinkpad-acpi,
79 - and map them to KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN. Process
80 - these keys on userspace somehow (e.g. by calling xbacklight).
81 - The driver will do this automatically if it detects that ACPI video
82 - has been disabled.
83 +The driver will issue KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN events
84 +automatically for the cases were userspace has to do something to
85 +implement brightness changes. When you override these events, you will
86 +either fail to handle properly the ThinkPads that require explicit
87 +action to change backlight brightness, or the ThinkPads that require
88 +that no action be taken to work properly.
89
90
91 Bluetooth
92 @@ -1465,3 +1436,5 @@ Sysfs interface changelog:
93 and it is always able to disable hot keys. Very old
94 thinkpads are properly supported. hotkey_bios_mask
95 is deprecated and marked for removal.
96 +
97 +0x020600: Marker for backlight change event support.
98 --- a/drivers/platform/x86/thinkpad_acpi.c
99 +++ b/drivers/platform/x86/thinkpad_acpi.c
100 @@ -22,7 +22,7 @@
101 */
102
103 #define TPACPI_VERSION "0.23"
104 -#define TPACPI_SYSFS_VERSION 0x020500
105 +#define TPACPI_SYSFS_VERSION 0x020600
106
107 /*
108 * Changelog:
109 @@ -6083,6 +6083,12 @@ static int brightness_get(struct backlig
110 return status & TP_EC_BACKLIGHT_LVLMSK;
111 }
112
113 +static void tpacpi_brightness_notify_change(void)
114 +{
115 + backlight_force_update(ibm_backlight_device,
116 + BACKLIGHT_UPDATE_HOTKEY);
117 +}
118 +
119 static struct backlight_ops ibm_backlight_data = {
120 .get_brightness = brightness_get,
121 .update_status = brightness_update_status,
122 @@ -6237,6 +6243,12 @@ static int __init brightness_init(struct
123 ibm_backlight_device->props.brightness = b & TP_EC_BACKLIGHT_LVLMSK;
124 backlight_update_status(ibm_backlight_device);
125
126 + vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_BRGHT,
127 + "brightness: registering brightness hotkeys "
128 + "as change notification\n");
129 + tpacpi_hotkey_driver_mask_set(hotkey_driver_mask
130 + | TP_ACPI_HKEY_BRGHTUP_MASK
131 + | TP_ACPI_HKEY_BRGHTDWN_MASK);;
132 return 0;
133 }
134
135 @@ -6313,6 +6325,9 @@ static int brightness_write(char *buf)
136 * Doing it this way makes the syscall restartable in case of EINTR
137 */
138 rc = brightness_set(level);
139 + if (!rc && ibm_backlight_device)
140 + backlight_force_update(ibm_backlight_device,
141 + BACKLIGHT_UPDATE_SYSFS);
142 return (rc == -EINTR)? -ERESTARTSYS : rc;
143 }
144
145 @@ -7712,6 +7727,13 @@ static struct ibm_struct fan_driver_data
146 */
147 static void tpacpi_driver_event(const unsigned int hkey_event)
148 {
149 + if (ibm_backlight_device) {
150 + switch (hkey_event) {
151 + case TP_HKEY_EV_BRGHT_UP:
152 + case TP_HKEY_EV_BRGHT_DOWN:
153 + tpacpi_brightness_notify_change();
154 + }
155 + }
156 }
157
158