lin
2025-04-23 399353eb5dc7e9c1db94cc97c380dc7f66c51a4c
longan/kernel/linux-4.9/drivers/input/touchscreen/gt9xx/gt9xx.c
....@@ -84,6 +84,7 @@
8484 static int revert_x_flag = 0;
8585 static int revert_y_flag = 0;
8686 static int exchange_x_y_flag = 0;
87
+static int gtp_send_cfgs = 0;
8788 static __u32 twi_id = 0;
8889 static char irq_pin_name[8];
8990
....@@ -171,6 +172,25 @@
171172 dprintk(DEBUG_INIT,"info.exchange_x_y_flag:%d\n",info.exchange_x_y_flag);
172173 dprintk(DEBUG_INIT,"info.irq_gpio_number:%d\n",info.irq_gpio.gpio);
173174 dprintk(DEBUG_INIT,"info.wakeup_gpio_number:%d\n",info.wakeup_gpio.gpio);
175
+ }
176
+}
177
+
178
+int gtp_parse_dt_cfg(struct device *dev, u8 *cfg, int *cfg_len, u8 sid)
179
+{
180
+ struct device_node *np = dev->of_node;
181
+ struct property *prop;
182
+ char cfg_name[18];
183
+
184
+ //rdzkj add for compatible of different screen by sensor_id
185
+ snprintf(cfg_name, sizeof(cfg_name), "goodix,cfg-group%d", sid);
186
+ GTP_INFO("get %s",cfg_name);
187
+ prop = of_find_property(np, cfg_name, cfg_len);
188
+ //add end
189
+ if (!prop || !prop->value || *cfg_len == 0 || *cfg_len > GTP_CONFIG_MAX_LENGTH) {
190
+ return -1;/* failed */
191
+ } else {
192
+ memcpy(cfg, prop->value, *cfg_len);
193
+ return 0;
174194 }
175195 }
176196
....@@ -345,18 +365,18 @@
345365 {
346366 s32 ret = 0;
347367
348
-#if GTP_DRIVER_SEND_CFG
368
+if( gtp_send_cfgs == 1 ) {
349369 s32 retry = 0;
350370
351371 for (retry = 0; retry < 5; retry++)
352372 {
353
- //ret = gtp_i2c_write(client, config , GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH);
354
- // if (ret > 0)
355
- // {
356
- // break;
357
- // }
373
+ ret = gtp_i2c_write(client, config , GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH);
374
+ if (ret > 0)
375
+ {
376
+ break;
377
+ }
358378 }
359
-#endif
379
+ }
360380
361381 return ret;
362382 }
....@@ -768,8 +788,10 @@
768788 static s32 gtp_init_panel(struct goodix_ts_data *ts)
769789 {
770790 s32 ret = -1;
791
+if ( gtp_send_cfgs == 1) // Device tree determines whether to send_cfgs
792
+{
793
+ GTP_DEBUG("gtp_send_cfgs==1 into send_cfgs");
771794
772
-#if GTP_DRIVER_SEND_CFG
773795 s32 i;
774796 u8 check_sum = 0;
775797 u8 rd_cfg_buf[16];
....@@ -870,18 +892,35 @@
870892 GTP_DEBUG("gt9xx:index = %d\n",index);
871893 }
872894
873
-printk("config send_cfg_buf******** \n");
874
-//index = rd_cfg_buf[GTP_ADDR_LENGTH];
875
-ts->gtp_cfg_len = cfg_info_len[index];
876
-GTP_DEBUG("gandy---SENSOR ID:%d\n", rd_cfg_buf[GTP_ADDR_LENGTH]);
895
+// printk("config send_cfg_buf******** \n");
896
+// //index = rd_cfg_buf[GTP_ADDR_LENGTH];
897
+// ts->gtp_cfg_len = cfg_info_len[index];
898
+// GTP_DEBUG("gandy---SENSOR ID:%d\n", rd_cfg_buf[GTP_ADDR_LENGTH]);
899
+// memset(&config[GTP_ADDR_LENGTH], 0, GTP_CONFIG_MAX_LENGTH);
900
+// memcpy(&config[GTP_ADDR_LENGTH], send_cfg_buf[index], ts->gtp_cfg_len);
901
+
902
+GTP_DEBUG("Get config data from device tree.");
877903 memset(&config[GTP_ADDR_LENGTH], 0, GTP_CONFIG_MAX_LENGTH);
878
-memcpy(&config[GTP_ADDR_LENGTH], send_cfg_buf[index], ts->gtp_cfg_len);
904
+ret = gtp_parse_dt_cfg(&ts->client->dev, &config[GTP_ADDR_LENGTH], &ts->gtp_cfg_len, 0);
905
+if (ret < 0) {
906
+ GTP_ERROR("Failed to parse config data form device tree.");
907
+ return -1;
908
+}
879909
880910 #if GTP_CUSTOM_CFG
881
-config[RESOLUTION_LOC] = (u8)GTP_MAX_WIDTH;
882
-config[RESOLUTION_LOC + 1] = (u8)(GTP_MAX_WIDTH>>8);
883
-config[RESOLUTION_LOC + 2] = (u8)GTP_MAX_HEIGHT;
884
-config[RESOLUTION_LOC + 3] = (u8)(GTP_MAX_HEIGHT>>8);
911
+if ( exchange_x_y_flag == 1 ) {
912
+ config[RESOLUTION_LOC] = (u8)screen_max_y;
913
+ config[RESOLUTION_LOC + 1] = (u8)(screen_max_y>>8);
914
+ config[RESOLUTION_LOC + 2] = (u8)screen_max_x;
915
+ config[RESOLUTION_LOC + 3] = (u8)(screen_max_x>>8);
916
+}
917
+else {
918
+ config[RESOLUTION_LOC] = (u8)screen_max_x;
919
+ config[RESOLUTION_LOC + 1] = (u8)(screen_max_x>>8);
920
+ config[RESOLUTION_LOC + 2] = (u8)screen_max_y;
921
+ config[RESOLUTION_LOC + 3] = (u8)(screen_max_y>>8);
922
+}
923
+
885924
886925 if (GTP_INT_TRIGGER == 0) //RISING
887926 {
....@@ -900,7 +939,7 @@
900939 }
901940 config[ts->gtp_cfg_len] = (~check_sum) + 1;
902941
903
-#else //else DRIVER NEED NOT SEND CONFIG
942
+}else{ //else DRIVER NEED NOT SEND CONFIG
904943
905944 if(ts->gtp_cfg_len == 0)
906945 {
....@@ -914,7 +953,7 @@
914953 ts->abs_y_max = GTP_MAX_HEIGHT;
915954 ts->int_trigger_type = GTP_INT_TRIGGER;
916955 }
917
-#endif //endif GTP_DRIVER_SEND_CFG
956
+}
918957
919958 GTP_DEBUG_FUNC();
920959
....@@ -932,10 +971,10 @@
932971 ret = gtp_send_cfg(ts->client);
933972 if (ret < 0)
934973 {
935
- printk("\ngandy-----send config error.ret=%d\n",ret);
974
+ GTP_DEBUG("\ngandy-----send config error.ret=%d\n",ret);
936975 GTP_ERROR("Send config error.");
937976 }
938
-printk("X_MAX = %d,Y_MAX = %d,TRIGGER = 0x%02x",
977
+GTP_DEBUG("X_MAX = %d,Y_MAX = %d,TRIGGER = 0x%02x",
939978 ts->abs_x_max,ts->abs_y_max,ts->int_trigger_type);
940979
941980 msleep(10);
....@@ -1588,6 +1627,7 @@
15881627 of_property_read_u32(np, "ctp_revert_x_flag", &revert_x_flag);
15891628 of_property_read_u32(np, "ctp_revert_y_flag", &revert_y_flag);
15901629 of_property_read_u32(np, "ctp_exchange_x_y_flag", &exchange_x_y_flag);
1630
+ of_property_read_u32(np, "gtp_send_cfgs", &gtp_send_cfgs);
15911631 #endif
15921632 sunxi_gpio_to_name(CTP_IRQ_NUMBER,irq_pin_name);
15931633 pr_err("gt %s, line:%d irq_pin_name = %s \n",__FUNCTION__, __LINE__, irq_pin_name);