From 922ffca1455c142341693f515af8e1860a39bab9 Mon Sep 17 00:00:00 2001 From: luowei Date: Wed, 26 Sep 2012 19:26:29 +0800 Subject: [PATCH] phonepad:improve ft5306_ts.c driver --- arch/arm/mach-rk30/include/mach/board.h | 3 +++ drivers/input/touchscreen/ft5306_ts.c | 31 ++++++++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-rk30/include/mach/board.h b/arch/arm/mach-rk30/include/mach/board.h index 67ff4e4c69e6..eedd14ddb9a0 100755 --- a/arch/arm/mach-rk30/include/mach/board.h +++ b/arch/arm/mach-rk30/include/mach/board.h @@ -47,6 +47,9 @@ struct ft5x0x_platform_data{ int max_y; int key_min_x; int key_min_y; + int xy_swap; + int x_revert; + int y_revert; int (*get_pendown_state)(void); int (*init_platform_hw)(void); int (*ft5x0x_platform_sleep)(void); diff --git a/drivers/input/touchscreen/ft5306_ts.c b/drivers/input/touchscreen/ft5306_ts.c index a3f00f0e9d85..d149ac58ed7d 100755 --- a/drivers/input/touchscreen/ft5306_ts.c +++ b/drivers/input/touchscreen/ft5306_ts.c @@ -240,7 +240,7 @@ static int ft5x0x_read_data(void) struct ft5x0x_ts_dev *data = i2c_get_clientdata(g_dev->client); struct ft5x0x_platform_data *pdata = g_dev->client->dev.platform_data; struct ts_event *event = &data->event; - + u16 i = 0; u8 buf[32]= {0};//set send addr to 0x00 *important* int ret = -1; int key; @@ -371,18 +371,37 @@ static int ft5x0x_read_data(void) case 1: event->point[0].status = (buf[0x03] & 0xc0)>>6; event->point[0].id = (buf[0x05] & 0xf0)>>4; - - event->point[0].y = (s16)(buf[0x03] & 0x0f)<<8 | (s16)buf[0x04]; - event->point[0].x = (s16)(buf[0x05] & 0x0f)<<8 | (s16)buf[0x06]; + event->point[0].x = (s16)(buf[0x03] & 0x0f)<<8 | (s16)buf[0x04]; + event->point[0].y = (s16)(buf[0x05] & 0x0f)<<8 | (s16)buf[0x06]; - event->point[0].x = pdata->max_x - event->point[0].x; if(event->point[0].x < 0){ event->point[0].x = 0; } - default: + + for(i=0; itouch_point; i++) + { + if(pdata->xy_swap) + { + swap(event->point[i].x, event->point[i].y); + } + + if(pdata->x_revert) + { + event->point[i].x = pdata->max_x - event->point[i].x; + } + + if(pdata->y_revert) + { + event->point[i].y = pdata->max_y - event->point[i].y; + } + } + + default: return 0; } + + #endif } -- 2.34.1