aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/tsc2007.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/touchscreen/tsc2007.c')
-rw-r--r--drivers/input/touchscreen/tsc2007.c44
1 files changed, 40 insertions, 4 deletions
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();