source: svn/newcon3bcm2_21bu/dst/dhl/src/DHL_AVCAP_Impl.c @ 76

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

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

  • Property svn:executable set to *
File size: 33.8 KB
Line 
1/*
2        DHL_AVCAP_Impl.c
3       
4        PHOENIX Driver HAL library
5        AudioVideo decoding/capture/output implementation
6
7        Copyright 2006 Digital STREAM Technology, Inc.
8        All Rights Reserved
9
10        $Id: DHL_AVCAP.c  v1.00 2006/04 cafrii Exp $
11
12*/
13
14
15
16#include "DHL_OSAL.h"
17#include "DHL_DBG.h"
18#include "DHL_Demux.h"
19
20#include "DHL_AVCAP.h"
21#include "DHL_AVCAP_Impl.h"
22#include "DHL_SYS_Impl.h"
23
24
25#include "bsettop.h"
26//#include "bchp_pcm.h"
27//#include "bmvd.h"
28#include "bavc.h"
29#include "bsettop_rfm.h"
30#include "bsettop_stream.h"
31#include "bsettop_smessage.h"
32#include "bsettop_display_priv.h"
33#include "bsettop_display.h"
34#include "bchp_vec_cfg.h"
35#include "bsettop.h"
36
37#include "bstd.h"
38#include "gist.h"
39#include "bchp_timer.h"
40
41
42#if COMMENT
43_______________(){}
44#endif
45
46
47// ch 3 or ch 4 output signal level
48//
49#define DHL_DEFAULT_RFM_VOLUME  70
50
51
52// cafrii 060427 Callback type ¼±¾ðÀ» header·Î À̵¿.
53// cafrii 060522 À§Ä¡ À̵¿
54
55tDHL_AVCALLBACK _DHL_AV_UserDataCallback;
56tDHL_AVCALLBACK _DHL_AV_ImportantVideoChangeCallback;
57tDHL_AVCALLBACK _DHL_AV_MajorVideoChangeCallback;
58tDHL_AVCALLBACK _DHL_AV_UserVideoChangeCallback;
59tDHL_AVCALLBACK _DHL_AV_VideoFreezeEndCallback;
60
61tDHL_AVCALLBACK _DHL_AV_DisplayFormatChangeCallback;
62
63tDHL_AVCALLBACK _DHL_AV_VideoScrambledCallback;
64
65
66
67#if COMMENT
68_______________(){}
69#endif
70
71int _DHL_AVCAP_DebugPrint(int level, char *fmt, ...);
72
73#define dprint _DHL_AVCAP_DebugPrint
74
75
76#if COMMENT
77_______________(){}
78#endif
79
80
81/*
82        cafrii comment:
83        in 3543, band is fixed as integer '0'.
84*/
85static bband_t band=0;
86static bdisplay_t display;
87static bdecode_t dhl_decode;
88static bdecode_window_t window;
89static bstream_t dhl_stream;
90static bstream_mpeg dhl_mpeg;
91//static bgraphics_t graphics;
92static baudio_decode_t audio;
93
94
95static int video_start = 0;
96static int audio_start = 0;
97        // each flag represents video/audio playback status.
98
99#define DHL_UNUSED_PID 0 //megakiss 2014.06.30 changed the value 0x1fff to 0x0 so that audio only channel with fixed vidoe can be played
100        // video decoder should be run even if audio only channel.
101        // in such case, if video pid is out of range,
102        //   decoder not working at all and audio also failed.
103        // so, we specify unused pid number as a default pid.
104        // this should be range of valid pids.
105
106
107#if COMMENT
108_______________(){}
109#endif
110
111/* cafrii 081218
112        sequence header ³»¿ë ÀÚüÀÇ ºñ±³´Â MW¿¡¼­ ¼öÇàÇϹǷÎ
113        interrupt ¹ß»ý ¿©ºÎÀ» ¾Ë·ÁÁÙ ¼ö ÀÖ´Â ÀÏ·Ã ¹øÈ£¸¸ Á¦°ø.
114*/
115static UINT32 g_dhl_seqhdr_generation_count = 0;
116
117BXVD_PictureParameterInfo g_dhl_stream_info;
118BOOL g_dhl_stream_info_valid;
119
120DHL_RESULT dhl_av_get_seq_hdr(tDHL_VideoSeqHdr *pSeq)
121{
122        //static DHL_VIDEO_SEQHDR *prev_seq_hdr=NULL;
123
124        BXVD_PictureParameterInfo info_0, *info = &info_0;
125        int i;
126        UINT32 flag;
127       
128        // neverdai ÇØ´çµÇ´Â °ÍÀÌ ¾ø´Â °æ¿ì, °¡Àå °¡±î¿î °ÍÀ¸·Î ġȯÇÑ´Ù.
129        UINT8 arTable[][2]={
130                {BFMT_AspectRatio_eUnknown, aspectRatioUnknown},
131                {BFMT_AspectRatio_eSquarePxl, SAR_SquarePixel},
132                {BFMT_AspectRatio_e4_3, DAR_3_4},
133                {BFMT_AspectRatio_e16_9, DAR_9_16},
134                {BFMT_AspectRatio_e221_1, DAR_1_2_21},
135                {BFMT_AspectRatio_e15_9, DAR_9_16},
136        };
137       
138        struct {
139                enum BAVC_FrameRateCode bfrcode;
140                MPEG_FRAME_RATE dhlfrcode;
141                float frame_rate;
142        } frCodeTable[]={
143                {BAVC_FrameRateCode_eUnknown,0,0},
144                {BAVC_FrameRateCode_e23_976,FRAMERATE_23_976,24*1000/1001.},
145                {BAVC_FrameRateCode_e24,FRAMERATE_24,24},
146                {BAVC_FrameRateCode_e25,FRAMERATE_25,25},
147                {BAVC_FrameRateCode_e29_97,FRAMERATE_29_97,30*1000/1001.},
148                {BAVC_FrameRateCode_e30,FRAMERATE_30,30},
149                {BAVC_FrameRateCode_e50,FRAMERATE_50,50},
150                {BAVC_FrameRateCode_e59_94,FRAMERATE_59_94,60*1000/1001.},
151                {BAVC_FrameRateCode_e60, FRAMERATE_60,60},
152        };
153
154        // cafrii 081218 disable interrupt.
155        // to avoid seq hdr interrupt race condition.
156        //
157        flag = DHL_OS_DisableInterrupts();
158
159        //if (!g_dhl_stream_info_valid) { // seqhdr not ready yet.
160        //      printf("[111]\n\n\n");
161        //      DHL_OS_RestoreInterrupts(flag);
162        //      return DHL_FAIL;
163        //}
164        if (pSeq==NULL) { // caller just want to know that seqhdr is ready or not.
165                printf("[222]\n\n\n");
166                DHL_OS_RestoreInterrupts(flag);
167                return DHL_OK;
168        }
169        *info = g_dhl_stream_info; // copy to local variable to minimize int disable
170        pSeq->generationNumber = g_dhl_seqhdr_generation_count;
171
172        DHL_OS_RestoreInterrupts(flag);
173
174        // now, all 'info' is local variable and no worry of race condition.
175       
176        pSeq->horizontal_size=info->ulSourceHorizontalSize;
177        pSeq->vertical_size=info->ulSourceVerticalSize;
178               
179        pSeq->aspect_ratio_information=aspectRatioUnknown;
180       
181        printf("[pSeq->horizontal_size(%d)]\n", pSeq->horizontal_size);
182        printf("[pSeq->vertical_size(%d)]\n", pSeq->vertical_size);
183        for(i=0; i<sizeof(arTable)/sizeof(arTable[0]); i++) {
184                if(info->eAspectRatio==arTable[i][0]) {
185                        pSeq->aspect_ratio_information=arTable[i][1];
186                        break;
187                }
188        }
189
190        pSeq->frame_rate_code = 0;
191        for(i=0; i<sizeof(frCodeTable)/sizeof(frCodeTable[0]); i++) {
192                if(info->eFrameRateCode==frCodeTable[i].bfrcode) {
193                        pSeq->frame_rate_code=frCodeTable[i].dhlfrcode;
194                        pSeq->frame_rate=frCodeTable[i].frame_rate;
195                        break;
196                }
197        }
198        printf("[pSeq->aspect_ratio_information(%d)]\n", pSeq->aspect_ratio_information);
199
200        pSeq->bit_rate=0;
201        pSeq->vbv_buffer_size=0;
202        pSeq->constrained_parameter_flag=0;
203        pSeq->MPEG2=0;
204        pSeq->profile_and_level_indication=0;
205        pSeq->progressive_sequence=info->bStreamProgressive;
206        pSeq->chroma_format=0;
207//      pSeq->low_delay=info->bLowDelay;
208
209       
210#if 0
211        if(prev_seq_hdr==NULL) { //óÀ½
212                prev_seq_hdr=OS_Malloc(sizeof(DHL_VIDEO_SEQHDR));
213                pSeq->generationNumber=0;
214                memcpy(prev_seq_hdr, pSeq, sizeof(*prev_seq_hdr));
215        }
216        else {
217                pSeq->generationNumber=prev_seq_hdr->generationNumber;
218
219#if 0           
220                //ºñ±³...
221                if(0!=memcmp(prev_seq_hdr, pSeq, sizeof(*prev_seq_hdr)))
222#else
223                if((prev_seq_hdr->horizontal_size != pSeq->horizontal_size) ||
224                        (prev_seq_hdr->vertical_size != pSeq->vertical_size) ||
225                        (prev_seq_hdr->aspect_ratio_information != pSeq->aspect_ratio_information) ||
226                        (prev_seq_hdr->frame_rate_code != pSeq->frame_rate_code) ||
227                        (prev_seq_hdr->progressive_sequence != pSeq->progressive_sequence))
228#endif         
229                { //º¯°æ °ªÀÌ ÀÖÀ½..
230                       
231                        pSeq->generationNumber++;
232                        memcpy(prev_seq_hdr, pSeq, sizeof(*prev_seq_hdr));
233                }
234        }
235       
236        printf("===========generatoin number.....(%d)\n", pSeq->generationNumber);
237#endif // 0
238        (*_DHL_AV_ImportantVideoChangeCallback)(eDHL_CB_VideoSeqHdr, &pSeq);   
239        return DHL_OK;
240}
241
242DHL_RESULT dhl_av_get_seq_hdr_info(void)
243{
244        static bdecode_status    status;
245        tDHL_VideoSeqHdr                                        *pSeq;
246        int framerate;
247        bdecode_get_status(dhl_decode,&status);
248
249        pSeq->horizontal_size = status.source_width;
250        pSeq->vertical_size = status.source_height;
251        pSeq->aspect_ratio_information = status.video_aspect_ratio;
252        pSeq->frame_rate_code =status.video_framerate;
253        pSeq->MPEG2=status.video_format;
254       
255        if(status.video_framerate == FRAMERATE_25)
256        framerate = 2500;
257  else if(status.video_framerate == FRAMERATE_29_97)
258        framerate = 2997;
259  else if(status.video_framerate == FRAMERATE_30)
260        framerate = 3000; 
261  else if(status.video_framerate == FRAMERATE_50)
262        framerate = 5000;
263  else if(status.video_framerate == FRAMERATE_59_94)
264        framerate = 5994;                       
265  else if(status.video_framerate == FRAMERATE_60)
266        framerate = 6000;
267       
268        pSeq->frame_rate =framerate;   
269       
270        pSeq->progressive_sequence = (status.bStreamProgressive) ? 1 : 0;
271               
272        (*_DHL_AV_ImportantVideoChangeCallback)(eDHL_CB_VideoSeqHdr, pSeq);
273
274}
275
276void dhl_av_disp_stop(BOOL onoff)
277{
278        if(onoff)
279        {
280                BREG_Write32( GetREG(), BCHP_VEC_CFG_SDSRC_0_SOURCE, 0);
281        }       
282        else
283        {
284                BREG_Write32( GetREG(), BCHP_VEC_CFG_SDSRC_0_SOURCE, 1);
285        }
286}
287
288DHL_RESULT dhl_av_video_hide(BOOL bHide)
289{
290        bdecode_config cfg;
291       
292        bdecode_get_config(dhl_decode,&cfg);
293       
294        if(bHide) cfg.mute=1;
295        else cfg.mute=0;
296       
297        bdecode_set_config(dhl_decode,&cfg);
298       
299        return DHL_OK;
300}
301
302
303DHL_RESULT dhl_av_video_resize(INT32 x, INT32 y, UINT32 w, UINT32 h)
304{
305        //TODO video resize°¡ Á¶ÀýµÉ ¼ö ÀÖ´ÂÁö .
306       
307        return DHL_OK;
308}
309
310
311DHL_RESULT dhl_av_video_freeze(BOOL bFreeze)
312{
313        //video freeze ±â´É Á¦°øÇÏÁö ¾ÊÀ½.
314        return DHL_OK;
315}
316
317DHL_RESULT dhl_av_get_video_pts(UINT32* p_vid_pts)
318{
319        bdecode_status status;
320        bdecode_get_status(dhl_decode,&status);
321        *p_vid_pts = status.video_pts;
322        return DHL_OK;
323}
324
325
326
327#if COMMENT
328_______________(){}
329#endif
330
331
332DHL_RESULT dhl_set_tuner_band(bband_t b)
333{
334        band=b;
335        return DHL_OK;
336}
337
338
339//refer to s_video_stream_types[] @ bsettop_decode.c
340static BAVC_VideoCompressionStd get_bcm_video_format(UINT16 uVidType)
341{
342        BAVC_VideoCompressionStd bcm_type=BAVC_VideoCompressionStd_eMPEG2;
343
344        switch(uVidType)
345        {
346                case eDHL_VIDEO_TYPE_MPEG1:
347                        bcm_type =      BAVC_VideoCompressionStd_eMPEG1;
348                        break;
349                case eDHL_VIDEO_TYPE_MPEG2:
350                        bcm_type =      BAVC_VideoCompressionStd_eMPEG2;
351                        break;
352                case eDHL_VIDEO_TYPE_MPEG4P2:
353                        bcm_type =      BAVC_VideoCompressionStd_eMPEG4Part2;
354                        break;
355                case eDHL_VIDEO_TYPE_H263:
356                        bcm_type =      BAVC_VideoCompressionStd_eH263;
357                        break;
358                case eDHL_VIDEO_TYPE_H264:
359                        bcm_type =      BAVC_VideoCompressionStd_eH264;
360                        break;
361                case eDHL_VIDEO_TYPE_VC1:
362                        bcm_type =      BAVC_VideoCompressionStd_eVC1;
363                        break;
364                case eDHL_VIDEO_TYPE_VC1SM:
365                        bcm_type =      BAVC_VideoCompressionStd_eVC1SimpleMain;
366                        break;
367                case eDHL_VIDEO_TYPE_DIVX311:   //BKTODO: divx has two codecs: MPEG-4 Part2, H.264/MPEG-4 AVC...
368                        bcm_type =      BAVC_VideoCompressionStd_eMPEG4Part2;//BAVC_VideoCompressionStd_eH264;
369                        break;
370                case eDHL_VIDEO_TYPE_AVS:
371                        bcm_type =      BAVC_VideoCompressionStd_eAVS;
372                        break;
373                case eDHL_VIDEO_TYPE_DC2:
374                        bcm_type =      BAVC_VideoCompressionStd_eMPEG2;
375                        break;
376                default://
377                        bcm_type =      BAVC_VideoCompressionStd_eMPEG2;
378                        break;
379        }
380        return bcm_type;
381}
382/*
383        caller can skip uAudPID at this time. (pid 0 for not specify)
384        later, when dhl_av_audio_start called, pid is checked again and update if it is not set before.
385*/
386DHL_RESULT dhl_av_video_start(UINT16 uVidPID, UINT16 uPcrPID, UINT16 uAudPID, UINT16 vid_type )
387{
388        bresult berr;
389
390        //printf("%s: vpid %x ppid %x apid %x vid_type %x\n", __FUNCTION__, uVidPID, uPcrPID, uAudPID, vid_type);
391        if (video_start) {
392                printf("!! video already run. vpid %x, pcr %x, apid %x\n",
393                        dhl_mpeg.video[0].pid, dhl_mpeg.pcr_pid, dhl_mpeg.audio[0].pid);
394                bdecode_stop(dhl_decode);
395                video_start = FALSE;
396        }
397       
398        if (uPcrPID == 0) {
399                printf("!! pcr pid invalid. set to 0x%x\n", uVidPID);
400                uPcrPID = uVidPID;
401        }
402
403        // µ¿½Ã¿¡ audio/video pid µî·ÏÇÑ´Ù.
404        // audio may already be started. so, check existing pid first.
405       
406        dhl_mpeg.video[0].pid = uVidPID;
407        dhl_mpeg.video[0].format = get_bcm_video_format(vid_type);
408        dhl_mpeg.pcr_pid = uPcrPID;
409
410        // if user specifies audio pid, set it here.
411        // actually, it does nothing but remeber pid values in 'stream'.
412        //
413        if (uAudPID && dhl_mpeg.audio[0].pid == DHL_UNUSED_PID)
414                dhl_mpeg.audio[0].pid=uAudPID;
415
416        if (dhl_stream) {
417                printf("!! dhl_stream already open. close first\n");
418                bstream_close(dhl_stream);
419        }
420        dhl_stream = bstream_open(band, &dhl_mpeg);
421        if(dhl_stream == NULL)
422        {
423                printf("\nERR: bstream_open failed\n\n");
424                        return DHL_FAIL_CORE_DRIVER;
425        }
426
427        if ((berr = bdecode_start(dhl_decode, dhl_stream, window)) != b_ok) {
428                printf("\nERR: bdecode_start failed\n\n");
429                bstream_close(dhl_stream);
430                dhl_stream = NULL;
431                return DHL_FAIL_CORE_DRIVER;
432        }
433
434        video_start = TRUE;
435
436        return DHL_OK;
437}
438
439
440void dhl_av_video_start_end(UINT16 uVidPID, UINT16 uPcrPID, BOOL bSuccess)
441{
442        if (bSuccess == FALSE)
443        {
444                printf("%s: video start failed\n", __FUNCTION__);
445               
446                // because we failed in decoding, (because of timeout or user cancel)
447                // we stop bcm_decode.
448
449                dhl_av_video_stop(uVidPID);
450        }
451}
452
453void dhl_av_video_stop(UINT16 uVidPID)
454{
455        //printf("%s: vpid %x\n\n\n", __FUNCTION__, uVidPID);
456        if (video_start) {
457                bdecode_stop(dhl_decode);
458        }
459        else
460                printf("!! video not started.\n");
461
462        g_dhl_stream_info_valid = FALSE;
463       
464        dhl_mpeg.video[0].pid = DHL_UNUSED_PID;
465
466        if (audio_start == FALSE) { // nothing run.
467                dhl_mpeg.pcr_pid = 0;
468                printf("\t now, nothing run.\n");
469
470                if (dhl_stream) {
471                        printf("\t close dhl_stream\n");
472                        bstream_close(dhl_stream);
473                        dhl_stream = NULL;
474                }               
475        }
476       
477        video_start = FALSE;
478}
479
480
481BOOL dhl_av_video_decoding_ready(void)
482{
483        return dhl_av_get_seq_hdr(NULL)==DHL_OK?TRUE:FALSE;
484}
485
486
487#if COMMENT
488_______________(){}
489#endif
490
491
492DHL_RESULT dhl_av_disp_start(void)
493{
494        return DHL_OK;
495}
496
497
498/*
499       
500
501*/
502DHL_RESULT dhl_av_change_display_format(tDHL_DispPort output, tDHL_DispFormat format, 
503                                                                tDHL_DispARC adjustment)
504{
505        /*adjustment¸¸ ´ëÀÀÀÌ µÇ¸é µÉ °Í °°À½*/
506       
507        dhl_av_change_display_adjustment(adjustment, NULL);
508       
509        return DHL_OK;
510}
511
512
513/*
514
515
516*/
517DHL_RESULT dhl_av_change_display_adjustment(tDHL_DispARC adj, DHL_WINRECT *rect)
518{
519        bdisplay_settings settings;
520
521        bdisplay_get(display, &settings);
522        if(adj == eDHL_ARC_FULLSCREEN)
523        {
524                settings.sd_options = bdisplay_sd_output_options_full;
525                bdisplay_set(display, &settings);
526        }
527        else if(adj == eDHL_ARC_LETTERBOX)
528        {
529                settings.sd_options = bdisplay_sd_output_options_widescreen;
530                bdisplay_set(display, &settings);
531        }
532        else if(adj == eDHL_ARC_ZOOM2)
533        {
534                settings.sd_options = bdisplay_sd_output_options_zoom;
535                bdisplay_set(display, &settings);
536        }
537        else
538        {
539                settings.sd_options = bdisplay_sd_output_options_full;
540                bdisplay_set(display, &settings);
541        }
542
543        return DHL_OK;
544}
545
546/*
547        it is recommended that audio is muted temporarily.
548*/
549void dhl_av_disp_change_rfm(int ch)
550{
551extern  brfm_t                          g_sys_rfm;
552
553
554        if (ch != 3 && ch != 4)
555                return;
556        if(ch==3)
557                brfm_set_ch3(g_sys_rfm,0);
558        else
559                brfm_set_ch3(g_sys_rfm,1);
560}
561
562
563
564#if COMMENT
565_______________(){}
566#endif
567
568
569
570// logical volume level (0 ~ 100).
571// it is NOT the actual device volume level that is currently set.
572// if decoder mute is ON, device volume becomes zero, but logical volume is kept unchanged.
573
574int g_dhl_audio_volume;
575
576
577// this is boolean value. it tracks current audio mute status.
578
579int g_dhl_audio_muted = FALSE;
580
581// this is boolean value. it tracks current audio temp mute status.
582
583int g_dhl_audio_temp_muted = FALSE;
584
585
586UINT32 dhl_av_audio_frame_count(void)
587{
588        bresult br;
589        baudio_decode_status status;
590
591        br = baudio_decode_get_status(audio, &status);
592        if (br != b_ok) return 0;
593
594        return status.pts;
595}
596
597
598//refer to s_audio_stream_types @ bdecode_audio_raaga.c
599static BAVC_AudioCompressionStd get_bcm_audio_format(tDHL_AudioCodingType AudStreamType)
600{
601        BAVC_AudioCompressionStd aud_type;
602        switch(AudStreamType)
603        {
604                case eDHL_AUDIO_TYPE_AC3:
605                        aud_type = BAVC_AudioCompressionStd_eAc3;
606                        break;
607                case eDHL_AUDIO_TYPE_DTS:
608                        aud_type = BAVC_AudioCompressionStd_eDts;
609                        break;
610                case eDHL_AUDIO_TYPE_MPEG_L1:
611                        aud_type = BAVC_AudioCompressionStd_eMpegL1;
612                        break;
613                case eDHL_AUDIO_TYPE_MPEG_L2:
614                        aud_type = BAVC_AudioCompressionStd_eMpegL2;
615                        break;
616                case eDHL_AUDIO_TYPE_MPEG_L3:
617                        aud_type = BAVC_AudioCompressionStd_eMpegL3;
618                        break;
619        //BKTODO: AC3+
620#if 0
621                case eDHL_AUDIO_TYPE_PCM:
622                        aud_type = BAVC_AudioCompressionStd_ePcm;
623                        break;
624                case eDHL_AUDIO_TYPE_AAC_ADTS:
625                        aud_type = BAVC_AudioCompressionStd_eAacAdts;
626                        break;
627                case eDHL_AUDIO_TYPE_AAC_LATM:
628                        aud_type = BAVC_AudioCompressionStd_eAacPlus;   //BKTODO: BAVC_AudioCompressionStd_eAacLoas;
629                        break;
630
631                case eDHL_AUDIO_TYPE_MPEG_1:
632                case eDHL_AUDIO_TYPE_MPEG_2:
633                case eDHL_AUDIO_TYPE_MPEG_4:
634#endif
635                default:
636                        aud_type = BAVC_AudioCompressionStd_eMax;//default: no audio.
637                        break;
638        }
639        return aud_type;
640}
641
642
643
644/*
645        audio decoder¸¦ ±âµ¿ÇÏ´Â ÇÔ¼ö.
646        BCM¿¡¼­´Â audio, video¸¦ µ¿½Ã¿¡ Stop StartÇÒ¼ö ÀÖ´Â API Á¦°ø
647*/
648bstream_mpeg temp_mpeg;
649
650DHL_RESULT dhl_av_audio_start(UINT16 uAudPID, UINT16 uPcrPID, tDHL_AudioCodingType AudStreamType)
651{
652        bresult berr;
653
654        //printf("%s: apid %x, pcrpid %x\n", __FUNCTION__, uAudPID, uPcrPID);
655        if (audio_start) {
656                printf("!! audio already run. pid %x, pcr %x, vid %x. stop first..\n", 
657                        dhl_mpeg.audio[0].pid, dhl_mpeg.pcr_pid, dhl_mpeg.video[0].pid);
658
659                baudio_decode_stop(audio);
660                audio_start = FALSE;
661        }
662
663        /*
664                if stream is not run, we make new stream and start temporary decode.
665                if stream is already run, we should match audio pid. if matched, its ok!
666               
667        */
668        //neverdai 080907 audio¸¦ ¹Ù²Ü ¶§ ºñµð¿À°¡ ±ô¹ÚÀÌ´Â ¹®Á¦ ¼öÁ¤
669        if (video_start == FALSE) 
670        {
671       
672                if (dhl_mpeg.pcr_pid != uPcrPID && dhl_mpeg.video[0].pid != DHL_UNUSED_PID)
673                        printf("!! pcr for video %x != pcr for audio %x\n", dhl_mpeg.pcr_pid, uPcrPID);
674
675                // previous dhl_mpeg and stream should be reset.
676                temp_mpeg.video[0].pid = dhl_mpeg.video[0].pid;
677                temp_mpeg.audio[0].pid = uAudPID;
678                temp_mpeg.audio[0].format = get_bcm_audio_format(AudStreamType);
679                temp_mpeg.pcr_pid = uPcrPID;
680
681                printf("\t stream open: audio %x, pcr %x, video %x\n", 
682                        temp_mpeg.audio[0].pid, temp_mpeg.pcr_pid, temp_mpeg.video[0].pid);
683                dhl_stream = bstream_open(band, &temp_mpeg);
684
685                // now, stream and decode is working. update with new parameter.
686                dhl_mpeg = temp_mpeg;
687
688        }
689        else if(dhl_mpeg.audio[0].pid != uAudPID || dhl_mpeg.pcr_pid != uPcrPID)
690        {
691#if 0
692                dhl_stream->dhl_mpeg.audio[0].pid=uAudPID;
693                dhl_stream->dhl_mpeg.pcr_pid=uPcrPID;
694#else//BK
695                dhl_mpeg.audio[0].pid=uAudPID;
696                dhl_mpeg.pcr_pid=uPcrPID;
697                dhl_mpeg.audio[0].format = get_bcm_audio_format(AudStreamType);
698                bstream_update_mpeg(dhl_stream, &dhl_mpeg);
699#endif
700        }
701
702        if ((berr = baudio_decode_start(audio, (void *)1, dhl_stream)) != b_ok) {
703                printf("!! baudio_decode_start err %d\n", berr);
704                return DHL_FAIL_CORE_DRIVER;
705        }
706        // cafrii 081006 add
707//BKTODO:       bstream_force_update_pcr_pid(band, uPcrPID);
708        audio_start = TRUE;
709
710        return DHL_OK;
711}
712
713
714
715/*
716        audio decodingÀÌ ¼º°øÀûÀ¸·Î ¼öÇà µÇ¾ú°Å³ª
717        decodingÀÌ ¾î¶² ÀÌÀ¯·Î ½ÇÆÐÇÑ °æ¿ì µÚó¸® ÇÏ´Â ÇÔ¼ö.
718*/
719void dhl_av_audio_start_end(UINT16 uAudPID, UINT16 uPcrPID, BOOL bSuccess)
720{
721        if (bSuccess == FALSE)
722        {
723                printf("%s: audio start failed\n", __FUNCTION__);
724       
725                // because we failed in decoding, (because of timeout or user cancel)
726                // we stop audio by calling driver api.
727                dhl_av_audio_stop(uAudPID);
728        }
729}
730
731void dhl_av_audio_stop(UINT16 uAudPID)
732{
733        //printf("[audio stop]%s: pid %x, video_run %d\n\n\n", __FUNCTION__, uAudPID, video_start);
734        if (audio_start) {
735                baudio_decode_stop(audio);
736        }
737        else
738                printf("!! audio not started\n");
739
740        if (video_start == FALSE) { // nothing is running now.
741                printf("\t now, nothing run. cur flag: v %d\n", video_start);
742
743                if (dhl_stream) {
744                        printf("\t close stream..\n");
745                        bstream_close(dhl_stream);
746                        dhl_stream = NULL;
747                }
748        }
749        else
750                printf("\t video still running\n");
751       
752        dhl_mpeg.audio[0].pid = DHL_UNUSED_PID;
753        audio_start = FALSE;
754}
755
756
757
758/*
759        Audio mute½Ã SPDIF & LR µ¿½Ã Àû¿ë..
760        todo : µû·Î ºÐ¸®°¡ ÇÊ¿ä?
761*/
762DHL_RESULT dhl_av_audio_set_spdif_mode(tDHL_AudioIecOutFormat iecOutputMode)
763{
764        return DHL_OK;
765}
766
767
768
769/*
770        note!
771        decoder mute should work independent to audio volume.
772*/
773DHL_RESULT dhl_av_audio_mute_control(tDHL_AudioMutePlace mutePlace, BOOL bMute)
774{
775        baudio_decode_config config;
776        if (mutePlace == eDHL_AUDIO_MUTE_DECODER)
777        {
778                if (bMute) {
779                        // mute on the audio decoder (or pcm engine)
780                        g_dhl_audio_muted = TRUE;
781                        baudio_decode_get_config(audio, &config);
782                        config.mute = (bMute == 0) ? false : true;
783                        baudio_decode_set_config(audio, &config);
784                }
785                else {
786                        g_dhl_audio_muted = FALSE;
787                        if (g_dhl_audio_temp_muted == FALSE)
788                                dhl_av_audio_set_volume(g_dhl_audio_volume);
789                }
790        }
791        else if (mutePlace == eDHL_AUDIO_MUTE_GPIO)
792        {
793                // mute on external audio mute logic
794//BKTODO:               dhl_sys_gpio_rw(GPIO_AUDIO_UNMUTE, bMute ? 0 : 1, TRUE);
795        }
796        else
797        {
798                return DHL_FAIL_NOT_AVAILABLE;
799        }
800        return DHL_OK;
801}
802       
803
804DHL_RESULT dhl_av_audio_get_channel_info(BOOL *pbSurround, BOOL *pbStereo)
805{
806        baudio_decode_config config;
807       
808        *pbSurround=FALSE;
809        *pbStereo=FALSE;
810       
811        baudio_decode_get_config(audio, &config);
812#if 0//BKTODO::
813        if(config.acmod>=3) *pbSurround = TRUE;
814        if(config.acmod==2) *pbStereo = TRUE;
815#endif
816        return DHL_OK;         
817}
818
819
820
821DHL_RESULT dhl_av_audio_set_delay(int nDelay, int nIecDelay)
822{
823        return DHL_OK;
824}
825
826#if 0
827DHL_RESULT dhl_av_audio_temp_mute(BOOL bMute)
828{
829        if (bMute) {
830                // mute on the audio decoder (or pcm engine)
831                g_dhl_audio_temp_muted = TRUE;
832                WriteReg32(BCHP_PCM_PB0_VOLUME, 0);
833        }
834        else {
835                g_dhl_audio_temp_muted = FALSE;
836                if (g_dhl_audio_muted == FALSE)
837                        dhl_av_audio_set_volume(g_dhl_audio_volume);
838        }
839        return DHL_OK;
840}
841#endif
842/*
843        uVolLvl range is logical volume level and range of 0 ~ 100.
844*/
845#define DEVICE_VOL_MIN  0
846#define DEVICE_VOL_MAX  32      /*refer to bcm ref. Vol_DB[]*/
847#define LOGICAL_VOL_RANGE       100
848
849DHL_RESULT dhl_av_audio_set_volume(UINT16 uVolLvl)
850{
851//      UINT32 vol;  // this is actual device volume.
852        unsigned int level = uVolLvl*(DEVICE_VOL_MAX-DEVICE_VOL_MIN)/LOGICAL_VOL_RANGE;
853
854        g_dhl_audio_volume = level;
855        baudio_decode_config  config;
856
857        // cafrii 081217 bugfix, consider 'g_dhl_audio_temp_muted'
858        if (g_dhl_audio_muted == FALSE && 
859                g_dhl_audio_temp_muted == FALSE)
860        {
861                baudio_decode_get_config(audio, &config);
862                config.mute = false;
863                config.left_volume = config.right_volume = level;
864                baudio_decode_set_config(audio, &config);
865        }
866
867        return DHL_OK;
868}
869
870
871
872
873#if COMMENT
874________________(){}
875#endif
876
877
878#if 1 // DYNAMIC_AC3_PARAM
879
880//#include "mips_sai_ddcd.h"
881// this header file is conflict on base type definition.
882
883/*
884// mode: Dolby Digital dynamic range compression modes
885enum {  MIPS_SAI_DDCD_COMP_CA,          // custom mode, analog dialnorm
886        MIPS_SAI_DDCD_COMP_CD,          // custom mode, digital dialnorm
887        MIPS_SAI_DDCD_COMP_LO,          // line out mode
888        MIPS_SAI_DDCD_COMP_RF,          // RF remod mode
889        MIPS_SAI_DDCD_NUM_COMP_MODES    };
890
891// mono_mode: Dolby Digital dual-mono modes
892enum {  MIPS_SAI_DDCD_DM_MODE_ST,       // stereo
893        MIPS_SAI_DDCD_DM_MODE_LM,       // left mono
894        MIPS_SAI_DDCD_DM_MODE_RM,       // right mono
895        MIPS_SAI_DDCD_DM_MODE_MM,       // mixed mono
896        MIPS_SAI_DDCD_NUM_DM_MODES      };
897
898// stereo_mode: Dolby Digital stereo modes
899enum {  MIPS_SAI_DDCD_ST_MODE_AUTO,     // auto-detect
900        MIPS_SAI_DDCD_ST_MODE_LTRT,     // dolby surround compatible (Lt/Rt)   
901        MIPS_SAI_DDCD_ST_MODE_LORO,     // stereo (Lo/Ro)
902        MIPS_SAI_DDCD_NUM_ST_MODES      };
903
904*/
905
906/* test:
907
908dhl_av_audio_set_ac3_params 3 1 0 2 // rf, mono
909dhl_av_audio_set_ac3_params 3 0 0 2 // rf, stereo
910dhl_av_audio_set_ac3_params 2 0 0 0 // line
911
912*/
913
914
915#define AUD_RESTART_AT_CHG 0
916// it is risky to stop audio.
917// to do this, it should be guaranteed that ac3 task stop completely, but it is difficult.
918// instead, we provide parameter change on the fly.
919
920void dhl_av_audio_set_ac3_params(int mode, int mono, UINT32 mono_mode, UINT32 stereo_mode)
921{
922        baudio_decode_config config;
923        int changed = FALSE;
924
925#if AUD_RESTART_AT_CHG
926        /* need to stop audio in order to set value */
927        if (audio_start) {
928                printf("audio run. pid %x. stop first..\n", dhl_mpeg.audio[0].pid);
929                baudio_decode_stop(audio);
930                bos_sleep(1000); // should be long enough to consume all PES in ac3 task. who knows?
931        }
932#endif
933
934        baudio_decode_get_config(audio, &config);
935
936        //printf("#### comp %d, mono %d, mmode %d, smode %d, acmod %d\n",
937        //              config.comp_mode, config.mono, config.mono_mode, config.stereo_mode, config.acmod);
938#if 0//BKTODO   
939        if (config.comp_mode != mode) {
940                changed = true;
941                config.comp_mode = mode;
942        }
943        if (config.mono != mono) {
944                config.mono = mono;
945                changed = true;
946        }
947        if (config.mono_mode != mono_mode) {
948                config.mono_mode = mono_mode;
949                changed = true;
950        }
951        if (config.stereo_mode != stereo_mode) {
952                config.stereo_mode = stereo_mode;
953                changed = true;
954        }
955#endif
956        baudio_decode_set_config(audio, &config);
957
958#if AUD_RESTART_AT_CHG
959        if (audio_start) {
960                printf("restart audio, pid %x\n", dhl_mpeg.audio[0].pid);
961                baudio_decode_start(audio, (void *)1, dhl_stream);
962        }
963#endif
964}
965
966#endif // DYNAMIC_AC3_PARAM
967
968
969
970
971#if COMMENT
972________________(){}
973#endif
974
975
976
977
978DHL_RESULT dhl_av_exec_callback(tDHL_AVCallbackType CBType, DHL_VIDEO_CONTEXT *context, UINT32 param)
979{
980       
981        switch (CBType)
982        {
983                case eDHL_CB_VideoSeqHdr: // Sequence Haeder Information
984                        if (_DHL_AV_ImportantVideoChangeCallback)
985                                (*_DHL_AV_ImportantVideoChangeCallback)(CBType, param);
986                        break;
987                       
988                case eDHL_CB_VideoUserData: // CC User Data Parser
989                  if (_DHL_AV_UserDataCallback)
990                                (*_DHL_AV_UserDataCallback)(CBType, param);
991                        break;
992               
993                case eDHL_CB_FirstVideoShow:
994                        if (_DHL_AV_MajorVideoChangeCallback)
995                                (*_DHL_AV_MajorVideoChangeCallback)(CBType, param);
996                        break;
997#if 0
998                //case DHL_CB_NOTIFY_VSTARTING:
999                //      g_dhlav.pAvStartingCallBack = (P_DHL_VDC_CALLBACK)pCallBack;
1000                //      g_dhlav.uStartingUserContext = ClientCntx;
1001                //      break;
1002
1003                //case DHL_CB_NOTIFY_VSTOPPING:
1004                //      g_dhlav.pAvStoppingCallBack = (P_DHL_VDC_CALLBACK)pCallBack;
1005                //      g_dhlav.uStoppingUserContext = ClientCntx;
1006                //      break;
1007
1008                //case DHL_CB_NOTIFY_DISPINITIALIZE:
1009                //      g_dhlav.pDispInitCallBack = (P_DHL_VDC_CALLBACK)pCallBack;
1010                //      g_dhlav.uDispInitUserContext = ClientCntx;
1011                //      break;
1012
1013                case DHL_CB_NOTIFY_DISPCHANGE:
1014                        if (_DHL_AV_DisplayFormatChangeCallback)
1015                                (*_DHL_AV_DisplayFormatChangeCallback)(context, param);
1016                        break;
1017
1018
1019                case DHL_CB_NOTIFY_USERVIDEOCHANGE:
1020                        if (_DHL_AV_UserVideoChangeCallback)
1021                                (*_DHL_AV_UserVideoChangeCallback)(context, param);
1022                        break;
1023
1024                case DHL_CB_NOTIFY_VIDEOFREEZEEND:
1025                        if (_DHL_AV_VideoFreezeEndCallback)
1026                                (*_DHL_AV_VideoFreezeEndCallback)(context, param);
1027                        break;
1028
1029                case DHL_CB_NOTIFY_VIDEOSCRAMBLED:
1030                        if (_DHL_AV_VideoScrambledCallback)
1031                                (*_DHL_AV_VideoScrambledCallback)(context, param);
1032                        break;
1033#endif
1034                default:
1035                        break;
1036        }
1037
1038        return DHL_OK;
1039}
1040
1041void  test_eia708_cb(unsigned char* data,          /* the data buffer, containing data_len valid bytes */
1042                int data_len,                      /* the number of valid bytes in data */
1043                bool banalog
1044                )
1045{
1046
1047        static tDHL_UserData dhl_ud;
1048        // DHL_VIDEO_CONTEXT *context=NULL;
1049        static unsigned char rcv_ud[CC_BUF_SIZE];
1050        //UINT8 flags;
1051        //flags = bos_enter_critical();
1052
1053        if (data_len < 3 || data_len > CC_BUF_SIZE)
1054        {
1055                printf("%s:%d data_len %d > %d\n",__FUNCTION__,__LINE__,data_len,CC_BUF_SIZE);
1056                // bos_exit_critical(flags);
1057                return;
1058        }
1059
1060        //memset(&dhl_ud, 0, sizeof(tDHL_UserData));   
1061        memcpy(rcv_ud,data,data_len);   
1062        dhl_ud.pdata = rcv_ud;
1063        dhl_ud.hdr.payload_size = (UINT32)data_len;
1064       
1065        //bos_exit_critical(flags);
1066
1067        (*_DHL_AV_UserDataCallback)(eDHL_CB_VideoUserData, &dhl_ud);
1068}
1069
1070static void test_first_pts_callback()
1071{
1072        printf("[test_first_pts_callback!!!]\n");
1073}
1074static void test_seq_hdr_callback()
1075{
1076        printf("[test_seq_hdr_callback!!!]\n");
1077}
1078       
1079static void p_exec_callback(enum bdecode_callback_type cb_type, void *param)
1080{
1081        DHL_VIDEO_CONTEXT *context=NULL; //neverdai ½ÇÁ¦·Î »ç¿ëÇÏ´Â °÷ÀÌ ¾øÀ½
1082                // ÀúÀåÀ» ÇØ ³õÁö ¾Ê¾Æ¼­ ÇöÀç·Î¼­´Â Àü´Þ ºÒ°¡´É.
1083                // todo:
1084                //  user param ±â¾ïÇØ¼­ Ãß°¡Çϱâ.
1085        UINT32 flag;
1086        bdecode_config cfg;
1087        tDHL_UserData *dhl_ud;
1088        switch(cb_type) {
1089                case bdecode_callback_type_userdata :
1090
1091                        bdecode_get_config(dhl_decode,&cfg);
1092                       
1093                        cfg.cc_enabled = 1;
1094                        cfg.cc_callback = test_eia708_cb;                       
1095                       
1096                        bdecode_set_config(dhl_decode,&cfg);
1097                                               
1098                        //dhl_av_exec_callback(eDHL_CB_VideoUserData, context, (UINT32)param);
1099                        break;
1100                       
1101                case bdecode_callback_type_vec_isr :
1102                       
1103                        break;
1104                       
1105                case bdecode_callback_type_seq_hdr_isr :
1106                        printf("===== seq_hdr_isr: count %u\n", g_dhl_seqhdr_generation_count);
1107
1108                        bdecode_get_config(dhl_decode,&cfg);
1109       
1110                        cfg.seq_hdr_callback = dhl_av_get_seq_hdr_info;
1111
1112                        bdecode_set_config(dhl_decode,&cfg);
1113
1114                        //dhl_av_exec_callback(eDHL_CB_VideoSeqHdr, context, (UINT32)param);
1115                        break;
1116                       
1117                default :
1118                        ;
1119        }
1120}
1121
1122DHL_RESULT dhl_av_register_callback(tDHL_AVCALLBACK pCallBack, 
1123                                                tDHL_AVCallbackType CBType)
1124{
1125        DHL_RESULT dhlResult = DHL_OK;
1126
1127        //printf("DHL_AV_PresetCallback(reg: type %d, fn 0x%x)\n", CBType, pCallBack);
1128
1129        switch (CBType)
1130        {
1131                case eDHL_CB_VideoSeqHdr:               //Sequence Haeder Information
1132                        _DHL_AV_ImportantVideoChangeCallback = (tDHL_AVCALLBACK)pCallBack;
1133                        bdecode_register_callback(bdecode_callback_type_seq_hdr_isr, p_exec_callback);
1134                        break;
1135                       
1136                case eDHL_CB_VideoUserData:             //CC User Data Parser
1137                        _DHL_AV_UserDataCallback = (tDHL_AVCALLBACK)pCallBack;         
1138                        bdecode_register_callback(bdecode_callback_type_userdata, p_exec_callback);
1139                        break;
1140                       
1141                case eDHL_CB_FirstVideoShow:            //BKTODO: newcon3...?
1142                        _DHL_AV_VideoFreezeEndCallback = (tDHL_AVCALLBACK)pCallBack;
1143                        break;
1144#if 0//BKTODO
1145
1146                case DHL_CB_NOTIFY_DISPCHANGE:
1147                        _DHL_AV_DisplayFormatChangeCallback = (P_DHL_VDC_CALLBACK)pCallBack;
1148                        break;
1149                       
1150                case DHL_CB_NOTIFY_MAJORCHANGE:
1151                        _DHL_AV_MajorVideoChangeCallback = (P_DHL_VDC_CALLBACK)pCallBack;
1152                        break;
1153
1154                case DHL_CB_NOTIFY_USERVIDEOCHANGE:
1155                        _DHL_AV_UserVideoChangeCallback = (P_DHL_VDC_CALLBACK)pCallBack;
1156                        break;
1157                case DHL_CB_NOTIFY_VIDEOSCRAMBLED:
1158                        _DHL_AV_VideoScrambledCallback = (P_DHL_VDC_CALLBACK)pCallBack;
1159                        break;
1160#endif
1161                default:                       
1162                        break;
1163        }
1164
1165        return dhlResult;
1166}
1167
1168
1169
1170
1171#if 0 // userdata interface is implemented in CCDDI.
1172
1173int g_dhl_ud_dump_count;
1174
1175void dhl_av_userdata_callback(void *param)
1176{
1177        BAVC_USERDATA_info *ui = (BAVC_USERDATA_info *)param;
1178
1179#if 0
1180        BAVC_USERDATA_Type_eSeq=1,       /* User data coming in the Sequence Header */
1181        BAVC_USERDATA_Type_eGOP,         /* User data coming in the Gop Header */
1182        BAVC_USERDATA_Type_ePicture,     /* User Data coming in Picture Header */
1183#endif
1184
1185        //if (ui->eUserDataType != BAVC_USERDATA_Type_ePicture)
1186        //      return;
1187
1188        if (g_dhl_ud_dump_count > 0)
1189        {
1190        #if 0
1191                UINT8 *p = ui->pUserDataBuffer;
1192                printf("[UD] %d %d: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
1193                                ui->eUserDataType,
1194                                ui->ui32UserDataBufSize,
1195                                p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9]);
1196        #else
1197                printf("*** userdata, type %d, len %d\n", ui->eUserDataType, ui->ui32UserDataBufSize);
1198        #endif
1199                memdump(ui->pUserDataBuffer, ui->ui32UserDataBufSize, "userdata");
1200                g_dhl_ud_dump_count--;
1201        }
1202
1203#if 1
1204
1205        //DHL_AV_ExecuteCallback(DHL_CB_VDC_CCUDP, ??);
1206
1207       
1208       
1209
1210#endif
1211
1212}
1213
1214
1215void dhl_av_userdata_init()
1216{
1217        // bcm driver ³»ÀÇ user data isr ÂÊ¿¡ callbackÀ» µî·ÏÇÑ´Ù.
1218
1219        bdecode_register_callback(bdecode_callback_type_userdata, dhl_av_userdata_callback);
1220}
1221
1222/*
1223        vbi out µÇ´Â line21 embeddingÀ» on/off ÇÑ´Ù.
1224*/
1225void dhl_av_vbi_enable_output(int enable)
1226{
1227        bdecode_config cfg;
1228        bdecode_get_config(dhl_decode,&cfg);
1229        if (cfg.cc_enabled != enable)
1230        {
1231                cfg.cc_enabled = (enable == 0) ? 0 : 1;
1232                bdecode_set_config(dhl_decode,&cfg);
1233        }
1234}
1235
1236#endif // 0
1237
1238
1239
1240#if COMMENT
1241________________(){}
1242#endif
1243
1244
1245#if 0
1246DHL_RESULT dhl_av_command(int param, UINT32 value)
1247{
1248        DHL_RESULT dhlResult = DHL_OK;
1249       
1250        switch (param)
1251        {
1252        case eDHL_AVCFG_GET_RMM:
1253                {
1254                        void *handle;
1255                        BMVD_VideoParams video_param;
1256                       
1257                        bdecode_get_channel_handle(&handle);
1258                        BMVD_GetVideoParams(handle, &video_param);
1259                       
1260                        *(BOOL *)value = !!video_param.bEnableRMM;
1261                }
1262                break;
1263
1264        default:
1265                dhlResult = DHL_FAIL_NOT_IMPLEMENTED;
1266                break;
1267        }
1268
1269        return dhlResult;
1270}
1271
1272#endif
1273
1274#if COMMENT
1275________________(){}
1276#endif
1277
1278
1279#if DHL_REGISTER_DEUBG_SYMBOLS
1280
1281static DHL_SymbolTable dhl_av_symbols[] =
1282{
1283        //DHL_VAR_SYM_ENTRY(g_dhl_ud_dump_count),
1284
1285};
1286
1287#endif
1288
1289#if COMMENT
1290________________(){}
1291#endif
1292
1293
1294
1295//DHL_RESULT dhl_playtunerinit();
1296// ÇÔ¼ö À§Ä¡ À̵¿.
1297// BCM AV Init Code
1298// todo : OpenÇÏ´Â °úÁ¤±îÁö °°ÀÌ ³Ö´Â´Ù.  ºÐ¸® ÇÒ°ÍÀÎÁö °í·ÁÇØ º¼°Í.
1299//              BCMÀº Init, Open, StartÇÏ´Â °úÁ¤ÀÌ ³ª´©¾îÁ® À־, Á»´õ ±¸ºÐÀÌ ÇÊ¿äÇÔ. Á¤¸® ÇÒ°Í.
1300DHL_RESULT dhl_av_init(void)
1301{
1302        bdisplay_settings settings;
1303        bdecode_config cfg;
1304
1305#if DHL_REGISTER_DEUBG_SYMBOLS
1306        DHL_DBG_RegisterSymbols(dhl_av_symbols, DHL_NUMSYMBOLS(dhl_av_symbols));
1307#endif
1308
1309        display=bdisplay_open(B_ID(0));
1310       
1311        // neverdai..comment 080908 TODO : interface¸¦ ÅëÇØ display¸¦ graphic¿¡ Àü´ÞÇÏ´Â °ÍÀÌ ÁÁÀ½
1312       
1313        {
1314                extern void dhl_set_display(bdisplay_t);
1315                dhl_set_display(display);
1316        }
1317       
1318//      graphics = bgraphics_open(B_ID(0),display);
1319       
1320        dhl_decode=bdecode_open(0);
1321
1322        smessage_init(NULL);
1323
1324
1325        // cafrii 080910 add.
1326        // bapp.c: bapp_init() Âü°íÇÔ.
1327        audio = baudio_decode_open(B_ID(0));
1328       
1329        window=bdecode_window_open(0, display);
1330
1331       
1332        bdisplay_get(display,&settings);
1333
1334        // DHL_GPIO should be initialized before AV init.
1335#if 0//BKTODO   
1336        settings.output = dhl_sys_gpio_rw(GPIO_CH34_SW_IN, 0, 0) ? eRFM_CH4 : eRFM_CH3;
1337        settings.volume = DHL_DEFAULT_RFM_VOLUME;
1338
1339        printf("## RFM switch is ch %d", settings.output == eRFM_CH3 ? 3 : 4);
1340#endif
1341        bdisplay_set(display,&settings);
1342
1343       
1344        bdecode_get_config(dhl_decode,&cfg);
1345       
1346        cfg.cc_enabled = 1;
1347        //cfg.cc_callback = test_eia708_cb;
1348        //cfg.first_pts_callback = test_first_pts_callback;
1349        cfg.seq_hdr_callback = dhl_av_get_seq_hdr_info;
1350        cfg.mute = 0;
1351
1352        cfg.widescreen=0;
1353//      cfg.static_fields[0] = &s_field_info_0;
1354//      cfg.static_fields[1] = &s_field_info_1;
1355
1356        bdecode_set_config(dhl_decode,&cfg);
1357       
1358        bstream_mpeg_init(&dhl_mpeg);
1359
1360        // cafrii 080924, use our own reset value.
1361        dhl_mpeg.video[0].pid = DHL_UNUSED_PID;
1362        dhl_mpeg.audio[0].pid = DHL_UNUSED_PID;
1363
1364       
1365        return DHL_OK;
1366}
1367
1368
1369
1370DHL_RESULT dhl_av_terminate(void)
1371{
1372        return DHL_OK; 
1373}
1374
1375
1376
1377#if COMMENT
1378_______________(){}
1379#endif
1380
1381/*
1382        Test Code
1383*/
1384#if 0
1385//  RF 81 freq : 567000000
1386//  RF 82 freq : 573000000
1387//  RF 83 freq : 579000000
1388//  RF 84 freq : 585000000
1389void TestVSB_Tuneinit(int freq)
1390{
1391#if 0
1392        btuner_t tuner;
1393        btuner_vsb_params vsb;
1394       
1395        btuner_vsb_params_init(&vsb, tuner);
1396        vsb.mode = btuner_vsb_mode_vsb8;
1397
1398        band = btuner_tune_vsb(tuner, freq, &vsb);
1399        if (!band) {
1400                printf("Can't tuning");
1401        }
1402#endif
1403}
1404
1405/*
1406 RF, CH,   PCR  VID  AUD
1407        81  SBS   0x11 0x11 0x14
1408        82  KBS2  0x21 0x21 0x24
1409        83  KBS1  0x21 0x21 0x24
1410        84  MBC   0x11 0x11 0x14
1411*/
1412void TestVSB_Tuneset(int videopid, int audiopid, int pcrpid)
1413{
1414        bstream_mpeg_init(&dhl_mpeg);
1415        dhl_mpeg.video[0].pid = videopid;
1416        dhl_mpeg.audio[0].pid = audiopid;
1417        dhl_mpeg.pcr_pid = pcrpid;
1418
1419        dhl_stream = bstream_open(band, &dhl_mpeg);
1420        bdecode_start(dhl_decode, dhl_stream,window);
1421
1422}
1423
1424
1425#endif
Note: See TracBrowser for help on using the repository browser.