aboutsummaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorsvek1 <[email protected]>2024-12-11 20:46:22 +0100
committerGitHub <[email protected]>2024-12-11 14:46:22 -0500
commita8f5ab67b5d449a2624e2de7ddfb264da778ea6c (patch)
tree8e934d393b1acea4007f8d7d91a02b0bcff19af3 /app
parent84baf929c9bb95f255d4bafd0e57f2ec47455fca (diff)
downloadzmk-a8f5ab67b5d449a2624e2de7ddfb264da778ea6c.tar.gz
zmk-a8f5ab67b5d449a2624e2de7ddfb264da778ea6c.zip
fix: allow kscan-composite to wake up device. (#2682)
* include kscan.yaml so we can set kscan-composite as a wakeup source * modify enable and disable callback to check for wakeup capabilities of composite and children * disable children wakeup source The disable function is only called when the composite is not an enabled wakeup source. In that case the children should also not be an enabled wakeup source, so they can get suspended
Diffstat (limited to 'app')
-rw-r--r--app/dts/bindings/zmk,kscan-composite.yaml2
-rw-r--r--app/module/drivers/kscan/kscan_composite.c15
2 files changed, 17 insertions, 0 deletions
diff --git a/app/dts/bindings/zmk,kscan-composite.yaml b/app/dts/bindings/zmk,kscan-composite.yaml
index ea6cc41619..2600eab7be 100644
--- a/app/dts/bindings/zmk,kscan-composite.yaml
+++ b/app/dts/bindings/zmk,kscan-composite.yaml
@@ -3,6 +3,8 @@ description: |
compatible: "zmk,kscan-composite"
+include: kscan.yaml
+
properties:
label:
type: string
diff --git a/app/module/drivers/kscan/kscan_composite.c b/app/module/drivers/kscan/kscan_composite.c
index 5b809d1721..18d957ec34 100644
--- a/app/module/drivers/kscan/kscan_composite.c
+++ b/app/module/drivers/kscan/kscan_composite.c
@@ -44,6 +44,13 @@ static int kscan_composite_enable_callback(const struct device *dev) {
for (int i = 0; i < cfg->children_len; i++) {
const struct kscan_composite_child_config *child_cfg = &cfg->children[i];
+#if IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) || IS_ENABLED(CONFIG_PM_DEVICE)
+ if (pm_device_wakeup_is_enabled(dev) && pm_device_wakeup_is_capable(child_cfg->child) &&
+ !pm_device_wakeup_enable(child_cfg->child, true)) {
+ LOG_ERR("Failed to enable wakeup for %s", child_cfg->child->name);
+ }
+#endif // IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) || IS_ENABLED(CONFIG_PM_DEVICE)
+
#if IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)
if (!pm_device_runtime_is_enabled(dev) && pm_device_runtime_is_enabled(child_cfg->child)) {
pm_device_runtime_get(child_cfg->child);
@@ -62,6 +69,14 @@ static int kscan_composite_disable_callback(const struct device *dev) {
for (int i = 0; i < cfg->children_len; i++) {
const struct kscan_composite_child_config *child_cfg = &cfg->children[i];
+#if IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) || IS_ENABLED(CONFIG_PM_DEVICE)
+ if (pm_device_wakeup_is_capable(child_cfg->child) &&
+ pm_device_wakeup_is_enabled(child_cfg->child) &&
+ !pm_device_wakeup_enable(child_cfg->child, false)) {
+ LOG_ERR("Failed to disable wakeup for %s", child_cfg->child->name);
+ }
+#endif // IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) || IS_ENABLED(CONFIG_PM_DEVICE)
+
kscan_disable_callback(child_cfg->child);
#if IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)