From: InKi Dae <daeinki@gmail.com>
To: linux-fbdev-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Cc: Kyungmin Park <kmpark@infradead.org>
Subject: [patch] added brightness feature to lcd class.
Date: Mon, 2 Nov 2009 17:50:02 +0900 [thread overview]
Message-ID: <90b950fc0911020050q3bc3fae8j954ec6ed73d79b5@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 686 bytes --]
This patch adds brightness feature to lcd class.
(kernel/driver/video/backlight/lcd.c)
In the past, most of the lcd panels for embedded system was TFT-LCD
Panel needing backlight device.
But now AMOLED LCD Panel appeared so we should consider brightness
control for AMOLED Panel.
For the time being, I used backlight fake driver for brightness
control of AMOLED LCD Panel.
But this way is not good, so I propose to add brightness feature to lcd class.
For this, I attached patch file and if my proposal is approved
Then I will send s6e63m0 and tl2796 AMOLED lcd panel driver based on
lcd class modified soon.
signed-off-by : InKi Dae <inki.dae@samsung.com>
Best Regards,
InKi Dae.
[-- Attachment #2: lcd.patch --]
[-- Type: application/octet-stream, Size: 2951 bytes --]
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index b644947..cc19ee9 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -164,6 +164,53 @@ static ssize_t lcd_show_max_contrast(struct device *dev,
return sprintf(buf, "%d\n", ld->props.max_contrast);
}
+static ssize_t lcd_show_brightness(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ int rc = -ENXIO;
+ struct lcd_device *ld = to_lcd_device(dev);
+
+ mutex_lock(&ld->ops_lock);
+ if (ld->ops && ld->ops->get_brightness)
+ rc = sprintf(buf, "%d\n", ld->ops->get_brightness(ld));
+ mutex_unlock(&ld->ops_lock);
+
+ return rc;
+}
+
+static ssize_t lcd_store_brightness(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ int rc = -ENXIO;
+ char *endp;
+ struct lcd_device *ld = to_lcd_device(dev);
+ int brightness = simple_strtoul(buf, &endp, 0);
+ size_t size = endp - buf;
+
+ if (*endp && isspace(*endp))
+ size++;
+ if (size != count)
+ return -EINVAL;
+
+ mutex_lock(&ld->ops_lock);
+ if (ld->ops && ld->ops->set_brightness) {
+ pr_debug("lcd: set brightness to %d\n", brightness);
+ ld->ops->set_brightness(ld, brightness);
+ rc = count;
+ }
+ mutex_unlock(&ld->ops_lock);
+
+ return rc;
+}
+
+static ssize_t lcd_show_max_brightness(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct lcd_device *ld = to_lcd_device(dev);
+
+ return sprintf(buf, "%d\n", ld->props.max_brightness);
+}
+
static struct class *lcd_class;
static void lcd_device_release(struct device *dev)
@@ -176,6 +223,8 @@ static struct device_attribute lcd_device_attributes[] = {
__ATTR(lcd_power, 0644, lcd_show_power, lcd_store_power),
__ATTR(contrast, 0644, lcd_show_contrast, lcd_store_contrast),
__ATTR(max_contrast, 0444, lcd_show_max_contrast, NULL),
+ __ATTR(brightness, 0644, lcd_show_brightness, lcd_store_brightness),
+ __ATTR(max_brightness, 0444, lcd_show_max_brightness, NULL),
__ATTR_NULL,
};
diff --git a/include/linux/lcd.h b/include/linux/lcd.h
index c67feca..5145fc6 100644
--- a/include/linux/lcd.h
+++ b/include/linux/lcd.h
@@ -34,6 +34,9 @@ struct fb_info;
struct lcd_properties {
/* The maximum value for contrast (read-only) */
int max_contrast;
+
+ /* The maximum value for brightness (read-only) */
+ int max_brightness;
};
struct lcd_ops {
@@ -46,6 +49,10 @@ struct lcd_ops {
int (*get_contrast)(struct lcd_device *);
/* Set LCD panel contrast */
int (*set_contrast)(struct lcd_device *, int contrast);
+ /* Get the current brighness setting (only AMOLED lcd panel) */
+ int (*get_brightness)(struct lcd_device *);
+ /* Set LCD panel brightness (only AMOLED lcd panel) */
+ int (*set_brightness)(struct lcd_device *, int brightness);
/* Set LCD panel mode (resolutions ...) */
int (*set_mode)(struct lcd_device *, struct fb_videomode *);
/* Check if given framebuffer device is the one LCD is bound to;
next reply other threads:[~2009-11-02 8:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-02 8:50 InKi Dae [this message]
2009-11-05 19:27 ` [patch] added brightness feature to lcd class Pavel Machek
2009-11-07 12:43 ` InKi Dae
2009-11-07 16:48 ` Pavel Machek
2009-11-09 15:37 ` InKi Dae
2009-11-09 20:15 ` Pavel Machek
2009-11-09 23:18 ` Andrew Morton
2009-11-09 23:35 ` Richard Purdie
2009-11-10 3:26 ` InKi Dae
2009-11-10 8:43 ` Richard Purdie
2009-11-10 15:27 ` Matthew Garrett
2009-11-11 6:17 ` InKi Dae
2009-11-11 9:28 ` Richard Purdie
2009-11-13 3:13 ` InKi Dae
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=90b950fc0911020050q3bc3fae8j954ec6ed73d79b5@mail.gmail.com \
--to=daeinki@gmail.com \
--cc=kmpark@infradead.org \
--cc=linux-fbdev-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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).