[UPSTREAM] Move backlight handling out of pcf50633 driver

Balaji Rao balajirrao at openmoko.org
Wed Oct 22 04:21:07 CEST 2008


On Tue, Oct 21, 2008 at 09:46:59PM +0100, Andy Green wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Somebody in the thread at some point said:
> | On Tue, Oct 21, 2008 at 10:04:15AM +0100, Mark Brown wrote:
> |> On Tue, Oct 21, 2008 at 08:41:55AM +0530, Balaji Rao wrote:
> |>
> |>> The voltage change effected by changing the brigtness value in /sys is
> |>> exponential, not linear.. So, the code that assumes that it's going to
> |>> reduce the brightness level by half by making it 30 or so, is actually
> |>> reducing it by 1/6 th.
> |> The human eye doesn't detect brightness linearly so hardware intended
> |> for use in controlling brightness often implements controls with
> |> non-linear values like this - check what the actual effect is for the
> |> user.
> |>
> |
> | I changed to code to scale brigtness linearly between 0-255 and the
> | result was not good. Now I've come to understand that brigtness does not
> | vary linearly with the voltage. :)
>
> Thanks for looking at it Balaji.
>
> What actually happened?  Smoke :?)  If it's simply that the range
> favours darkness or brightness at one end, it doesn't seem to make
> trouble.... the meaning of these brightness numbers to Linux is nowhere
> defined except presumably that there should generally be a monotonic
> increase in brightness with an increase with these numbers.
>

Yes, the values at the end of the range favoured brightness. So a
brightness value of 127 meant much higher brightness than what I
expected.

> Whatever the nonlinear mapping is, it should be unchanged when we map
> 0-255 -> 0-63 by shifting it two places to the right?  That includes the
> halfway point or whatever?

Yes, that's what I have done below and it works well AFAICS.

diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index 2c5d87e..43bcf19 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -1037,6 +1037,9 @@ static void gta02_bl_set_intensity(int intensity)
 	u_int8_t ledena = 2;
 	int ret;
 
+	/* Change the intensity range to 0-63 */
+	intensity >>= 2;
+
 	if (old_intensity == intensity)
 		return;
 
@@ -1067,8 +1070,8 @@ static void gta02_bl_set_intensity(int intensity)
 
 static struct generic_bl_info gta02_bl_info = {
 	.name 			= "gta02-bl",
-	.max_intensity 		= 0x3f,
-	.default_intensity 	= 0x3f,
+	.max_intensity 		= 0xff,
+	.default_intensity 	= 0xff,
 	.set_bl_intensity 	= gta02_bl_set_intensity,
 };
 



More information about the openmoko-kernel mailing list