Skip to content

Commit 86579a4

Browse files
mrothNETdtor
authored andcommitted
Input: ads7846 - support swapping x and y axes
Signed-off-by: Michael Roth <mroth@nessie.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
1 parent 225c988 commit 86579a4

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎drivers/input/touchscreen/ads7846.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ struct ads7846 {
9797
u16 x_plate_ohms;
9898
u16 pressure_max;
9999

100+
bool swap_xy;
101+
100102
struct ads7846_packet *packet;
101103

102104
struct spi_transfer xfer[18];
@@ -599,6 +601,10 @@ static void ads7846_rx(void *ads)
599601
dev_dbg(&ts->spi->dev, "DOWN\n");
600602
#endif
601603
}
604+
605+
if (ts->swap_xy)
606+
swap(x, y);
607+
602608
input_report_abs(input, ABS_X, x);
603609
input_report_abs(input, ABS_Y, y);
604610
input_report_abs(input, ABS_PRESSURE, Rt);
@@ -917,6 +923,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
917923
ts->spi = spi;
918924
ts->input = input_dev;
919925
ts->vref_mv = pdata->vref_mv;
926+
ts->swap_xy = pdata->swap_xy;
920927

921928
hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
922929
ts->timer.function = ads7846_timer;

‎include/linux/spi/ads7846.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct ads7846_platform_data {
1717
u16 vref_mv; /* external vref value, milliVolts */
1818
bool keep_vref_on; /* set to keep vref on for differential
1919
* measurements as well */
20+
bool swap_xy; /* swap x and y axes */
2021

2122
/* Settling time of the analog signals; a function of Vcc and the
2223
* capacitance on the X/Y drivers. If set to non-zero, two samples

0 commit comments

Comments
 (0)