aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPeter Johanson <[email protected]>2024-08-05 12:12:17 -0600
committerPete Johanson <[email protected]>2024-10-08 10:20:39 -0600
commit47a17c64d71a1115fb1eb66bf2a7af90463be315 (patch)
treee4d06613376d40ed0f2261c408827fc92dee5948
parent6cac781adae07e13aab48053d50bfa1fc26856ce (diff)
downloadzmk-47a17c64d71a1115fb1eb66bf2a7af90463be315.tar.gz
zmk-47a17c64d71a1115fb1eb66bf2a7af90463be315.zip
fix: Defer auto enabling of kscan sideband.
* Now that device init of kscan sideband is in POST_KERNEL stage, use a separate SYS_INIT for auto enabling the device so processing of early/initial presses from referenced toggle mode kscan devices occurs at the proper time during init.
-rw-r--r--app/src/kscan_sideband_behaviors.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/app/src/kscan_sideband_behaviors.c b/app/src/kscan_sideband_behaviors.c
index 9f38e0fbcf..eab7f04302 100644
--- a/app/src/kscan_sideband_behaviors.c
+++ b/app/src/kscan_sideband_behaviors.c
@@ -168,16 +168,11 @@ static int ksbb_init(const struct device *dev) {
return -ENODEV;
}
- if (config->auto_enable) {
-#if !IS_ENABLED(CONFIG_PM_DEVICE)
- kscan_config(config->kscan, &ksbb_inner_kscan_callback);
- kscan_enable_callback(config->kscan);
-#else
- ksbb_pm_action(dev, PM_DEVICE_ACTION_RESUME);
- } else {
+#if IS_ENABLED(CONFIG_PM_DEVICE)
+ if (!config->auto_enable) {
pm_device_init_suspended(dev);
-#endif
}
+#endif
return 0;
}
@@ -196,6 +191,16 @@ static const struct kscan_driver_api ksbb_api = {
}
#define KSBB_INST(n) \
+ COND_CODE_1(DT_INST_PROP_OR(n, auto_enable, false), (static int ksbb_auto_enable_##n(void) { \
+ const struct device *dev = DEVICE_DT_GET(DT_DRV_INST(n)); \
+ COND_CODE_1(IS_ENABLED(CONFIG_PM_DEVICE), \
+ (ksbb_pm_action(dev, PM_DEVICE_ACTION_RESUME);), \
+ (const struct ksbb_config *config = dev->config; \
+ kscan_config(config->kscan, &ksbb_inner_kscan_callback); \
+ kscan_enable_callback(config->kscan);)) \
+ return 0; \
+ } SYS_INIT(ksbb_auto_enable_##n, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);), \
+ ()) \
static struct ksbb_entry entries_##n[] = { \
DT_INST_FOREACH_CHILD_STATUS_OKAY_SEP(n, ENTRY, (, ))}; \
const struct ksbb_config ksbb_config_##n = { \