aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/video/backlight/backlight.c41
-rw-r--r--include/linux/backlight.h7
2 files changed, 48 insertions, 0 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 157057c79ca3..6e1446ae7f52 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -73,6 +73,26 @@ static inline void backlight_unregister_fb(struct backlight_device *bd)
73} 73}
74#endif /* CONFIG_FB */ 74#endif /* CONFIG_FB */
75 75
76static void backlight_generate_event(struct backlight_device *bd,
77 enum backlight_update_reason reason)
78{
79 char *envp[2];
80
81 switch (reason) {
82 case BACKLIGHT_UPDATE_SYSFS:
83 envp[0] = "SOURCE=sysfs";
84 break;
85 case BACKLIGHT_UPDATE_HOTKEY:
86 envp[0] = "SOURCE=hotkey";
87 break;
88 default:
89 envp[0] = "SOURCE=unknown";
90 break;
91 }
92 envp[1] = NULL;
93 kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp);
94}
95
76static ssize_t backlight_show_power(struct device *dev, 96static ssize_t backlight_show_power(struct device *dev,
77 struct device_attribute *attr,char *buf) 97 struct device_attribute *attr,char *buf)
78{ 98{
@@ -142,6 +162,8 @@ static ssize_t backlight_store_brightness(struct device *dev,
142 } 162 }
143 mutex_unlock(&bd->ops_lock); 163 mutex_unlock(&bd->ops_lock);
144 164
165 backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS);
166
145 return rc; 167 return rc;
146} 168}
147 169
@@ -214,6 +236,25 @@ static struct device_attribute bl_device_attributes[] = {
214}; 236};
215 237
216/** 238/**
239 * backlight_force_update - tell the backlight subsystem that hardware state
240 * has changed
241 * @bd: the backlight device to update
242 *
243 * Updates the internal state of the backlight in response to a hardware event,
244 * and generate a uevent to notify userspace
245 */
246void backlight_force_update(struct backlight_device *bd,
247 enum backlight_update_reason reason)
248{
249 mutex_lock(&bd->ops_lock);
250 if (bd->ops && bd->ops->get_brightness)
251 bd->props.brightness = bd->ops->get_brightness(bd);
252 mutex_unlock(&bd->ops_lock);
253 backlight_generate_event(bd, reason);
254}
255EXPORT_SYMBOL(backlight_force_update);
256
257/**
217 * backlight_device_register - create and register a new object of 258 * backlight_device_register - create and register a new object of
218 * backlight_device class. 259 * backlight_device class.
219 * @name: the name of the new object(must be the same as the name of the 260 * @name: the name of the new object(must be the same as the name of the
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 79ca2da81c87..0f5f57858a23 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -27,6 +27,11 @@
27 * Any other use of the locks below is probably wrong. 27 * Any other use of the locks below is probably wrong.
28 */ 28 */
29 29
30enum backlight_update_reason {
31 BACKLIGHT_UPDATE_HOTKEY,
32 BACKLIGHT_UPDATE_SYSFS,
33};
34
30struct backlight_device; 35struct backlight_device;
31struct fb_info; 36struct fb_info;
32 37
@@ -100,6 +105,8 @@ static inline void backlight_update_status(struct backlight_device *bd)
100extern struct backlight_device *backlight_device_register(const char *name, 105extern struct backlight_device *backlight_device_register(const char *name,
101 struct device *dev, void *devdata, struct backlight_ops *ops); 106 struct device *dev, void *devdata, struct backlight_ops *ops);
102extern void backlight_device_unregister(struct backlight_device *bd); 107extern void backlight_device_unregister(struct backlight_device *bd);
108extern void backlight_force_update(struct backlight_device *bd,
109 enum backlight_update_reason reason);
103 110
104#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev) 111#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
105 112