Do not duplicate kbled support. Add kbled_max and kbled_get_color functions
This commit is contained in:
parent
9309efb3e0
commit
5bab59a526
@ -6,6 +6,9 @@ EC=it8587e
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=rgb_pwm
|
||||||
|
|
||||||
# Set discrete GPU I2C bus
|
# Set discrete GPU I2C bus
|
||||||
CFLAGS+=-DI2C_DGPU=I2C_1
|
CFLAGS+=-DI2C_DGPU=I2C_1
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ EC=it5570e
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=rgb_pwm
|
||||||
|
|
||||||
# Set discrete GPU I2C bus
|
# Set discrete GPU I2C bus
|
||||||
CFLAGS+=-DI2C_DGPU=I2C_1
|
CFLAGS+=-DI2C_DGPU=I2C_1
|
||||||
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
#include <board/kbled.h>
|
|
||||||
#include <ec/pwm.h>
|
|
||||||
|
|
||||||
void kbled_init(void) {
|
|
||||||
//TODO: enable PWMs
|
|
||||||
kbled_reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_reset(void) {
|
|
||||||
// Set brightness and color
|
|
||||||
kbled_set_color(0xFFFFFF);
|
|
||||||
kbled_set(0x00);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t kbled_get(void) {
|
|
||||||
// Get PWM for power
|
|
||||||
return DCR0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
|
||||||
// Set PWM for power
|
|
||||||
DCR0 = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) {
|
|
||||||
// Set PWM for blue component
|
|
||||||
DCR7 = (uint8_t)(color);
|
|
||||||
|
|
||||||
// Set PWM for green component
|
|
||||||
DCR6 = (uint8_t)(color >> 8);
|
|
||||||
|
|
||||||
// Set PWM for red component
|
|
||||||
DCR5 = (uint8_t)(color >> 16);
|
|
||||||
}
|
|
@ -6,6 +6,9 @@ EC=it5570e
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=bonw14
|
||||||
|
|
||||||
# Set discrete GPU I2C bus
|
# Set discrete GPU I2C bus
|
||||||
CFLAGS+=-DI2C_DGPU=I2C_1
|
CFLAGS+=-DI2C_DGPU=I2C_1
|
||||||
|
|
||||||
|
@ -28,6 +28,10 @@ CFLAGS+=-I$(SYSTEM76_COMMON_DIR)/include
|
|||||||
CHARGER?=bq24780s
|
CHARGER?=bq24780s
|
||||||
SRC+=$(SYSTEM76_COMMON_DIR)/charger/$(CHARGER).c
|
SRC+=$(SYSTEM76_COMMON_DIR)/charger/$(CHARGER).c
|
||||||
|
|
||||||
|
# Add kbled
|
||||||
|
KBLED?=none
|
||||||
|
SRC+=$(SYSTEM76_COMMON_DIR)/kbled/$(KBLED).c
|
||||||
|
|
||||||
# Add scratch ROM
|
# Add scratch ROM
|
||||||
include $(SYSTEM76_COMMON_DIR)/scratch/scratch.mk
|
include $(SYSTEM76_COMMON_DIR)/scratch/scratch.mk
|
||||||
|
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
void kbled_init(void);
|
void kbled_init(void);
|
||||||
void kbled_reset(void);
|
void kbled_reset(void);
|
||||||
uint8_t kbled_get(void);
|
uint8_t kbled_get(void);
|
||||||
|
uint8_t kbled_max(void);
|
||||||
void kbled_set(uint8_t level);
|
void kbled_set(uint8_t level);
|
||||||
|
uint32_t kbled_get_color(void);
|
||||||
void kbled_set_color(uint32_t color);
|
void kbled_set_color(uint32_t color);
|
||||||
|
|
||||||
// Provided by common code
|
// Provided by common code
|
||||||
|
@ -27,16 +27,13 @@ void kbled_reset(void) {
|
|||||||
kbled_set(0x00);
|
kbled_set(0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t kbled_get(void) {
|
// Keep the following functions for compatibility - they are set via USB HID
|
||||||
return 0;
|
uint8_t kbled_get(void) { /*Always off*/ return 0; }
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
uint8_t kbled_max(void) { /*Always off*/ return 0; }
|
||||||
// Keep function for compatibility - this is set via USB HID
|
|
||||||
level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) {
|
void kbled_set(uint8_t level) { /*Fix unused variable*/ level = level; }
|
||||||
// Keep function for compatibility - this is set via USB HID
|
|
||||||
color = color;
|
uint32_t kbled_get_color(void) { /*Always black*/ return 0; }
|
||||||
}
|
|
||||||
|
void kbled_set_color(uint32_t color) { /*Fix unused variable*/ color = color; }
|
@ -39,10 +39,31 @@ uint8_t kbled_get(void) {
|
|||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t kbled_max(void) {
|
||||||
|
return 255;
|
||||||
|
}
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
void kbled_set(uint8_t level) {
|
||||||
kbled_i2c_set(0x12, &level, 1);
|
kbled_i2c_set(0x12, &level, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t kbled_get_color(void) {
|
||||||
|
// Get blue component from channel 0
|
||||||
|
uint8_t value;
|
||||||
|
kbled_i2c_get(0x02, &value, 1);
|
||||||
|
uint32_t color = (uint32_t)value;
|
||||||
|
|
||||||
|
// Get green component from channel 3
|
||||||
|
kbled_i2c_get(0x05, &value, 1);
|
||||||
|
color |= ((uint32_t)value) << 8;
|
||||||
|
|
||||||
|
// Get red component from channel 6
|
||||||
|
kbled_i2c_get(0x08, &value, 1);
|
||||||
|
color |= ((uint32_t)value) << 16;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) {
|
void kbled_set_color(uint32_t color) {
|
||||||
// Set channel 0 - 2 to blue component
|
// Set channel 0 - 2 to blue component
|
||||||
uint8_t value = (uint8_t)(color);
|
uint8_t value = (uint8_t)(color);
|
17
src/board/system76/common/kbled/none.c
Normal file
17
src/board/system76/common/kbled/none.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
#include <board/kbled.h>
|
||||||
|
|
||||||
|
void kbled_init(void) {}
|
||||||
|
|
||||||
|
void kbled_reset(void) {}
|
||||||
|
|
||||||
|
uint8_t kbled_get(void) { /*Always off*/ return 0; }
|
||||||
|
|
||||||
|
uint8_t kbled_max(void) { /*Always off*/ return 0; }
|
||||||
|
|
||||||
|
void kbled_set(uint8_t level) { /*Fix unused variable*/ level = level; }
|
||||||
|
|
||||||
|
uint32_t kbled_get_color(void) { /*Always black*/ return 0; }
|
||||||
|
|
||||||
|
void kbled_set_color(uint32_t color) { /*Fix unused variable*/ color = color; }
|
@ -39,10 +39,31 @@ uint8_t kbled_get(void) {
|
|||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t kbled_max(void) {
|
||||||
|
return 255;
|
||||||
|
}
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
void kbled_set(uint8_t level) {
|
||||||
kbled_i2c_set(0x12, &level, 1);
|
kbled_i2c_set(0x12, &level, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t kbled_get_color(void) {
|
||||||
|
// Get blue component
|
||||||
|
uint8_t value;
|
||||||
|
kbled_i2c_get(0x02, &value, 1);
|
||||||
|
uint32_t color = (uint32_t)value;
|
||||||
|
|
||||||
|
// Get green component
|
||||||
|
kbled_i2c_get(0x03, &value, 1);
|
||||||
|
color |= ((uint32_t)value) << 8;
|
||||||
|
|
||||||
|
// Get red component
|
||||||
|
kbled_i2c_get(0x04, &value, 1);
|
||||||
|
color |= ((uint32_t)value) << 16;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) {
|
void kbled_set_color(uint32_t color) {
|
||||||
// Set blue component
|
// Set blue component
|
||||||
uint8_t value = (uint8_t)(color);
|
uint8_t value = (uint8_t)(color);
|
||||||
@ -50,13 +71,13 @@ void kbled_set_color(uint32_t color) {
|
|||||||
kbled_i2c_set(0x05, &value, 1);
|
kbled_i2c_set(0x05, &value, 1);
|
||||||
kbled_i2c_set(0x08, &value, 1);
|
kbled_i2c_set(0x08, &value, 1);
|
||||||
|
|
||||||
// Set red component
|
// Set green component
|
||||||
value = (uint8_t)(color >> 8);
|
value = (uint8_t)(color >> 8);
|
||||||
kbled_i2c_set(0x03, &value, 1);
|
kbled_i2c_set(0x03, &value, 1);
|
||||||
kbled_i2c_set(0x06, &value, 1);
|
kbled_i2c_set(0x06, &value, 1);
|
||||||
kbled_i2c_set(0x09, &value, 1);
|
kbled_i2c_set(0x09, &value, 1);
|
||||||
|
|
||||||
// Set green component
|
// Set red component
|
||||||
value = (uint8_t)(color >> 16);
|
value = (uint8_t)(color >> 16);
|
||||||
kbled_i2c_set(0x04, &value, 1);
|
kbled_i2c_set(0x04, &value, 1);
|
||||||
kbled_i2c_set(0x07, &value, 1);
|
kbled_i2c_set(0x07, &value, 1);
|
@ -19,11 +19,28 @@ uint8_t kbled_get(void) {
|
|||||||
return DCR0;
|
return DCR0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t kbled_max(void) {
|
||||||
|
return 255;
|
||||||
|
}
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
void kbled_set(uint8_t level) {
|
||||||
// Set PWM for power
|
// Set PWM for power
|
||||||
DCR0 = level;
|
DCR0 = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t kbled_get_color(void) {
|
||||||
|
// Get PWM of blue component
|
||||||
|
uint32_t color = (uint32_t)DCR7;
|
||||||
|
|
||||||
|
// Get PWM of green component
|
||||||
|
color |= ((uint32_t)DCR6) << 8;
|
||||||
|
|
||||||
|
// Get PWM of red component
|
||||||
|
color |= ((uint32_t)DCR5) << 16;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) {
|
void kbled_set_color(uint32_t color) {
|
||||||
// Set PWM for blue component
|
// Set PWM for blue component
|
||||||
DCR7 = (uint8_t)(color);
|
DCR7 = (uint8_t)(color);
|
@ -4,8 +4,11 @@
|
|||||||
#include <common/macro.h>
|
#include <common/macro.h>
|
||||||
#include <ec/dac.h>
|
#include <ec/dac.h>
|
||||||
|
|
||||||
#define KBLED_DAC 2
|
#if !defined(KBLED_DAC)
|
||||||
#define KBLED_DACDAT DACDAT2
|
#error "KBLED_DAC must be defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define KBLED_DACDAT xconcat(DACDAT, KBLED_DAC)
|
||||||
|
|
||||||
static uint8_t __code levels[] = {
|
static uint8_t __code levels[] = {
|
||||||
0x00,
|
0x00,
|
||||||
@ -37,6 +40,10 @@ uint8_t kbled_get(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t kbled_max(void) {
|
||||||
|
return ARRAY_SIZE(levels) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
void kbled_set(uint8_t level) {
|
||||||
uint8_t raw = 0;
|
uint8_t raw = 0;
|
||||||
if (level < ARRAY_SIZE(levels)) {
|
if (level < ARRAY_SIZE(levels)) {
|
||||||
@ -45,4 +52,6 @@ void kbled_set(uint8_t level) {
|
|||||||
KBLED_DACDAT = raw;
|
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; }
|
void kbled_set_color(uint32_t color) { /*Fix unused variable*/ color = color; }
|
@ -6,12 +6,13 @@ EC=it8587e
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=darp5
|
||||||
|
CFLAGS+=-DI2C_KBLED=I2C_1
|
||||||
|
|
||||||
# Set battery I2C bus
|
# Set battery I2C bus
|
||||||
CFLAGS+=-DI2C_SMBUS=I2C_0
|
CFLAGS+=-DI2C_SMBUS=I2C_0
|
||||||
|
|
||||||
# Set keyboard LED I2C bus
|
|
||||||
CFLAGS+=-DI2C_KBLED=I2C_1
|
|
||||||
|
|
||||||
# Set touchpad PS2 bus
|
# Set touchpad PS2 bus
|
||||||
CFLAGS+=-DPS2_TOUCHPAD=PS2_3
|
CFLAGS+=-DPS2_TOUCHPAD=PS2_3
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@ CFLAGS+=-DEC_ESPI=1
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=rgb_pwm
|
||||||
|
|
||||||
# Set battery I2C bus
|
# Set battery I2C bus
|
||||||
CFLAGS+=-DI2C_SMBUS=I2C_4
|
CFLAGS+=-DI2C_SMBUS=I2C_4
|
||||||
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
#include <board/kbled.h>
|
|
||||||
#include <ec/pwm.h>
|
|
||||||
|
|
||||||
void kbled_init(void) {
|
|
||||||
//TODO: enable PWMs
|
|
||||||
kbled_reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_reset(void) {
|
|
||||||
// Set brightness and color
|
|
||||||
kbled_set_color(0xFFFFFF);
|
|
||||||
kbled_set(0x00);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t kbled_get(void) {
|
|
||||||
// Get PWM for power
|
|
||||||
return DCR0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
|
||||||
// Set PWM for power
|
|
||||||
DCR0 = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) {
|
|
||||||
// Set PWM for blue component
|
|
||||||
DCR7 = (uint8_t)(color);
|
|
||||||
|
|
||||||
// Set PWM for green component
|
|
||||||
DCR6 = (uint8_t)(color >> 8);
|
|
||||||
|
|
||||||
// Set PWM for red component
|
|
||||||
DCR5 = (uint8_t)(color >> 16);
|
|
||||||
}
|
|
@ -6,6 +6,10 @@ EC=it8587e
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=white_dac
|
||||||
|
CFLAGS+=-DKBLED_DAC=5
|
||||||
|
|
||||||
# Set battery I2C bus
|
# Set battery I2C bus
|
||||||
CFLAGS+=-DI2C_SMBUS=I2C_0
|
CFLAGS+=-DI2C_SMBUS=I2C_0
|
||||||
|
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
#include <board/kbled.h>
|
|
||||||
#include <common/macro.h>
|
|
||||||
#include <ec/dac.h>
|
|
||||||
|
|
||||||
#define KBLED_DAC 5
|
|
||||||
#define KBLED_DACDAT DACDAT5
|
|
||||||
|
|
||||||
static uint8_t __code levels[] = {
|
|
||||||
0x00,
|
|
||||||
0x80,
|
|
||||||
0x90,
|
|
||||||
0xA8,
|
|
||||||
0xC0,
|
|
||||||
0xFF
|
|
||||||
};
|
|
||||||
|
|
||||||
void kbled_init(void) {
|
|
||||||
// Enable DAC used for KBLIGHT_ADJ
|
|
||||||
DACPDREG &= ~(1 << 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
|
||||||
uint8_t raw = 0;
|
|
||||||
if (level < ARRAY_SIZE(levels)) {
|
|
||||||
raw = levels[level];
|
|
||||||
}
|
|
||||||
KBLED_DACDAT = raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) { /*Fix unused variable*/ color = color; }
|
|
@ -9,6 +9,10 @@ CFLAGS+=-DEC_ESPI=1
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=white_dac
|
||||||
|
CFLAGS+=-DKBLED_DAC=2
|
||||||
|
|
||||||
# Set discrete GPU I2C bus
|
# Set discrete GPU I2C bus
|
||||||
CFLAGS+=-DI2C_DGPU=I2C_1
|
CFLAGS+=-DI2C_DGPU=I2C_1
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ EC=it5570e
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=rgb_pwm
|
||||||
|
|
||||||
# Set discrete GPU I2C bus
|
# Set discrete GPU I2C bus
|
||||||
CFLAGS+=-DI2C_DGPU=I2C_1
|
CFLAGS+=-DI2C_DGPU=I2C_1
|
||||||
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
#include <board/kbled.h>
|
|
||||||
#include <ec/pwm.h>
|
|
||||||
|
|
||||||
void kbled_init(void) {
|
|
||||||
//TODO: enable PWMs
|
|
||||||
kbled_reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_reset(void) {
|
|
||||||
// Set brightness and color
|
|
||||||
kbled_set_color(0xFFFFFF);
|
|
||||||
kbled_set(0x00);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t kbled_get(void) {
|
|
||||||
// Get PWM for power
|
|
||||||
return DCR0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
|
||||||
// Set PWM for power
|
|
||||||
DCR0 = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) {
|
|
||||||
// Set PWM for blue component
|
|
||||||
DCR7 = (uint8_t)(color);
|
|
||||||
|
|
||||||
// Set PWM for green component
|
|
||||||
DCR6 = (uint8_t)(color >> 8);
|
|
||||||
|
|
||||||
// Set PWM for red component
|
|
||||||
DCR5 = (uint8_t)(color >> 16);
|
|
||||||
}
|
|
@ -9,6 +9,10 @@ CFLAGS+=-DEC_ESPI=1
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=white_dac
|
||||||
|
CFLAGS+=-DKBLED_DAC=2
|
||||||
|
|
||||||
# Set battery I2C bus
|
# Set battery I2C bus
|
||||||
CFLAGS+=-DI2C_SMBUS=I2C_4
|
CFLAGS+=-DI2C_SMBUS=I2C_4
|
||||||
|
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
#include <board/kbled.h>
|
|
||||||
#include <common/macro.h>
|
|
||||||
#include <ec/dac.h>
|
|
||||||
|
|
||||||
#define KBLED_DAC 2
|
|
||||||
#define KBLED_DACDAT DACDAT2
|
|
||||||
|
|
||||||
static uint8_t __code levels[] = {
|
|
||||||
0x00,
|
|
||||||
0x80,
|
|
||||||
0x90,
|
|
||||||
0xA8,
|
|
||||||
0xC0,
|
|
||||||
0xFF
|
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
|
||||||
uint8_t raw = 0;
|
|
||||||
if (level < ARRAY_SIZE(levels)) {
|
|
||||||
raw = levels[level];
|
|
||||||
}
|
|
||||||
KBLED_DACDAT = raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) { /*Fix unused variable*/ color = color; }
|
|
@ -6,6 +6,10 @@ EC=it5570e
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=white_dac
|
||||||
|
CFLAGS+=-DKBLED_DAC=2
|
||||||
|
|
||||||
# Set battery I2C bus
|
# Set battery I2C bus
|
||||||
CFLAGS+=-DI2C_SMBUS=I2C_4
|
CFLAGS+=-DI2C_SMBUS=I2C_4
|
||||||
|
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
#include <board/kbled.h>
|
|
||||||
#include <common/macro.h>
|
|
||||||
#include <ec/dac.h>
|
|
||||||
|
|
||||||
#define KBLED_DAC 2
|
|
||||||
#define KBLED_DACDAT DACDAT2
|
|
||||||
|
|
||||||
static uint8_t __code levels[] = {
|
|
||||||
0x00,
|
|
||||||
0x80,
|
|
||||||
0x90,
|
|
||||||
0xA8,
|
|
||||||
0xC0,
|
|
||||||
0xFF
|
|
||||||
};
|
|
||||||
|
|
||||||
void kbled_init(void) {
|
|
||||||
// Enable DAC used for KBLIGHT_ADJ
|
|
||||||
DACPDREG &= ~(1 << 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
|
||||||
uint8_t raw = 0;
|
|
||||||
if (level < ARRAY_SIZE(levels)) {
|
|
||||||
raw = levels[level];
|
|
||||||
}
|
|
||||||
KBLED_DACDAT = raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) { /*Fix unused variable*/ color = color; }
|
|
@ -6,15 +6,16 @@ EC=it8587e
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=oryp5
|
||||||
|
CFLAGS+=-DI2C_KBLED=I2C_1
|
||||||
|
|
||||||
# Set discrete GPU I2C bus
|
# Set discrete GPU I2C bus
|
||||||
CFLAGS+=-DI2C_DGPU=I2C_1
|
CFLAGS+=-DI2C_DGPU=I2C_1
|
||||||
|
|
||||||
# Set battery I2C bus
|
# Set battery I2C bus
|
||||||
CFLAGS+=-DI2C_SMBUS=I2C_0
|
CFLAGS+=-DI2C_SMBUS=I2C_0
|
||||||
|
|
||||||
# Set keyboard LED I2C bus
|
|
||||||
CFLAGS+=-DI2C_KBLED=I2C_1
|
|
||||||
|
|
||||||
# Set touchpad PS2 bus
|
# Set touchpad PS2 bus
|
||||||
CFLAGS+=-DPS2_TOUCHPAD=PS2_3
|
CFLAGS+=-DPS2_TOUCHPAD=PS2_3
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ EC=it5570e
|
|||||||
KEYMAP?=default
|
KEYMAP?=default
|
||||||
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
|
||||||
|
|
||||||
|
# Set keyboard LED mechanism
|
||||||
|
KBLED=rgb_pwm
|
||||||
|
|
||||||
# Set discrete GPU I2C bus
|
# Set discrete GPU I2C bus
|
||||||
CFLAGS+=-DI2C_DGPU=I2C_1
|
CFLAGS+=-DI2C_DGPU=I2C_1
|
||||||
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
#include <board/kbled.h>
|
|
||||||
#include <ec/pwm.h>
|
|
||||||
|
|
||||||
void kbled_init(void) {
|
|
||||||
//TODO: enable PWMs
|
|
||||||
kbled_reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_reset(void) {
|
|
||||||
// Set brightness and color
|
|
||||||
kbled_set_color(0xFFFFFF);
|
|
||||||
kbled_set(0x00);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t kbled_get(void) {
|
|
||||||
// Get PWM for power
|
|
||||||
return DCR0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set(uint8_t level) {
|
|
||||||
// Set PWM for power
|
|
||||||
DCR0 = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kbled_set_color(uint32_t color) {
|
|
||||||
// Set PWM for blue component
|
|
||||||
DCR7 = (uint8_t)(color);
|
|
||||||
|
|
||||||
// Set PWM for green component
|
|
||||||
DCR6 = (uint8_t)(color >> 8);
|
|
||||||
|
|
||||||
// Set PWM for red component
|
|
||||||
DCR5 = (uint8_t)(color >> 16);
|
|
||||||
}
|
|
@ -3,6 +3,9 @@
|
|||||||
#ifndef _COMMON_MACRO_H
|
#ifndef _COMMON_MACRO_H
|
||||||
#define _COMMON_MACRO_H
|
#define _COMMON_MACRO_H
|
||||||
|
|
||||||
|
#define xconcat(a, b) concat(a, b)
|
||||||
|
#define concat(a, b) a ## b
|
||||||
|
|
||||||
#define xstr(s) str(s)
|
#define xstr(s) str(s)
|
||||||
#define str(s) #s
|
#define str(s) #s
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user