aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight/backlight.c
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2011-03-22 16:30:21 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-22 17:43:59 -0700
commitbb7ca747f8d6243b3943c5b133048652020f4a50 (patch)
treeb40e879a7b26e3763aea2af2d4dd9079483de11e /drivers/video/backlight/backlight.c
parentccd7510fd8dea5b4b2af87fb2aef2ebd6b23b76b (diff)
downloadkernel_samsung_smdk4412-bb7ca747f8d6243b3943c5b133048652020f4a50.zip
kernel_samsung_smdk4412-bb7ca747f8d6243b3943c5b133048652020f4a50.tar.gz
kernel_samsung_smdk4412-bb7ca747f8d6243b3943c5b133048652020f4a50.tar.bz2
backlight: add backlight type
There may be multiple ways of controlling the backlight on a given machine. Allow drivers to expose the type of interface they are providing, making it possible for userspace to make appropriate policy decisions. Signed-off-by: Matthew Garrett <mjg@redhat.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: David Airlie <airlied@linux.ie> Cc: Alex Deucher <alexdeucher@gmail.com> Cc: Ben Skeggs <bskeggs@redhat.com> Cc: Zhang Rui <rui.zhang@intel.com> Cc: Len Brown <lenb@kernel.org> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/backlight/backlight.c')
-rw-r--r--drivers/video/backlight/backlight.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 0870329..80d292f 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -19,6 +19,12 @@
#include <asm/backlight.h>
#endif
+static const char const *backlight_types[] = {
+ [BACKLIGHT_RAW] = "raw",
+ [BACKLIGHT_PLATFORM] = "platform",
+ [BACKLIGHT_FIRMWARE] = "firmware",
+};
+
#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
/* This callback gets called when something important happens inside a
@@ -169,6 +175,14 @@ static ssize_t backlight_store_brightness(struct device *dev,
return rc;
}
+static ssize_t backlight_show_type(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct backlight_device *bd = to_backlight_device(dev);
+
+ return sprintf(buf, "%s\n", backlight_types[bd->props.type]);
+}
+
static ssize_t backlight_show_max_brightness(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -234,6 +248,7 @@ static struct device_attribute bl_device_attributes[] = {
__ATTR(actual_brightness, 0444, backlight_show_actual_brightness,
NULL),
__ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
+ __ATTR(type, 0444, backlight_show_type, NULL),
__ATTR_NULL,
};
@@ -292,9 +307,16 @@ struct backlight_device *backlight_device_register(const char *name,
dev_set_drvdata(&new_bd->dev, devdata);
/* Set default properties */
- if (props)
+ if (props) {
memcpy(&new_bd->props, props,
sizeof(struct backlight_properties));
+ if (props->type <= 0 || props->type >= BACKLIGHT_TYPE_MAX) {
+ WARN(1, "%s: invalid backlight type", name);
+ new_bd->props.type = BACKLIGHT_RAW;
+ }
+ } else {
+ new_bd->props.type = BACKLIGHT_RAW;
+ }
rc = device_register(&new_bd->dev);
if (rc) {