diff --git a/drivers/gpu/drm/panel/panel-asus-ili9881c.c b/drivers/gpu/drm/panel/panel-asus-ili9881c.c old mode 100755 new mode 100644 index 0d3ce83cb470..d6a15259ff7f --- a/drivers/gpu/drm/panel/panel-asus-ili9881c.c +++ b/drivers/gpu/drm/panel/panel-asus-ili9881c.c @@ -472,6 +472,7 @@ static const struct ili9881c_instr ili9881c_init_1[] = {//10-inch extern struct backlight_device * tinker_mcu_ili9881c_get_backlightdev(void); extern int tinker_mcu_ili9881c_set_bright(int bright); extern void tinker_mcu_ili9881c_screen_power_up(void); +extern void tinker_ft5406_start_polling(void); static inline struct ili9881c *panel_to_ili9881c(struct drm_panel *panel) { @@ -616,6 +617,7 @@ static int ili9881c_enable(struct drm_panel *panel) tinker_mcu_ili9881c_set_bright(0x1F); } + tinker_ft5406_start_polling(); enable = 1; diff --git a/drivers/input/touchscreen/tinker_ft5406.c b/drivers/input/touchscreen/tinker_ft5406.c index 79415e5c85d2..ea709c2b535b 100644 --- a/drivers/input/touchscreen/tinker_ft5406.c +++ b/drivers/input/touchscreen/tinker_ft5406.c @@ -27,6 +27,7 @@ #include "tinker_ft5406.h" struct tinker_ft5406_data *g_ts_data = NULL; +int g_mcu_ready = 0; static int fts_i2c_read(struct i2c_client *client, char *writebuf, int writelen, char *readbuf, int readlen) @@ -93,7 +94,7 @@ static int fts_check_fw_ver(struct i2c_client *client) if (ret < 0) goto error; - LOG_ERR("Firmware version = %d.%d.%d\n", fw_ver[0], fw_ver[1], fw_ver[2]); + LOG_INFO("Firmware version = %d.%d.%d\n", fw_ver[0], fw_ver[1], fw_ver[2]); return 0; error: @@ -135,10 +136,10 @@ static int fts_read_touchdata(struct tinker_ft5406_data *ts_data) event->au16_y[i] = (s16) (buf[FT_TOUCH_Y_H] & 0x0F) << 8 | (s16) buf[FT_TOUCH_Y_L]; event->au8_touch_event[i] = buf[FT_TOUCH_EVENT] >> 6; -#if XY_REVERSE - event->au16_x[i] = SCREEN_WIDTH - event->au16_x[i] - 1; - event->au16_y[i] = SCREEN_HEIGHT - event->au16_y[i] - 1; -#endif + if (ts_data->xy_reverse) { + event->au16_x[i] = ts_data->screen_width - event->au16_x[i] - 1; + event->au16_y[i] = ts_data->screen_height - event->au16_y[i] - 1; + } } event->pressure = FT_PRESS; @@ -186,6 +187,7 @@ static void fts_report_value(struct tinker_ft5406_data *ts_data) } extern int tinker_mcu_is_connected(void); +extern int tinker_mcu_ili9881c_is_connected(void); static void fts_retry_clear(struct tinker_ft5406_data *ts_data) { @@ -248,12 +250,15 @@ static void tinker_ft5406_work(struct work_struct *work) void tinker_ft5406_start_polling(void) { - if (g_ts_data != NULL && g_ts_data->is_polling != 1) { + if (g_ts_data == NULL) { + LOG_ERR("touch is not ready\n"); + } else if (g_ts_data->is_polling == 1) { + LOG_ERR("touch is busy\n"); + } else { g_ts_data->is_polling = 1; schedule_work(&g_ts_data->ft5406_work); - } else { - LOG_ERR("touch is not ready or busy\n"); } + g_mcu_ready = 1; } EXPORT_SYMBOL_GPL(tinker_ft5406_start_polling); @@ -274,7 +279,7 @@ static int tinker_ft5406_probe(struct i2c_client *client, g_ts_data->client = client; i2c_set_clientdata(client, g_ts_data); - while(!tinker_mcu_is_connected() && timeout > 0) { + while(!tinker_mcu_is_connected() && !tinker_mcu_ili9881c_is_connected() && timeout > 0) { msleep(50); timeout--; } @@ -285,6 +290,18 @@ static int tinker_ft5406_probe(struct i2c_client *client, goto timeout_failed; } + if (tinker_mcu_ili9881c_is_connected()) { + g_ts_data->screen_width = 720; + g_ts_data->screen_height = 1280; + g_ts_data->xy_reverse = 0; + } else { + g_ts_data->screen_width = 800; + g_ts_data->screen_height = 480; + g_ts_data->xy_reverse = 1; + } + LOG_INFO("width = %d, height = %d, reverse = %d\n", + g_ts_data->screen_width, g_ts_data->screen_height, g_ts_data->xy_reverse); + input_dev = input_allocate_device(); if (!input_dev) { LOG_ERR("failed to allocate input device\n"); @@ -303,10 +320,8 @@ static int tinker_ft5406_probe(struct i2c_client *client, __set_bit(BTN_TOUCH, input_dev->keybit); input_mt_init_slots(input_dev, MAX_TOUCH_POINTS, 0); - input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, - SCREEN_WIDTH, 0, 0); - input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, - SCREEN_HEIGHT, 0, 0); + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, g_ts_data->screen_width, 0, 0); + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, g_ts_data->screen_height, 0, 0); ret = input_register_device(input_dev); if (ret) { @@ -315,6 +330,8 @@ static int tinker_ft5406_probe(struct i2c_client *client, } INIT_WORK(&g_ts_data->ft5406_work, tinker_ft5406_work); + if (g_mcu_ready == 1) + schedule_work(&g_ts_data->ft5406_work); return 0; @@ -336,6 +353,7 @@ static int tinker_ft5406_remove(struct i2c_client *client) } kfree(g_ts_data); g_ts_data = NULL; + g_mcu_ready = 0; return 0; } diff --git a/drivers/input/touchscreen/tinker_ft5406.h b/drivers/input/touchscreen/tinker_ft5406.h index dcd3e1d3056c..c47f1d2ca781 100644 --- a/drivers/input/touchscreen/tinker_ft5406.h +++ b/drivers/input/touchscreen/tinker_ft5406.h @@ -6,11 +6,6 @@ #define LOG_ERR(fmt,arg...) pr_err("tinker-ft5406: %s: "fmt, __func__, ##arg); #define RETRY_COUNT 10 -#define XY_REVERSE 1 - -#define SCREEN_WIDTH 800 -#define SCREEN_HEIGHT 480 - #define FT_ONE_TCH_LEN 6 #define FT_REG_FW_VER 0xA6 @@ -58,6 +53,9 @@ struct tinker_ft5406_data { struct ts_event event; struct work_struct ft5406_work; + int screen_width; + int screen_height; + int xy_reverse; int is_polling; int known_ids; int retry_count;