The controller supports setting brightness of each channel of the RGB LEDs to values 0-255. We do not support RGB LED class yet, but we can use this to be able to have 256 brightness levels for each LED, instead of just on/off state. Signed-off-by: Marek Behún <marek.behun@xxxxxx> --- drivers/leds/Kconfig | 4 ++-- drivers/leds/leds-turris-omnia.c | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index a11a79bad973..48b7c790cf0b 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -139,8 +139,8 @@ config LEDS_TURRIS_OMNIA side of CZ.NIC's Turris Omnia router. There are 12 RGB LEDs on the front panel. This driver does not currently support setting LED colors, only - on/off state. Also HW triggering is disabled when the controller - is probed by this driver. + brightness. Also HW triggering is disabled when the controller is + probed by this driver. config LEDS_LM3530 tristate "LCD Backlight driver for LM3530" diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index dc9fac56b13a..0097e62e25d8 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -54,7 +54,7 @@ static int omnia_led_brightness_set_blocking(struct led_classdev *led, struct omnia_leds *leds = dev_get_drvdata(led->dev->parent); int idx = omnia_led_idx(leds, led); int ret; - u8 state; + u8 buf[5], state; if (idx < 0) return idx; @@ -63,8 +63,16 @@ static int omnia_led_brightness_set_blocking(struct led_classdev *led, if (brightness) state |= CMD_LED_STATE_ON; + buf[0] = CMD_LED_COLOR; + buf[1] = idx; + buf[2] = buf[3] = buf[4] = brightness; + mutex_lock(&leds->lock); + ret = i2c_smbus_write_byte_data(leds->client, CMD_LED_STATE, state); + if (ret >= 0) + ret = i2c_master_send(leds->client, buf, 5); + mutex_unlock(&leds->lock); return ret; -- 2.21.0