From patchwork Wed Jul 8 20:16:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 34705 X-Patchwork-Delegate: rui.zhang@intel.com 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 n68KHR4M027586 for ; Wed, 8 Jul 2009 20:17:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756220AbZGHUQ0 (ORCPT ); Wed, 8 Jul 2009 16:16:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756242AbZGHUQ0 (ORCPT ); Wed, 8 Jul 2009 16:16:26 -0400 Received: from marcansoft.com ([80.68.93.119]:49212 "EHLO smtp.marcansoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756220AbZGHUQ0 (ORCPT ); Wed, 8 Jul 2009 16:16:26 -0400 Received: from [192.168.3.171] (85.Red-88-24-251.staticIP.rima-tde.net [88.24.251.85]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.marcansoft.com (Postfix) with ESMTPSA id 207711E8009; Wed, 8 Jul 2009 22:16:24 +0200 (CEST) Message-ID: <4A54FE96.2030407@marcansoft.com> Date: Wed, 08 Jul 2009 22:16:22 +0200 From: Hector Martin User-Agent: Thunderbird 2.0.0.22 (X11/20090701) MIME-Version: 1.0 To: Zhang Rui CC: Len Brown , linux-acpi@vger.kernel.org Subject: [PATCH] disable _BQC/_BCQ if it returns invalid values Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Validate the result of the _BQC or _BCQ method when querying the current backlight level. If the value is out of range, the support for this method is disabled. This does not break functionality as long as the hardware doesn't touch the backlight level on it own, since the driver will just use the last cached value. Acer Aspire 8930G with BIOS v1.10 (latest) has this issue. Signed-off-by: Hector Martin --- linux-2.6.30/drivers/acpi/video.c 2009-07-08 22:04:54.000000000 +0200 +++ linux-2.6.30-mod/drivers/acpi/video.c 2009-07-08 22:12:19.000000000 +0200 @@ -602,15 +605,29 @@ acpi_video_device_lcd_get_level_current( NULL, level); if (ACPI_SUCCESS(status)) { if (device->brightness->flags._BQC_use_index) { + if (*level >= (device->brightness->count - 2)) { + ACPI_WARNING((AE_INFO, + "%s is broken (returned %llu)", + buf, *level)); + device->cap._BQC = device->cap._BCQ = 0; + *level = device->brightness->curr; + return 0; + } if (device->brightness->flags._BCL_reversed) *level = device->brightness->count - 3 - (*level); *level = device->brightness->levels[*level + 2]; } - *level += bqc_offset_aml_bug_workaround; - device->brightness->curr = *level; - return 0; + if (*level > 100) { + ACPI_WARNING((AE_INFO, "%s is broken " + "(returned %llu)", buf, *level)); + device->cap._BQC = device->cap._BCQ = 0; + } else { + *level += bqc_offset_aml_bug_workaround; + device->brightness->curr = *level; + return 0; + } } else { /* Fixme: * should we return an error or ignore this failure?