-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update TSC2007 to common touch axis handling #5791
base: rpi-6.1.y
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | ||
%YAML 1.2 | ||
--- | ||
$id: http://devicetree.org/schemas/input/touchscreen/ti,tsc2007.yaml# | ||
$schema: http://devicetree.org/meta-schemas/core.yaml# | ||
|
||
title: Texas Instruments TSC2007 touchscreen controller bindings | ||
|
||
maintainers: | ||
- Timon Skerutsch <kernel@diodes-delight.com> | ||
|
||
allOf: | ||
- $ref: touchscreen.yaml# | ||
|
||
properties: | ||
compatible: | ||
enum: | ||
- ti,tsc2007 | ||
|
||
reg: | ||
maxItems: 1 | ||
description: | | ||
I2C address of the chip. | ||
|
||
interrupts: | ||
maxItems: 1 | ||
description: | | ||
(gpio) interrupt to which the chip is connected | ||
|
||
gpios: | ||
maxItems: 1 | ||
description: the interrupt gpio the chip is connected to (trough the penirq pin). | ||
|
||
ti,poll-period: how much time to wait (in milliseconds) before reading again | ||
|
||
touchscreen-fuzz-pressure: true | ||
touchscreen-fuzz-x: true | ||
touchscreen-fuzz-y: true | ||
touchscreen-min-pressure: true | ||
touchscreen-max-pressure: true | ||
touchscreen-min-x: true | ||
touchscreen-size-x: true | ||
touchscreen-min-y: true | ||
touchscreen-size-y: true | ||
touchscreen-x-plate-ohms: true | ||
touchscreen-inverted-x: true | ||
touchscreen-inverted-y: true | ||
touchscreen-swapped-x-y: true | ||
|
||
|
||
additionalProperties: false | ||
|
||
required: | ||
- compatible | ||
- reg | ||
- touchscreen-x-plate-ohms | ||
|
||
examples: | ||
- | | ||
tsc2007@48 { | ||
compatible = "ti,tsc2007"; | ||
reg = <0x48>; | ||
touchscreen-swapped-x-y; | ||
touchscreen-inverted-x; | ||
touchscreen-min-x = <350>; | ||
touchscreen-size-x = <3700>; | ||
touchscreen-fuzz-x = <4>; | ||
touchscreen-min-y = <320>; | ||
touchscreen-size-y = <3700>; | ||
touchscreen-fuzz-y = <4>; | ||
touchscreen-min-pressure = <1000>; | ||
touchscreen-max-pressure = <3700>; | ||
touchscreen-fuzz-pressure = <4>; | ||
touchscreen-x-plate-ohms = <180>; | ||
|
||
pinctrl-0 = <&tsc_int_pin>; | ||
interrupt-parent = <&gpio>; | ||
interrupts = <17 2>; | ||
gpios = <&gpio 17 1>; | ||
|
||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1 @@ | ||
* Texas Instruments tsc2007 touchscreen controller | ||
|
||
Required properties: | ||
- compatible: must be "ti,tsc2007". | ||
- reg: I2C address of the chip. | ||
- ti,x-plate-ohms: X-plate resistance in ohms. | ||
|
||
Optional properties: | ||
- gpios: the interrupt gpio the chip is connected to (trough the penirq pin). | ||
The penirq pin goes to low when the panel is touched. | ||
(see GPIO binding[1] for more details). | ||
- interrupts: (gpio) interrupt to which the chip is connected | ||
(see interrupt binding[0]). | ||
- ti,max-rt: maximum pressure. | ||
- ti,fuzzx: specifies the absolute input fuzz x value. | ||
If set, it will permit noise in the data up to +- the value given to the fuzz | ||
parameter, that is used to filter noise from the event stream. | ||
- ti,fuzzy: specifies the absolute input fuzz y value. | ||
- ti,fuzzz: specifies the absolute input fuzz z value. | ||
- ti,poll-period: how much time to wait (in milliseconds) before reading again the | ||
values from the tsc2007. | ||
|
||
[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt | ||
[1]: Documentation/devicetree/bindings/gpio/gpio.txt | ||
|
||
Example: | ||
&i2c1 { | ||
/* ... */ | ||
tsc2007@49 { | ||
compatible = "ti,tsc2007"; | ||
reg = <0x49>; | ||
interrupt-parent = <&gpio4>; | ||
interrupts = <0x0 0x8>; | ||
gpios = <&gpio4 0 0>; | ||
ti,x-plate-ohms = <180>; | ||
}; | ||
|
||
/* ... */ | ||
}; | ||
see ti,tsc2007.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
#include <linux/slab.h> | ||
#include <linux/gpio/consumer.h> | ||
#include <linux/input.h> | ||
#include <linux/input/touchscreen.h> | ||
#include <linux/interrupt.h> | ||
#include <linux/i2c.h> | ||
#include <linux/mod_devicetable.h> | ||
|
@@ -141,9 +142,8 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle) | |
|
||
rt = ts->max_rt - rt; | ||
|
||
touchscreen_report_pos(ts->input, &ts->prop, tc.x, tc.y, false); | ||
input_report_key(input, BTN_TOUCH, 1); | ||
input_report_abs(input, ABS_X, tc.x); | ||
input_report_abs(input, ABS_Y, tc.y); | ||
input_report_abs(input, ABS_PRESSURE, rt); | ||
|
||
input_sync(input); | ||
|
@@ -234,29 +234,20 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) | |
u32 val32; | ||
u64 val64; | ||
|
||
if (!device_property_read_u32(dev, "ti,max-rt", &val32)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dropping these causes a regression for any existing users. AIUI you need to parse these, and then overwrite with values from the common parsing if present. |
||
if (!device_property_read_u32(dev, "touchscreen-max-pressure", &val32)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Set the default to MAX_12BIT before calling |
||
ts->max_rt = val32; | ||
else | ||
ts->max_rt = MAX_12BIT; | ||
|
||
if (!device_property_read_u32(dev, "ti,fuzzx", &val32)) | ||
ts->fuzzx = val32; | ||
|
||
if (!device_property_read_u32(dev, "ti,fuzzy", &val32)) | ||
ts->fuzzy = val32; | ||
|
||
if (!device_property_read_u32(dev, "ti,fuzzz", &val32)) | ||
ts->fuzzz = val32; | ||
|
||
if (!device_property_read_u64(dev, "ti,poll-period", &val64)) | ||
ts->poll_period = msecs_to_jiffies(val64); | ||
else | ||
ts->poll_period = msecs_to_jiffies(1); | ||
|
||
if (!device_property_read_u32(dev, "ti,x-plate-ohms", &val32)) { | ||
if (!device_property_read_u32(dev, "touchscreen-x-plate-ohms", &val32)) { | ||
ts->x_plate_ohms = val32; | ||
} else { | ||
dev_err(dev, "Missing ti,x-plate-ohms device property\n"); | ||
dev_err(dev, "Missing touchscreen-x-plate-ohms device property\n"); | ||
return -EINVAL; | ||
} | ||
|
||
|
@@ -353,10 +344,13 @@ static int tsc2007_probe(struct i2c_client *client, | |
|
||
input_set_capability(input_dev, EV_KEY, BTN_TOUCH); | ||
|
||
/* Apply */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This and line 350 appear to only be irrelevant changes. |
||
input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0); | ||
input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0); | ||
input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, | ||
ts->fuzzz, 0); | ||
input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, ts->fuzzz, 0); | ||
|
||
/*Get all properties from devicetree and override defaults if present*/ | ||
touchscreen_parse_properties(input_dev, false, &ts->prop); | ||
|
||
if (pdata) { | ||
if (pdata->exit_platform_hw) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
#include <linux/i2c.h> | ||
#include <linux/iio/iio.h> | ||
#include <linux/input/touchscreen.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed? |
||
#include "tsc2007.h" | ||
|
||
struct tsc2007_iio { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've changed the order of this (which triggers ABS_X and ABS_Y events), wrt to BTN_TOUCH. Does that matter?
I suspect not as I believe
input_sync
is the trigger to do anything with all the events, but I couldn't say so definitively.