Skip to content

Commit

Permalink
Conditionally compile KBLED support
Browse files Browse the repository at this point in the history
Remove the need for a "none" option by only adding KBLED sources when
enabled.

The resulting binaries with KBLED enabled (all of them) are identical.

Signed-off-by: Tim Crawford <[email protected]>
  • Loading branch information
crawfxrd committed Jan 24, 2024
1 parent 4b86176 commit 899f0bc
Show file tree
Hide file tree
Showing 41 changed files with 79 additions and 35 deletions.
1 change: 1 addition & 0 deletions src/board/system76/addw1/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_EC_ITE_IT8587E=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/addw2/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_EC_ITE_IT5570E=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/addw3/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CONFIG_SECURITY=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/bonw14/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_EC_ITE_IT5570E=y
KEYBOARD=15in_102_nkey

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=bonw14

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/bonw15/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CONFIG_SECURITY=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=bonw14

# Set discrete GPU I2C bus
Expand Down
2 changes: 2 additions & 0 deletions src/board/system76/common/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static uint8_t fbuf[4] = { 0, 0, 0, 0 };

void fcommand(void) {
switch (fcmd) {
#if CONFIG_HAVE_KBLED
// Keyboard backlight
case 0xCA:
switch (fdat) {
Expand Down Expand Up @@ -65,6 +66,7 @@ void fcommand(void) {
break;
}
break;
#endif // CONFIG_HAVE_KBLED
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/board/system76/common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ board-common-$(CONFIG_BUS_ESPI) += espi.c
board-common-y += fan.c
board-common-y += gctrl.c
board-common-y += kbc.c
board-common-y += kbled.c
board-common-y += kbscan.c
board-common-y += keymap.c
board-common-y += lid.c
Expand Down Expand Up @@ -88,8 +87,11 @@ KEYBOARD_DIR=src/keyboard/system76/$(KEYBOARD)
include $(KEYBOARD_DIR)/keyboard.mk

# Add kbled
KBLED?=none
ifeq ($(CONFIG_HAVE_KBLED),y)
CFLAGS += -DCONFIG_HAVE_KBLED=1
board-common-y += kbled/common.c
board-common-y += kbled/$(KBLED).c
endif

# Add scratch ROM
include $(SYSTEM76_COMMON_DIR)/scratch/scratch.mk
Expand Down
37 changes: 36 additions & 1 deletion src/board/system76/common/include/board/kbled.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@

#include <stdint.h>

#if CONFIG_HAVE_KBLED

enum KbledKind {
KBLED_NONE = 0,
KBLED_WHITE = 1,
KBLED_RGB = 2,
};
extern enum KbledKind kbled_kind;

// Must be specified by board
// Must be specified per mechanism
void kbled_init(void);
void kbled_reset(void);
uint8_t kbled_get(void);
Expand All @@ -28,4 +30,37 @@ void kbled_hotkey_up(void);
void kbled_hotkey_toggle(void);
void kbled_hotkey_step(void);

#else // CONFIG_HAVE_KBLED

static inline void kbled_init(void) {}
static inline void kbled_reset(void) {}

static inline uint8_t kbled_get(void) {
return 0;
}

static inline uint8_t kbled_max(void) {
return 0;
}

static inline void kbled_set(uint8_t level) {
(void)level;
}

static inline uint32_t kbled_get_color(void) {
return 0;
}

static inline void kbled_set_color(uint32_t color) {
(void)color;
}

static inline void kbled_hotkey_color(void) {}
static inline void kbled_hotkey_down(void) {}
static inline void kbled_hotkey_up(void) {}
static inline void kbled_hotkey_toggle(void) {}
static inline void kbled_hotkey_step(void) {}

#endif // CONFIG_HAVE_KBLED

#endif // _BOARD_KBLED_H
File renamed without changes.
32 changes: 0 additions & 32 deletions src/board/system76/common/kbled/none.c

This file was deleted.

2 changes: 2 additions & 0 deletions src/board/system76/common/kbscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ static void hardware_hotkey(uint16_t key) {
case K_FAN_TOGGLE:
fan_max = !fan_max;
break;
#if CONFIG_HAVE_KBLED
case K_KBD_BKL:
kbled_hotkey_step();
break;
Expand All @@ -150,6 +151,7 @@ static void hardware_hotkey(uint16_t key) {
if (acpi_ecos != EC_OS_FULL)
kbled_hotkey_toggle();
break;
#endif // CONFIG_HAVE_KBLED
}
}

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/darp5/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_EC_ITE_IT8587E=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=darp5
CFLAGS+=-DI2C_KBLED=I2C_1

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/darp6/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_EC_ITE_IT8587E=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=darp5
CFLAGS+=-DI2C_KBLED=I2C_1

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/darp7/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set battery I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/darp8/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set battery I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/darp9/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CONFIG_SECURITY=y
KEYBOARD=18H9LHA05

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set battery I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/galp3-c/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_EC_ITE_IT8587E=y
KEYBOARD=14in_86

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=5

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/galp4/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_EC_ITE_IT8587E=y
KEYBOARD=14in_86

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=5

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/galp5/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=14in_83

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/galp6/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CONFIG_SECURITY=y
KEYBOARD=14in_83

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/galp7/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CONFIG_SECURITY=y
KEYBOARD=14in_83

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/gaze15/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_EC_ITE_IT5570E=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/gaze16-3050/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/gaze16-3060-b/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/gaze16-3060/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/gaze17-3050/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/gaze17-3060-b/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/gaze17-3060/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/gaze18/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CONFIG_SECURITY=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/lemp10/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=14in_83

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/lemp11/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=14in_83

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/lemp12/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CONFIG_SECURITY=y
KEYBOARD=14in_83

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/lemp9/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_EC_ITE_IT5570E=y
KEYBOARD=14in_83

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/oryp10/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CONFIG_SECURITY=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/oryp11/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CONFIG_SECURITY=y
KEYBOARD=18H9LHA04

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/oryp5/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_EC_ITE_IT8587E=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=oryp5
CFLAGS+=-DI2C_KBLED=I2C_1

Expand Down
1 change: 1 addition & 0 deletions src/board/system76/oryp6/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_EC_ITE_IT5570E=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
1 change: 1 addition & 0 deletions src/board/system76/oryp7/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_EC_ITE_IT5570E=y
KEYBOARD=15in_102

# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm

# Set discrete GPU I2C bus
Expand Down
Loading

0 comments on commit 899f0bc

Please sign in to comment.