1 #include "sample_comm.h" 2 uapi_usage_show(uapi_case_t * uapi_list)3int uapi_usage_show(uapi_case_t* uapi_list) 4 { 5 int case_i = 0; 6 7 if (!uapi_list) { 8 return -1; 9 } 10 11 CLEAR(); 12 printf("Usage <key>:\n"); 13 14 while (1) { 15 if (!uapi_list[case_i].desc) { 16 break; 17 } 18 19 if (uapi_list[case_i].desc) { 20 printf("\t\t%c) %s.\n", '0' + case_i, uapi_list[case_i].desc); 21 } 22 23 case_i++; 24 } 25 26 return 0; 27 } 28 uapi_list_count(uapi_case_t * uapi_list)29int uapi_list_count(uapi_case_t* uapi_list) 30 { 31 int case_i = 0; 32 while (1) { 33 if (!uapi_list[case_i].desc) { 34 break; 35 } 36 case_i++; 37 } 38 39 return case_i; 40 } 41 uapi_process_loop(const rk_aiq_sys_ctx_t * ctx,uapi_case_t * uapi_list)42int uapi_process_loop(const rk_aiq_sys_ctx_t* ctx, uapi_case_t* uapi_list) 43 { 44 int key = -1; 45 int max_key = -1; 46 47 max_key = uapi_list_count(uapi_list); 48 49 uapi_usage_show(uapi_list); 50 51 do { 52 printf("\t please press the key: "); 53 key = getchar(); 54 while (key == '\n' || key == '\r') 55 key = getchar(); 56 printf("\n"); 57 58 if (key == 'h') { 59 uapi_usage_show(uapi_list); 60 continue; 61 } 62 63 if (key - '0' > max_key) { 64 printf("\t invalid input key:[%c]\n", key); 65 continue; 66 } 67 68 if (!uapi_list[key - '0'].func) { 69 printf("\t invalid function for key:[%c]\n", key); 70 continue; 71 } 72 73 uapi_list[key - '0'].func(ctx); 74 75 } while (key != 'q' && key != 'Q'); 76 77 return XCAM_RETURN_NO_ERROR; 78 } 79