1
2
3
4
5
6
7
8#ifndef _LINUX_BACKLIGHT_H
9#define _LINUX_BACKLIGHT_H
10
11#include <linux/device.h>
12#include <linux/mutex.h>
13#include <linux/notifier.h>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30enum backlight_update_reason {
31 BACKLIGHT_UPDATE_HOTKEY,
32 BACKLIGHT_UPDATE_SYSFS,
33};
34
35enum backlight_type {
36 BACKLIGHT_RAW = 1,
37 BACKLIGHT_PLATFORM,
38 BACKLIGHT_FIRMWARE,
39 BACKLIGHT_TYPE_MAX,
40};
41
42struct backlight_device;
43struct fb_info;
44
45struct backlight_ops {
46 unsigned int options;
47
48#define BL_CORE_SUSPENDRESUME (1 << 0)
49
50
51 int (*update_status)(struct backlight_device *);
52
53
54 int (*get_brightness)(struct backlight_device *);
55
56
57 int (*check_fb)(struct backlight_device *, struct fb_info *);
58};
59
60
61struct backlight_properties {
62
63 int brightness;
64
65 int max_brightness;
66
67
68 int power;
69
70
71 int fb_blank;
72
73 enum backlight_type type;
74
75
76 unsigned int state;
77
78#define BL_CORE_SUSPENDED (1 << 0)
79#define BL_CORE_FBBLANK (1 << 1)
80#define BL_CORE_DRIVER4 (1 << 28)
81#define BL_CORE_DRIVER3 (1 << 29)
82#define BL_CORE_DRIVER2 (1 << 30)
83#define BL_CORE_DRIVER1 (1 << 31)
84
85};
86
87struct backlight_device {
88
89 struct backlight_properties props;
90
91
92 struct mutex update_lock;
93
94
95
96
97 struct mutex ops_lock;
98 const struct backlight_ops *ops;
99
100
101 struct notifier_block fb_notif;
102
103 struct device dev;
104};
105
106static inline void backlight_update_status(struct backlight_device *bd)
107{
108 mutex_lock(&bd->update_lock);
109 if (bd->ops && bd->ops->update_status)
110 bd->ops->update_status(bd);
111 mutex_unlock(&bd->update_lock);
112}
113
114extern struct backlight_device *backlight_device_register(const char *name,
115 struct device *dev, void *devdata, const struct backlight_ops *ops,
116 const struct backlight_properties *props);
117extern void backlight_device_unregister(struct backlight_device *bd);
118extern void backlight_force_update(struct backlight_device *bd,
119 enum backlight_update_reason reason);
120
121#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
122
123static inline void * bl_get_data(struct backlight_device *bl_dev)
124{
125 return dev_get_drvdata(&bl_dev->dev);
126}
127
128struct generic_bl_info {
129 const char *name;
130 int max_intensity;
131 int default_intensity;
132 int limit_mask;
133 void (*set_bl_intensity)(int intensity);
134 void (*kick_battery)(void);
135};
136
137#ifdef CONFIG_OF
138struct backlight_device *of_find_backlight_by_node(struct device_node *node);
139#else
140static inline struct backlight_device *
141of_find_backlight_by_node(struct device_node *node)
142{
143 return NULL;
144}
145#endif
146
147#endif
148