From c5c377a7f5dbcbe7bcf4e2d84f6047e62112349c Mon Sep 17 00:00:00 2001 From: Lukas-David Gorris Date: Fri, 22 Apr 2011 23:10:01 +0200 Subject: [PATCH] htcleo: add Cotulla's fixes for non-android touchscreen! --- arch/arm/mach-msm/board-htcleo-ts.c | 58 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/arch/arm/mach-msm/board-htcleo-ts.c b/arch/arm/mach-msm/board-htcleo-ts.c index 46e7c37e..707719c7 100644 --- a/arch/arm/mach-msm/board-htcleo-ts.c +++ b/arch/arm/mach-msm/board-htcleo-ts.c @@ -51,16 +51,23 @@ #define MAKEWORD(a, b) ((uint16_t)(((uint8_t)(a)) | ((uint16_t)((uint8_t)(b))) << 8)) +typedef struct tagPOINT +{ + int x; + int y; +} POINT, *PPOINT, *LPPOINT; + struct htcleo_ts_data { struct i2c_client *client; struct input_dev *input_dev; - uint32_t prev_ptcount; int ts_type; int intr_type; // 0 - FAILING, 1- RISING int pressed1; int pressed2; + POINT pt1; + POINT pt2; struct work_struct work; #ifndef TS_USE_IRQ struct hrtimer timer; @@ -249,8 +256,7 @@ static void htcleo_ts_work_func(struct work_struct *work) { uint8_t buf[9]; uint32_t ptcount; - uint32_t ptx[2]; - uint32_t pty[2]; + POINT pt1, pt2; struct htcleo_ts_data *ts = container_of(work, struct htcleo_ts_data, work); int pressed1, pressed2; @@ -277,13 +283,13 @@ static void htcleo_ts_work_func(struct work_struct *work) if (ptcount >= 1) { - ptx[0] = MAKEWORD(buf[2], (buf[1] & 0xF0) >> 4); - pty[0] = MAKEWORD(buf[3], (buf[1] & 0x0F) >> 0); + pt1.x = MAKEWORD(buf[2], (buf[1] & 0xF0) >> 4); + pt1.y = MAKEWORD(buf[3], (buf[1] & 0x0F) >> 0); } if (ptcount == 2) { - ptx[1] = MAKEWORD(buf[5], (buf[4] & 0xF0) >> 4); - pty[1] = MAKEWORD(buf[6], (buf[4] & 0x0F) >> 0); + pt2.x = MAKEWORD(buf[5], (buf[4] & 0xF0) >> 4); + pt2.y = MAKEWORD(buf[6], (buf[4] & 0x0F) >> 0); } break; default: @@ -293,11 +299,11 @@ static void htcleo_ts_work_func(struct work_struct *work) if (ptcount == 0) - dev_dbg(&ts->client->dev, "TS: not pressed\n"); + dev_dbg(&ts->client->dev, "TS: not pressed (%d, %d)\n", pt1.x, pt1.y); else if (ptcount == 1) - dev_dbg(&ts->client->dev, "TS: pressed1 (%d, %d)\n", ptx[0], pty[0]); + dev_dbg(&ts->client->dev, "TS: pressed1 (%d, %d)\n", pt1.x, pt1.y); else if (ptcount == 2) - dev_dbg(&ts->client->dev, "TS: pressed2 (%d, %d) (%d, %d)\n", ptx[0], pty[0], ptx[1], pty[1]); + dev_dbg(&ts->client->dev, "TS: pressed2 (%d, %d) (%d, %d)\n", pt1.x, pt1.y, pt2.x, pt2.y); else dev_dbg(&ts->client->dev, "TS: BUGGY!\n"); @@ -326,14 +332,14 @@ static void htcleo_ts_work_func(struct work_struct *work) if (pressed1) { dev_dbg(&ts->client->dev, "pressed1\n"); - input_report_abs(ts->input_dev, ABS_X, ptx[0]); - input_report_abs(ts->input_dev, ABS_Y, pty[0]); + input_report_abs(ts->input_dev, ABS_X, pt1.x); + input_report_abs(ts->input_dev, ABS_Y, pt1.y); input_report_abs(ts->input_dev, ABS_PRESSURE, 100); input_report_abs(ts->input_dev, ABS_TOOL_WIDTH, 1); input_report_key(ts->input_dev, BTN_TOUCH, 1); #ifdef CONFIG_HTCLEO_ENABLE_MULTI_TOUCH - input_report_abs(ts->input_dev, ABS_MT_POSITION_X, ptx[0]); - input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, pty[0]); + input_report_abs(ts->input_dev, ABS_MT_POSITION_X, pt1.x); + input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, pt1.y); input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 100); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); #endif @@ -341,27 +347,28 @@ static void htcleo_ts_work_func(struct work_struct *work) else if (ts->pressed1) { dev_dbg(&ts->client->dev, "unpressed1\n"); - input_report_abs(ts->input_dev, ABS_X, ptx[0]); - input_report_abs(ts->input_dev, ABS_Y, pty[0]); + input_report_abs(ts->input_dev, ABS_X, ts->pt1.x); + input_report_abs(ts->input_dev, ABS_Y, ts->pt1.y); input_report_abs(ts->input_dev, ABS_PRESSURE, 0); input_report_abs(ts->input_dev, ABS_TOOL_WIDTH, 0); input_report_key(ts->input_dev, BTN_TOUCH, 0); #ifdef CONFIG_HTCLEO_ENABLE_MULTI_TOUCH - input_report_abs(ts->input_dev, ABS_MT_POSITION_X, ptx[0]); - input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, pty[0]); + input_report_abs(ts->input_dev, ABS_MT_POSITION_X, ts->pt1.x); + input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, ts->pt1.y); input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); #endif } - #ifdef CONFIG_HTCLEO_ENABLE_MULTI_TOUCH + +#ifdef CONFIG_HTCLEO_ENABLE_MULTI_TOUCH input_mt_sync(ts->input_dev); if (pressed2) { dev_dbg(&ts->client->dev, "pressed2\n"); - input_report_abs(ts->input_dev, ABS_MT_POSITION_X, ptx[1]); - input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, pty[1]); + input_report_abs(ts->input_dev, ABS_MT_POSITION_X, pt2.x); + input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, pt2.y); input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 100); input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); } @@ -371,14 +378,16 @@ static void htcleo_ts_work_func(struct work_struct *work) input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); } input_mt_sync(ts->input_dev); - #endif +#endif input_sync(ts->input_dev); + /* save old values */ ts->pressed1 = pressed1; ts->pressed2 = pressed2; + ts->pt1 = pt1; + ts->pt2 = pt2; - error: - ts->prev_ptcount = ptcount; +error: /* prepare for next intr */ enable_irq(ts->client->irq); @@ -435,7 +444,6 @@ static int htcleo_ts_probe(struct i2c_client *client, const struct i2c_device_id INIT_WORK(&ts->work, htcleo_ts_work_func); ts->client = client; i2c_set_clientdata(client, ts); - ts->prev_ptcount = 0; config_gpio_table(touch_on_gpio_table, ARRAY_SIZE(touch_on_gpio_table)); -- 2.11.4.GIT