INPUT: ads7846 - fix wrong transfer init for ads7845

Started by Markus Niebel on Apr 26, 2012

Subsystems (2)

Maintainers (2)

DORMANTno replies

open the first message on its own page

Message details and related content
For ads7845 transfer packets are wrong initialized for
activated settle_delay_usec. Buffers of spi_transfers have to point
to the ads7845 buffers also for the transfers used for implementing
the settling delay. Otherwise the filter will see invalid / uninitialized
data and the input gets the first raw samples.

This patch fixes the wrong buffer init.

Signed-off-by: Markus Niebel <redacted>
---
 drivers/input/touchscreen/ads7846.c |   50 ++++++++++++++++++++++------------
 1 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 23fd901..9dca61d 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -1043,16 +1043,23 @@ static void __devinit ads7846_setup_spi_msg(struct ads7846 *ts,
 	 */
 	if (pdata->settle_delay_usecs) {
 		x->delay_usecs = pdata->settle_delay_usecs;
+		if (ts->model == 7845) {
+			x++;
+			x->tx_buf = &packet->read_y_cmd[0];
+			x->rx_buf = &packet->tc.y_buf[0];
+			x->len = 3;
+			spi_message_add_tail(x, m);
+		} else {
+			x++;
+			x->tx_buf = &packet->read_y;
+			x->len = 1;
+			spi_message_add_tail(x, m);
 
-		x++;
-		x->tx_buf = &packet->read_y;
-		x->len = 1;
-		spi_message_add_tail(x, m);
-
-		x++;
-		x->rx_buf = &packet->tc.y;
-		x->len = 2;
-		spi_message_add_tail(x, m);
+			x++;
+			x->rx_buf = &packet->tc.y;
+			x->len = 2;
+			spi_message_add_tail(x, m);
+		}
 	}
 
 	ts->msg_count++;
@@ -1086,16 +1093,23 @@ static void __devinit ads7846_setup_spi_msg(struct ads7846 *ts,
 	/* ... maybe discard first sample ... */
 	if (pdata->settle_delay_usecs) {
 		x->delay_usecs = pdata->settle_delay_usecs;
+		if (ts->model == 7845) {
+			x++;
+			x->tx_buf = &packet->read_x_cmd[0];
+			x->rx_buf = &packet->tc.x_buf[0];
+			x->len = 3;
+			spi_message_add_tail(x, m);
+		} else {
+			x++;
+			x->tx_buf = &packet->read_x;
+			x->len = 1;
+			spi_message_add_tail(x, m);
 
-		x++;
-		x->tx_buf = &packet->read_x;
-		x->len = 1;
-		spi_message_add_tail(x, m);
-
-		x++;
-		x->rx_buf = &packet->tc.x;
-		x->len = 2;
-		spi_message_add_tail(x, m);
+			x++;
+			x->rx_buf = &packet->tc.x;
+			x->len = 2;
+			spi_message_add_tail(x, m);
+		}
 	}
 
 	/* turn y+ off, x- on; we'll use formula #2 */
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help