Commit 963ce8ae authored by Michael Hennerich's avatar Michael Hennerich Committed by Dmitry Torokhov

Input: ad7879 - report EV_KEY/BTN_TOUCH events

Some input events users such as Android require BTN_TOUCH events.
Implement EV_KEY/BTN_TOUCH and make sure that the release event
is not erroneous scheduled without a preceding valid touch.
Avoid duplicated BTN_TOUCH events, even though input core filters
them.
Signed-off-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 447b9065
...@@ -146,7 +146,7 @@ static int ad7879_write(struct ad7879 *ts, u8 reg, u16 val) ...@@ -146,7 +146,7 @@ static int ad7879_write(struct ad7879 *ts, u8 reg, u16 val)
return ts->bops->write(ts->dev, reg, val); return ts->bops->write(ts->dev, reg, val);
} }
static void ad7879_report(struct ad7879 *ts) static int ad7879_report(struct ad7879 *ts)
{ {
struct input_dev *input_dev = ts->input; struct input_dev *input_dev = ts->input;
unsigned Rt; unsigned Rt;
...@@ -175,11 +175,17 @@ static void ad7879_report(struct ad7879 *ts) ...@@ -175,11 +175,17 @@ static void ad7879_report(struct ad7879 *ts)
Rt /= z1; Rt /= z1;
Rt = (Rt + 2047) >> 12; Rt = (Rt + 2047) >> 12;
if (!timer_pending(&ts->timer))
input_report_key(input_dev, BTN_TOUCH, 1);
input_report_abs(input_dev, ABS_X, x); input_report_abs(input_dev, ABS_X, x);
input_report_abs(input_dev, ABS_Y, y); input_report_abs(input_dev, ABS_Y, y);
input_report_abs(input_dev, ABS_PRESSURE, Rt); input_report_abs(input_dev, ABS_PRESSURE, Rt);
input_sync(input_dev); input_sync(input_dev);
return 0;
} }
return -EINVAL;
} }
static void ad7879_ts_event_release(struct ad7879 *ts) static void ad7879_ts_event_release(struct ad7879 *ts)
...@@ -187,6 +193,7 @@ static void ad7879_ts_event_release(struct ad7879 *ts) ...@@ -187,6 +193,7 @@ static void ad7879_ts_event_release(struct ad7879 *ts)
struct input_dev *input_dev = ts->input; struct input_dev *input_dev = ts->input;
input_report_abs(input_dev, ABS_PRESSURE, 0); input_report_abs(input_dev, ABS_PRESSURE, 0);
input_report_key(input_dev, BTN_TOUCH, 0);
input_sync(input_dev); input_sync(input_dev);
} }
...@@ -202,9 +209,9 @@ static irqreturn_t ad7879_irq(int irq, void *handle) ...@@ -202,9 +209,9 @@ static irqreturn_t ad7879_irq(int irq, void *handle)
struct ad7879 *ts = handle; struct ad7879 *ts = handle;
ad7879_multi_read(ts, AD7879_REG_XPLUS, AD7879_NR_SENSE, ts->conversion_data); ad7879_multi_read(ts, AD7879_REG_XPLUS, AD7879_NR_SENSE, ts->conversion_data);
ad7879_report(ts);
mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); if (!ad7879_report(ts))
mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -506,6 +513,9 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq, ...@@ -506,6 +513,9 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
__set_bit(ABS_Y, input_dev->absbit); __set_bit(ABS_Y, input_dev->absbit);
__set_bit(ABS_PRESSURE, input_dev->absbit); __set_bit(ABS_PRESSURE, input_dev->absbit);
__set_bit(EV_KEY, input_dev->evbit);
__set_bit(BTN_TOUCH, input_dev->keybit);
input_set_abs_params(input_dev, ABS_X, input_set_abs_params(input_dev, ABS_X,
pdata->x_min ? : 0, pdata->x_min ? : 0,
pdata->x_max ? : MAX_12BIT, pdata->x_max ? : MAX_12BIT,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment