Skip to content

Commit 0f07faa

Browse files
faxe1008kartben
authored andcommitted
drivers: input: gt911: Add touchscreen common config
Adds the touchscreen common config to the gt911 controller. Signed-off-by: Fabian Blatz <[email protected]>
1 parent 4bd0c33 commit 0f07faa

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

drivers/input/Kconfig.gt911

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ menuconfig INPUT_GT911
77
default y
88
depends on DT_HAS_GOODIX_GT911_ENABLED
99
select I2C
10+
select INPUT_TOUCH
1011
help
1112
Enable driver for multiple Goodix capacitive touch panel controllers.
1213
This driver should support gt9110, gt912, gt927, gt9271, gt928,

drivers/input/input_gt911.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <zephyr/drivers/gpio.h>
1212
#include <zephyr/drivers/i2c.h>
1313
#include <zephyr/input/input.h>
14+
#include <zephyr/input/input_touch.h>
1415
#include <zephyr/sys/byteorder.h>
1516
#include <zephyr/pm/pm.h>
1617

@@ -41,6 +42,7 @@ LOG_MODULE_REGISTER(gt911, CONFIG_INPUT_LOG_LEVEL);
4142

4243
/** GT911 configuration (DT). */
4344
struct gt911_config {
45+
struct input_touchscreen_common_config common;
4446
/** I2C bus. */
4547
struct i2c_dt_spec bus;
4648
struct gpio_dt_spec rst_gpio;
@@ -70,6 +72,8 @@ struct gt911_data {
7072
#endif
7173
};
7274

75+
INPUT_TOUCH_STRUCT_CHECK(struct gt911_config);
76+
7377
/** gt911 point reg */
7478
struct gt911_point_reg {
7579
uint8_t id; /*!< Track ID. */
@@ -166,8 +170,7 @@ static int gt911_process(const struct device *dev)
166170
row = ((point_reg[i].high_y) << 8U) | point_reg[i].low_y;
167171
col = ((point_reg[i].high_x) << 8U) | point_reg[i].low_x;
168172

169-
input_report_abs(dev, INPUT_ABS_X, col, false, K_FOREVER);
170-
input_report_abs(dev, INPUT_ABS_Y, row, false, K_FOREVER);
173+
input_touchscreen_report_pos(dev, col, row, K_FOREVER);
171174
input_report_key(dev, INPUT_BTN_TOUCH, 1, true, K_FOREVER);
172175
}
173176

@@ -187,8 +190,7 @@ static int gt911_process(const struct device *dev)
187190
}
188191
row = ((prev_point_reg[i].high_y) << 8U) | prev_point_reg[i].low_y;
189192
col = ((prev_point_reg[i].high_x) << 8U) | prev_point_reg[i].low_x;
190-
input_report_abs(dev, INPUT_ABS_X, col, false, K_FOREVER);
191-
input_report_abs(dev, INPUT_ABS_Y, row, false, K_FOREVER);
193+
input_touchscreen_report_pos(dev, col, row, K_FOREVER);
192194
input_report_key(dev, INPUT_BTN_TOUCH, 0, true, K_FOREVER);
193195
}
194196
}
@@ -452,6 +454,7 @@ static void gt911_##n##_pm_state_exit(enum pm_state state)
452454

453455
#define GT911_INIT(index) \
454456
static const struct gt911_config gt911_config_##index = { \
457+
.common = INPUT_TOUCH_DT_INST_COMMON_CONFIG_INIT(index), \
455458
.bus = I2C_DT_SPEC_INST_GET(index), \
456459
.rst_gpio = GPIO_DT_SPEC_INST_GET_OR(index, reset_gpios, {0}), \
457460
.int_gpio = GPIO_DT_SPEC_INST_GET(index, irq_gpios), \

dts/bindings/input/goodix,gt911.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: GT9xx / GT9xxx capacitive touch panels
55

66
compatible: "goodix,gt911"
77

8-
include: i2c-device.yaml
8+
include: [i2c-device.yaml, touchscreen-common.yaml]
99

1010
properties:
1111
irq-gpios:

0 commit comments

Comments
 (0)