Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e11e211a0b21bbb625fac2056bdb54dd02020556
Commit:     e11e211a0b21bbb625fac2056bdb54dd02020556
Parent:     87cc537a54fc017d998cf603f5fab9ca4a85d668
Author:     Henrique de Moraes Holschuh <[EMAIL PROTECTED]>
AuthorDate: Tue Oct 30 17:46:22 2007 -0200
Committer:  Len Brown <[EMAIL PROTECTED]>
CommitDate: Mon Nov 5 13:07:11 2007 -0500

    ACPI: thinkpad-acpi: prefer standard ACPI backlight level control
    
    Newer Lenovo BIOSes support the standard ACPI backlight brightness
    interface (_BCM, _BQC, _BCL).  It should be used instead of the native
    thinkpad backlight brightness control interface when possible.
    
    This patch disables the native brightness support in the driver by default
    when we detect that the standard ACPI interface is available.  The local
    admin can still enable it using the module parameter "brightness_enable".
    
    Note that we need to detect the standard ACPI backlight interface only in
    boxes for which we would load the native backlight interface in the first
    place, and that no ThinkPad BIOS has _BCL but misses the other methods, so
    the detection routines can be really simple.
    
    Signed-off-by: Henrique de Moraes Holschuh <[EMAIL PROTECTED]>
    Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 Documentation/thinkpad-acpi.txt |    8 ++++++--
 drivers/misc/thinkpad_acpi.c    |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index f877c13..bb1c7a6 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -942,11 +942,15 @@ and CMOS.  The driver tries to autodetect which interface 
to use.
 
 When display backlight brightness controls are available through the
 standard ACPI interface, it is best to use it instead of this direct
-ThinkPad-specific interface.
+ThinkPad-specific interface.  The driver will disable its native
+backlight brightness control interface if it detects that the standard
+ACPI interface is available in the ThinkPad.
 
 The brightness_enable module parameter can be used to control whether
 the LCD brightness control feature will be enabled when available.
-brightness_enable=0 forces it to be disabled.
+brightness_enable=0 forces it to be disabled.  brightness_enable=1
+forces it to be enabled when available, even if the standard ACPI
+interface is also available.
 
 Procfs notes:
 
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 56a21e6..109bd27 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -3174,6 +3174,39 @@ static int __init brightness_check_levels(void)
        return (ACPI_SUCCESS(status) && found_node != NULL);
 }
 
+static acpi_status __init brightness_find_bcl(acpi_handle handle, u32 lvl,
+                                       void *context, void **rv)
+{
+       char name[ACPI_PATH_SEGMENT_LENGTH];
+       struct acpi_buffer buffer = { sizeof(name), &name };
+
+       if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) &&
+           !strncmp("_BCL", name, sizeof(name) - 1)) {
+               *rv = handle;
+               return AE_CTRL_TERMINATE;
+       } else {
+               return AE_OK;
+       }
+}
+
+static int __init brightness_check_std_acpi_support(void)
+{
+       int status;
+       void *found_node = NULL;
+
+       if (!vid_handle) {
+               IBM_ACPIHANDLE_INIT(vid);
+       }
+       if (!vid_handle)
+               return 0;
+
+       /* Search for a _BCL method, but don't execute it */
+       status = acpi_walk_namespace(ACPI_TYPE_METHOD, vid_handle, 3,
+                                    brightness_find_bcl, NULL, &found_node);
+
+       return (ACPI_SUCCESS(status) && found_node != NULL);
+}
+
 static int __init brightness_init(struct ibm_init_struct *iibm)
 {
        int b;
@@ -3186,6 +3219,12 @@ static int __init brightness_init(struct ibm_init_struct 
*iibm)
                dbg_printk(TPACPI_DBG_INIT,
                           "brightness support disabled by module parameter\n");
                return 1;
+       } else if (brightness_enable > 1) {
+               if (brightness_check_std_acpi_support()) {
+                       printk(IBM_NOTICE
+                              "standard ACPI backlight interface available, 
not loading native one...\n");
+                       return 1;
+               }
        }
 
        if (!brightness_mode) {
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to