aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/backlight/backlight.c41
1 files changed, 41 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