/*************************************************************************** * Copyright (c) 2011, 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: transport capture test * * Revision History: * * $brcm_Log: $ * * ***************************************************************************/ #include "bstd.h" #include "bkni.h" #include "bdbg.h" #include "bsettop_smessage.h" #include "test_capture.h" #define CAP_BUFFER_SIZE 188 /* must be power of two */ #define CAP_BLK_CNT 32 typedef struct tcap_context_t { smessage_stream_t msg; uint16_t pid; uint8_t cnt; smessage_stream_params_t params; uint8_t buffer[CAP_BUFFER_SIZE*CAP_BLK_CNT]; } tcap_context_t; BDBG_MODULE(tcap); static tcap_context_t tcap_context = {NULL, 0, 0}; uint8_t buffer[CAP_BUFFER_SIZE*CAP_BLK_CNT]; extern unsigned int menu_read_number(void); extern void comm_dump_mem(unsigned char *buff, size_t size); void *tcap_message_callback(void *context, size_t size) { unsigned w_idx; BDBG_ASSERT(size==CAP_BUFFER_SIZE); tcap_context.cnt++; w_idx = CAP_BUFFER_SIZE * (tcap_context.cnt % CAP_BLK_CNT); return (void*)&tcap_context.buffer[w_idx]; } void tcap_parameters(void) { BKNI_Printf("Enter number in decimal (1234) or hex (0x1234) format.\n"); BKNI_Printf("PID to capture "); tcap_context.pid = menu_read_number(); BKNI_Printf("\n"); } void tcap_start(void) { if (!tcap_context.pid) { BKNI_Printf("PID is not configured, configure it first.\n"); return; } if (tcap_context.msg) { BKNI_Printf("Capture is running now for PID 0x%04x.\n", tcap_context.params.pid); return; } BKNI_Printf("Start TS capture for PID 0x%04x\n", tcap_context.pid); tcap_context.msg = smessage_open(smessage_format_tsc); if (tcap_context.msg == NULL) { BDBG_ERR(("%s:%d", __FILE__, __LINE__)); return; } tcap_context.cnt = 0; smessage_stream_params_init(&tcap_context.params, tcap_context.msg); tcap_context.params.band = TUNER_BAND; tcap_context.params.pid = tcap_context.pid; tcap_context.params.pid_channel = 6; tcap_context.params.buffer = tcap_context.buffer; tcap_context.params.buffer_size = CAP_BUFFER_SIZE; /* capture one TS packet at a time */ tcap_context.params.data_ready_callback = tcap_message_callback; tcap_context.params.overflow = NULL; tcap_context.params.callback_context = NULL; tcap_context.params.crc_disabled = true; if (b_ok != smessage_start(&tcap_context.params, tcap_context.msg)) { BDBG_ERR(("%s:%d", __FILE__, __LINE__)); return; } } void tcap_stop(void) { if (tcap_context.msg) { if (b_ok != smessage_stop(tcap_context.msg)) { BDBG_ERR(("%s:%d", __FILE__, __LINE__)); } smessage_close(tcap_context.msg); tcap_context.msg = NULL; } } void tcap_display(void) { int i; BKNI_Printf("Accepted TS packet : %d\n", tcap_context.cnt); if (tcap_context.cnt>=CAP_BLK_CNT) { for (i=(tcap_context.cnt%CAP_BLK_CNT); i