Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] Input: touchscreen: tsc2007: Reduce I2C transactions for Z2 read
@ 2026-04-10  7:41 Yuki Horii
  2026-04-20  0:18 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Yuki Horii @ 2026-04-10  7:41 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: clamor95, johannes.kirchmair, linux-input, yuuki198708

From: Yuki Horii <yuuki198708@gmail.com>

The current implementation sends a separate power-down command
after reading the Z2 value, resulting in an extra I2C
transaction per measurement cycle.

The TSC2007 command byte contains a 2-bit power-down mode
selection field. By selecting the power-down state in the Z2
measurement command, the device powers down after the Z2 A/D
conversion completes, eliminating the subsequent power-down
transaction.

This reduces the number of I2C transactions by one per touch
measurement cycle, decreasing I2C bus overhead and improving
touch sampling performance.

Signed-off-by: Yuki Horii <yuuki198708@gmail.com>
---
 drivers/input/touchscreen/tsc2007_core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
index 948935de894b..ff60245baa96 100644
--- a/drivers/input/touchscreen/tsc2007_core.c
+++ b/drivers/input/touchscreen/tsc2007_core.c
@@ -61,10 +61,8 @@ static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
 
 	/* turn y+ off, x- on; we'll use formula #1 */
 	tc->z1 = tsc2007_xfer(tsc, READ_Z1);
-	tc->z2 = tsc2007_xfer(tsc, READ_Z2);
-
-	/* Prepare for next touch reading - power down ADC, enable PENIRQ */
-	tsc2007_xfer(tsc, PWRDOWN);
+	/* Read Z2 and power down ADC after A/D conversion, enable PENIRQ */
+	tc->z2 = tsc2007_xfer(tsc, (TSC2007_POWER_OFF_IRQ_EN | TSC2007_MEASURE_Z2));
 }
 
 u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)
-- 
2.51.0


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

* Re: [PATCH] Input: touchscreen: tsc2007: Reduce I2C transactions for Z2 read
  2026-04-10  7:41 [PATCH] Input: touchscreen: tsc2007: Reduce I2C transactions for Z2 read Yuki Horii
@ 2026-04-20  0:18 ` Dmitry Torokhov
  2026-05-02 10:53   ` Andreas Kemnade
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2026-04-20  0:18 UTC (permalink / raw)
  To: Yuki Horii; +Cc: clamor95, johannes.kirchmair, linux-input, Andreas Kemnade

Hi Yuki,

On Fri, Apr 10, 2026 at 04:41:00PM +0900, Yuki Horii wrote:
> From: Yuki Horii <yuuki198708@gmail.com>
> 
> The current implementation sends a separate power-down command
> after reading the Z2 value, resulting in an extra I2C
> transaction per measurement cycle.
> 
> The TSC2007 command byte contains a 2-bit power-down mode
> selection field. By selecting the power-down state in the Z2
> measurement command, the device powers down after the Z2 A/D
> conversion completes, eliminating the subsequent power-down
> transaction.
> 
> This reduces the number of I2C transactions by one per touch
> measurement cycle, decreasing I2C bus overhead and improving
> touch sampling performance.
> 
> Signed-off-by: Yuki Horii <yuuki198708@gmail.com>
> ---
>  drivers/input/touchscreen/tsc2007_core.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
> index 948935de894b..ff60245baa96 100644
> --- a/drivers/input/touchscreen/tsc2007_core.c
> +++ b/drivers/input/touchscreen/tsc2007_core.c
> @@ -61,10 +61,8 @@ static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
>  
>  	/* turn y+ off, x- on; we'll use formula #1 */
>  	tc->z1 = tsc2007_xfer(tsc, READ_Z1);
> -	tc->z2 = tsc2007_xfer(tsc, READ_Z2);
> -
> -	/* Prepare for next touch reading - power down ADC, enable PENIRQ */
> -	tsc2007_xfer(tsc, PWRDOWN);
> +	/* Read Z2 and power down ADC after A/D conversion, enable PENIRQ */
> +	tc->z2 = tsc2007_xfer(tsc, (TSC2007_POWER_OFF_IRQ_EN | TSC2007_MEASURE_Z2));
>  }
>  
>  u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)

Thank you for the patch.

I'd like people using this part to chime in (CCed).

Thanks.

-- 
Dmitry

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

* Re: [PATCH] Input: touchscreen: tsc2007: Reduce I2C transactions for Z2 read
  2026-04-20  0:18 ` Dmitry Torokhov
@ 2026-05-02 10:53   ` Andreas Kemnade
  2026-05-05  0:29     ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Kemnade @ 2026-05-02 10:53 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Yuki Horii, clamor95, johannes.kirchmair, linux-input

Hi,

On Sun, 19 Apr 2026 17:18:23 -0700
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:

