Lines Matching full:touch

66 static inline int is_pen_down(struct da9034_touch *touch)  in is_pen_down()  argument
68 return da903x_query_status(touch->da9034_dev, DA9034_STATUS_PEN_DOWN); in is_pen_down()
71 static inline int detect_pen_down(struct da9034_touch *touch, int on) in detect_pen_down() argument
74 return da903x_set_bits(touch->da9034_dev, in detect_pen_down()
77 return da903x_clr_bits(touch->da9034_dev, in detect_pen_down()
81 static int read_tsi(struct da9034_touch *touch) in read_tsi() argument
86 ret = da903x_read(touch->da9034_dev, DA9034_TSI_X_MSB, &_x); in read_tsi()
90 ret = da903x_read(touch->da9034_dev, DA9034_TSI_Y_MSB, &_y); in read_tsi()
94 ret = da903x_read(touch->da9034_dev, DA9034_TSI_XY_LSB, &_v); in read_tsi()
98 touch->last_x = ((_x << 2) & 0x3fc) | (_v & 0x3); in read_tsi()
99 touch->last_y = ((_y << 2) & 0x3fc) | ((_v & 0xc) >> 2); in read_tsi()
104 static inline int start_tsi(struct da9034_touch *touch) in start_tsi() argument
106 return da903x_set_bits(touch->da9034_dev, in start_tsi()
110 static inline int stop_tsi(struct da9034_touch *touch) in stop_tsi() argument
112 return da903x_clr_bits(touch->da9034_dev, in stop_tsi()
116 static inline void report_pen_down(struct da9034_touch *touch) in report_pen_down() argument
118 int x = touch->last_x; in report_pen_down()
119 int y = touch->last_y; in report_pen_down()
122 if (touch->x_inverted) in report_pen_down()
125 if (touch->y_inverted) in report_pen_down()
128 input_report_abs(touch->input_dev, ABS_X, x); in report_pen_down()
129 input_report_abs(touch->input_dev, ABS_Y, y); in report_pen_down()
130 input_report_key(touch->input_dev, BTN_TOUCH, 1); in report_pen_down()
132 input_sync(touch->input_dev); in report_pen_down()
135 static inline void report_pen_up(struct da9034_touch *touch) in report_pen_up() argument
137 input_report_key(touch->input_dev, BTN_TOUCH, 0); in report_pen_up()
138 input_sync(touch->input_dev); in report_pen_up()
141 static void da9034_event_handler(struct da9034_touch *touch, int event) in da9034_event_handler() argument
145 switch (touch->state) { in da9034_event_handler()
153 err = start_tsi(touch); in da9034_event_handler()
157 touch->state = STATE_BUSY; in da9034_event_handler()
164 err = read_tsi(touch); in da9034_event_handler()
171 err = stop_tsi(touch); in da9034_event_handler()
175 touch->state = STATE_STOP; in da9034_event_handler()
183 da9034_event_handler(touch, in da9034_event_handler()
184 is_pen_down(touch) ? EVENT_PEN_DOWN : in da9034_event_handler()
190 report_pen_down(touch); in da9034_event_handler()
191 schedule_delayed_work(&touch->tsi_work, in da9034_event_handler()
192 msecs_to_jiffies(touch->interval_ms)); in da9034_event_handler()
193 touch->state = STATE_WAIT; in da9034_event_handler()
197 report_pen_up(touch); in da9034_event_handler()
198 touch->state = STATE_IDLE; in da9034_event_handler()
206 if (is_pen_down(touch)) { in da9034_event_handler()
207 start_tsi(touch); in da9034_event_handler()
208 touch->state = STATE_BUSY; in da9034_event_handler()
210 report_pen_up(touch); in da9034_event_handler()
211 touch->state = STATE_IDLE; in da9034_event_handler()
218 touch->state = STATE_IDLE; in da9034_event_handler()
219 stop_tsi(touch); in da9034_event_handler()
220 detect_pen_down(touch, 1); in da9034_event_handler()
225 struct da9034_touch *touch = in da9034_tsi_work() local
228 da9034_event_handler(touch, EVENT_TIMEDOUT); in da9034_tsi_work()
234 struct da9034_touch *touch = in da9034_touch_notifier() local
238 da9034_event_handler(touch, EVENT_TSI_READY); in da9034_touch_notifier()
240 if ((event & DA9034_EVENT_PEN_DOWN) && touch->state == STATE_IDLE) in da9034_touch_notifier()
241 da9034_event_handler(touch, EVENT_PEN_DOWN); in da9034_touch_notifier()
248 struct da9034_touch *touch = input_get_drvdata(dev); in da9034_touch_open() local
251 ret = da903x_register_notifier(touch->da9034_dev, &touch->notifier, in da9034_touch_open()
257 ret = da903x_set_bits(touch->da9034_dev, in da9034_touch_open()
263 ret = da903x_write(touch->da9034_dev, DA9034_TSI_CTRL1, 0x1b); in da9034_touch_open()
267 ret = da903x_write(touch->da9034_dev, DA9034_TSI_CTRL2, 0x00); in da9034_touch_open()
271 touch->state = STATE_IDLE; in da9034_touch_open()
272 detect_pen_down(touch, 1); in da9034_touch_open()
279 struct da9034_touch *touch = input_get_drvdata(dev); in da9034_touch_close() local
281 da903x_unregister_notifier(touch->da9034_dev, &touch->notifier, in da9034_touch_close()
284 cancel_delayed_work_sync(&touch->tsi_work); in da9034_touch_close()
286 touch->state = STATE_IDLE; in da9034_touch_close()
287 stop_tsi(touch); in da9034_touch_close()
288 detect_pen_down(touch, 0); in da9034_touch_close()
291 da903x_clr_bits(touch->da9034_dev, in da9034_touch_close()
299 struct da9034_touch *touch; in da9034_touch_probe() local
303 touch = devm_kzalloc(&pdev->dev, sizeof(struct da9034_touch), in da9034_touch_probe()
305 if (!touch) { in da9034_touch_probe()
310 touch->da9034_dev = pdev->dev.parent; in da9034_touch_probe()
313 touch->interval_ms = pdata->interval_ms; in da9034_touch_probe()
314 touch->x_inverted = pdata->x_inverted; in da9034_touch_probe()
315 touch->y_inverted = pdata->y_inverted; in da9034_touch_probe()
318 touch->interval_ms = 10; in da9034_touch_probe()
321 INIT_DELAYED_WORK(&touch->tsi_work, da9034_tsi_work); in da9034_touch_probe()
322 touch->notifier.notifier_call = da9034_touch_notifier; in da9034_touch_probe()
344 touch->input_dev = input_dev; in da9034_touch_probe()
345 input_set_drvdata(input_dev, touch); in da9034_touch_probe()
356 .name = "da9034-touch",
365 MODULE_ALIAS("platform:da9034-touch");