linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: linux-fbdev-devel@lists.sourceforge.net
Cc: rpurdie@rpsys.net, Andrew Zabolotny <zap@homelink.ru>,
	Jamey Hicks <jamey.hicks@hp.com>
Subject: [PATCH] backlight.c: avoid unnecessarily calling backlight_update_status()
Date: Sun, 6 Jan 2008 15:29:19 +0100	[thread overview]
Message-ID: <200801061529.19606.deller@gmx.de> (raw)

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/

             reply	other threads:[~2008-01-06 14:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-06 14:29 Helge Deller [this message]
2008-01-13 23:02 ` [PATCH] backlight.c: avoid unnecessarily calling backlight_update_status() Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200801061529.19606.deller@gmx.de \
    --to=deller@gmx.de \
    --cc=jamey.hicks@hp.com \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=rpurdie@rpsys.net \
    --cc=zap@homelink.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).