20
20
#include <linux/device.h>
21
21
#include <linux/sysfs.h>
22
22
#include <linux/input/mt.h>
23
+ #include <linux/input/touchscreen.h>
23
24
#include <linux/platform_data/zforce_ts.h>
24
25
#include <linux/regulator/consumer.h>
25
26
#include <linux/of.h>
@@ -106,6 +107,7 @@ struct zforce_point {
106
107
struct zforce_ts {
107
108
struct i2c_client * client ;
108
109
struct input_dev * input ;
110
+ struct touchscreen_properties prop ;
109
111
const struct zforce_ts_platdata * pdata ;
110
112
char phys [32 ];
111
113
@@ -266,7 +268,6 @@ static int zforce_setconfig(struct zforce_ts *ts, char b1)
266
268
static int zforce_start (struct zforce_ts * ts )
267
269
{
268
270
struct i2c_client * client = ts -> client ;
269
- const struct zforce_ts_platdata * pdata = ts -> pdata ;
270
271
int ret ;
271
272
272
273
dev_dbg (& client -> dev , "starting device\n" );
@@ -277,7 +278,7 @@ static int zforce_start(struct zforce_ts *ts)
277
278
return ret ;
278
279
}
279
280
280
- ret = zforce_resolution (ts , pdata -> x_max , pdata -> y_max );
281
+ ret = zforce_resolution (ts , ts -> prop . max_x , ts -> prop . max_y );
281
282
if (ret ) {
282
283
dev_err (& client -> dev , "Unable to set resolution, %d\n" , ret );
283
284
goto error ;
@@ -337,7 +338,6 @@ static int zforce_stop(struct zforce_ts *ts)
337
338
static int zforce_touch_event (struct zforce_ts * ts , u8 * payload )
338
339
{
339
340
struct i2c_client * client = ts -> client ;
340
- const struct zforce_ts_platdata * pdata = ts -> pdata ;
341
341
struct zforce_point point ;
342
342
int count , i , num = 0 ;
343
343
@@ -355,8 +355,8 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
355
355
point .coord_y =
356
356
payload [9 * i + 4 ] << 8 | payload [9 * i + 3 ];
357
357
358
- if (point .coord_x > pdata -> x_max ||
359
- point .coord_y > pdata -> y_max ) {
358
+ if (point .coord_x > ts -> prop . max_x ||
359
+ point .coord_y > ts -> prop . max_y ) {
360
360
dev_warn (& client -> dev , "coordinates (%d,%d) invalid\n" ,
361
361
point .coord_x , point .coord_y );
362
362
point .coord_x = point .coord_y = 0 ;
@@ -390,10 +390,9 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
390
390
point .state != STATE_UP );
391
391
392
392
if (point .state != STATE_UP ) {
393
- input_report_abs (ts -> input , ABS_MT_POSITION_X ,
394
- point .coord_x );
395
- input_report_abs (ts -> input , ABS_MT_POSITION_Y ,
396
- point .coord_y );
393
+ touchscreen_report_pos (ts -> input , & ts -> prop ,
394
+ point .coord_x , point .coord_y ,
395
+ true);
397
396
input_report_abs (ts -> input , ABS_MT_TOUCH_MAJOR ,
398
397
point .area_major );
399
398
input_report_abs (ts -> input , ABS_MT_TOUCH_MINOR ,
@@ -719,15 +718,8 @@ static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
719
718
return ERR_PTR (- ENOMEM );
720
719
}
721
720
722
- if (of_property_read_u32 (np , "x-size" , & pdata -> x_max )) {
723
- dev_err (dev , "failed to get x-size property\n" );
724
- return ERR_PTR (- EINVAL );
725
- }
726
-
727
- if (of_property_read_u32 (np , "y-size" , & pdata -> y_max )) {
728
- dev_err (dev , "failed to get y-size property\n" );
729
- return ERR_PTR (- EINVAL );
730
- }
721
+ of_property_read_u32 (np , "x-size" , & pdata -> x_max );
722
+ of_property_read_u32 (np , "y-size" , & pdata -> y_max );
731
723
732
724
return pdata ;
733
725
}
@@ -856,6 +848,12 @@ static int zforce_probe(struct i2c_client *client)
856
848
input_set_abs_params (input_dev , ABS_MT_POSITION_Y , 0 ,
857
849
pdata -> y_max , 0 , 0 );
858
850
851
+ touchscreen_parse_properties (input_dev , true, & ts -> prop );
852
+ if (ts -> prop .max_x == 0 || ts -> prop .max_y == 0 ) {
853
+ dev_err (& client -> dev , "no size specified\n" );
854
+ return - EINVAL ;
855
+ }
856
+
859
857
input_set_abs_params (input_dev , ABS_MT_TOUCH_MAJOR , 0 ,
860
858
ZFORCE_MAX_AREA , 0 , 0 );
861
859
input_set_abs_params (input_dev , ABS_MT_TOUCH_MINOR , 0 ,
0 commit comments