#include #include #include #ifndef __AVM_HUI_LEDS_INTERNAL_H__ #define __AVM_HUI_LEDS_INTERNAL_H__ struct led; typedef struct blink_code (*led_overlay_t)(struct led *); // There are predefined colors for used to denote some meanings. The value here is the index into the color array // // By default these are white (0xFFFFFF) and can be set via dt or // sysfs. // // Note that depending on the platform only some components are present // and they not necessarily are RGB. enum led_color_name { #define COLOR(name) led_color_name_##name, #include "../def/colors.h" LED_NUM_COLOR_NAMES }; struct colored_kobject { struct kobject kobj; struct led_color colors[LED_NUM_COLOR_NAMES]; }; // To allow a hierarchy of color definitions we define that the color black is invalid static inline bool led_color_valid(struct led_color color) { return color.c[0] != 0 || color.c[1] != 0 || color.c[2] != 0; } #define LED_FLAG_BARE_UPDATE BIT(1) #define CONNECT_METHODE(x) (1 << (x & 0x7)) #define CONNECT_METHODE_ALL 0xFF struct led_options { // Which connect methods are serviced by this led // used by overlay_connect u8 connect_methods; // Which physical location has this led // Is used by rssi and vu overlays // // 0 -> no location u8 location; u32 flags; }; struct led_type { const char *name; struct led_options options; led_overlay_t *overlays; }; struct led { struct colored_kobject obj; struct list_head list; const char *name; const struct led_type *type; struct led_options options; const struct avm_hui_led_ops *ops; void *ops_ctx; struct led_color current_color; struct blink_code current_code; void *current_code_source; struct blink_code forced_code; bool dimmable; u8 brightness_max; u8 brightness_min; }; #define to_led_obj(x) container_of(x, struct led, obj.kobj) extern struct kobj_type led_ktype; extern const struct attribute_group colored_attribute_group; extern const struct led_type* lookup_led_type(const char *name); extern struct led_color led_default_colors[LED_NUM_COLOR_NAMES]; extern struct led_color led_lookup_color(const struct led *led, enum led_color_name, bool allow_fallback); struct colored_attribute { struct attribute attr; ssize_t (*show)(struct colored_kobject *obj, char *buf); ssize_t (*store)(struct colored_kobject *obj, const char *buf, size_t count); }; #define to_colored_attr(x) container_of(x, struct colored_attribute, attr) int colored_kobject_init_from_dt(struct colored_kobject *kobj, struct device_node *node); #endif