[PATCH 1/2] input: touchscreen: ads7846.c: Add support for invert_x/y in dt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Added device-tree flags "ti,invert_x" and "ti,invert_y" to specify
inversion of X and/or Y axes respectively.

Signed-off-by: David Jander <david@xxxxxxxxxxx>
---
 .../bindings/input/touchscreen/ads7846.txt           |  2 ++
 drivers/input/touchscreen/ads7846.c                  | 12 ++++++++++++
 include/linux/spi/ads7846.h                          |  2 ++
 3 files changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
index 04413da51391..946f4fd0133e 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
@@ -33,6 +33,8 @@ Optional properties:
 	ti,keep-vref-on			set to keep vref on for differential
 					measurements as well
 	ti,swap-xy			swap x and y axis
+	ti,invert_x			invert x axis
+	ti,invert_y			invert y axis
 	ti,settle-delay-usec		Settling time of the analog signals;
 					a function of Vcc and the capacitance
 					on the X/Y drivers.  If set to non-zero,
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index a2f45aefce08..b853e889c6ec 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -111,6 +111,8 @@ struct ads7846 {
 	u16			pressure_max;
 
 	bool			swap_xy;
+	bool			invert_x;
+	bool			invert_y;
 	bool			use_internal;
 
 	struct ads7846_packet	*packet;
@@ -829,6 +831,12 @@ static void ads7846_report_state(struct ads7846 *ts)
 		if (ts->swap_xy)
 			swap(x, y);
 
+		if (ts->invert_x)
+			x = MAX_12BIT - x;
+
+		if (ts->invert_y)
+			y = MAX_12BIT - y;
+
 		if (!ts->pendown) {
 			input_report_key(input, BTN_TOUCH, 1);
 			ts->pendown = true;
@@ -1212,6 +1220,8 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
 	pdata->keep_vref_on = of_property_read_bool(node, "ti,keep-vref-on");
 
 	pdata->swap_xy = of_property_read_bool(node, "ti,swap-xy");
+	pdata->invert_x = of_property_read_bool(node, "ti,invert_x");
+	pdata->invert_y = of_property_read_bool(node, "ti,invert_y");
 
 	of_property_read_u16(node, "ti,settle-delay-usec",
 			     &pdata->settle_delay_usecs);
@@ -1316,6 +1326,8 @@ static int ads7846_probe(struct spi_device *spi)
 
 	ts->vref_mv = pdata->vref_mv;
 	ts->swap_xy = pdata->swap_xy;
+	ts->invert_x = pdata->invert_x;
+	ts->invert_y = pdata->invert_y;
 
 	if (pdata->filter != NULL) {
 		if (pdata->filter_init != NULL) {
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index 1a5eaef3b7f2..6b8022c625a3 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -20,6 +20,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	invert_x;		/* Invert x axis */
+	bool	invert_y;		/* Invert y axis */
 
 	/* 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
-- 
2.19.1




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux