source: svn/newcon3bcm2_21bu/dta/tests/unit_test/test_oob.c @ 43

Last change on this file since 43 was 43, checked in by megakiss, 11 years ago

광주방송 OTC 주파수 369Mhz로 변경

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2011, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: $
11 * $brcm_Revision: $
12 * $brcm_Date: $
13 *
14 * Module Description: filter test for certification
15 *
16 * Revision History:
17 *
18 * $brcm_Log: $
19 *
20 *
21 ***************************************************************************/
22#include "bstd.h"
23#include "bkni.h"
24#include "bdbg.h"
25
26#include "serial.h"
27#include "input_parser.h"
28#include "bcrc32.h"
29
30#include "bsettop.h"
31#include "bsettop_tuner_aob.h"
32#include "bsettop_smessage.h"
33
34BDBG_MODULE(oob_test);
35
36#define MAX_MSG_BUFFERS 0x400
37#define MSG_BUFFER_SIZE 0x1000
38
39unsigned char oob_msg_buffer[MSG_BUFFER_SIZE];
40
41void *oob_msg_callback(void *context, size_t data_size)
42{
43    uint8_t *msg;
44    uint32_t crc, i;
45
46    msg = (uint8_t*)oob_msg_buffer;
47    /* check syntax indicator to see if we need to do crc */
48    if(0 == (msg[1] & 0x80)){
49        crc = bcrc32(msg, data_size);
50        if(0 != crc){
51                BDBG_ERR(("crc error detected"));
52        }
53    }
54    BDBG_ERR(("msg %hx size %u", msg[0], data_size));
55
56#define DUMP_MSG
57#ifdef DUMP_MSG
58        for (i = 0; i < 16; i++) {
59                BKNI_Printf("[%3d]=0x%02x\n", i, msg[i]);
60        }
61#endif
62
63    return msg;
64}
65
66/* for MOTO HE OOB */
67#define MOTO_OOB_NETWORK_ID     0x777
68#define MOTO_OOB_VCT_ID         5
69
70static btuner_aob_t                     tuner_aob = NULL;
71static btuner_aob_params        tuner_aob_params;
72static smessage_stream_t        oob_msg = NULL;
73static unsigned int                     freq_khz = 75250;       /* currently hardcoding at 75.25 MHz */
74
75bool oob_init(void)
76{
77        if (tuner_aob)
78                return true;
79
80        tuner_aob = btuner_aob_open(0);
81        if (NULL == tuner_aob) {
82                BKNI_Printf("btuner_aob_open failed");
83                return false;
84        }
85        return true;
86}
87
88bool oob_tune(void)
89{
90        if (NULL == tuner_aob) {
91                BKNI_Printf("OOB tuner is not initialized");
92                return false;
93        }
94
95        btuner_aob_params_init(tuner_aob, &tuner_aob_params);
96        /* for DVS167QPSK */
97        tuner_aob_params.mode = 0;
98        tuner_aob_params.symbol_rate = 772000;  //1544000;
99        freq_khz = 84000;       // 84 MHz
100        if (0 == tuner_aob_params.mode)
101                BKNI_Printf("DVS167QPSK");
102        else {
103                if (1 == tuner_aob_params.mode)
104                        BKNI_Printf("DVS178QPSK");
105                else {
106                        BKNI_Printf("Unsupported mode");
107                        tuner_aob_params.mode = 1;
108                }
109        }
110        tuner_aob_params.wait_for_lock = false;
111
112        if (btuner_aob_tune(tuner_aob, freq_khz * 1000, &tuner_aob_params) < 0) {
113                BKNI_Printf("btuner_tune_aob %d khz (mode=%d) failed\n", freq_khz, tuner_aob_params.mode );
114                return false;
115        }
116        return true;
117}
118
119bool oob_get_status(void)
120{
121        btuner_aob_status status;
122
123        if (NULL == tuner_aob) {
124                BKNI_Printf("OOB tuner is not initialized");
125                return false;
126        }
127
128        btuner_aob_get_status(tuner_aob, &status);
129        BKNI_Printf("OOB tuner is %s on frequency %d KHz\n", status.lock ? "locked" : "not locked", freq_khz);
130        return true;
131}
132
133bool oob_start_message(unsigned short pid)
134{
135        bresult bres;
136        smessage_stream_params_t params;
137
138        /* if started already */
139        if (oob_msg)
140                return true;
141
142        oob_msg = smessage_open(smessage_format_psi);
143        if (NULL == oob_msg) {
144                BKNI_Printf("smessage_open failed");
145                return false;
146        }
147
148        smessage_stream_params_init(&params, NULL);
149        params.band = OOB_TUNER_BAND;
150        params.pid = pid;
151
152        params.buffer = oob_msg_buffer;
153        params.buffer_size = MSG_BUFFER_SIZE;
154        params.crc_disabled = true;
155        params.data_ready_callback = oob_msg_callback;
156        params.overflow = NULL;
157        //params.priv = (void *)4;
158
159        bres = smessage_start(&params, oob_msg);
160        if (b_ok != bres)
161        {
162                BDBG_ERR(("%s:%d",__FILE__, __LINE__));
163                smessage_close(oob_msg);
164                oob_msg = NULL; 
165                return false;
166        }
167
168        return true;
169}
170
171bool oob_stop_message(void)
172{
173        if (!oob_msg) {
174                BKNI_Printf("OOB message filtering is not started yet");
175                return false;
176        }
177        smessage_stop(oob_msg);
178        smessage_close(oob_msg);
179        oob_msg = NULL;
180
181        return true;
182}
Note: See TracBrowser for help on using the repository browser.