input: convert gt911 from kscan
Convert the GT911 driver to the input subsystem, fix the existing boards to work in the default config. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
parent
fd54a9ab6e
commit
04e0e458c8
|
@ -19,7 +19,10 @@ if LVGL
|
|||
config KSCAN
|
||||
default y
|
||||
|
||||
config KSCAN_GT911_INTERRUPT
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
config INPUT_GT911_INTERRUPT
|
||||
default y
|
||||
|
||||
config LV_Z_POINTER_KSCAN
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
/{
|
||||
aliases {
|
||||
kscan0 = &touch_controller;
|
||||
kscan0 = &kscan_input_gt911;
|
||||
};
|
||||
|
||||
chosen {
|
||||
zephyr,display = &lcdif;
|
||||
zephyr,keyboard-scan = &touch_controller;
|
||||
zephyr,keyboard-scan = &kscan_input_gt911;
|
||||
};
|
||||
|
||||
en_mipi_display: enable-mipi-display {
|
||||
|
@ -31,6 +31,10 @@
|
|||
reg = <0x5d>;
|
||||
irq-gpios = <&nxp_mipi_connector 29 GPIO_ACTIVE_HIGH>;
|
||||
reset-gpios = <&nxp_mipi_connector 28 GPIO_ACTIVE_HIGH>;
|
||||
|
||||
kscan_input_gt911: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ zephyr_library_property(ALLOW_EMPTY TRUE)
|
|||
zephyr_library_sources_ifdef(CONFIG_INPUT_FT5336 input_ft5336.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_INPUT_GPIO_KEYS input_gpio_keys.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_INPUT_GPIO_QDEC input_gpio_qdec.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_INPUT_GT911 input_gt911.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_INPUT_NPCX_KBD input_npcx_kbd.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_INPUT_XPT2046 input_xpt2046.c)
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ menu "Input drivers"
|
|||
source "drivers/input/Kconfig.ft5336"
|
||||
source "drivers/input/Kconfig.gpio_keys"
|
||||
source "drivers/input/Kconfig.gpio_qdec"
|
||||
source "drivers/input/Kconfig.gt911"
|
||||
source "drivers/input/Kconfig.npcx"
|
||||
source "drivers/input/Kconfig.sdl"
|
||||
source "drivers/input/Kconfig.xpt2046"
|
||||
|
|
|
@ -2,28 +2,28 @@
|
|||
# Copyright (c) 2020 Teslabs Engineering S.L.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig KSCAN_GT911
|
||||
menuconfig INPUT_GT911
|
||||
bool "GT9xx / GT9xxx capacitive touch panel driver"
|
||||
default y
|
||||
depends on DT_HAS_GOODIX_GT911_ENABLED
|
||||
select I2C
|
||||
help
|
||||
Enable driver for multiple Goodix capacitive touch panel
|
||||
controllers. This driver should support gt9110, gt912,
|
||||
gt927, gt9271, gt928, gt967
|
||||
Enable driver for multiple Goodix capacitive touch panel controllers.
|
||||
This driver should support gt9110, gt912, gt927, gt9271, gt928,
|
||||
gt967.
|
||||
|
||||
if KSCAN_GT911
|
||||
if INPUT_GT911
|
||||
|
||||
config KSCAN_GT911_PERIOD
|
||||
config INPUT_GT911_PERIOD_MS
|
||||
int "Sample period"
|
||||
depends on !KSCAN_GT911_INTERRUPT
|
||||
depends on !INPUT_GT911_INTERRUPT
|
||||
default 10
|
||||
help
|
||||
Sample period in milliseconds when in polling mode.
|
||||
|
||||
config KSCAN_GT911_INTERRUPT
|
||||
config INPUT_GT911_INTERRUPT
|
||||
bool "Interrupt"
|
||||
help
|
||||
Enable interrupt support (requires GPIO).
|
||||
|
||||
endif # KSCAN_GT911
|
||||
endif # INPUT_GT911
|
|
@ -8,13 +8,13 @@
|
|||
|
||||
#define DT_DRV_COMPAT goodix_gt911
|
||||
|
||||
#include <zephyr/drivers/kscan.h>
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
#include <zephyr/input/input.h>
|
||||
#include <zephyr/sys/byteorder.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(gt911, CONFIG_KSCAN_LOG_LEVEL);
|
||||
LOG_MODULE_REGISTER(gt911, CONFIG_INPUT_LOG_LEVEL);
|
||||
|
||||
/* GT911 used registers */
|
||||
#define DEVICE_ID __bswap_16(0x8140U)
|
||||
|
@ -45,11 +45,9 @@ struct gt911_config {
|
|||
struct gt911_data {
|
||||
/** Device pointer. */
|
||||
const struct device *dev;
|
||||
/** KSCAN Callback. */
|
||||
kscan_callback_t callback;
|
||||
/** Work queue (for deferred read). */
|
||||
struct k_work work;
|
||||
#ifdef CONFIG_KSCAN_GT911_INTERRUPT
|
||||
#ifdef CONFIG_INPUT_GT911_INTERRUPT
|
||||
/** Interrupt GPIO callback. */
|
||||
struct gpio_callback int_gpio_cb;
|
||||
#else
|
||||
|
@ -73,7 +71,6 @@ struct gt911_point_reg_t {
|
|||
static int gt911_process(const struct device *dev)
|
||||
{
|
||||
const struct gt911_config *config = dev->config;
|
||||
struct gt911_data *data = dev->data;
|
||||
|
||||
int r;
|
||||
uint16_t reg_addr;
|
||||
|
@ -124,7 +121,13 @@ static int gt911_process(const struct device *dev)
|
|||
|
||||
LOG_DBG("pressed: %d, row: %d, col: %d", pressed, row, col);
|
||||
|
||||
data->callback(dev, row, col, pressed);
|
||||
if (pressed) {
|
||||
input_report_abs(dev, INPUT_ABS_X, col, false, K_FOREVER);
|
||||
input_report_abs(dev, INPUT_ABS_Y, row, false, K_FOREVER);
|
||||
input_report_key(dev, INPUT_BTN_TOUCH, 1, true, K_FOREVER);
|
||||
} else {
|
||||
input_report_key(dev, INPUT_BTN_TOUCH, 0, true, K_FOREVER);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -136,7 +139,7 @@ static void gt911_work_handler(struct k_work *work)
|
|||
gt911_process(data->dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KSCAN_GT911_INTERRUPT
|
||||
#ifdef CONFIG_INPUT_GT911_INTERRUPT
|
||||
static void gt911_isr_handler(const struct device *dev,
|
||||
struct gpio_callback *cb, uint32_t pins)
|
||||
{
|
||||
|
@ -153,52 +156,6 @@ static void gt911_timer_handler(struct k_timer *timer)
|
|||
}
|
||||
#endif
|
||||
|
||||
static int gt911_configure(const struct device *dev,
|
||||
kscan_callback_t callback)
|
||||
{
|
||||
struct gt911_data *data = dev->data;
|
||||
|
||||
if (!callback) {
|
||||
LOG_ERR("Invalid callback (NULL)");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
data->callback = callback;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gt911_enable_callback(const struct device *dev)
|
||||
{
|
||||
struct gt911_data *data = dev->data;
|
||||
|
||||
#ifdef CONFIG_KSCAN_GT911_INTERRUPT
|
||||
const struct gt911_config *config = dev->config;
|
||||
|
||||
gpio_add_callback(config->int_gpio.port, &data->int_gpio_cb);
|
||||
#else
|
||||
k_timer_start(&data->timer, K_MSEC(CONFIG_KSCAN_GT911_PERIOD),
|
||||
K_MSEC(CONFIG_KSCAN_GT911_PERIOD));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gt911_disable_callback(const struct device *dev)
|
||||
{
|
||||
struct gt911_data *data = dev->data;
|
||||
|
||||
#ifdef CONFIG_KSCAN_GT911_INTERRUPT
|
||||
const struct gt911_config *config = dev->config;
|
||||
|
||||
gpio_remove_callback(config->int_gpio.port, &data->int_gpio_cb);
|
||||
#else
|
||||
k_timer_stop(&data->timer);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t gt911_get_firmware_checksum(const uint8_t *firmware)
|
||||
{
|
||||
uint8_t sum = 0;
|
||||
|
@ -269,7 +226,7 @@ static int gt911_init(const struct device *dev)
|
|||
return r;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KSCAN_GT911_INTERRUPT
|
||||
#ifdef CONFIG_INPUT_GT911_INTERRUPT
|
||||
r = gpio_pin_interrupt_configure_dt(&config->int_gpio,
|
||||
GPIO_INT_EDGE_TO_ACTIVE);
|
||||
if (r < 0) {
|
||||
|
@ -320,15 +277,16 @@ static int gt911_init(const struct device *dev)
|
|||
return r;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_INPUT_GT911_INTERRUPT
|
||||
gpio_add_callback(config->int_gpio.port, &data->int_gpio_cb);
|
||||
#else
|
||||
k_timer_start(&data->timer, K_MSEC(CONFIG_INPUT_GT911_PERIOD_MS),
|
||||
K_MSEC(CONFIG_INPUT_GT911_PERIOD_MS));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct kscan_driver_api gt911_driver_api = {
|
||||
.config = gt911_configure,
|
||||
.enable_callback = gt911_enable_callback,
|
||||
.disable_callback = gt911_disable_callback,
|
||||
};
|
||||
|
||||
#define GT911_INIT(index) \
|
||||
static const struct gt911_config gt911_config_##index = { \
|
||||
.bus = I2C_DT_SPEC_INST_GET(index), \
|
||||
|
@ -338,7 +296,7 @@ static const struct kscan_driver_api gt911_driver_api = {
|
|||
static struct gt911_data gt911_data_##index; \
|
||||
DEVICE_DT_INST_DEFINE(index, gt911_init, NULL, \
|
||||
>911_data_##index, >911_config_##index, \
|
||||
POST_KERNEL, CONFIG_KSCAN_INIT_PRIORITY, \
|
||||
>911_driver_api);
|
||||
POST_KERNEL, CONFIG_INPUT_INIT_PRIORITY, \
|
||||
NULL);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(GT911_INIT)
|
|
@ -4,7 +4,6 @@ zephyr_syscall_header(${ZEPHYR_BASE}/include/zephyr/drivers/kscan.h)
|
|||
|
||||
zephyr_library()
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_KSCAN_GT911 kscan_gt911.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_KSCAN_ITE_IT8XXX2 kscan_ite_it8xxx2.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_KSCAN_XEC kscan_mchp_xec.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_KSCAN_HT16K33 kscan_ht16k33.c)
|
||||
|
|
|
@ -10,7 +10,6 @@ menuconfig KSCAN
|
|||
|
||||
if KSCAN
|
||||
|
||||
source "drivers/kscan/Kconfig.gt911"
|
||||
source "drivers/kscan/Kconfig.it8xxx2"
|
||||
source "drivers/kscan/Kconfig.xec"
|
||||
source "drivers/kscan/Kconfig.ht16k33"
|
||||
|
|
|
@ -5,7 +5,7 @@ description: GT9xx / GT9xxx capacitive touch panels
|
|||
|
||||
compatible: "goodix,gt911"
|
||||
|
||||
include: [kscan.yaml, i2c-device.yaml]
|
||||
include: i2c-device.yaml
|
||||
|
||||
properties:
|
||||
irq-gpios:
|
|
@ -14,15 +14,3 @@ tests:
|
|||
fixture: fixture_connect_keyboard
|
||||
depends_on: kscan
|
||||
filter: dt_chosen_enabled("zephyr,keyboard-scan")
|
||||
sample.drivers.kscan.rk055hdmipi4m:
|
||||
tags: drivers kscan
|
||||
harness: console
|
||||
harness_config:
|
||||
type: multi_line
|
||||
ordered: true
|
||||
regex:
|
||||
- "kb data(.*)"
|
||||
fixture: fixture_connect_rk055hdmipi4m
|
||||
depends_on: kscan
|
||||
extra_args: SHIELD="rk055hdmipi4m"
|
||||
platform_allow: mimxrt1170_evk_cm7 mimxrt595_evk_cm33
|
||||
|
|
|
@ -57,6 +57,13 @@
|
|||
reg = <0x0>;
|
||||
int-gpios = <&test_gpio 0 0>;
|
||||
};
|
||||
|
||||
gt911@1 {
|
||||
compatible = "goodix,gt911";
|
||||
reg = <0x1>;
|
||||
irq-gpios = <&gpio0 0 0>;
|
||||
reset-gpios = <&gpio0 0 0>;
|
||||
};
|
||||
};
|
||||
|
||||
spi@2 {
|
||||
|
|
|
@ -14,8 +14,3 @@ tests:
|
|||
- kscan
|
||||
extra_args: CONF_FILE="mec15xxevb_assy6853.conf"
|
||||
platform_allow: mec15xxevb_assy6853
|
||||
drivers.kscan.rk055hdmipi4m:
|
||||
tags: drivers kscan userspace
|
||||
depends_on: kscan
|
||||
extra_args: SHIELD="rk055hdmipi4m"
|
||||
platform_allow: mimxrt1170_evk_cm7 mimxrt595_evk_cm33
|
||||
|
|
Loading…
Reference in a new issue