linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] backlight.c: avoid unnecessarily calling backlight_update_status()
@ 2008-01-06 14:29 Helge Deller
  2008-01-13 23:02 ` Richard Purdie
  0 siblings, 1 reply; 2+ messages in thread
From: Helge Deller @ 2008-01-06 14:29 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: rpurdie, Andrew Zabolotny, Jamey Hicks

Every write to the backlight control sysfs entries like (on a Sharp
Zaurus Poodle):
- /sys/class/backlight/locomo-bl/power
- /sys/class/backlight/locomo-bl/brightness
triggers a call of backlight_update_status(), even if the same
value is written multiple times in row into those entries.

In principle this is not critical, but e.g. on the SHARP Poodle everytime
backlight_update_status() is called, a lot of registers are reset
and this leads to screen distortions of a ~ 0.4 seconds time frame.
Esp. tools like some light control programs with controlling sliders 
for the light intensity happen to set those values more often 
which is really annoying and makes it nearly impossible to use them
because the reaction time is really slow and you see lots of screen
distortions.

The trivial patch below avoids this problem by comparing the 
new value with the already set value. In case they are the same,
it just avoids to call backlight_update_status() again.

It would be great if this patch could be applied to the fbdev git tree
for inclusion in later linux kernels.

Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 4840fe2..3939475 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -94,8 +94,10 @@ static ssize_t backlight_store_power(struct device *dev,
 	mutex_lock(&bd->ops_lock);
 	if (bd->ops) {
 		pr_debug("backlight: set power to %d\n", power);
-		bd->props.power = power;
-		backlight_update_status(bd);
+		if (bd->props.power != power) {
+			bd->props.power = power;
+			backlight_update_status(bd);
+		}
 		rc = count;
 	}
 	mutex_unlock(&bd->ops_lock);
@@ -132,8 +134,10 @@ static ssize_t backlight_store_brightness(struct device *dev,
 		else {
 			pr_debug("backlight: set brightness to %d\n",
 				 brightness);
-			bd->props.brightness = brightness;
-			backlight_update_status(bd);
+			if (bd->props.brightness != brightness) {
+				bd->props.brightness = brightness;
+				backlight_update_status(bd);
+			}
 			rc = count;
 		}
 	}

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] backlight.c: avoid unnecessarily calling backlight_update_status()
  2008-01-06 14:29 [PATCH] backlight.c: avoid unnecessarily calling backlight_update_status() Helge Deller
@ 2008-01-13 23:02 ` Richard Purdie
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2008-01-13 23:02 UTC (permalink / raw)
  To: Helge Deller; +Cc: Andrew Zabolotny, linux-fbdev-devel, Jamey Hicks

On Sun, 2008-01-06 at 15:29 +0100, Helge Deller wrote:
> Every write to the backlight control sysfs entries like (on a Sharp
> Zaurus Poodle):
> - /sys/class/backlight/locomo-bl/power
> - /sys/class/backlight/locomo-bl/brightness
> triggers a call of backlight_update_status(), even if the same
> value is written multiple times in row into those entries.
> 
> In principle this is not critical, but e.g. on the SHARP Poodle everytime
> backlight_update_status() is called, a lot of registers are reset
> and this leads to screen distortions of a ~ 0.4 seconds time frame.
> Esp. tools like some light control programs with controlling sliders 
> for the light intensity happen to set those values more often 
> which is really annoying and makes it nearly impossible to use them
> because the reaction time is really slow and you see lots of screen
> distortions.
> 
> The trivial patch below avoids this problem by comparing the 
> new value with the already set value. In case they are the same,
> it just avoids to call backlight_update_status() again.
> 
> It would be great if this patch could be applied to the fbdev git tree
> for inclusion in later linux kernels.

I've queued this in the backlight tree, thanks.

Note that ideally userspace shouldn't be making all these calls
mind ;-).

Richard


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-13 23:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-06 14:29 [PATCH] backlight.c: avoid unnecessarily calling backlight_update_status() Helge Deller
2008-01-13 23:02 ` Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).