Browse Source

refactor(kscan): Auto enable kscan drivers

The key scanning drivers are now automatically enabled when a DT node
with the matching "compatible" property is present and enabled, so they
no longer need to be manually set for each board.
xmkb
Joel Spadin 3 years ago committed by Pete Johanson
parent
commit
6d6efa32f5
  1. 6
      app/Kconfig
  2. 3
      app/boards/arm/ferris/Kconfig.defconfig
  3. 2
      app/boards/arm/ferris/ferris_rev02_defconfig
  4. 3
      app/boards/native_posix.conf
  5. 3
      app/boards/native_posix_64.conf
  6. 6
      app/drivers/kscan/CMakeLists.txt
  7. 32
      app/drivers/kscan/Kconfig
  8. 4
      app/drivers/kscan/kscan_gpio_demux.c
  9. 4
      app/drivers/kscan/kscan_gpio_direct.c
  10. 4
      app/drivers/kscan/kscan_gpio_matrix.c
  11. 3
      app/tests/backlight/basic/native_posix_64.conf
  12. 3
      app/tests/backlight/config-brt/native_posix_64.conf
  13. 3
      app/tests/backlight/config-on/native_posix_64.conf
  14. 3
      app/tests/backlight/config-step/native_posix_64.conf
  15. 3
      app/tests/backlight/cycle/native_posix_64.conf
  16. 3
      app/tests/backlight/low-brightness/native_posix_64.conf
  17. 3
      app/tests/wpm/1-single_keypress/native_posix_64.conf
  18. 3
      app/tests/wpm/2-multiple_keypress/native_posix_64.conf

6
app/Kconfig

@ -461,12 +461,6 @@ config ZMK_KSCAN_EVENT_QUEUE_SIZE @@ -461,12 +461,6 @@ config ZMK_KSCAN_EVENT_QUEUE_SIZE
int "Size of the event queue for KSCAN events to buffer events"
default 4
config ZMK_KSCAN_MOCK_DRIVER
bool "Enable mock kscan driver to simulate key presses"
config ZMK_KSCAN_COMPOSITE_DRIVER
bool "Enable composite kscan driver to combine kscan devices"
#KSCAN Settings
endmenu

3
app/boards/arm/ferris/Kconfig.defconfig

@ -17,7 +17,4 @@ config ZMK_USB @@ -17,7 +17,4 @@ config ZMK_USB
config ZMK_KSCAN_MATRIX_POLLING
default y
config ZMK_KSCAN_COMPOSITE_DRIVER
default y
endif # BOARD_FERRIS

2
app/boards/arm/ferris/ferris_rev02_defconfig

@ -17,8 +17,6 @@ CONFIG_I2C=y @@ -17,8 +17,6 @@ CONFIG_I2C=y
# ZMK Settings
CONFIG_ZMK_USB=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=y
CONFIG_ZMK_KSCAN_COMPOSITE_DRIVER=y
CONFIG_ZMK_KSCAN_MATRIX_POLLING=y
CONFIG_USB_SELF_POWERED=n

3
app/boards/native_posix.conf

@ -1,6 +1,3 @@ @@ -1,6 +1,3 @@
CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=n
CONFIG_ZMK_BLE=n
CONFIG_LOG=y

3
app/boards/native_posix_64.conf

@ -1,6 +1,3 @@ @@ -1,6 +1,3 @@
CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=n
# Enable to have the native posix build expose USBIP device(s)
# CONFIG_ZMK_USB=y

6
app/drivers/kscan/CMakeLists.txt

@ -5,8 +5,8 @@ zephyr_library_named(zmk__drivers__kscan) @@ -5,8 +5,8 @@ zephyr_library_named(zmk__drivers__kscan)
zephyr_library_include_directories(${CMAKE_SOURCE_DIR}/include)
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER debounce.c)
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER kscan_gpio_matrix.c)
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER kscan_gpio_direct.c)
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DRIVER kscan_gpio_demux.c)
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_MATRIX kscan_gpio_matrix.c)
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DIRECT kscan_gpio_direct.c)
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_GPIO_DEMUX kscan_gpio_demux.c)
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_MOCK_DRIVER kscan_mock.c)
zephyr_library_sources_ifdef(CONFIG_ZMK_KSCAN_COMPOSITE_DRIVER kscan_composite.c)

32
app/drivers/kscan/Kconfig

