source: svn/trunk/newcon3bcm2_21bu/dta/src/app/bscreen_factory_test.c

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 6.1 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2006, 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:
15 *
16 * Revision History:
17 *
18 * $brcm_Log:  $
19 *
20 ***************************************************************************/
21
22#include "bapp.h"
23#include "bstd.h"
24#include "bapp_util.h"
25#include "bgfx.h"
26#include "ch_map.h"
27#include "bsettop_decode_audio.h"
28
29BDBG_MODULE(bscreen_ft);                 /* Register software module with debug interface */
30
31/*
32 Factory test channel map
33 */
34static b_mutex_t s_ch_map_mutex;
35
36static ch_map_t s_ch_map =
37{
38        0x00000000,
39        0,
40        1, /* default OFF for HD capability */
41        { 1,
42                {{ 0,0,80,0 }},
43        },
44        { 1,
45                {{ 0,567000 }},
46        },
47        { 3,
48                {{ 0x0001,"Ch - 1.1" } ,
49                 { 0x0002,"Ch - 1.2" } ,
50                 { 0x0003,"Ch - 1.3" }},
51        },
52        { 3,
53                {{ 101,0x0001,1,0,0,0,2,0},
54                 { 102,0x0002,2,0,0,0,2,0},
55                 { 103,0x0003,3,0,0,0,2,0}},
56        },
57};
58
59/* left, freq 1000, count 48, repeat 1 */
60static const uint32_t s_1khz_samples[] =
61{
62        (uint32_t) 0,
63        (uint32_t) 68433,
64        (uint32_t) 135695,
65        (uint32_t) 200636,
66        (uint32_t) 262143,
67        (uint32_t) 319166,
68        (uint32_t) 370727,
69        (uint32_t) 415945,
70        (uint32_t) 454046,
71        (uint32_t) 484378,
72        (uint32_t) 506422,
73        (uint32_t) 519802,
74        (uint32_t) 524287,
75        (uint32_t) 519802,
76        (uint32_t) 506422,
77        (uint32_t) 484378,
78        (uint32_t) 454046,
79        (uint32_t) 415945,
80        (uint32_t) 370727,
81        (uint32_t) 319166,
82        (uint32_t) 262143,
83        (uint32_t) 200636,
84        (uint32_t) 135695,
85        (uint32_t) 68433,
86        (uint32_t) 0,
87        (uint32_t) -68433,
88        (uint32_t) -135695,
89        (uint32_t) -200636,
90        (uint32_t) -262143,
91        (uint32_t) -319166,
92        (uint32_t) -370727,
93        (uint32_t) -415945,
94        (uint32_t) -454046,
95        (uint32_t) -484378,
96        (uint32_t) -506422,
97        (uint32_t) -519802,
98        (uint32_t) -524287,
99        (uint32_t) -519802,
100        (uint32_t) -506422,
101        (uint32_t) -484378,
102        (uint32_t) -454046,
103        (uint32_t) -415945,
104        (uint32_t) -370727,
105        (uint32_t) -319166,
106        (uint32_t) -262144,
107        (uint32_t) -200636,
108        (uint32_t) -135695,
109        (uint32_t) -68433
110};
111
112
113static int s_1khz_samples_num = sizeof(s_1khz_samples)/sizeof(s_1khz_samples[0]);
114
115/* Actual frequency: 10000, Repeat count: 24, Number of sine waves per repeat: 5 */
116static const uint32_t s_10khz_samples[] =
117{
118        (uint32_t) 0,
119        (uint32_t) 506422,
120        (uint32_t) 262143,
121        (uint32_t) -370727,
122        (uint32_t) -454046,
123        (uint32_t) 135695,
124        (uint32_t) 524287,
125        (uint32_t) 135695,
126        (uint32_t) -454046,
127        (uint32_t) -370727,
128        (uint32_t) 262144,
129        (uint32_t) 506422,
130        (uint32_t) 0,
131        (uint32_t) -506422,
132        (uint32_t) -262144,
133        (uint32_t) 370727,
134        (uint32_t) 454046,
135        (uint32_t) -135695,
136        (uint32_t) -524287,
137        (uint32_t) -135695,
138        (uint32_t) 454046,
139        (uint32_t) 370727,
140        (uint32_t) -262143,
141        (uint32_t) -506422
142};
143
144static int s_10khz_samples_num = sizeof(s_10khz_samples)/sizeof(s_10khz_samples[0]);
145
146/*
147Summary:
148        Disable tone test.
149*/
150static void factory_enable_tone(bool left, bool enable)
151{
152        baudio_decode_test_tone(NULL, (uint32_t*)s_1khz_samples, s_1khz_samples_num, left, enable);
153}
154
155/*
156Summary:
157        Status screen drawing function.
158*/
159void factory_draw(void *v_app, void *v_screen)
160{
161        bapp_t *p_app = (bapp_t*)v_app;
162        vch_t vch;
163        st_t st;
164        freq_t freq;
165        /* not used bscreen_t *p_screen = (bscreen_t*)v_screen; */
166        uint16_t x,y;
167        unsigned int num_chars = 0;
168        static char s_str[128];
169
170        y = 50; x = 60;
171        bgfx_fill_rect(&p_app->surf,0,0,eWIDTH,eHEIGHT,eCOLOR_CLEAR);
172        bgfx_fill_rect(&p_app->surf,0,0,280,160,eCOLOR_BLACK);
173        num_chars = snprintf(s_str,128,"Vendor:  %s",DEF_VENDOR_NAME);
174        num_chars = c_to_uni_str((unsigned char*)s_str,p_app->tmp_str,num_chars);
175        text_box(&p_app->surf, p_app->p_font[eLANG_ENGLISH][eFONT_SIZE_SMALL],
176                         x, y, 220, 30, p_app->tmp_str, num_chars, eCOLOR_RED_TICK,0);
177
178       
179        if (!ch_map_get_current(bapp_cur_ch_map(p_app),&vch,&st,&freq))
180        {
181                BDBG_MSG(("Invalid current channel or map.\n"));
182                return;
183        }
184        y += 30;
185        num_chars = snprintf(s_str,128,"Channel:  %s(%d)",st.name,vch.ch_num);
186        num_chars = c_to_uni_str((unsigned char*)s_str,p_app->tmp_str,num_chars);
187        text_box(&p_app->surf, p_app->p_font[eLANG_ENGLISH][eFONT_SIZE_SMALL],
188                         x, y, 220, 30, p_app->tmp_str, num_chars, eCOLOR_BLUE_TICK,0);
189
190}
191
192/*
193Summary:
194        Status screen event handler for debugging and monitoring.
195        .
196*/
197int factory_handle_event(void *v_app, void *v_screen, 
198                                                 bscreen_event_t *p_event)
199{
200        bapp_t *p_app = (bapp_t*)v_app;
201        bscreen_t *p_screen = (bscreen_t*)v_screen;
202        int result = 0;
203        static int cnt = 0;
204
205        switch (p_event->type)
206        {
207        case eS_EVENT_IDLE:
208                {
209                        /* Do periodic processing here */
210                        if (cnt++ == 10)
211                        {
212                                cnt = 0;
213                                result = 1; /* cause redraw */
214                        }
215                }
216                break;
217        case eS_EVENT_SETUP_DONE:
218                result = 0;
219                BDBG_WRN(("eS_EVENT_SETUP_DONE...\n"));
220                break;
221        case eS_EVENT_SETUP:
222                BDBG_WRN(("eS_EVENT_SETUP...\n"));
223                /* Install canned channel for factory test */
224                p_app->settings.psi_scan = 1;
225                bos_create_mutex(&(s_ch_map_mutex));
226                BDBG_ASSERT(s_ch_map_mutex.queue);
227                s_ch_map.p_mutex = &s_ch_map_mutex;
228                ch_map_copy(&(p_app->settings.ch_map),&(s_ch_map),0xF);
229                break;
230
231        case eS_EVENT_SELECTED:
232                result = (p_screen->button_selection == p_event->id) ? 1 : 0;
233                break;
234
235        case eS_EVENT_CHECKED:
236                result = (p_screen->button_checked == p_event->id) ? 1 : 0;
237                break;
238
239        case eS_EVENT_IR:
240                {
241                        if ((p_event->id & KEY_UP) == 0)
242                        {
243                                factory_enable_tone(true,false);
244                        }
245                        switch (p_event->id)
246                        {
247                        case eIR_CH_UP:
248                        case eIR_UP:
249                                result = bapp_change_channel(p_app, 1, 1);
250                                break;
251
252                        case eIR_CH_DOWN:
253                        case eIR_DOWN:
254                                result = bapp_change_channel(p_app, 0, 1);
255                                break;
256                        case eIR_RIGHT:
257                                factory_enable_tone(false,true);
258                                break;
259                        case eIR_LEFT:
260                                factory_enable_tone(true,true);
261                                break;
262
263                        default:
264                                break;
265                        }
266                        break;
267                }
268                break;
269        default:
270                break;
271        }
272        return result; /* always handle event */
273}
274
Note: See TracBrowser for help on using the repository browser.