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

197 	struct i2c_client *client;  member
233 struct device_node *np = gsl_client->dev.of_node; in gsl3673_init()
237 this_ts->irq = of_get_named_gpio_flags(np, "irq_gpio_number", 0, in gsl3673_init()
239 this_ts->rst = of_get_named_gpio_flags(np, "rst_gpio_number", 0, in gsl3673_init()
241 if (devm_gpio_request(&this_ts->client->dev, this_ts->rst, NULL) != 0) { in gsl3673_init()
242 dev_err(&this_ts->client->dev, "gpio_request this_ts->rst error\n"); in gsl3673_init()
243 return -EIO; in gsl3673_init()
245 gpio_direction_output(this_ts->rst, 0); in gsl3673_init()
246 gpio_set_value(this_ts->rst, 1); in gsl3673_init()
252 if (this_ts->rst > 1) in gsl3673_shutdown_low()
253 gpio_set_value(this_ts->rst, 0); in gsl3673_shutdown_low()
259 if (this_ts->rst > 1) in gsl3673_shutdown_high()
260 gpio_set_value(this_ts->rst, 1); in gsl3673_shutdown_high()
273 static u32 gsl_write_interface(struct i2c_client *client, const u8 reg, in gsl_write_interface() argument
279 xfer_msg[0].addr = client->addr; in gsl_write_interface()
281 xfer_msg[0].flags = client->flags & I2C_M_TEN; in gsl_write_interface()
284 return i2c_transfer(client->adapter, xfer_msg, 1) == 1 ? 0 : -EFAULT; in gsl_write_interface()
287 static int gsl_ts_write(struct i2c_client *client, u8 addr, u8 *pdata, in gsl_ts_write() argument
296 return -1; in gsl_ts_write()
304 ret = i2c_master_send(client, tmp_buf, bytelen); in gsl_ts_write()
308 static int gsl_ts_read(struct i2c_client *client, u8 addr, u8 *pdata, in gsl_ts_read() argument
315 return -1; in gsl_ts_read()
317 ret = gsl_ts_write(client, addr, NULL, 0); in gsl_ts_read()
322 return i2c_master_recv(client, pdata, datalen); in gsl_ts_read()
326 static void judge_chip_type(struct i2c_client *client) in judge_chip_type() argument
331 gsl_ts_read(client, 0xfc, read_buf, sizeof(read_buf)); in judge_chip_type()
334 gsl_ts_read(client, 0xfc, read_buf, sizeof(read_buf)); in judge_chip_type()
348 static void gsl_load_fw(struct i2c_client *client) in gsl_load_fw() argument
372 gsl_write_interface(client, GSL_PAGE_REG, buf, 4); in gsl_load_fw()
380 gsl_write_interface(client, buf[0], buf, cur - buf - 1); in gsl_load_fw()
388 static int test_i2c(struct i2c_client *client) in test_i2c() argument
394 ret = gsl_ts_read(client, 0xf0, &read_buf, sizeof(read_buf)); in test_i2c()
396 rc--; in test_i2c()
398 ret = gsl_ts_write(client, 0xf0, &write_buf, sizeof(write_buf)); in test_i2c()
400 ret = gsl_ts_read(client, 0xf0, &read_buf, sizeof(read_buf)); in test_i2c()
402 rc--; in test_i2c()
406 static void gsl_io_control(struct i2c_client *client) in gsl_io_control() argument
417 gsl_ts_write(client, 0xf0, buf, 4); in gsl_io_control()
422 gsl_ts_write(client, 0x78, buf, 4); in gsl_io_control()
429 static void startup_chip(struct i2c_client *client) in startup_chip() argument
436 gsl_ts_write(client, 0xe0, &tmp, 1); in startup_chip()
438 gsl_io_control(client); in startup_chip()
441 static void reset_chip(struct i2c_client *client) in reset_chip() argument
446 gsl_ts_write(client, 0xe0, &tmp, sizeof(tmp)); in reset_chip()
449 gsl_ts_write(client, 0xe4, &tmp, sizeof(tmp)); in reset_chip()
451 gsl_ts_write(client, 0xbc, buf, sizeof(buf)); in reset_chip()
455 static void clr_reg(struct i2c_client *client) in clr_reg() argument
460 gsl_ts_write(client, 0xe0, &write_buf[0], 1); in clr_reg()
463 gsl_ts_write(client, 0x80, &write_buf[0], 1); in clr_reg()
466 gsl_ts_write(client, 0xe4, &write_buf[0], 1); in clr_reg()
469 gsl_ts_write(client, 0xe0, &write_buf[0], 1); in clr_reg()
473 static int init_chip(struct i2c_client *client) in init_chip() argument
476 struct gsl_ts *ts = i2c_get_clientdata(client); in init_chip()
482 rc = test_i2c(client); in init_chip()
484 dev_err(&client->dev, "GSL3673 test_i2c error!\n"); in init_chip()
487 schedule_work(&ts->download_fw_work); in init_chip()
498 rc = init_chip(gsl3673_ts->client); in gsl_delayed_work_init()
500 dev_err(&gsl3673_ts->client->dev, "gsl_probe: init_chip failed\n"); in gsl_delayed_work_init()
501 cancel_work_sync(&gsl3673_ts->download_fw_work); in gsl_delayed_work_init()
505 static int check_mem_data(struct i2c_client *client) in check_mem_data() argument
511 gsl_ts_read(client, 0xb0, read_buf, sizeof(read_buf)); in check_mem_data()
516 rc = init_chip(client); in check_mem_data()
527 return (ch - '0'); in char_to_int()
529 return (ch - 'a' + 10); in char_to_int()
578 return -EFAULT; in gsl_config_write_proc()
641 static void filter_point(u16 x, u16 y, u8 id) in filter_point() argument
647 id_sign[id] = id_sign[id] + 1; in filter_point()
648 if (id_sign[id] == 1) { in filter_point()
649 x_old[id] = x; in filter_point()
650 y_old[id] = y; in filter_point()
652 x_err = x > x_old[id] ? (x - x_old[id]) : (x_old[id] - x); in filter_point()
653 y_err = y > y_old[id] ? (y - y_old[id]) : (y_old[id] - y); in filter_point()
674 x_new = x > x_old[id] ? (x_old[id] + filter_step_x) in filter_point()
675 : (x_old[id] - filter_step_x); in filter_point()
676 y_new = y > y_old[id] ? (y_old[id] + filter_step_y) in filter_point()
677 : (y_old[id] - filter_step_y); in filter_point()
678 x_old[id] = x_new; in filter_point()
679 y_old[id] = y_new; in filter_point()
683 static void record_point(u16 x, u16 y, u8 id) in record_point() argument
688 id_sign[id] = id_sign[id] + 1; in record_point()
689 if (id_sign[id] == 1) { in record_point()
690 x_old[id] = x; in record_point()
691 y_old[id] = y; in record_point()
693 x = (x_old[id] + x) / 2; in record_point()
694 y = (y_old[id] + y) / 2; in record_point()
695 if (x > x_old[id]) in record_point()
696 x_err = x - x_old[id]; in record_point()
698 x_err = x_old[id] - x; in record_point()
699 if (y > y_old[id]) in record_point()
700 y_err = y - y_old[id]; in record_point()
702 y_err = y_old[id] - y; in record_point()
705 x_old[id] = x; in record_point()
707 y_old[id] = y; in record_point()
711 x_old[id] = x; in record_point()
713 x_new = x_old[id]; in record_point()
717 y_old[id] = y; in record_point()
719 y_new = y_old[id]; in record_point()
722 if (id_sign[id] == 1) { in record_point()
723 x_new = x_old[id]; in record_point()
724 y_new = y_old[id]; in record_point()
739 input_report_key(ts->input, key, 1); in report_key()
740 input_sync(ts->input); in report_key()
748 static void report_data(struct gsl_ts *ts, u16 x, u16 y, u8 pressure, u8 id) in report_data() argument
760 input_mt_slot(ts->input, id); in report_data()
761 input_report_abs(ts->input, ABS_MT_TRACKING_ID, id); in report_data()
762 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure); in report_data()
764 input_report_abs(ts->input, ABS_MT_POSITION_X, SCREEN_MAX_X - x); in report_data()
766 input_report_abs(ts->input, ABS_MT_POSITION_X, x); in report_data()
769 input_report_abs(ts->input, ABS_MT_POSITION_Y, (SCREEN_MAX_Y - y)); in report_data()
771 input_report_abs(ts->input, ABS_MT_POSITION_Y, (y)); in report_data()
773 input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1); in report_data()
775 input_report_abs(ts->input, ABS_MT_TRACKING_ID, id); in report_data()
776 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure); in report_data()
777 input_report_abs(ts->input, ABS_MT_POSITION_X, x); in report_data()
778 input_report_abs(ts->input, ABS_MT_POSITION_Y, y); in report_data()
779 input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1); in report_data()
780 input_mt_sync(ts->input); in report_data()
788 spin_lock_irqsave(&ts->irq_lock, irqflags); in ts_irq_disable()
789 if (!ts->flag_irq_is_disable) { in ts_irq_disable()
790 disable_irq_nosync(ts->client->irq); in ts_irq_disable()
791 ts->flag_irq_is_disable = 1; in ts_irq_disable()
793 spin_unlock_irqrestore(&ts->irq_lock, irqflags); in ts_irq_disable()
800 spin_lock_irqsave(&ts->irq_lock, irqflags); in ts_irq_enable()
801 if (ts->flag_irq_is_disable) { in ts_irq_enable()
802 enable_irq(ts->client->irq); in ts_irq_enable()
803 ts->flag_irq_is_disable = 0; in ts_irq_enable()
805 spin_unlock_irqrestore(&ts->irq_lock, irqflags); in ts_irq_enable()
811 u8 id, touches; in gsl3673_ts_worker() local
831 rc = gsl_ts_read(ts->client, 0x80, ts->touch_data, ts->dd->data_size); in gsl3673_ts_worker()
833 dev_err(&ts->client->dev, "read failed\n"); in gsl3673_ts_worker()
836 touches = ts->touch_data[ts->dd->touch_index]; in gsl3673_ts_worker()
840 cinfo.x[i] = join_bytes((ts->touch_data[ts->dd->x_index + in gsl3673_ts_worker()
841 4 * i + 1] & 0xf), ts->touch_data[ts->dd->x_index + 4 * i]); in gsl3673_ts_worker()
842 cinfo.y[i] = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1], in gsl3673_ts_worker()
843 ts->touch_data[ts->dd->y_index + 4 * i]); in gsl3673_ts_worker()
844 cinfo.id[i] = ((ts->touch_data[ts->dd->x_index + 4 * i + 1] in gsl3673_ts_worker()
847 cinfo.finger_num = (ts->touch_data[3] << 24) | (ts->touch_data[2] << 16) in gsl3673_ts_worker()
848 | (ts->touch_data[1] << 8) | (ts->touch_data[0]); in gsl3673_ts_worker()
856 gsl_ts_write(ts->client, 0xf0, buf, 4); in gsl3673_ts_worker()
864 gsl_ts_write(ts->client, 0x8, buf, 4); in gsl3673_ts_worker()
875 id = cinfo.id[i]; in gsl3673_ts_worker()
879 x = join_bytes((ts->touch_data[ts->dd->x_index + 4 * i + 1] in gsl3673_ts_worker()
880 & 0xf), ts->touch_data[ts->dd->x_index + 4 * i]); in gsl3673_ts_worker()
881 y = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1], in gsl3673_ts_worker()
882 ts->touch_data[ts->dd->y_index + 4 * i]); in gsl3673_ts_worker()
883 id = ts->touch_data[ts->dd->id_index + 4 * i] >> 4; in gsl3673_ts_worker()
885 if (id >= 1 && id <= MAX_CONTACTS) { in gsl3673_ts_worker()
887 filter_point(x, y, id); in gsl3673_ts_worker()
889 record_point(x, y, id); in gsl3673_ts_worker()
891 report_data(ts, x_new, y_new, 10, id); in gsl3673_ts_worker()
892 id_state_flag[id] = 1; in gsl3673_ts_worker()
899 input_mt_slot(ts->input, i); in gsl3673_ts_worker()
900 input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1); in gsl3673_ts_worker()
901 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false); in gsl3673_ts_worker()
910 input_report_key(ts->input, key, 0); in gsl3673_ts_worker()
911 input_sync(ts->input); in gsl3673_ts_worker()
916 input_sync(ts->input); in gsl3673_ts_worker()
992 if (!work_pending(&ts->work)) in gsl_ts_irq()
993 queue_work(ts->wq, &ts->work); in gsl_ts_irq()
997 static int gsl3673_ts_init(struct i2c_client *client, struct gsl_ts *ts) in gsl3673_ts_init() argument
1005 ts->dd = &devices[ts->device_id]; in gsl3673_ts_init()
1006 if (ts->device_id == 0) { in gsl3673_ts_init()
1007 ts->dd->data_size = MAX_FINGERS * ts->dd->touch_bytes + in gsl3673_ts_init()
1008 ts->dd->touch_meta_data; in gsl3673_ts_init()
1009 ts->dd->touch_index = 0; in gsl3673_ts_init()
1011 ts->touch_data = devm_kzalloc(&client->dev, in gsl3673_ts_init()
1012 ts->dd->data_size, GFP_KERNEL); in gsl3673_ts_init()
1013 if (!ts->touch_data) in gsl3673_ts_init()
1014 return -ENOMEM; in gsl3673_ts_init()
1015 input_device = devm_input_allocate_device(&ts->client->dev); in gsl3673_ts_init()
1017 return -ENOMEM; in gsl3673_ts_init()
1019 ts->input = input_device; in gsl3673_ts_init()
1020 input_device->name = GSL3673_I2C_NAME; in gsl3673_ts_init()
1021 input_device->id.bustype = BUS_I2C; in gsl3673_ts_init()
1022 input_device->dev.parent = &client->dev; in gsl3673_ts_init()
1026 input_device->evbit[i] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY); in gsl3673_ts_init()
1027 set_bit(key_array[i], input_device->keybit); in gsl3673_ts_init()
1031 __set_bit(EV_ABS, input_device->evbit); in gsl3673_ts_init()
1032 __set_bit(EV_KEY, input_device->evbit); in gsl3673_ts_init()
1033 __set_bit(EV_REP, input_device->evbit); in gsl3673_ts_init()
1034 __set_bit(INPUT_PROP_DIRECT, input_device->propbit); in gsl3673_ts_init()
1039 set_bit(EV_ABS, input_device->evbit); in gsl3673_ts_init()
1040 set_bit(EV_KEY, input_device->evbit); in gsl3673_ts_init()
1041 __set_bit(INPUT_PROP_DIRECT, input_device->propbit); in gsl3673_ts_init()
1042 input_device->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); in gsl3673_ts_init()
1044 set_bit(ABS_MT_POSITION_X, input_device->absbit); in gsl3673_ts_init()
1045 set_bit(ABS_MT_POSITION_Y, input_device->absbit); in gsl3673_ts_init()
1046 set_bit(ABS_MT_TOUCH_MAJOR, input_device->absbit); in gsl3673_ts_init()
1047 set_bit(ABS_MT_WIDTH_MAJOR, input_device->absbit); in gsl3673_ts_init()
1055 ts->wq = create_singlethread_workqueue("kworkqueue_ts"); in gsl3673_ts_init()
1056 if (!ts->wq) { in gsl3673_ts_init()
1057 dev_err(&client->dev, "gsl Could not create workqueue\n"); in gsl3673_ts_init()
1058 return -ENOMEM; in gsl3673_ts_init()
1060 flush_workqueue(ts->wq); in gsl3673_ts_init()
1061 INIT_WORK(&ts->work, gsl3673_ts_worker); in gsl3673_ts_init()
1067 destroy_workqueue(ts->wq); in gsl3673_ts_init()
1080 cancel_work_sync(&ts->work); in gsl_ts_suspend()
1087 input_mt_slot(ts->input, i); in gsl_ts_suspend()
1088 input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1); in gsl_ts_suspend()
1089 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false); in gsl_ts_suspend()
1092 input_mt_sync(ts->input); in gsl_ts_suspend()
1094 input_sync(ts->input); in gsl_ts_suspend()
1097 input_sync(ts->input); in gsl_ts_suspend()
1110 reset_chip(ts->client); in gsl_ts_resume()
1111 startup_chip(ts->client); in gsl_ts_resume()
1112 rc = check_mem_data(ts->client); in gsl_ts_resume()
1118 input_mt_slot(ts->input, i); in gsl_ts_resume()
1119 input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1); in gsl_ts_resume()
1120 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false); in gsl_ts_resume()
1123 input_mt_sync(ts->input); in gsl_ts_resume()
1125 input_sync(ts->input); in gsl_ts_resume()
1138 gsl_ts_suspend(&ts->client->dev); in gsl_ts_early_suspend()
1146 schedule_work(&ts->resume_work); in gsl_ts_late_resume()
1155 clr_reg(ts->client); in gsl_download_fw_work()
1156 reset_chip(ts->client); in gsl_download_fw_work()
1157 gsl_load_fw(ts->client); in gsl_download_fw_work()
1158 startup_chip(ts->client); in gsl_download_fw_work()
1159 reset_chip(ts->client); in gsl_download_fw_work()
1160 startup_chip(ts->client); in gsl_download_fw_work()
1165 gsl_ts_resume(&gsl_client->dev); in gsl_resume_work()
1168 static int gsl_ts_probe(struct i2c_client *client, in gsl_ts_probe() argument
1169 const struct i2c_device_id *id) in gsl_ts_probe() argument
1177 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in gsl_ts_probe()
1178 dev_err(&client->dev, "gsl I2C functionality not supported\n"); in gsl_ts_probe()
1179 return -ENODEV; in gsl_ts_probe()
1181 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); in gsl_ts_probe()
1183 return -ENOMEM; in gsl_ts_probe()
1184 ts->tp.tp_resume = gsl_ts_late_resume; in gsl_ts_probe()
1185 ts->tp.tp_suspend = gsl_ts_early_suspend; in gsl_ts_probe()
1186 tp_register_fb(&ts->tp); in gsl_ts_probe()
1187 ts->client = client; in gsl_ts_probe()
1188 i2c_set_clientdata(client, ts); in gsl_ts_probe()
1190 gsl_client = client; in gsl_ts_probe()
1192 rc = gsl3673_ts_init(client, ts); in gsl_ts_probe()
1194 dev_err(&client->dev, "gsl GSL3673 init failed\n"); in gsl_ts_probe()
1198 judge_chip_type(client); in gsl_ts_probe()
1200 INIT_WORK(&ts->download_fw_work, gsl_download_fw_work); in gsl_ts_probe()
1201 INIT_WORK(&ts->resume_work, gsl_resume_work); in gsl_ts_probe()
1202 INIT_DELAYED_WORK(&ts->delayed_work_init, gsl_delayed_work_init); in gsl_ts_probe()
1204 spin_lock_init(&ts->irq_lock); in gsl_ts_probe()
1205 client->irq = gpio_to_irq(ts->irq); in gsl_ts_probe()
1206 rc = devm_request_irq(&client->dev, client->irq, gsl_ts_irq, in gsl_ts_probe()
1207 IRQF_TRIGGER_RISING, client->name, ts); in gsl_ts_probe()
1209 dev_err(&client->dev, "gsl_probe: request irq failed\n"); in gsl_ts_probe()
1213 schedule_delayed_work(&ts->delayed_work_init, in gsl_ts_probe()
1227 tp_unregister_fb(&ts->tp); in gsl_ts_probe()
1231 static int gsl_ts_remove(struct i2c_client *client) in gsl_ts_remove() argument
1233 struct gsl_ts *ts = i2c_get_clientdata(client); in gsl_ts_remove()
1239 tp_unregister_fb(&ts->tp); in gsl_ts_remove()
1240 device_init_wakeup(&client->dev, 0); in gsl_ts_remove()
1241 cancel_work_sync(&ts->work); in gsl_ts_remove()
1242 destroy_workqueue(ts->wq); in gsl_ts_remove()
1243 cancel_delayed_work_sync(&ts->delayed_work_init); in gsl_ts_remove()
1244 cancel_work_sync(&ts->download_fw_work); in gsl_ts_remove()