27
27
#include "tinker_ft5406.h"
28
28
29
29
struct tinker_ft5406_data * g_ts_data = NULL ;
30
+ int g_mcu_ready = 0 ;
30
31
31
32
static int fts_i2c_read (struct i2c_client * client , char * writebuf ,
32
33
int writelen , char * readbuf , int readlen )
@@ -93,7 +94,7 @@ static int fts_check_fw_ver(struct i2c_client *client)
93
94
if (ret < 0 )
94
95
goto error ;
95
96
96
- LOG_ERR ("Firmware version = %d.%d.%d\n" , fw_ver [0 ], fw_ver [1 ], fw_ver [2 ]);
97
+ LOG_INFO ("Firmware version = %d.%d.%d\n" , fw_ver [0 ], fw_ver [1 ], fw_ver [2 ]);
97
98
return 0 ;
98
99
99
100
error :
@@ -135,10 +136,10 @@ static int fts_read_touchdata(struct tinker_ft5406_data *ts_data)
135
136
event -> au16_y [i ] = (s16 ) (buf [FT_TOUCH_Y_H ] & 0x0F ) << 8 | (s16 ) buf [FT_TOUCH_Y_L ];
136
137
event -> au8_touch_event [i ] = buf [FT_TOUCH_EVENT ] >> 6 ;
137
138
138
- # if XY_REVERSE
139
- event -> au16_x [i ] = SCREEN_WIDTH - event -> au16_x [i ] - 1 ;
140
- event -> au16_y [i ] = SCREEN_HEIGHT - event -> au16_y [i ] - 1 ;
141
- #endif
139
+ if ( ts_data -> xy_reverse ) {
140
+ event -> au16_x [i ] = ts_data -> screen_width - event -> au16_x [i ] - 1 ;
141
+ event -> au16_y [i ] = ts_data -> screen_height - event -> au16_y [i ] - 1 ;
142
+ }
142
143
}
143
144
event -> pressure = FT_PRESS ;
144
145
@@ -186,6 +187,7 @@ static void fts_report_value(struct tinker_ft5406_data *ts_data)
186
187
}
187
188
188
189
extern int tinker_mcu_is_connected (void );
190
+ extern int tinker_mcu_ili9881c_is_connected (void );
189
191
190
192
static void fts_retry_clear (struct tinker_ft5406_data * ts_data )
191
193
{
@@ -248,12 +250,15 @@ static void tinker_ft5406_work(struct work_struct *work)
248
250
249
251
void tinker_ft5406_start_polling (void )
250
252
{
251
- if (g_ts_data != NULL && g_ts_data -> is_polling != 1 ) {
253
+ if (g_ts_data == NULL ) {
254
+ LOG_ERR ("touch is not ready\n" );
255
+ } else if (g_ts_data -> is_polling == 1 ) {
256
+ LOG_ERR ("touch is busy\n" );
257
+ } else {
252
258
g_ts_data -> is_polling = 1 ;
253
259
schedule_work (& g_ts_data -> ft5406_work );
254
- } else {
255
- LOG_ERR ("touch is not ready or busy\n" );
256
260
}
261
+ g_mcu_ready = 1 ;
257
262
}
258
263
EXPORT_SYMBOL_GPL (tinker_ft5406_start_polling );
259
264
@@ -274,7 +279,7 @@ static int tinker_ft5406_probe(struct i2c_client *client,
274
279
g_ts_data -> client = client ;
275
280
i2c_set_clientdata (client , g_ts_data );
276
281
277
- while (!tinker_mcu_is_connected () && timeout > 0 ) {
282
+ while (!tinker_mcu_is_connected () && ! tinker_mcu_ili9881c_is_connected () && timeout > 0 ) {
278
283
msleep (50 );
279
284
timeout -- ;
280
285
}
@@ -285,6 +290,18 @@ static int tinker_ft5406_probe(struct i2c_client *client,
285
290
goto timeout_failed ;
286
291
}
287
292
293
+ if (tinker_mcu_ili9881c_is_connected ()) {
294
+ g_ts_data -> screen_width = 720 ;
295
+ g_ts_data -> screen_height = 1280 ;
296
+ g_ts_data -> xy_reverse = 0 ;
297
+ } else {
298
+ g_ts_data -> screen_width = 800 ;
299
+ g_ts_data -> screen_height = 480 ;
300
+ g_ts_data -> xy_reverse = 1 ;
301
+ }
302
+ LOG_INFO ("width = %d, height = %d, reverse = %d\n" ,
303
+ g_ts_data -> screen_width , g_ts_data -> screen_height , g_ts_data -> xy_reverse );
304
+
288
305
input_dev = input_allocate_device ();
289
306
if (!input_dev ) {
290
307
LOG_ERR ("failed to allocate input device\n" );
@@ -303,10 +320,8 @@ static int tinker_ft5406_probe(struct i2c_client *client,
303
320
__set_bit (BTN_TOUCH , input_dev -> keybit );
304
321
305
322
input_mt_init_slots (input_dev , MAX_TOUCH_POINTS , 0 );
306
- input_set_abs_params (input_dev , ABS_MT_POSITION_X , 0 ,
307
- SCREEN_WIDTH , 0 , 0 );
308
- input_set_abs_params (input_dev , ABS_MT_POSITION_Y , 0 ,
309
- SCREEN_HEIGHT , 0 , 0 );
323
+ input_set_abs_params (input_dev , ABS_MT_POSITION_X , 0 , g_ts_data -> screen_width , 0 , 0 );
324
+ input_set_abs_params (input_dev , ABS_MT_POSITION_Y , 0 , g_ts_data -> screen_height , 0 , 0 );
310
325
311
326
ret = input_register_device (input_dev );
312
327
if (ret ) {
@@ -315,6 +330,8 @@ static int tinker_ft5406_probe(struct i2c_client *client,
315
330
}
316
331
317
332
INIT_WORK (& g_ts_data -> ft5406_work , tinker_ft5406_work );
333
+ if (g_mcu_ready == 1 )
334
+ schedule_work (& g_ts_data -> ft5406_work );
318
335
319
336
return 0 ;
320
337
@@ -336,6 +353,7 @@ static int tinker_ft5406_remove(struct i2c_client *client)
336
353
}
337
354
kfree (g_ts_data );
338
355
g_ts_data = NULL ;
356
+ g_mcu_ready = 0 ;
339
357
return 0 ;
340
358
}
341
359
0 commit comments