Commit 6680884a44207efe8ef6bc56b1c932cce2b89994

Authored by Michael Hennerich
Committed by Dmitry Torokhov
1 parent f2bb26b9b7

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 <michael.hennerich@analog.com>
Reported-and-tested-by: Sebastian Zenker <sebastian.zenker@gmx.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Showing 2 changed files with 7 additions and 0 deletions Side-by-side Diff

drivers/input/touchscreen/ad7879.c
... ... @@ -118,6 +118,7 @@
118 118 unsigned int irq;
119 119 bool disabled; /* P: input->mutex */
120 120 bool suspended; /* P: input->mutex */
  121 + bool swap_xy;
121 122 u16 conversion_data[AD7879_NR_SENSE];
122 123 char phys[32];
123 124 u8 first_conversion_delay;
... ... @@ -161,6 +162,9 @@
161 162 z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT;
162 163 z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT;
163 164  
  165 + if (ts->swap_xy)
  166 + swap(x, y);
  167 +
164 168 /*
165 169 * The samples processed here are already preprocessed by the AD7879.
166 170 * The preprocessing function consists of a median and an averaging
... ... @@ -520,6 +524,7 @@
520 524 ts->dev = dev;
521 525 ts->input = input_dev;
522 526 ts->irq = irq;
  527 + ts->swap_xy = pdata->swap_xy;
523 528  
524 529 setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts);
525 530  
include/linux/spi/ad7879.h
... ... @@ -12,6 +12,8 @@
12 12 u16 y_min, y_max;
13 13 u16 pressure_min, pressure_max;
14 14  
  15 + bool swap_xy; /* swap x and y axes */
  16 +
15 17 /* [0..255] 0=OFF Starts at 1=550us and goes
16 18 * all the way to 9.440ms in steps of 35us.
17 19 */