Skip to content

Commit 681d5fa

Browse files
zandarlag-linaro
authored andcommitted
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áč <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent c161656 commit 681d5fa

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/leds/leds-lp5562.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,30 @@ static int lp5562_post_init_device(struct lp55xx_chip *chip)
161161
return 0;
162162
}
163163

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+
164188
static int lp5562_led_brightness(struct lp55xx_led *led)
165189
{
166190
struct lp55xx_chip *chip = led->chip;
@@ -364,6 +388,7 @@ static struct lp55xx_device_config lp5562_cfg = {
364388
.post_init_device = lp5562_post_init_device,
365389
.set_led_current = lp5562_set_led_current,
366390
.brightness_fn = lp5562_led_brightness,
391+
.multicolor_brightness_fn = lp5562_multicolor_brightness,
367392
.run_engine = lp5562_run_engine,
368393
.firmware_cb = lp55xx_firmware_loaded_cb,
369394
.dev_attr_group = &lp5562_group,

0 commit comments

Comments
 (0)