Lines Matching +full:client +full:- +full:id

197 	struct i2c_client *client;  member
233 struct device_node *np = gsl_client->dev.of_node; in gsl_init()
237 this_ts->irq = of_get_named_gpio_flags(np, "irq_gpio_number", 0, in gsl_init()
239 this_ts->rst = of_get_named_gpio_flags(np, "rst_gpio_number", 0, in gsl_init()
242 if (gpio_is_valid(this_ts->rst)) { in gsl_init()
243 if (devm_gpio_request(&this_ts->client->dev, this_ts->rst, NULL) != 0) { in gsl_init()
244 dev_err(&this_ts->client->dev, "gpio_request this_ts->rst error\n"); in gsl_init()
245 return -EIO; in gsl_init()
247 gpio_direction_output(this_ts->rst, 0); in gsl_init()
248 gpio_set_value(this_ts->rst, 1); in gsl_init()
250 dev_info(&this_ts->client->dev, "rst pin invalid\n"); in gsl_init()
258 if (gpio_is_valid(this_ts->rst)) in gsl_shutdown_low()
259 gpio_set_value(this_ts->rst, 0); in gsl_shutdown_low()
265 if (gpio_is_valid(this_ts->rst)) in gsl_shutdown_high()
266 gpio_set_value(this_ts->rst, 1); in gsl_shutdown_high()
279 static u32 gsl_write_interface(struct i2c_client *client, const u8 reg, in gsl_write_interface() argument
285 xfer_msg[0].addr = client->addr; in gsl_write_interface()
287 xfer_msg[0].flags = client->flags & I2C_M_TEN; in gsl_write_interface()
290 return i2c_transfer(client->adapter, xfer_msg, 1) == 1 ? 0 : -EFAULT; in gsl_write_interface()
293 static int gsl_ts_write(struct i2c_client *client, u8 addr, u8 *pdata, in gsl_ts_write() argument
302 return -1; in gsl_ts_write()
310 ret = i2c_master_send(client, tmp_buf, bytelen); in gsl_ts_write()
314 static int gsl_ts_read(struct i2c_client *client, u8 addr, u8 *pdata, in gsl_ts_read() argument
321 return -1; in gsl_ts_read()
323 ret = gsl_ts_write(client, addr, NULL, 0); in gsl_ts_read()
328 return i2c_master_recv(client, pdata, datalen); in gsl_ts_read()
332 static void judge_chip_type(struct i2c_client *client) in judge_chip_type() argument
337 gsl_ts_read(client, 0xfc, read_buf, sizeof(read_buf)); in judge_chip_type()
340 gsl_ts_read(client, 0xfc, read_buf, sizeof(read_buf)); in judge_chip_type()
354 static void gsl_load_fw(struct i2c_client *client) in gsl_load_fw() argument
378 gsl_write_interface(client, GSL_PAGE_REG, buf, 4); in gsl_load_fw()
386 gsl_write_interface(client, buf[0], buf, cur - buf - 1); in gsl_load_fw()
394 static int test_i2c(struct i2c_client *client) in test_i2c() argument
400 ret = gsl_ts_read(client, 0xf0, &read_buf, sizeof(read_buf)); in test_i2c()
402 rc--; in test_i2c()
404 ret = gsl_ts_write(client, 0xf0, &write_buf, sizeof(write_buf)); in test_i2c()
406 ret = gsl_ts_read(client, 0xf0, &read_buf, sizeof(read_buf)); in test_i2c()
408 rc--; in test_i2c()
412 static void startup_chip(struct i2c_client *client) in startup_chip() argument
419 gsl_ts_write(client, 0xe0, &tmp, 1); in startup_chip()
423 static void reset_chip(struct i2c_client *client) in reset_chip() argument
428 gsl_ts_write(client, 0xe0, &tmp, sizeof(tmp)); in reset_chip()
431 gsl_ts_write(client, 0xe4, &tmp, sizeof(tmp)); in reset_chip()
433 gsl_ts_write(client, 0xbc, buf, sizeof(buf)); in reset_chip()
437 static void clr_reg(struct i2c_client *client) in clr_reg() argument
442 gsl_ts_write(client, 0xe0, &write_buf[0], 1); in clr_reg()
445 gsl_ts_write(client, 0x80, &write_buf[0], 1); in clr_reg()
448 gsl_ts_write(client, 0xe4, &write_buf[0], 1); in clr_reg()
451 gsl_ts_write(client, 0xe0, &write_buf[0], 1); in clr_reg()
455 static int init_chip(struct i2c_client *client) in init_chip() argument
458 struct gsl_ts *ts = i2c_get_clientdata(client); in init_chip()
464 rc = test_i2c(client); in init_chip()
466 dev_err(&client->dev, "GSL test_i2c error!\n"); in init_chip()
469 schedule_work(&ts->download_fw_work); in init_chip()
473 static int check_mem_data(struct i2c_client *client) in check_mem_data() argument
479 gsl_ts_read(client, 0xb0, read_buf, sizeof(read_buf)); in check_mem_data()
484 rc = init_chip(client); in check_mem_data()
495 return (ch - '0'); in char_to_int()
497 return (ch - 'a' + 10); in char_to_int()
547 return -EFAULT; in gsl_config_write_proc()
552 return -ENOMEM; in gsl_config_write_proc()
613 static void filter_point(u16 x, u16 y, u8 id) in filter_point() argument
619 id_sign[id] = id_sign[id] + 1; in filter_point()
620 if (id_sign[id] == 1) { in filter_point()
621 x_old[id] = x; in filter_point()
622 y_old[id] = y; in filter_point()
624 x_err = x > x_old[id] ? (x - x_old[id]) : (x_old[id] - x); in filter_point()
625 y_err = y > y_old[id] ? (y - y_old[id]) : (y_old[id] - y); in filter_point()
646 x_new = x > x_old[id] ? (x_old[id] + filter_step_x) in filter_point()
647 : (x_old[id] - filter_step_x); in filter_point()
648 y_new = y > y_old[id] ? (y_old[id] + filter_step_y) in filter_point()
649 : (y_old[id] - filter_step_y); in filter_point()
650 x_old[id] = x_new; in filter_point()
651 y_old[id] = y_new; in filter_point()
655 static void record_point(u16 x, u16 y, u8 id) in record_point() argument
660 id_sign[id] = id_sign[id] + 1; in record_point()
661 if (id_sign[id] == 1) { in record_point()
662 x_old[id] = x; in record_point()
663 y_old[id] = y; in record_point()
665 x = (x_old[id] + x) / 2; in record_point()
666 y = (y_old[id] + y) / 2; in record_point()
667 if (x > x_old[id]) in record_point()
668 x_err = x - x_old[id]; in record_point()
670 x_err = x_old[id] - x; in record_point()
671 if (y > y_old[id]) in record_point()
672 y_err = y - y_old[id]; in record_point()
674 y_err = y_old[id] - y; in record_point()
677 x_old[id] = x; in record_point()
679 y_old[id] = y; in record_point()
683 x_old[id] = x; in record_point()
685 x_new = x_old[id]; in record_point()
689 y_old[id] = y; in record_point()
691 y_new = y_old[id]; in record_point()
694 if (id_sign[id] == 1) { in record_point()
695 x_new = x_old[id]; in record_point()
696 y_new = y_old[id]; in record_point()
711 input_report_key(ts->input, key, 1); in report_key()
712 input_sync(ts->input); in report_key()
720 static void report_data(struct gsl_ts *ts, u16 x, u16 y, u8 pressure, u8 id) in report_data() argument
734 x = SCREEN_MAX_X-x-1; in report_data()
736 y = SCREEN_MAX_Y-y-1; in report_data()
739 input_mt_slot(ts->input, id); in report_data()
740 input_report_abs(ts->input, ABS_MT_TRACKING_ID, id); in report_data()
741 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure); in report_data()
743 input_report_abs(ts->input, ABS_MT_POSITION_X, x); in report_data()
744 input_report_abs(ts->input, ABS_MT_POSITION_Y, (y)); in report_data()
745 input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1); in report_data()
747 input_report_abs(ts->input, ABS_MT_TRACKING_ID, id); in report_data()
748 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure); in report_data()
749 input_report_abs(ts->input, ABS_MT_POSITION_X, x); in report_data()
750 input_report_abs(ts->input, ABS_MT_POSITION_Y, y); in report_data()
751 input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1); in report_data()
752 input_mt_sync(ts->input); in report_data()
760 spin_lock_irqsave(&ts->irq_lock, irqflags); in ts_irq_disable()
761 if (!ts->flag_irq_is_disable) { in ts_irq_disable()
762 disable_irq_nosync(ts->client->irq); in ts_irq_disable()
763 ts->flag_irq_is_disable = 1; in ts_irq_disable()
765 spin_unlock_irqrestore(&ts->irq_lock, irqflags); in ts_irq_disable()
772 spin_lock_irqsave(&ts->irq_lock, irqflags); in ts_irq_enable()
773 if (ts->flag_irq_is_disable) { in ts_irq_enable()
774 enable_irq(ts->client->irq); in ts_irq_enable()
775 ts->flag_irq_is_disable = 0; in ts_irq_enable()
777 spin_unlock_irqrestore(&ts->irq_lock, irqflags); in ts_irq_enable()
783 u8 id, touches; in gsl_ts_worker() local
804 rc = gsl_ts_read(ts->client, 0x80, ts->touch_data, ts->dd->data_size); in gsl_ts_worker()
806 dev_err(&ts->client->dev, "read failed\n"); in gsl_ts_worker()
809 touches = ts->touch_data[ts->dd->touch_index]; in gsl_ts_worker()
813 cinfo.x[i] = join_bytes((ts->touch_data[ts->dd->x_index + in gsl_ts_worker()
814 4 * i + 1] & 0xf), ts->touch_data[ts->dd->x_index + 4 * i]); in gsl_ts_worker()
815 cinfo.y[i] = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1], in gsl_ts_worker()
816 ts->touch_data[ts->dd->y_index + 4 * i]); in gsl_ts_worker()
817 cinfo.id[i] = ((ts->touch_data[ts->dd->x_index + 4 * i + 1] in gsl_ts_worker()
820 cinfo.finger_num = (ts->touch_data[3] << 24) | (ts->touch_data[2] << 16) in gsl_ts_worker()
821 | (ts->touch_data[1] << 8) | (ts->touch_data[0]); in gsl_ts_worker()
829 gsl_ts_write(ts->client, 0xf0, buf, 4); in gsl_ts_worker()
837 gsl_ts_write(ts->client, 0x8, buf, 4); in gsl_ts_worker()
848 id = cinfo.id[i]; in gsl_ts_worker()
852 x = join_bytes((ts->touch_data[ts->dd->x_index + 4 * i + 1] in gsl_ts_worker()
853 & 0xf), ts->touch_data[ts->dd->x_index + 4 * i]); in gsl_ts_worker()
854 y = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1], in gsl_ts_worker()
855 ts->touch_data[ts->dd->y_index + 4 * i]); in gsl_ts_worker()
856 id = ts->touch_data[ts->dd->id_index + 4 * i] >> 4; in gsl_ts_worker()
858 if (id >= 1 && id <= MAX_CONTACTS) { in gsl_ts_worker()
860 filter_point(x, y, id); in gsl_ts_worker()
862 record_point(x, y, id); in gsl_ts_worker()
864 report_data(ts, x_new, y_new, 10, id); in gsl_ts_worker()
865 id_state_flag[id] = 1; in gsl_ts_worker()
872 input_mt_slot(ts->input, i); in gsl_ts_worker()
873 input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1); in gsl_ts_worker()
874 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false); in gsl_ts_worker()
883 input_report_key(ts->input, key, 0); in gsl_ts_worker()
884 input_sync(ts->input); in gsl_ts_worker()
889 input_sync(ts->input); in gsl_ts_worker()
965 if (!work_pending(&ts->work)) in gsl_ts_irq()
966 queue_work(ts->wq, &ts->work); in gsl_ts_irq()
970 static int gsl_thzy_ts_init(struct i2c_client *client, struct gsl_ts *ts) in gsl_thzy_ts_init() argument
978 ts->dd = &devices[ts->device_id]; in gsl_thzy_ts_init()
979 if (ts->device_id == 0) { in gsl_thzy_ts_init()
980 ts->dd->data_size = MAX_FINGERS * ts->dd->touch_bytes + in gsl_thzy_ts_init()
981 ts->dd->touch_meta_data; in gsl_thzy_ts_init()
982 ts->dd->touch_index = 0; in gsl_thzy_ts_init()
984 ts->touch_data = devm_kzalloc(&client->dev, in gsl_thzy_ts_init()
985 ts->dd->data_size, GFP_KERNEL); in gsl_thzy_ts_init()
986 if (!ts->touch_data) in gsl_thzy_ts_init()
987 return -ENOMEM; in gsl_thzy_ts_init()
988 input_device = devm_input_allocate_device(&ts->client->dev); in gsl_thzy_ts_init()
990 return -ENOMEM; in gsl_thzy_ts_init()
992 ts->input = input_device; in gsl_thzy_ts_init()
993 input_device->name = GSL_I2C_NAME; in gsl_thzy_ts_init()
994 input_device->id.bustype = BUS_I2C; in gsl_thzy_ts_init()
995 input_device->dev.parent = &client->dev; in gsl_thzy_ts_init()
999 input_device->evbit[i] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY); in gsl_thzy_ts_init()
1000 set_bit(key_array[i], input_device->keybit); in gsl_thzy_ts_init()
1004 __set_bit(EV_ABS, input_device->evbit); in gsl_thzy_ts_init()
1005 __set_bit(EV_KEY, input_device->evbit); in gsl_thzy_ts_init()
1006 __set_bit(EV_REP, input_device->evbit); in gsl_thzy_ts_init()
1007 __set_bit(INPUT_PROP_DIRECT, input_device->propbit); in gsl_thzy_ts_init()
1012 set_bit(EV_ABS, input_device->evbit); in gsl_thzy_ts_init()
1013 set_bit(EV_KEY, input_device->evbit); in gsl_thzy_ts_init()
1014 __set_bit(INPUT_PROP_DIRECT, input_device->propbit); in gsl_thzy_ts_init()
1015 input_device->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); in gsl_thzy_ts_init()
1017 set_bit(ABS_MT_POSITION_X, input_device->absbit); in gsl_thzy_ts_init()
1018 set_bit(ABS_MT_POSITION_Y, input_device->absbit); in gsl_thzy_ts_init()
1019 set_bit(ABS_MT_TOUCH_MAJOR, input_device->absbit); in gsl_thzy_ts_init()
1020 set_bit(ABS_MT_WIDTH_MAJOR, input_device->absbit); in gsl_thzy_ts_init()
1028 ts->wq = create_singlethread_workqueue("kworkqueue_ts"); in gsl_thzy_ts_init()
1029 if (!ts->wq) { in gsl_thzy_ts_init()
1030 dev_err(&client->dev, "gsl Could not create workqueue\n"); in gsl_thzy_ts_init()
1031 return -ENOMEM; in gsl_thzy_ts_init()
1033 flush_workqueue(ts->wq); in gsl_thzy_ts_init()
1034 INIT_WORK(&ts->work, gsl_ts_worker); in gsl_thzy_ts_init()
1040 destroy_workqueue(ts->wq); in gsl_thzy_ts_init()
1053 cancel_work_sync(&ts->work); in gsl_ts_suspend()
1060 input_mt_slot(ts->input, i); in gsl_ts_suspend()
1061 input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1); in gsl_ts_suspend()
1062 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false); in gsl_ts_suspend()
1065 input_mt_sync(ts->input); in gsl_ts_suspend()
1067 input_sync(ts->input); in gsl_ts_suspend()
1070 input_sync(ts->input); in gsl_ts_suspend()
1083 reset_chip(ts->client); in gsl_ts_resume()
1084 startup_chip(ts->client); in gsl_ts_resume()
1085 rc = check_mem_data(ts->client); in gsl_ts_resume()
1091 input_mt_slot(ts->input, i); in gsl_ts_resume()
1092 input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1); in gsl_ts_resume()
1093 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false); in gsl_ts_resume()
1096 input_mt_sync(ts->input); in gsl_ts_resume()
1098 input_sync(ts->input); in gsl_ts_resume()
1111 gsl_ts_suspend(&ts->client->dev); in gsl_ts_early_suspend()
1119 schedule_work(&ts->resume_work); in gsl_ts_late_resume()
1128 clr_reg(ts->client); in gsl_download_fw_work()
1129 reset_chip(ts->client); in gsl_download_fw_work()
1130 gsl_load_fw(ts->client); in gsl_download_fw_work()
1131 startup_chip(ts->client); in gsl_download_fw_work()
1132 reset_chip(ts->client); in gsl_download_fw_work()
1133 startup_chip(ts->client); in gsl_download_fw_work()
1138 gsl_ts_resume(&gsl_client->dev); in gsl_resume_work()
1141 static int gsl_ts_probe(struct i2c_client *client, in gsl_ts_probe() argument
1142 const struct i2c_device_id *id) in gsl_ts_probe() argument
1150 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in gsl_ts_probe()
1151 dev_err(&client->dev, "gsl I2C functionality not supported\n"); in gsl_ts_probe()
1152 return -ENODEV; in gsl_ts_probe()
1154 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); in gsl_ts_probe()
1156 return -ENOMEM; in gsl_ts_probe()
1157 ts->tp.tp_resume = gsl_ts_late_resume; in gsl_ts_probe()
1158 ts->tp.tp_suspend = gsl_ts_early_suspend; in gsl_ts_probe()
1159 tp_register_fb(&ts->tp); in gsl_ts_probe()
1160 ts->client = client; in gsl_ts_probe()
1161 i2c_set_clientdata(client, ts); in gsl_ts_probe()
1163 gsl_client = client; in gsl_ts_probe()
1165 rc = gsl_thzy_ts_init(client, ts); in gsl_ts_probe()
1167 dev_err(&client->dev, "gsl GSL init failed\n"); in gsl_ts_probe()
1171 judge_chip_type(client); in gsl_ts_probe()
1173 INIT_WORK(&ts->download_fw_work, gsl_download_fw_work); in gsl_ts_probe()
1174 INIT_WORK(&ts->resume_work, gsl_resume_work); in gsl_ts_probe()
1176 rc = init_chip(ts->client); in gsl_ts_probe()
1178 dev_err(&client->dev, "gsl_probe: init_chip failed\n"); in gsl_ts_probe()
1181 spin_lock_init(&ts->irq_lock); in gsl_ts_probe()
1182 client->irq = gpio_to_irq(ts->irq); in gsl_ts_probe()
1183 rc = devm_request_irq(&client->dev, client->irq, gsl_ts_irq, in gsl_ts_probe()
1184 IRQF_TRIGGER_RISING, client->name, ts); in gsl_ts_probe()
1186 dev_err(&client->dev, "gsl_probe: request irq failed\n"); in gsl_ts_probe()
1201 cancel_work_sync(&ts->download_fw_work); in gsl_ts_probe()
1203 tp_unregister_fb(&ts->tp); in gsl_ts_probe()
1207 static int gsl_ts_remove(struct i2c_client *client) in gsl_ts_remove() argument
1209 struct gsl_ts *ts = i2c_get_clientdata(client); in gsl_ts_remove()
1215 device_init_wakeup(&client->dev, 0); in gsl_ts_remove()
1216 cancel_work_sync(&ts->work); in gsl_ts_remove()
1217 destroy_workqueue(ts->wq); in gsl_ts_remove()
1218 cancel_work_sync(&ts->download_fw_work); in gsl_ts_remove()