From db70b583ac60f563d46b1d4f3b8f893b39788c24 Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 29 Oct 2026 11:44:19 +0100 Subject: [PATCH] fwk: lotus: debounce input deck power-off A single full scan in which any hub board ID channel misreads cuts input deck power immediately, while power-on is already debounced by INPUT_MODULE_POWER_ON_DELAY. On affected units this power-cycles the keyboard and touchpad every few seconds in Auto mode. Require the deck to read as not fully populated for more than INPUT_MODULE_DISCON_DEBOUNCE before powering it off. BRANCH=fwk-tulip-29169 BUG=input deck power-cycles every few seconds in Auto mode TEST=none; not built or flashed (work machine). Needs verification on hardware: Auto mode should show no keyboard USB disconnects, and removing a module should still power the deck off. Signed-off-by: Arthur --- zephyr/program/framework/lotus/src/input_module.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/zephyr/program/framework/lotus/src/input_module.c b/zephyr/program/framework/lotus/src/input_module.c index 3a517601a3..50c46a3596 100644 --- a/zephyr/program/framework/lotus/src/input_module.c +++ b/zephyr/program/framework/lotus/src/input_module.c @@ -28,6 +28,7 @@ LOG_MODULE_REGISTER(inputmodule, LOG_LEVEL_INF); #define INPUT_MODULE_POLL_INTERVAL 10*MSEC #define INPUT_MODULE_POWER_ON_DELAY (300*MSEC) #define INPUT_MODULE_MUX_DELAY_US 2 +#define INPUT_MODULE_DISCON_DEBOUNCE (240*MSEC) int oc_count; int force_on; @@ -195,6 +196,7 @@ static void poll_c_deck(void) { static int turning_on_count; static int current_adc_ch = 0; + static int disconnect_counter = 0; hub_board_id[current_adc_ch] = get_hardware_id(ADC_HUB_BOARD_ID); current_adc_ch = (current_adc_ch + 1) % 8; @@ -224,6 +226,7 @@ static void poll_c_deck(void) turning_on_count > (INPUT_MODULE_POWER_ON_DELAY / (INPUT_MODULE_POLL_INTERVAL*8))) { enable_touchpad_emulate(0); inputdeck_set_power(true); + disconnect_counter = 0; deck_state = DECK_ON; LOG_INF("Input modules on"); } else if (hub_board_id[TOUCHPAD] != INPUT_MODULE_TOUCHPAD) { @@ -236,6 +239,15 @@ static void poll_c_deck(void) * if lid is closed input modules cannot be removed */ if (!input_deck_is_fully_populated()) { + ++disconnect_counter; + LOG_DBG("Deck not populated. Debounce counter at %d", + disconnect_counter); + } else { + disconnect_counter = 0; + } + + if (disconnect_counter > (INPUT_MODULE_DISCON_DEBOUNCE / + (INPUT_MODULE_POLL_INTERVAL*8))) { inputdeck_set_power(false); /* enable TP emulation */ enable_touchpad_emulate(1);