From patchwork Tue Mar 10 08:03:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 10823 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 n2A82Z4l026811 for ; Tue, 10 Mar 2009 08:02:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752985AbZCJICm (ORCPT ); Tue, 10 Mar 2009 04:02:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753069AbZCJICm (ORCPT ); Tue, 10 Mar 2009 04:02:42 -0400 Received: from mga03.intel.com ([143.182.124.21]:19009 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752985AbZCJICl (ORCPT ); Tue, 10 Mar 2009 04:02:41 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 10 Mar 2009 01:02:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,335,1233561600"; d="scan'208";a="118570331" Received: from rzhang-dt.sh.intel.com (HELO [10.239.36.218]) ([10.239.36.218]) by azsmga001.ch.intel.com with ESMTP; 10 Mar 2009 01:02:37 -0700 Subject: [RFC PATCH 4/5] ACPI video: support reversed _BCL method From: Zhang Rui To: linux-acpi Cc: Len Brown , Thomas Renninger , Matthew Garrett , "Zhang, Rui" Date: Tue, 10 Mar 2009 16:03:31 +0800 Message-Id: <1236672211.2820.122.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 Subject: support reversed _BCL method in ACPI video driver From: Zhang Rui The brightness levels returned by _BCL package are in a reversed order on some laptops. http://bugzilla.kernel.org/show_bug.cgi?id=12037 http://bugzilla.kernel.org/show_bug.cgi?id=12302 http://bugzilla.kernel.org/show_bug.cgi?id=12235 sort the _BCL packge in case it's reversed. Signed-off-by: Zhang Rui Acked-by: Matthew Garrett --- drivers/acpi/video.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 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 @@ -170,6 +170,7 @@ struct acpi_video_device_cap { struct acpi_video_brightness_flags { u8 _BCL_no_ac_battery_levels:1; /* no AC/Battery levels in _BCL */ + u8 _BCL_reversed:1; /* _BCL package is in a reversed order*/ }; struct acpi_video_device_brightness { @@ -746,9 +747,16 @@ acpi_video_init_brightness(struct acpi_v count += level_ac_battery; } - /* don't sort the first two brightness levels */ - sort(&br->levels[2], count - 2, sizeof(br->levels[2]), - acpi_video_cmp_level, NULL); + /* Check if the _BCL package is in a reversed order */ + if (max_level == br->levels[2]) { + br->flags._BCL_reversed = 1; + sort(&br->levels[2], count - 2, sizeof(br->levels[2]), + acpi_video_cmp_level, NULL); + } else if (max_level != br->levels[count - 1]) { + ACPI_ERROR((AE_INFO, + "Brightness levels in _BCL is in a mess\n")); + goto out_free_levels; + } br->count = count; device->brightness = br;