Lines Matching full:ts
128 static int zforce_command(struct zforce_ts *ts, u8 cmd) in zforce_command() argument
130 struct i2c_client *client = ts->client; in zforce_command()
149 static int zforce_send_wait(struct zforce_ts *ts, const char *buf, int len) in zforce_send_wait() argument
151 struct i2c_client *client = ts->client; in zforce_send_wait()
157 ts->command_waiting = buf[2]; in zforce_send_wait()
167 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) in zforce_send_wait()
170 ret = ts->command_result; in zforce_send_wait()
174 static int zforce_command_wait(struct zforce_ts *ts, u8 cmd) in zforce_command_wait() argument
176 struct i2c_client *client = ts->client; in zforce_command_wait()
186 error = zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_command_wait()
196 static int zforce_resolution(struct zforce_ts *ts, u16 x, u16 y) in zforce_resolution() argument
198 struct i2c_client *client = ts->client; in zforce_resolution()
205 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_resolution()
208 static int zforce_scan_frequency(struct zforce_ts *ts, u16 idle, u16 finger, in zforce_scan_frequency() argument
211 struct i2c_client *client = ts->client; in zforce_scan_frequency()
221 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_scan_frequency()
224 static int zforce_setconfig(struct zforce_ts *ts, char b1) in zforce_setconfig() argument
226 struct i2c_client *client = ts->client; in zforce_setconfig()
232 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_setconfig()
235 static int zforce_start(struct zforce_ts *ts) in zforce_start() argument
237 struct i2c_client *client = ts->client; in zforce_start()
242 error = zforce_command_wait(ts, COMMAND_INITIALIZE); in zforce_start()
248 error = zforce_resolution(ts, ts->prop.max_x, ts->prop.max_y); in zforce_start()
254 error = zforce_scan_frequency(ts, 10, 50, 50); in zforce_start()
261 error = zforce_setconfig(ts, SETCONFIG_DUALTOUCH); in zforce_start()
268 error = zforce_command(ts, COMMAND_DATAREQUEST); in zforce_start()
283 zforce_command_wait(ts, COMMAND_DEACTIVATE); in zforce_start()
287 static int zforce_stop(struct zforce_ts *ts) in zforce_stop() argument
289 struct i2c_client *client = ts->client; in zforce_stop()
295 error = zforce_command_wait(ts, COMMAND_DEACTIVATE); in zforce_stop()
305 static int zforce_touch_event(struct zforce_ts *ts, u8 *payload) in zforce_touch_event() argument
307 struct i2c_client *client = ts->client; in zforce_touch_event()
326 if (point.coord_x > ts->prop.max_x || in zforce_touch_event()
327 point.coord_y > ts->prop.max_y) { in zforce_touch_event()
353 input_mt_slot(ts->input, point.id - 1); in zforce_touch_event()
355 if (input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, in zforce_touch_event()
357 touchscreen_report_pos(ts->input, &ts->prop, in zforce_touch_event()
360 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, in zforce_touch_event()
362 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, in zforce_touch_event()
364 input_report_abs(ts->input, ABS_MT_ORIENTATION, in zforce_touch_event()
370 input_mt_sync_frame(ts->input); in zforce_touch_event()
372 input_mt_report_finger_count(ts->input, num); in zforce_touch_event()
374 input_sync(ts->input); in zforce_touch_event()
379 static int zforce_read_packet(struct zforce_ts *ts, u8 *buf) in zforce_read_packet() argument
381 struct i2c_client *client = ts->client; in zforce_read_packet()
415 static void zforce_complete(struct zforce_ts *ts, int cmd, int result) in zforce_complete() argument
417 struct i2c_client *client = ts->client; in zforce_complete()
419 if (ts->command_waiting == cmd) { in zforce_complete()
421 ts->command_result = result; in zforce_complete()
422 complete(&ts->command_done); in zforce_complete()
430 struct zforce_ts *ts = dev_id; in zforce_irq() local
431 struct i2c_client *client = ts->client; in zforce_irq()
433 if (ts->suspended && device_may_wakeup(&client->dev)) in zforce_irq()
441 struct zforce_ts *ts = dev_id; in zforce_irq_thread() local
442 struct i2c_client *client = ts->client; in zforce_irq_thread()
452 if (ts->suspended) { in zforce_irq_thread()
460 suspending = READ_ONCE(ts->suspending); in zforce_irq_thread()
474 error = zforce_read_packet(ts, payload_buffer); in zforce_irq_thread()
491 zforce_touch_event(ts, &payload[RESPONSE_DATA]); in zforce_irq_thread()
495 ts->boot_complete = payload[RESPONSE_DATA]; in zforce_irq_thread()
496 zforce_complete(ts, payload[RESPONSE_ID], 0); in zforce_irq_thread()
504 zforce_complete(ts, payload[RESPONSE_ID], in zforce_irq_thread()
513 ts->version_major = in zforce_irq_thread()
515 ts->version_minor = in zforce_irq_thread()
517 ts->version_build = in zforce_irq_thread()
519 ts->version_rev = in zforce_irq_thread()
522 dev_dbg(&ts->client->dev, in zforce_irq_thread()
524 ts->version_major, ts->version_minor, in zforce_irq_thread()
525 ts->version_build, ts->version_rev); in zforce_irq_thread()
527 zforce_complete(ts, payload[RESPONSE_ID], 0); in zforce_irq_thread()
531 dev_err(&ts->client->dev, "invalid command: 0x%x\n", in zforce_irq_thread()
536 dev_err(&ts->client->dev, in zforce_irq_thread()
541 } while (gpiod_get_value_cansleep(ts->gpio_int)); in zforce_irq_thread()
553 struct zforce_ts *ts = input_get_drvdata(dev); in zforce_input_open() local
555 return zforce_start(ts); in zforce_input_open()
560 struct zforce_ts *ts = input_get_drvdata(dev); in zforce_input_close() local
561 struct i2c_client *client = ts->client; in zforce_input_close()
564 error = zforce_stop(ts); in zforce_input_close()
569 static int __zforce_suspend(struct zforce_ts *ts) in __zforce_suspend() argument
571 struct i2c_client *client = ts->client; in __zforce_suspend()
572 struct input_dev *input = ts->input; in __zforce_suspend()
586 error = zforce_start(ts); in __zforce_suspend()
596 error = zforce_stop(ts); in __zforce_suspend()
603 ts->suspended = true; in __zforce_suspend()
610 struct zforce_ts *ts = i2c_get_clientdata(client); in zforce_suspend() local
613 WRITE_ONCE(ts->suspending, true); in zforce_suspend()
616 ret = __zforce_suspend(ts); in zforce_suspend()
619 WRITE_ONCE(ts->suspending, false); in zforce_suspend()
627 struct zforce_ts *ts = i2c_get_clientdata(client); in zforce_resume() local
628 struct input_dev *input = ts->input; in zforce_resume()
633 ts->suspended = false; in zforce_resume()
642 error = zforce_stop(ts); in zforce_resume()
651 error = zforce_start(ts); in zforce_resume()
663 struct zforce_ts *ts = data; in zforce_reset() local
665 gpiod_set_value_cansleep(ts->gpio_rst, 1); in zforce_reset()
669 static void zforce_ts_parse_legacy_properties(struct zforce_ts *ts) in zforce_ts_parse_legacy_properties() argument
674 device_property_read_u32(&ts->client->dev, "x-size", &x_max); in zforce_ts_parse_legacy_properties()
675 input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, x_max, 0, 0); in zforce_ts_parse_legacy_properties()
677 device_property_read_u32(&ts->client->dev, "y-size", &y_max); in zforce_ts_parse_legacy_properties()
678 input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, y_max, 0, 0); in zforce_ts_parse_legacy_properties()
683 struct zforce_ts *ts; in zforce_probe() local
687 ts = devm_kzalloc(&client->dev, sizeof(struct zforce_ts), GFP_KERNEL); in zforce_probe()
688 if (!ts) in zforce_probe()
691 ts->gpio_rst = devm_gpiod_get_optional(&client->dev, "reset", in zforce_probe()
693 error = PTR_ERR_OR_ZERO(ts->gpio_rst); in zforce_probe()
698 if (ts->gpio_rst) { in zforce_probe()
699 ts->gpio_int = devm_gpiod_get_optional(&client->dev, "irq", in zforce_probe()
701 error = PTR_ERR_OR_ZERO(ts->gpio_int); in zforce_probe()
712 ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, in zforce_probe()
715 error = PTR_ERR_OR_ZERO(ts->gpio_int); in zforce_probe()
721 ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1, in zforce_probe()
723 error = PTR_ERR_OR_ZERO(ts->gpio_rst); in zforce_probe()
740 error = devm_add_action_or_reset(&client->dev, zforce_reset, ts); in zforce_probe()
745 snprintf(ts->phys, sizeof(ts->phys), in zforce_probe()
753 ts->client = client; in zforce_probe()
754 ts->input = input_dev; in zforce_probe()
757 input_dev->phys = ts->phys; in zforce_probe()
763 zforce_ts_parse_legacy_properties(ts); in zforce_probe()
764 touchscreen_parse_properties(input_dev, true, &ts->prop); in zforce_probe()
765 if (ts->prop.max_x == 0 || ts->prop.max_y == 0) in zforce_probe()
779 input_set_drvdata(ts->input, ts); in zforce_probe()
781 init_completion(&ts->command_done); in zforce_probe()
792 IRQF_ONESHOT, input_dev->name, ts); in zforce_probe()
797 i2c_set_clientdata(client, ts); in zforce_probe()
800 gpiod_set_value_cansleep(ts->gpio_rst, 0); in zforce_probe()
802 ts->command_waiting = NOTIFICATION_BOOTCOMPLETE; in zforce_probe()
803 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) in zforce_probe()
807 error = zforce_command_wait(ts, COMMAND_INITIALIZE); in zforce_probe()
812 error = zforce_command_wait(ts, COMMAND_STATUS); in zforce_probe()
815 zforce_stop(ts); in zforce_probe()
820 error = zforce_stop(ts); in zforce_probe()
835 { "zforce-ts" },
850 .name = "zforce-ts",