linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: egalax_ts: optmize driver for more fluency touch feelling
@ 2011-12-07  9:10 Zhang Jiejing
  2011-12-12  8:34 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang Jiejing @ 2011-12-07  9:10 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Henrik Rydberg

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@freescale.com>
---
 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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] input: egalax_ts: optmize driver for more fluency touch feelling
  2011-12-07  9:10 [PATCH] input: egalax_ts: optmize driver for more fluency touch feelling Zhang Jiejing
@ 2011-12-12  8:34 ` Dmitry Torokhov
       [not found]   ` <CACrgxGAUYW0E3cLradFJ8SAYBjszWjYdsfrFBAZN6R7a0NO41w@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2011-12-12  8:34 UTC (permalink / raw)
  To: Zhang Jiejing; +Cc: linux-input, Henrik Rydberg

Hi Zhang,

On Wed, Dec 07, 2011 at 05:10:02PM +0800, Zhang Jiejing wrote:
> 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.

I am not sure what you mean by "the event reported is a uniform speed"
but since I2C operations generally sleep you are at the mercy of
scheduler anyways. But since IRQ thread is a real-time one it should get
scheduled immediately.

> 
> 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.

Does it really or it is your opinion that it would?

Also, your change means that the driver can not be stopped/unloaded as
long as user had finger on the touchpad. This would need to be corrected
(but first you need to prove that the change is actually needed).

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] input: egalax_ts: optmize driver for more fluency touch feelling
       [not found]   ` <CACrgxGAUYW0E3cLradFJ8SAYBjszWjYdsfrFBAZN6R7a0NO41w@mail.gmail.com>
@ 2011-12-15  6:24     ` Jiejing.Zhang 
  0 siblings, 0 replies; 3+ messages in thread
From: Jiejing.Zhang  @ 2011-12-15  6:24 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Zhang Jiejing, linux-input, Henrik Rydberg

Hi Dimitry,

2011/12/12 Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> Hi Zhang,
>
> On Wed, Dec 07, 2011 at 05:10:02PM +0800, Zhang Jiejing wrote:
> > 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.
>
> I am not sure what you mean by "the event reported is a uniform speed"
> but since I2C operations generally sleep you are at the mercy of
> scheduler anyways. But since IRQ thread is a real-time one it should get
> scheduled immediately.

I'm using 2.6.38 kernel and Android 4.0 and with a Freescale ARM
A9(1.0GHz) Soc doing this test, but in my test, if I sweep on the
touch screen with very fast speed, my UI can't move as fast as my
finger,
I first suspect our GPU not powerful to drive UI, but after test with
USB mouse doing same sweep operation, the UI was moving quite fast.

So I made this change, after made this change, I can't feed any lay
between finger and the UI animation.
I think the threaded_irq not quite real time.

I checked kernel/irq/handle.c file,
I found in handle_IRQ_event() functin, it will use
wake_up_processs(action->thread);  and the thread was created by
kthread_create() in __setup_irq() function.

I think in this implementation, it will be not so realtime, it depends
on schedule time.
>
>
> >
> > 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.
>
> Does it really or it is your opinion that it would?
>
As I mentioned in above, I got this result with a real machine and
environment  test.
>
> Also, your change means that the driver can not be stopped/unloaded as
> long as user had finger on the touchpad. This would need to be corrected
> (but first you need to prove that the change is actually needed).
>


I need test in the driver unload case and suspend case.

Thanks for you advance.

BR,
Jiejing

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-15  6:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-07  9:10 [PATCH] input: egalax_ts: optmize driver for more fluency touch feelling Zhang Jiejing
2011-12-12  8:34 ` Dmitry Torokhov
     [not found]   ` <CACrgxGAUYW0E3cLradFJ8SAYBjszWjYdsfrFBAZN6R7a0NO41w@mail.gmail.com>
2011-12-15  6:24     ` Jiejing.Zhang 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).