From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mitko Gamishev <hehopmajieh@debian.bg>
Date: Wed, 5 Feb 2020 15:18:04 +0200
Subject: drv:input:touchscreen:sun4i-ts Enable parsing

---
 drivers/input/touchscreen/sun4i-ts.c | 19 ++++++++--
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c
index 111111111111..222222222222 100644
--- a/drivers/input/touchscreen/sun4i-ts.c
+++ b/drivers/input/touchscreen/sun4i-ts.c
@@ -32,6 +32,7 @@
 #include <linux/thermal.h>
 #include <linux/init.h>
 #include <linux/input.h>
+#include <linux/input/touchscreen.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -106,6 +107,7 @@
 struct sun4i_ts_data {
 	struct device *dev;
 	struct input_dev *input;
+	struct touchscreen_properties prop;
 	void __iomem *base;
 	unsigned int irq;
 	bool ignore_fifo_data;
@@ -123,8 +125,8 @@ static void sun4i_ts_irq_handle_input(struct sun4i_ts_data *ts, u32 reg_val)
 		y = readl(ts->base + TP_DATA);
 		/* The 1st location reported after an up event is unreliable */
 		if (!ts->ignore_fifo_data) {
-			input_report_abs(ts->input, ABS_X, x);
-			input_report_abs(ts->input, ABS_Y, y);
+			touchscreen_report_pos(ts->input, &ts->prop, x, y, false);
+
 			/*
 			 * The hardware has a separate down status bit, but
 			 * that gets set before we get the first location,
@@ -296,8 +298,17 @@ static int sun4i_ts_probe(struct platform_device *pdev)
 		ts->input->id.version = 0x0100;
 		ts->input->evbit[0] =  BIT(EV_SYN) | BIT(EV_KEY) | BIT(EV_ABS);
 		__set_bit(BTN_TOUCH, ts->input->keybit);
-		input_set_abs_params(ts->input, ABS_X, 0, 4095, 0, 0);
-		input_set_abs_params(ts->input, ABS_Y, 0, 4095, 0, 0);
+
+		touchscreen_parse_properties(ts->input, false, &ts->prop);
+
+		if (!ts->prop.max_x || !ts->prop.max_y) {
+			dev_info(&pdev->dev, "Invalid configuration, using defaults\n");
+			ts->prop.max_x = 4095;
+			ts->prop.max_y = 4095;
+		}
+
+		input_set_abs_params(ts->input, ABS_X, 0, ts->prop.max_x, 0, 0);
+		input_set_abs_params(ts->input, ABS_Y, 0, ts->prop.max_y, 0, 0);
 		input_set_drvdata(ts->input, ts);
 	}
 
-- 
Armbian

