Skip to content

Commit 07f73eb

Browse files
Tzuhsuan_ChenTzuhsuan_Chen
Tzuhsuan_Chen
authored and
Tzuhsuan_Chen
committed
touch: Support the 7" ili9881c panel.
Change-Id: I9a844e41b4ab48ecee42c1ad5cf1b4b4029426ac
1 parent c09c94d commit 07f73eb

File tree

3 files changed

+36
-18
lines changed

3 files changed

+36
-18
lines changed

drivers/gpu/drm/panel/panel-asus-ili9881c.c

100755100644
+2
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ static const struct ili9881c_instr ili9881c_init_1[] = {//10-inch
472472
extern struct backlight_device * tinker_mcu_ili9881c_get_backlightdev(void);
473473
extern int tinker_mcu_ili9881c_set_bright(int bright);
474474
extern void tinker_mcu_ili9881c_screen_power_up(void);
475+
extern void tinker_ft5406_start_polling(void);
475476

476477
static inline struct ili9881c *panel_to_ili9881c(struct drm_panel *panel)
477478
{
@@ -616,6 +617,7 @@ static int ili9881c_enable(struct drm_panel *panel)
616617
tinker_mcu_ili9881c_set_bright(0x1F);
617618
}
618619

620+
tinker_ft5406_start_polling();
619621

620622
enable = 1;
621623

drivers/input/touchscreen/tinker_ft5406.c

+31-13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "tinker_ft5406.h"
2828

2929
struct tinker_ft5406_data *g_ts_data = NULL;
30+
int g_mcu_ready = 0;
3031

3132
static 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

99100
error:
@@ -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

188189
extern int tinker_mcu_is_connected(void);
190+
extern int tinker_mcu_ili9881c_is_connected(void);
189191

190192
static 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

249251
void 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
}
258263
EXPORT_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

drivers/input/touchscreen/tinker_ft5406.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
#define LOG_ERR(fmt,arg...) pr_err("tinker-ft5406: %s: "fmt, __func__, ##arg);
77

88
#define RETRY_COUNT 10
9-
#define XY_REVERSE 1
10-
11-
#define SCREEN_WIDTH 800
12-
#define SCREEN_HEIGHT 480
13-
149
#define FT_ONE_TCH_LEN 6
1510

1611
#define FT_REG_FW_VER 0xA6
@@ -58,6 +53,9 @@ struct tinker_ft5406_data {
5853
struct ts_event event;
5954
struct work_struct ft5406_work;
6055

56+
int screen_width;
57+
int screen_height;
58+
int xy_reverse;
6159
int is_polling;
6260
int known_ids;
6361
int retry_count;

0 commit comments

Comments
 (0)