Skip to content

Commit 6680884

Browse files
mhennerichdtor
authored andcommitted
Input: ad7879 - add option to correct xy axis
Sebastian Zenker reported that driver swaps x and y samples when the touchscreen leads are connected in accordance with the datasheet specification. Transposed axis can be typically corrected by touch screen calibration however this bug also negatively influences touch pressure measurements. Add an option to correct x and y axis. Signed-off-by: Michael Hennerich <[email protected]> Reported-and-tested-by: Sebastian Zenker <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent f2bb26b commit 6680884

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

drivers/input/touchscreen/ad7879.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct ad7879 {
118118
unsigned int irq;
119119
bool disabled; /* P: input->mutex */
120120
bool suspended; /* P: input->mutex */
121+
bool swap_xy;
121122
u16 conversion_data[AD7879_NR_SENSE];
122123
char phys[32];
123124
u8 first_conversion_delay;
@@ -161,6 +162,9 @@ static int ad7879_report(struct ad7879 *ts)
161162
z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT;
162163
z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT;
163164

165+
if (ts->swap_xy)
166+
swap(x, y);
167+
164168
/*
165169
* The samples processed here are already preprocessed by the AD7879.
166170
* The preprocessing function consists of a median and an averaging
@@ -520,6 +524,7 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
520524
ts->dev = dev;
521525
ts->input = input_dev;
522526
ts->irq = irq;
527+
ts->swap_xy = pdata->swap_xy;
523528

524529
setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts);
525530

include/linux/spi/ad7879.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ struct ad7879_platform_data {
1212
u16 y_min, y_max;
1313
u16 pressure_min, pressure_max;
1414

15+
bool swap_xy; /* swap x and y axes */
16+
1517
/* [0..255] 0=OFF Starts at 1=550us and goes
1618
* all the way to 9.440ms in steps of 35us.
1719
*/

0 commit comments

Comments
 (0)