diff options
author | PaulK <contact@paulk.fr> | 2012-04-16 15:47:45 +0200 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@no-log.org> | 2013-07-21 00:12:09 +0200 |
commit | a520262aa6f3d986e51dcb8998eb10abf79fc1a4 (patch) | |
tree | e38afe41b28847008679904c8352ef2b9e597ca1 | |
parent | 6878b24904887cb9b1677b4a8bf985dc633ac451 (diff) | |
download | kernel_goldelico_gta04-a520262aa6f3d986e51dcb8998eb10abf79fc1a4.zip kernel_goldelico_gta04-a520262aa6f3d986e51dcb8998eb10abf79fc1a4.tar.gz kernel_goldelico_gta04-a520262aa6f3d986e51dcb8998eb10abf79fc1a4.tar.bz2 |
Added calibrated values for GTA04 tsc2007 touchscreen
Signed-off-by: PaulK <contact@paulk.fr>
-rw-r--r-- | arch/arm/mach-omap2/board-omap3gta04.c | 8 | ||||
-rw-r--r-- | drivers/input/touchscreen/tsc2007.c | 44 | ||||
-rw-r--r-- | include/linux/i2c/tsc2007.h | 12 |
3 files changed, 57 insertions, 7 deletions
diff --git a/arch/arm/mach-omap2/board-omap3gta04.c b/arch/arm/mach-omap2/board-omap3gta04.c index 1b7ac22..36207b9 100644 --- a/arch/arm/mach-omap2/board-omap3gta04.c +++ b/arch/arm/mach-omap2/board-omap3gta04.c @@ -79,6 +79,8 @@ #define GPMC_CS0_BASE 0x60 #define GPMC_CS_SIZE 0x30 +#define MAX_12BIT ((1 << 12) - 1) + #define NAND_BLOCK_SIZE SZ_128K #define AUX_BUTTON_GPIO 7 @@ -940,6 +942,12 @@ static void tsc2007_exit(void) struct tsc2007_platform_data __initdata tsc2007_info = { .model = 2007, .x_plate_ohms = 600, // range: 250 .. 900 + .min_x = 0x100, + .min_y = 0xc0, + .min_z = 0, + .max_x = 0xf00, + .max_y = 0xf00, + .max_z = MAX_12BIT, .get_pendown_state = ts_get_pendown_state, .init_platform_hw = tsc2007_init, .exit_platform_hw = tsc2007_exit, diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c index 08faaff..0ff8463 100644 --- a/drivers/input/touchscreen/tsc2007.c +++ b/drivers/input/touchscreen/tsc2007.c @@ -71,6 +71,12 @@ struct tsc2007 { u16 model; u16 x_plate_ohms; + int min_x; + int min_y; + int min_z; + int max_x; + int max_y; + int max_z; u16 max_rt; unsigned long poll_delay; unsigned long poll_period; @@ -168,6 +174,29 @@ static bool tsc2007_is_pen_down(struct tsc2007 *ts) return ts->get_pendown_state(); } +static void tsc2007_range_values(struct tsc2007 *ts, struct ts_event *tc, u32 *rt) +{ + /* Get the read values in the correct calibrated range. */ + + /* X */ + if(tc->x > ts->max_x) + tc->x = ts->max_x; + else if(tc->x < ts->min_x) + tc->x = ts->min_x; + + /* Y */ + if(tc->y > ts->max_y) + tc->y = ts->max_y; + else if(tc->y < ts->min_y) + tc->y = ts->min_y; + + /* Z */ + if(*rt > ts->max_z) + *rt = ts->max_z; + else if(*rt < ts->min_z) + *rt = ts->min_z; +} + static irqreturn_t tsc2007_soft_irq(int irq, void *handle) { struct tsc2007 *ts = handle; @@ -192,6 +221,8 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle) } if (rt <= ts->max_rt) { + tsc2007_range_values(ts, &tc, &rt); + dev_dbg(&ts->client->dev, "DOWN point(%4d,%4d), pressure (%4u)\n", tc.x, tc.y, rt); @@ -308,6 +339,12 @@ static int tsc2007_probe(struct i2c_client *client, ts->model = pdata->model; ts->x_plate_ohms = pdata->x_plate_ohms; + ts->min_x = pdata->min_x ? : 0; + ts->min_y = pdata->min_y ? : 0; + ts->min_z = pdata->min_z ? : 0; + ts->max_x = pdata->max_x ? : MAX_12BIT; + ts->max_y = pdata->max_y ? : MAX_12BIT; + ts->max_z = pdata->max_z ? : MAX_12BIT; ts->max_rt = pdata->max_rt ? : MAX_12BIT; ts->poll_delay = pdata->poll_delay ? : 1; ts->poll_period = pdata->poll_period ? : 1; @@ -335,10 +372,9 @@ static int tsc2007_probe(struct i2c_client *client, input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); - input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, pdata->fuzzx, 0); - input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, pdata->fuzzy, 0); - input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, - pdata->fuzzz, 0); + input_set_abs_params(input_dev, ABS_X, pdata->min_x, pdata->max_x, pdata->fuzz_x, 0); + input_set_abs_params(input_dev, ABS_Y, pdata->min_y, pdata->max_y, pdata->fuzz_y, 0); + input_set_abs_params(input_dev, ABS_PRESSURE, pdata->min_z, pdata->max_z, pdata->fuzz_z, 0); if (pdata->init_platform_hw) pdata->init_platform_hw(); diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h index 506a9f7..4831e25 100644 --- a/include/linux/i2c/tsc2007.h +++ b/include/linux/i2c/tsc2007.h @@ -10,9 +10,15 @@ struct tsc2007_platform_data { unsigned long poll_delay; /* delay (in ms) after pen-down event before polling starts */ unsigned long poll_period; /* time (in ms) between samples */ - int fuzzx; /* fuzz factor for X, Y and pressure axes */ - int fuzzy; - int fuzzz; + int min_x; + int min_y; + int min_z; + int max_x; + int max_y; + int max_z; + int fuzz_x; /* fuzz factor for X, Y and pressure axes */ + int fuzz_y; + int fuzz_z; int (*get_pendown_state)(void); void (*clear_penirq)(void); /* If needed, clear 2nd level |