Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: lp5562: Add multicolor brightness control

The framework for multicolor brightness control is already in place
in the lp55xx-common code but the function to control the multicolor
brightness for this particular chip is still missing.

Implement the multicolor_brightness_fn function to allow multicolor
brightness control of LEDs connected to the LP5562 LED driver.

Signed-off-by: Michal Vokáč <michal.vokac@ysoft.com>
Link: https://lore.kernel.org/r/20241009095635.2790613-1-michal.vokac@ysoft.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Michal Vokáč and committed by
Lee Jones
681d5fa6 c161656b

+25
+25
drivers/leds/leds-lp5562.c
··· 161 161 return 0; 162 162 } 163 163 164 + static int lp5562_multicolor_brightness(struct lp55xx_led *led) 165 + { 166 + struct lp55xx_chip *chip = led->chip; 167 + static const u8 addr[] = { 168 + LP5562_REG_R_PWM, 169 + LP5562_REG_G_PWM, 170 + LP5562_REG_B_PWM, 171 + LP5562_REG_W_PWM, 172 + }; 173 + int ret; 174 + int i; 175 + 176 + guard(mutex)(&chip->lock); 177 + for (i = 0; i < led->mc_cdev.num_colors; i++) { 178 + ret = lp55xx_write(chip, 179 + addr[led->mc_cdev.subled_info[i].channel], 180 + led->mc_cdev.subled_info[i].brightness); 181 + if (ret) 182 + break; 183 + } 184 + 185 + return ret; 186 + } 187 + 164 188 static int lp5562_led_brightness(struct lp55xx_led *led) 165 189 { 166 190 struct lp55xx_chip *chip = led->chip; ··· 388 364 .post_init_device = lp5562_post_init_device, 389 365 .set_led_current = lp5562_set_led_current, 390 366 .brightness_fn = lp5562_led_brightness, 367 + .multicolor_brightness_fn = lp5562_multicolor_brightness, 391 368 .run_engine = lp5562_run_engine, 392 369 .firmware_cb = lp55xx_firmware_loaded_cb, 393 370 .dev_attr_group = &lp5562_group,