Skip to content

Commit

Permalink
touch: Support the 7" ili9881c panel.
Browse files Browse the repository at this point in the history
Change-Id: I9a844e41b4ab48ecee42c1ad5cf1b4b4029426ac
  • Loading branch information
Tzuhsuan_Chen authored and Tzuhsuan_Chen committed Feb 26, 2020
1 parent c09c94d commit 07f73eb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/panel/panel-asus-ili9881c.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -616,6 +617,7 @@ static int ili9881c_enable(struct drm_panel *panel)
tinker_mcu_ili9881c_set_bright(0x1F);
}

tinker_ft5406_start_polling();

enable = 1;

Expand Down
44 changes: 31 additions & 13 deletions drivers/input/touchscreen/tinker_ft5406.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand All @@ -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--;
}
Expand All @@ -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");
Expand All @@ -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) {
Expand All @@ -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;

Expand All @@ -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;
}

Expand Down
8 changes: 3 additions & 5 deletions drivers/input/touchscreen/tinker_ft5406.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 07f73eb

Please sign in to comment.