Commit 6680884a authored by Michael Hennerich's avatar Michael Hennerich Committed by Dmitry Torokhov

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: default avatarMichael Hennerich <michael.hennerich@analog.com>
Reported-and-tested-by: default avatarSebastian Zenker <sebastian.zenker@gmx.de>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent f2bb26b9
...@@ -118,6 +118,7 @@ struct ad7879 { ...@@ -118,6 +118,7 @@ struct ad7879 {
unsigned int irq; unsigned int irq;
bool disabled; /* P: input->mutex */ bool disabled; /* P: input->mutex */
bool suspended; /* P: input->mutex */ bool suspended; /* P: input->mutex */
bool swap_xy;
u16 conversion_data[AD7879_NR_SENSE]; u16 conversion_data[AD7879_NR_SENSE];
char phys[32]; char phys[32];
u8 first_conversion_delay; u8 first_conversion_delay;
...@@ -161,6 +162,9 @@ static int ad7879_report(struct ad7879 *ts) ...@@ -161,6 +162,9 @@ static int ad7879_report(struct ad7879 *ts)
z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT; z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT;
z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT; z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT;
if (ts->swap_xy)
swap(x, y);
/* /*
* The samples processed here are already preprocessed by the AD7879. * The samples processed here are already preprocessed by the AD7879.
* The preprocessing function consists of a median and an averaging * 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, ...@@ -520,6 +524,7 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
ts->dev = dev; ts->dev = dev;
ts->input = input_dev; ts->input = input_dev;
ts->irq = irq; ts->irq = irq;
ts->swap_xy = pdata->swap_xy;
setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts); setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts);
......
...@@ -12,6 +12,8 @@ struct ad7879_platform_data { ...@@ -12,6 +12,8 @@ struct ad7879_platform_data {
u16 y_min, y_max; u16 y_min, y_max;
u16 pressure_min, pressure_max; u16 pressure_min, pressure_max;
bool swap_xy; /* swap x and y axes */
/* [0..255] 0=OFF Starts at 1=550us and goes /* [0..255] 0=OFF Starts at 1=550us and goes
* all the way to 9.440ms in steps of 35us. * all the way to 9.440ms in steps of 35us.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment