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

129 	struct i2c_client *client;  member
169 if (gpio_is_valid(gts->rst_pin)) in gslX680_shutdown_low()
170 gpio_set_value(gts->rst_pin, GPIO_LOW); in gslX680_shutdown_low()
177 if (gpio_is_valid(gts->rst_pin)) in gslX680_shutdown_high()
178 gpio_set_value(gts->rst_pin, GPIO_HIGH); in gslX680_shutdown_high()
192 static u32 gsl_write_interface(struct i2c_client *client, const u8 reg, u8 *buf, u32 num) in gsl_write_interface() argument
197 xfer_msg[0].addr = client->addr; in gsl_write_interface()
199 xfer_msg[0].flags = client->flags & I2C_M_TEN; in gsl_write_interface()
202 return i2c_transfer(client->adapter, xfer_msg, 1) == 1 ? 0 : -EFAULT; in gsl_write_interface()
205 static int gsl_ts_write(struct i2c_client *client, u8 addr, u8 *pdata, int datalen) in gsl_ts_write() argument
212 return -1; in gsl_ts_write()
220 ret = i2c_master_send(client, tmp_buf, bytelen); in gsl_ts_write()
224 static int gsl_ts_read(struct i2c_client *client, u8 addr, u8 *pdata, unsigned int datalen) in gsl_ts_read() argument
229 return -1; in gsl_ts_read()
231 ret = gsl_ts_write(client, addr, NULL, 0); in gsl_ts_read()
235 return i2c_master_recv(client, pdata, datalen); in gsl_ts_read()
239 static void judge_chip_type(struct i2c_client *client) in judge_chip_type() argument
245 gsl_ts_read(client, 0xfc, read_buf, sizeof(read_buf)); in judge_chip_type()
249 gsl_ts_read(client, 0xfc, read_buf, sizeof(read_buf)); in judge_chip_type()
270 static void gsl_load_fw(struct i2c_client *client) in gsl_load_fw() argument
289 gsl_write_interface(client, GSL_PAGE_REG, buf, 4); in gsl_load_fw()
299 gsl_write_interface(client, buf[0], buf, cur - buf - 1); in gsl_load_fw()
307 static int test_i2c(struct i2c_client *client) in test_i2c() argument
313 ret = gsl_ts_read(client, 0xf0, &read_buf, sizeof(read_buf)); in test_i2c()
315 rc--; in test_i2c()
318 ret = gsl_ts_write(client, 0xf0, &write_buf, sizeof(write_buf)); in test_i2c()
321 ret = gsl_ts_read(client, 0xf0, &read_buf, sizeof(read_buf)); in test_i2c()
323 rc--; in test_i2c()
328 static void startup_chip(struct i2c_client *client) in startup_chip() argument
335 gsl_ts_write(client, 0xe0, &tmp, 1); in startup_chip()
339 static void reset_chip(struct i2c_client *client) in reset_chip() argument
344 gsl_ts_write(client, 0xe0, &tmp, sizeof(tmp)); in reset_chip()
347 gsl_ts_write(client, 0xe4, &tmp, sizeof(tmp)); in reset_chip()
349 gsl_ts_write(client, 0xbc, buf, sizeof(buf)); in reset_chip()
353 static void clr_reg(struct i2c_client *client) in clr_reg() argument
358 gsl_ts_write(client, 0xe0, &write_buf[0], 1); in clr_reg()
361 gsl_ts_write(client, 0x80, &write_buf[0], 1); in clr_reg()
364 gsl_ts_write(client, 0xe4, &write_buf[0], 1); in clr_reg()
367 gsl_ts_write(client, 0xe0, &write_buf[0], 1); in clr_reg()
371 static void init_chip(struct i2c_client *client) in init_chip() argument
379 rc = test_i2c(client); in init_chip()
381 print_info("------gslX680 test_i2c error------\n"); in init_chip()
384 clr_reg(client); in init_chip()
385 reset_chip(client); in init_chip()
386 gsl_load_fw(client); in init_chip()
387 startup_chip(client); in init_chip()
388 reset_chip(client); in init_chip()
389 startup_chip(client); in init_chip()
392 static void check_mem_data(struct i2c_client *client) in check_mem_data() argument
397 gsl_ts_read(client, 0xb0, read_buf, sizeof(read_buf)); in check_mem_data()
400 init_chip(client); in check_mem_data()
407 return (ch - '0'); in char_to_int()
409 return (ch - 'a' + 10); in char_to_int()
445 return (ptr - page);
456 print_info("[tp-gsl][%s]\n", __func__);
459 return -EFAULT;
461 path_buf = devm_kzalloc(&gts->client->dev, count, GFP_KERNEL);
470 print_info("[tp-gsl][%s][%s]\n", __func__, temp_buf);
506 devm_kfree(&client->dev, path_buf);
512 static void filter_point(u16 x, u16 y, u8 id)
518 id_sign[id] = id_sign[id] + 1;
519 if (id_sign[id] == 1) {
520 x_old[id] = x;
521 y_old[id] = y;
524 x_err = x > x_old[id] ? (x - x_old[id]) : (x_old[id] - x);
525 y_err = y > y_old[id] ? (y - y_old[id]) : (y_old[id] - y);
548 x_new = x > x_old[id] ? (x_old[id] + filter_step_x) : (x_old[id] - filter_step_x);
549 y_new = y > y_old[id] ? (y_old[id] + filter_step_y) : (y_old[id] - filter_step_y);
551 x_old[id] = x_new;
552 y_old[id] = y_new;
555 static void record_point(u16 x, u16 y, u8 id)
560 id_sign[id] = id_sign[id] + 1;
562 if (id_sign[id] == 1) {
563 x_old[id] = x;
564 y_old[id] = y;
567 x = (x_old[id] + x) / 2;
568 y = (y_old[id] + y) / 2;
570 if (x > x_old[id])
571 x_err = x - x_old[id];
573 x_err = x_old[id] - x;
575 if (y > y_old[id])
576 y_err = y - y_old[id];
578 y_err = y_old[id] - y;
582 x_old[id] = x;
584 y_old[id] = y;
588 x_old[id] = x;
590 x_new = x_old[id];
595 y_old[id] = y;
597 y_new = y_old[id];
601 if (id_sign[id] == 1) {
602 x_new = x_old[id];
603 y_new = y_old[id];
617 input_report_key(ts->input, key, 1);
618 input_sync(ts->input);
626 static void report_data(struct gsl_ts *ts, u16 x, u16 y, u8 pressure, u8 id)
628 if (ts->flip_x == 1)
629 x = SCREEN_MAX_X - x;
631 if (ts->flip_y == 1)
632 y = SCREEN_MAX_Y - y;
634 if (ts->swap_xy == 1)
637 print_info("#####id=%d,x=%d,y=%d######\n", id, x, y);
647 y = SCREEN_MAX_Y - y;
651 input_mt_slot(ts->input, id);
652 input_report_abs(ts->input, ABS_MT_TRACKING_ID, id);
653 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure);
654 input_report_abs(ts->input, ABS_MT_POSITION_X, x);
655 input_report_abs(ts->input, ABS_MT_POSITION_Y, y);
656 input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1);
658 input_report_abs(ts->input, ABS_MT_TRACKING_ID, id);
659 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure);
660 input_report_abs(ts->input, ABS_MT_POSITION_X, x);
661 input_report_abs(ts->input, ABS_MT_POSITION_Y, y);
662 input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1);
663 input_mt_sync(ts->input);
670 u8 id, touches; local
686 rc = gsl_ts_read(ts->client, 0x80, ts->touch_data, ts->dd->data_size);
688 dev_err(&ts->client->dev, "read failed\n");
692 touches = ts->touch_data[ts->dd->touch_index];
693 print_info("-----touches: %d -----\n", touches);
696 print_info("tp-gsl finger_num = %d\n", cinfo.finger_num);
698 cinfo.x[i] = join_bytes((ts->touch_data[ts->dd->x_index + 4 * i + 1] & 0xf),
699 ts->touch_data[ts->dd->x_index + 4 * i]);
700 cinfo.y[i] = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1],
701 ts->touch_data[ts->dd->y_index + 4 * i]);
702 print_info("tp-gsl x = %d y = %d\n", cinfo.x[i], cinfo.y[i]);
704 cinfo.finger_num = (ts->touch_data[3] << 24) | (ts->touch_data[2] << 16)
705 | (ts->touch_data[1] << 8) | (ts->touch_data[0]);
708 print_info("[tp-gsl] tmp1=%x\n", tmp1);
711 gsl_ts_write(ts->client, 0xf0, buf, 4);
718 gsl_ts_write(ts->client, 0x8, buf, 4);
730 id = cinfo.id[i];
734 x = join_bytes((ts->touch_data[ts->dd->x_index + 4 * i + 1] & 0xf),
735 ts->touch_data[ts->dd->x_index + 4 * i]);
736 y = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1],
737 ts->touch_data[ts->dd->y_index + 4 * i]);
738 id = ts->touch_data[ts->dd->id_index + 4 * i] >> 4;
741 if (1 <= id && id <= MAX_CONTACTS) {
743 filter_point(x, y, id);
745 record_point(x, y, id);
747 report_data(ts, x_new, y_new, 10, id);
748 id_state_flag[id] = 1;
754 input_mt_slot(ts->input, i);
755 input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1);
756 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
764 input_mt_sync(ts->input);
767 input_report_key(ts->input, key, 0);
768 input_sync(ts->input);
774 input_sync(ts->input);
777 enable_irq(ts->irq);
788 disable_irq_nosync(ts->irq);
789 if (!work_pending(&ts->work))
790 queue_work(ts->wq, &ts->work);
795 static int gslX680_ts_init(struct i2c_client *client, struct gsl_ts *ts)
800 ts->dd = &devices[ts->device_id];
802 if (ts->device_id == 0) {
803 ts->dd->data_size = MAX_FINGERS * ts->dd->touch_bytes + ts->dd->touch_meta_data;
804 ts->dd->touch_index = 0;
807 ts->touch_data = devm_kzalloc(&client->dev, ts->dd->data_size, GFP_KERNEL);
808 if (!ts->touch_data) {
810 return -ENOMEM;
815 rc = -ENOMEM;
819 ts->input = input_device;
820 input_device->name = GSLX680_I2C_NAME;
821 input_device->id.bustype = BUS_I2C;
822 input_device->dev.parent = &client->dev;
826 __set_bit(EV_ABS, input_device->evbit);
827 __set_bit(EV_KEY, input_device->evbit);
828 __set_bit(EV_REP, input_device->evbit);
829 __set_bit(INPUT_PROP_DIRECT, input_device->propbit);
833 set_bit(EV_ABS, input_device->evbit);
834 set_bit(EV_KEY, input_device->evbit);
835 __set_bit(INPUT_PROP_DIRECT, input_device->propbit);
836 input_device->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
840 input_device->evbit[0] = BIT_MASK(EV_KEY);
842 set_bit(key_array[i], input_device->keybit);
845 set_bit(ABS_MT_POSITION_X, input_device->absbit);
846 set_bit(ABS_MT_POSITION_Y, input_device->absbit);
847 set_bit(ABS_MT_TOUCH_MAJOR, input_device->absbit);
848 set_bit(ABS_MT_WIDTH_MAJOR, input_device->absbit);
856 client->irq = gts->irq_pin;
857 ts->irq = client->irq;
858 ts->wq = create_singlethread_workqueue("kworkqueue_ts");
859 if (!ts->wq) {
860 dev_err(&client->dev, "Could not create workqueue\n");
863 flush_workqueue(ts->wq);
865 INIT_WORK(&ts->work, gslX680_ts_worker);
874 destroy_workqueue(ts->wq);
878 devm_kfree(&client->dev, ts->touch_data);
888 disable_irq_nosync(ts->irq);
895 input_mt_slot(ts->input, i);
896 input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1);
897 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
900 input_mt_sync(ts->input);
902 input_sync(ts->input);
905 input_sync(ts->input);
918 reset_chip(ts->client);
919 startup_chip(ts->client);
920 check_mem_data(ts->client);
925 input_mt_slot(ts->input, i);
926 input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1);
927 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
930 input_mt_sync(ts->input);
932 input_sync(ts->input);
934 enable_irq(ts->irq);
944 gsl_ts_suspend(&ts->client->dev);
951 gsl_ts_resume(&ts->client->dev);
955 static int gsl_ts_probe(struct i2c_client *client,
956 const struct i2c_device_id *id)
963 struct device_node *np = client->dev.of_node;
968 ret = i2c_master_recv(client, &buffer, 1);
971 timer--;
978 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
979 dev_err(&client->dev, "I2C functionality not supported\n");
980 return -ENODEV;
983 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
985 return -ENOMEM;
987 ts->client = client;
988 i2c_set_clientdata(client, ts);
989 ts->device_id = 0;
990 ts->tp.tp_resume = rk_ts_early_resume;
991 ts->tp.tp_suspend = rk_ts_early_suspend;
992 tp_register_fb(&ts->tp);
994 ts->irq_pin = of_get_named_gpio_flags(np, "touch-gpio", 0, (enum of_gpio_flags *)&irq_flags);
995 ts->rst_pin = of_get_named_gpio_flags(np, "reset-gpio", 0, &rst_flags);
996 if (of_property_read_u32(np, "flip-x", &ts->flip_x) < 0)
997 ts->flip_x = 0;
999 if (of_property_read_u32(np, "flip-y", &ts->flip_y) < 0)
1000 ts->flip_y = 0;
1002 if (of_property_read_u32(np, "swap-xy", &ts->swap_xy) < 0)
1003 ts->swap_xy = 0;
1005 if (gpio_is_valid(ts->rst_pin)) {
1006 ts->rst_val = (rst_flags & OF_GPIO_ACTIVE_LOW) ? 0 : 1;
1007 …ret = devm_gpio_request_one(&client->dev, ts->rst_pin, (rst_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OU…
1009 dev_err(&client->dev, "goodix gpio_request error\n");
1010 return -EIO;
1012 gpio_direction_output(ts->rst_pin, 0);
1013 gpio_set_value(ts->rst_pin, GPIO_HIGH);
1016 dev_info(&client->dev, "reset pin invalid\n");
1020 rc = gslX680_ts_init(client, ts);
1022 dev_err(&client->dev, "GSLX680 init failed\n");
1026 gsl_client = client;
1029 judge_chip_type(ts->client);
1031 init_chip(ts->client);
1032 check_mem_data(ts->client);
1034 ts->irq = gpio_to_irq(ts->irq_pin); /*If not defined in client*/
1035 if (ts->irq) {
1036 rc = devm_request_threaded_irq(&client->dev, ts->irq, NULL,
1037 gsl_ts_irq, irq_flags | IRQF_ONESHOT, client->name, ts);
1045 ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
1046 ts->early_suspend.suspend = gsl_ts_early_suspend;
1047 ts->early_suspend.resume = gsl_ts_late_resume;
1048 register_early_suspend(&ts->early_suspend);
1056 gsl_config_proc->read_proc = gsl_config_read_proc;
1057 gsl_config_proc->write_proc = gsl_config_write_proc;
1064 free_irq(ts->irq, ts);
1067 input_free_device(ts->input);
1068 devm_kfree(&client->dev, ts);
1072 static int gsl_ts_remove(struct i2c_client *client)
1074 struct gsl_ts *ts = i2c_get_clientdata(client);
1077 unregister_early_suspend(&ts->early_suspend);
1079 device_init_wakeup(&client->dev, 0);
1080 cancel_work_sync(&ts->work);
1081 free_irq(ts->irq, ts);
1082 destroy_workqueue(ts->wq);
1083 input_unregister_device(ts->input);
1085 devm_kfree(&client->dev, ts->touch_data);
1086 devm_kfree(&client->dev, ts);