Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

authored by

Michael Hennerich and committed by
Dmitry Torokhov
963ce8ae 447b9065

+13 -3
+13 -3
drivers/input/touchscreen/ad7879.c
··· 146 146 return ts->bops->write(ts->dev, reg, val); 147 147 } 148 148 149 - static void ad7879_report(struct ad7879 *ts) 149 + static int ad7879_report(struct ad7879 *ts) 150 150 { 151 151 struct input_dev *input_dev = ts->input; 152 152 unsigned Rt; ··· 175 175 Rt /= z1; 176 176 Rt = (Rt + 2047) >> 12; 177 177 178 + if (!timer_pending(&ts->timer)) 179 + input_report_key(input_dev, BTN_TOUCH, 1); 180 + 178 181 input_report_abs(input_dev, ABS_X, x); 179 182 input_report_abs(input_dev, ABS_Y, y); 180 183 input_report_abs(input_dev, ABS_PRESSURE, Rt); 181 184 input_sync(input_dev); 185 + return 0; 182 186 } 187 + 188 + return -EINVAL; 183 189 } 184 190 185 191 static void ad7879_ts_event_release(struct ad7879 *ts) ··· 193 187 struct input_dev *input_dev = ts->input; 194 188 195 189 input_report_abs(input_dev, ABS_PRESSURE, 0); 190 + input_report_key(input_dev, BTN_TOUCH, 0); 196 191 input_sync(input_dev); 197 192 } 198 193 ··· 209 202 struct ad7879 *ts = handle; 210 203 211 204 ad7879_multi_read(ts, AD7879_REG_XPLUS, AD7879_NR_SENSE, ts->conversion_data); 212 - ad7879_report(ts); 213 205 214 - mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); 206 + if (!ad7879_report(ts)) 207 + mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); 215 208 216 209 return IRQ_HANDLED; 217 210 } ··· 512 505 __set_bit(ABS_X, input_dev->absbit); 513 506 __set_bit(ABS_Y, input_dev->absbit); 514 507 __set_bit(ABS_PRESSURE, input_dev->absbit); 508 + 509 + __set_bit(EV_KEY, input_dev->evbit); 510 + __set_bit(BTN_TOUCH, input_dev->keybit); 515 511 516 512 input_set_abs_params(input_dev, ABS_X, 517 513 pdata->x_min ? : 0,