From d34f52d35cb815e5abcf5c0dfde5518e5279bd85 Mon Sep 17 00:00:00 2001
From: z3deverp <z3@vmsv-debian.(none)>
Date: Sat, 14 Nov 2009 01:30:04 +0900
Subject: [PATCH] modify ads7846 touchscreen driver

---
 drivers/input/touchscreen/ads7846.c |   10 ++++++++++
 include/linux/spi/ads7846.h         |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index ba9d38c..7f81d60 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -99,6 +99,8 @@ struct ads7846 {
 	u16			pressure_max;
 
 	bool			swap_xy;
+	u16			reverse_x;
+	u16			reverse_y;
 
 	struct ads7846_packet	*packet;
 
@@ -606,6 +608,12 @@ static void ads7846_rx(void *ads)
 		if (ts->swap_xy)
 			swap(x, y);
 
+		if (ts->reverse_x)
+			x = (x < ts->reverse_x) ? (ts->reverse_x - x) : 0;
+
+		if (ts->reverse_y)
+			y = (y < ts->reverse_y) ? (ts->reverse_y - y) : 0;
+
 		input_report_abs(input, ABS_X, x);
 		input_report_abs(input, ABS_Y, y);
 		input_report_abs(input, ABS_PRESSURE, Rt);
@@ -925,6 +933,8 @@ static int __devinit ads7846_probe(struct spi_device *spi)
 	ts->input = input_dev;
 	ts->vref_mv = pdata->vref_mv;
 	ts->swap_xy = pdata->swap_xy;
+	ts->reverse_x = pdata->reverse_x ? (pdata->x_min + pdata->x_max) : 0;
+	ts->reverse_y = pdata->reverse_y ? (pdata->y_min + pdata->y_max) : 0;
 
 	hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	ts->timer.function = ads7846_timer;
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index 51948eb..0de69c6 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -18,6 +18,8 @@ struct ads7846_platform_data {
 	bool	keep_vref_on;		/* set to keep vref on for differential
 					 * measurements as well */
 	bool	swap_xy;		/* swap x and y axes */
+	bool	reverse_x;		/* reverse x */
+	bool	reverse_y;		/* reverse y */
 
 	/* Settling time of the analog signals; a function of Vcc and the
 	 * capacitance on the X/Y drivers.  If set to non-zero, two samples
-- 
1.4.4.4

