drivers: input: gt911: Add touchscreen common config
Adds the touchscreen common config to the gt911 controller. Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
This commit is contained in:
committed by
Benjamin Cabé
parent
4bd0c33cdd
commit
0f07faa14b
@@ -7,6 +7,7 @@ menuconfig INPUT_GT911
|
||||
default y
|
||||
depends on DT_HAS_GOODIX_GT911_ENABLED
|
||||
select I2C
|
||||
select INPUT_TOUCH
|
||||
help
|
||||
Enable driver for multiple Goodix capacitive touch panel controllers.
|
||||
This driver should support gt9110, gt912, gt927, gt9271, gt928,
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
#include <zephyr/input/input.h>
|
||||
#include <zephyr/input/input_touch.h>
|
||||
#include <zephyr/sys/byteorder.h>
|
||||
#include <zephyr/pm/pm.h>
|
||||
|
||||
@@ -41,6 +42,7 @@ LOG_MODULE_REGISTER(gt911, CONFIG_INPUT_LOG_LEVEL);
|
||||
|
||||
/** GT911 configuration (DT). */
|
||||
struct gt911_config {
|
||||
struct input_touchscreen_common_config common;
|
||||
/** I2C bus. */
|
||||
struct i2c_dt_spec bus;
|
||||
struct gpio_dt_spec rst_gpio;
|
||||
@@ -70,6 +72,8 @@ struct gt911_data {
|
||||
#endif
|
||||
};
|
||||
|
||||
INPUT_TOUCH_STRUCT_CHECK(struct gt911_config);
|
||||
|
||||
/** gt911 point reg */
|
||||
struct gt911_point_reg {
|
||||
uint8_t id; /*!< Track ID. */
|
||||
@@ -166,8 +170,7 @@ static int gt911_process(const struct device *dev)
|
||||
row = ((point_reg[i].high_y) << 8U) | point_reg[i].low_y;
|
||||
col = ((point_reg[i].high_x) << 8U) | point_reg[i].low_x;
|
||||
|
||||
input_report_abs(dev, INPUT_ABS_X, col, false, K_FOREVER);
|
||||
input_report_abs(dev, INPUT_ABS_Y, row, false, K_FOREVER);
|
||||
input_touchscreen_report_pos(dev, col, row, K_FOREVER);
|
||||
input_report_key(dev, INPUT_BTN_TOUCH, 1, true, K_FOREVER);
|
||||
}
|
||||
|
||||
@@ -187,8 +190,7 @@ static int gt911_process(const struct device *dev)
|
||||
}
|
||||
row = ((prev_point_reg[i].high_y) << 8U) | prev_point_reg[i].low_y;
|
||||
col = ((prev_point_reg[i].high_x) << 8U) | prev_point_reg[i].low_x;
|
||||
input_report_abs(dev, INPUT_ABS_X, col, false, K_FOREVER);
|
||||
input_report_abs(dev, INPUT_ABS_Y, row, false, K_FOREVER);
|
||||
input_touchscreen_report_pos(dev, col, row, K_FOREVER);
|
||||
input_report_key(dev, INPUT_BTN_TOUCH, 0, true, K_FOREVER);
|
||||
}
|
||||
}
|
||||
@@ -452,6 +454,7 @@ static void gt911_##n##_pm_state_exit(enum pm_state state)
|
||||
|
||||
#define GT911_INIT(index) \
|
||||
static const struct gt911_config gt911_config_##index = { \
|
||||
.common = INPUT_TOUCH_DT_INST_COMMON_CONFIG_INIT(index), \
|
||||
.bus = I2C_DT_SPEC_INST_GET(index), \
|
||||
.rst_gpio = GPIO_DT_SPEC_INST_GET_OR(index, reset_gpios, {0}), \
|
||||
.int_gpio = GPIO_DT_SPEC_INST_GET(index, irq_gpios), \
|
||||
|
||||
@@ -5,7 +5,7 @@ description: GT9xx / GT9xxx capacitive touch panels
|
||||
|
||||
compatible: "goodix,gt911"
|
||||
|
||||
include: i2c-device.yaml
|
||||
include: [i2c-device.yaml, touchscreen-common.yaml]
|
||||
|
||||
properties:
|
||||
irq-gpios:
|
||||
|
||||
Reference in New Issue
Block a user