/*************************************************************************** * Copyright (c) 2012, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: HD DTA unit test application * * Revision History: * * $brcm_Log: $ * * ***************************************************************************/ #include "bstd.h" #include "bkni.h" #include "bdbg.h" #include "ministd.h" #include "gist.h" #include "serial.h" #include "test_capture.h" #include "bsettop_smessage.h" #include "test_a56.h" void menu_level1(void); void menu_tune(void); void menu_tscap(void); void menu_decode(void); void menu_a56_test(void); #ifdef OOB_TUNER_SUPPORT #include "test_oob.h" void menu_oob_test(void); #endif #include "test_tuner.h" unsigned int menu_read_number(void); #define MENU_DELIMETER() BKNI_Printf("*************************************\n") void do_test(void * para) { unsigned int ca_system_id; BERR_Code berr; ca_system_id = 0x0; berr = gist_rap_open(ca_system_id, NULL); if(BERR_SUCCESS != berr){ BKNI_Printf("gist_rap_open failed\n"); } /* function name is kind of misleading since it hook whatever the tuner underneath, it can be QAM, VSB, ISDB-T */ if (!qam_tuner_init()) { BKNI_Printf("QAM tuner open failed\n"); } smessage_init(NULL); a56_init(); menu_level1(); __asm__("sdbbp"); } void menu_level1(void) { int input; int exit_menu = 0; while(0 == exit_menu){ MENU_DELIMETER(); BKNI_Printf("Menu Level 1\n"); BKNI_Printf("1 - PSI Filter Tests\n"); BKNI_Printf("2 - Tune\n"); BKNI_Printf("3 - Transport Capture\n"); BKNI_Printf("4 - Decode Video/Audio\n"); #ifdef OOB_TUNER_SUPPORT BKNI_Printf("5 - OOB tuner\n"); #endif BKNI_Printf("6 - A56 Test\n"); #ifdef CONFIG_NXP_TDA182I4 BKNI_Printf("7 - NXP tuner test\n"); #endif BKNI_Printf("> "); input = serial_getc(CONSOLE_UART, true); BKNI_Printf("%c\n", input); switch(input){ case '1': BKNI_Printf("Not implemented yet\n"); //menu_psi(); break; case '2': menu_tune(); break; case '3': BKNI_Printf("Not implemented yet\n"); //menu_tscap(); break; case '4': BKNI_Printf("Not implemented yet\n"); //menu_decode(); break; #ifdef OOB_TUNER_SUPPORT case '5': //menu_oob_test(); BKNI_Printf("Not implemented yet\n"); break; #endif case '6': menu_a56_test(); break; #ifdef CONFIG_NXP_TDA182I4 /* implemented in the bsettop_tuner_vsb.c */ extern void NXP_tuner_test(void); case '7': NXP_tuner_test(); break; #endif default: break; } } } void menu_psi(void) { int input; int exit_menu = 0; while(0 == exit_menu){ MENU_DELIMETER(); BKNI_Printf("Menu Level 2 - PSI\n"); BKNI_Printf("1 - Receive PSI filter setup\n"); BKNI_Printf("2 - Start PSI filters\n"); BKNI_Printf("3 - Stop PSI filters\n"); BKNI_Printf("4 - Display statistics\n"); BKNI_Printf("5 - Reset statistics\n"); BKNI_Printf("6 - Display last 1000 messages\n"); BKNI_Printf("7 - Display PSI filter setup\n"); BKNI_Printf("0 - Return to previous menu\n"); BKNI_Printf("> "); input = serial_getc(CONSOLE_UART, true); BKNI_Printf("%c\n", input); switch(input){ case '1': //ft_receive_filters(); break; case '2': //ft_start_filters(); break; case '3': //ft_stop_filters(); break; case '4': //ft_display_stats(); break; case '5': //ft_reset_stats(); break; case '6': //ft_dump_message(); break; case '7': //ft_dump_filters(); break; case '0': exit_menu = 1; break; } } } void menu_tune(void) { int input; int exit_menu = 0; while(0 == exit_menu){ MENU_DELIMETER(); BKNI_Printf("Menu Level 2 - Tuner\n"); #ifdef CONFIG_VSB BKNI_Printf("1 - Tune To a VSB Frequency\n"); BKNI_Printf("2 - Get Tune Status\n"); BKNI_Printf("3 - Start VSB Message Filtering\n"); BKNI_Printf("4 - Stop VSB Message Filtering\n"); BKNI_Printf("5 - VSB Channel Scan (scan ATSC frequency and get PAT)\n"); #else BKNI_Printf("1 - Tune To a QAM Frequency\n"); BKNI_Printf("2 - Get Tune Status\n"); BKNI_Printf("3 - Start QAM Message Filtering\n"); BKNI_Printf("4 - Stop QAM Message Filtering\n"); #endif BKNI_Printf("0 - Return to previous menu\n"); BKNI_Printf("> "); input = serial_getc(CONSOLE_UART, true); BKNI_Printf("%c\n", input); switch(input){ case '1': BKNI_Printf("Please input tune frequency in KHz ?\n"); input = menu_read_number(); qam_tune(input * 1000); break; case '2': qam_get_status(); break; break; case '3': BKNI_Printf("Please input PID to get message from ?\n"); input = menu_read_number(); BKNI_Printf("Pid = %d\n", input); qam_start_message(input); break; case '4': qam_stop_message(); break; #ifdef CONFIG_VSB case '5': break; #endif case '0': qam_stop_message(); exit_menu = 1; } } } void menu_tscap(void) { int input; int exit_menu = 0; while(0 == exit_menu){ MENU_DELIMETER(); BKNI_Printf("Menu Level 2 - Transport Capture\n"); BKNI_Printf("1 - Enter Capture Parameters\n"); BKNI_Printf("2 - Start Capture\n"); BKNI_Printf("3 - Stop Capture\n"); BKNI_Printf("4 - Display Data\n"); BKNI_Printf("0 - Return to previous menu\n"); BKNI_Printf("> "); input = serial_getc(CONSOLE_UART, true); BKNI_Printf("%c\n", input); switch(input){ case '1': //tcap_parameters(); break; case '2': //tcap_start(); break; case '3': //tcap_stop(); break; case '4': //tcap_display(); break; case '0': exit_menu = 1; break; } } } void menu_decode(void) { int input; int exit_menu = 0; while(0 == exit_menu){ MENU_DELIMETER(); BKNI_Printf("Menu Level 2 - Program Decode\n"); BKNI_Printf("1 - Enter Decode Parameters\n"); BKNI_Printf("2 - Start Decode\n"); BKNI_Printf("3 - Stop Decode\n"); BKNI_Printf("4 - Decode Default Parameters\n"); BKNI_Printf("0 - Return to previous menu\n"); BKNI_Printf("> "); input = serial_getc(CONSOLE_UART, true); BKNI_Printf("%c\n", input); switch(input){ case '1': //comm_decode_params(); break; case '2': //comm_decode_start(); break; case '3': //comm_decode_stop(); break; case '4': //comm_decode_params_default(); break; case '0': exit_menu = 1; break; } } } #define MENU_CR '\xd' #define MENU_BS '\x8' enum im_token_t { IMT_OTHER, IMT_DIGIT, IMT_XDIGIT, IMT_CR, IMT_X, IMT_BS }; enum im_token_t im_tokenize(int ch) { if(('0' <= ch) && ('9' >= ch)){ return IMT_DIGIT; } if(('A' <= ch) && ('F' >= ch)){ return IMT_XDIGIT; } if(('a' <= ch) && ('f' >= ch)){ return IMT_XDIGIT; } switch(ch){ case 'x': case 'X': return IMT_X; case MENU_CR: return IMT_CR; case MENU_BS: return IMT_BS; } return IMT_OTHER; } #define IN_MAX 32 extern long strtol(const char *str, char **endptr, int base); /* read hex or decimal number */ unsigned int menu_read_number(void) { int input; int radix; unsigned value; enum im_token_t tok; int accept; char input_str[IN_MAX]; char * input_end; value = 0; radix = 10; input_end = input_str; do { accept = 0; input = serial_getc(CONSOLE_UART, true); tok = im_tokenize(input); switch(tok){ case IMT_XDIGIT: if(0x10 == radix){ accept = 1; } break; case IMT_DIGIT: accept = 1; break; case IMT_X: if(10 == radix){ if((input_str[0] = '0') && (input_end == &input_str[1])){ accept = 1; radix = 0x10; } } break; case IMT_BS: if(input_end != input_str){ accept = 0; BKNI_Printf("\x8 \x8"); input_end--; } break; case IMT_CR: case IMT_OTHER: default: break; } if(accept){ BKNI_Printf("%c", input); /* place character in to the input string */ *input_end = (char)input; input_end++; if(input_end == &input_str[IN_MAX-1]){ input_end--; } } }while(input != MENU_CR); *input_end = '\0'; value = strtol(input_str, &input_end, radix); return value; } int get_pid(void) { int pid; do { BKNI_Printf("Please input PID (0 - 0x1ffff) to get message from ?\n"); pid = menu_read_number(); } while (pid < 0 || pid > 0x1ffff); return pid; } #ifdef OOB_TUNER_SUPPORT void menu_oob_test(void) { bool initialized = false; int input; int exit_menu = 0; if (!initialized) { if (!oob_init()) { BKNI_Printf("oob_init failed\n"); return; } initialized = true; } while(0 == exit_menu){ MENU_DELIMETER(); BKNI_Printf("Menu Level 2 - OOB Tuner Test\n"); BKNI_Printf("1 - Tune OOB Frequeny\n"); BKNI_Printf("2 - Get OOB Tuner Status\n"); BKNI_Printf("3 - Start OOB Message Filtering\n"); BKNI_Printf("4 - Stop OOB Message Filtering\n"); BKNI_Printf("5 - Loop All Pids\n"); BKNI_Printf("6 - Start OOB Message Filtering for ATM Packet Capture\n"); BKNI_Printf("0 - Return to previous menu\n"); BKNI_Printf("> "); input = serial_getc(CONSOLE_UART, true); BKNI_Printf("%c\n", input); switch(input){ case '1': oob_tune(); break; case '2': oob_get_status(); break; case '3': input = get_pid(); BKNI_Printf("Pid = %d\n", input); oob_start_message(input); break; case '4': oob_stop_message(); break; case '5': { unsigned int pid; for (pid = 0; pid < 0x1ffff; pid++) { BKNI_Printf("tune to pid %d\n", pid); oob_start_message(pid); bos_sleep(10 * 1000); oob_stop_message(); } } break; case '6': { /* hardcoding the vpi/vci value first */ oob_start_amessage(0, 0x3e8); } break; case '0': oob_stop_message(); exit_menu = 1; break; } } } #endif void menu_a56_test(void) { int input; int exit_menu = 0; #ifdef OOB_TUNER_SUPPORT BKNI_Printf("You need to tune to a frequency before testing A56 use either in band or out of band tuner.\n"); BKNI_Printf("If not yet, please use tuner test to tune a freqency first.\n"); BKNI_Printf("Which tuner to use (0 in band, 1 out of band?)\n"); input = serial_getc(CONSOLE_UART, true); a56_test_choose_tuner(input); #else BKNI_Printf("You need to tune to a frequency before testing A56 use in band tuner.\n"); BKNI_Printf("If not yet, please use tuner test to tune a freqency first.\n"); #endif while(0 == exit_menu){ MENU_DELIMETER(); BKNI_Printf("Menu Level 2 - A56 Filter Test\n"); BKNI_Printf("1 - Test Network Information Message filter\n"); BKNI_Printf("2 - Test Network Text Message filter\n"); BKNI_Printf("3 - Test Virtual Channel Message filter\n"); BKNI_Printf("4 - Stop filter\n"); BKNI_Printf("0 - Return to previous menu\n"); BKNI_Printf("> "); input = serial_getc(CONSOLE_UART, true); BKNI_Printf("%c\n", input); switch(input){ case '0': a56_test_stop(); exit_menu = 1; continue; case '1': input = get_pid(); a56_test_start(A56_NIM, input); break; case '2': input = get_pid(); a56_test_start(A56_NTM, input); break; case '3': input = get_pid(); a56_test_start(A56_VCM, input); break; case '4': a56_test_stop(); break; } } }