diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2012-11-27 18:09:38 +0100 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2013-05-04 23:11:46 +0200 |
commit | 1513e8440e20e2aedd11993125c38d70da7877a0 (patch) | |
tree | 25a293c36ce041093c83599d21d4a270a8c0672e | |
parent | 66d57b8d83362f4ad23fe3431e22538dad85b29e (diff) | |
download | kernel_goldelico_gta04-1513e8440e20e2aedd11993125c38d70da7877a0.zip kernel_goldelico_gta04-1513e8440e20e2aedd11993125c38d70da7877a0.tar.gz kernel_goldelico_gta04-1513e8440e20e2aedd11993125c38d70da7877a0.tar.bz2 |
TSC2007: Permit platform-specific calibration values
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r-- | drivers/input/touchscreen/tsc2007.c | 44 | ||||
-rw-r--r-- | include/linux/i2c/tsc2007.h | 12 |
2 files changed, 49 insertions, 7 deletions
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c index db92c0a..ca9b6f3 100644 --- a/drivers/input/touchscreen/tsc2007.c +++ b/drivers/input/touchscreen/tsc2007.c @@ -72,6 +72,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; @@ -152,6 +158,29 @@ static void tsc2007_send_up_event(struct tsc2007 *tsc) input_sync(input); } +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 void tsc2007_work(struct work_struct *work) { struct tsc2007 *ts = @@ -207,6 +236,8 @@ static void tsc2007_work(struct work_struct *work) ts->pendown = true; } + tsc2007_range_values(ts, &tc, &rt); + input_report_abs(input, ABS_X, tc.x); input_report_abs(input, ABS_Y, tc.y); input_report_abs(input, ABS_PRESSURE, rt); @@ -294,6 +325,12 @@ static int __devinit 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; @@ -310,10 +347,9 @@ static int __devinit 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 591427a..dd86070 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 |