Lines Matching defs:touch

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