> Hi Yuki,
> 
> On Fri, Apr 10, 2026 at 04:41:00PM +0900, Yuki Horii wrote:
> > From: Yuki Horii <yuuki198708@gmail.com>
> > 
> > The current implementation sends a separate power-down command
> > after reading the Z2 value, resulting in an extra I2C
> > transaction per measurement cycle.
> > 
> > The TSC2007 command byte contains a 2-bit power-down mode
> > selection field. By selecting the power-down state in the Z2
> > measurement command, the device powers down after the Z2 A/D
> > conversion completes, eliminating the subsequent power-down
> > transaction.
> > 
> > This reduces the number of I2C transactions by one per touch
> > measurement cycle, decreasing I2C bus overhead and improving
> > touch sampling performance.
> > 
> > Signed-off-by: Yuki Horii <yuuki198708@gmail.com>
> > ---
> >  drivers/input/touchscreen/tsc2007_core.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
> > index 948935de894b..ff60245baa96 100644
> > --- a/drivers/input/touchscreen/tsc2007_core.c
> > +++ b/drivers/input/touchscreen/tsc2007_core.c
> > @@ -61,10 +61,8 @@ static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
> >  
> >  	/* turn y+ off, x- on; we'll use formula #1 */
> >  	tc->z1 = tsc2007_xfer(tsc, READ_Z1);
> > -	tc->z2 = tsc2007_xfer(tsc, READ_Z2);
> > -
> > -	/* Prepare for next touch reading - power down ADC, enable PENIRQ */
> > -	tsc2007_xfer(tsc, PWRDOWN);
> > +	/* Read Z2 and power down ADC after A/D conversion, enable PENIRQ */
> > +	tc->z2 = tsc2007_xfer(tsc, (TSC2007_POWER_OFF_IRQ_EN | TSC2007_MEASURE_Z2));
> >  }
> >  
> >  u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)  
> 
> Thank you for the patch.
> 
> I'd like people using this part to chime in (CCed).
> 
This looks like that there might be some reason behind it. But I cannot find any.
Either by reading the datasheet nor by testing.

I have checked the interrupt counter. Output seems still be same.
Interrupts appear when finger is moving.

So 
Tested-by: Andreas Kemnade <andreas@kemnade.info> # GTA04



> Thanks.
> 


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

* Re: [PATCH] Input: touchscreen: tsc2007: Reduce I2C transactions for Z2 read
  2026-05-02 10:53   ` Andreas Kemnade
@ 2026-05-05  0:29     ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2026-05-05  0:29 UTC (permalink / raw)
  To: Andreas Kemnade; +Cc: Yuki Horii, clamor95, johannes.kirchmair, linux-input

On Sat, May 02, 2026 at 12:53:13PM +0200, Andreas Kemnade wrote:
> Hi,
> 
> On Sun, 19 Apr 2026 17:18:23 -0700
> Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> 
> > Hi Yuki,
> > 
> > On Fri, Apr 10, 2026 at 04:41:00PM +0900, Yuki Horii wrote:
> > > From: Yuki Horii <yuuki198708@gmail.com>
> > > 
> > > The current implementation sends a separate power-down command
> > > after reading the Z2 value, resulting in an extra I2C
> > > transaction per measurement cycle.
> > > 
> > > The TSC2007 command byte contains a 2-bit power-down mode
> > > selection field. By selecting the power-down state in the Z2
> > > measurement command, the device powers down after the Z2 A/D
> > > conversion completes, eliminating the subsequent power-down
> > > transaction.
> > > 
> > > This reduces the number of I2C transactions by one per touch
> > > measurement cycle, decreasing I2C bus overhead and improving
> > > touch sampling performance.
> > > 
> > > Signed-off-by: Yuki Horii <yuuki198708@gmail.com>
> > > ---
> > >  drivers/input/touchscreen/tsc2007_core.c | 6 ++----
> > >  1 file changed, 2 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
> > > index 948935de894b..ff60245baa96 100644
> > > --- a/drivers/input/touchscreen/tsc2007_core.c
> > > +++ b/drivers/input/touchscreen/tsc2007_core.c
> > > @@ -61,10 +61,8 @@ static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
> > >  
> > >  	/* turn y+ off, x- on; we'll use formula #1 */
> > >  	tc->z1 = tsc2007_xfer(tsc, READ_Z1);
> > > -	tc->z2 = tsc2007_xfer(tsc, READ_Z2);
> > > -
> > > -	/* Prepare for next touch reading - power down ADC, enable PENIRQ */
> > > -	tsc2007_xfer(tsc, PWRDOWN);
> > > +	/* Read Z2 and power down ADC after A/D conversion, enable PENIRQ */
> > > +	tc->z2 = tsc2007_xfer(tsc, (TSC2007_POWER_OFF_IRQ_EN | TSC2007_MEASURE_Z2));
> > >  }
> > >  
> > >  u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)  
> > 
> > Thank you for the patch.
> > 
> > I'd like people using this part to chime in (CCed).
> > 
> This looks like that there might be some reason behind it. But I cannot find any.
> Either by reading the datasheet nor by testing.
> 
> I have checked the interrupt counter. Output seems still be same.
> Interrupts appear when finger is moving.
> 
> So 
> Tested-by: Andreas Kemnade <andreas@kemnade.info> # GTA04

Thank you for giving it a spin Andreas.

Applied, thank you Yuki.

-- 
Dmitry

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

end of thread, other threads:[~2026-05-05  0:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10  7:41 [PATCH] Input: touchscreen: tsc2007: Reduce I2C transactions for Z2 read Yuki Horii
2026-04-20  0:18 ` Dmitry Torokhov
2026-05-02 10:53   ` Andreas Kemnade
2026-05-05  0:29     ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox