This source file includes following definitions.
- backlight_update_status
- backlight_enable
- backlight_disable
- backlight_put
- bl_get_data
- of_find_backlight_by_node
- of_find_backlight
- devm_of_find_backlight
1
2
3
4
5
6
7
8
9 #ifndef _LINUX_BACKLIGHT_H
10 #define _LINUX_BACKLIGHT_H
11
12 #include <linux/device.h>
13 #include <linux/fb.h>
14 #include <linux/mutex.h>
15 #include <linux/notifier.h>
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 enum backlight_update_reason {
33 BACKLIGHT_UPDATE_HOTKEY,
34 BACKLIGHT_UPDATE_SYSFS,
35 };
36
37 enum backlight_type {
38 BACKLIGHT_RAW = 1,
39 BACKLIGHT_PLATFORM,
40 BACKLIGHT_FIRMWARE,
41 BACKLIGHT_TYPE_MAX,
42 };
43
44 enum backlight_notification {
45 BACKLIGHT_REGISTERED,
46 BACKLIGHT_UNREGISTERED,
47 };
48
49 enum backlight_scale {
50 BACKLIGHT_SCALE_UNKNOWN = 0,
51 BACKLIGHT_SCALE_LINEAR,
52 BACKLIGHT_SCALE_NON_LINEAR,
53 };
54
55 struct backlight_device;
56 struct fb_info;
57
58 struct backlight_ops {
59 unsigned int options;
60
61 #define BL_CORE_SUSPENDRESUME (1 << 0)
62
63
64 int (*update_status)(struct backlight_device *);
65
66
67 int (*get_brightness)(struct backlight_device *);
68
69
70 int (*check_fb)(struct backlight_device *, struct fb_info *);
71 };
72
73
74 struct backlight_properties {
75
76 int brightness;
77
78 int max_brightness;
79
80
81 int power;
82
83
84 int fb_blank;
85
86 enum backlight_type type;
87
88 unsigned int state;
89
90 enum backlight_scale scale;
91
92 #define BL_CORE_SUSPENDED (1 << 0)
93 #define BL_CORE_FBBLANK (1 << 1)
94
95 };
96
97 struct backlight_device {
98
99 struct backlight_properties props;
100
101
102 struct mutex update_lock;
103
104
105
106
107 struct mutex ops_lock;
108 const struct backlight_ops *ops;
109
110
111 struct notifier_block fb_notif;
112
113
114 struct list_head entry;
115
116 struct device dev;
117
118
119 bool fb_bl_on[FB_MAX];
120
121 int use_count;
122 };
123
124 static inline int backlight_update_status(struct backlight_device *bd)
125 {
126 int ret = -ENOENT;
127
128 mutex_lock(&bd->update_lock);
129 if (bd->ops && bd->ops->update_status)
130 ret = bd->ops->update_status(bd);
131 mutex_unlock(&bd->update_lock);
132
133 return ret;
134 }
135
136
137
138
139
140 static inline int backlight_enable(struct backlight_device *bd)
141 {
142 if (!bd)
143 return 0;
144
145 bd->props.power = FB_BLANK_UNBLANK;
146 bd->props.fb_blank = FB_BLANK_UNBLANK;
147 bd->props.state &= ~BL_CORE_FBBLANK;
148
149 return backlight_update_status(bd);
150 }
151
152
153
154
155
156 static inline int backlight_disable(struct backlight_device *bd)
157 {
158 if (!bd)
159 return 0;
160
161 bd->props.power = FB_BLANK_POWERDOWN;
162 bd->props.fb_blank = FB_BLANK_POWERDOWN;
163 bd->props.state |= BL_CORE_FBBLANK;
164
165 return backlight_update_status(bd);
166 }
167
168
169
170
171
172 static inline void backlight_put(struct backlight_device *bd)
173 {
174 if (bd)
175 put_device(&bd->dev);
176 }
177
178 extern struct backlight_device *backlight_device_register(const char *name,
179 struct device *dev, void *devdata, const struct backlight_ops *ops,
180 const struct backlight_properties *props);
181 extern struct backlight_device *devm_backlight_device_register(
182 struct device *dev, const char *name, struct device *parent,
183 void *devdata, const struct backlight_ops *ops,
184 const struct backlight_properties *props);
185 extern void backlight_device_unregister(struct backlight_device *bd);
186 extern void devm_backlight_device_unregister(struct device *dev,
187 struct backlight_device *bd);
188 extern void backlight_force_update(struct backlight_device *bd,
189 enum backlight_update_reason reason);
190 extern int backlight_register_notifier(struct notifier_block *nb);
191 extern int backlight_unregister_notifier(struct notifier_block *nb);
192 extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type);
193 extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness);
194
195 #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
196
197 static inline void * bl_get_data(struct backlight_device *bl_dev)
198 {
199 return dev_get_drvdata(&bl_dev->dev);
200 }
201
202 struct generic_bl_info {
203 const char *name;
204 int max_intensity;
205 int default_intensity;
206 int limit_mask;
207 void (*set_bl_intensity)(int intensity);
208 void (*kick_battery)(void);
209 };
210
211 #ifdef CONFIG_OF
212 struct backlight_device *of_find_backlight_by_node(struct device_node *node);
213 #else
214 static inline struct backlight_device *
215 of_find_backlight_by_node(struct device_node *node)
216 {
217 return NULL;
218 }
219 #endif
220
221 #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
222 struct backlight_device *of_find_backlight(struct device *dev);
223 struct backlight_device *devm_of_find_backlight(struct device *dev);
224 #else
225 static inline struct backlight_device *of_find_backlight(struct device *dev)
226 {
227 return NULL;
228 }
229
230 static inline struct backlight_device *
231 devm_of_find_backlight(struct device *dev)
232 {
233 return NULL;
234 }
235 #endif
236
237 #endif