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). */
4344struct 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 */
7478struct 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), \
0 commit comments