2222#include <linux/pm_qos.h>
2323#include <linux/slab.h>
2424#include <linux/types.h>
25+ #include <linux/input/touch-overlay.h>
2526
2627#define ST1232_TS_NAME "st1232-ts"
2728#define ST1633_TS_NAME "st1633-ts"
@@ -57,6 +58,7 @@ struct st1232_ts_data {
5758 struct dev_pm_qos_request low_latency_req ;
5859 struct gpio_desc * reset_gpio ;
5960 const struct st_chip_info * chip_info ;
61+ struct list_head touch_overlay_list ;
6062 int read_buf_len ;
6163 u8 * read_buf ;
6264};
@@ -156,6 +158,10 @@ static int st1232_ts_parse_and_report(struct st1232_ts_data *ts)
156158
157159 input_mt_assign_slots (input , slots , pos , n_contacts , 0 );
158160 for (i = 0 ; i < n_contacts ; i ++ ) {
161+ if (touch_overlay_process_contact (& ts -> touch_overlay_list ,
162+ input , & pos [i ], slots [i ]))
163+ continue ;
164+
159165 input_mt_slot (input , slots [i ]);
160166 input_mt_report_slot_state (input , MT_TOOL_FINGER , true);
161167 input_report_abs (input , ABS_MT_POSITION_X , pos [i ].x );
@@ -164,6 +170,7 @@ static int st1232_ts_parse_and_report(struct st1232_ts_data *ts)
164170 input_report_abs (input , ABS_MT_TOUCH_MAJOR , z [i ]);
165171 }
166172
173+ touch_overlay_sync_frame (& ts -> touch_overlay_list , input );
167174 input_mt_sync_frame (input );
168175 input_sync (input );
169176
@@ -292,18 +299,30 @@ static int st1232_ts_probe(struct i2c_client *client)
292299 if (error )
293300 return error ;
294301
295- /* Read resolution from the chip */
296- error = st1232_ts_read_resolution (ts , & max_x , & max_y );
297- if (error ) {
298- dev_err (& client -> dev ,
299- "Failed to read resolution: %d\n" , error );
300- return error ;
301- }
302-
303302 if (ts -> chip_info -> have_z )
304303 input_set_abs_params (input_dev , ABS_MT_TOUCH_MAJOR , 0 ,
305304 ts -> chip_info -> max_area , 0 , 0 );
306305
306+ /* map overlay objects if defined in the device tree */
307+ INIT_LIST_HEAD (& ts -> touch_overlay_list );
308+ error = touch_overlay_map (& ts -> touch_overlay_list , input_dev );
309+ if (error )
310+ return error ;
311+
312+ if (touch_overlay_mapped_touchscreen (& ts -> touch_overlay_list )) {
313+ /* Read resolution from the overlay touchscreen if defined */
314+ touch_overlay_get_touchscreen_abs (& ts -> touch_overlay_list ,
315+ & max_x , & max_y );
316+ } else {
317+ /* Read resolution from the chip */
318+ error = st1232_ts_read_resolution (ts , & max_x , & max_y );
319+ if (error ) {
320+ dev_err (& client -> dev ,
321+ "Failed to read resolution: %d\n" , error );
322+ return error ;
323+ }
324+ }
325+
307326 input_set_abs_params (input_dev , ABS_MT_POSITION_X ,
308327 0 , max_x , 0 , 0 );
309328 input_set_abs_params (input_dev , ABS_MT_POSITION_Y ,
0 commit comments