Add patches accepted for 2.6.26-rc1
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.24-rc4 / 0004-ACPI-thinkpad-acpi-prefer-standard-ACPI-backlight.patch
blobd56f1fa64c8d40efefe3495a6b5abb23d7a4355c
1 From e11e211a0b21bbb625fac2056bdb54dd02020556 Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Tue, 30 Oct 2007 17:46:22 -0200
4 Subject: [PATCH 19/23] ACPI: thinkpad-acpi: prefer standard ACPI backlight level control
6 Newer Lenovo BIOSes support the standard ACPI backlight brightness
7 interface (_BCM, _BQC, _BCL). It should be used instead of the native
8 thinkpad backlight brightness control interface when possible.
10 This patch disables the native brightness support in the driver by default
11 when we detect that the standard ACPI interface is available. The local
12 admin can still enable it using the module parameter "brightness_enable".
14 Note that we need to detect the standard ACPI backlight interface only in
15 boxes for which we would load the native backlight interface in the first
16 place, and that no ThinkPad BIOS has _BCL but misses the other methods, so
17 the detection routines can be really simple.
19 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
20 Signed-off-by: Len Brown <len.brown@intel.com>
21 ---
22 Documentation/thinkpad-acpi.txt | 8 ++++++--
23 drivers/misc/thinkpad_acpi.c | 39 +++++++++++++++++++++++++++++++++++++++
24 2 files changed, 45 insertions(+), 2 deletions(-)
26 diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
27 index f877c13..bb1c7a6 100644
28 --- a/Documentation/thinkpad-acpi.txt
29 +++ b/Documentation/thinkpad-acpi.txt
30 @@ -942,11 +942,15 @@ and CMOS. The driver tries to autodetect which interface to use.
32 When display backlight brightness controls are available through the
33 standard ACPI interface, it is best to use it instead of this direct
34 -ThinkPad-specific interface.
35 +ThinkPad-specific interface. The driver will disable its native
36 +backlight brightness control interface if it detects that the standard
37 +ACPI interface is available in the ThinkPad.
39 The brightness_enable module parameter can be used to control whether
40 the LCD brightness control feature will be enabled when available.
41 -brightness_enable=0 forces it to be disabled.
42 +brightness_enable=0 forces it to be disabled. brightness_enable=1
43 +forces it to be enabled when available, even if the standard ACPI
44 +interface is also available.
46 Procfs notes:
48 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
49 index 56a21e6..109bd27 100644
50 --- a/drivers/misc/thinkpad_acpi.c
51 +++ b/drivers/misc/thinkpad_acpi.c
52 @@ -3174,6 +3174,39 @@ static int __init brightness_check_levels(void)
53 return (ACPI_SUCCESS(status) && found_node != NULL);
56 +static acpi_status __init brightness_find_bcl(acpi_handle handle, u32 lvl,
57 + void *context, void **rv)
59 + char name[ACPI_PATH_SEGMENT_LENGTH];
60 + struct acpi_buffer buffer = { sizeof(name), &name };
62 + if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) &&
63 + !strncmp("_BCL", name, sizeof(name) - 1)) {
64 + *rv = handle;
65 + return AE_CTRL_TERMINATE;
66 + } else {
67 + return AE_OK;
68 + }
71 +static int __init brightness_check_std_acpi_support(void)
73 + int status;
74 + void *found_node = NULL;
76 + if (!vid_handle) {
77 + IBM_ACPIHANDLE_INIT(vid);
78 + }
79 + if (!vid_handle)
80 + return 0;
82 + /* Search for a _BCL method, but don't execute it */
83 + status = acpi_walk_namespace(ACPI_TYPE_METHOD, vid_handle, 3,
84 + brightness_find_bcl, NULL, &found_node);
86 + return (ACPI_SUCCESS(status) && found_node != NULL);
89 static int __init brightness_init(struct ibm_init_struct *iibm)
91 int b;
92 @@ -3186,6 +3219,12 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
93 dbg_printk(TPACPI_DBG_INIT,
94 "brightness support disabled by module parameter\n");
95 return 1;
96 + } else if (brightness_enable > 1) {
97 + if (brightness_check_std_acpi_support()) {
98 + printk(IBM_NOTICE
99 + "standard ACPI backlight interface available, not loading native one...\n");
100 + return 1;
104 if (!brightness_mode) {
106 1.5.3.4