xref: /openbsd-src/sys/dev/pci/drm/include/linux/backlight.h (revision 4e1ee0786f11cc571bd0be17d38e46f635c719fc)
1 /* Public domain. */
2 
3 #ifndef _LINUX_BACKLIGHT_H
4 #define _LINUX_BACKLIGHT_H
5 
6 #include <sys/task.h>
7 
8 struct backlight_device;
9 
10 struct backlight_properties {
11 	int type;
12 	int max_brightness;
13 	int brightness;
14 	int power;
15 };
16 
17 struct backlight_ops {
18 	int options;
19 	int (*update_status)(struct backlight_device *);
20 	int (*get_brightness)(struct backlight_device *);
21 };
22 
23 #define BL_CORE_SUSPENDRESUME	1
24 
25 struct backlight_device {
26 	const struct backlight_ops *ops;
27 	struct backlight_properties props;
28 	struct task task;
29 	void *data;
30 };
31 
32 #define bl_get_data(bd)	(bd)->data
33 
34 #define BACKLIGHT_RAW		0
35 #define BACKLIGHT_FIRMWARE	1
36 
37 #define BACKLIGHT_UPDATE_HOTKEY	0
38 
39 struct backlight_device *backlight_device_register(const char *, void *,
40      void *, const struct backlight_ops *, struct backlight_properties *);
41 void backlight_device_unregister(struct backlight_device *);
42 
43 static inline void
44 backlight_update_status(struct backlight_device *bd)
45 {
46 	bd->ops->update_status(bd);
47 }
48 
49 static inline void
50 backlight_force_update(struct backlight_device *bd, int reason)
51 {
52 	bd->props.brightness = bd->ops->get_brightness(bd);
53 }
54 
55 static inline void
56 backlight_device_set_brightness(struct backlight_device *bd, int level)
57 {
58 	if (level > bd->props.max_brightness)
59 		return;
60 	bd->props.brightness = level;
61 	bd->ops->update_status(bd);
62 }
63 
64 void backlight_schedule_update_status(struct backlight_device *);
65 
66 int backlight_enable(struct backlight_device *);
67 int backlight_disable(struct backlight_device *);
68 
69 #define devm_of_find_backlight(x)	NULL
70 
71 #endif
72