2727#include "tinker_ft5406.h"
2828
2929struct tinker_ft5406_data * g_ts_data = NULL ;
30+ int g_mcu_ready = 0 ;
3031
3132static int fts_i2c_read (struct i2c_client * client , char * writebuf ,
3233 int writelen , char * readbuf , int readlen )
@@ -93,7 +94,7 @@ static int fts_check_fw_ver(struct i2c_client *client)
9394 if (ret < 0 )
9495 goto error ;
9596
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 ]);
9798 return 0 ;
9899
99100error :
@@ -135,10 +136,10 @@ static int fts_read_touchdata(struct tinker_ft5406_data *ts_data)
135136 event -> au16_y [i ] = (s16 ) (buf [FT_TOUCH_Y_H ] & 0x0F ) << 8 | (s16 ) buf [FT_TOUCH_Y_L ];
136137 event -> au8_touch_event [i ] = buf [FT_TOUCH_EVENT ] >> 6 ;
137138
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+ }
142143 }
143144 event -> pressure = FT_PRESS ;
144145
@@ -186,6 +187,7 @@ static void fts_report_value(struct tinker_ft5406_data *ts_data)
186187}
187188
188189extern int tinker_mcu_is_connected (void );
190+ extern int tinker_mcu_ili9881c_is_connected (void );
189191
190192static void fts_retry_clear (struct tinker_ft5406_data * ts_data )
191193{
@@ -248,12 +250,15 @@ static void tinker_ft5406_work(struct work_struct *work)
248250
249251void tinker_ft5406_start_polling (void )
250252{
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 {
252258 g_ts_data -> is_polling = 1 ;
253259 schedule_work (& g_ts_data -> ft5406_work );
254- } else {
255- LOG_ERR ("touch is not ready or busy\n" );
256260 }
261+ g_mcu_ready = 1 ;
257262}
258263EXPORT_SYMBOL_GPL (tinker_ft5406_start_polling );
259264
@@ -274,7 +279,7 @@ static int tinker_ft5406_probe(struct i2c_client *client,
274279 g_ts_data -> client = client ;
275280 i2c_set_clientdata (client , g_ts_data );
276281
277- while (!tinker_mcu_is_connected () && timeout > 0 ) {
282+ while (!tinker_mcu_is_connected () && ! tinker_mcu_ili9881c_is_connected () && timeout > 0 ) {
278283 msleep (50 );
279284 timeout -- ;
280285 }
@@ -285,6 +290,18 @@ static int tinker_ft5406_probe(struct i2c_client *client,
285290 goto timeout_failed ;
286291 }
287292
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+
288305 input_dev = input_allocate_device ();
289306 if (!input_dev ) {
290307 LOG_ERR ("failed to allocate input device\n" );
@@ -303,10 +320,8 @@ static int tinker_ft5406_probe(struct i2c_client *client,
303320 __set_bit (BTN_TOUCH , input_dev -> keybit );
304321
305322 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 );
310325
311326 ret = input_register_device (input_dev );
312327 if (ret ) {
@@ -315,6 +330,8 @@ static int tinker_ft5406_probe(struct i2c_client *client,
315330 }
316331
317332 INIT_WORK (& g_ts_data -> ft5406_work , tinker_ft5406_work );
333+ if (g_mcu_ready == 1 )
334+ schedule_work (& g_ts_data -> ft5406_work );
318335
319336 return 0 ;
320337
@@ -336,6 +353,7 @@ static int tinker_ft5406_remove(struct i2c_client *client)
336353 }
337354 kfree (g_ts_data );
338355 g_ts_data = NULL ;
356+ g_mcu_ready = 0 ;
339357 return 0 ;
340358}
341359
0 commit comments