From patchwork Mon Aug 31 06:39:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 44806 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 n7V6bgvN018654 for ; Mon, 31 Aug 2009 06:41:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754519AbZHaGl0 (ORCPT ); Mon, 31 Aug 2009 02:41:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754520AbZHaGl0 (ORCPT ); Mon, 31 Aug 2009 02:41:26 -0400 Received: from mga11.intel.com ([192.55.52.93]:7957 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754519AbZHaGl0 (ORCPT ); Mon, 31 Aug 2009 02:41:26 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 30 Aug 2009 23:30:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.44,303,1249282800"; d="scan'208";a="722437479" Received: from rzhang-dt.sh.intel.com (HELO [10.239.36.60]) ([10.239.36.60]) by fmsmga001.fm.intel.com with ESMTP; 30 Aug 2009 23:44:31 -0700 Subject: [PATCH] ACPI video: workaround buggy _BQC method that exports uninitialized value From: Zhang Rui To: Len Brown Cc: linux-acpi , "Zhang, Rui" , alain57@gmail.com Date: Mon, 31 Aug 2009 14:39:26 +0800 Message-Id: <1251700766.3483.137.camel@rzhang-dt> Mime-Version: 1.0 X-Mailer: Evolution 2.22.1 (2.22.1-2.fc9) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org _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/show_bug.cgi?id=13955 Signed-off-by: Zhang Rui --- drivers/acpi/video.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/acpi/video.c =================================================================== --- linux-2.6.orig/drivers/acpi/video.c +++ linux-2.6/drivers/acpi/video.c @@ -870,7 +870,7 @@ acpi_video_init_brightness(struct acpi_v 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; @@ -892,15 +892,25 @@ acpi_video_init_brightness(struct acpi_v 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;