source: svn/newcon3bcm2_21bu/dst/app/src/Function/App_Fnc_Video.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: 38.9 KB
Line 
1/****************************************************************************
2* NAME: App_Fnc_Video.c
3*----------------------------------------------------------------------------
4* Copyright (c) DIGITAL STREAM Technology Inc.
5*----------------------------------------------------------------------------
6* CREATED_BY: Chan Hun Jeon
7* CREATION_DATE: 2009/08/27
8* $Author: chjeon $
9* $Revision: 1.1 $
10* $Date: 2009/07/08 15:08:26 $
11*----------------------------------------------------------------------------
12* PURPOSE:
13*       - Implement video timing change, mode change, HDMI monitor
14*****************************************************************************/
15
16/*_____ I N C L U D E __________________________________________*/
17
18#include "App_Main.h"
19#include "App_Fnc_Common.h"
20
21#include "DHL_AVCAP.h"
22
23#include "DMW_Status.h"
24
25#include "App_Fnc_Video.h"
26
27#include "App_Res_Resources.h"
28
29
30
31
32
33/*_____ D E F I N I T I O N ____________________________________*/
34
35#if COMMENT
36_____DbgPrint_____(){}
37#endif
38
39DHL_MODULE("@f_vid", 0);
40
41
42
43
44
45#if COMMENT
46____Config____(){}
47#endif
48
49#define APP_REGISTER_DEBUG_SYMBOL 1
50
51#define AFD_DEFAULT 0xf0
52#define AFD_UNINITIALIZED 0xff
53
54#define DISP_MODE_AT_NO_AFD_WIDE   eDHL_ARC_PAN_AND_SCAN
55#define DISP_MODE_AT_NO_AFD_NARROW eDHL_ARC_FULLSCREEN
56        // cafrii 081223 add
57        // AFD ¾ø´Â ¹æ¼Û ½ÅÈ£¿¡¼­ AUTO ¸ðµå¸¦ ¼±ÅÃÇÒ ¶§ Àû¿ëµÇ´Â ¸ðµå.
58        //
59        // AFD_DEFAULT ³ª AFD_UNINITIALIZED °ªÀÌ process ÇÔ¼ö·Î Àü´ÞµÇ¸é
60        // table¿¡ Á¸ÀçÇÏÁö ¾Ê´Â °ªÀ̹ǷΠÀÌ °ªÀÌ Àû¿ëµÊ.
61        //
62
63
64
65
66
67#if COMMENT
68____Types____(){}
69#endif
70
71
72
73
74
75#if COMMENT
76____Variables____(){}
77#endif
78
79UINT8 g_App_videoDisplayModeSet;
80        //
81        // type of APP_DISP_MODE
82
83UINT8 g_App_VideoDisplayModeAuto;
84        //
85        // if true, current mode is AUTO mode.
86       
87tDHL_DispARC g_App_VideoAdjustmentHd, g_App_VideoAdjustmentSd;
88        // type tDHL_DispARC
89        // if user change DST_VideoDisplayMode, it will be automatically changed
90        // according to source format.
91
92static struct
93{
94        UINT8 videoDisplayModeSet;
95        UINT8 videoDisplayModeAuto;
96        UINT8 screen_ratio;
97        UINT8 edge_color;
98        UINT8 output_resolution;
99        UINT8 menu_trans;
100} p_vid_nvm_param;
101
102
103
104/*_____ F U N C T I O N ________________________________________*/
105
106#if COMMENT
107____Function____(){}
108#endif
109
110/*
111        App_GetInputVideoFormat:
112               
113        ÀԷµǰí ÀÖ´Â video format Á¤º¸¸¦ ¸®ÅÏÇÑ´Ù.
114        video formatÀ» ±â¼úÇÏ´Â Á¤º¸´Â ÈξÀ ´õ ´Ù¾çÇÏÁö¸¸
115        (¿¹: frame rate, non-standard resolution)
116        ´ëÇ¥ÀûÀÎ ¸î°¡Áö Ç¥ÁØ formatÀ¸·Î ±¸ºÐÇØ¼­ ¾Ë·ÁÁØ´Ù.
117*/
118APP_VIDEO_FORMAT App_GetInputVideoFormat(void)
119{
120        BOOL bReturn = FALSE;
121        tDHL_VideoSeqHdr seq_0, *seq = &seq_0;
122       
123        bReturn = Dmc_GetVideoSequenceHeader(seq);
124       
125        if (!bReturn)
126        {
127                //return APP_VIDEO_FORMAT_480I;
128                return APP_VIDEO_FORMAT_NONE;
129                 /* 2010.04.30 foxhunt
130                  * Video Sequence header Á¤º¸¸¦ ¾ò¾î¿ÀÁö ¸øÇßÀ» ¶§(FALSE)¿¡´Â ±âº»À¸·Î 480I°¡ ¾Æ´Ñ NONEÀ» Ç¥±âÇÑ´Ù.
131                  * resolutionÀÌ ´Ù¸¦ ¶§, OSD »ó¿¡¼­ 480I°¡ ¸ÕÀú º¸¿©ÁüÀ¸·Î½á ±ôºýÀÌ´Â Çö»ó ¾ø¾Ö±â À§ÇÔ. */
132        }
133
134        if (seq->vertical_size >= 1080)
135        {
136                if(seq->progressive_sequence)
137                        return APP_VIDEO_FORMAT_1080P;
138                else
139                        return APP_VIDEO_FORMAT_1080I;
140        }
141        else if (seq->vertical_size  >= 720)
142        {
143                return APP_VIDEO_FORMAT_720P;
144        }
145        else
146        {
147                if(seq->progressive_sequence)
148                {
149                        return APP_VIDEO_FORMAT_480P; 
150                }
151                else
152                {
153                        return APP_VIDEO_FORMAT_480I;
154                }
155        }
156       
157}
158
159
160
161
162
163#if COMMENT
164____Mute____(){}
165#endif
166
167static UINT32 s_VideoMuteStatus;
168        // APP_VIDEO_MUTE_TYPE °ª¿¡ ÇØ´çÇÏ´Â °¢ bit °ªÀÌ ¼³Á¤µÇ¾î ÀÖ´Ù.
169        // bit°¡ 1À̸é mute°¡ µÇ¾î ÀÖ´Â »óÅÂÀÓ.
170
171static BOOL s_bVideoMuted;
172        // ÇöÀç Video ÀÇ mute »óÅÂ.
173
174void App_VideoSetBlank(BOOL bBlank, APP_VIDEO_MUTE_TYPE eMuteType)
175{
176        // cafrii comment
177        // ÀÌ ÇÔ¼ö´Â Rating °ü·Ã Äڵ忡¼­ ¼ö½Ã·Î Àß ºÒ¸®´Âµ¥
178        // º¸Åë EpgCore mutex°¡ take µÈ »óÅ¿¡¼­ Àß ºÎ¸£°Ô µÈ´Ù.
179        // ±×·±µ¥ Dmc task°¡ App callback¿¡¼­ EpgCore mutex¸¦ ¿äûÇÏ·ÁÇÏ´Â °æ¿ì¿¡
180        // dead-lockÀÌ °É¸®±â ¶§¹®¿¡
181        // ±×·² °æ¿ì¿¡´Â Rating °ü·Ã Äڵ忡¼­ ¹Ýµå½Ã async mode·Î ÀÌ ÇÔ¼ö¸¦ ºÒ·¯¾ß ÇÒ °ÍÀÌ´Ù.
182        //
183        // --> rating block check´Â Ç×»ó timer task (¶Ç´Â stream monitor) ·Î deferµÇ¾î ½ÇÇàÇÏ°Ô ÇÔ.
184        //     epg task¿¡¼­ Á÷Á¢ ¼öÇàÇÏÁö ¾Ê´Â´Ù.
185        //     
186        UINT32 bitmask;
187
188        dprint(0, "Video blank %s, by %s: prev stat %d, muted %d\n", 
189                        bBlank ? "ON" : "off", APP_VIDEO_MUTE_TYPE_STR(eMuteType), 
190                        s_VideoMuteStatus, s_bVideoMuted);
191
192        bitmask = 1 << (UINT32)eMuteType;
193       
194        if (bBlank) 
195                s_VideoMuteStatus |= bitmask;
196        else 
197                s_VideoMuteStatus &= ~bitmask;
198
199        if (s_bVideoMuted) 
200        {
201                if (s_VideoMuteStatus) { // should be muted
202                        // mute -> mute
203                        // do nothing
204                }
205                else {
206                        // mute -> unmute
207                        dprint(0, "  video unmute\n");
208                        Dmc_HideVideo(FALSE, FALSE); // asynchronous call
209                        s_bVideoMuted = FALSE;
210                }
211        }
212        else
213        {
214                if (s_VideoMuteStatus) {
215                        // unmute -> mute
216                        dprint(0, "  video mute\n");
217                        Dmc_HideVideo(TRUE, FALSE); // asynchronous call
218                        s_bVideoMuted = TRUE;
219                }
220                else {
221                        // unmute -> unmute
222                        // do nothing
223                }
224        }
225
226}
227
228
229
230
231
232#if COMMENT
233____DispMode____(){}
234#endif
235
236const char *PnxDisplayModeString(APP_DISP_MODE mode)
237{
238        return
239                mode == APP_DISP_MODE_WIDE ? "WIDE" :
240                mode == APP_DISP_MODE_NORM ? "NORM" :
241                mode == APP_DISP_MODE_ZOOM ? "ZOOM2" : 
242                mode == APP_DISP_MODE_14_9 ? "ZOOM1" : 
243                mode == APP_DISP_MODE_AUTO ? "AUTO" :
244                "??";
245}
246
247
248const char *PnxAdjustmentString(tDHL_DispARC adj)
249{
250        return
251                adj == eDHL_ARC_FULLSCREEN ? "full_scr" :
252                adj == eDHL_ARC_LETTERBOX ? "letterbox" :
253                adj == eDHL_ARC_SIDEBAR ? "sidebar" :
254                adj == eDHL_ARC_PAN_AND_SCAN ? "pan_scan" :
255                adj == eDHL_ARC_TILT_AND_SCAN ? "tilt_scan" :
256                adj == eDHL_ARC_PARTIAL_LETTERBOX ? "partial_lettebox" :
257                adj == eDHL_ARC_PARTIAL_SIDEBAR ? "partial_sidebar" :
258                adj == eDHL_ARC_ZOOM1 ? "zoom1" :
259                adj == eDHL_ARC_ZOOM2 ? "zoom2" : "?";
260}
261
262
263/*
264        Display Ratio
265                Monitor typeÀ̶ó°íµµ Çϰí, ¿¬°áµÈ Display°¡ 16:9 ÀÎÁö 4:3ÀÎÁö¸¦ ³ªÅ¸³½´Ù.
266                ¸Þ´º¿¡¼­ »ç¿ëÀÚ°¡ ¼±ÅÃÇÑ´Ù.
267               
268        Display Mode
269                WIDE, NORMAL, ZOOMÀ¸·Î °¢ ¸ðµåº°·Î ºñµð¿À È­¸é Ç¥½Ã°¡ ´Þ¶óÁø´Ù.
270                ¸Þ´º»ó¿¡¼­ »ç¿ëÀÚ°¡ ¼±ÅÃÇÑ´Ù.
271
272        DST_VideoDisplayMode is now bitfield.
273
274        Display Ratio°¡ 16:9 ÀÎ °æ¿ì, 4:3 ÀÎ °æ¿ì,
275        Source Video°¡ 16:9 ÀÎ °æ¿ì, 4:3 ÀÎ °æ¿ì,
276
277        ÃÑ ³×°¡Áö °æ¿ì¿¡ ´ëÇØ¼­ °¢°¢ÀÇ Display Mode¸¦ °ü¸®ÇÑ´Ù.
278
279
280            7        6       5      4       3        2       1      0
281        +----------------+---------------+---------------+--------------+
282        | 16:9 D, 16:9 S | 16:9 D, 4:3 S | 4:3 D, 16:9 S | 4:3 D, 4:3 S |
283        +----------------+---------------+---------------+--------------+
284
285                        D: display
286                        S: source
287
288        ÀÌ °ªµéÀÌ Á¶ÇյǼ­ DST_VideoDisplayMode º¯¼ö¸¦ ±¸¼ºÇϰí ÀÖ´Ù.
289
290
291        --> CB2 specific
292            16:9 display´Â °í·ÁÇÏÁö ¾Ê´Â´Ù.
293       
294            7        6       5      4       3        2       1      0
295        +--------------------------------+---------------+--------------+
296        |            Reserved            | 4:3 D, 16:9 S | 4:3 D, 4:3 S |
297        +--------------------------------+---------------+--------------+
298
299        --> CB2, CB3
300                total 5 modes are provided. so, mode bit is extended to 4 bit.
301       
302            7       6       5      4       3        2       1      0
303        +------------------------------+------------------------------+
304        |         4:3 D, 16:9 S        |          4:3 D, 4:3 S        |
305        +------------------------------+------------------------------+
306*/
307
308APP_DISP_MODE App_VideoGetDisplayModeFlag(BOOL bSrcWide)
309{
310        // DST_VideoDisplayMode ¿¡¼­,
311        // ÁöÁ¤ÇÑ Display, Source Á¶°ÇÀÇ Display Mode¸¦ ÃßÃâÇÏ¿© ¸®ÅÏÇÑ´Ù.
312       
313        UINT8 data = g_App_videoDisplayModeSet;
314        UINT8 mode;
315
316        if (g_App_VideoDisplayModeAuto)
317                return APP_DISP_MODE_AUTO;
318               
319        if (bSrcWide)
320        {
321                mode = ((data >> 4) & 0xf);
322        }
323        else
324        {
325                mode = data & 0xf;
326        }
327
328        // mode value from variable cannot be 'APP_DISP_MODE_AUTO'.
329        //
330        if (mode > APP_DISP_MODE_MAX || mode == APP_DISP_MODE_AUTO) {
331                dprint(0, "!! invalid display mode data! 0x%02x\n", data);
332                dprint(0, "mode = 0x%x", mode);
333                mode = 1; // default normal..
334        }
335
336        return (APP_DISP_MODE)mode;
337}
338
339
340void App_VideoSetDisplayModeFlag(BOOL bSrcWide, APP_DISP_MODE mode)
341{
342        // DST_VideoDisplayMode ¿¡
343        // ÁöÁ¤ÇÑ Display, Source Á¶°ÇÀÇ Display Mode¸¦ ÀúÀåÇÑ´Ù.
344       
345        // auto modeÀÇ °æ¿ì´Â º°µµÀÇ bit¿¡ ÀúÀåÀ» Çϵµ·Ï ÇÑ´Ù.
346
347        if (mode == APP_DISP_MODE_AUTO) {
348                g_App_VideoDisplayModeAuto = TRUE;
349
350                // do not change 'g_App_videoDisplayModeSet' variable.
351                // it will be recovered back.
352                return;
353        }
354       
355        if (0)
356                ;
357        else if (bSrcWide)     
358                g_App_videoDisplayModeSet =  (g_App_videoDisplayModeSet & 0x0f) | (mode << 4);         
359        else 
360                g_App_videoDisplayModeSet = (g_App_videoDisplayModeSet & 0xf0) | mode;         
361
362        g_App_VideoDisplayModeAuto = FALSE;
363}
364
365
366//
367//  Channel MW¿¡¼­ È£ÃâµÇ´Â Notification callback
368//
369//  Video°¡ ½ÃÀÛÇÒ ¶§ ¾î¶² Adjustment·Î ½ÃÀÛÇÒ °ÍÀÎÁö ¹°¾îº»´Ù.
370//  ÇöÀçÀÇ »óÅ¿¡ µû¶ó ÀûÀýÇÑ adjustment¸¦ °áÁ¤Çؼ­ ¸®ÅÏÇÑ´Ù.
371//
372//  doDmc_ProcessScreenAdjustment ¿¡¼­ È£Ãâ..
373//
374void App_VideoScreenAdjustCallback(ScreenAdjustmentParam *sap)
375{
376        // DMC_NOTIFY_ScreenAdjustment noti handler
377
378        tDHL_DispARC adjustment;
379
380        // NOTE!!
381        //  ÀÌÁ¦ ¿ì¸®´Â MW¿¡¼­ ¾Ë·ÁÁÖ´Â displayÀÇ ratio¸¦ Âü°íÇÏÁö ¾Ê´Â´Ù.
382        //  App Àü¿ëÀÇ ratio º¯¼ö¸¦ »ç¿ëÇÑ´Ù.
383
384        BOOL bSourceWide = sap->bSourceWide ? TRUE : FALSE;
385        BOOL bDispWide = App_VideoGetScrRatio()==APP_DISP_RATIO_WIDE?TRUE:FALSE;
386
387        APP_DISP_MODE mode = App_VideoGetDisplayModeFlag(bSourceWide);
388                // ÇöÀç Á¶°Ç¿¡ ÇØ´çµÇ´Â mode ÃßÃâ.
389       
390        dprint(0, "VideoScreenAdjustCallback (%s src, %s(%d), total 0x%02x:%d)\n", 
391                bSourceWide ? "wide" : "narrow",
392                PnxDisplayModeString(mode), mode,
393                g_App_videoDisplayModeSet, g_App_VideoDisplayModeAuto);
394
395        // cafrii 101208 add..
396        // sigmon¿¡ ÀÇÇØ av mute°¡ °É¸° »óÅ¿¡¼­ retry tuning, ¶Ç´Â »õ ä³Î Æ©´×ÀÇ °æ¿ì
397        // video mute°¡ ¿©ÀüÈ÷ ³²°Ô µÈ´Ù. À̰ÍÀ» ¹Ì¸® unmute ÇÏÁö ¸øÇÏ´Â ÀÌÀ¯´Â ÀÌÀü ä³ÎÀÇ ÀÜ»ó ¶§¹®.
398        // ¿©±â¼­ Ç®¾îÁÖ¸é µÊ.
399        // »ç½Ç ÁÁÀº À§Ä¡´Â ¾Æ´Ï´Ù..
400        App_VideoSetBlank(FALSE, APP_VIDEO_MUTE_SIGMON);
401
402        if (mode == APP_DISP_MODE_AUTO) 
403        {
404#if SUPPORT_AFD==0
405                mode=APP_DISP_MODE_WIDE;
406#else
407                // keep current settings. we will change it later, after afd is coming.
408                sap->bKeepCurrent = TRUE;
409
410                App_VideoAfdTriggerDefaultAfd();
411
412                dprint(0, "\t start afd monitor\n");
413                App_VideoAfdStartMonitor(TRUE);
414                return;
415#endif // #if SUPPORT_AFD
416        }
417               
418        // °¢°¢ÀÇ ÀÔ·Â Á¶°Ç¿¡ µû¶ó ÀûÀýÇÑ Adjustment¸¦ °áÁ¤ÇÑ´Ù.
419        // updated by chjeon 091221
420
421        if(bDispWide) {
422                if(bSourceWide) adjustment=eDHL_ARC_FULLSCREEN;
423                else {
424                        if(mode==APP_DISP_MODE_WIDE) adjustment=eDHL_ARC_TILT_AND_SCAN;
425                        else if(mode==APP_DISP_MODE_NORM) adjustment=eDHL_ARC_SIDEBAR;
426                        else if(mode==APP_DISP_MODE_14_9) adjustment=eDHL_ARC_PARTIAL_SIDEBAR;
427                        else if(mode==APP_DISP_MODE_ZOOM) adjustment=eDHL_ARC_FULLSCREEN;
428                }
429        }
430        else {
431                if(!bSourceWide) adjustment=eDHL_ARC_FULLSCREEN;
432                else {
433                        if(mode==APP_DISP_MODE_WIDE) adjustment=eDHL_ARC_LETTERBOX;
434                        else if(mode==APP_DISP_MODE_NORM) adjustment=eDHL_ARC_PAN_AND_SCAN;
435                        else if(mode==APP_DISP_MODE_14_9) adjustment=eDHL_ARC_PARTIAL_LETTERBOX;
436                        else if(mode==APP_DISP_MODE_ZOOM) adjustment=eDHL_ARC_FULLSCREEN;
437                }
438        }
439        sap->adjustment_hd = adjustment;
440
441        // sd port´Â narrow display·Î °¡Á¤ÇÑ´Ù.
442        if (1) {
443                if(!bSourceWide) adjustment=eDHL_ARC_FULLSCREEN;
444                else {
445                        if(0);
446                        else if(mode==APP_DISP_MODE_WIDE) adjustment=eDHL_ARC_LETTERBOX;
447                        else if(mode==APP_DISP_MODE_NORM) adjustment=eDHL_ARC_PAN_AND_SCAN;
448                        else if(mode==APP_DISP_MODE_14_9) adjustment=eDHL_ARC_PARTIAL_LETTERBOX;
449                        else if(mode==APP_DISP_MODE_ZOOM) adjustment=eDHL_ARC_FULLSCREEN;
450                }
451        }
452        sap->adjustment_sd = adjustment; // sd arc´Â Áö¿ø¿©ºÎ È®ÀÎ ÇÊ¿ä.
453
454        dprint(0, "  selected adjustment hd: %s(%d)-> %s(%d)\n", 
455                PnxAdjustmentString(g_App_VideoAdjustmentHd), g_App_VideoAdjustmentHd, 
456                PnxAdjustmentString(sap->adjustment_hd), sap->adjustment_hd);
457        dprint(0, "  selected adjustment sd: %s(%d)-> %s(%d)\n", 
458                PnxAdjustmentString(g_App_VideoAdjustmentSd), g_App_VideoAdjustmentSd, 
459                PnxAdjustmentString(sap->adjustment_sd), sap->adjustment_sd);
460
461        g_App_VideoAdjustmentHd = sap->adjustment_hd;
462        g_App_VideoAdjustmentSd = sap->adjustment_sd;
463                // ³ªÁß¿¡ video start°¡ ¾Æ´Ñ ±×³É ChangeDisplay¸¦ ÇÒ °æ¿ì,
464                // °¡Àå ÃÖ±Ù °ªÀ¸·Î ±×´ë·Î Àû¿ëÇϱâ À§Çؼ­ÀÓ.
465}
466
467
468// App_VideoGetCurrentDisplayMode
469//
470// [OUT] pbSourceWide: return *TRUE if current source is 16:9
471//
472// return value:
473//   return current DisplayMode
474//
475// DisplayMode ¸Þ´º¿¡ µé¾î°¡±â Àü¿¡ ºÒ·¯¼­
476// ÇöÀç ¾î¶² Á¶°ÇÀÎÁö, ¾î¶² ModeÀÎÁö¸¦ ¾Ë¾Æ³½´Ù.
477//
478APP_DISP_MODE App_VideoGetCurrentDisplayMode(BOOL *pbSourceWide)
479{
480        APP_DISP_MODE mode;
481        ProgramAVInfo *program;
482        BOOL bSrcWide;
483
484        program = Dmc_LockAVMutex();
485
486        // note:
487        //  video°¡ ¾È³ª¿À°í ÀÖ´Â °æ¿ì¶ó¸é sequence header°¡ À߸øµÇ¾úÀ» ¼ö Àִµ¥
488        //  ¾îÂ¥ÇÇ video°¡ ¾È³ª¿À°í ÀÖÀ¸¹Ç·Î È­¸é»ó¿¡ ¹®Á¦°¡ µÇÁö´Â ¾Ê´Â´Ù.
489        //
490       
491        //neverdai 081210 aspect ratio üũÇϱâ Àü¿¡ ¹Ýµå½Ã seq hdr¸¦ ¾÷µ¥ÀÌÆ®ÇÑ´Ù.
492        DHL_AV_VideoSeqInfo(0, &program->seq_hdr);
493       
494        bSrcWide = DHL_AV_IsWideoFormat(&program->seq_hdr) ? TRUE : FALSE;
495
496        Dmc_UnlockAVMutex();
497       
498        mode = App_VideoGetDisplayModeFlag(bSrcWide);
499
500        if (pbSourceWide)
501                *pbSourceWide = bSrcWide;
502
503        return mode;
504}
505
506
507//  App_VideoChangeDisplayMode
508//
509//  ÇöÀç DST_Ratio, Source¿¡ ´ëÇØ¼­
510//  »õ·Î¿î Display Mode¸¦ Àû¿ëÇÑ´Ù.
511//  ¸Þ´º¿¡¼­ DisplayMode º¯°æ½Ã È£Ãâ.
512//
513void App_VideoChangeDisplayMode(APP_DISP_MODE mode, BOOL bSaveNvRam)
514{
515        // ÇöÀç monitor type (DST_Ratio)¿Í ¿¬°üÁö¾î¼­ ó¸®ÇØ¾ß ÇÔ.
516        // App_VideoScreenAdjustCallback ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© ÇÊ¿äÇÑ AdjustmentÀ» ¾Ë¾Æ³½´Ù.
517        //
518        ScreenAdjustmentParam sap;
519        APP_DISP_MODE cur_mode;
520       
521        BOOL bSourceWide;
522
523       
524        if (mode != APP_DISP_MODE_WIDE &&
525                mode != APP_DISP_MODE_NORM &&
526                mode != APP_DISP_MODE_ZOOM &&
527                mode != APP_DISP_MODE_14_9 &&
528                mode != APP_DISP_MODE_AUTO
529                ) {
530                dprint(0, "!! %s: invalid DispMode %d\n", __FUNCTION__, mode);
531                return;
532        }
533
534        dprint(0, "%s:\n", __FUNCTION__);
535
536               
537        cur_mode = App_VideoGetCurrentDisplayMode(&bSourceWide);
538
539        if (cur_mode == (UINT8)mode) {
540                dprint(0, "Warning: same disp mode %d, %s\n", cur_mode,
541                        PnxDisplayModeString(cur_mode));
542                        // cafrii 070420, ¾û¶×ÇÑ °ªÀÌ Ãâ·ÂµÇ´Â ¹ö±×
543        }
544
545        sap.bSourceWide = bSourceWide;
546        sap.bDisplayWide = FALSE;
547        sap.bKeepCurrent = FALSE;
548
549        // g_App_videoDisplayModeSet º¯¼ö¸¦ °»½ÅÇÑ´Ù.
550        //
551       
552
553        App_VideoSetDisplayModeFlag(sap.bSourceWide, mode);
554
555        if (mode == APP_DISP_MODE_AUTO) 
556        {
557#if SUPPORT_AFD==0
558
559                mode=APP_DISP_MODE_WIDE;
560                // stop afd.
561                //App_VideoAfdStartMonitor(FALSE);
562
563                // ÀÌ callbackÀº MW/DHL¿¡¼­ App·Î ºÎ¸£°Ô²û ¸¸µé¾îÁ³Áö¸¸
564                // ÀÌ·¸°Ô »ç¿ëÇØµµ ¹®Á¦µÉ °ÍÀº ¾ø´Ù.
565                //
566                App_VideoScreenAdjustCallback(&sap);
567
568                g_App_VideoAdjustmentHd = sap.adjustment_hd;
569                g_App_VideoAdjustmentSd = sap.adjustment_sd;
570               
571                // ½ÇÁ¦·Î È­¸éÀÌ º¯Çϵµ·Ï Á¶Ä¡¸¦ ÇØ¾ß ÇÑ´Ù.
572
573
574                Dmc_ChangeVideoAdjustment(g_App_VideoAdjustmentHd, g_App_VideoAdjustmentSd);
575               
576#else
577       
578                App_VideoAfdTriggerDefaultAfd();
579                App_VideoAfdStartMonitor(TRUE);
580#endif // #if SUPPORT_AFD
581        }
582        else
583        {
584#if SUPPORT_AFD
585
586                // stop afd.
587       
588
589                App_VideoAfdStartMonitor(FALSE);
590
591#endif
592
593                // ÀÌ callbackÀº MW/DHL¿¡¼­ App·Î ºÎ¸£°Ô²û ¸¸µé¾îÁ³Áö¸¸
594                // ÀÌ·¸°Ô »ç¿ëÇØµµ ¹®Á¦µÉ °ÍÀº ¾ø´Ù.
595                //
596
597                App_VideoScreenAdjustCallback(&sap);
598       
599               
600                g_App_VideoAdjustmentHd = sap.adjustment_hd;
601                g_App_VideoAdjustmentSd = sap.adjustment_sd;
602               
603                // ½ÇÁ¦·Î È­¸éÀÌ º¯Çϵµ·Ï Á¶Ä¡¸¦ ÇØ¾ß ÇÑ´Ù.
604       
605
606
607                //App_VideoSetBlank(TRUE, APP_VIDEO_MUTE_SIGMON);
608                Dmc_ChangeVideoAdjustment(g_App_VideoAdjustmentHd, g_App_VideoAdjustmentSd);
609                //App_VideoSetBlank(FALSE, APP_VIDEO_MUTE_SIGMON);     
610
611
612
613               
614        }
615
616       
617        if (bSaveNvRam) {
618                p_vid_nvm_param.videoDisplayModeSet = g_App_videoDisplayModeSet;       
619                p_vid_nvm_param.videoDisplayModeAuto = g_App_VideoDisplayModeAuto;
620                App_NVM_SaveModuleParam(eAPP_NVR_VIDEO, &p_vid_nvm_param);
621        }
622       
623       
624                //      s_VideoMuteStatus &= ~1;                       
625
626}
627
628
629//
630// ¸®¸ðÄÁ ۰¡ ´­·ÈÀ» ¶§ È£ÃâµÇ´Â API
631//
632//  bChangeToNext TRUEÀÌ¸é ´ÙÀ½ ¸ðµå·Î º¯°æ..
633//
634//  cafrii, return °ªÀ» enum typeÀ¸·Î º¯°æ.
635//        string returnÇÏÁö ¾ÊÀ¸¹Ç·Î static buffer Á¦°Å..
636//
637APP_DISP_MODE App_VideoShowOrChangeDisplayMode(BOOL bChangeToNext)
638{
639        BOOL bSrcWide, bDispWide;
640        APP_DISP_MODE mode;
641        APP_DISP_MODE Nextmode;
642        char buf1[80], buf2[80], *msgs[5];
643       
644        APP_DISP_MODE next_mode_table[2][2][5] =
645        {
646#if SUPPORT_NEWBY //¼ø¼­ º¯°æ Àüüº¸±â->16:9->14:9->Áß¾Óº¸±â
647                // bDispWide:0, narrow display
648                {
649                        // bSrcWide:0, narrow source
650                        {
651                                // current mode
652                                // Wide(0), Normal(1), Zoom(2)
653                                APP_DISP_MODE_14_9, // <-- 14:9
654                                APP_DISP_MODE_AUTO, // <-- auto
655                                APP_DISP_MODE_WIDE, // <-- wide
656                                APP_DISP_MODE_NORM, // <-- norm
657                                APP_DISP_MODE_ZOOM, // <-- zoom
658                               
659                                // only normal allowed
660                        },
661
662                        // bSrcWide:1, wide source
663                        {
664                                APP_DISP_MODE_14_9, // <-- 14:9
665                                APP_DISP_MODE_AUTO, // <-- auto
666                                APP_DISP_MODE_WIDE, // <-- wide
667                                APP_DISP_MODE_NORM, // <-- norm
668                                APP_DISP_MODE_ZOOM, // <-- zoom
669                                // normal(1) -> 16:9(0) -> 14:9(3) -> zoom(2) -> Auto(4)
670                        },
671                },
672
673                // bDispWide:1, wide dispay
674                {
675                        // bSrcWide:0, narrow source
676                        {
677                                APP_DISP_MODE_14_9, // <-- 14:9
678                                APP_DISP_MODE_AUTO, // <-- auto
679                                APP_DISP_MODE_WIDE, // <-- wide
680                                APP_DISP_MODE_NORM, // <-- norm
681                                APP_DISP_MODE_ZOOM, // <-- zoom
682                                // normal(1) -> 16:9(0) -> 14:9(3) -> zoom(2) -> Auto(4)
683                        },
684
685                        // bSrcWide:1, wide source
686                        {
687                                APP_DISP_MODE_14_9, // <-- 14:9
688                                APP_DISP_MODE_AUTO, // <-- auto
689                                APP_DISP_MODE_WIDE, // <-- wide
690                                APP_DISP_MODE_NORM, // <-- norm
691                                APP_DISP_MODE_ZOOM, // <-- zoom
692                                // zoom(2) not allowed
693                        },
694                }
695#else
696                // bDispWide:0, narrow display
697                {
698                        // bSrcWide:0, narrow source
699                        {
700                                // current mode
701                                // Wide(0), Normal(1), Zoom(2)
702                                APP_DISP_MODE_NORM, // <-- wide
703                                APP_DISP_MODE_14_9, // <-- norm
704                                APP_DISP_MODE_AUTO, // <-- zoom
705                                APP_DISP_MODE_ZOOM, // <-- 14:9
706                                APP_DISP_MODE_WIDE, // <-- auto
707                                // only normal allowed
708                        },
709
710                        // bSrcWide:1, wide source
711                        {
712                                APP_DISP_MODE_NORM, // <-- wide
713                                APP_DISP_MODE_14_9, // <-- norm
714                                APP_DISP_MODE_AUTO, // <-- zoom
715                                APP_DISP_MODE_ZOOM, // <-- 14:9
716                                APP_DISP_MODE_WIDE, // <-- auto
717                                // normal(1) -> 16:9(0) -> 14:9(3) -> zoom(2) -> Auto(4)
718                        },
719                },
720
721                // bDispWide:1, wide dispay
722                {
723                        // bSrcWide:0, narrow source
724                        {
725                                APP_DISP_MODE_NORM, // <-- wide
726                                APP_DISP_MODE_14_9, // <-- norm
727                                APP_DISP_MODE_AUTO, // <-- zoom
728                                APP_DISP_MODE_ZOOM, // <-- 14:9
729                                APP_DISP_MODE_WIDE, // <-- auto
730                                // normal(1) -> 16:9(0) -> 14:9(3) -> zoom(2) -> Auto(4)
731                        },
732
733                        // bSrcWide:1, wide source
734                        {
735                                APP_DISP_MODE_NORM, // <-- wide
736                                APP_DISP_MODE_14_9, // <-- norm
737                                APP_DISP_MODE_AUTO, // <-- zoom
738                                APP_DISP_MODE_ZOOM, // <-- 14:9
739                                APP_DISP_MODE_WIDE, // <-- auto
740                                // zoom(2) not allowed
741                        },
742                }
743#endif
744        };
745
746        mode = App_VideoGetCurrentDisplayMode(&bSrcWide);
747        bSrcWide = bSrcWide ? 1 : 0;
748               
749        bDispWide = p_vid_nvm_param.screen_ratio==VOUT_WIDE? 1 : 0;
750
751        if (bChangeToNext && (bSrcWide!=bDispWide)) /* neverdai src¿Í disp°¡ ´Þ¶ó¾ßÁö¸¸ Àû¿ëÇÔ*/
752        {
753                Nextmode = next_mode_table[bDispWide][bSrcWide][mode];
754
755
756#if SUPPORT_AFD==0 /* AFD¸¦ Áö¿øÇÏÁö ¾Ê´Â °æ¿ì, ƯÈ÷ ±¹³»ÇâÀº Áö¿øÇÏÁö ¾ÊÀ½ */
757                if(Nextmode==APP_DISP_MODE_AUTO) 
758                        Nextmode=next_mode_table[bDispWide][bSrcWide][Nextmode];
759
760#endif
761
762                App_VideoChangeDisplayMode(Nextmode, TRUE);
763        }
764        else if(bSrcWide==bDispWide)
765                Nextmode=APP_DISP_MODE_ZOOM; //Àüü º¸±â
766        else
767                Nextmode=mode;
768
769
770        sprintf(buf1, "%s display, %s source",
771                        bDispWide ? "wide" : "narrow",
772                        bSrcWide ? "wide" : "narrow");         
773        sprintf(buf2, "%s mode", 
774                        Nextmode == APP_DISP_MODE_WIDE ? "WIDE" :
775                        Nextmode == APP_DISP_MODE_NORM ? "NORMAL" : 
776                        Nextmode == APP_DISP_MODE_14_9 ? "ZOOM1" : 
777                        Nextmode == APP_DISP_MODE_ZOOM? "ZOOM2" : "AUTO(AFD)");
778
779        msgs[0] = buf1;
780        msgs[1] = buf2;
781       
782
783        App_PrintTextMessageBox2(2, msgs, 30);
784
785        return Nextmode;
786}
787
788
789
790
791
792#if COMMENT
793____Resolution____(){}
794#endif
795
796/*
797        ÇØ»óµµ ¼³Á¤¿¡ ´ëÇØ
798       
799        -ÇØ»óµµ Á¤º¸´Â ¸ÕÀú ¼³Á¤µÈ ÇØ»óµµ Á¤º¸(or)¿Í ¼±È£ ÇØ»óµµ(pr) Á¤º¸°¡ ÀÖ´Ù.
800         ¼³Á¤ ÇØ»óµµ´Â ÇöÀç Ãâ·Â ÇØ»óµµ¸¦ ÀǹÌÇϰí, ¼±È£ ÇØ»óµµ´Â ¸Þ´º Ç׸ñÀÇ ¼±È£ ÇØ»óµµ´Ù.
801       
802        - hdmi¿Í ¿¬°áµÈ °æ¿ì
803          hdmi ¿¬°á½Ã ¼±È£ ÇØ»óµµ(hpr), Áö¿ø ÇØ»óµµ Á¤º¸¸¦ Àоî¿Â´Ù.(hrs)
804         
805          a. ½Ã½ºÅÛ ½ÃÀÛ..
806                1. hpr, hrs Àбâ
807                2. orÀÌ hrs¿¡ ÀÖ´ÂÁö üũ ÈÄ ¼¼ÆÃ.(x) orÀº ÀúÀåµÇÁö ¾ÊÀ½.
808                3. orÀÌ hrs¿¡ ¾øÀ» °æ¿ì pr·Î °Ë»ö ÈÄ ¼¼ÆÃ
809                4. prµµ hrs¿¡ ¾øÀ» °æ¿ì hpr·Î ¼³Á¤
810                5. orÀ» ÇöÀç Ãâ·Â or·Î º¯°æ
811         
812          b. ÇØ»óµµ Ű ¼³Á¤
813            1. hrs¸¦ µû¶ó ÇØ»óµµ ¼³Á¤. orÀº
814         
815          c. hdmi ¿¬°á
816            ½Ã½ºÅÛ ½ÃÀÛ°ú µ¿ÀÏÇÔ.
817         
818          d. ¼±È£ ÇØ»óµµ ¼³Á¤
819                1. orÀº ¹«½ÃµÇ°í pr·Î hpr, hrs¸¦ °Ë»ö ÈÄ ¼³Á¤
820                2. prÀÌ hrs¿¡ ¾øÀ» °æ¿ì hpr·Î ¼³Á¤
821                3. orÀ» ÇöÀç Ãâ·Â or·Î ¼³Á¤
822*/
823
824static BOOL p_is_hdmi_connected;
825static APP_VIDEO_FORMAT p_supported_format_list[16];
826static int p_num_supported_format_list;
827static APP_VIDEO_FORMAT p_prefered_format;
828
829#define FORMAT_H2A(f) \
830                        (f)==eDHL_DISP_1920x1080i?APP_VIDEO_FORMAT_1080I:\
831                        (f)==eDHL_DISP_1280x720p?APP_VIDEO_FORMAT_720P:\
832                        (f)==eDHL_DISP_720x480p?APP_VIDEO_FORMAT_480P:\
833                        (f)==eDHL_DISP_720x480i?APP_VIDEO_FORMAT_480I:APP_VIDEO_FORMAT_NONE
834
835#define FORMAT_A2M(f) \
836                        (f==APP_VIDEO_FORMAT_1080I)?VOUT_1080I:\
837                        (f==APP_VIDEO_FORMAT_720P)?VOUT_720P:\
838                        (f==APP_VIDEO_FORMAT_480P)?VOUT_480P:\
839                        (f==APP_VIDEO_FORMAT_480I)?VOUT_480I:VOUT_NATURAL
840
841#define FORMAT_M2A(f) \
842                        (f==VOUT_1080I)?APP_VIDEO_FORMAT_1080I:\
843                        (f==VOUT_720P)?APP_VIDEO_FORMAT_720P:\
844                        (f==VOUT_480P)?APP_VIDEO_FORMAT_480P:\
845                        (f==VOUT_480I)?APP_VIDEO_FORMAT_480I:APP_VIDEO_FORMAT_NONE
846
847
848/* prefered resolution */
849void App_VideoSetPreferedResolution(APP_VIDEO_FORMAT format, BOOL bSave)
850{
851        int i;
852       
853        p_vid_nvm_param.output_resolution = FORMAT_A2M(format);
854       
855        if(!p_is_hdmi_connected) {
856                App_VideoSetOutputResolution(format);
857        }
858        else {
859                for(i=0; i<p_num_supported_format_list; i++) {
860                        if(format==p_supported_format_list[i]) {
861                                App_VideoSetOutputResolution(format);
862                                break;
863                        }
864                }
865                if(i==p_num_supported_format_list) {
866                        App_VideoSetOutputResolution(p_prefered_format);
867                }
868        }
869        // HAL apiÀÇ º¯°æÀ¸·Î ÀÎÇÏ¿© ÀÌ MW ÇÔ¼ö´Â ´õ ÀÌ»ó arc ¼³Á¤Àº ÇÏÁö ¾Ê°í ÀÖ´Ù.
870       
871        if(bSave)
872                App_NVM_SaveModuleParam(eAPP_NVR_VIDEO, &p_vid_nvm_param);
873}
874
875APP_VIDEO_FORMAT App_VideoGetPreferedResolution()
876{
877        return FORMAT_M2A(p_vid_nvm_param.output_resolution);
878}
879
880
881static void _HdmiCangeCallback(tDHL_AVCallbackType cb_type, UINT32 param)
882{
883        int idx=0;
884        tDHL_VideoHdmiStatus *hdmi_status;
885       
886        if(cb_type!=eDHL_CB_HdmiStatusChanged) return;
887       
888        hdmi_status=(tDHL_VideoHdmiStatus *)param;
889       
890        p_is_hdmi_connected=hdmi_status->bConnected;
891       
892        if(p_is_hdmi_connected) {
893                if(hdmi_status->supportedFormat & (1<<eDHL_DISP_1920x1080i)) 
894                        p_supported_format_list[idx++]=APP_VIDEO_FORMAT_1080I;
895                if(hdmi_status->supportedFormat & (1<<eDHL_DISP_1280x720p)) 
896                        p_supported_format_list[idx++]=APP_VIDEO_FORMAT_720P;
897                if(hdmi_status->supportedFormat & (1<<eDHL_DISP_720x480p)) 
898                        p_supported_format_list[idx++]=APP_VIDEO_FORMAT_480P;
899                if(hdmi_status->supportedFormat & (1<<eDHL_DISP_720x480i)) 
900                        p_supported_format_list[idx++]=APP_VIDEO_FORMAT_480I;
901               
902                p_num_supported_format_list=idx;
903       
904                p_prefered_format=FORMAT_H2A(hdmi_status->preferedFormat);
905               
906                if(p_prefered_format==APP_VIDEO_FORMAT_NONE)
907                        p_prefered_format=p_supported_format_list[0];
908        }
909        //todo : popupÀ» ¶ç¿ï ¼ö ÀÖÀ¸¸é µÊ
910        {
911                DMG_SetUserKeyInput(APP_VK_CUSTOM0);
912        }
913}
914
915
916APP_VIDEO_FORMAT App_VideoGetOutputResolution()
917{
918        //½ÇÁ¦ Àû¿ëµÇ°í ÀÖ´Â ÇØ»óµµ¸¦ ¾ò¾î¿È
919        tDHL_VideoStatus status;
920       
921        DHL_AV_VideoGetStatus(0, &status);
922       
923        return FORMAT_H2A(status.curDisplayFormat);
924}
925
926
927void App_VideoSetOutputResolution(APP_VIDEO_FORMAT format)
928{
929        Dmc_ChangeDisplay(
930                VOUT_YPBPR, 
931                FORMAT_A2M(format),
932                (VOUT_RATIO)p_vid_nvm_param.screen_ratio,
933                g_App_VideoAdjustmentHd, // ¾Æ¹« °ªÀÌµç »ó°ü ¾ø´Ù.
934                noAuxVideo);
935}
936
937
938APP_VIDEO_FORMAT App_VideoGetAndSetNextSupportedFormat()
939{
940        int i;
941       
942        APP_VIDEO_FORMAT format=App_VideoGetOutputResolution();
943       
944        if(p_is_hdmi_connected) {
945                for(i=0; i<p_num_supported_format_list; i++) {
946                        if(format==p_supported_format_list[i]) {
947                                if(++i>=p_num_supported_format_list) i=0;
948#if 0    // ¼±È£ ÇØ»óµµ¸¦ º¯°æÇÒ ÇÊ¿ä ¾øÀ½.                     
949                                if(p_supported_format_list[i]!=APP_VIDEO_FORMAT_NONE) {
950                                        p_vid_nvm_param.output_resolution = FORMAT_A2M(p_supported_format_list[i]);
951                                        App_NVM_SaveModuleParam(eAPP_NVR_VIDEO, &p_vid_nvm_param);
952                                }
953#endif 
954                                App_VideoSetOutputResolution(p_supported_format_list[i]);
955                               
956                                return p_supported_format_list[i];
957                        }
958                }
959                /* for¹®À» ´Ù µ¹¾Æµµ ÇØ´çµÇ´Â ÇØ»óµµ¸¦ ¼±ÅÃÇÒ ¼ö ¾ø´Ù? ÀÌ·± °æ¿ì°¡ ÀÖÀ»±î? */
960               
961        }
962        else { /* hdmi°¡ ¿¬°áµÇ¾îÀÖÁö ¾Ê´Â °æ¿ì */
963                format=
964                        format==APP_VIDEO_FORMAT_1080I?APP_VIDEO_FORMAT_720P:
965                        format==APP_VIDEO_FORMAT_720P?APP_VIDEO_FORMAT_480P:
966                        format==APP_VIDEO_FORMAT_480P?APP_VIDEO_FORMAT_480I:APP_VIDEO_FORMAT_1080I;
967#if 0           
968                p_vid_nvm_param.output_resolution = FORMAT_A2M(format);
969                App_NVM_SaveModuleParam(eAPP_NVR_VIDEO, &p_vid_nvm_param);
970#endif
971                App_VideoSetOutputResolution(format);
972                return format;
973        }
974       
975        return format;
976}
977
978
979
980
981
982#if COMMENT
983____Scr_Ratio____(){}
984#endif
985
986void App_VideoSetScrRatio(APP_DISP_RATIO ratio, BOOL bSave)
987{
988        p_vid_nvm_param.screen_ratio=ratio;
989
990        // hal api º¯°æÀ¸·Î ÀÎÇÏ¿© ¾Æ·¡ MW ÇÔ¼ö´Â ¿ÀÁ÷ resolution & color ¸¸ ¼³Á¤Çϰí ÀÖÀ½.
991#if 0
992        Dmc_ChangeDisplay(
993                                        VOUT_YPBPR,
994                                        (VOUT_FORMAT)p_vid_nvm_param.output_resolution,
995                                        (VOUT_RATIO)p_vid_nvm_param.screen_ratio,
996                                        g_App_VideoAdjustmentHd,
997                                        noAuxVideo);
998#endif
999
1000        App_VideoChangeDisplayMode((APP_DISP_MODE)g_App_videoDisplayModeSet, 0);
1001       
1002        if(bSave)
1003                App_NVM_SaveModuleParam(eAPP_NVR_VIDEO, &p_vid_nvm_param);
1004}
1005
1006
1007APP_DISP_RATIO App_VideoGetScrRatio()
1008{
1009        return (APP_DISP_RATIO)p_vid_nvm_param.screen_ratio;
1010} 
1011
1012
1013void App_VideoSetEdgeColor(APP_VIDEO_EDGE_COLOR color, BOOL bSave)
1014{
1015        static APP_VIDEO_EDGE_COLOR p_prev_color=APP_VIDEO_EDGE_BLACK;
1016       
1017        if(p_prev_color!=color) {
1018
1019                if(color==APP_VIDEO_EDGE_BLACK) {
1020                        DHL_AV_Control(eDHL_AV_CTL_VIDEO_BG_COLOR, 0xff000000);
1021                }
1022                else {
1023                        DHL_AV_Control(eDHL_AV_CTL_VIDEO_BG_COLOR, 0xff808080);
1024                }
1025
1026                p_prev_color=color;
1027        }
1028       
1029        if(bSave) {
1030                p_vid_nvm_param.edge_color=color;
1031                App_NVM_SaveModuleParam(eAPP_NVR_VIDEO, &p_vid_nvm_param);
1032        }
1033}
1034
1035
1036APP_VIDEO_EDGE_COLOR App_VideoGetEdgeColor()
1037{
1038        return (APP_VIDEO_EDGE_COLOR)p_vid_nvm_param.edge_color;
1039}
1040
1041
1042
1043#if COMMENT
1044____Menu_Opacity____(){}
1045#endif
1046
1047
1048tDHL_AlphaMode APP_GetMenuOpacity()
1049{
1050        return (tDHL_AlphaMode)p_vid_nvm_param.menu_trans;
1051}
1052
1053
1054void APP_SetMenuOpacity(tDHL_AlphaMode mode)
1055{
1056        p_vid_nvm_param.menu_trans=(UINT8)mode;         
1057        App_NVM_SaveModuleParam(eAPP_NVR_VIDEO, &p_vid_nvm_param);
1058}
1059
1060
1061
1062
1063
1064#if COMMENT
1065____Freeze____(){}
1066#endif
1067
1068//  App_VideoFreeze
1069//
1070//  VideoÈ­¸é freeze toggle ½ÃŲ´Ù.
1071//  ¸®ÅϰªÀ¸·Î ÇöÀç freeze »óŸ¦ ¸®ÅÏÇÑ´Ù.
1072//
1073BOOL App_VideoToggleFreeze(void)
1074{
1075        tDHL_VideoStatus vstatus;
1076        DHL_RESULT result;
1077        BOOL bFreezed = FALSE;
1078       
1079        dprint(0, "video toggle freeze\n");
1080
1081        result=DHL_AV_VideoGetStatus(0, &vstatus);
1082       
1083        if(result) {
1084                dprint(0, "error : DHL_AV_VideoGetStatus failed(err code : %d)\n", result);
1085                return FALSE;
1086        }
1087       
1088        if (vstatus.bDecoding) {
1089                Dmc_FreezeVideo(TRUE, FALSE);
1090                bFreezed = TRUE;
1091        }
1092        else {
1093                Dmc_FreezeVideo(FALSE, FALSE);
1094        }
1095       
1096        return bFreezed;
1097}
1098
1099
1100void App_ForceDisableFreeze(void)
1101{
1102        tDHL_VideoStatus vstatus;
1103        DHL_RESULT result;
1104        BOOL bFreezed = FALSE;
1105       
1106        dprint(0, "video toggle freeze\n");
1107
1108        result=DHL_AV_VideoGetStatus(0, &vstatus);
1109       
1110        if(result) {
1111                dprint(0, "error : DHL_AV_VideoGetStatus failed(err code : %d\n", result);
1112                return;
1113        }
1114       
1115        if(!vstatus.bDecoding || !vstatus.bOutputExist) {
1116                //decodingÀÌ ¾ÈµÇ°í Àְųª, outputÀÌ ¾øÀ¸¸é ¹Ù·Î ¸®ÅÏÇÔ
1117                return;
1118        }
1119       
1120        Dmc_FreezeVideo(FALSE, FALSE);
1121}
1122
1123
1124#if COMMENT
1125____AD_Toggle____(){}
1126#endif
1127
1128//iskang 080331. add.
1129//analog pass through timeout ¼³Á¤.
1130//´ÜÀ§ milli sec.
1131static int g_AnalogPassExTimeOut = 700;
1132static BOOL g_bAnalogPassThruExcuting = FALSE;
1133 
1134void _AnalogPassThroughEXTimerProc(UINT32 nIdTimer)
1135{
1136        if (nIdTimer != TIMER_ID_ANALOGPASS)
1137                return;
1138
1139        //DHL_SYS_ResetGPIO(GPIO_RF34_CTRL);
1140        g_bAnalogPassThruExcuting = FALSE;//excute end!!
1141        dprint(0, "Analog Pass through excuted!!\n");   
1142
1143        // TODO:  After RCU porting
1144        // App_SimulateRcuKey(APP_VK_POWER_OFF); // App_Debug.c »ç¿ë½Ã »ç¿ëÇÏÀÚ.
1145}
1146
1147
1148BOOL App_VideoToggleAD(void)
1149{
1150        BOOL bCurrentAD;
1151        static BOOL bRegdAD = TRUE;
1152       
1153        dprint(0, "A/D toggle\n");
1154       
1155        //bCurrentAD = DHL_SYS_ReadGPIO(GPIO_RF34_CTRL);
1156        bCurrentAD = bRegdAD;
1157
1158        bCurrentAD=bCurrentAD?FALSE:TRUE;
1159       
1160        dprint(0, "--> A/D set to %d\n", bCurrentAD);
1161       
1162        if(g_bAnalogPassThruExcuting)
1163        {       
1164                //¸ÕÀú ½ÇÇàÀÌ µÇ¾ú´Ù¸é(excute start »óÅÂÀ̸é) ..
1165                dprint(0, "D->A key Comming Again in Changing D->A !!\n");
1166                return bCurrentAD;
1167        }       
1168        if (bCurrentAD)
1169                ;//DHL_SYS_SetGPIO(GPIO_RF34_CTRL);
1170        else
1171        {
1172//              DHL_SYS_ResetGPIO(GPIO_RF34_CTRL);
1173                DMW_SYS_SetTimer(TIMER_ID_ANALOGPASS, g_AnalogPassExTimeOut,
1174                        (DMW_TIMER_PROC)_AnalogPassThroughEXTimerProc,0,TRUE);
1175                g_bAnalogPassThruExcuting = TRUE;//excute start!!
1176        //iskang 080331 add.
1177        //timeoutÈÄ¿¡ D->A°¡ ½ÇÇàÇϵµ·Ï ÇÑ´Ù.
1178        }
1179       
1180        if(bRegdAD) bRegdAD=FALSE;
1181        else bRegdAD=TRUE;
1182       
1183        return bCurrentAD;
1184}
1185
1186
1187
1188
1189
1190#if COMMENT
1191____Debug____(){}
1192#endif
1193
1194static void video_stat(void)
1195{
1196        APP_DISP_MODE mode;
1197
1198        DHL_OS_Printf("Adjustment hd %d, sd %d\n", 
1199                        g_App_VideoAdjustmentHd, g_App_VideoAdjustmentSd);
1200        //DHL_OS_Printf("DisplayRatio: %d (%s)\n",
1201        //              DST_Ratio, PnxDisplayRatioString(DST_Ratio));
1202        DHL_OS_Printf("DisplayMode status:\n");
1203
1204        mode = App_VideoGetDisplayModeFlag(1);
1205        DHL_OS_Printf("  narrow disp, wide src: %d (%s)\n",
1206                        mode, PnxDisplayModeString(mode));
1207
1208        mode = App_VideoGetDisplayModeFlag(0);
1209        DHL_OS_Printf("  narrow disp, narrow src: %d (%s)\n",
1210                        mode, PnxDisplayModeString(mode));
1211}
1212
1213
1214static void video_help(void)
1215{
1216        DHL_OS_Printf("\tvideo_ratio [0/1] [save]\n");
1217        DHL_OS_Printf("\tvideo_mode [0/1/2] [save]\n");
1218        DHL_OS_Printf("\tvideo_freeze: toggle freeze\n");
1219        DHL_OS_Printf("\tvideo_mute [0/1]\n");
1220        DHL_OS_Printf("\tvideo_aux [aux]\n");
1221}
1222
1223
1224
1225
1226
1227#if COMMENT
1228_____AFD_____() {}
1229#endif
1230
1231#if SUPPORT_AFD
1232
1233static void p_afd_process_timerproc(UINT32 id, UINT32 afdFormat);
1234
1235static void p_afd_process(UINT8 afdFormat, int retryCount)
1236{
1237        BOOL bSrcWide=FALSE;
1238        APP_DISP_MODE dispMode;
1239        int tvOutMode=0;
1240        int adjMode;
1241        int i;
1242        tDHL_VideoSeqHdr seq;
1243        UINT32 param;
1244       
1245  /*
1246        090116, afd value 0x4 is added.
1247                        14:9 adjustment is added for (0,0,0xe) (0,0,0xf) (0,1,0xb) (0,1,0xe).
1248        090116, afd value 0 is also added.
1249       
1250  */
1251        struct {
1252                BOOL bDisplayWide;
1253                BOOL bSrcWide;
1254                UINT8 afdFmt;
1255                UINT8 vidAdj;
1256        } afdTable[]=
1257        {
1258                // 4:3 display, 4:3 coded
1259                {0, 0, 0x0, eDHL_ARC_FULLSCREEN}, // added
1260                {0, 0, 0x4, eDHL_ARC_FULLSCREEN}, // added
1261                {0, 0, 0x8, eDHL_ARC_FULLSCREEN},
1262                {0, 0, 0x9, eDHL_ARC_FULLSCREEN},
1263                {0, 0, 0xa, eDHL_ARC_FULLSCREEN},
1264                {0, 0, 0xb, eDHL_ARC_FULLSCREEN},
1265                {0, 0, 0xd, eDHL_ARC_FULLSCREEN},
1266
1267                // TODO: CB3¿¡¼­ »ç¿ëÇÑ Å¸ÀÔÀÌ Á¤À̵ǾîÀÖÁö ¾Ê´Ù.
1268                {0, 0, 0xe, eDHL_ARC_FULLSCREEN},               // CB3 : FORCE_CENTER_875 
1269                {0, 0, 0xf, eDHL_ARC_FULLSCREEN},               // CB3 : FORCE_CENTER_75 
1270
1271                // 4:3 display, 16:9 coded
1272                {0, 1, 0x0, eDHL_ARC_LETTERBOX_OVERSCAN}, // added
1273                {0, 1, 0x4, eDHL_ARC_LETTERBOX_OVERSCAN}, // added
1274                {0, 1, 0x8, eDHL_ARC_LETTERBOX_OVERSCAN},
1275                {0, 1, 0x9, eDHL_ARC_PAN_AND_SCAN},
1276                {0, 1, 0xa, eDHL_ARC_LETTERBOX_OVERSCAN},
1277                {0, 1, 0xb, eDHL_ARC_PARTIAL_LETTERBOX}, // <- FORCE_PAN_AND_SCAN
1278                {0, 1, 0xd, eDHL_ARC_PAN_AND_SCAN},
1279                {0, 1, 0xe, eDHL_ARC_PARTIAL_LETTERBOX}, // <- FORCE_PAN_AND_SCAN
1280                {0, 1, 0xf, eDHL_ARC_PAN_AND_SCAN},
1281
1282                // 16:9 display - this table is not tested at all.
1283                {1, 0, 0x8, eDHL_ARC_SIDEBAR}, {1, 1, 0x8, eDHL_ARC_FULLSCREEN},
1284                {1, 0, 0x9, eDHL_ARC_SIDEBAR}, {1, 1, 0x9, eDHL_ARC_FULLSCREEN},
1285                {1, 0, 0xa, eDHL_ARC_PAN_AND_SCAN}, {1, 1, 0xa, eDHL_ARC_FULLSCREEN},
1286                {1, 0, 0xb, eDHL_ARC_PAN_AND_SCAN}, {1, 1, 0xb, eDHL_ARC_FULLSCREEN},
1287                {1, 0, 0xd, eDHL_ARC_PAN_AND_SCAN}, {1, 1, 0xd, eDHL_ARC_PAN_AND_SCAN},
1288                {1, 0, 0xe, eDHL_ARC_PAN_AND_SCAN}, {1, 1, 0xe, eDHL_ARC_FULLSCREEN},
1289                {1, 0, 0xf, eDHL_ARC_PAN_AND_SCAN}, {1, 1, 0xf, eDHL_ARC_FULLSCREEN},
1290        };
1291       
1292        #define NUM_AFD_TABLE (sizeof(afdTable)/sizeof(afdTable[0]))
1293
1294        if (DHL_AV_VideoSeqInfo(0, &seq) != DHL_OK) {
1295                // sequence header not received after tuning start.
1296                // we cannot decide source wide/narrow.
1297                // wait again..
1298                //
1299                // todo:
1300                //  for audio only channel or no program channel,
1301                //  this makes debug screen too verbose.. try other better method..
1302                //
1303                if (++retryCount < 10) {
1304                        param = afdFormat | (retryCount << 8);
1305                       
1306                        printf("!!!! afd %x, no seq hdr yet. wait.. cnt %d\n", afdFormat, retryCount);
1307                        DMW_SYS_SetTimer(TIMER_ID_AFD_DPC, 100, p_afd_process_timerproc, param, TRUE);
1308                }
1309                return;
1310        }
1311
1312        dispMode=App_VideoGetCurrentDisplayMode(&bSrcWide);
1313        tvOutMode=App_VideoGetScrRatio()==APP_DISP_RATIO_WIDE?1:0;
1314       
1315        for(i=0, adjMode=-1; adjMode==-1 && i<NUM_AFD_TABLE; i++) {
1316                if(afdTable[i].bDisplayWide==tvOutMode &&
1317                        afdTable[i].bSrcWide==bSrcWide &&
1318                        afdTable[i].afdFmt==afdFormat) {
1319                        adjMode=afdTable[i].vidAdj;
1320                }
1321        }
1322       
1323        if(adjMode==-1) { 
1324                //ÀÌ·± °æ¿ì°¡ »ý±â¸é table¿¡¼­ Á¤ÀÇÇÏÁö ¾Ê°í ÀÖ´Â °ÍÀ̹ǷΠdefault°ª ANAMORPHICÀ¸·Î ¼³Á¤
1325                adjMode=bSrcWide ? DISP_MODE_AT_NO_AFD_WIDE : DISP_MODE_AT_NO_AFD_NARROW;
1326        }
1327       
1328        if(g_App_VideoAdjustmentHd != adjMode) {
1329                printf("________ active format = %x, adj %d ______\n", afdFormat, adjMode);
1330                g_App_VideoAdjustment = adjMode;
1331                        //neverdaii 080924. user¿¡ ÀÇÇØ g_App_VideoAdjustmentÀÌ º¯°æµÉ ¼ö Àֱ⠶§¹®¿¡
1332                        //Âг¯ °¡´É¼ºÀÌ ÀÖÀ»±î? mutex¸¦ ½á¾ßÇÒÁöµµ ¸ð¸§.
1333
1334                // race conditionÀÌ °ÆÁ¤ÀÌ µÇ¸é dmc task·Î defer ÇÏ¿© ¼öÇàÇÏÀÚ.
1335                Dmc_ChangeVideoAdjustment((tDHL_DispARC)adjMode);
1336        }
1337        else
1338                printf("________ afd %x, same adj value %d\n", afdFormat, adjMode);
1339       
1340}
1341
1342
1343
1344static void p_afd_process_timerproc(UINT32 id, UINT32 param)
1345{
1346        if (id == TIMER_ID_AFD_DPC)
1347                p_afd_process((UINT8)(param & 0xff), (param >> 8));
1348}
1349
1350
1351static void p_afd_process_callback(UINT8 afdFormat)
1352{
1353        UINT32 param = afdFormat; // zero count.
1354        DMW_SYS_SetTimer(TIMER_ID_AFD_DPC, 0, p_afd_process_timerproc, param, TRUE);
1355}
1356
1357
1358void App_VideoAfdInit()
1359{
1360        // TODO:  After DMW_CC porting (AFD)
1361//      DMW_SetAFDCallback(p_afd_process_callback);
1362}
1363
1364
1365/*
1366        trigger default afd.
1367
1368        if incoming stream has NO afd data, this default timer proc will be called.     
1369
1370        if incoming stream has afd data, user callback will be called back no later than 30 ms.
1371        this will delete default afd timer.
1372*/
1373void App_VideoAfdTriggerDefaultAfd(void)
1374{
1375        // trigger default afd value.
1376        // delay 100ms.
1377        // if real afd is coming, this delayed timer will be overridden with real one.
1378        // picture user data is 30 ms interval. so 100 ms is long enough.
1379        //
1380        // use invalid afd value on purpose.
1381
1382        UINT32 param = AFD_DEFAULT;     
1383        DMW_SYS_SetTimer(TIMER_ID_AFD_DPC, 100, p_afd_process_timerproc, param, TRUE);
1384}
1385
1386
1387/*
1388        start or stop monitor afd change.
1389
1390        before start monitor, we reset stored afd to init value.
1391        if afd is changed, it is called back to user proc.
1392*/
1393void App_VideoAfdStartMonitor(BOOL bOn)
1394{
1395        if (bOn) // start.
1396        {
1397                // TODO:  After DMW_CC porting (AFD)
1398
1399       
1400                // initialize afd value, so that any first following afd data is notified.
1401//              DMW_SetAFDFormat(AFD_UNINITIALIZED);
1402
1403                // start monitor.
1404//              DMW_SetAFDOn(TRUE);
1405
1406                // now, any valid afd will generate afd user callback.
1407        }
1408        else // stop.
1409        {
1410                // TODO:  After DMW_CC porting (AFD)
1411//              DMW_SetAFDOn(FALSE);
1412               
1413                // Ȥ½Ã timer queue¿¡ ³²¾Æ ÀÖÀ» ¼ö ÀÖ´Â dpc Á¦°Å.
1414                DMW_SYS_KillTimer(TIMER_ID_AFD_DPC);
1415        }
1416}
1417
1418
1419/*
1420BOOL App_IsAFDOn()
1421{
1422        return DMW_GetIsAFDOn();
1423}
1424*/
1425#endif /* SUPPORT_AFD */
1426
1427
1428
1429
1430#if COMMENT
1431____NvParam____(){}
1432#endif
1433
1434static void p_format_vid_param(void)
1435{
1436        UINT8 mode;
1437       
1438        p_vid_nvm_param.videoDisplayModeSet = (APP_DISP_MODE_ZOOM << 4) | (APP_DISP_MODE_ZOOM);
1439        p_vid_nvm_param.videoDisplayModeAuto = FALSE;
1440        p_vid_nvm_param.menu_trans=(UINT8)eDHL_ALPHA_100;
1441        p_vid_nvm_param.output_resolution=VOUT_480I;
1442        p_vid_nvm_param.screen_ratio=APP_DISP_RATIO_NARROW;
1443       
1444        App_NVM_SaveModuleParam(eAPP_NVR_VIDEO, &p_vid_nvm_param);
1445
1446#if 1 //neverdai 100802 These are required because of standby mode that is implemented by SW   
1447        g_App_videoDisplayModeSet = p_vid_nvm_param.videoDisplayModeSet;
1448        g_App_VideoDisplayModeAuto = p_vid_nvm_param.videoDisplayModeAuto;
1449        g_App_VideoAdjustmentHd = eDHL_ARC_FULLSCREEN;  // default
1450        g_App_VideoAdjustmentSd = eDHL_ARC_FULLSCREEN;  // default
1451
1452        // cafrii 070420 comment
1453        //  display mode (adjustment)´Â ³ªÁß¿¡ channel tuningÀ» ½ÃÀÛÇϰí
1454        // video°¡ ½ÃÀ۵Ǵ ¼ø°£ video source ratio¸¦ º¸°í »õ·Ó°Ô ´Ù½Ã Àû¿ëµÈ´Ù.
1455        // µû¶ó¼­ ¿©±â¼­´Â ¾Æ¹« °ªÀ̳ª Àû¿ëÇÏ¸é µÈ´Ù.
1456#if 1
1457        Dmc_ChangeDisplay(VOUT_YPBPR,
1458                                        (VOUT_FORMAT)p_vid_nvm_param.output_resolution,
1459                                        (VOUT_RATIO)p_vid_nvm_param.screen_ratio,
1460                                        g_App_VideoAdjustmentHd,
1461                                        noAuxVideo);
1462#endif
1463
1464
1465#if SUPPORT_AFD
1466        App_VideoAfdInit(); //neverdai 080924 AFD Init
1467#endif
1468
1469        App_VideoSetEdgeColor((APP_VIDEO_EDGE_COLOR)p_vid_nvm_param.edge_color, FALSE);
1470#endif
1471}
1472
1473
1474
1475
1476
1477#if COMMENT
1478____Symbol____(){}
1479#endif
1480
1481#if APP_REGISTER_DEBUG_SYMBOL
1482
1483static DHL_SymbolTable _VideoSymbolx[] =
1484{
1485        DHL_FNC_SYM_ENTRY2("video_mode", App_VideoChangeDisplayMode),
1486        DHL_FNC_SYM_ENTRY2("video_freeze", App_VideoToggleFreeze),
1487        DHL_FNC_SYM_ENTRY2("video_mute", App_VideoSetBlank),
1488        DHL_FNC_SYM_ENTRY2("video_stat", video_stat),
1489        DHL_FNC_SYM_ENTRY2("video_help", video_help),
1490};
1491
1492static void RegisterSymbols(void)
1493{
1494        DHL_DBG_RegisterSymbols(_VideoSymbolx, DHL_NUMSYMBOLS(_VideoSymbolx));
1495}
1496
1497#else
1498static void RegisterSymbols(void) { }
1499#endif  /* APP_REGISTER_DEBUG_SYMBOL */
1500
1501
1502
1503
1504
1505#if COMMENT
1506____Init____(){}
1507#endif
1508       
1509//  App_VideoInit
1510//
1511//  Video module ÃʱâÈ­.
1512//
1513
1514
1515void App_VideoInit(void)
1516{
1517        dprint(0, "%s:\n", __FUNCTION__);
1518
1519        RegisterSymbols();
1520
1521        /* °¢Á¾ init code.. */
1522       
1523        /* load nv param */
1524        App_NVM_LoadModuleParam(eAPP_NVR_VIDEO, &p_vid_nvm_param);
1525       
1526        /* apply nv param */
1527        g_App_videoDisplayModeSet = p_vid_nvm_param.videoDisplayModeSet;
1528        g_App_VideoDisplayModeAuto = p_vid_nvm_param.videoDisplayModeAuto;
1529        g_App_VideoAdjustmentHd = eDHL_ARC_FULLSCREEN;  // default
1530        g_App_VideoAdjustmentSd = eDHL_ARC_FULLSCREEN;  // default
1531
1532        // cafrii 070420 comment
1533        //  display mode (adjustment)´Â ³ªÁß¿¡ channel tuningÀ» ½ÃÀÛÇϰí
1534        // video°¡ ½ÃÀ۵Ǵ ¼ø°£ video source ratio¸¦ º¸°í »õ·Ó°Ô ´Ù½Ã Àû¿ëµÈ´Ù.
1535        // µû¶ó¼­ ¿©±â¼­´Â ¾Æ¹« °ªÀ̳ª Àû¿ëÇÏ¸é µÈ´Ù.
1536#if 0
1537        Dmc_ChangeDisplay(VOUT_YPBPR,
1538                                        (VOUT_FORMAT)p_vid_nvm_param.output_resolution,
1539                                        (VOUT_RATIO)p_vid_nvm_param.screen_ratio,
1540                                        g_App_VideoAdjustmentHd,
1541                                        noAuxVideo);
1542#endif
1543
1544
1545#if SUPPORT_AFD
1546        App_VideoAfdInit(); //neverdai 080924 AFD Init
1547#endif
1548
1549        App_VideoSetEdgeColor((APP_VIDEO_EDGE_COLOR)p_vid_nvm_param.edge_color, FALSE);
1550       
1551       
1552        DHL_AV_SetCallback(eDHL_CB_HdmiStatusChanged, _HdmiCangeCallback); //hdmi status
1553       
1554}
1555
1556void App_VideoParamInit(void)
1557{
1558        App_NVM_RegisterModule(eAPP_NVR_VIDEO, sizeof(p_vid_nvm_param), p_format_vid_param);
1559}
1560
1561
1562
1563/* end of file */
Note: See TracBrowser for help on using the repository browser.