Skip to contentSkip to conversation

spitz backlight: fix brightness limiting

PATCH Pavel Machek 3 participants 7 messages Oct 19, 2009 – Oct 23, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

On spitz (& similar) machines, if battery is running low, backlight needs to be limited to lower step. Unfortunately, current code uses &= for limiting, turning backlight off completely for some backlight settings. Fix that.

drivers/video/backlight/corgi_lcd.c +3 -2
@@ -433,8 +434,9 @@
 
 	if (corgibl_flags & CORGIBL_SUSPENDED)
 		intensity = 0;
-	if (corgibl_flags & CORGIBL_BATTLOW)
-		intensity &= lcd->limit_mask;
+
+	if ((corgibl_flags & CORGIBL_BATTLOW) && intensity > lcd->limit_mask)
+		intensity = lcd->limit_mask;
 
 	return corgi_bl_set_intensity(lcd, intensity);
 }
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#1 lore raw

It's a little bit weird it's called 'limit_mask' when I first converted it to a spi driver. There must be some reasons, Richard, you've got any ideas?

Quoted 28 lines · Pavel Machek

On spitz (& similar) machines, if battery is running low, backlight needs to be limited to lower step. Unfortunately, current code uses &= for limiting, turning backlight off completely for some backlight settings. Fix that.

drivers/video/backlight/corgi_lcd.c ? ? ? ?2009-10-16 02:10:13.000000000 +0200 renamed from drivers/video/backlight/corgi_lcd.c ? ? ? ?2009-10-18 18:11:36.000000000 +0200 +3 -3
@@ -433,8 +434,9 @@
 
 ? ? ? ?if (corgibl_flags & CORGIBL_SUSPENDED)
 ? ? ? ? ? ? ? ?intensity = 0;
- ? ? ? if (corgibl_flags & CORGIBL_BATTLOW)
- ? ? ? ? ? ? ? intensity &= lcd->limit_mask;
+
+ ? ? ? if ((corgibl_flags & CORGIBL_BATTLOW) && intensity > lcd->limit_mask)
+ ? ? ? ? ? ? ? intensity = lcd->limit_mask;
 
 ? ? ? ?return corgi_bl_set_intensity(lcd, intensity);
 ?}
 
 
--

(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

#2 lore raw
Quoted 3 lines · Eric Miao

It's a little bit weird it's called 'limit_mask' when I first converted it to a spi driver. There must be some reasons, Richard, you've got any ideas?

Yes, the code was "interesting"...

I can certainly do the rename, but maybe we can fix the issue now and do futher cleanups later?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw
Quoted 9 lines · Pavel Machek
Quoted 3 lines · Eric Miao

It's a little bit weird it's called 'limit_mask' when I first converted it to a spi driver. There must be some reasons, Richard, you've got any ideas?

Yes, the code was "interesting"...

I can certainly do the rename, but maybe we can fix the issue now and do futher cleanups later?

Fair enough, I'm fine with that - I'd like this to go through Richard's backlight tree if possible, though.

#4 lore raw
In reply to Eric Miao
Quoted 3 lines · Eric Miao

It's a little bit weird it's called 'limit_mask' when I first converted it to a spi driver. There must be some reasons, Richard, you've got any ideas?

Its a historical artifact that once worked through some bitfield magic but probably stopped working when we increased the range of values the backlight could accept and we didn't notice the limiting problem.

I'll happily take a patch to fix that.

Cheers,

Richard

#5 lore raw
Quoted 10 lines · Richard Purdie
Quoted 3 lines · Eric Miao

It's a little bit weird it's called 'limit_mask' when I first converted it to a spi driver. There must be some reasons, Richard, you've got any ideas?

Its a historical artifact that once worked through some bitfield magic but probably stopped working when we increased the range of values the backlight could accept and we didn't notice the limiting problem.

I'll happily take a patch to fix that.

Patch is available in the parent post. For now, I just fix it so that it does not turn backlight off when it should not. I'll submit limit_mask -> limit as separate patch, ok?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw
Quoted 10 lines · Pavel Machek
Quoted 9 lines · Richard Purdie
Quoted 3 lines · Eric Miao

It's a little bit weird it's called 'limit_mask' when I first converted it to a spi driver. There must be some reasons, Richard, you've got any ideas?

Its a historical artifact that once worked through some bitfield magic but probably stopped working when we increased the range of values the backlight could accept and we didn't notice the limiting problem.

Quoted 5 lines
Quoted 1 line

I'll happily take a patch to fix that.

Patch is available in the parent post. For now, I just fix it so that it does not turn backlight off when it should not. I'll submit limit_mask -> limit as separate patch, ok?

I'm fine with that. Feel free to.