Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 166460
b: refs/heads/master
c: 325253a
h: refs/heads/master
v: v3
  • Loading branch information
Matthew Garrett authored and Richard Purdie committed Sep 21, 2009
1 parent 56823a4 commit af09dda
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0f7e7273803aa03ad7a0e210461a3db9d35e7abb
refs/heads/master: 325253a6b2de4bdfa9ef0e28b5df8a4a4fe2b677
41 changes: 41 additions & 0 deletions trunk/drivers/video/backlight/backlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ static inline void backlight_unregister_fb(struct backlight_device *bd)
}
#endif /* CONFIG_FB */

static void backlight_generate_event(struct backlight_device *bd,
enum backlight_update_reason reason)
{
char *envp[2];

switch (reason) {
case BACKLIGHT_UPDATE_SYSFS:
envp[0] = "SOURCE=sysfs";
break;
case BACKLIGHT_UPDATE_HOTKEY:
envp[0] = "SOURCE=hotkey";
break;
default:
envp[0] = "SOURCE=unknown";
break;
}
envp[1] = NULL;
kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp);
}

static ssize_t backlight_show_power(struct device *dev,
struct device_attribute *attr,char *buf)
{
Expand Down Expand Up @@ -142,6 +162,8 @@ static ssize_t backlight_store_brightness(struct device *dev,
}
mutex_unlock(&bd->ops_lock);

backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS);

return rc;
}

Expand Down Expand Up @@ -213,6 +235,25 @@ static struct device_attribute bl_device_attributes[] = {
__ATTR_NULL,
};

/**
* backlight_force_update - tell the backlight subsystem that hardware state
* has changed
* @bd: the backlight device to update
*
* Updates the internal state of the backlight in response to a hardware event,
* and generate a uevent to notify userspace
*/
void backlight_force_update(struct backlight_device *bd,
enum backlight_update_reason reason)
{
mutex_lock(&bd->ops_lock);
if (bd->ops && bd->ops->get_brightness)
bd->props.brightness = bd->ops->get_brightness(bd);
mutex_unlock(&bd->ops_lock);
backlight_generate_event(bd, reason);
}
EXPORT_SYMBOL(backlight_force_update);

/**
* backlight_device_register - create and register a new object of
* backlight_device class.
Expand Down
7 changes: 7 additions & 0 deletions trunk/include/linux/backlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
* Any other use of the locks below is probably wrong.
*/

enum backlight_update_reason {
BACKLIGHT_UPDATE_HOTKEY,
BACKLIGHT_UPDATE_SYSFS,
};

struct backlight_device;
struct fb_info;

Expand Down Expand Up @@ -100,6 +105,8 @@ static inline void backlight_update_status(struct backlight_device *bd)
extern struct backlight_device *backlight_device_register(const char *name,
struct device *dev, void *devdata, struct backlight_ops *ops);
extern void backlight_device_unregister(struct backlight_device *bd);
extern void backlight_force_update(struct backlight_device *bd,
enum backlight_update_reason reason);

#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)

Expand Down

0 comments on commit af09dda

Please sign in to comment.