From patchwork Sat Sep 26 00:57:33 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrique de Moraes Holschuh X-Patchwork-Id: 50201 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8Q0vfZt023738 for ; Sat, 26 Sep 2009 00:57:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751998AbZIZA5g (ORCPT ); Fri, 25 Sep 2009 20:57:36 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752831AbZIZA5g (ORCPT ); Fri, 25 Sep 2009 20:57:36 -0400 Received: from out1.smtp.messagingengine.com ([66.111.4.25]:59175 "EHLO out1.smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751998AbZIZA5f (ORCPT ); Fri, 25 Sep 2009 20:57:35 -0400 Received: from compute2.internal (compute2.internal [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id 4CC2C755C9; Fri, 25 Sep 2009 20:57:39 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute2.internal (MEProxy); Fri, 25 Sep 2009 20:57:39 -0400 X-Sasl-enc: OqzrHq/nwRceCSI9WM6LyINTSwbB0l9nySfpg9gkqBpB 1253926658 Received: from khazad-dum.debian.net (unknown [201.82.170.176]) by mail.messagingengine.com (Postfix) with ESMTPSA id B58E22CCB1; Fri, 25 Sep 2009 20:57:38 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by localhost.khazad-dum.debian.net (Postfix) with ESMTP id DE4BE1001E; Fri, 25 Sep 2009 21:57:34 -0300 (BRT) X-Virus-Scanned: Debian amavisd-new at khazad-dum.debian.net Received: from khazad-dum.debian.net ([127.0.0.1]) by localhost (khazad-dum.debian.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id sXD5bxBQGFKE; Fri, 25 Sep 2009 21:57:33 -0300 (BRT) Received: by khazad-dum.debian.net (Postfix, from userid 1000) id C9F971001D; Fri, 25 Sep 2009 21:57:33 -0300 (BRT) From: Henrique de Moraes Holschuh To: stable@kernel.org Cc: linux-acpi@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net Subject: thinkpad-acpi: fix incorrect use of TPACPI_BRGHT_MODE_ECNVRAM Date: Fri, 25 Sep 2009 21:57:33 -0300 Message-Id: <1253926653-6147-1-git-send-email-hmh@hmh.eng.br> X-Mailer: git-send-email 1.6.4.3 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org HBRV-based default selection of backlight control strategy didn't work well, at least the X41 defines it but doesn't use it and I don't think it will stop there. Switch to a blacklist, and make sure only Radeon- based models get ECNVRAM. Symptoms of incorrect backlight mode selection are: 1. Non-working backlight control through sysfs; 2. Backlight gets reset to the lowest level at every shutdown, reboot and when thinkpad-acpi gets unloaded; This fixes a regression in 2.6.30, bugzilla #13826. This fix is already present on 2.6.31. This is a minimal patch for 2.6.30-stable, based on mainline commits: 050df107c408a3df048524b3783a5fc6d4dccfdb, 7d95a3d564901e88ed42810f054e579874151999, 59fe4fe34d7afdf63208124f313be9056feaa2f4, 6da25bf51689a5cc60370d30275dbb9e6852e0cb Signed-off-by: Henrique de Moraes Holschuh Reported-by: Tobias Diedrich Reported-by: Robert de Rooy --- drivers/platform/x86/thinkpad_acpi.c | 74 ++++++++++++++++++++++++++++------ 1 files changed, 61 insertions(+), 13 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 912be65..7cd6d11 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -286,6 +286,8 @@ struct thinkpad_id_data { u16 bios_model; /* Big Endian, TP-1Y = 0x5931, 0 = unknown */ u16 ec_model; + u16 bios_release; /* 1ZETK1WW = 0x314b, 0 = unknown */ + u16 ec_release; char *model_str; /* ThinkPad T43 */ char *nummodel_str; /* 9384A9C for a 9384-A9C model */ @@ -362,6 +364,45 @@ static void tpacpi_log_usertask(const char * const what) } \ } while (0) +#define TPACPI_MATCH_ANY 0xffffU +#define TPACPI_MATCH_UNKNOWN 0U + +/* TPID('1', 'Y') == 0x5931 */ +#define TPID(__c1, __c2) (((__c2) << 8) | (__c1)) + +#define TPACPI_Q_IBM(__id1, __id2, __quirk) \ + { .vendor = PCI_VENDOR_ID_IBM, \ + .bios = TPID(__id1, __id2), \ + .ec = TPACPI_MATCH_ANY, \ + .quirks = (__quirk) } + +struct tpacpi_quirk { + unsigned int vendor; + u16 bios; + u16 ec; + unsigned long quirks; +}; + +static unsigned long __init tpacpi_check_quirks( + const struct tpacpi_quirk *qlist, + unsigned int qlist_size) +{ + while (qlist_size) { + if ((qlist->vendor == thinkpad_id.vendor || + qlist->vendor == TPACPI_MATCH_ANY) && + (qlist->bios == thinkpad_id.bios_model || + qlist->bios == TPACPI_MATCH_ANY) && + (qlist->ec == thinkpad_id.ec_model || + qlist->ec == TPACPI_MATCH_ANY)) + return qlist->quirks; + + qlist_size--; + qlist++; + } + return 0; +} + + /**************************************************************************** **************************************************************************** * @@ -5757,14 +5798,27 @@ static struct backlight_ops ibm_backlight_data = { /* --------------------------------------------------------------------- */ +#define TPACPI_BRGHT_Q_EC 0x0002 /* Should or must use EC HBRV */ + +static const struct tpacpi_quirk brightness_quirk_table[] __initconst = { + TPACPI_Q_IBM('1', 'Y', TPACPI_BRGHT_Q_EC), + TPACPI_Q_IBM('1', 'Q', TPACPI_BRGHT_Q_EC), + TPACPI_Q_IBM('7', '6', TPACPI_BRGHT_Q_EC), + TPACPI_Q_IBM('7', '8', TPACPI_BRGHT_Q_EC), +}; + static int __init brightness_init(struct ibm_init_struct *iibm) { int b; + unsigned long quirks; vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n"); mutex_init(&brightness_mutex); + quirks = tpacpi_check_quirks(brightness_quirk_table, + ARRAY_SIZE(brightness_quirk_table)); + /* * We always attempt to detect acpi support, so as to switch * Lenovo Vista BIOS to ACPI brightness mode even if we are not @@ -5821,19 +5875,9 @@ static int __init brightness_init(struct ibm_init_struct *iibm) /* TPACPI_BRGHT_MODE_AUTO not implemented yet, just use default */ if (brightness_mode == TPACPI_BRGHT_MODE_AUTO || brightness_mode == TPACPI_BRGHT_MODE_MAX) { - if (thinkpad_id.vendor == PCI_VENDOR_ID_IBM) { - /* - * IBM models that define HBRV probably have - * EC-based backlight level control - */ - if (acpi_evalf(ec_handle, NULL, "HBRV", "qd")) - /* T40-T43, R50-R52, R50e, R51e, X31-X41 */ - brightness_mode = TPACPI_BRGHT_MODE_ECNVRAM; - else - /* all other IBM ThinkPads */ - brightness_mode = TPACPI_BRGHT_MODE_UCMS_STEP; - } else - /* All Lenovo ThinkPads */ + if (quirks & TPACPI_BRGHT_Q_EC) + brightness_mode = TPACPI_BRGHT_MODE_ECNVRAM; + else brightness_mode = TPACPI_BRGHT_MODE_UCMS_STEP; dbg_printk(TPACPI_DBG_BRGHT, @@ -7387,6 +7431,8 @@ static int __must_check __init get_thinkpad_model_data( return 0; tp->bios_model = tp->bios_version_str[0] | (tp->bios_version_str[1] << 8); + tp->bios_release = (tp->bios_version_str[4] << 8) + | tp->bios_version_str[5]; /* * ThinkPad T23 or newer, A31 or newer, R50e or newer, @@ -7407,6 +7453,8 @@ static int __must_check __init get_thinkpad_model_data( return -ENOMEM; tp->ec_model = ec_fw_string[0] | (ec_fw_string[1] << 8); + tp->ec_release = (ec_fw_string[4] << 8) + | ec_fw_string[5]; break; } }