source: svn/newcon3bcm2_21bu/nexus/app/nanotv/bscreen_debug.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 17.4 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 "chan_mgr.h"
27#include "bchp_hifidac_ctrl0.h"
28#include "bchp_sun_top_ctrl.h"
29#include "bchp_hifidac_rm0.h"
30
31BDBG_MODULE(bscreen_debug);              /* Register software module with debug interface */
32
33typedef enum dbg_layout_t
34{
35        eDBG_STATUS_X   = 260,
36        eDBG_STATUS_Y   = 40,
37        eDBG_COL_WIDTH  = 170,
38        eDBG_ROW_HEIGHT = 26,
39}dbg_layout_t;
40
41static const unsigned char *s_status_str_table[] =
42{
43        "V/A/PCR PID:",
44        "VSTC/PTS:",
45        "ASTC/PTS:",
46        "AV,V,A Delta:",
47        "A/V FIFO:",
48        "SRC W:H:",
49        "CH#,FREQ:",
50        "SNR:",
51        "State:",
52        "Version:",
53#ifdef CONFIG_SCL_INFO 
54        "SCL IN:",
55        "SCL OUT:",
56        "SRC OUT:",
57        "WIN:",
58        "PanScan:",
59#endif
60        "\0"
61};
62
63/* left, freq 1000, count 48, repeat 1 */
64static const uint32_t s_1khz_samples[] =
65{
66        (uint32_t) 0,
67        (uint32_t) 68433,
68        (uint32_t) 135695,
69        (uint32_t) 200636,
70        (uint32_t) 262143,
71        (uint32_t) 319166,
72        (uint32_t) 370727,
73        (uint32_t) 415945,
74        (uint32_t) 454046,
75        (uint32_t) 484378,
76        (uint32_t) 506422,
77        (uint32_t) 519802,
78        (uint32_t) 524287,
79        (uint32_t) 519802,
80        (uint32_t) 506422,
81        (uint32_t) 484378,
82        (uint32_t) 454046,
83        (uint32_t) 415945,
84        (uint32_t) 370727,
85        (uint32_t) 319166,
86        (uint32_t) 262143,
87        (uint32_t) 200636,
88        (uint32_t) 135695,
89        (uint32_t) 68433,
90        (uint32_t) 0,
91        (uint32_t) -68433,
92        (uint32_t) -135695,
93        (uint32_t) -200636,
94        (uint32_t) -262143,
95        (uint32_t) -319166,
96        (uint32_t) -370727,
97        (uint32_t) -415945,
98        (uint32_t) -454046,
99        (uint32_t) -484378,
100        (uint32_t) -506422,
101        (uint32_t) -519802,
102        (uint32_t) -524287,
103        (uint32_t) -519802,
104        (uint32_t) -506422,
105        (uint32_t) -484378,
106        (uint32_t) -454046,
107        (uint32_t) -415945,
108        (uint32_t) -370727,
109        (uint32_t) -319166,
110        (uint32_t) -262144,
111        (uint32_t) -200636,
112        (uint32_t) -135695,
113        (uint32_t) -68433
114};
115
116
117static int s_1khz_samples_num = sizeof(s_1khz_samples)/sizeof(s_1khz_samples[0]);
118
119/* Actual frequency: 10000, Repeat count: 24, Number of sine waves per repeat: 5 */
120static const uint32_t s_10khz_samples[] =
121{
122        (uint32_t) 0,
123        (uint32_t) 506422,
124        (uint32_t) 262143,
125        (uint32_t) -370727,
126        (uint32_t) -454046,
127        (uint32_t) 135695,
128        (uint32_t) 524287,
129        (uint32_t) 135695,
130        (uint32_t) -454046,
131        (uint32_t) -370727,
132        (uint32_t) 262144,
133        (uint32_t) 506422,
134        (uint32_t) 0,
135        (uint32_t) -506422,
136        (uint32_t) -262144,
137        (uint32_t) 370727,
138        (uint32_t) 454046,
139        (uint32_t) -135695,
140        (uint32_t) -524287,
141        (uint32_t) -135695,
142        (uint32_t) 454046,
143        (uint32_t) 370727,
144        (uint32_t) -262143,
145        (uint32_t) -506422
146};
147
148static int s_10khz_samples_num = sizeof(s_10khz_samples)/sizeof(s_10khz_samples[0]);
149
150static bool antenna_detect = false;
151/*
152Summary:
153        Use the this function to get a UNI string.
154*/
155
156static void get_status_str(bapp_t *p_app,
157                                                  int text_id,           /* Text id */
158                                                  unsigned int *p_uni_str,        /* Buffer to put UNI string into */
159                                                  unsigned int *str_len,           /* On input the max length in words on output the actual size in characters. */
160                                                  bdecode_status *p_status,
161                                                  btuner_ds_status *p_ds_status
162                                                  )
163{
164        static char ts_str[64];
165        *str_len = 0;
166
167        switch (text_id)
168        {
169        case 0: *str_len = snprintf(ts_str,64,"0x%04x, 0x%04x, 0x%04x",p_status->vPID,p_status->aPID,p_status->pcrPID); break;
170        case 1: *str_len = snprintf(ts_str,64,"0x%08x/0x%08x",p_status->video_stc,p_status->video_pts); break;
171        case 2: *str_len = snprintf(ts_str,64,"0x%08x/0x%08x",p_status->audio_stc,p_status->audio_pts); break;
172        case 3: *str_len = snprintf(ts_str,64,"%d,%d,%d",(int)p_status->audio_pts - (int)p_status->video_pts,
173                                                                (int)p_status->audio_stc-(int)p_status->audio_pts, 
174                                                                (int)p_status->video_stc-(int)p_status->video_pts); 
175                                                                break;
176        case 4: *str_len = snprintf(ts_str,64,"%d/%d,%d/%d",p_status->audio_fifo_depth,p_status->audio_fifo_size,p_status->video_fifo_depth,p_status->video_fifo_size); break;
177        case 5: *str_len = snprintf(ts_str,64,"%d:%d(%s,%d)",p_status->source_width,p_status->source_height,(p_status->bStreamProgressive ? "P" : "I"),p_status->video_aspect_ratio); break;
178        case 6:
179                *str_len = snprintf(ts_str,64,"%d,%d,%s",p_app->cur_ch_num + 2,p_ds_status->freq, antenna_detect ? "Smart" : "STD"); 
180                break;
181        case 7:
182                *str_len = snprintf(ts_str,64,"%d",p_ds_status->snr); 
183                break;
184        case 8:
185                *str_len = snprintf(ts_str,64,"%s(late:  %d/%d) %s",(p_status->bVideoDecoderState == 0) ? "stop" : "start",p_status->late_int,
186                                                        p_status->picture_int_cnt,(ReadReg32(BCHP_HIFIDAC_CTRL0_MUTECTRL) & BCHP_HIFIDAC_CTRL0_MUTECTRL_MUTEALL_MASK) ? "mute" : "unmute"); 
187                break;
188        case 9:
189                *str_len = snprintf(ts_str, 64, "%d.%d.%d, %s", MAJOR_VERSION,MINOR_VERSION,SUB_VERSION,__DATE__);
190                break;
191#ifdef CONFIG_SCL_INFO 
192        case 10: *str_len = snprintf(ts_str,64,"%d,%d,%d,%d",p_status->scl_cut_left,p_status->scl_cut_top,p_status->scl_cut_width,p_status->scl_cut_height); break;
193        case 11: *str_len = snprintf(ts_str,64,"%d,%d,%d,%d",p_status->scl_out_left,p_status->scl_out_top,p_status->scl_out_width,p_status->scl_out_height); break;
194        case 12: *str_len = snprintf(ts_str,64,"%d,%d,%d,%d",p_status->src_out_left,p_status->src_out_top,p_status->src_out_width,p_status->src_out_height); break;
195        case 13: *str_len = snprintf(ts_str,64,"%d,%d,%d,%d",p_status->win_left,p_status->win_top,p_status->win_width,p_status->win_height); break;
196        case 14: *str_len = snprintf(ts_str,64,"%d,%d(0x%04x)",p_status->hPanScan,p_status->vPanScan,p_status->video_format); break;
197#endif
198        }
199
200        if (*str_len)
201        {
202                *str_len = c_to_uni_str(ts_str,p_uni_str,*str_len);
203        }
204}
205
206/*
207Summary:
208        Use the this function to get a UNI string.
209*/
210
211static void get_status_label(
212                                                        int text_id,       /* Text id */
213                                                        unsigned int *p_uni_str,        /* Buffer to put UNI string into */
214                                                        unsigned int *str_len           /* On input the max length in words on output the actual size in characters. */
215                                                        )
216{
217        char *p_str;
218
219        p_str = (char*)s_status_str_table[text_id];
220        if (!p_str)
221        {
222                *str_len = 0;
223                return;
224        }
225
226        *str_len = c_to_uni_str(p_str,p_uni_str,*str_len);
227}
228/*
229Summary:
230        Status screen drawing function.
231*/
232void bscreen_status_draw(void *v_app, void *v_screen)
233{
234        bapp_t *p_app = (bapp_t*)v_app;
235        /* not used bscreen_t *p_screen = (bscreen_t*)v_screen; */
236        uint16_t x,y,y_off;
237        unsigned int num_chars = 0;
238        int i;
239        bdecode_status status;
240        btuner_ds_status ds_status;
241
242        x = eDBG_STATUS_X;
243        y = eDBG_STATUS_Y;
244
245        i = 0;
246
247        status.audio_decode = p_app->audio;
248        bdecode_get_status(p_app->decode,&status);
249
250        btuner_get_ds_status(p_app->tuner, &ds_status);
251
252        while (*(s_status_str_table[i]) != '\0')
253        {
254                y_off = y + (i * eDBG_ROW_HEIGHT);
255                bgfx_fill_rect(&p_app->surf,x,y_off,eWIDTH - x,eDBG_ROW_HEIGHT,eCOLOR_BLACK_65);
256                num_chars = SCREEN_MAX_STR_WIDTH;
257                get_status_label(i, p_app->tmp_str, &num_chars);
258                text_box(&p_app->surf, p_app->p_font[eLANG_ENGLISH][eFONT_SIZE_SMALL],
259                                 x, y_off, eDBG_COL_WIDTH - 20, eDBG_ROW_HEIGHT, p_app->tmp_str, num_chars, eCOLOR_WHITE,0);
260
261                num_chars = SCREEN_MAX_STR_WIDTH;
262                get_status_str(p_app,i,p_app->tmp_str, &num_chars,&status, &ds_status);
263                text_box(&p_app->surf, p_app->p_font[eLANG_ENGLISH][eFONT_SIZE_SMALL],
264                                 x + eDBG_COL_WIDTH + 20, y_off, eWIDTH - x - eDBG_COL_WIDTH, eDBG_ROW_HEIGHT, 
265                                 p_app->tmp_str, num_chars, eCOLOR_WHITE,0);
266                i++;
267        }
268}
269
270/*
271Summary:
272        Status screen event handler for debugging and monitoring.
273        .
274*/
275#ifdef CONFIG_BCM_FACTORY_TEST
276int bscreen_status_event(void *v_app, void *v_screen, 
277                                                 bscreen_event_t *p_event)
278{
279        bapp_t *p_app = (bapp_t*)v_app;
280        bscreen_t *p_screen = (bscreen_t*)v_screen;
281        int result = 0;
282        int i;
283        unsigned int flags;
284
285        static bool tune = false;
286        static int cnt = 0;
287        static int reject_key_timeout = 10;
288
289        switch (p_event->type)
290        {
291        case eS_EVENT_IDLE:
292                {
293                        if (reject_key_timeout > 0)
294                        {
295                                reject_key_timeout--;
296                                if (reject_key_timeout == 0)
297                                {
298                                        bapp_sync(p_app);
299                                        bgfx_fill_rect(&p_app->surf,0,0,eWIDTH,eHEIGHT,eCOLOR_CLEAR);
300                                        bapp_flush_screen(p_app);
301                                }
302                        }
303
304                        if (cnt++ == 10)
305                        {
306                                cnt = 0;
307                                bapp_sync(p_app);
308                                bscreen_status_draw(v_app,v_screen);
309                                bapp_flush_screen(p_app);
310                        }
311                }
312                break;
313        case eS_EVENT_SETUP_DONE:
314                result = 0;
315                BDBG_WRN(("eS_EVENT_SETUP_DONE...\n"));
316                if (p_app->factory_test)
317                {
318                        result = 1;
319                        p_app->cur_ch_num = 0;
320                        tune = true;
321                }
322                break;
323
324        case eS_EVENT_SETUP:
325                BDBG_WRN(("eS_EVENT_SETUP...\n"));
326                if (p_app->factory_test)
327                {
328                        antenna_detect = bant_detect();
329                        p_app->audio_vol = 100;
330                        bapp_set_audio_volume(p_app, p_app->audio_vol);
331                        /* For factory test mode only */
332                        flags = bos_enter_critical();
333                        WriteReg32(LED_DATA_REG, ReadReg32( LED_DATA_REG) | LED_GREEN_MASK);
334                        bos_exit_critical(flags);
335                }
336                result = 1;
337                flags = bos_enter_critical();
338#if (BCHP_CHIP!=3543)
339                WriteReg32(LED_DATA_REG, ReadReg32( LED_DATA_REG) & ~LED_RED_MASK);
340#else
341                WriteReg32(BCHP_SUN_TOP_CTRL_GENERAL_CTRL_1, 
342                        ReadReg32( BCHP_SUN_TOP_CTRL_GENERAL_CTRL_1) & ~BCHP_SUN_TOP_CTRL_GENERAL_CTRL_1_irw_top_sw_led_cntrl_MASK);
343#endif
344                bos_exit_critical(flags);
345                bapp_av_mute(p_app, 0);
346                break;
347
348        case eS_EVENT_SELECTED:
349                result = (p_screen->button_selection == p_event->id) ? 1 : 0;
350                break;
351
352        case eS_EVENT_CHECKED:
353                result = (p_screen->button_checked == p_event->id) ? 1 : 0;
354                break;
355
356        case eS_EVENT_IR:
357                {
358                       
359                        if (reject_key_timeout > 0)
360                        {
361                                BDBG_WRN(("############ STARTING UP THROW AWAY KEY (0x%08x) ############",p_event->id));
362                                break;
363                        }
364
365                        if (p_event->id & 0x40000000)
366                        {
367                                BDBG_WRN(("############ THROW AWAY KEY UP (0x%08x) ############",p_event->id));
368                                break;
369                        }
370                       
371                        switch (p_event->id)
372                        {
373                        case eIR_CH_UP:
374                        case eIR_UP:
375                                result = bapp_change_channel(p_app, 1, 1);
376                                break;
377
378                        case eIR_CH_DOWN:
379                        case eIR_DOWN:
380                                result = bapp_change_channel(p_app, 0, 1);
381                                break;
382                        case eIR_RIGHT:
383                                {
384                                        static char idx = 0;
385                                        if (idx < 4)
386                                        {
387                                                p_app->settings.ch[p_app->cur_ch_num].cmd = idx << 5;
388                                        } else
389                                        {
390                                                p_app->settings.ch[p_app->cur_ch_num].cmd = 0;
391                                        }
392                                        bant_send(p_app->settings.ch[p_app->cur_ch_num].cmd,
393                                                          p_app->settings.ch[p_app->cur_ch_num].freq_idx + 2);
394                                        idx++;
395                                        if (idx > 4)
396                                                idx = 0;
397                                }
398                                break;
399                        case eIR_LEFT:
400                                {
401                                        static char idx = 0;
402                                        p_app->settings.ch[p_app->cur_ch_num].cmd = idx;
403                                        bant_send(p_app->settings.ch[p_app->cur_ch_num].cmd,
404                                                          p_app->settings.ch[p_app->cur_ch_num].freq_idx + 2);
405                                        if (idx == 0x7F)
406                                                idx = 0;
407                                        else
408                                                idx++;
409                                }
410                                break;
411
412                        default:
413                                break;
414                        }
415                        break;
416                }
417                break;
418        default:
419                break;
420        }
421        return result; /* always handle event */
422}
423
424#else /* CONFIG_BCM_FACTORY_TEST */
425int bscreen_status_event(void *v_app, void *v_screen, 
426                                                 bscreen_event_t *p_event)
427{
428        bapp_t *p_app = (bapp_t*)v_app;
429        bscreen_t *p_screen = (bscreen_t*)v_screen;
430        int result = 0;
431        int i;
432        unsigned int flags;
433
434        static bool tune = false;
435        static bool color_bars = false;
436        static bool status = false;
437        static int cnt = 0;
438        static int reject_key_timeout = 10;
439
440        switch (p_event->type)
441        {
442        case eS_EVENT_IDLE:
443                {
444                        static int led_cnt = 0;
445                        static bool led_enabled = false;
446                        if (reject_key_timeout > 0)
447                        {
448                                reject_key_timeout--;
449                                if (reject_key_timeout == 0)
450                                {
451                                        bapp_sync(p_app);
452                                        bgfx_fill_rect(&p_app->surf,0,0,eWIDTH,eHEIGHT,eCOLOR_CLEAR);
453                                        bapp_flush_screen(p_app);
454                                }
455                        }
456
457                        if (cnt++ == 10)
458                        {
459                                cnt = 0;
460                                if (color_bars)
461                                {
462                                        cnt = 11;
463                                        bapp_sync(p_app);
464                                        bgfx_fill_rect(&p_app->surf,0,0,eWIDTH ,eHEIGHT,eCOLOR_BLACK);
465                                        bgfx_fill_rect(&p_app->surf,40,40,eWIDTH - 80,eHEIGHT - 80,eCOLOR_WHITE);
466                                        bgfx_fill_rect(&p_app->surf,80,80,(eWIDTH - 160)/3,eHEIGHT - 160,eCOLOR_LT_YELLOW);
467                                        bgfx_fill_rect(&p_app->surf,80 + ((eWIDTH - 160)/3),80,(eWIDTH - 160)/3,eHEIGHT - 160,eCOLOR_NEON_GREEN);
468                                        bgfx_fill_rect(&p_app->surf,80 + (((eWIDTH - 160) * 2)/3),80,(eWIDTH - 160)/3,eHEIGHT - 160,eCOLOR_LT_BLUE);
469                                        bapp_flush_screen(p_app);
470
471                                }
472                                else if (!p_app->factory_test || status)
473                                {
474                                        bapp_sync(p_app);
475                                        bscreen_status_draw(v_app,v_screen);
476                                        bapp_flush_screen(p_app);
477                                }
478                        }
479
480                        if ((led_cnt++ == 5) && p_app->factory_test)
481                        {
482                                flags = bos_enter_critical();
483                                led_cnt = 0;
484
485                                /* flash the LED */
486                                if (led_enabled)
487                                {
488                                        WriteReg32(LED_DATA_REG, ReadReg32( LED_DATA_REG) | LED_GREEN_MASK);
489                                } else
490                                {
491                                        WriteReg32(LED_DATA_REG, ReadReg32( LED_DATA_REG) & ~LED_GREEN_MASK);
492                                }
493                                bos_exit_critical(flags);
494                                led_enabled = (led_enabled) ? false : true;
495                        }
496                }
497                break;
498        case eS_EVENT_SETUP_DONE:
499                result = 0;
500                BDBG_WRN(("eS_EVENT_SETUP_DONE...\n"));
501                if (p_app->factory_test)
502                {
503                        result = 1;
504                        p_app->cur_ch_num = 0;
505                        tune = true;
506                }
507                break;
508
509        case eS_EVENT_SETUP:
510                BDBG_WRN(("eS_EVENT_SETUP...\n"));
511                if (p_app->factory_test)
512                {
513                        p_app->audio_vol = 100;
514                        bapp_set_audio_volume(p_app, p_app->audio_vol);
515                        /* For factory test mode only */
516                        flags = bos_enter_critical();
517                        WriteReg32(LED_DATA_REG, ReadReg32( LED_DATA_REG) | LED_GREEN_MASK);
518                        bos_exit_critical(flags);
519                }
520                result = 1;
521                flags = bos_enter_critical();
522#if (BCHP_CHIP!=3543)
523                WriteReg32(LED_DATA_REG, ReadReg32( LED_DATA_REG) & ~LED_RED_MASK);
524#else
525                WriteReg32(BCHP_SUN_TOP_CTRL_GENERAL_CTRL_1, 
526                        ReadReg32( BCHP_SUN_TOP_CTRL_GENERAL_CTRL_1) & ~BCHP_SUN_TOP_CTRL_GENERAL_CTRL_1_irw_top_sw_led_cntrl_MASK);
527#endif
528                bos_exit_critical(flags);
529                bapp_av_mute(p_app, 0);
530                break;
531
532        case eS_EVENT_SELECTED:
533                result = (p_screen->button_selection == p_event->id) ? 1 : 0;
534                break;
535
536        case eS_EVENT_CHECKED:
537                result = (p_screen->button_checked == p_event->id) ? 1 : 0;
538                break;
539
540        case eS_EVENT_IR:
541                {
542                       
543                        if (reject_key_timeout > 0)
544                        {
545                                BDBG_WRN(("############ STARTING UP THROW AWAY KEY (0x%08x) ############",p_event->id));
546                                break;
547                        }
548
549                        if (p_event->id & 0x40000000)
550                        {
551                                BDBG_WRN(("############ THROW AWAY KEY UP (0x%08x) ############",p_event->id));
552                                break;
553                        }
554                       
555                        WriteReg32(BCHP_HIFIDAC_CTRL0_TEST,
556                                           ReadReg32(BCHP_HIFIDAC_CTRL0_TEST) & ~BCHP_HIFIDAC_CTRL0_TEST_TESTTONE_ENABLE_MASK);
557                        if (!p_app->factory_test)
558                        {
559                                bgfx_fill_rect(&p_app->surf,0,0,eWIDTH,eHEIGHT,eCOLOR_CLEAR);
560                                result = 1;
561                                bapp_goto_last_screen(v_app);
562
563                                /* for testing auto power off */
564                                if (p_event->id == eIR_1)
565                                {
566                                        p_app->settings.auto_power_off = 1;
567                                }
568                                return result;
569                        }
570                        color_bars = false;
571                        status = false;
572                        switch (p_event->id)
573                        {
574                        case eIR_1:
575                                p_app->cur_ch_num = 1;
576                                tune = true;
577                                break;
578
579                        case eIR_2:
580                                p_app->cur_ch_num = 0;
581                                tune = true;
582                                break;
583
584                        case eIR_3:
585                                p_app->cur_ch_num = 2;
586                                tune = true;
587                                break;
588
589                        case eIR_4:
590                                BDBG_WRN(("Test left audio channel...\n"));
591                                color_bars = true;
592                                cnt = 0;
593                                /* left, freq 1000, count 48, repeat 1 */
594                                WriteReg32(BCHP_HIFIDAC_CTRL0_TEST, (BCHP_HIFIDAC_CTRL0_TEST_TESTTONE_ENABLE_MASK |
595                                                                                                         BCHP_HIFIDAC_CTRL0_TEST_TESTTONE_SHARE_MASK |
596                                                                                                         BCHP_HIFIDAC_CTRL0_TEST_TESTTONE_RIGHT_MASK |
597                                                                                                         (47 << BCHP_HIFIDAC_CTRL0_TEST_TESTTONE_REPEAT_LEFT_SHIFT)));
598                                for (i = 0; i < s_1khz_samples_num; ++i)
599                                {
600                                        WriteReg32(BCHP_HIFIDAC_CTRL0_TESTTONE_SAMPLE_i_ARRAY_BASE + (i * 4),s_1khz_samples[i]);
601                                }
602                                break;
603
604                        case eIR_6:
605                                BDBG_WRN(("Test right audio channel...\n"));
606                                color_bars = true;
607                                cnt = 0;
608                                /* Actual frequency: 10000, Repeat count: 24, Number of sine waves per repeat: 5 */
609                                WriteReg32(BCHP_HIFIDAC_CTRL0_TEST, (BCHP_HIFIDAC_CTRL0_TEST_TESTTONE_ENABLE_MASK |
610                                                                                                         BCHP_HIFIDAC_CTRL0_TEST_TESTTONE_SHARE_MASK |
611                                                                                                         BCHP_HIFIDAC_CTRL0_TEST_TESTTONE_LEFT_MASK |
612                                                                                                         (23 << BCHP_HIFIDAC_CTRL0_TEST_TESTTONE_REPEAT_LEFT_SHIFT)));
613                                /* Write every other sample */
614                                for (i = 0; i < s_10khz_samples_num; ++i)
615                                {
616                                        WriteReg32(BCHP_HIFIDAC_CTRL0_TESTTONE_SAMPLE_i_ARRAY_BASE + (i * 4),s_10khz_samples[i]);
617                                }
618                                break;
619
620                        case eIR_8:
621                                antenna_detect = bant_detect();
622                        case eIR_7:
623                                BDBG_WRN(("Status...\n"));
624                                bapp_sync(p_app);
625                                bgfx_fill_rect(&p_app->surf,0,0,eWIDTH,eHEIGHT,eCOLOR_CLEAR);
626                                bapp_flush_screen(p_app);
627                                status = true;
628                                cnt = 0;
629                                break;
630
631                        case eIR_9:
632                                BDBG_WRN(("Reset user settings...\n"));
633                                /* setup flash */
634                                bapp_reset_settings(p_app);
635
636                                /* update flash with new settings */
637                                bapp_save_settings(p_app);
638                                BDBG_WRN(("Factory reset complete, powering off...\n"));
639                                bos_sleep(200);
640                                bapp_do_poweroff(p_app);
641                                result = 1;
642                                break;
643
644                        case eIR_UP:
645                        case eIR_CH_UP:
646                                if (p_app->cur_ch_num == 2)
647                                        p_app->cur_ch_num = 0;
648                                else
649                                        p_app->cur_ch_num++;
650
651                                tune = true;
652                                break;
653
654                        case eIR_CH_DOWN:
655                        case eIR_DOWN:
656                                if (p_app->cur_ch_num == 0)
657                                        p_app->cur_ch_num = 2;
658                                else
659                                        p_app->cur_ch_num--;
660                                tune = true;
661                                break;
662
663                        case eIR_0:
664                        case eIR_5:
665                        default:
666                                break;
667                        }
668                        break;
669                }
670                break;
671        default:
672                break;
673        }
674
675        if (tune)
676        {
677                BDBG_WRN(("Channel index = %d...\n",p_app->cur_ch_num));
678                bapp_sync(p_app);
679                bgfx_fill_rect(&p_app->surf,0,0,eWIDTH,eHEIGHT,eCOLOR_CLEAR);
680                bapp_flush_screen(p_app);
681                bapp_tune(p_app);
682                tune = false;
683        }
684        return result; /* always handle event */
685}
686#endif /* CONFIG_BCM_FACTORY_TEST */
687
688
Note: See TracBrowser for help on using the repository browser.