diff options
Diffstat (limited to 'drivers/video/backlight/backlight.c')
| -rw-r--r-- | drivers/video/backlight/backlight.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 157057c79ca3..6615ac7fa60a 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c | |||
| @@ -73,6 +73,27 @@ static inline void backlight_unregister_fb(struct backlight_device *bd) | |||
| 73 | } | 73 | } |
| 74 | #endif /* CONFIG_FB */ | 74 | #endif /* CONFIG_FB */ |
| 75 | 75 | ||
| 76 | static 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 | sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness"); | ||
| 95 | } | ||
| 96 | |||
| 76 | static ssize_t backlight_show_power(struct device *dev, | 97 | static ssize_t backlight_show_power(struct device *dev, |
| 77 | struct device_attribute *attr,char *buf) | 98 | struct device_attribute *attr,char *buf) |
| 78 | { | 99 | { |
| @@ -142,6 +163,8 @@ static ssize_t backlight_store_brightness(struct device *dev, | |||
| 142 | } | 163 | } |
| 143 | mutex_unlock(&bd->ops_lock); | 164 | mutex_unlock(&bd->ops_lock); |
| 144 | 165 | ||
| 166 | backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS); | ||
| 167 | |||
| 145 | return rc; | 168 | return rc; |
| 146 | } | 169 | } |
| 147 | 170 | ||
| @@ -214,6 +237,25 @@ static struct device_attribute bl_device_attributes[] = { | |||
| 214 | }; | 237 | }; |
| 215 | 238 | ||
| 216 | /** | 239 | /** |
| 240 | * backlight_force_update - tell the backlight subsystem that hardware state | ||
| 241 | * has changed | ||
| 242 | * @bd: the backlight device to update | ||
| 243 | * | ||
| 244 | * Updates the internal state of the backlight in response to a hardware event, | ||
| 245 | * and generate a uevent to notify userspace | ||
| 246 | */ | ||
| 247 | void backlight_force_update(struct backlight_device *bd, | ||
| 248 | enum backlight_update_reason reason) | ||
| 249 | { | ||
| 250 | mutex_lock(&bd->ops_lock); | ||
| 251 | if (bd->ops && bd->ops->get_brightness) | ||
| 252 | bd->props.brightness = bd->ops->get_brightness(bd); | ||
| 253 | mutex_unlock(&bd->ops_lock); | ||
| 254 | backlight_generate_event(bd, reason); | ||
| 255 | } | ||
| 256 | EXPORT_SYMBOL(backlight_force_update); | ||
| 257 | |||
| 258 | /** | ||
| 217 | * backlight_device_register - create and register a new object of | 259 | * backlight_device_register - create and register a new object of |
| 218 | * backlight_device class. | 260 | * backlight_device class. |
| 219 | * @name: the name of the new object(must be the same as the name of the | 261 | * @name: the name of the new object(must be the same as the name of the |
