static void bd2802_set_on(struct bd2802_led *led, enum led_ids id,
                          enum led_colors color)
{
    u8 reg;

    if (bd2802_is_all_off(led) && !led->adf_on)
        bd2802_reset_cancel(led);

    reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT1SETUP);
    bd2802_write_byte(led->client, reg, led->rgb_current);
    reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT2SETUP);
    bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
    reg = bd2802_get_reg_addr(id, color, BD2802_REG_WAVEPATTERN);
    bd2802_write_byte(led->client, reg, BD2802_PATTERN_FULL);

    bd2802_enable(led, id);
    bd2802_update_state(led, id, color, BD2802_ON);
}
Пример #2
0
static void bd2802_update_state(struct bd2802_led *led, enum led_ids id,
                                enum led_colors color, enum led_bits led_bit)
{
    int i;
    u8 value;

    for (i = 0; i < LED_NUM; i++) {
        if (i == id) {
            switch (color) {
            case RED:
                led->led[i].r = led_bit;
                break;
            case GREEN:
                led->led[i].g = led_bit;
                break;
            case BLUE:
                led->led[i].b = led_bit;
                break;
            default:
                dev_err(&led->client->dev,
                        "%s: Invalid color\n", __func__);
                return;
            }
        }
    }

    if (led_bit == BD2802_BLINK || led_bit == BD2802_ON)
        return;

    if (!bd2802_is_led_off(led, id))
        return;

    if (bd2802_is_all_off(led) && !led->adf_on) {
        gpio_set_value(led->pdata->reset_gpio, 0);
        return;
    }

    /*
     * In this case, other led is turned on, and current led is turned
     * off. So set RGB LED Control register to stop the current RGB LED
     */
    value = (id == LED1) ? LED_CTL(1, 0) : LED_CTL(0, 1);
    bd2802_write_byte(led->client, BD2802_REG_CONTROL, value);
}