diff --git a/drivers/input/touchscreen/chipone_tddi_v2_mmi/cts_test.c b/drivers/input/touchscreen/chipone_tddi_v2_mmi/cts_test.c index 3d514ef550fa..b3512c008153 100644 --- a/drivers/input/touchscreen/chipone_tddi_v2_mmi/cts_test.c +++ b/drivers/input/touchscreen/chipone_tddi_v2_mmi/cts_test.c @@ -665,25 +665,21 @@ static int wait_fw_to_curr_mode(struct cts_device *cts_dev) { int i = 0; int ret; - + u8 work_mode; cts_info("Wait fw to curr work mode"); do { - u8 work_mode; - ret = cts_tcs_get_curr_mode(cts_dev, &work_mode); if (ret) { cts_err("Get fw curr work mode failed %d", work_mode); continue; - } else { - if (work_mode == CTS_FIRMWARE_WORK_MODE_OPEN_SHORT) + } else if (work_mode == CTS_FIRMWARE_WORK_MODE_OPEN_SHORT) { return 0; } - mdelay(10); } while (++i < 100); - - return ret ? ret : -ETIMEDOUT; + cts_err("Get work_mode: %d != %d", work_mode, CTS_FIRMWARE_WORK_MODE_OPEN_SHORT); + return -ETIMEDOUT; } #endif static int prepare_test(struct cts_device *cts_dev) @@ -692,6 +688,9 @@ static int prepare_test(struct cts_device *cts_dev) #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) int i = 0; u8 workmode = -1; +#else + int i = 0; + u8 workmode = -1; #endif cts_info("Prepare test"); @@ -723,7 +722,22 @@ static int prepare_test(struct cts_device *cts_dev) workmode, CTS_FIRMWARE_WORK_MODE_CFG, i); } while (i++ < 10); if (workmode != CTS_FIRMWARE_WORK_MODE_CFG) - return -EINVAL; + return -EINVAL; +#else + mdelay(30); + do { + ret = cts_tcs_get_workmode(cts_dev, &workmode); + if (ret) { + cts_err("Get real workmode to FACTORY MODE failed %d", ret); + } else if (workmode == CTS_FIRMWARE_WORK_MODE_CFG) { + break; + } + mdelay(30); + cts_err("Get workmode: %d, CTS_FIRMWARE_WORK_MODE_CFG: %d, retry count: %d", + workmode, CTS_FIRMWARE_WORK_MODE_CFG, i); + } while (i++ < 10); + if (workmode != CTS_FIRMWARE_WORK_MODE_CFG) + return -EINVAL; #endif ret = cts_tcs_set_product_en(cts_dev, 1); @@ -977,7 +991,8 @@ int cts_test_rawdata(struct cts_device *cts_dev, struct cts_test_param *param) int frame = 0; int count = 3; #else - int frame; + int frame = 0; + int count = 3; #endif int fail_frame = 0; @@ -1053,6 +1068,8 @@ int cts_test_rawdata(struct cts_device *cts_dev, struct cts_test_param *param) cts_lock_device(cts_dev); #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) try_again: +#else +try_again: #endif ret = prepare_test(cts_dev); if (ret) { @@ -1060,7 +1077,7 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) goto prepare_try; #else - goto unlock; + goto prepare_try; #endif } @@ -1116,9 +1133,7 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) prepare_try: #else - if (dump_test_data_to_file) { - cts_stop_dump_test_data_to_file(); - } +prepare_try: #endif post_test(cts_dev); cts_set_int_data_method(cts_dev, INT_DATA_METHOD_NONE); @@ -1136,7 +1151,17 @@ prepare_try: cts_stop_dump_test_data_to_file(); } #else -unlock: + if (ret < 0 && count--) { + if (dump_test_data_to_user) { + *param->test_data_wr_size = 0; + rawdata = (u16 *) param->test_data_buf; + } + goto try_again; + } + + if (dump_test_data_to_file) { + cts_stop_dump_test_data_to_file(); + } #endif cts_unlock_device(cts_dev); { @@ -1182,7 +1207,7 @@ int cts_test_noise(struct cts_device *cts_dev, struct cts_test_param *param) #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) int frame = 0; #else - int frame; + int frame = 0; #endif u16 *buffer = NULL; int buf_size = 0; @@ -1197,6 +1222,8 @@ int cts_test_noise(struct cts_device *cts_dev, struct cts_test_param *param) int ret; #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) int count = 3; +#else + int count = 3; #endif if (cts_dev == NULL || param == NULL || @@ -1268,6 +1295,8 @@ int cts_test_noise(struct cts_device *cts_dev, struct cts_test_param *param) cts_lock_device(cts_dev); #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) try_again: +#else +try_again: #endif ret = prepare_test(cts_dev); if (ret) { @@ -1275,7 +1304,7 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) goto prepare_try; #else - goto unlock; + goto prepare_try; #endif } @@ -1301,7 +1330,7 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) goto prepare_try; #else - goto disable_get_tsdata; + goto prepare_try; #endif } @@ -1338,10 +1367,7 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) prepare_try: #else -disable_get_tsdata: - if (dump_test_data_to_file) { - cts_stop_dump_test_data_to_file(); - } +prepare_try: #endif post_test(cts_dev); cts_set_int_data_method(cts_dev, INT_DATA_METHOD_NONE); @@ -1358,7 +1384,16 @@ disable_get_tsdata: cts_stop_dump_test_data_to_file(); } #else -unlock: + if (ret < 0 && count--) { + if (dump_test_data_to_user) { + *param->test_data_wr_size = 0; + } + goto try_again; + } + + if (dump_test_data_to_file) { + cts_stop_dump_test_data_to_file(); + } #endif cts_unlock_device(cts_dev); { @@ -1432,6 +1467,8 @@ int cts_test_open(struct cts_device *cts_dev, struct cts_test_param *param) int ret; #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) int count = 3; +#else + int count = 3; #endif u16 *test_result = NULL; bool recovery_display_state = false; @@ -1488,6 +1525,8 @@ int cts_test_open(struct cts_device *cts_dev, struct cts_test_param *param) cts_lock_device(cts_dev); #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) try_again: +#else +try_again: #endif ret = prepare_test(cts_dev); if (ret) { @@ -1522,11 +1561,11 @@ try_again: goto err_recovery_display_state; } - ret = wait_fw_to_curr_mode(cts_dev); - if (ret) { + ret = wait_fw_to_curr_mode(cts_dev); + if (ret) { cts_err("wait_to_curr_mode failed %d", ret); goto err_recovery_display_state; - } + } cts_set_int_data_types(cts_dev, INT_DATA_TYPE_RAWDATA); cts_set_int_data_method(cts_dev, INT_DATA_METHOD_POLLING); @@ -1585,6 +1624,14 @@ err_free_test_result: } goto try_again; } +#else + if (ret < 0 && count--) { + if (dump_test_data_to_user) { + *param->test_data_wr_size = 0; + test_result = (u16 *) param->test_data_buf; + } + goto try_again; + } #endif #ifdef CONFIG_CTS_CHARGER_DETECT @@ -1657,6 +1704,8 @@ int cts_test_short(struct cts_device *cts_dev, struct cts_test_param *param) int loopcnt; #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) int count = 3; +#else + int count = 3; #endif int ret; u16 *test_result = NULL; @@ -1716,6 +1765,8 @@ int cts_test_short(struct cts_device *cts_dev, struct cts_test_param *param) cts_lock_device(cts_dev); #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) try_again: +#else +try_again: #endif ret = prepare_test(cts_dev); if (ret) { @@ -1723,7 +1774,7 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) goto prepare_try; #else - goto unlock_device; + goto prepare_try; #endif } ret = cts_tcs_is_display_on(cts_dev, &need_display_on); @@ -1732,7 +1783,7 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) goto prepare_try; #else - goto err_free_test_result; + goto prepare_try; #endif } @@ -1743,7 +1794,7 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) goto recovery_display_state; #else - goto err_free_test_result; + goto recovery_display_state; #endif } recovery_display_state = true; @@ -1755,7 +1806,7 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) cts_err("Set short test type failed %d", ret); #else - cts_err("Set short test type to SHORT_TO_GND failed %d", ret); + cts_err("Set short test type failed %d", ret); #endif goto recovery_display_state; } @@ -1784,7 +1835,7 @@ try_again: cts_err("Set short test type to SHORT_TO_GND failed %d", ret); goto recovery_display_state; } - + ret = cts_tcs_polling_test_data(cts_dev, (u8 *)test_result, RAWDATA_BUFFER_SIZE(cts_dev)); if (ret) { @@ -1814,7 +1865,7 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) goto recovery_display_state; #else - goto stop_dump_test_data_to_file; + goto recovery_display_state; #endif } } @@ -1864,17 +1915,14 @@ try_again: } /* Short between rows */ - cts_info("Test short between rows"); - ret = cts_tcs_set_short_test_type(cts_dev, CTS_SHORT_TEST_BETWEEN_ROWS); - if (ret) { - cts_err("Set short test type to BETWEEN_ROWS failed %d", ret); - goto recovery_display_state; - } + ret = cts_tcs_set_short_test_type(cts_dev, CTS_SHORT_TEST_BETWEEN_ROWS); + if (ret) { + cts_err("Set short test type to BETWEEN_ROWS failed %d", ret); + goto recovery_display_state; + } - for (loopcnt = 0; loopcnt < SHORT_ROWS_TEST_LOOP; loopcnt++) { - ret = cts_tcs_polling_test_data(cts_dev, (u8 *)test_result, RAWDATA_BUFFER_SIZE(cts_dev)); if (ret) { @@ -1924,17 +1972,23 @@ prepare_try: goto try_again; } #else -stop_dump_test_data_to_file: +prepare_try: + post_test(cts_dev); + cts_set_int_data_method(cts_dev, old_int_data_method); + cts_set_int_data_types(cts_dev, old_int_data_types); + + if (ret < 0 && count--) { + if (dump_test_data_to_user) { + *param->test_data_wr_size = 0; + test_result = (u16 *) param->test_data_buf; + } + goto try_again; + } #endif if (dump_test_data_to_file) { cts_stop_dump_test_data_to_file(); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0) - post_test(cts_dev); - cts_set_int_data_method(cts_dev, old_int_data_method); - cts_set_int_data_types(cts_dev, old_int_data_types); -#endif #ifdef CONFIG_CTS_CHARGER_DETECT if (cts_is_charger_exist(cts_dev)) { int r = cts_set_dev_charger_attached(cts_dev, true); @@ -1963,9 +2017,7 @@ stop_dump_test_data_to_file: cts_enable_fw_log_redirect(cts_dev); } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0) -unlock_device: -#endif + cts_unlock_device(cts_dev); cts_start_device(cts_dev); @@ -2148,6 +2200,8 @@ int cts_test_compensate_cap(struct cts_device *cts_dev, int num_nodes; #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) int count = 3; +#else + int count = 3; #endif u8 *cap = NULL; int ret = 0; @@ -2203,6 +2257,8 @@ int cts_test_compensate_cap(struct cts_device *cts_dev, cts_lock_device(cts_dev); #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) try_again: +#else +try_again: #endif ret = prepare_test(cts_dev); if (ret) { @@ -2210,19 +2266,22 @@ try_again: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) goto prepare_try; #else - goto unlock_device; + goto prepare_try; #endif } ret = cts_tcs_top_get_cnegdata(cts_dev, cap, num_nodes); #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) prepare_try: #else -unlock_device: +prepare_try: #endif post_test(cts_dev); #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0) if (ret && count--) goto try_again; +#else + if (ret && count--) + goto try_again; #endif cts_unlock_device(cts_dev);