From 1da5cc7373f44cb73fd323d78e1184e61cb4b46e Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Wed, 2 Apr 2025 12:37:08 +0100
Subject: [PATCH] dtoverlays: Add invx and invy overrides to ads7846 touch
 overlay

It had swapxy, but no way to trigger the X and Y inversions

Also use the generic "touchscreen-swapped-x-y" for swapxy
instead of the TI specific "ti,swap-xy".

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 arch/arm/boot/dts/overlays/README              | 2 ++
 arch/arm/boot/dts/overlays/ads7846-overlay.dts | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -602,6 +602,8 @@ Params: cs                      SPI bus
         pmax                    Maximum reported pressure value (default 65535)
         xohms                   Touchpanel sensitivity (X-plate resistance)
                                 (default 400)
+        invx                    Invert x axis
+        invy                    Invert y axis
 
         penirq is required and usually xohms (60-100) has to be set as well.
         Apart from that, pmax (255) and swapxy are also common.
--- a/arch/arm/boot/dts/overlays/ads7846-overlay.dts
+++ b/arch/arm/boot/dts/overlays/ads7846-overlay.dts
@@ -77,7 +77,7 @@
 			 <&ads7846>,"interrupts:0",
 			 <&ads7846>,"pendown-gpio:4";
 		penirq_pull = <&ads7846_pins>,"brcm,pull:0";
-		swapxy = <&ads7846>,"ti,swap-xy?";
+		swapxy = <&ads7846>,"touchscreen-swapped-x-y?";
 		xmin =   <&ads7846>,"ti,x-min;0";
 		ymin =   <&ads7846>,"ti,y-min;0";
 		xmax =   <&ads7846>,"ti,x-max;0";
@@ -85,5 +85,7 @@
 		pmin =   <&ads7846>,"ti,pressure-min;0";
 		pmax =   <&ads7846>,"ti,pressure-max;0";
 		xohms =  <&ads7846>,"ti,x-plate-ohms;0";
+		invx =   <&ads7846>,"touchscreen-inverted-x?";
+		invy =   <&ads7846>,"touchscreen-inverted-y?";
 	};
 };
