From patchwork Wed Sep 30 19:48:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Bader X-Patchwork-Id: 34619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 583E9B7BAA for ; Thu, 1 Oct 2009 05:49:27 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.60) (envelope-from ) id 1Mt5Av-0002q9-Es; Wed, 30 Sep 2009 20:49:21 +0100 Received: from adelie.canonical.com ([91.189.90.139]) by chlorine.canonical.com with esmtp (Exim 4.60) (envelope-from ) id 1Mt5A0-0002bM-Ve for kernel-team@lists.canonical.com; Wed, 30 Sep 2009 20:48:25 +0100 Received: from hutte.canonical.com ([91.189.90.181]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1Mt5A0-0004Z4-11 for ; Wed, 30 Sep 2009 20:48:24 +0100 Received: from p5b2e4121.dip.t-dialin.net ([91.46.65.33] helo=canonical.com) by hutte.canonical.com with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Mt59z-0005Oe-NO for kernel-team@lists.canonical.com; Wed, 30 Sep 2009 20:48:24 +0100 From: Stefan Bader To: kernel-team@lists.canonical.com Subject: [PATCH 2/2] ACPI video: work-around BIOS AML bug in _BQC Date: Wed, 30 Sep 2009 21:48:25 +0200 Message-Id: <1254340105-19372-3-git-send-email-stefan.bader@canonical.com> X-Mailer: git-send-email 1.5.6.3 In-Reply-To: <1254340105-19372-1-git-send-email-stefan.bader@canonical.com> References: <1254340105-19372-1-git-send-email-stefan.bader@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.8 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Zhang Rui BugLink: https://bugs.launchpad.net/bugs/428910 commit 90c53ca426cb93d15eefea79dcf6bd15ad3ffeb4 upstream _BQC on some laptops returns an uninitialized value when it's invoked for the first time. Set the laptop to the maximum backlight level in this case. http://bugzilla.kernel.org/attachment.cgi?id=22675 Signed-off-by: Zhang Rui Signed-off-by: Len Brown Signed-off-by: Stefan Bader --- drivers/acpi/video.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 57abb8c..54c6942 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -878,7 +878,7 @@ acpi_video_init_brightness(struct acpi_video_device *device) br->flags._BCM_use_index = br->flags._BCL_use_index; /* _BQC uses INDEX while _BCL uses VALUE in some laptops */ - br->curr = level_old = max_level; + br->curr = level = max_level; if (!device->cap._BQC) goto set_level; @@ -900,15 +900,25 @@ acpi_video_init_brightness(struct acpi_video_device *device) br->flags._BQC_use_index = (level == max_level ? 0 : 1); - if (!br->flags._BQC_use_index) + if (!br->flags._BQC_use_index) { + /* + * Set the backlight to the initial state. + * On some buggy laptops, _BQC returns an uninitialized value + * when invoked for the first time, i.e. level_old is invalid. + * set the backlight to max_level in this case + */ + for (i = 2; i < br->count; i++) + if (level_old == br->levels[i]) + level = level_old; goto set_level; + } if (br->flags._BCL_reversed) level_old = (br->count - 1) - level_old; - level_old = br->levels[level_old]; + level = br->levels[level_old]; set_level: - result = acpi_video_device_lcd_set_level(device, level_old); + result = acpi_video_device_lcd_set_level(device, level); if (result) goto out_free_levels;