From bfbbfe43e64e6f57cbef137a6078b3664e8524fa Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Fri, 19 May 2023 17:05:39 -0600 Subject: [PATCH] acpi: Update keyboard backlight functions Existing FDAT values remain unchanged in their functionality. New functionality is added to fill unused FDAT values. FDAT values correspond to the following functionality: - 0: Set brightness - 1: Get brightness - 2: Get backlight type (new) - 3: Set color - 4: Get color (new) - 5: - 6: Set brightness (duplicate) Signed-off-by: Tim Crawford --- src/board/system76/common/acpi.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/board/system76/common/acpi.c b/src/board/system76/common/acpi.c index 5ca29a5..3116e44 100644 --- a/src/board/system76/common/acpi.c +++ b/src/board/system76/common/acpi.c @@ -28,16 +28,20 @@ void fcommand(void) { // Keyboard backlight case 0xCA: switch (fdat) { - // Set white LED brightness - case 0x00: + // Set brightness + case 0: kbled_set(fbuf[0]); break; - // Get white LED brightness - case 0x01: + // Get brightness + case 1: fbuf[0] = kbled_get(); break; - // Set LED color - case 0x03: + // Get type + case 2: + fbuf[0] = kbled_kind; + break; + // Set color + case 3: // clang-format off kbled_set_color( ((uint32_t)fbuf[0]) | @@ -46,8 +50,17 @@ void fcommand(void) { ); // clang-format on break; - // Set LED brightness - case 0x06: + // Get color + case 4: + { + uint32_t color = kbled_get_color(); + fbuf[0] = color & 0xFF; + fbuf[1] = (color >> 16) & 0xFF; + fbuf[2] = (color >> 8) & 0xFF; + } + break; + // DUPLICATE: Set brightness + case 6: kbled_set(fbuf[0]); break; }