[PATCH] input: egalax_ts: optmize driver for more fluency touch feelling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



egalax_ts use threaded_irq to report touch event, it will wake up the
irq thread and stop the thread irq after process one touch event, so
even user touch the screen very fast, the fastest event report speed
is depends on the scheduler, so the event reported is a uniform speed.

This patch will let thread irq check the gpio's status, if the gpio
is down, means still have more events, it will not exit the irq handler
and continue process another new event, it can improve user experience.

Signed-off-by: Zhang Jiejing <jiejing.zhang@xxxxxxxxxxxxx>
---
 drivers/input/touchscreen/egalax_ts.c |   63 +++++++++++++++++---------------
 1 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index f694535..21bd2ec 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -74,45 +74,48 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
 	u8 state;
 
 	do {
-		ret = i2c_master_recv(client, buf, MAX_I2C_DATA_LEN);
-	} while (ret == -EAGAIN && tries++ < EGALAX_MAX_TRIES);
+		do {
+			ret = i2c_master_recv(client, buf, MAX_I2C_DATA_LEN);
+		} while (ret == -EAGAIN && tries++ < EGALAX_MAX_TRIES);
 
-	if (ret < 0)
-		return IRQ_HANDLED;
+		if (ret < 0)
+			return IRQ_HANDLED;
 
-	if (buf[0] != REPORT_MODE_MTTOUCH) {
-		/* ignore mouse events and vendor events */
-		return IRQ_HANDLED;
-	}
+		if (buf[0] != REPORT_MODE_MTTOUCH) {
+			/* ignore mouse events and vendor events */
+			return IRQ_HANDLED;
+		}
 
-	state = buf[1];
-	x = (buf[3] << 8) | buf[2];
-	y = (buf[5] << 8) | buf[4];
-	z = (buf[7] << 8) | buf[6];
+		state = buf[1];
+		x = (buf[3] << 8) | buf[2];
+		y = (buf[5] << 8) | buf[4];
+		z = (buf[7] << 8) | buf[6];
 
-	valid = state & EVENT_VALID_MASK;
-	id = (state & EVENT_ID_MASK) >> EVENT_ID_OFFSET;
-	down = state & EVENT_DOWN_UP;
+		valid = state & EVENT_VALID_MASK;
+		id = (state & EVENT_ID_MASK) >> EVENT_ID_OFFSET;
+		down = state & EVENT_DOWN_UP;
 
-	if (!valid || id > MAX_SUPPORT_POINTS) {
-		dev_dbg(&client->dev, "point invalid\n");
-		return IRQ_HANDLED;
-	}
+		if (!valid || id > MAX_SUPPORT_POINTS) {
+			dev_dbg(&client->dev, "point invalid\n");
+			return IRQ_HANDLED;
+		}
 
-	input_mt_slot(input_dev, id);
-	input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down);
+		input_mt_slot(input_dev, id);
+		input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down);
 
-	dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d",
-		(down ? "down" : "up"), id, x, y, z);
+		dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d",
+			(down ? "down" : "up"), id, x, y, z);
 
-	if (down) {
-		input_report_abs(input_dev, ABS_MT_POSITION_X, x);
-		input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
-		input_report_abs(input_dev, ABS_MT_PRESSURE, z);
-	}
+		if (down) {
+			input_report_abs(input_dev, ABS_MT_POSITION_X, x);
+			input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
+			input_report_abs(input_dev, ABS_MT_PRESSURE, z);
+		}
+
+		input_mt_report_pointer_emulation(input_dev, true);
+		input_sync(input_dev);
+	} while (gpio_get_value(irq_to_gpio(client->irq)) == 0);
 
-	input_mt_report_pointer_emulation(input_dev, true);
-	input_sync(input_dev);
 	return IRQ_HANDLED;
 }
 
-- 
1.7.1


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux