0001
0002
0003
0004
0005
0006 #ifndef _LINUX_MULTICOLOR_LEDS_H_INCLUDED
0007 #define _LINUX_MULTICOLOR_LEDS_H_INCLUDED
0008
0009 #include <linux/leds.h>
0010 #include <dt-bindings/leds/common.h>
0011
0012 struct mc_subled {
0013 unsigned int color_index;
0014 unsigned int brightness;
0015 unsigned int intensity;
0016 unsigned int channel;
0017 };
0018
0019 struct led_classdev_mc {
0020
0021 struct led_classdev led_cdev;
0022 unsigned int num_colors;
0023
0024 struct mc_subled *subled_info;
0025 };
0026
0027 static inline struct led_classdev_mc *lcdev_to_mccdev(
0028 struct led_classdev *led_cdev)
0029 {
0030 return container_of(led_cdev, struct led_classdev_mc, led_cdev);
0031 }
0032
0033 #if IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR)
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 int led_classdev_multicolor_register_ext(struct device *parent,
0044 struct led_classdev_mc *mcled_cdev,
0045 struct led_init_data *init_data);
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev);
0056
0057
0058 int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev,
0059 enum led_brightness brightness);
0060
0061 int devm_led_classdev_multicolor_register_ext(struct device *parent,
0062 struct led_classdev_mc *mcled_cdev,
0063 struct led_init_data *init_data);
0064
0065 void devm_led_classdev_multicolor_unregister(struct device *parent,
0066 struct led_classdev_mc *mcled_cdev);
0067 #else
0068
0069 static inline int led_classdev_multicolor_register_ext(struct device *parent,
0070 struct led_classdev_mc *mcled_cdev,
0071 struct led_init_data *init_data)
0072 {
0073 return 0;
0074 }
0075
0076 static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) {};
0077 static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev,
0078 enum led_brightness brightness)
0079 {
0080 return 0;
0081 }
0082
0083 static inline int devm_led_classdev_multicolor_register_ext(struct device *parent,
0084 struct led_classdev_mc *mcled_cdev,
0085 struct led_init_data *init_data)
0086 {
0087 return 0;
0088 }
0089
0090 static inline void devm_led_classdev_multicolor_unregister(struct device *parent,
0091 struct led_classdev_mc *mcled_cdev)
0092 {};
0093
0094 #endif
0095
0096 static inline int led_classdev_multicolor_register(struct device *parent,
0097 struct led_classdev_mc *mcled_cdev)
0098 {
0099 return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL);
0100 }
0101
0102 static inline int devm_led_classdev_multicolor_register(struct device *parent,
0103 struct led_classdev_mc *mcled_cdev)
0104 {
0105 return devm_led_classdev_multicolor_register_ext(parent, mcled_cdev,
0106 NULL);
0107 }
0108
0109 #endif