[PATCH v1 leds-next 3/3] leds: turris-omnia: Add support for continuous brightness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The controller supports setting brightness of each channel of the RGB
LEDs. Utilize this by adding support for setting continuous brightness
of the entire LED by setting the same brightness on all 3 channels.

Signed-off-by: Marek Behún <marek.behun@xxxxxx>
---
 drivers/leds/Kconfig             |  4 ++--
 drivers/leds/leds-turris-omnia.c | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index adcd53c02b3c..f97ef7977b24 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -137,8 +137,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 4ebf7e917a0f..96f9a95cc2c4 100644
--- a/drivers/leds/leds-turris-omnia.c
+++ b/drivers/leds/leds-turris-omnia.c
@@ -61,7 +61,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;
@@ -70,10 +70,20 @@ 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);
-	mutex_unlock(&leds->lock);
+	if (ret < 0)
+		goto unlock;
 
+	ret = i2c_master_send(leds->client, buf, 5);
+
+unlock:
+	mutex_unlock(&leds->lock);
 	return ret;
 }
 
-- 
2.19.2




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux