blob: 11a670df9cfa01a570fe530d5c6997e367b2be0b [file] [log] [blame]
#include "led.h"
#include "i2c_led_driver.h"
#define LED_NUM 1
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
LED leds_lp5018[LED_NUM] = {
{
false,
0,
0x29,
LED_DRIVER_TYPE_LP5018,
}
};
LED leds_aw210xx[LED_NUM] = {
{
false,
0,
0x21,
LED_DRIVER_TYPE_AW210XX,
}
};
static int leds_inited = 0;
static void init_leds(int led_driver_type) {
int ret = -1;
if (0 == leds_inited) {
if (led_driver_type == LED_DRIVER_TYPE_LP5018) {
ret = i2c_led_init(leds_lp5018, LED_NUM);
} else if (led_driver_type == LED_DRIVER_TYPE_AW210XX) {
ret = i2c_led_init(leds_aw210xx, LED_NUM);
}
if (ret == 0) {
leds_inited = 1;
}
}
return;
}
extern int lgpl_printf(const char *format, ...);
void detect_led_driver(int *led_driver_type) {
if (i2c_led_detect_driver(leds_lp5018, LED_NUM, led_driver_type) == 0) {
lgpl_printf("Detected LP5018 LED Driver\n");
} else if (i2c_led_detect_driver(leds_aw210xx, LED_NUM, led_driver_type) == 0) {
lgpl_printf("Detected AW21018 LED Driver\n");
} else {
lgpl_printf("Failed to detect LED Driver\n");
*led_driver_type = LED_DRIVER_TYPE_UNKNOWN;
}
}
void cold_boot_show_led_init_boot(int led_driver_type) {
init_leds(led_driver_type);
if (!leds_inited)
return;
// See go/vento-schematics for led channel mapping
unsigned char led_frame_29[32] = {
0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
i2c_led_show_frame(0, led_frame_29, ARRAY_SIZE(led_frame_29));
}
void cold_boot_show_led_done_boot() {
// See go/vento-schematics for led channel mapping
unsigned char led_frame_29[32] = {
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x9A, 0x9A, 0x9A,
0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A,
0x9A, 0x9A, 0x9A, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
if (!leds_inited)
return;
i2c_led_show_frame(0, led_frame_29, ARRAY_SIZE(led_frame_29));
}