From 14d8377378324cc63d1e1891cfa772adda0f5d32 Mon Sep 17 00:00:00 2001 From: hanwckf Date: Mon, 26 Dec 2022 21:03:49 +0800 Subject: [PATCH] leds-ws2812b: add 'color-intensity' prop to set default color --- package/kernel/leds-ws2812b/src/leds-ws2812b.c | 9 ++++++++- .../dts/mediatek/mt7986a-xiaomi-redmi-router-ax6000.dtsi | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/package/kernel/leds-ws2812b/src/leds-ws2812b.c b/package/kernel/leds-ws2812b/src/leds-ws2812b.c index 4627cae936..691240ef80 100644 --- a/package/kernel/leds-ws2812b/src/leds-ws2812b.c +++ b/package/kernel/leds-ws2812b/src/leds-ws2812b.c @@ -137,6 +137,8 @@ static int ws2812b_probe(struct spi_device *spi) LED_COLOR_ID_RED, LED_COLOR_ID_BLUE, }; + + u32 color_intensity[WS2812B_NUM_COLORS] = { 255, 255, 255, }; u32 cascade; ret = fwnode_property_read_u32(led_node, "reg", &cascade); @@ -157,6 +159,11 @@ static int ws2812b_probe(struct spi_device *spi) fwnode_property_read_u32_array(led_node, "color-index", color_idx, (size_t)cnt); + cnt = fwnode_property_count_u32(led_node, "color-intensity"); + if (cnt > 0 && cnt <= WS2812B_NUM_COLORS) + fwnode_property_read_u32_array(led_node, "color-intensity", + color_intensity, (size_t)cnt); + priv->leds[cur_led].mc_cdev.subled_info = priv->leds[cur_led].subled; priv->leds[cur_led].mc_cdev.num_colors = WS2812B_NUM_COLORS; @@ -165,7 +172,7 @@ static int ws2812b_probe(struct spi_device *spi) for (i = 0; i < WS2812B_NUM_COLORS; i++) { priv->leds[cur_led].subled[i].color_index = color_idx[i]; - priv->leds[cur_led].subled[i].intensity = 255; + priv->leds[cur_led].subled[i].intensity = color_intensity[i]; } priv->leds[cur_led].cascade = cascade; diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a-xiaomi-redmi-router-ax6000.dtsi b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a-xiaomi-redmi-router-ax6000.dtsi index aace2664bc..50fed0a0ca 100644 --- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a-xiaomi-redmi-router-ax6000.dtsi +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a-xiaomi-redmi-router-ax6000.dtsi @@ -171,12 +171,14 @@ reg = <0>; label = "rgb:status"; color-index = ; + color-intensity = <0 255 0>; /* GREEN */ }; led_network_rgb: led@1 { reg = <1>; label = "rgb:network"; color-index = ; + color-intensity = <0 0 255>; /* BLUE */ }; }; };