source: svn/newcon3bcm2_21bu/dta/src/app/ntia/bscreen_debug.c @ 22

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