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