Lines Matching refs:ts

142 static int zforce_command(struct zforce_ts *ts, u8 cmd)  in zforce_command()  argument
144 struct i2c_client *client = ts->client; in zforce_command()
154 mutex_lock(&ts->access_mutex); in zforce_command()
156 mutex_unlock(&ts->access_mutex); in zforce_command()
165 static int zforce_send_wait(struct zforce_ts *ts, const char *buf, int len) in zforce_send_wait() argument
167 struct i2c_client *client = ts->client; in zforce_send_wait()
170 ret = mutex_trylock(&ts->command_mutex); in zforce_send_wait()
179 ts->command_waiting = buf[2]; in zforce_send_wait()
181 mutex_lock(&ts->access_mutex); in zforce_send_wait()
183 mutex_unlock(&ts->access_mutex); in zforce_send_wait()
191 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) { in zforce_send_wait()
196 ret = ts->command_result; in zforce_send_wait()
199 mutex_unlock(&ts->command_mutex); in zforce_send_wait()
203 static int zforce_command_wait(struct zforce_ts *ts, u8 cmd) in zforce_command_wait() argument
205 struct i2c_client *client = ts->client; in zforce_command_wait()
215 ret = zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_command_wait()
224 static int zforce_resolution(struct zforce_ts *ts, u16 x, u16 y) in zforce_resolution() argument
226 struct i2c_client *client = ts->client; in zforce_resolution()
233 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_resolution()
236 static int zforce_scan_frequency(struct zforce_ts *ts, u16 idle, u16 finger, in zforce_scan_frequency() argument
239 struct i2c_client *client = ts->client; in zforce_scan_frequency()
249 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_scan_frequency()
252 static int zforce_setconfig(struct zforce_ts *ts, char b1) in zforce_setconfig() argument
254 struct i2c_client *client = ts->client; in zforce_setconfig()
260 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_setconfig()
263 static int zforce_start(struct zforce_ts *ts) in zforce_start() argument
265 struct i2c_client *client = ts->client; in zforce_start()
266 const struct zforce_ts_platdata *pdata = ts->pdata; in zforce_start()
271 ret = zforce_command_wait(ts, COMMAND_INITIALIZE); in zforce_start()
277 ret = zforce_resolution(ts, pdata->x_max, pdata->y_max); in zforce_start()
283 ret = zforce_scan_frequency(ts, 10, 50, 50); in zforce_start()
290 ret = zforce_setconfig(ts, SETCONFIG_DUALTOUCH); in zforce_start()
297 ret = zforce_command(ts, COMMAND_DATAREQUEST); in zforce_start()
312 zforce_command_wait(ts, COMMAND_DEACTIVATE); in zforce_start()
316 static int zforce_stop(struct zforce_ts *ts) in zforce_stop() argument
318 struct i2c_client *client = ts->client; in zforce_stop()
324 ret = zforce_command_wait(ts, COMMAND_DEACTIVATE); in zforce_stop()
334 static int zforce_touch_event(struct zforce_ts *ts, u8 *payload) in zforce_touch_event() argument
336 struct i2c_client *client = ts->client; in zforce_touch_event()
337 const struct zforce_ts_platdata *pdata = ts->pdata; in zforce_touch_event()
384 input_mt_slot(ts->input, point.id - 1); in zforce_touch_event()
386 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, in zforce_touch_event()
390 input_report_abs(ts->input, ABS_MT_POSITION_X, in zforce_touch_event()
392 input_report_abs(ts->input, ABS_MT_POSITION_Y, in zforce_touch_event()
394 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, in zforce_touch_event()
396 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, in zforce_touch_event()
398 input_report_abs(ts->input, ABS_MT_ORIENTATION, in zforce_touch_event()
404 input_mt_sync_frame(ts->input); in zforce_touch_event()
406 input_mt_report_finger_count(ts->input, num); in zforce_touch_event()
408 input_sync(ts->input); in zforce_touch_event()
413 static int zforce_read_packet(struct zforce_ts *ts, u8 *buf) in zforce_read_packet() argument
415 struct i2c_client *client = ts->client; in zforce_read_packet()
418 mutex_lock(&ts->access_mutex); in zforce_read_packet()
451 mutex_unlock(&ts->access_mutex); in zforce_read_packet()
455 static void zforce_complete(struct zforce_ts *ts, int cmd, int result) in zforce_complete() argument
457 struct i2c_client *client = ts->client; in zforce_complete()
459 if (ts->command_waiting == cmd) { in zforce_complete()
461 ts->command_result = result; in zforce_complete()
462 complete(&ts->command_done); in zforce_complete()
470 struct zforce_ts *ts = dev_id; in zforce_irq() local
471 struct i2c_client *client = ts->client; in zforce_irq()
473 if (ts->suspended && device_may_wakeup(&client->dev)) in zforce_irq()
481 struct zforce_ts *ts = dev_id; in zforce_irq_thread() local
482 struct i2c_client *client = ts->client; in zforce_irq_thread()
483 const struct zforce_ts_platdata *pdata = ts->pdata; in zforce_irq_thread()
492 if (ts->suspended) { in zforce_irq_thread()
500 if (!ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
504 ret = zforce_read_packet(ts, payload_buffer); in zforce_irq_thread()
519 if (ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
521 zforce_touch_event(ts, &payload[RESPONSE_DATA]); in zforce_irq_thread()
525 ts->boot_complete = payload[RESPONSE_DATA]; in zforce_irq_thread()
526 zforce_complete(ts, payload[RESPONSE_ID], 0); in zforce_irq_thread()
534 zforce_complete(ts, payload[RESPONSE_ID], in zforce_irq_thread()
543 ts->version_major = (payload[RESPONSE_DATA + 1] << 8) | in zforce_irq_thread()
545 ts->version_minor = (payload[RESPONSE_DATA + 3] << 8) | in zforce_irq_thread()
547 ts->version_build = (payload[RESPONSE_DATA + 5] << 8) | in zforce_irq_thread()
549 ts->version_rev = (payload[RESPONSE_DATA + 7] << 8) | in zforce_irq_thread()
551 dev_dbg(&ts->client->dev, in zforce_irq_thread()
553 ts->version_major, ts->version_minor, in zforce_irq_thread()
554 ts->version_build, ts->version_rev); in zforce_irq_thread()
556 zforce_complete(ts, payload[RESPONSE_ID], 0); in zforce_irq_thread()
560 dev_err(&ts->client->dev, "invalid command: 0x%x\n", in zforce_irq_thread()
565 dev_err(&ts->client->dev, in zforce_irq_thread()
572 if (!ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
582 struct zforce_ts *ts = input_get_drvdata(dev); in zforce_input_open() local
585 ret = zforce_start(ts); in zforce_input_open()
594 struct zforce_ts *ts = input_get_drvdata(dev); in zforce_input_close() local
595 struct i2c_client *client = ts->client; in zforce_input_close()
598 ret = zforce_stop(ts); in zforce_input_close()
608 struct zforce_ts *ts = i2c_get_clientdata(client); in zforce_suspend() local
609 struct input_dev *input = ts->input; in zforce_suspend()
613 ts->suspending = true; in zforce_suspend()
624 ret = zforce_start(ts); in zforce_suspend()
634 ret = zforce_stop(ts); in zforce_suspend()
641 ts->suspended = true; in zforce_suspend()
644 ts->suspending = false; in zforce_suspend()
653 struct zforce_ts *ts = i2c_get_clientdata(client); in zforce_resume() local
654 struct input_dev *input = ts->input; in zforce_resume()
659 ts->suspended = false; in zforce_resume()
668 ret = zforce_stop(ts); in zforce_resume()
677 ret = zforce_start(ts); in zforce_resume()
692 struct zforce_ts *ts = data; in zforce_reset() local
694 gpio_set_value(ts->pdata->gpio_rst, 0); in zforce_reset()
698 if (!IS_ERR(ts->reg_vdd)) in zforce_reset()
699 regulator_disable(ts->reg_vdd); in zforce_reset()
745 struct zforce_ts *ts; in zforce_probe() local
755 ts = devm_kzalloc(&client->dev, sizeof(struct zforce_ts), GFP_KERNEL); in zforce_probe()
756 if (!ts) in zforce_probe()
775 ts->reg_vdd = devm_regulator_get_optional(&client->dev, "vdd"); in zforce_probe()
776 if (IS_ERR(ts->reg_vdd)) { in zforce_probe()
777 ret = PTR_ERR(ts->reg_vdd); in zforce_probe()
781 ret = regulator_enable(ts->reg_vdd); in zforce_probe()
792 ret = devm_add_action(&client->dev, zforce_reset, ts); in zforce_probe()
798 if (!IS_ERR(ts->reg_vdd)) in zforce_probe()
799 regulator_disable(ts->reg_vdd); in zforce_probe()
804 snprintf(ts->phys, sizeof(ts->phys), in zforce_probe()
813 mutex_init(&ts->access_mutex); in zforce_probe()
814 mutex_init(&ts->command_mutex); in zforce_probe()
816 ts->pdata = pdata; in zforce_probe()
817 ts->client = client; in zforce_probe()
818 ts->input = input_dev; in zforce_probe()
821 input_dev->phys = ts->phys; in zforce_probe()
844 input_set_drvdata(ts->input, ts); in zforce_probe()
846 init_completion(&ts->command_done); in zforce_probe()
858 input_dev->name, ts); in zforce_probe()
864 i2c_set_clientdata(client, ts); in zforce_probe()
869 ts->command_waiting = NOTIFICATION_BOOTCOMPLETE; in zforce_probe()
870 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) in zforce_probe()
874 ret = zforce_command_wait(ts, COMMAND_INITIALIZE); in zforce_probe()
881 ret = zforce_command_wait(ts, COMMAND_STATUS); in zforce_probe()
884 zforce_stop(ts); in zforce_probe()
889 ret = zforce_stop(ts); in zforce_probe()