public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Stubbs <jasonbstubbs@gmail.com>
To: Greg KH <greg@kroah.com>
Cc: Greg KH <gregkh@suse.de>, linux-kernel@vger.kernel.org
Subject: [PATCH] platform: samsung_laptop: fix samsung brightness min/max calculations
Date: Mon, 20 Jun 2011 07:23:19 +1000	[thread overview]
Message-ID: <201106200723.20173.jasonbstubbs@gmail.com> (raw)
In-Reply-To: <20110613235549.GA14762@kroah.com>

From: Jason Stubbs <jasonbstubbs@gmail.com>

The min_brightness value of the sabi_config is incorrectly used in brightness
calculations. For the config where min_brightness = 1 and max_brightness = 8,
the user visible range should be 0 to 7 with hardware being set in the range
of 1 to 8. What is actually happening is that the user visible range is 0 to
8 with hardware being set in the range of -1 to 7.

This patch fixes the above issue as well as a miscalculation that would occur
in the case of min_brightness > 1.

Signed-off-by: Jason Stubbs <jasonbstubbs@gmail.com>
---
diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
index 4c78dbc..aad14ab 100644
--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -371,15 +371,17 @@ static u8 read_brightness(void)
 				  &sretval);
 	if (!retval) {
 		user_brightness = sretval.retval[0];
-		if (user_brightness != 0)
+		if (user_brightness > sabi_config->min_brightness)
 			user_brightness -= sabi_config->min_brightness;
+		else
+			user_brightness = 0;
 	}
 	return user_brightness;
 }
 
 static void set_brightness(u8 user_brightness)
 {
-	u8 user_level = user_brightness - sabi_config->min_brightness;
+	u8 user_level = user_brightness + sabi_config->min_brightness;
 
 	if (has_stepping_quirk && user_level != 0) {
 		/*
@@ -834,7 +836,8 @@ static int __init samsung_init(void)
 	/* create a backlight device to talk to this one */
 	memset(&props, 0, sizeof(struct backlight_properties));
 	props.type = BACKLIGHT_PLATFORM;
-	props.max_brightness = sabi_config->max_brightness;
+	props.max_brightness = sabi_config->max_brightness -
+				sabi_config->min_brightness;
 	backlight_device = backlight_device_register("samsung", &sdev->dev,
 						     NULL, &backlight_ops,
 						     &props);

  reply	other threads:[~2011-06-19 21:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-20  3:58 [PATCH] platform: fix samsung brightness min/max calculations Jason Stubbs
2011-04-28  8:55 ` Jason Stubbs
2011-05-10 22:39   ` Greg KH
2011-05-11  4:47     ` Jason Stubbs
2011-05-11 13:51       ` Greg KH
2011-05-12  2:13         ` Jason Stubbs
2011-05-12 16:44           ` Greg KH
2011-05-13 10:44             ` Jason Stubbs
2011-05-13 10:47               ` [PATCH] platform: add support for samsung nc210/nc110 Jason Stubbs
2011-06-13 23:55               ` [PATCH] platform: fix samsung brightness min/max calculations Greg KH
2011-06-19 21:23                 ` Jason Stubbs [this message]
2011-06-19 21:36                 ` Jason Stubbs
2011-08-24 23:11                   ` Greg KH
2011-05-12  2:32         ` Jason Stubbs

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=201106200723.20173.jasonbstubbs@gmail.com \
    --to=jasonbstubbs@gmail.com \
    --cc=greg@kroah.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /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