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 #define BACKLIGHT_RAW 0 15 #define BACKLIGHT_FIRMWARE 1 16 #define BACKLIGHT_PLATFORM 2 17 int max_brightness; 18 int brightness; 19 int power; 20 int scale; 21 #define BACKLIGHT_SCALE_LINEAR 0 22 int state; 23 #define BL_CORE_SUSPENDED 0x00000001 24 }; 25 26 struct backlight_ops { 27 int options; 28 #define BL_CORE_SUSPENDRESUME 0x00000001 29 int (*update_status)(struct backlight_device *); 30 int (*get_brightness)(struct backlight_device *); 31 }; 32 33 struct backlight_device { 34 const struct backlight_ops *ops; 35 struct backlight_properties props; 36 struct task task; 37 void *data; 38 SLIST_ENTRY(backlight_device) next; 39 const char *name; 40 }; 41 42 static inline void * 43 bl_get_data(struct backlight_device *bd) 44 { 45 return bd->data; 46 } 47 48 static inline int 49 backlight_get_brightness(struct backlight_device *bd) 50 { 51 return bd->props.brightness; 52 } 53 54 #define BACKLIGHT_UPDATE_HOTKEY 0 55 56 struct backlight_device *backlight_device_register(const char *, void *, 57 void *, const struct backlight_ops *, const struct backlight_properties *); 58 void backlight_device_unregister(struct backlight_device *); 59 60 static inline struct backlight_device * 61 devm_backlight_device_register(void *dev, const char *name, void *parent, 62 void *data, const struct backlight_ops *bo, 63 const struct backlight_properties *bp) 64 { 65 return backlight_device_register(name, dev, data, bo, bp); 66 } 67 68 static inline void 69 backlight_update_status(struct backlight_device *bd) 70 { 71 bd->ops->update_status(bd); 72 } 73 74 static inline void 75 backlight_force_update(struct backlight_device *bd, int reason) 76 { 77 bd->props.brightness = bd->ops->get_brightness(bd); 78 } 79 80 static inline void 81 backlight_device_set_brightness(struct backlight_device *bd, int level) 82 { 83 if (level > bd->props.max_brightness) 84 return; 85 bd->props.brightness = level; 86 bd->ops->update_status(bd); 87 } 88 89 void backlight_schedule_update_status(struct backlight_device *); 90 91 int backlight_enable(struct backlight_device *); 92 int backlight_disable(struct backlight_device *); 93 94 static inline struct backlight_device * 95 devm_of_find_backlight(struct device *dev) 96 { 97 return NULL; 98 } 99 100 struct backlight_device *backlight_device_get_by_name(const char *); 101 102 #endif 103