Update .clang-format for LLVM 14.0, available on Ubuntu 22.04. There is still plenty that clang-format sucks at or does wrong, so either add some more blocks to disable it, or just put up with it. Signed-off-by: Tim Crawford <tcrawford@system76.com>
66 lines
1.1 KiB
C
66 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <board/kbled.h>
|
|
#include <common/macro.h>
|
|
#include <ec/dac.h>
|
|
|
|
#if !defined(KBLED_DAC)
|
|
#error "KBLED_DAC must be defined"
|
|
#endif
|
|
|
|
#define KBLED_DACDAT xconcat(DACDAT, KBLED_DAC)
|
|
|
|
// clang-format off
|
|
static uint8_t __code levels[] = {
|
|
0x00,
|
|
0x80,
|
|
0x90,
|
|
0xA8,
|
|
0xC0,
|
|
0xFF
|
|
};
|
|
// clang-format on
|
|
|
|
void kbled_init(void) {
|
|
// Enable DAC used for KBLIGHT_ADJ
|
|
DACPDREG &= ~BIT(KBLED_DAC);
|
|
kbled_reset();
|
|
}
|
|
|
|
void kbled_reset(void) {
|
|
kbled_set(0);
|
|
}
|
|
|
|
uint8_t kbled_get(void) {
|
|
uint8_t level;
|
|
uint8_t raw = KBLED_DACDAT;
|
|
for (level = 0; level < ARRAY_SIZE(levels); level++) {
|
|
if (raw <= levels[level]) {
|
|
return level;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
uint8_t kbled_max(void) {
|
|
return ARRAY_SIZE(levels) - 1;
|
|
}
|
|
|
|
void kbled_set(uint8_t level) {
|
|
uint8_t raw = 0;
|
|
if (level < ARRAY_SIZE(levels)) {
|
|
raw = levels[level];
|
|
}
|
|
KBLED_DACDAT = raw;
|
|
}
|
|
|
|
uint32_t kbled_get_color(void) {
|
|
/* Always white */
|
|
return 0xFFFFFF;
|
|
}
|
|
|
|
void kbled_set_color(uint32_t color) {
|
|
/* Fix unused variable */
|
|
color = color;
|
|
}
|