[PATCH] Change backlight intensity to range 0-255

Balaji Rao balajirrao at openmoko.org
Wed Oct 22 10:04:45 CEST 2008


On Wed, Oct 22, 2008 at 05:14:16AM +0100, Andy Green wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Somebody in the thread at some point said:
>
> | 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
>
> Can you update Balaji-tracking so I can take that into stable and apply
> this?  It seems to be on top of things I don't have.
>

Since this patch depends on the new backlight patch, It won't apply on
stable. And with this patch stable-tracking won't even boot. So, all
this is currently on top of andy-tracking and will remain so until
I see the resume dependency stuff in stable-tracking replaced with
a proper device relationship patch in andy-tracking.

So, I've made a new patch that applies on stable.

Signed-off-by: Balaji Rao <balajirrao at openmoko.org>

diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
index 490e34d..ff151be 100644
--- a/drivers/i2c/chips/pcf50633.c
+++ b/drivers/i2c/chips/pcf50633.c
@@ -121,6 +121,7 @@ struct pcf50633_data {
 	struct i2c_client client;
 	struct pcf50633_platform_data *pdata;
 	struct backlight_device *backlight;
+	int backlight_intensity;
 	struct mutex lock;
 	unsigned int flags;
 	unsigned int working;
@@ -1897,12 +1898,8 @@ static struct rtc_class_ops pcf50633_rtc_ops = {
 static int pcf50633bl_get_intensity(struct backlight_device *bd)
 {
 	struct pcf50633_data *pcf = bl_get_data(bd);
-	int intensity = reg_read(pcf, PCF50633_REG_LEDOUT);
 
-	if (!(reg_read(pcf, PCF50633_REG_LEDENA) & 1))
-		intensity = 0;
-
-	return intensity & 0x3f;
+	return pcf->backlight_intensity;
 }
 
 static int __pcf50633bl_set_intensity(struct pcf50633_data *pcf, int intensity)
@@ -1913,6 +1910,11 @@ static int __pcf50633bl_set_intensity(struct pcf50633_data *pcf, int intensity)
 	if (!(reg_read(pcf, PCF50633_REG_LEDENA) & 1))
 		old_intensity = 0;
 
+	pcf->backlight_intensity = intensity;
+
+	/* Change the intensity to 0-63 range */
+	intensity >>= 2;
+
 	/*
 	 * The PCF50633 cannot handle LEDOUT = 0 (datasheet p60)
 	 * if seen, you have to re-enable the LED unit
@@ -2244,11 +2246,12 @@ static int pcf50633_detect(struct i2c_adapter *adapter, int address, int kind)
 		if (!pcf->backlight)
 			goto exit_rtc;
 		/* FIXME: are we sure we want default == off? */
-		pcf->backlight->props.max_brightness = 0x3f;
+		pcf->backlight->props.max_brightness = 0xff;
 		pcf->backlight->props.power = FB_BLANK_UNBLANK;
 		pcf->backlight->props.fb_blank = FB_BLANK_UNBLANK;
 		pcf->backlight->props.brightness =
 					pcf->backlight->props.max_brightness;
+		pcf->backlight_intensity = pcf->backlight->props.brightness;
 		backlight_update_status(pcf->backlight);
 	}
 



More information about the openmoko-kernel mailing list