fix: Fix wakeup from kscan wrapped in sideband.

* If using a sideband kscan device to wrap a native kscan device,
  ensure the inner kscan device is also wakeup enabled to it can
  be waken from a deep sleep state by key press.
This commit is contained in:
Peter Johanson 2024-09-16 14:13:51 -06:00 committed by Pete Johanson
parent 92745903c9
commit 32d0a4bf41
2 changed files with 10 additions and 4 deletions

View File

@ -111,6 +111,9 @@ static int ksbb_enable(const struct device *dev) {
pm_device_runtime_get(config->kscan); pm_device_runtime_get(config->kscan);
} }
#elif IS_ENABLED(CONFIG_PM_DEVICE) #elif IS_ENABLED(CONFIG_PM_DEVICE)
if (pm_device_wakeup_is_capable(config->kscan)) {
pm_device_wakeup_enable(config->kscan, true);
}
pm_device_action_run(config->kscan, PM_DEVICE_ACTION_RESUME); pm_device_action_run(config->kscan, PM_DEVICE_ACTION_RESUME);
#endif // IS_ENABLED(CONFIG_PM_DEVICE) #endif // IS_ENABLED(CONFIG_PM_DEVICE)
@ -132,6 +135,10 @@ static int ksbb_disable(const struct device *dev) {
pm_device_runtime_put(config->kscan); pm_device_runtime_put(config->kscan);
} }
#elif IS_ENABLED(CONFIG_PM_DEVICE) #elif IS_ENABLED(CONFIG_PM_DEVICE)
if (pm_device_wakeup_is_capable(config->kscan) && !pm_device_wakeup_is_enabled(dev) &&
pm_device_wakeup_is_enabled(config->kscan)) {
pm_device_wakeup_enable(config->kscan, false);
}
pm_device_action_run(config->kscan, PM_DEVICE_ACTION_SUSPEND); pm_device_action_run(config->kscan, PM_DEVICE_ACTION_SUSPEND);
#endif // IS_ENABLED(CONFIG_PM_DEVICE) #endif // IS_ENABLED(CONFIG_PM_DEVICE)

View File

@ -393,10 +393,9 @@ static int zmk_physical_layouts_init(void) {
#if IS_ENABLED(CONFIG_PM_DEVICE) #if IS_ENABLED(CONFIG_PM_DEVICE)
for (int l = 0; l < ARRAY_SIZE(layouts); l++) { for (int l = 0; l < ARRAY_SIZE(layouts); l++) {
const struct zmk_physical_layout *pl = layouts[l]; const struct zmk_physical_layout *pl = layouts[l];
if (pl->kscan) { if (pl->kscan && pm_device_wakeup_is_capable(pl->kscan) &&
if (pm_device_wakeup_is_capable(pl->kscan)) { !pm_device_wakeup_enable(pl->kscan, true)) {
pm_device_wakeup_enable(pl->kscan, true); LOG_WRN("Failed to wakeup enable %s", pl->kscan->name);
}
} }
} }
#endif // IS_ENABLED(CONFIG_PM_DEVICE) #endif // IS_ENABLED(CONFIG_PM_DEVICE)