Skip to content

Commit

Permalink
fix: Fix wakeup from kscan wrapped in sideband.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
petejohanson committed Sep 16, 2024
1 parent 9274590 commit 32d0a4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 7 additions & 0 deletions app/src/kscan_sideband_behaviors.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ static int ksbb_enable(const struct device *dev) {
pm_device_runtime_get(config->kscan);
}
#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);
#endif // IS_ENABLED(CONFIG_PM_DEVICE)

Expand All @@ -132,6 +135,10 @@ static int ksbb_disable(const struct device *dev) {
pm_device_runtime_put(config->kscan);
}
#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);
#endif // IS_ENABLED(CONFIG_PM_DEVICE)

Expand Down
7 changes: 3 additions & 4 deletions app/src/physical_layouts.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,9 @@ static int zmk_physical_layouts_init(void) {
#if IS_ENABLED(CONFIG_PM_DEVICE)
for (int l = 0; l < ARRAY_SIZE(layouts); l++) {
const struct zmk_physical_layout *pl = layouts[l];
if (pl->kscan) {
if (pm_device_wakeup_is_capable(pl->kscan)) {
pm_device_wakeup_enable(pl->kscan, true);
}
if (pl->kscan && pm_device_wakeup_is_capable(pl->kscan) &&
!pm_device_wakeup_enable(pl->kscan, true)) {
LOG_WRN("Failed to wakeup enable %s", pl->kscan->name);
}
}
#endif // IS_ENABLED(CONFIG_PM_DEVICE)
Expand Down

0 comments on commit 32d0a4b

Please sign in to comment.