.. | .. |
---|
84 | 84 | static int revert_x_flag = 0; |
---|
85 | 85 | static int revert_y_flag = 0; |
---|
86 | 86 | static int exchange_x_y_flag = 0; |
---|
| 87 | +static int gtp_send_cfgs = 0; |
---|
87 | 88 | static __u32 twi_id = 0; |
---|
88 | 89 | static char irq_pin_name[8]; |
---|
89 | 90 | |
---|
.. | .. |
---|
171 | 172 | dprintk(DEBUG_INIT,"info.exchange_x_y_flag:%d\n",info.exchange_x_y_flag); |
---|
172 | 173 | dprintk(DEBUG_INIT,"info.irq_gpio_number:%d\n",info.irq_gpio.gpio); |
---|
173 | 174 | 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; |
---|
174 | 194 | } |
---|
175 | 195 | } |
---|
176 | 196 | |
---|
.. | .. |
---|
345 | 365 | { |
---|
346 | 366 | s32 ret = 0; |
---|
347 | 367 | |
---|
348 | | -#if GTP_DRIVER_SEND_CFG |
---|
| 368 | +if( gtp_send_cfgs == 1 ) { |
---|
349 | 369 | s32 retry = 0; |
---|
350 | 370 | |
---|
351 | 371 | for (retry = 0; retry < 5; retry++) |
---|
352 | 372 | { |
---|
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 | + } |
---|
358 | 378 | } |
---|
359 | | -#endif |
---|
| 379 | + } |
---|
360 | 380 | |
---|
361 | 381 | return ret; |
---|
362 | 382 | } |
---|
.. | .. |
---|
768 | 788 | static s32 gtp_init_panel(struct goodix_ts_data *ts) |
---|
769 | 789 | { |
---|
770 | 790 | 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"); |
---|
771 | 794 | |
---|
772 | | -#if GTP_DRIVER_SEND_CFG |
---|
773 | 795 | s32 i; |
---|
774 | 796 | u8 check_sum = 0; |
---|
775 | 797 | u8 rd_cfg_buf[16]; |
---|
.. | .. |
---|
870 | 892 | GTP_DEBUG("gt9xx:index = %d\n",index); |
---|
871 | 893 | } |
---|
872 | 894 | |
---|
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."); |
---|
877 | 903 | 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 | +} |
---|
879 | 909 | |
---|
880 | 910 | #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 | + |
---|
885 | 924 | |
---|
886 | 925 | if (GTP_INT_TRIGGER == 0) //RISING |
---|
887 | 926 | { |
---|
.. | .. |
---|
900 | 939 | } |
---|
901 | 940 | config[ts->gtp_cfg_len] = (~check_sum) + 1; |
---|
902 | 941 | |
---|
903 | | -#else //else DRIVER NEED NOT SEND CONFIG |
---|
| 942 | +}else{ //else DRIVER NEED NOT SEND CONFIG |
---|
904 | 943 | |
---|
905 | 944 | if(ts->gtp_cfg_len == 0) |
---|
906 | 945 | { |
---|
.. | .. |
---|
914 | 953 | ts->abs_y_max = GTP_MAX_HEIGHT; |
---|
915 | 954 | ts->int_trigger_type = GTP_INT_TRIGGER; |
---|
916 | 955 | } |
---|
917 | | -#endif //endif GTP_DRIVER_SEND_CFG |
---|
| 956 | +} |
---|
918 | 957 | |
---|
919 | 958 | GTP_DEBUG_FUNC(); |
---|
920 | 959 | |
---|
.. | .. |
---|
932 | 971 | ret = gtp_send_cfg(ts->client); |
---|
933 | 972 | if (ret < 0) |
---|
934 | 973 | { |
---|
935 | | - printk("\ngandy-----send config error.ret=%d\n",ret); |
---|
| 974 | + GTP_DEBUG("\ngandy-----send config error.ret=%d\n",ret); |
---|
936 | 975 | GTP_ERROR("Send config error."); |
---|
937 | 976 | } |
---|
938 | | -printk("X_MAX = %d,Y_MAX = %d,TRIGGER = 0x%02x", |
---|
| 977 | +GTP_DEBUG("X_MAX = %d,Y_MAX = %d,TRIGGER = 0x%02x", |
---|
939 | 978 | ts->abs_x_max,ts->abs_y_max,ts->int_trigger_type); |
---|
940 | 979 | |
---|
941 | 980 | msleep(10); |
---|
.. | .. |
---|
1588 | 1627 | of_property_read_u32(np, "ctp_revert_x_flag", &revert_x_flag); |
---|
1589 | 1628 | of_property_read_u32(np, "ctp_revert_y_flag", &revert_y_flag); |
---|
1590 | 1629 | of_property_read_u32(np, "ctp_exchange_x_y_flag", &exchange_x_y_flag); |
---|
| 1630 | + of_property_read_u32(np, "gtp_send_cfgs", >p_send_cfgs); |
---|
1591 | 1631 | #endif |
---|
1592 | 1632 | sunxi_gpio_to_name(CTP_IRQ_NUMBER,irq_pin_name); |
---|
1593 | 1633 | pr_err("gt %s, line:%d irq_pin_name = %s \n",__FUNCTION__, __LINE__, irq_pin_name); |
---|