diff options
author | Eric Nelson <eric.nelson@boundarydevices.com> | 2013-10-01 11:56:35 -0700 |
---|---|---|
committer | Eric Nelson <eric.nelson@boundarydevices.com> | 2013-10-01 11:56:35 -0700 |
commit | ac24896a5c3311d5d30c06d19dbc40944c9e5b39 (patch) | |
tree | 108a27675fb9ee1347fadb869092e2b726a75652 /drivers | |
parent | 5cedf9606d0b11ceb9773ff1e31c882dd43fa4b2 (diff) |
ft5x06_ts: Add calibration parameter
Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/touchscreen/ft5x06_ts.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/ft5x06_ts.c b/drivers/input/touchscreen/ft5x06_ts.c index 89b57265f7e8..7885c1082e5a 100644 --- a/drivers/input/touchscreen/ft5x06_ts.c +++ b/drivers/input/touchscreen/ft5x06_ts.c @@ -36,6 +36,33 @@ #define USE_ABS_MT #endif +static int calibration[7]; +module_param_array(calibration, int, NULL, S_IRUGO | S_IWUSR); + +static void translate(int *px, int *py) +{ + int x, y, x1, y1; + if (calibration[6]) { + x1 = *px; + y1 = *py; + + x = calibration[0] * x1 + + calibration[1] * y1 + + calibration[2]; + x /= calibration[6]; + if (x < 0) + x = 0; + y = calibration[3] * x1 + + calibration[4] * y1 + + calibration[5]; + y /= calibration[6]; + if (y < 0) + y = 0; + *px = x ; + *py = y ; + } +} + struct point { int x; int y; @@ -107,6 +134,7 @@ static inline void ts_evt_add(struct ft5x06_ts *ts, #endif } else { for (i = 0; i < buttons; i++) { + translate(&p[i].x, &p[i].y); #ifdef USE_ABS_MT input_event(idev, EV_ABS, ABS_MT_POSITION_X, p[i].x); input_event(idev, EV_ABS, ABS_MT_POSITION_Y, p[i].y); |