mirror of https://github.com/armbian/build.git
BigTreeTech TSC2007 touchscreen ghost touches patch update for current (6.6)
This commit is contained in:
parent
5610f20aaa
commit
d92d484e3f
|
@ -1,21 +1,22 @@
|
||||||
From f95e0f97e5decca1dd3f25d82729af4dca3b80d7 Mon Sep 17 00:00:00 2001
|
From f95e0f97e5decca1dd3f25d82729af4dca3b80d7 Mon Sep 17 00:00:00 2001
|
||||||
From: JohnTheCoolingFan <ivan8215145640@gmail.com>
|
From: JohnTheCoolingFan <ivan8215145640@gmail.com>
|
||||||
Date: Sun, 15 Dec 2024 13:59:13 +0000
|
Date: Sat, 25 Jan 2025 11:12:12 +0000
|
||||||
Subject: Fix ghost touches on tsc2007 tft screen
|
Subject: Fix ghost touches on tsc2007 tft-screen
|
||||||
|
|
||||||
Signed-off-by: JohnTheCoolingFan <ivan8215145640@gmail.com>
|
Signed-off-by: JohnTheCoolingFan <ivan8215145640@gmail.com>
|
||||||
---
|
arch/arm64/boot/dts/allwinner/sun50i-h616-bigtreetech-cb1.dtsi | 1 +
|
||||||
.../sun50i-h616-bigtreetech-cb1.dtsi | 1 +
|
drivers/input/touchscreen/tsc2007.h | 1 +
|
||||||
drivers/input/touchscreen/tsc2007.h | 1 +
|
drivers/input/touchscreen/tsc2007_core.c | 96 +++++-----
|
||||||
drivers/input/touchscreen/tsc2007_core.c | 111 +++++++++---------
|
include/linux/platform_data/tsc2007.h | 1 +
|
||||||
include/linux/platform_data/tsc2007.h | 1 +
|
4 files changed, 49 insertions(+), 50 deletions(-)
|
||||||
4 files changed, 60 insertions(+), 54 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h616-bigtreetech-cb1.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h616-bigtreetech-cb1.dtsi
|
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h616-bigtreetech-cb1.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h616-bigtreetech-cb1.dtsi
|
||||||
index c2e20408cb66..f4a4b4fea1f5 100644
|
index c2e20408c..f4a4b4fea 100644
|
||||||
--- a/arch/arm64/boot/dts/allwinner/sun50i-h616-bigtreetech-cb1.dtsi
|
--- a/arch/arm64/boot/dts/allwinner/sun50i-h616-bigtreetech-cb1.dtsi
|
||||||
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-bigtreetech-cb1.dtsi
|
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-bigtreetech-cb1.dtsi
|
||||||
@@ -124,6 +124,7 @@ tft_tp: ns2009@48 {
|
@@ -122,10 +122,11 @@ i2c_gpio: i2c-gpio {
|
||||||
|
tft_tp: ns2009@48 {
|
||||||
|
compatible = "ti,tsc2007";
|
||||||
reg = <0x48>;
|
reg = <0x48>;
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
ti,x-plate-ohms = <660>;
|
ti,x-plate-ohms = <660>;
|
||||||
|
@ -23,11 +24,15 @@ index c2e20408cb66..f4a4b4fea1f5 100644
|
||||||
ti,rt-thr = <3000>;
|
ti,rt-thr = <3000>;
|
||||||
ti,fuzzx = <32>;
|
ti,fuzzx = <32>;
|
||||||
ti,fuzzy = <16>;
|
ti,fuzzy = <16>;
|
||||||
|
i2c,ignore-nak = <1>;
|
||||||
|
};
|
||||||
diff --git a/drivers/input/touchscreen/tsc2007.h b/drivers/input/touchscreen/tsc2007.h
|
diff --git a/drivers/input/touchscreen/tsc2007.h b/drivers/input/touchscreen/tsc2007.h
|
||||||
index 5252b6c6daeb..7411b8bce99c 100644
|
index 5252b6c6d..7411b8bce 100644
|
||||||
--- a/drivers/input/touchscreen/tsc2007.h
|
--- a/drivers/input/touchscreen/tsc2007.h
|
||||||
+++ b/drivers/input/touchscreen/tsc2007.h
|
+++ b/drivers/input/touchscreen/tsc2007.h
|
||||||
@@ -65,6 +65,7 @@ struct tsc2007 {
|
@@ -63,10 +63,11 @@ struct tsc2007 {
|
||||||
|
|
||||||
|
struct i2c_client *client;
|
||||||
|
|
||||||
u16 model;
|
u16 model;
|
||||||
u16 x_plate_ohms;
|
u16 x_plate_ohms;
|
||||||
|
@ -35,11 +40,15 @@ index 5252b6c6daeb..7411b8bce99c 100644
|
||||||
u16 max_rt;
|
u16 max_rt;
|
||||||
u16 rt_thr;
|
u16 rt_thr;
|
||||||
u8 touched;
|
u8 touched;
|
||||||
|
unsigned long poll_period; /* in jiffies */
|
||||||
|
int fuzzx;
|
||||||
diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
|
diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
|
||||||
index 5267b0d0ad8c..51fb33d76426 100644
|
index 5267b0d0a..e2708fc92 100644
|
||||||
--- a/drivers/input/touchscreen/tsc2007_core.c
|
--- a/drivers/input/touchscreen/tsc2007_core.c
|
||||||
+++ b/drivers/input/touchscreen/tsc2007_core.c
|
+++ b/drivers/input/touchscreen/tsc2007_core.c
|
||||||
@@ -70,22 +70,25 @@ static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
|
@@ -68,26 +68,24 @@ static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
|
||||||
|
tsc2007_xfer(tsc, PWRDOWN);
|
||||||
|
}
|
||||||
|
|
||||||
u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)
|
u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)
|
||||||
{
|
{
|
||||||
|
@ -47,8 +56,10 @@ index 5267b0d0ad8c..51fb33d76426 100644
|
||||||
-
|
-
|
||||||
- /* range filtering */
|
- /* range filtering */
|
||||||
- if (tc->x == MAX_12BIT)
|
- if (tc->x == MAX_12BIT)
|
||||||
- tc->x = 0;
|
+ if (tc->x == MAX_12BIT){
|
||||||
-
|
tc->x = 0;
|
||||||
|
+ }
|
||||||
|
|
||||||
- if (likely(tc->x && tc->z1)) {
|
- if (likely(tc->x && tc->z1)) {
|
||||||
- /* compute touch resistance using equation #1 */
|
- /* compute touch resistance using equation #1 */
|
||||||
- rt = tc->z2 - tc->z1;
|
- rt = tc->z2 - tc->z1;
|
||||||
|
@ -56,31 +67,25 @@ index 5267b0d0ad8c..51fb33d76426 100644
|
||||||
- rt *= tsc->x_plate_ohms;
|
- rt *= tsc->x_plate_ohms;
|
||||||
- rt /= tc->z1;
|
- rt /= tc->z1;
|
||||||
- rt = (rt + 2047) >> 12;
|
- rt = (rt + 2047) >> 12;
|
||||||
- }
|
+ if (tc->y == MAX_12BIT){
|
||||||
+ u32 rt = 0;
|
+ tc->y = 0;
|
||||||
+ if (tc->x == MAX_12BIT){
|
}
|
||||||
+ /* dev_info(&tsc->client->dev, "[DEBUG TSC] RESISTANCE CALCULATED | TC->X is MAX_12BIT Force to 0 || TC Z1: (%4d) | TC Z2: (%4d) | TC X: (%4d) | TC Y: (%4d)", tc->z1, tc->z2, tc->x, tc->y);*/
|
|
||||||
+ tc->x = 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (tc->y == MAX_12BIT){
|
|
||||||
+ /*dev_info(&tsc->client->dev, "[DEBUG TSC] RESISTANCE CALCULATED | TC->Y is MAX_12BIT Force to 0 || TC Z1: (%4d) | TC Z2: (%4d) | TC X: (%4d) | TC Y: (%4d)", tc->z1, tc->z2, tc->x, tc->y);*/
|
|
||||||
+ tc->y = 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ if (likely(tc->x && tc->y && tc->z1)) {
|
|
||||||
+ return (tsc->x_plate_ohms * tc->x / 4096) * ((4096 / tc->z1) - 1) - tsc->y_plate_ohms * (1 - tc->y / 4096);
|
|
||||||
+ }else{
|
|
||||||
+ /*dev_info(&tsc->client->dev, "[DEBUG TSC] RESISTANCE CALCULATED | Missing mandatory Data TCX(%4d) | TCY(%4d) | TCZ1(%4d)",tc->x,tc->y,tc->z1);*/
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
- return rt;
|
- return rt;
|
||||||
|
+
|
||||||
|
+ if (likely(tc->x && tc->y && tc->z1)) {
|
||||||
|
+ return (tsc->x_plate_ohms * tc->x / 4096) * ((4096 / tc->z1) - 1) - tsc->y_plate_ohms * (1 - tc->y / 4096);
|
||||||
|
+ } else{
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tsc2007_is_pen_down(struct tsc2007 *ts)
|
bool tsc2007_is_pen_down(struct tsc2007 *ts)
|
||||||
@@ -180,6 +183,7 @@ static irqreturn_t tsc2007_soft_poll(int irq, void *handle)
|
{
|
||||||
|
/*
|
||||||
|
@@ -178,58 +176,45 @@ static irqreturn_t tsc2007_soft_poll(int irq, void *handle)
|
||||||
|
{
|
||||||
|
struct tsc2007 *ts = handle;
|
||||||
struct input_dev *input = ts->input;
|
struct input_dev *input = ts->input;
|
||||||
struct ts_event tc;
|
struct ts_event tc;
|
||||||
u32 rt;
|
u32 rt;
|
||||||
|
@ -88,7 +93,9 @@ index 5267b0d0ad8c..51fb33d76426 100644
|
||||||
|
|
||||||
if(!ts->stopped) {
|
if(!ts->stopped) {
|
||||||
|
|
||||||
@@ -189,47 +193,39 @@ static irqreturn_t tsc2007_soft_poll(int irq, void *handle)
|
mutex_lock(&ts->mlock);
|
||||||
|
tsc2007_read_values(ts, &tc);
|
||||||
|
mutex_unlock(&ts->mlock);
|
||||||
|
|
||||||
rt = tsc2007_calculate_resistance(ts, &tc);
|
rt = tsc2007_calculate_resistance(ts, &tc);
|
||||||
|
|
||||||
|
@ -110,12 +117,21 @@ index 5267b0d0ad8c..51fb33d76426 100644
|
||||||
- tc.x, tc.y, rt);
|
- tc.x, tc.y, rt);
|
||||||
-
|
-
|
||||||
- rt = ts->max_rt - rt;
|
- rt = ts->max_rt - rt;
|
||||||
-
|
+ if (likely(rt)) {
|
||||||
|
|
||||||
- input_report_key(input, BTN_TOUCH, 1);
|
- input_report_key(input, BTN_TOUCH, 1);
|
||||||
- input_report_abs(input, ABS_X, tc.y);
|
- input_report_abs(input, ABS_X, tc.y);
|
||||||
- input_report_abs(input, ABS_Y, 4096 - tc.x);
|
- input_report_abs(input, ABS_Y, 4096 - tc.x);
|
||||||
- input_report_abs(input, ABS_PRESSURE, rt);
|
- input_report_abs(input, ABS_PRESSURE, rt);
|
||||||
-
|
+ /* range >= 0 && <= 4096 */
|
||||||
|
+ if (rt > 0 && rt <= ts->max_rt) {
|
||||||
|
+ rt = ts->max_rt - rt;
|
||||||
|
+ input_report_key(input, BTN_TOUCH, 1);
|
||||||
|
+ input_report_abs(input, ABS_X, tc.y);
|
||||||
|
+ input_report_abs(input, ABS_Y, 4096 - tc.x);
|
||||||
|
+ input_report_abs(input, ABS_PRESSURE, rt);
|
||||||
|
+ input_sync(input);
|
||||||
|
|
||||||
- input_sync(input);
|
- input_sync(input);
|
||||||
- ts->touched = 1;
|
- ts->touched = 1;
|
||||||
-
|
-
|
||||||
|
@ -127,47 +143,29 @@ index 5267b0d0ad8c..51fb33d76426 100644
|
||||||
- input_report_abs(input, ABS_PRESSURE, 0);
|
- input_report_abs(input, ABS_PRESSURE, 0);
|
||||||
- input_sync(input);
|
- input_sync(input);
|
||||||
- ts->touched = 0;
|
- ts->touched = 0;
|
||||||
- }
|
+ } else {
|
||||||
- }
|
+ //Discard Input Ghost or inconsistent
|
||||||
|
+ skipSync= true;
|
||||||
|
}
|
||||||
|
+ }else{
|
||||||
|
+ // No touch event or missing data for rt calculation
|
||||||
|
+ skipSync= true;
|
||||||
|
}
|
||||||
|
+ }
|
||||||
|
|
||||||
-
|
-
|
||||||
-
|
+ if(skipSync){
|
||||||
+ if (likely(rt)) {
|
+ input_report_key(input, BTN_TOUCH, 0);
|
||||||
+
|
+ input_report_abs(input, ABS_PRESSURE, 0);
|
||||||
+ /* range >= 0 && <= 4096 */
|
+ input_sync(input);
|
||||||
+ if (rt > 0 && rt <= ts->max_rt) {
|
|
||||||
+ rt = ts->max_rt - rt;
|
|
||||||
+ input_report_key(input, BTN_TOUCH, 1);
|
|
||||||
+ input_report_abs(input, ABS_X, tc.y);
|
|
||||||
+ input_report_abs(input, ABS_Y, 4096 - tc.x);
|
|
||||||
+ input_report_abs(input, ABS_PRESSURE, rt);
|
|
||||||
+ input_sync(input);
|
|
||||||
+ /*dev_info(&ts->client->dev, "[DEBUG TSC] TOUCH TRIGGERED | RT: (%4d) | TC Z1: (%4d) | TC Z2: (%4d) | TC X: (%4d) | TC Y: (%4d)", rt, tc.z1, tc.z2, tc.x, tc.y);*/
|
|
||||||
+
|
|
||||||
+ } else {
|
|
||||||
+ //Discard Input Ghost or inconsistent
|
|
||||||
+ /*dev_info(&ts->client->dev, "[DEBUG TSC] TOUCH DISCARD | RT: (%4d) | TC Z1: (%4d) | TC Z2: (%4d) | TC X: (%4d) | TC Y: (%4d)", rt, tc.z1, tc.z2, tc.x, tc.y);*/
|
|
||||||
+ skipSync= true;
|
|
||||||
+ }
|
|
||||||
+ }else{
|
|
||||||
+ // No touch event or missing data for rt calculation
|
|
||||||
+ skipSync= true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ }else{
|
|
||||||
+ // TFT Not initialized
|
|
||||||
+ /* dev_info(&ts->client->dev, "DEBUG TSC: TouchScreen Stopped"); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ if(skipSync){
|
|
||||||
+ input_report_key(input, BTN_TOUCH, 0);
|
|
||||||
+ input_report_abs(input, ABS_PRESSURE, 0);
|
|
||||||
+ input_sync(input);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +325,13 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)
|
@@ -327,10 +312,17 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)
|
||||||
|
} else {
|
||||||
|
dev_err(dev, "Missing ti,x-plate-ohms device property\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,11 +179,61 @@ index 5267b0d0ad8c..51fb33d76426 100644
|
||||||
ts->gpiod = devm_gpiod_get_optional(dev, NULL, GPIOD_IN);
|
ts->gpiod = devm_gpiod_get_optional(dev, NULL, GPIOD_IN);
|
||||||
if (IS_ERR(ts->gpiod))
|
if (IS_ERR(ts->gpiod))
|
||||||
return PTR_ERR(ts->gpiod);
|
return PTR_ERR(ts->gpiod);
|
||||||
|
|
||||||
|
if (ts->gpiod)
|
||||||
|
@@ -345,10 +337,11 @@ static int tsc2007_probe_pdev(struct device *dev, struct tsc2007 *ts,
|
||||||
|
const struct tsc2007_platform_data *pdata,
|
||||||
|
const struct i2c_device_id *id)
|
||||||
|
{
|
||||||
|
ts->model = pdata->model;
|
||||||
|
ts->x_plate_ohms = pdata->x_plate_ohms;
|
||||||
|
+ ts->y_plate_ohms = pdata->y_plate_ohms;
|
||||||
|
ts->max_rt = pdata->max_rt ? : MAX_12BIT;
|
||||||
|
ts->poll_period = msecs_to_jiffies(pdata->poll_period ? : 1);
|
||||||
|
ts->get_pendown_state = pdata->get_pendown_state;
|
||||||
|
ts->clear_penirq = pdata->clear_penirq;
|
||||||
|
ts->fuzzx = pdata->fuzzx;
|
||||||
|
@@ -358,10 +351,15 @@ static int tsc2007_probe_pdev(struct device *dev, struct tsc2007 *ts,
|
||||||
|
if (pdata->x_plate_ohms == 0) {
|
||||||
|
dev_err(dev, "x_plate_ohms is not set up in platform data\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (pdata->y_plate_ohms == 0) {
|
||||||
|
+ dev_err(dev, "y_plate_ohms is not set up in platform data\n");
|
||||||
|
+ return -EINVAL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tsc2007_call_exit_platform_hw(void *data)
|
||||||
|
{
|
||||||
|
@@ -456,15 +454,13 @@ static int tsc2007_probe(struct i2c_client *client)
|
||||||
|
dev_err(&client->dev, "Failed to request irq %d: %d\n",
|
||||||
|
ts->irq, err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
- INIT_WORK(&ts->work_i2c_poll,
|
||||||
|
- tsc2007_ts_work_i2c_poll);
|
||||||
|
+ INIT_WORK(&ts->work_i2c_poll, tsc2007_ts_work_i2c_poll);
|
||||||
|
timer_setup(&ts->timer, tsc2007_ts_irq_poll_timer, 0);
|
||||||
|
- ts->timer.expires = jiffies +
|
||||||
|
- msecs_to_jiffies(POLL_INTERVAL_MS);
|
||||||
|
+ ts->timer.expires = jiffies + msecs_to_jiffies(POLL_INTERVAL_MS);
|
||||||
|
add_timer(&ts->timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
tsc2007_stop(ts);
|
||||||
|
|
||||||
diff --git a/include/linux/platform_data/tsc2007.h b/include/linux/platform_data/tsc2007.h
|
diff --git a/include/linux/platform_data/tsc2007.h b/include/linux/platform_data/tsc2007.h
|
||||||
index a0ca52c41ccb..f88e580322f0 100644
|
index a0ca52c41..f88e58032 100644
|
||||||
--- a/include/linux/platform_data/tsc2007.h
|
--- a/include/linux/platform_data/tsc2007.h
|
||||||
+++ b/include/linux/platform_data/tsc2007.h
|
+++ b/include/linux/platform_data/tsc2007.h
|
||||||
@@ -7,6 +7,7 @@
|
@@ -5,10 +5,11 @@
|
||||||
|
/* linux/platform_data/tsc2007.h */
|
||||||
|
|
||||||
struct tsc2007_platform_data {
|
struct tsc2007_platform_data {
|
||||||
u16 model; /* 2007. */
|
u16 model; /* 2007. */
|
||||||
u16 x_plate_ohms; /* must be non-zero value */
|
u16 x_plate_ohms; /* must be non-zero value */
|
||||||
|
@ -193,6 +241,8 @@ index a0ca52c41ccb..f88e580322f0 100644
|
||||||
u16 max_rt; /* max. resistance above which samples are ignored */
|
u16 max_rt; /* max. resistance above which samples are ignored */
|
||||||
unsigned long poll_period; /* time (in ms) between samples */
|
unsigned long poll_period; /* time (in ms) between samples */
|
||||||
int fuzzx; /* fuzz factor for X, Y and pressure axes */
|
int fuzzx; /* fuzz factor for X, Y and pressure axes */
|
||||||
|
int fuzzy;
|
||||||
|
int fuzzz;
|
||||||
--
|
--
|
||||||
2.35.3
|
Created with Armbian build tools https://github.com/armbian/build
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue