/*************************************************************************** * 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: filter test for certification * * Revision History: * * $brcm_Log: $ * * ***************************************************************************/ #include "bstd.h" #include "bkni.h" #include "bdbg.h" #include "serial.h" #include "input_parser.h" #include "bcrc32.h" #include "bsettop.h" #include "bsettop_tuner_aob.h" #include "bsettop_smessage.h" BDBG_MODULE(oob_test); #define MAX_MSG_BUFFERS 0x400 #define MSG_BUFFER_SIZE 0x1000 unsigned char oob_msg_buffer[MSG_BUFFER_SIZE]; void *oob_msg_callback(void *context, size_t data_size) { uint8_t *msg; uint32_t crc, i; msg = (uint8_t*)oob_msg_buffer; /* check syntax indicator to see if we need to do crc */ if(0 == (msg[1] & 0x80)){ crc = bcrc32(msg, data_size); if(0 != crc){ BDBG_ERR(("crc error detected")); } } BDBG_ERR(("msg %hx size %u", msg[0], data_size)); #define DUMP_MSG #ifdef DUMP_MSG for (i = 0; i < 16; i++) { BKNI_Printf("[%3d]=0x%02x\n", i, msg[i]); } #endif return msg; } /* for MOTO HE OOB */ #define MOTO_OOB_NETWORK_ID 0x777 #define MOTO_OOB_VCT_ID 5 static btuner_aob_t tuner_aob = NULL; static btuner_aob_params tuner_aob_params; static smessage_stream_t oob_msg = NULL; static unsigned int freq_khz = 75250; /* currently hardcoding at 75.25 MHz */ bool oob_init(void) { if (tuner_aob) return true; tuner_aob = btuner_aob_open(0); if (NULL == tuner_aob) { BKNI_Printf("btuner_aob_open failed"); return false; } return true; } bool oob_tune(void) { if (NULL == tuner_aob) { BKNI_Printf("OOB tuner is not initialized"); return false; } btuner_aob_params_init(tuner_aob, &tuner_aob_params); /* for DVS167QPSK */ tuner_aob_params.mode = 0; tuner_aob_params.symbol_rate = 772000; //1544000; freq_khz = 84000; // 84 MHz if (0 == tuner_aob_params.mode) BKNI_Printf("DVS167QPSK"); else { if (1 == tuner_aob_params.mode) BKNI_Printf("DVS178QPSK"); else { BKNI_Printf("Unsupported mode"); tuner_aob_params.mode = 1; } } tuner_aob_params.wait_for_lock = false; if (btuner_aob_tune(tuner_aob, freq_khz * 1000, &tuner_aob_params) < 0) { BKNI_Printf("btuner_tune_aob %d khz (mode=%d) failed\n", freq_khz, tuner_aob_params.mode ); return false; } return true; } bool oob_get_status(void) { btuner_aob_status status; if (NULL == tuner_aob) { BKNI_Printf("OOB tuner is not initialized"); return false; } btuner_aob_get_status(tuner_aob, &status); BKNI_Printf("OOB tuner is %s on frequency %d KHz\n", status.lock ? "locked" : "not locked", freq_khz); return true; } bool oob_start_message(unsigned short pid) { bresult bres; smessage_stream_params_t params; /* if started already */ if (oob_msg) return true; oob_msg = smessage_open(smessage_format_psi); if (NULL == oob_msg) { BKNI_Printf("smessage_open failed"); return false; } smessage_stream_params_init(¶ms, NULL); params.band = OOB_TUNER_BAND; params.pid = pid; params.buffer = oob_msg_buffer; params.buffer_size = MSG_BUFFER_SIZE; params.crc_disabled = true; params.data_ready_callback = oob_msg_callback; params.overflow = NULL; //params.priv = (void *)4; bres = smessage_start(¶ms, oob_msg); if (b_ok != bres) { BDBG_ERR(("%s:%d",__FILE__, __LINE__)); smessage_close(oob_msg); oob_msg = NULL; return false; } return true; } bool oob_stop_message(void) { if (!oob_msg) { BKNI_Printf("OOB message filtering is not started yet"); return false; } smessage_stop(oob_msg); smessage_close(oob_msg); oob_msg = NULL; return true; }