@ -1,11 +1,39 @@ @@ -1,11 +1,39 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
DT_COMPAT_ZMK_KSCAN_COMPOSITE := zmk,kscan-composite
DT_COMPAT_ZMK_KSCAN_GPIO_DEMUX := zmk,kscan-gpio-demux
DT_COMPAT_ZMK_KSCAN_GPIO_DIRECT := zmk,kscan-gpio-direct
DT_COMPAT_ZMK_KSCAN_GPIO_MATRIX := zmk,kscan-gpio-matrix
DT_COMPAT_ZMK_KSCAN_MOCK := zmk,kscan-mock
config ZMK_KSCAN_COMPOSITE_DRIVER
bool
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_KSCAN_COMPOSITE))
config ZMK_KSCAN_GPIO_DRIVER
bool "Enable GPIO kscan driver to detect key presses"
default y
bool
select GPIO
config ZMK_KSCAN_GPIO_DEMUX
bool
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_KSCAN_GPIO_DEMUX))
select ZMK_KSCAN_GPIO_DRIVER
config ZMK_KSCAN_GPIO_DIRECT
bool
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_KSCAN_GPIO_DIRECT))
select ZMK_KSCAN_GPIO_DRIVER
config ZMK_KSCAN_GPIO_MATRIX
bool
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_KSCAN_GPIO_MATRIX))
select ZMK_KSCAN_GPIO_DRIVER
config ZMK_KSCAN_MOCK_DRIVER
bool
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_KSCAN_MOCK))
if ZMK_KSCAN_GPIO_DRIVER
config ZMK_KSCAN_MATRIX_POLLING

4
app/drivers/kscan/kscan_gpio_demux.c

@ -13,8 +13,6 @@ @@ -13,8 +13,6 @@
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
struct kscan_gpio_item_config {
char *label;
gpio_pin_t pin;
@ -251,5 +249,3 @@ struct kscan_gpio_item_config { @@ -251,5 +249,3 @@ struct kscan_gpio_item_config {
&gpio_driver_api_##n);
DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT)
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */

4
app/drivers/kscan/kscan_gpio_direct.c

@ -13,8 +13,6 @@ @@ -13,8 +13,6 @@
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
struct kscan_gpio_item_config {
char *label;
gpio_pin_t pin;
@ -242,5 +240,3 @@ static const struct kscan_driver_api gpio_driver_api = { @@ -242,5 +240,3 @@ static const struct kscan_driver_api gpio_driver_api = {
&gpio_driver_api);
DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT)
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */

4
app/drivers/kscan/kscan_gpio_matrix.c

@ -19,8 +19,6 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -19,8 +19,6 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#define DT_DRV_COMPAT zmk_kscan_gpio_matrix
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
#define INST_DIODE_DIR(n) DT_ENUM_IDX(DT_DRV_INST(n), diode_direction)
#define COND_DIODE_DIR(n, row2col_code, col2row_code) \
COND_CODE_0(INST_DIODE_DIR(n), row2col_code, col2row_code)
@ -463,5 +461,3 @@ static const struct kscan_driver_api kscan_matrix_api = { @@ -463,5 +461,3 @@ static const struct kscan_driver_api kscan_matrix_api = {
CONFIG_APPLICATION_INIT_PRIORITY, &kscan_matrix_api);
DT_INST_FOREACH_STATUS_OKAY(KSCAN_MATRIX_INIT);
#endif // DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)

3
app/tests/backlight/basic/native_posix_64.conf

@ -1,6 +1,3 @@ @@ -1,6 +1,3 @@
CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=y
CONFIG_GPIO_EMUL=y
CONFIG_ZMK_BLE=n

3
app/tests/backlight/config-brt/native_posix_64.conf

@ -1,6 +1,3 @@ @@ -1,6 +1,3 @@
CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=y
CONFIG_GPIO_EMUL=y
CONFIG_ZMK_BLE=n

3
app/tests/backlight/config-on/native_posix_64.conf

@ -1,6 +1,3 @@ @@ -1,6 +1,3 @@
CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=y
CONFIG_GPIO_EMUL=y
CONFIG_ZMK_BLE=n

3
app/tests/backlight/config-step/native_posix_64.conf

@ -1,6 +1,3 @@ @@ -1,6 +1,3 @@
CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=y
CONFIG_GPIO_EMUL=y
CONFIG_ZMK_BLE=n

3
app/tests/backlight/cycle/native_posix_64.conf

@ -1,6 +1,3 @@ @@ -1,6 +1,3 @@
CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=y
CONFIG_GPIO_EMUL=y
CONFIG_ZMK_BLE=n

3
app/tests/backlight/low-brightness/native_posix_64.conf

@ -1,6 +1,3 @@ @@ -1,6 +1,3 @@
CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=y
CONFIG_GPIO_EMUL=y
CONFIG_ZMK_BLE=n

3
app/tests/wpm/1-single_keypress/native_posix_64.conf

@ -1,6 +1,3 @@ @@ -1,6 +1,3 @@
CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=n
CONFIG_ZMK_BLE=n
CONFIG_LOG=y

3
app/tests/wpm/2-multiple_keypress/native_posix_64.conf

@ -1,6 +1,3 @@ @@ -1,6 +1,3 @@
CONFIG_KSCAN=n
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
CONFIG_GPIO=n
CONFIG_ZMK_BLE=n
CONFIG_LOG=y

Loading…
Cancel
Save