mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Danny Baumann <dannybaumann@web.de>
To: linux-acpi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Zhang Rui <rui.zhang@intel.com>,
	Len Brown <lenb@kernel.org>, Danny Baumann <dannybaumann@web.de>
Subject: [PATCH 3/3] ACPI video: Fix applying indexed initial brightness value.
Date: Thu, 14 Mar 2013 11:34:24 +0100	[thread overview]
Message-ID: <1363257264-15984-4-git-send-email-dannybaumann@web.de> (raw)
In-Reply-To: <1363257264-15984-1-git-send-email-dannybaumann@web.de>

The value initially read via _BQC also needs to be offset by 2 to
compensate for the first 2 special items in _BCL. Introduce a helper
function to do the conversion in order to not needlessly duplicate code.
---
 drivers/acpi/video.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index d0fade7..562ccc3 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -450,6 +450,16 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
 	{}
 };
 
+static unsigned long long
+acpi_video_index_to_level(struct acpi_video_device *device,
+			  unsigned long long index)
+{
+	if (device->brightness->flags._BCL_reversed)
+		index = device->brightness->count - 3 - index;
+
+	return device->brightness->levels[index + 2];
+}
+
 static int
 acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
 					unsigned long long *level, int init)
@@ -472,13 +482,10 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
 				return 0;
 			}
 
-			if (device->brightness->flags._BQC_use_index) {
-				if (device->brightness->flags._BCL_reversed)
-					*level = device->brightness->count
-								 - 3 - (*level);
-				*level = device->brightness->levels[*level + 2];
+			if (device->brightness->flags._BQC_use_index)
+				*level = acpi_video_index_to_level(device,
+								   *level);
 
-			}
 			*level += bqc_offset_aml_bug_workaround;
 			for (i = 2; i < device->brightness->count; i++)
 				if (device->brightness->levels[i] == *level) {
@@ -742,9 +749,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
 				}
 		}
 	} else {
-		if (br->flags._BCL_reversed)
-			level_old = (br->count - 1) - level_old;
-		level = br->levels[level_old];
+		level = acpi_video_index_to_level(device, level_old);
 	}
 
 set_level:
-- 
1.8.1.4


  parent reply	other threads:[~2013-03-14 10:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-14 10:34 [PATCH 0/3] ACPI video: Fix brightness control initialization sequence Danny Baumann
2013-03-14 10:34 ` [PATCH 1/3] ACPI video: Fix brightness control initialization for some laptops Danny Baumann
2013-03-15  8:38   ` Aaron Lu
2013-03-14 10:34 ` [PATCH 2/3] ACPI video: Make logic a little easier to understand Danny Baumann
2013-03-15  8:39   ` Aaron Lu
2013-03-14 10:34 ` Danny Baumann [this message]
2013-03-15  8:48   ` [PATCH 3/3] ACPI video: Fix applying indexed initial brightness value Aaron Lu
2013-03-15  8:55     ` Danny Baumann
2013-03-15  9:01       ` Aaron Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1363257264-15984-4-git-send-email-dannybaumann@web.de \
    --to=dannybaumann@web.de \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®