Skip to contentSkip to conversation

fix channel allocation in the touch screen driver

PATCH In review Alan Cox 3 participants 5 messages Aug 25, 2010 – Sep 1, 2010

Subsystems (2)
lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/2 fix channel allocation in the touch screen driver

From: Arjan van de Ven <[email protected]>

the touch screen driver tries to find a range of free channels (which are an array of bytes), by scanning for the "end of used channel" marker. however it tries to be WAAAAY too smart and does 32 bit logic on 8 bit quantities, and in the process completely gets it wrong (repeatedly read the same register instead of incrementing in the loop, assuming that if any of the 4 bytes in the 32 byte quantity is free, all four are free, returning the channel number divided by 4 rather than the actual first free channel number)

On the setting side, the same mistakes are made by and large; changed this to just use the byte SCU write functions....

with these fixes we go from a completely non detected touchscreen to something that appears to completely get detected.
(after also fixing the ordering issue that Jacobs patch should solve)

---

 drivers/staging/mrst-touchscreen/intel-mid-touch.c |   29 ++++++++------------
 1 files changed, 12 insertions(+), 17 deletions(-)
drivers/staging/mrst-touchscreen/intel-mid-touch.c +12 -17
index 97c7b7f..2a1a692 100644
@@ -157,8 +157,8 @@ static int mrstouch_pmic_id(uint *vendor, uint *rev)
  */
 static int mrstouch_chan_parse(struct mrstouch_dev *tsdev)
 {
-	int err, i, j, found;
-	u32 r32;
+	int err, i, found;
+	u8 r8;
 
 	found = -1;
 
@@ -166,15 +166,13 @@ static int mrstouch_chan_parse(struct mrstouch_dev *tsdev)
 		if (found >= 0)
 			break;
 
-		err = intel_scu_ipc_ioread32(PMICADDR0, &r32);
+		err = intel_scu_ipc_ioread8(PMICADDR0 + i, &r8);
 		if (err)
 			return err;
 
-		for (j = 0; j < 32; j+= 8) {
-			if (((r32 >> j) & 0xFF) == END_OF_CHANNEL) {
-				found = i;
-				break;
-			}
+		if (r8 == END_OF_CHANNEL) {
+			found = i;
+			break;
 		}
 	}
 	if (found < 0)
@@ -284,20 +282,17 @@ static int mrstouch_ts_chan_read(u16 offset, u16 chan, u16 *vp, u16 *vm)
  */
 static int mrstouch_ts_chan_set(uint offset)
 {
-	int count;
 	u16 chan;
-	u16 reg[5];
-	u8 data[5];
+
+	int ret, count;
 
 	chan = PMICADDR0 + offset;
 	for (count = 0; count <= 3; count++) {
-		reg[count] = chan++;
-		data[count] = MRST_TS_CHAN10 + count;
+		ret = intel_scu_ipc_iowrite8(chan++, MRST_TS_CHAN10 + count);
+		if (ret)
+			return ret;
 	}
-	reg[count] = chan;
-	data[count] = END_OF_CHANNEL;
-
-	return intel_scu_ipc_writev(reg, data, 5);
+	return intel_scu_ipc_iowrite8(chan++, END_OF_CHANNEL);
 }
 
 /* Initialize ADC */
author
#1 lore raw

PATCH 2/2 intel_mid_touch: Resync upstream with the development tree

This merges bits from the two diverging trees including code by Andy Ross and Arjan van de Ven

---

 drivers/staging/mrst-touchscreen/TODO              |    3 
 drivers/staging/mrst-touchscreen/intel-mid-touch.c |  938 ++++++++------------
 2 files changed, 378 insertions(+), 563 deletions(-)
drivers/staging/mrst-touchscreen/TODO +1 -2
index 7157028..0bb20d4 100644
@@ -1,2 +1 @@
-- Move the driver to not think it is SPI (requires fixing some of the SFI
-  and firmware side)
+- Final fixups and checks on r/m/w sequence conversions
drivers/staging/mrst-touchscreen/intel-mid-touch.c +377 -561

1,144 lines not on this page · raw message

#2 lore raw

Re: [PATCH 2/2] intel_mid_touch: Resync upstream with the development tree

Quoted 2 lines · Alan Cox

This merges bits from the two diverging trees including code by Andy Ross and Arjan van de Ven

But it doesn't apply to my staging tree, odd.

Care to respin it against linux-next? Is there something in linux-next from Dmitry for this driver that might be getting me confused here?

thanks,

greg k-h

#3 lore raw

Re: [PATCH 2/2] intel_mid_touch: Resync upstream with the development tree

Quoted 8 lines · Greg KH
Quoted 2 lines · Alan Cox

This merges bits from the two diverging trees including code by Andy Ross and Arjan van de Ven

But it doesn't apply to my staging tree, odd.

Care to respin it against linux-next? Is there something in linux-next from Dmitry for this driver that might be getting me confused here?

Well, I collected all patches from Alan and applied to my mrst-touchscreen branch (based off 2.6.35) and added a patch moving it out of staging and into input. Please take a look and if you do not see any issues I'll merge it into my 'next' branch for .37.

BTW, I took the liberty of tagging the move patch as Acked-by by both of you so please shout if you disagree.

Thanks.

Signature · 1 line
Dmitry
#4 lore raw

Re: [PATCH 2/2] intel_mid_touch: Resync upstream with the development tree

Quoted 7 lines · Dmitry Torokhov
Quoted 6 lines · Greg KH
Quoted 2 lines · Alan Cox

This merges bits from the two diverging trees including code by Andy Ross and Arjan van de Ven

But it doesn't apply to my staging tree, odd.

Quoted 7 lines
Quoted 2 lines

Care to respin it against linux-next? Is there something in linux-next from Dmitry for this driver that might be getting me confused here?

Well, I collected all patches from Alan and applied to my mrst-touchscreen branch (based off 2.6.35) and added a patch moving it out of staging and into input. Please take a look and if you do not see any issues I'll merge it into my 'next' branch for .37.

Ah, that's great, sorry, I didn't realize this.

Quoted 2 lines

BTW, I took the liberty of tagging the move patch as Acked-by by both of you so please shout if you disagree.

It's fine by me, thanks for doing this.

greg k-h