diff options
| author | Jason Stubbs <jasonbstubbs@gmail.com> | 2011-09-20 12:16:11 -0400 |
|---|---|---|
| committer | Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com> | 2011-11-21 12:54:58 -0500 |
| commit | 35790ae08ab05a6b07557b871556bea4b088a307 (patch) | |
| tree | 30195e17897c75fcbb1160e712588ab7add2a2df /drivers/platform | |
| parent | 11ada83408fefd2464d170ec7dfc5c9f2232e82c (diff) | |
platform: samsung_laptop: fix samsung brightness min/max calculations
BugLink: http://bugs.launchpad.net/bugs/890952
commit bee460be8c691c544e84ed678280ace6153104c6 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Diffstat (limited to 'drivers/platform')
| -rw-r--r-- | drivers/platform/x86/samsung-laptop.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c index ffa7008d0c9..33d3c3f3eb0 100644 --- a/drivers/platform/x86/samsung-laptop.c +++ b/drivers/platform/x86/samsung-laptop.c | |||
| @@ -370,15 +370,17 @@ static u8 read_brightness(void) | |||
| 370 | &sretval); | 370 | &sretval); |
| 371 | if (!retval) { | 371 | if (!retval) { |
| 372 | user_brightness = sretval.retval[0]; | 372 | user_brightness = sretval.retval[0]; |
| 373 | if (user_brightness != 0) | 373 | if (user_brightness > sabi_config->min_brightness) |
| 374 | user_brightness -= sabi_config->min_brightness; | 374 | user_brightness -= sabi_config->min_brightness; |
| 375 | else | ||
| 376 | user_brightness = 0; | ||
| 375 | } | 377 | } |
| 376 | return user_brightness; | 378 | return user_brightness; |
| 377 | } | 379 | } |
| 378 | 380 | ||
| 379 | static void set_brightness(u8 user_brightness) | 381 | static void set_brightness(u8 user_brightness) |
| 380 | { | 382 | { |
| 381 | u8 user_level = user_brightness - sabi_config->min_brightness; | 383 | u8 user_level = user_brightness + sabi_config->min_brightness; |
| 382 | 384 | ||
| 383 | sabi_set_command(sabi_config->commands.set_brightness, user_level); | 385 | sabi_set_command(sabi_config->commands.set_brightness, user_level); |
| 384 | } | 386 | } |
| @@ -819,7 +821,8 @@ static int __init samsung_init(void) | |||
| 819 | /* create a backlight device to talk to this one */ | 821 | /* create a backlight device to talk to this one */ |
| 820 | memset(&props, 0, sizeof(struct backlight_properties)); | 822 | memset(&props, 0, sizeof(struct backlight_properties)); |
| 821 | props.type = BACKLIGHT_PLATFORM; | 823 | props.type = BACKLIGHT_PLATFORM; |
| 822 | props.max_brightness = sabi_config->max_brightness; | 824 | props.max_brightness = sabi_config->max_brightness - |
| 825 | sabi_config->min_brightness; | ||
| 823 | backlight_device = backlight_device_register("samsung", &sdev->dev, | 826 | backlight_device = backlight_device_register("samsung", &sdev->dev, |
| 824 | NULL, &backlight_ops, | 827 | NULL, &backlight_ops, |
| 825 | &props); | 828 | &props); |
