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