Conditionally compile KBLED support

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 <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2024-01-24 09:53:07 -07:00
committed by Jeremy Soller
parent ecac574671
commit fff6208f98
41 changed files with 79 additions and 35 deletions

View File

@ -11,6 +11,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -11,6 +11,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -17,6 +17,7 @@ CONFIG_SECURITY=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -11,6 +11,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=15in_102_nkey
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=bonw14
# Set discrete GPU I2C bus

View File

@ -17,6 +17,7 @@ CONFIG_SECURITY=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=bonw14
# Set discrete GPU I2C bus

View File

@ -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) {
@ -65,6 +66,7 @@ void fcommand(void) {
break;
}
break;
#endif // CONFIG_HAVE_KBLED
}
}

View File

@ -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
@ -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

View File

@ -5,6 +5,8 @@
#include <stdint.h>
#if CONFIG_HAVE_KBLED
enum KbledKind {
KBLED_NONE = 0,
KBLED_WHITE = 1,
@ -12,7 +14,7 @@ enum KbledKind {
};
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);
@ -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

View File

@ -1,32 +0,0 @@
// 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;
}

View File

@ -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;
@ -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
}
}

View File

@ -11,6 +11,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=darp5
CFLAGS+=-DI2C_KBLED=I2C_1

View File

@ -14,6 +14,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=darp5
CFLAGS+=-DI2C_KBLED=I2C_1

View File

@ -14,6 +14,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set battery I2C bus

View File

@ -14,6 +14,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set battery I2C bus

View File

@ -17,6 +17,7 @@ CONFIG_SECURITY=y
KEYBOARD=18H9LHA05
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set battery I2C bus

View File

@ -11,6 +11,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=14in_86
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=5

View File

@ -14,6 +14,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=14in_86
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=5

View File

@ -14,6 +14,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=14in_83
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

View File

@ -17,6 +17,7 @@ CONFIG_SECURITY=y
KEYBOARD=14in_83
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

View File

@ -20,6 +20,7 @@ CONFIG_SECURITY=y
KEYBOARD=14in_83
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

View File

@ -11,6 +11,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -14,6 +14,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -17,6 +17,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -14,6 +14,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -14,6 +14,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -17,6 +17,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -14,6 +14,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -17,6 +17,7 @@ CONFIG_SECURITY=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -14,6 +14,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=14in_83
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

View File

@ -14,6 +14,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=14in_83
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

View File

@ -17,6 +17,7 @@ CONFIG_SECURITY=y
KEYBOARD=14in_83
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

View File

@ -11,6 +11,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=14in_83
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2

View File

@ -20,6 +20,7 @@ CONFIG_SECURITY=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -19,6 +19,7 @@ CONFIG_SECURITY=y
KEYBOARD=18H9LHA04
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -11,6 +11,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=oryp5
CFLAGS+=-DI2C_KBLED=I2C_1

View File

@ -11,6 +11,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -11,6 +11,7 @@ CONFIG_EC_FLASH_SIZE_128K = y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -14,6 +14,7 @@ CONFIG_BUS_ESPI=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -17,6 +17,7 @@ CONFIG_SECURITY=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus

View File

@ -17,6 +17,7 @@ CONFIG_SECURITY=y
KEYBOARD=15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus