kscan: drop kscan and any reference
Drop the whole kscan subsystem and reference to it. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
parent
501b95ff9b
commit
60a9a202df
69 changed files with 8 additions and 1077 deletions
|
@ -1777,24 +1777,6 @@ Release Notes:
|
|||
tests:
|
||||
- drivers.ipm
|
||||
|
||||
"Drivers: kscan":
|
||||
status: maintained
|
||||
maintainers:
|
||||
- albertofloyd
|
||||
collaborators:
|
||||
- VenkatKotakonda
|
||||
files:
|
||||
- drivers/kscan/
|
||||
- include/zephyr/drivers/kscan.h
|
||||
- samples/drivers/kscan/
|
||||
- tests/drivers/kscan/
|
||||
- dts/bindings/kscan/
|
||||
- doc/hardware/peripherals/kscan.rst
|
||||
labels:
|
||||
- "area: Kscan"
|
||||
tests:
|
||||
- drivers.kscan
|
||||
|
||||
"Drivers: LED":
|
||||
status: maintained
|
||||
maintainers:
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# Copyright (c) 2023 ITE Corporation. All Rights Reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if BOARD_IT82XX2_EVB
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
endif
|
|
@ -17,7 +17,6 @@
|
|||
i2c-0 = &i2c0;
|
||||
peci-0 = &peci0;
|
||||
led0 = &led0;
|
||||
kscan0 = &kscan_input;
|
||||
watchdog0 = &twd0;
|
||||
pwm-0 = &pwm0;
|
||||
};
|
||||
|
@ -30,7 +29,6 @@
|
|||
zephyr,flash = &flash0;
|
||||
zephyr,flash-controller = &flashctrl;
|
||||
zephyr,code-partition = &slot0_partition;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
leds {
|
||||
|
@ -196,10 +194,6 @@
|
|||
pinctrl-names = "default";
|
||||
row-size = <8>;
|
||||
col-size = <16>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
||||
&peci0 {
|
||||
|
|
|
@ -15,7 +15,6 @@ supported:
|
|||
- gpio
|
||||
- usb_device
|
||||
- i2c
|
||||
- kscan
|
||||
- pm
|
||||
- pwm
|
||||
- tach
|
||||
|
|
|
@ -14,7 +14,4 @@ endchoice
|
|||
|
||||
endif # PM
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
endif # BOARD_IT8XXX2_EVB
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
i2c-0 = &i2c0;
|
||||
peci-0 = &peci0;
|
||||
led0 = &led0;
|
||||
kscan0 = &kscan_input;
|
||||
watchdog0 = &twd0;
|
||||
pwm-0 = &pwm0;
|
||||
};
|
||||
|
@ -30,7 +29,6 @@
|
|||
zephyr,flash = &flash0;
|
||||
zephyr,flash-controller = &flashctrl;
|
||||
zephyr,code-partition = &slot0_partition;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
leds {
|
||||
|
@ -180,10 +178,6 @@
|
|||
pinctrl-names = "default";
|
||||
row-size = <8>;
|
||||
col-size = <16>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
&peci0 {
|
||||
status = "okay";
|
||||
|
|
|
@ -13,7 +13,6 @@ supported:
|
|||
- gpio
|
||||
- adc
|
||||
- i2c
|
||||
- kscan
|
||||
- pwm
|
||||
- watchdog
|
||||
vendor: ite
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
if BOARD_MEC1501MODULAR_ASSY6885
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
#PS/2 driver is compiled in terms of this flag.
|
||||
config ESPI_PERIPHERAL_8042_KBC
|
||||
default y
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
zephyr,sram = &sram0;
|
||||
zephyr,console = &uart1;
|
||||
zephyr,flash = &flash0;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
aliases {
|
||||
|
@ -26,7 +25,6 @@
|
|||
|
||||
i2c0 = &i2c_smb_0;
|
||||
i2c1 = &i2c_smb_1;
|
||||
kscan0 = &kscan_input;
|
||||
watchdog0 = &wdog;
|
||||
};
|
||||
};
|
||||
|
@ -120,10 +118,6 @@
|
|||
pinctrl-names = "default", "sleep";
|
||||
row-size = <8>;
|
||||
col-size = <16>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
||||
&peci0 {
|
||||
|
|
|
@ -21,6 +21,5 @@ supported:
|
|||
- i2c
|
||||
- pwm
|
||||
- watchdog
|
||||
- kscan
|
||||
- tach
|
||||
vendor: microchip
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
if BOARD_MEC15XXEVB_ASSY6853
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
config ESPI_XEC
|
||||
default y
|
||||
depends on ESPI
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
zephyr,sram = &sram0;
|
||||
zephyr,console = &uart2;
|
||||
zephyr,flash = &flash0;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
aliases {
|
||||
|
@ -29,7 +28,6 @@
|
|||
i2c-0 = &i2c_smb_0;
|
||||
i2c1 = &i2c_smb_1;
|
||||
i2c7 = &i2c_smb_2;
|
||||
kscan0 = &kscan_input;
|
||||
watchdog0 = &wdog;
|
||||
};
|
||||
|
||||
|
@ -177,10 +175,6 @@
|
|||
pinctrl-names = "default", "sleep";
|
||||
row-size = <8>;
|
||||
col-size = <16>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
||||
&peci0 {
|
||||
|
|
|
@ -21,5 +21,4 @@ supported:
|
|||
- i2c
|
||||
- pwm
|
||||
- watchdog
|
||||
- kscan
|
||||
vendor: microchip
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
if BOARD_MEC172XEVB_ASSY6906
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
if RTOS_TIMER
|
||||
|
||||
# XEC RTOS timer HW frequency is fixed at 32768 Hz.
|
||||
|
|
|
@ -233,10 +233,6 @@
|
|||
pinctrl-names = "default", "sleep";
|
||||
row-size = <8>;
|
||||
col-size = <16>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
||||
&ksi0_gpio017 {
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
if BOARD_MEC172XMODULAR_ASSY6930
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
if RTOS_TIMER
|
||||
|
||||
# XEC RTOS timer HW frequency is fixed at 32768 Hz.
|
||||
|
|
|
@ -211,10 +211,6 @@
|
|||
pinctrl-names = "default", "sleep";
|
||||
row-size = <8>;
|
||||
col-size = <16>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
||||
&ksi0_gpio017 {
|
||||
|
|
|
@ -3,6 +3,3 @@
|
|||
|
||||
config SYS_CLOCK_TICKS_PER_SEC
|
||||
default 1000
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
zephyr,console = &uart1;
|
||||
zephyr,shell-uart = &uart1;
|
||||
zephyr,flash = &flash0;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
aliases {
|
||||
|
@ -28,7 +27,6 @@
|
|||
i2c-0 = &i2c0_0;
|
||||
watchdog0 = &twd0;
|
||||
peci-0 = &peci0;
|
||||
kscan0 = &kscan_input;
|
||||
};
|
||||
|
||||
leds-pwm {
|
||||
|
@ -114,10 +112,6 @@
|
|||
row-size = <8>;
|
||||
col-size = <13>;
|
||||
status = "okay";
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
||||
&i3c0 {
|
||||
|
|
|
@ -3,6 +3,3 @@
|
|||
|
||||
config SYS_CLOCK_TICKS_PER_SEC
|
||||
default 1000
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
zephyr,console = &uart1;
|
||||
zephyr,shell-uart = &uart1;
|
||||
zephyr,flash = &flash0;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
aliases {
|
||||
|
@ -29,8 +28,6 @@
|
|||
i2c-0 = &i2c0_0;
|
||||
watchdog0 = &twd0;
|
||||
peci-0 = &peci0;
|
||||
/* For kscan test suites */
|
||||
kscan0 = &kscan_input;
|
||||
};
|
||||
|
||||
pwmleds {
|
||||
|
@ -118,8 +115,4 @@
|
|||
row-size = <8>;
|
||||
col-size = <6>;
|
||||
status = "okay";
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,6 +3,3 @@
|
|||
|
||||
config SYS_CLOCK_TICKS_PER_SEC
|
||||
default 1000
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
zephyr,console = &uart1;
|
||||
zephyr,shell-uart = &uart1;
|
||||
zephyr,flash = &flash0;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
aliases {
|
||||
|
@ -32,8 +31,6 @@
|
|||
/* For watchdog sample */
|
||||
watchdog0 = &twd0;
|
||||
peci-0 = &peci0;
|
||||
/* For kscan test suites */
|
||||
kscan0 = &kscan_input;
|
||||
};
|
||||
|
||||
leds-pwm {
|
||||
|
@ -137,8 +134,4 @@
|
|||
row-size = <8>;
|
||||
col-size = <13>;
|
||||
status = "okay";
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -7,6 +7,4 @@ toolchain:
|
|||
- gnuarmemb
|
||||
ram: 64
|
||||
flash: 512
|
||||
supported:
|
||||
- kscan:touch
|
||||
vendor: pine64
|
||||
|
|
|
@ -14,7 +14,7 @@ endif # DISPLAY
|
|||
|
||||
if LVGL
|
||||
|
||||
# Configure LVGL to use touchscreen with KSCAN API
|
||||
# Configure LVGL to use touchscreen
|
||||
|
||||
config INPUT
|
||||
default y
|
||||
|
|
|
@ -16,5 +16,4 @@ supported:
|
|||
- arduino_gpio
|
||||
- netif:eth
|
||||
- memc
|
||||
- kscan:touch
|
||||
vendor: st
|
||||
|
|
|
@ -193,7 +193,6 @@ REDIRECTS = [
|
|||
('reference/peripherals/i2c', 'hardware/peripherals/i2c'),
|
||||
('reference/peripherals/index', 'hardware/peripherals/index'),
|
||||
('reference/peripherals/ipm', 'hardware/peripherals/ipm'),
|
||||
('reference/peripherals/kscan', 'hardware/peripherals/kscan'),
|
||||
('reference/peripherals/led', 'hardware/peripherals/led'),
|
||||
('reference/peripherals/mbox', 'hardware/peripherals/mbox'),
|
||||
('reference/peripherals/mdio', 'hardware/peripherals/mdio'),
|
||||
|
@ -284,7 +283,6 @@ REDIRECTS = [
|
|||
('samples/boards/stm32/sensortile_box_pro/sensors-on-board/README', 'samples/boards/st/sensortile_box_pro/sensors-on-board/README'),
|
||||
('samples/boards/stm32/steval_stwinbx1/sensors/README', 'samples/boards/st/steval_stwinbx1/sensors/README'),
|
||||
('samples/drivers/adc/README', 'samples/drivers/adc/adc_dt/README'),
|
||||
('samples/drivers/kscan_touch', 'samples/subsys/input/input'),
|
||||
('samples/drivers/led_apa102/README', 'samples/drivers/led_strip/README'),
|
||||
('samples/drivers/led_is31fl3194/README', 'samples/drivers/led/is31fl3194/README'),
|
||||
('samples/drivers/led_is31fl3216a/README', 'samples/drivers/led/is31fl3216a/README'),
|
||||
|
|
|
@ -38,7 +38,6 @@ Peripherals
|
|||
i3c.rst
|
||||
i2c.rst
|
||||
ipm.rst
|
||||
kscan.rst
|
||||
led.rst
|
||||
mdio.rst
|
||||
mipi_dbi.rst
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
.. _kscan_api:
|
||||
|
||||
|
||||
Keyboard Scan
|
||||
#############
|
||||
|
||||
.. note:: Kscan APIs are deprecated, any driver and applications should be
|
||||
ported over to use :ref:`input` instead.
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
The kscan driver (keyboard scan matrix) is used for detecting a key press in a
|
||||
connected matrix keyboard or any device with buttons such as joysticks.
|
||||
Typically, matrix keyboards are implemented using a two-dimensional
|
||||
configuration in order to sense several keys. This allows interfacing to
|
||||
many keys through fewer physical pins. Keyboard matrix
|
||||
drivers read the rows while applying power through the columns one at a time
|
||||
with the purpose of detecting key events.
|
||||
There is no correlation between the physical and electrical layout of keys.
|
||||
For, example, the physical layout may be one array of 16 or fewer keys, which
|
||||
may be electrically connected to a 4 x 4 array. In addition, key values are
|
||||
defined by a keymap provided by the keyboard manufacturer.
|
||||
|
||||
Configuration Options
|
||||
*********************
|
||||
|
||||
Related configuration options:
|
||||
|
||||
* :kconfig:option:`CONFIG_KSCAN`
|
||||
|
||||
API Reference
|
||||
*************
|
||||
|
||||
.. doxygengroup:: kscan_interface
|
|
@ -150,12 +150,12 @@ Changes in this release
|
|||
* ``gpio_keys``: moved out of ``gpio``, replaced the custom API to use input
|
||||
events instead, the :dtcompatible:`zephyr,gpio-keys` binding is unchanged
|
||||
but now requires ``zephyr,code`` to be set.
|
||||
* ``ft5336``: moved from :ref:`kscan_api` to :ref:`input`, renamed the Kconfig
|
||||
* ``ft5336``: moved from ``kscan_api`` to :ref:`input`, renamed the Kconfig
|
||||
options from ``CONFIG_KSCAN_FT5336``, ``CONFIG_KSCAN_FT5336_PERIOD`` and
|
||||
``KSCAN_FT5336_INTERRUPT`` to :kconfig:option:`CONFIG_INPUT_FT5336`,
|
||||
:kconfig:option:`CONFIG_INPUT_FT5336_PERIOD` and
|
||||
:kconfig:option:`CONFIG_INPUT_FT5336_INTERRUPT`.
|
||||
* ``kscan_sdl``: moved from :ref:`kscan_api` to :ref:`input`, renamed the Kconfig
|
||||
* ``kscan_sdl``: moved from ``kscan_api`` to :ref:`input`, renamed the Kconfig
|
||||
option from ``KSCAN_SDL`` to :kconfig:option:`CONFIG_INPUT_SDL_TOUCH` and the
|
||||
compatible from ``zephyr,sdl-kscan`` to
|
||||
:dtcompatible:`zephyr,input-sdl-touch`.
|
||||
|
|
|
@ -108,7 +108,7 @@ Deprecated in this release
|
|||
* Deprecated the ``net_buf_put()`` and ``net_buf_get()`` API functions in favor of
|
||||
:c:func:`k_fifo_put` and :c:func:`k_fifo_get`.
|
||||
|
||||
* The :ref:`kscan_api` subsystem has been marked as deprecated.
|
||||
* The ``kscan_api`` subsystem has been marked as deprecated.
|
||||
|
||||
* Deprecated the TinyCrypt shim driver ``CONFIG_CRYPTO_TINYCRYPT_SHIM``.
|
||||
|
||||
|
|
|
@ -63,29 +63,6 @@ this purpose, the :c:func:`input_to_hid_code` and
|
|||
:c:func:`input_to_hid_modifier` functions can be used to map input codes to HID
|
||||
codes and modifiers.
|
||||
|
||||
Kscan Compatibility
|
||||
*******************
|
||||
|
||||
Input devices generating X/Y/Touch events can be used in existing applications
|
||||
based on the :ref:`kscan_api` API by enabling both
|
||||
:kconfig:option:`CONFIG_INPUT` and :kconfig:option:`CONFIG_KSCAN`, defining a
|
||||
:dtcompatible:`zephyr,kscan-input` node as a child node of the corresponding
|
||||
input device and pointing the ``zephyr,keyboard-scan`` chosen node to the
|
||||
compatibility device node, for example:
|
||||
|
||||
.. code-block:: devicetree
|
||||
|
||||
chosen {
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
ft5336@38 {
|
||||
...
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
||||
General Purpose Drivers
|
||||
***********************
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ add_subdirectory_ifdef(CONFIG_IEEE802154 ieee802154)
|
|||
add_subdirectory_ifdef(CONFIG_INPUT input)
|
||||
add_subdirectory_ifdef(CONFIG_INTEL_ADSP_MIC_PRIVACY audio/mic_privacy/intel)
|
||||
add_subdirectory_ifdef(CONFIG_IPM ipm)
|
||||
add_subdirectory_ifdef(CONFIG_KSCAN kscan)
|
||||
add_subdirectory_ifdef(CONFIG_LED led)
|
||||
add_subdirectory_ifdef(CONFIG_LED_STRIP led_strip)
|
||||
add_subdirectory_ifdef(CONFIG_LORA lora)
|
||||
|
|
|
@ -50,7 +50,6 @@ source "drivers/input/Kconfig"
|
|||
source "drivers/interrupt_controller/Kconfig"
|
||||
source "drivers/interrupt_controller/Kconfig.shared_irq"
|
||||
source "drivers/ipm/Kconfig"
|
||||
source "drivers/kscan/Kconfig"
|
||||
source "drivers/led/Kconfig"
|
||||
source "drivers/led_strip/Kconfig"
|
||||
source "drivers/lora/Kconfig"
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_syscall_header(${ZEPHYR_BASE}/include/zephyr/drivers/kscan.h)
|
||||
|
||||
zephyr_library()
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_KSCAN_INPUT kscan_input.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_USERSPACE kscan_handlers.c)
|
|
@ -1,26 +0,0 @@
|
|||
# Keyboard scan configuration options
|
||||
|
||||
# Copyright (c) 2019 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig KSCAN
|
||||
bool "Keyboard scan drivers [DEPRECATED]"
|
||||
select DEPRECATED
|
||||
help
|
||||
Include Keyboard scan drivers in system config.
|
||||
|
||||
if KSCAN
|
||||
|
||||
source "drivers/kscan/Kconfig.input"
|
||||
|
||||
module = KSCAN
|
||||
module-str = kscan
|
||||
source "subsys/logging/Kconfig.template.log_config"
|
||||
|
||||
config KSCAN_INIT_PRIORITY
|
||||
int "Keyboard scan driver init priority"
|
||||
default 90
|
||||
help
|
||||
Keyboard scan device driver initialization priority.
|
||||
|
||||
endif # KSCAN
|
|
@ -1,8 +0,0 @@
|
|||
# Copyright 2023 Google LLC
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config KSCAN_INPUT
|
||||
bool "Input subsystem to kscan adapter driver"
|
||||
default y
|
||||
depends on INPUT
|
||||
depends on DT_HAS_ZEPHYR_KSCAN_INPUT_ENABLED
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/drivers/kscan.h>
|
||||
#include <zephyr/internal/syscall_handler.h>
|
||||
|
||||
static inline int z_vrfy_kscan_config(const struct device *dev,
|
||||
kscan_callback_t callback_isr)
|
||||
{
|
||||
K_OOPS(K_SYSCALL_DRIVER_KSCAN(dev, config));
|
||||
K_OOPS(K_SYSCALL_VERIFY_MSG(callback_isr == 0,
|
||||
"callback cannot be set from user mode"));
|
||||
return z_impl_kscan_config((const struct device *)dev, callback_isr);
|
||||
}
|
||||
#include <zephyr/syscalls/kscan_config_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_kscan_disable_callback(const struct device *dev)
|
||||
{
|
||||
K_OOPS(K_SYSCALL_DRIVER_KSCAN(dev, disable_callback));
|
||||
|
||||
return z_impl_kscan_disable_callback((const struct device *)dev);
|
||||
}
|
||||
#include <zephyr/syscalls/kscan_disable_callback_mrsh.c>
|
||||
|
||||
static int z_vrfy_kscan_enable_callback(const struct device *dev)
|
||||
{
|
||||
K_OOPS(K_SYSCALL_DRIVER_KSCAN(dev, enable_callback));
|
||||
|
||||
return z_impl_kscan_enable_callback((const struct device *)dev);
|
||||
}
|
||||
#include <zephyr/syscalls/kscan_enable_callback_mrsh.c>
|
|
@ -1,118 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#define DT_DRV_COMPAT zephyr_kscan_input
|
||||
|
||||
#include <zephyr/drivers/kscan.h>
|
||||
#include <zephyr/input/input.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(kscan_input, CONFIG_KSCAN_LOG_LEVEL);
|
||||
|
||||
struct kscan_input_config {
|
||||
const struct device *input_dev;
|
||||
};
|
||||
|
||||
struct kscan_input_data {
|
||||
bool enabled;
|
||||
kscan_callback_t callback;
|
||||
int row;
|
||||
int col;
|
||||
bool pressed;
|
||||
};
|
||||
|
||||
static void kscan_input_cb(struct input_event *evt, void *user_data)
|
||||
{
|
||||
const struct device *dev = user_data;
|
||||
struct kscan_input_data *data = dev->data;
|
||||
|
||||
switch (evt->code) {
|
||||
case INPUT_ABS_X:
|
||||
data->col = evt->value;
|
||||
break;
|
||||
case INPUT_ABS_Y:
|
||||
data->row = evt->value;
|
||||
break;
|
||||
case INPUT_BTN_TOUCH:
|
||||
data->pressed = evt->value;
|
||||
break;
|
||||
}
|
||||
|
||||
if (evt->sync) {
|
||||
LOG_DBG("input event: %3d %3d %d",
|
||||
data->row, data->col, data->pressed);
|
||||
if (data->callback) {
|
||||
data->callback(dev, data->row, data->col, data->pressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int kscan_input_configure(const struct device *dev,
|
||||
kscan_callback_t callback)
|
||||
{
|
||||
struct kscan_input_data *data = dev->data;
|
||||
|
||||
if (!callback) {
|
||||
LOG_ERR("Invalid callback (NULL)");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
data->callback = callback;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int kscan_input_enable_callback(const struct device *dev)
|
||||
{
|
||||
struct kscan_input_data *data = dev->data;
|
||||
|
||||
data->enabled = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int kscan_input_disable_callback(const struct device *dev)
|
||||
{
|
||||
struct kscan_input_data *data = dev->data;
|
||||
|
||||
data->enabled = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int kscan_input_init(const struct device *dev)
|
||||
{
|
||||
const struct kscan_input_config *cfg = dev->config;
|
||||
|
||||
if (!device_is_ready(cfg->input_dev)) {
|
||||
LOG_ERR("Input device not ready");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DEVICE_API(kscan, kscan_input_driver_api) = {
|
||||
.config = kscan_input_configure,
|
||||
.enable_callback = kscan_input_enable_callback,
|
||||
.disable_callback = kscan_input_disable_callback,
|
||||
};
|
||||
|
||||
#define KSCAN_INPUT_INIT(index) \
|
||||
INPUT_CALLBACK_DEFINE_NAMED(DEVICE_DT_GET(DT_INST_PARENT(index)), \
|
||||
kscan_input_cb, \
|
||||
(void *)DEVICE_DT_INST_GET(index), \
|
||||
kscan_input_cb_##index); \
|
||||
static const struct kscan_input_config kscan_input_config_##index = { \
|
||||
.input_dev = DEVICE_DT_GET(DT_INST_PARENT(index)), \
|
||||
}; \
|
||||
static struct kscan_input_data kscan_input_data_##index; \
|
||||
DEVICE_DT_INST_DEFINE(index, kscan_input_init, NULL, \
|
||||
&kscan_input_data_##index, \
|
||||
&kscan_input_config_##index, \
|
||||
POST_KERNEL, CONFIG_KSCAN_INIT_PRIORITY, \
|
||||
&kscan_input_driver_api);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(KSCAN_INPUT_INIT)
|
|
@ -66,7 +66,6 @@ input Input
|
|||
interrupt-controller Interrupt controller
|
||||
ipc IPC (Inter-Processor Communication)
|
||||
ipm IPM (Inter-Processor Mailbox)
|
||||
kscan Keyscan
|
||||
led LED (Light Emitting Diode)
|
||||
led_strip LED (Light Emitting Diode) strip
|
||||
lora LoRa
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
# Copyright (c) 2019, Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Common properties for keyboard matrix devices
|
||||
|
||||
include: base.yaml
|
||||
|
||||
bus: kscan
|
|
@ -1,23 +0,0 @@
|
|||
# Copyright 2023 Google LLC
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
description: |
|
||||
Input to kscan adapter.
|
||||
|
||||
Allows using an input device with the kscan API. Define as a child node of
|
||||
the input device, for example
|
||||
|
||||
chosen {
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
ft5336@38 {
|
||||
...
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
||||
compatible: "zephyr,kscan-input"
|
||||
|
||||
include: kscan.yaml
|
|
@ -1,150 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Public API for Keyboard scan matrix devices.
|
||||
* The scope of this API is simply to report which key event was triggered
|
||||
* and users can later decode keys using their desired scan code tables in
|
||||
* their application. In addition, typematic rate and delay can easily be
|
||||
* implemented using a timer if desired.
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_DRIVERS_KB_SCAN_H_
|
||||
#define ZEPHYR_INCLUDE_DRIVERS_KB_SCAN_H_
|
||||
|
||||
#include <errno.h>
|
||||
#include <zephyr/types.h>
|
||||
#include <stddef.h>
|
||||
#include <zephyr/device.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief KSCAN APIs
|
||||
* @defgroup kscan_interface Keyboard Scan Driver APIs
|
||||
* @since 2.1
|
||||
* @version 1.0.0
|
||||
* @deprecated
|
||||
* @ingroup io_interfaces
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @brief Keyboard scan callback called when user press/release
|
||||
* a key on a matrix keyboard.
|
||||
*
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
* @param row Describes row change.
|
||||
* @param column Describes column change.
|
||||
* @param pressed Describes the kind of key event.
|
||||
*/
|
||||
typedef void (*kscan_callback_t)(const struct device *dev, uint32_t row,
|
||||
uint32_t column,
|
||||
bool pressed);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @cond INTERNAL_HIDDEN
|
||||
*
|
||||
* Keyboard scan driver API definition and system call entry points.
|
||||
*
|
||||
* (Internal use only.)
|
||||
*/
|
||||
typedef int (*kscan_config_t)(const struct device *dev,
|
||||
kscan_callback_t callback);
|
||||
typedef int (*kscan_disable_callback_t)(const struct device *dev);
|
||||
typedef int (*kscan_enable_callback_t)(const struct device *dev);
|
||||
|
||||
__subsystem struct kscan_driver_api {
|
||||
kscan_config_t config;
|
||||
kscan_disable_callback_t disable_callback;
|
||||
kscan_enable_callback_t enable_callback;
|
||||
};
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @brief Configure a Keyboard scan instance.
|
||||
*
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
* @param callback called when keyboard devices reply to a keyboard
|
||||
* event such as key pressed/released.
|
||||
*
|
||||
* @retval 0 If successful.
|
||||
* @retval Negative errno code if failure.
|
||||
*/
|
||||
__syscall int kscan_config(const struct device *dev,
|
||||
kscan_callback_t callback);
|
||||
|
||||
static inline int z_impl_kscan_config(const struct device *dev,
|
||||
kscan_callback_t callback)
|
||||
{
|
||||
const struct kscan_driver_api *api =
|
||||
(struct kscan_driver_api *)dev->api;
|
||||
|
||||
return api->config(dev, callback);
|
||||
}
|
||||
/**
|
||||
* @deprecated
|
||||
* @brief Enables callback.
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
*
|
||||
* @retval 0 If successful.
|
||||
* @retval Negative errno code if failure.
|
||||
*/
|
||||
__syscall int kscan_enable_callback(const struct device *dev);
|
||||
|
||||
static inline int z_impl_kscan_enable_callback(const struct device *dev)
|
||||
{
|
||||
const struct kscan_driver_api *api =
|
||||
(const struct kscan_driver_api *)dev->api;
|
||||
|
||||
if (api->enable_callback == NULL) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
return api->enable_callback(dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @brief Disables callback.
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
*
|
||||
* @retval 0 If successful.
|
||||
* @retval Negative errno code if failure.
|
||||
*/
|
||||
__syscall int kscan_disable_callback(const struct device *dev);
|
||||
|
||||
static inline int z_impl_kscan_disable_callback(const struct device *dev)
|
||||
{
|
||||
const struct kscan_driver_api *api =
|
||||
(const struct kscan_driver_api *)dev->api;
|
||||
|
||||
if (api->disable_callback == NULL) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
return api->disable_callback(dev);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <zephyr/syscalls/kscan.h>
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_DRIVERS_KB_SCAN_H_ */
|
|
@ -9,6 +9,5 @@ CONFIG_THREAD_NAME=y
|
|||
|
||||
# Enable additional drivers to evaluate power consumption without activity
|
||||
CONFIG_PECI=y
|
||||
CONFIG_KSCAN=y
|
||||
|
||||
CONFIG_IDLE_STACK_SIZE=512
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.. zephyr:code-sample:: ht16k33
|
||||
:name: HT16K33 LED driver with keyscan
|
||||
:relevant-api: led_interface kscan_interface
|
||||
:relevant-api: led_interface input_interface
|
||||
|
||||
Control up to 128 LEDs connected to an HT16K33 LED driver and log keyscan events.
|
||||
|
||||
|
|
|
@ -12,9 +12,5 @@
|
|||
reg = <0x70>;
|
||||
/* Uncomment to use IRQ instead of polling: */
|
||||
/* irq-gpios = <&gpio1 8 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; */
|
||||
|
||||
kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CONFIG_LOG=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_LED=y
|
||||
CONFIG_KSCAN=y
|
||||
CONFIG_INPUT=y
|
||||
CONFIG_INPUT_EVENT_DUMP=y
|
||||
CONFIG_HT16K33_KEYSCAN=y
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
#include <zephyr/drivers/led.h>
|
||||
#include <zephyr/drivers/kscan.h>
|
||||
#include <zephyr/devicetree.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
|
@ -13,20 +12,10 @@
|
|||
LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL);
|
||||
|
||||
#define LED_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(holtek_ht16k33)
|
||||
#define KEY_NODE DT_CHILD(LED_NODE, kscan_input)
|
||||
|
||||
static void keyscan_callback(const struct device *dev, uint32_t row,
|
||||
uint32_t column, bool pressed)
|
||||
{
|
||||
LOG_INF("Row %d, column %d %s", row, column,
|
||||
pressed ? "pressed" : "released");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const struct device *const led = DEVICE_DT_GET(LED_NODE);
|
||||
const struct device *const key = DEVICE_DT_GET(KEY_NODE);
|
||||
int err;
|
||||
int i;
|
||||
|
||||
if (!device_is_ready(led)) {
|
||||
|
@ -34,16 +23,6 @@ int main(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!device_is_ready(key)) {
|
||||
LOG_ERR("Keyscan device not ready");
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = kscan_config(key, keyscan_callback);
|
||||
if (err) {
|
||||
LOG_ERR("Failed to add keyscan callback (err %d)", err);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
LOG_INF("Iterating through all LEDs, turning them on "
|
||||
"one-by-one");
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(kscan)
|
||||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
|
@ -1,33 +0,0 @@
|
|||
.. zephyr:code-sample:: kscan
|
||||
:name: KSCAN
|
||||
:relevant-api: kscan_interface timer_apis
|
||||
|
||||
Use the KSCAN API to read key presses and releases on a keyboard matrix.
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
This sample demonstrates how to use the :ref:`KSCAN API <kscan_api>`.
|
||||
Callbacks are registered that will write to the console indicating KSCAN events.
|
||||
These events indicate key presses and releases.
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
The sample can be built and executed on boards supporting a Keyboard Matrix.
|
||||
It requires a correct fixture setup. Please connect a Keyboard Matrix to
|
||||
exercise the functionality (you need to obtain the right keymap from the vendor
|
||||
because they vary across different manufactures).
|
||||
For the correct execution of that sample in twister, add into boards's
|
||||
map-file next fixture settings::
|
||||
|
||||
- fixture: fixture_connect_keyboard
|
||||
|
||||
Sample output
|
||||
=============
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
KSCAN test with a Keyboard matrix
|
||||
Note: You are expected to see several callbacks
|
||||
as you press and release keys!
|
|
@ -1,3 +0,0 @@
|
|||
CONFIG_CONSOLE=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_LOG_PROCESS_THREAD_SLEEP_MS=100
|
|
@ -1,4 +0,0 @@
|
|||
CONFIG_STDOUT_CONSOLE=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_KSCAN=y
|
||||
CONFIG_LOG=y
|
|
@ -1,18 +0,0 @@
|
|||
sample:
|
||||
name: KSCAN driver sample
|
||||
tests:
|
||||
sample.drivers.kscan:
|
||||
tags:
|
||||
- drivers
|
||||
- kscan
|
||||
harness: console
|
||||
harness_config:
|
||||
type: multi_line
|
||||
ordered: true
|
||||
regex:
|
||||
- "kb data(.*)"
|
||||
fixture: fixture_connect_keyboard
|
||||
depends_on: kscan
|
||||
filter: dt_chosen_enabled("zephyr,keyboard-scan")
|
||||
integration_platforms:
|
||||
- mec1501modular_assy6885
|
|
@ -1,166 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
#include <soc.h>
|
||||
#include <zephyr/drivers/kscan.h>
|
||||
|
||||
#define LOG_LEVEL LOG_LEVEL_DBG
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
LOG_MODULE_REGISTER(main);
|
||||
|
||||
const struct device *const kscan_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_keyboard_scan));
|
||||
static struct k_timer typematic_timer;
|
||||
static struct k_timer block_matrix_timer;
|
||||
|
||||
#define KEY_RSVD 0U
|
||||
#define MAX_MATRIX_KEY_COLS 16
|
||||
#define MAX_MATRIX_KEY_ROWS 8
|
||||
|
||||
/****************************************************************************/
|
||||
/* Fujitsu keyboard model N860-7401-TOO1 */
|
||||
/* */
|
||||
/* Sense7 Sense6 Sense5 Sense4 Sense3 Sense2 Sense1 Sense0 */
|
||||
/*+---------------------------------------------------------------+ */
|
||||
/*| | Capslk| | 1! | Tab | F1 | `~ | | Scan 0 */
|
||||
/*| | (30) | | (2) | (16) | (112) | (1) | | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| | W | Q | F7 | | Esc | F6 | F5 | Scan 1 */
|
||||
/*| | (18) | (17) | (118) | | (110) | (117) | (116) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| | F8 | | 2@ | F4 | F3 | | F2 | Scan 2 */
|
||||
/*| | (119) | | (3) | (115) | (114) | | (113) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| | R | E | 3# | 4$ | C | F | V | Scan 3 */
|
||||
/*| | (20) | (19) | (4) | (5) | (48) | (34) | (49) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| N | Y | 6^ | 5% | B | T | H | G | Scan 4 */
|
||||
/*| (51) | (22) | (7) | (6) | (50) | (21) | (36) | (35) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| SpaceB| M | A | 7& | J | D | S | U | Scan 5 */
|
||||
/*| (61) | (52) | (31) | (8) | (37) | (33) | (32) | (23) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| F9 | I | ,< | 8* | | Z | X | K | Scan 6 */
|
||||
/*| (120) | (24) | (53) | (9) | | (46) | (47) | (38) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| | =+ | ]} | 9( | L | | CRSL | O | Scan 7 */
|
||||
/*| | (13) | (28) | (10) | (39) | | (79) | (25) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| -_ | 0) | /? | [{ | ;: | | | '" | Scan 8 */
|
||||
/*| (12) | (11) | (55) | (27) | (40) | | | (41) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| F10 | Pause | NumLK | P | | | | | Scan 9 */
|
||||
/*| (121) | (126) | (90) | (26) | | | | | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| BkSpac| \| | F11 | .> | | | W-Appl| CRSD | Scan 10 */
|
||||
/*| (15) | (29) | (122) | (54) | | | (71) | (84) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| Enter | Delete| Insert| F12 | | | CRSU | CRSR | Scan 11 */
|
||||
/*| (43) | (76) | (75) | (123) | | | (83) | (89) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| | R-WIN | | | | | L-WIN | Fn | Scan 12 */
|
||||
/*| | (87) | | | | | (59) | (255) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| | | | RShift| LShift| | | | Scan 13 */
|
||||
/*| | | | (57) | (44) | | | | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| | | | | | | L Alt | R Alt | Scan 14 */
|
||||
/*| | | | | | | (60) | (62) | (KEY #) */
|
||||
/*|-------+-------+-------+-------+-------+-------+-------+-------| */
|
||||
/*| R Ctrl| | | | | L Ctrl| | | Scan 15 */
|
||||
/*| (64) | | | | | (58) | | | (KEY #) */
|
||||
/*+---------------------------------------------------------------+ */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
static const uint8_t keymap[MAX_MATRIX_KEY_COLS][MAX_MATRIX_KEY_ROWS] = {
|
||||
{KEY_RSVD, 1, 112, 16, 2, KEY_RSVD, 30, KEY_RSVD},
|
||||
{116, 117, 110, KEY_RSVD, 118, 17, 18, KEY_RSVD},
|
||||
{113, KEY_RSVD, 114, 115, 3, KEY_RSVD, 119, KEY_RSVD},
|
||||
{49, 34, 48, 5, 4, 19, 20, KEY_RSVD},
|
||||
{35, 36, 21, 50, 6, 7, 22, 51},
|
||||
{23, 32, 33, 37, 8, 31, 52, 61},
|
||||
{38, 47, 46, KEY_RSVD, 9, 53, 24, 120},
|
||||
{25, 79, KEY_RSVD, 39, 10, 28, 13, KEY_RSVD},
|
||||
{41, KEY_RSVD, KEY_RSVD, 40, 27, 55, 11, 12},
|
||||
{KEY_RSVD, KEY_RSVD, KEY_RSVD, KEY_RSVD, 26, 90, 126, 121},
|
||||
{84, 71, KEY_RSVD, KEY_RSVD, 54, 122, 29, 15},
|
||||
{89, 83, KEY_RSVD, KEY_RSVD, 123, 75, 76, 43},
|
||||
{255, 59, KEY_RSVD, KEY_RSVD, KEY_RSVD, KEY_RSVD, 87, KEY_RSVD},
|
||||
{KEY_RSVD, KEY_RSVD, 44, 57, KEY_RSVD, KEY_RSVD, KEY_RSVD},
|
||||
{62, 60, KEY_RSVD, KEY_RSVD, KEY_RSVD, KEY_RSVD, KEY_RSVD, KEY_RSVD},
|
||||
{KEY_RSVD, KEY_RSVD, 58, KEY_RSVD, KEY_RSVD, KEY_RSVD, KEY_RSVD, 64},
|
||||
};
|
||||
|
||||
/* Key used for typematic */
|
||||
static uint8_t last_key;
|
||||
|
||||
/* Typematic rate and delay values correspond to the data passed after
|
||||
* the F3 command (See the 8042 spec online)
|
||||
*/
|
||||
static const uint16_t period[] = {
|
||||
33U, 37U, 42U, 46U, 50U, 54U, 58U, 63U,
|
||||
67U, 75U, 83U, 92U, 100U, 109U, 116U, 125U,
|
||||
133U, 149U, 167U, 182U, 200U, 217U, 232U, 250U,
|
||||
270U, 303U, 333U, 370U, 400U, 435U, 470U, 500U
|
||||
};
|
||||
|
||||
static const uint16_t delay[] = { 250U, 500U, 750U, 1000U };
|
||||
|
||||
static bool block_kb_matrix;
|
||||
|
||||
static void typematic_callback(struct k_timer *timer)
|
||||
{
|
||||
LOG_INF("Typematic : %u\n", last_key);
|
||||
}
|
||||
|
||||
static void kb_callback(const struct device *dev, uint32_t row, uint32_t col,
|
||||
bool pressed)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
last_key = keymap[col][row];
|
||||
|
||||
LOG_INF("Key code = %u Pressed = %u\n", last_key, pressed);
|
||||
|
||||
if (pressed) {
|
||||
k_timer_start(&typematic_timer,
|
||||
K_MSEC(delay[0]), K_MSEC(period[0]));
|
||||
} else {
|
||||
k_timer_stop(&typematic_timer);
|
||||
}
|
||||
}
|
||||
|
||||
static void block_matrix_callback(struct k_timer *timer)
|
||||
{
|
||||
LOG_DBG("block host : %d\n", block_kb_matrix);
|
||||
if (block_kb_matrix) {
|
||||
kscan_disable_callback(kscan_dev);
|
||||
block_kb_matrix = false;
|
||||
k_timer_stop(&typematic_timer);
|
||||
} else {
|
||||
kscan_enable_callback(kscan_dev);
|
||||
block_kb_matrix = true;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printk("Kscan matrix sample application\n");
|
||||
|
||||
if (!device_is_ready(kscan_dev)) {
|
||||
LOG_ERR("kscan device %s not ready", kscan_dev->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
kscan_config(kscan_dev, kb_callback);
|
||||
k_timer_init(&typematic_timer, typematic_callback, NULL);
|
||||
k_timer_init(&block_matrix_timer, block_matrix_callback, NULL);
|
||||
k_timer_start(&block_matrix_timer, K_SECONDS(1), K_SECONDS(3));
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -92,10 +92,10 @@ void soc_deep_sleep_non_wake_dis(void)
|
|||
/* When MEC172x drivers are power-aware this should be move there */
|
||||
void soc_deep_sleep_wake_en(void)
|
||||
{
|
||||
#if defined(CONFIG_KSCAN) || \
|
||||
#if defined(INPUT_XEC_KBD) || \
|
||||
(!defined(CONFIG_PM_DEVICE) && DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(ps2_0)))
|
||||
struct ecia_named_regs *regs = ECIA_XEC_REG_BASE;
|
||||
#if defined(CONFIG_KSCAN)
|
||||
#if defined(INPUT_XEC_KBD)
|
||||
/* Enable PLL wake via KSCAN */
|
||||
regs->GIRQ21.SRC = MCHP_KEYSCAN_GIRQ_BIT;
|
||||
regs->GIRQ21.EN_SET = MCHP_KEYSCAN_GIRQ_BIT;
|
||||
|
|
|
@ -25,8 +25,4 @@
|
|||
kso-mapping = <0 1 20 3 4 5 6 17 18 16 15 11 12>;
|
||||
row-size = <8>;
|
||||
col-size = <13>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(kscan_api)
|
||||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_KSCAN=y
|
||||
CONFIG_ZTEST=y
|
|
@ -1,3 +0,0 @@
|
|||
CONFIG_KSCAN=y
|
||||
CONFIG_TEST_USERSPACE=y
|
||||
CONFIG_ZTEST=y
|
|
@ -1,10 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
ZTEST_SUITE(kscan_basic, NULL, NULL, NULL, NULL, NULL);
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/device.h>
|
||||
#include <stdlib.h>
|
||||
#include <zephyr/drivers/kscan.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
static void kb_callback(const struct device *dev, uint32_t row, uint32_t col,
|
||||
bool pressed)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
ARG_UNUSED(row);
|
||||
ARG_UNUSED(col);
|
||||
ARG_UNUSED(pressed);
|
||||
}
|
||||
|
||||
static int test_kb_callback(void)
|
||||
{
|
||||
const struct device *const kscan_dev = DEVICE_DT_GET(DT_ALIAS(kscan0));
|
||||
|
||||
if (!device_is_ready(kscan_dev)) {
|
||||
TC_PRINT("KBSCAN device is not ready\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
if (kscan_config(kscan_dev, kb_callback) != 0) {
|
||||
TC_PRINT("Unexpected error code received\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
return TC_PASS;
|
||||
}
|
||||
|
||||
static int test_null_callback(void)
|
||||
{
|
||||
const struct device *const kscan_dev = DEVICE_DT_GET(DT_ALIAS(kscan0));
|
||||
|
||||
if (!device_is_ready(kscan_dev)) {
|
||||
TC_PRINT("KBSCAN device is not ready\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
if (kscan_config(kscan_dev, NULL) != -EINVAL) {
|
||||
TC_PRINT("Unexpected error code received\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
return TC_PASS;
|
||||
}
|
||||
|
||||
static int test_disable_enable_callback(void)
|
||||
{
|
||||
const struct device *const kscan_dev = DEVICE_DT_GET(DT_ALIAS(kscan0));
|
||||
|
||||
if (!device_is_ready(kscan_dev)) {
|
||||
TC_PRINT("KBSCAN device is not ready\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
if (kscan_config(kscan_dev, kb_callback) != 0) {
|
||||
TC_PRINT("Unexpected error code received\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
if (kscan_disable_callback(kscan_dev) != 0) {
|
||||
TC_PRINT("Error while disabling callback\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
if (kscan_enable_callback(kscan_dev) != 0) {
|
||||
TC_PRINT("Error while enabling callback\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
return TC_PASS;
|
||||
}
|
||||
|
||||
ZTEST(kscan_basic, test_init_callback)
|
||||
{
|
||||
/* Configure kscan matrix with an appropriate callback */
|
||||
zassert_true(test_kb_callback() == TC_PASS);
|
||||
k_sleep(K_MSEC(1000));
|
||||
|
||||
/* Configure kscan with a null callback */
|
||||
zassert_true(test_null_callback() == TC_PASS);
|
||||
}
|
||||
|
||||
ZTEST(kscan_basic, test_control_callback)
|
||||
{
|
||||
/* Disable/enable notifications to user */
|
||||
zassert_true(test_disable_enable_callback() == TC_PASS);
|
||||
k_sleep(K_MSEC(1000));
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
tests:
|
||||
drivers.kscan:
|
||||
tags:
|
||||
- drivers
|
||||
- kscan
|
||||
- userspace
|
||||
depends_on: kscan
|
||||
platform_exclude: mec15xxevb_assy6853
|
||||
filter: dt_alias_exists("kscan0")
|
||||
drivers.kscan.mec15xxevb_assy6853:
|
||||
depends_on: kscan
|
||||
tags:
|
||||
- drivers
|
||||
- kscan
|
||||
extra_args: CONF_FILE="mec15xxevb_assy6853.conf"
|
||||
platform_allow: mec15xxevb_assy6853
|
|
@ -1,9 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(kscan_input)
|
||||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
/delete-node/ input_sdl_touch;
|
||||
|
||||
fake_input_device: fake-device {
|
||||
compatible = "vnd,input-device";
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
|
@ -1,6 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "native_sim.overlay"
|
|
@ -1,6 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
CONFIG_ZTEST=y
|
||||
CONFIG_KSCAN=y
|
||||
CONFIG_INPUT=y
|
||||
CONFIG_INPUT_MODE_SYNCHRONOUS=y
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023 Google LLC
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/kscan.h>
|
||||
#include <zephyr/input/input.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
static const struct device *kscan_dev = DEVICE_DT_GET(
|
||||
DT_NODELABEL(kscan_input));
|
||||
static const struct device *input_dev = DEVICE_DT_GET(
|
||||
DT_NODELABEL(fake_input_device));
|
||||
|
||||
DEVICE_DT_DEFINE(DT_INST(0, vnd_input_device), NULL, NULL, NULL, NULL,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);
|
||||
|
||||
static struct {
|
||||
uint32_t row;
|
||||
uint32_t col;
|
||||
bool pressed;
|
||||
} last_cb_val;
|
||||
static int callback_calls_count;
|
||||
|
||||
static void kscan_callback(const struct device *dev, uint32_t row, uint32_t col,
|
||||
bool pressed)
|
||||
{
|
||||
TC_PRINT("row = %u col = %u %d\n", row, col, pressed);
|
||||
|
||||
callback_calls_count++;
|
||||
last_cb_val.row = row;
|
||||
last_cb_val.col = col;
|
||||
last_cb_val.pressed = pressed;
|
||||
}
|
||||
|
||||
ZTEST(kscan_input, test_kscan_input)
|
||||
{
|
||||
kscan_config(kscan_dev, kscan_callback);
|
||||
kscan_enable_callback(kscan_dev);
|
||||
|
||||
input_report_abs(input_dev, INPUT_ABS_X, 101, false, K_FOREVER);
|
||||
zassert_equal(callback_calls_count, 0);
|
||||
|
||||
input_report_abs(input_dev, INPUT_ABS_Y, 102, false, K_FOREVER);
|
||||
zassert_equal(callback_calls_count, 0);
|
||||
|
||||
input_report_key(input_dev, INPUT_BTN_TOUCH, 1, true, K_FOREVER);
|
||||
zassert_equal(callback_calls_count, 1);
|
||||
zassert_equal(last_cb_val.col, 101);
|
||||
zassert_equal(last_cb_val.row, 102);
|
||||
zassert_equal(last_cb_val.pressed, true);
|
||||
|
||||
input_report_abs(input_dev, INPUT_ABS_X, 103, true, K_FOREVER);
|
||||
zassert_equal(callback_calls_count, 2);
|
||||
zassert_equal(last_cb_val.col, 103);
|
||||
zassert_equal(last_cb_val.row, 102);
|
||||
zassert_equal(last_cb_val.pressed, true);
|
||||
|
||||
input_report_key(input_dev, INPUT_BTN_TOUCH, 0, true, K_FOREVER);
|
||||
zassert_equal(callback_calls_count, 3);
|
||||
zassert_equal(last_cb_val.col, 103);
|
||||
zassert_equal(last_cb_val.row, 102);
|
||||
zassert_equal(last_cb_val.pressed, false);
|
||||
}
|
||||
|
||||
ZTEST_SUITE(kscan_input, NULL, NULL, NULL, NULL, NULL);
|
|
@ -1,13 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
tests:
|
||||
drivers.input.kscan_input:
|
||||
platform_allow:
|
||||
- native_sim
|
||||
- native_sim/native/64
|
||||
tags:
|
||||
- drivers
|
||||
- kscan
|
||||
- input
|
||||
integration_platforms:
|
||||
- native_sim
|
|
@ -50,7 +50,6 @@
|
|||
#include <zephyr/drivers/i2s.h>
|
||||
#include <zephyr/drivers/i3c.h>
|
||||
#include <zephyr/drivers/ipm.h>
|
||||
#include <zephyr/drivers/kscan.h>
|
||||
#include <zephyr/drivers/led.h>
|
||||
#include <zephyr/drivers/led_strip.h>
|
||||
#include <zephyr/drivers/lora.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue