summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Baltieri <fabiobaltieri@google.com>2021-09-20 14:33:24 +0000
committerCommit Bot <commit-bot@chromium.org>2021-09-21 09:33:00 +0000
commitad3c72d45cbfea3f5c8150a1a39625c99d82f784 (patch)
treec7a8f09c9e6360912edbe76b7276c3a6c5e3777d
parentd8e0677d61d059e6c80db0e526de495b7d94a22b (diff)
downloadchrome-ec-ad3c72d45cbfea3f5c8150a1a39625c99d82f784.tar.gz
led_pwm: split color map on a separate structure
Currently color map is reusing the same structure as the channel and callback selection, which is a bit wasteful and somewhat confusing. Split it to its own struct with just three uint8_t fields. BRANCH=none BUG=none TEST=build only Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I56992fa9525db46980e450eb6569ba8291987b9b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3168864 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Yuval Peress <peress@google.com>
-rw-r--r--board/atlas/led.c2
-rw-r--r--board/boldar/led.c2
-rw-r--r--board/brya/led.c2
-rw-r--r--board/grunt/led.c2
-rw-r--r--board/kano/led.c2
-rw-r--r--board/liara/led.c2
-rw-r--r--board/nocturne/led.c13
-rw-r--r--board/terrador/led.c2
-rw-r--r--board/todor/led.c2
-rw-r--r--board/trondo/led.c2
-rw-r--r--board/volteer/led.c3
-rw-r--r--board/waddledee/led.c2
-rw-r--r--board/waddledoo/led.c2
-rw-r--r--board/wheelie/led.c2
-rw-r--r--include/led_pwm.h8
15 files changed, 27 insertions, 21 deletions
diff --git a/board/atlas/led.c b/board/atlas/led.c
index ec46d9d206..9cb4dabfd3 100644
--- a/board/atlas/led.c
+++ b/board/atlas/led.c
@@ -17,7 +17,7 @@ const enum ec_led_id supported_led_ids[] = {
};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
/* Red, Green, Blue */
[EC_LED_COLOR_RED] = { 70, 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 35, 0 },
diff --git a/board/boldar/led.c b/board/boldar/led.c
index 4486bcb912..6ee71bbe19 100644
--- a/board/boldar/led.c
+++ b/board/boldar/led.c
@@ -18,7 +18,7 @@ const enum ec_led_id supported_led_ids[] = {
};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-struct pwm_led led_color_map[] = {
+struct pwm_led_color_map led_color_map[] = {
/* Red, Green, Blue */
[EC_LED_COLOR_RED] = { 100, 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 100, 0 },
diff --git a/board/brya/led.c b/board/brya/led.c
index 38caa38d37..68945ec79e 100644
--- a/board/brya/led.c
+++ b/board/brya/led.c
@@ -29,7 +29,7 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
* We only have a white and an amber LED, so setting any other color results in
* both LEDs being off.
*/
-struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
/* Amber, White */
[EC_LED_COLOR_RED] = { 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 0 },
diff --git a/board/grunt/led.c b/board/grunt/led.c
index 9cd1122665..824ec55f6c 100644
--- a/board/grunt/led.c
+++ b/board/grunt/led.c
@@ -18,7 +18,7 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
* We only have a blue and an amber LED, so setting any other colour results in
* both LEDs being off.
*/
-struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
/* Amber, Blue */
[EC_LED_COLOR_RED] = { 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 0 },
diff --git a/board/kano/led.c b/board/kano/led.c
index 936a02503b..ab1021b845 100644
--- a/board/kano/led.c
+++ b/board/kano/led.c
@@ -29,7 +29,7 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
* We only have a white and an amber LED, so setting any other color results in
* both LEDs being off.
*/
-struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
/* Amber, White */
[EC_LED_COLOR_RED] = { 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 0 },
diff --git a/board/liara/led.c b/board/liara/led.c
index 8efb6150fc..371c08ce40 100644
--- a/board/liara/led.c
+++ b/board/liara/led.c
@@ -18,7 +18,7 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
* We only have a blue and an amber LED, so setting any other colour results in
* both LEDs being off.
*/
-struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
/* White, Amber */
[EC_LED_COLOR_RED] = { 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 0 },
diff --git a/board/nocturne/led.c b/board/nocturne/led.c
index a569f5b49f..b214a8df84 100644
--- a/board/nocturne/led.c
+++ b/board/nocturne/led.c
@@ -18,7 +18,7 @@ const enum ec_led_id supported_led_ids[] = {
};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-struct pwm_led led_color_map_v3[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map_v3[EC_LED_COLOR_COUNT] = {
/* Red, Green, Blue */
[EC_LED_COLOR_RED] = { 36, 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 15, 0 },
@@ -29,7 +29,7 @@ struct pwm_led led_color_map_v3[EC_LED_COLOR_COUNT] = {
};
/* Map for board rev 2 */
-struct pwm_led led_color_map_v2[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map_v2[EC_LED_COLOR_COUNT] = {
/* Red, Green, Blue */
[EC_LED_COLOR_RED] = { 62, 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 31, 0 },
@@ -40,7 +40,7 @@ struct pwm_led led_color_map_v2[EC_LED_COLOR_COUNT] = {
};
/* Map for board rev 0 and 1 */
-struct pwm_led led_color_map_v0_1[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map_v0_1[EC_LED_COLOR_COUNT] = {
/* Red, Green, Blue */
[EC_LED_COLOR_RED] = { 1, 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 1, 0 },
@@ -50,7 +50,7 @@ struct pwm_led led_color_map_v0_1[EC_LED_COLOR_COUNT] = {
[EC_LED_COLOR_AMBER] = { 15, 1, 0 },
};
-struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = { { 0 } };
+struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = { { 0 } };
/* Two tri-color LEDs with red, green, and blue channels. */
struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = {
@@ -112,9 +112,10 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
return EC_SUCCESS;
}
-static void fill_led_color_map(struct pwm_led map[])
+static void fill_led_color_map(struct pwm_led_color_map map[])
{
- memcpy(led_color_map, map, EC_LED_COLOR_COUNT * sizeof(struct pwm_led));
+ memcpy(led_color_map, map,
+ EC_LED_COLOR_COUNT * sizeof(struct pwm_led_color_map));
}
static void select_color_map(void)
diff --git a/board/terrador/led.c b/board/terrador/led.c
index f792eb6e3f..640312bd64 100644
--- a/board/terrador/led.c
+++ b/board/terrador/led.c
@@ -18,7 +18,7 @@ const enum ec_led_id supported_led_ids[] = {
};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-struct pwm_led led_color_map[] = {
+struct pwm_led_color_map led_color_map[] = {
/* Green, Red, Blue */
[EC_LED_COLOR_GREEN] = { 100, 0, 0 },
[EC_LED_COLOR_RED] = { 0, 100, 0 },
diff --git a/board/todor/led.c b/board/todor/led.c
index c4053f0f10..31d1c6fe20 100644
--- a/board/todor/led.c
+++ b/board/todor/led.c
@@ -16,7 +16,7 @@ const enum ec_led_id supported_led_ids[] = {
};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-struct pwm_led led_color_map[] = {
+struct pwm_led_color_map led_color_map[] = {
/* Red, Green, Blue */
[EC_LED_COLOR_RED] = { 100, 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 100, 0 },
diff --git a/board/trondo/led.c b/board/trondo/led.c
index 735df935d2..981469af53 100644
--- a/board/trondo/led.c
+++ b/board/trondo/led.c
@@ -18,7 +18,7 @@ const enum ec_led_id supported_led_ids[] = {
};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-struct pwm_led led_color_map[] = {
+struct pwm_led_color_map led_color_map[] = {
/* Red, Green, Blue */
[EC_LED_COLOR_RED] = { 100, 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 100, 0 },
diff --git a/board/volteer/led.c b/board/volteer/led.c
index 35bede89c5..357cdd038a 100644
--- a/board/volteer/led.c
+++ b/board/volteer/led.c
@@ -18,7 +18,7 @@ const enum ec_led_id supported_led_ids[] = {
};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-struct pwm_led led_color_map[] = {
+struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
/* Red, Green, Blue */
[EC_LED_COLOR_RED] = { 100, 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 100, 0 },
@@ -112,4 +112,3 @@ static void board_led_init(void)
pwm_set_duty(PWM_CH_LED4_SIDESEL, 50);
}
DECLARE_HOOK(HOOK_INIT, board_led_init, HOOK_PRIO_DEFAULT);
-
diff --git a/board/waddledee/led.c b/board/waddledee/led.c
index b19e594fbd..058d23d761 100644
--- a/board/waddledee/led.c
+++ b/board/waddledee/led.c
@@ -19,7 +19,7 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
/*
* Board has one physical LED with red, green, and blue
*/
-struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
/* Red, Green, Blue */
[EC_LED_COLOR_RED] = { 100, 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 100, 0 },
diff --git a/board/waddledoo/led.c b/board/waddledoo/led.c
index ca9a05bd84..b9ff2e74e8 100644
--- a/board/waddledoo/led.c
+++ b/board/waddledoo/led.c
@@ -19,7 +19,7 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
* We only have a white and an amber LED, so setting any other colour results in
* both LEDs being off.
*/
-struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
/* Amber, White */
[EC_LED_COLOR_RED] = { 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 0 },
diff --git a/board/wheelie/led.c b/board/wheelie/led.c
index 8c65f54568..9524a68a84 100644
--- a/board/wheelie/led.c
+++ b/board/wheelie/led.c
@@ -19,7 +19,7 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
/*
* Board has one physical LED with red, green, and blue
*/
-struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = {
+struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
/* Red, Green, Blue */
[EC_LED_COLOR_RED] = { 100, 0, 0 },
[EC_LED_COLOR_GREEN] = { 0, 100, 0 },
diff --git a/include/led_pwm.h b/include/led_pwm.h
index e372f02aab..0f8b270d19 100644
--- a/include/led_pwm.h
+++ b/include/led_pwm.h
@@ -23,6 +23,12 @@ struct pwm_led {
void (*set_duty)(enum pwm_channel ch, int percent);
};
+struct pwm_led_color_map {
+ uint8_t ch0;
+ uint8_t ch1;
+ uint8_t ch2;
+};
+
enum pwm_led_id {
PWM_LED0 = 0,
#if CONFIG_LED_PWM_COUNT >= 2
@@ -39,7 +45,7 @@ enum pwm_led_id {
* all applicable channels. (e.g. A bi-color LED which has a red and green
* channel should define all 0s for EC_LED_COLOR_BLUE and EC_LED_COLOR_WHITE.)
*/
-extern struct pwm_led led_color_map[EC_LED_COLOR_COUNT];
+extern struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT];
/*
* A map of the PWM channels to logical PWM LEDs.