source: svn/newcon3bcm2_21bu/dst/app/src/Function/App_Fnc_Pod.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: 27.0 KB
Line 
1/****************************************************************************
2* NAME: App_Fnc_Pod.c
3*----------------------------------------------------------------------------
4* Copyright (c) DIGITAL STREAM Technology Inc.
5*----------------------------------------------------------------------------
6* CREATED_BY: cafrii
7* CREATION_DATE: 2009/11/11
8* $Author: cafrii $
9* $Revision: 1.0 $
10* $Date: $
11*----------------------------------------------------------------------------
12* PURPOSE:
13*       - provide various CableCard Interface API.
14*****************************************************************************/
15
16/*_____ I N C L U D E __________________________________________*/
17
18#include "App_Main.h"
19
20#if SUPPORT_POD
21
22#include "App_Fnc_Pod.h"
23#include "App_Fnc_Power.h"
24#include "App_Res_Resources.h"
25
26#include "DMW_PodFlowControl.h"
27#include "DMW_SysTime.h"
28#include "DMW_Timer.h"
29#include "DMW_ScteSiScan.h"
30#include "DMW_HTMLParser.h"
31
32#include "DHL_AVCAP.h"
33
34
35
36/*_____ D E F I N I T I O N ____________________________________*/
37
38#if COMMENT
39_____DbgPrint_____(){}
40#endif
41
42DHL_MODULE("@f_pod", 0);
43
44
45
46
47
48#if COMMENT
49____Config____(){}
50#endif
51
52/*
53        -1 À̸é dialog ¾ø´Â »óÅÂ.
54        >=0 À̸é dialog°¡ ±×·ÁÁø »óÅÂ.
55        0x100 bit°¡ set µÇ¾î ÀÖÀ¸¸é card mmi, ¾Æ´Ï¶ó¸é host initiated html menu.
56*/
57#define CARD_MMI_MASK 0x100
58
59int s_dialog_nb = -1;
60
61#define IS_CARD_MMI() ((s_dialog_nb)>=0 && ((s_dialog_nb)&CARD_MMI_MASK))
62#define IS_HOST_DLG() ((s_dialog_nb)>=0 && ((s_dialog_nb)&CARD_MMI_MASK)==0)
63
64#define SET_HOST_DLG(dlg) ((s_dialog_nb) = (dlg)&0xff)
65#define SET_CARD_MMI(dlg) ((s_dialog_nb) = ((dlg)&0xff)|CARD_MMI_MASK)
66
67#define DLG_NB() ((s_dialog_nb)&0xff)
68#define CLEAR_DLG() ((s_dialog_nb) = -1)
69
70
71int s_card_dialog_nb = -1;
72
73PODIF_APINFO *s_apinfo;
74 // 2010.04.19 foxhunt : OSD¿¡¼­ externÀ¸·Î »ç¿ëÇϱâ À§ÇØ static ÇØÁ¦
75
76
77
78
79
80#if COMMENT
81____Types____(){}
82#endif
83
84
85
86
87
88#if COMMENT
89____Variables____(){}
90#endif
91
92static int gDelayBetweenSiFeedingMs = 100; 
93
94unsigned char *CardMmi;
95 // 2010.04.12 foxhunt : card mmi¸¦ ÀúÀåÇØµÎ±â À§ÇÑ Àü¿ªº¯¼ö
96 // 2010.04.19 foxhunt : Proc¿¡¼­ externÀ¸·Î »ç¿ëÇϱâ À§ÇØ header¿¡¼­ À̰÷À¸·Î À̵¿
97
98static BOOL AppRegisterON = FALSE;
99 // 2010.04.22 foxhunt : cardÀÇ ApplicationRegisterCb ¿©ºÎ¸¦ ¾Ë·ÁÁÖ´Â flag
100
101
102
103
104
105#if COMMENT
106________(){}
107#endif
108
109/*
110        mpod link thread ¿¡¼­ Á÷Á¢ card in/out µ¿ÀÛÀ» ¼öÇàÇÏ´Â °ÍÀº ¹Ù¶÷Á÷ÇÏÁö ¸øÇÔ.
111        ƯÈ÷ card ²Å°í ºÎÆÃÇϸé app init Çϱ⵵ Àü¿¡ ¸ÕÀú card in µ¿ÀÛ ¼öÇà Áß¿¡ Á×¾î¹ö¸².
112
113        flag¸¸ ¼³Á¤Çϰí, ³ª¸ÓÁö µ¿ÀÛÀº App task¿¡¼­ pollingÀ¸·Î µ¿ÀÛ Çϵµ·Ï ÇÔ.
114
115        ÁÖÀÇ: power on defaut »óŸ¦ card out »óÅ·Π°£ÁÖÇϱ⠶§¹®¿¡,
116                card out »óÅ¿¡¼­ ÇÁ·Î±×·¥ ½ÇÇà Çϸé card out À̶ó´Â callbackÀº È£ÃâµÇÁö ¾Ê´Â´Ù.
117*/
118void CardInsertedCb(BOOL bInserted)
119{
120        // ±×³É trigger¸¸ ¼öÇàÇϰí, ÀÌ driver thread¿¡¼­´Â ¾Æ¹«°Íµµ ÇÏÁö ¾Ê´Â´Ù. race condition °¡´É¼º ¶§¹®ÀÓ.
121        // ¿¹: card in callback ÀÌ ºÒ¸° ÈÄ º¯¼ö´Â ¼³Á¤ µÇ¾úÀ¸³ª ¾ÆÁ÷ card in process°¡ ÁøÇàµÇÁö ¾ÊÀº »óÅ¿¡¼­
122        // APP_POD_IsPodInserted()°¡ È£Ãâ µÉ °æ¿ì ¹®Á¦°¡ µÊ.
123        //
124        dprint(2, "card inserted %d detected\n", bInserted);
125       
126        // ¾ÆÁ÷ ¸Þ´º systemÀÌ ÃʱâÈ­ µÇÁö ¾ÊÀº »óÅÂÀÎ °æ¿ì ¹®Á¦°¡ ¹ß»ýÇÒ ¼ö ÀÖÀ½..
127        // --> DMG_SendMessage µîÀÇ Äڵ忡 º¸È£ ·çƾ Ãß°¡.
128        //
129        // ¸Þ´º system ÃʱâÈ­ Àü¿¡ insert callbackÀÌ ¿À´Â °æ¿ì ¹«½ÃµÊ.
130        // --> power ready callback ³»¿¡¼­ card check¸¦ ´Ù½Ã ¼öÇàÇÔ. ¹®Á¦ ¾øÀ½.
131        //
132        DMG_SetUserDefined(UD_ID_OP_STATE, 0, 0);
133                // defer to menu task. executed in APP_OP_xxx()
134}
135
136
137/*
138        host requested html À̳ª, card mmi ³ª ¸ðµÎ dialog·Î °ü¸®ÇÑ´Ù.
139       
140        ÇÑ ¼ø°£¿¡ ÇϳªÀÇ dialog¸¸ Ãë±ÞÇÑ´Ù.
141                (card mmi, host initiated html ¸Þ´º, ÅëÆ²¾î¼­ 1°³)
142               
143        TV ¸Þ´º°¡ Ç¥½ÃµÈ »óÅ¿¡¼­ÀÇ card mmi Çã¿ë ¿©ºÎ´Â º°µµ policy¿¡ µû¸¥´Ù.
144        TV ¸Þ´º¾È¿¡ Æ÷ÇÔµÈ CableCard ¸Þ´ºµµ TV ¸Þ´ºÀÇ ÀϺηΠ°£ÁÖÇÑ´Ù.
145       
146        Card mmi ´ÙÀ̾ó·Î±×´Â »ç¿ëÀÚ ¸®¸ðÄÁ/¹öư µîÀ¸·Î Ãë¼Ò ÇÒ ¼ö ÀÖ´Ù.
147       
148                dialog number ÃßÀû ÇÊ¿ä.
149                card mmi ÀÎÁö ¸Þ´º ÀÎÁö Ç÷¡±× °ü¸®.
150               
151        Card mmi°¡ Ç¥½ÃµÈ »óÅ¿¡¼­ close ¾øÀÌ ´Ù½Ã »õ·Î¿î card mmi ¿äûÀÌ ¿Â °æ¿ì.
152                --> ÀÌÀü card mmi Ãë¼Ò.
153*/
154
155void PrintApInfo(void)
156{
157        int i;
158        PODIF_APINFO *apinfo = s_apinfo;
159       
160        DHL_OS_Printf("=== total %d apps\n", apinfo->num_application);
161        DHL_OS_Printf("  card mfg_id %04x, ver %04x\n", apinfo->mfg_id, apinfo->version);
162        if (apinfo->cardinfo_valid) {
163                UINT8 *m = apinfo->card.mac_addr;
164                DHL_OS_Printf("    %02x-%02x-%02x-%02x-%02x-%02x, %s\n", 
165                                        m[0],m[1],m[2],m[3],m[4],m[5], apinfo->card.serial);
166        }
167        for (i=0; i<apinfo->num_application; i++) {
168                DHL_OS_Printf("  (%d) %u %04x, %s, %s\n", i, apinfo->appinfo[i].type, apinfo->appinfo[i].version,
169                                        apinfo->appinfo[i].name, apinfo->appinfo[i].url);
170        }
171        DHL_OS_Printf("\n");
172}
173
174
175/* 2010.04.22 foxhunt
176        card in ÈÄ, Ä«µå ÀνÄ(ApplicationRegisterCb) µÇ±â Àü¿¡ host mmi¸¦ ½ÇÇàÇϸé hang-up.
177        cardÀÇ applicationÀ» Àü´Þ ¹ÞÀº ÈÄ, host mmi¸¦ ½ÇÇàÇÒ ¼ö ÀÖ°Ô ÇϱâÀ§ÇÑ Flag¿ë ÇÔ¼ö.
178*/
179BOOL AppInfoRegisterOn(BOOL bOn)
180{
181        // card out »óÅÂÀ̸鼭, App_Op_ChangeOperationState·ÎºÎÅÍ eUDCP_OP_CABLE_INB°ªÀ» Àü´Þ ¹Þ¾ÒÀ» °æ¿ì.
182        if(!APP_POD_IsPodInserted() || bOn==FALSE)
183                AppRegisterON = FALSE;
184               
185        dprint(2, "AppRegisterON is %s !!\n", AppRegisterON?"TRUE":"FALSE");
186               
187        return AppRegisterON;
188}
189
190
191
192
193
194#if COMMENT
195________(){}
196#endif
197
198void ApplicationRegisterCb(PODIF_APINFO *apinfo)
199{
200        dprint(2, "new apinfo received\n");
201               
202        AppRegisterON = TRUE;
203        DMG_SetUserDefined(UD_ID_APP_RG_ON, 0, 0);
204         // app µî·ÏÀÌ ³¡³µÀ½À» ¾Ë·ÁÁÖ¾î wait host mmi banner¸¦ ´Ý°ÔÇÑ´Ù.
205       
206        if (s_apinfo) {
207                dprint(2, "free previous apinfo..\n");
208                PODIF_APPUI_FreeApInfo(s_apinfo);
209                s_apinfo = NULL;
210        }
211        s_apinfo = apinfo;
212       
213        if (dprintable(2)) {
214                PrintApInfo();
215        }
216}
217
218
219void URLReceivedCb(UINT8 dialogNb, int nMimeType, unsigned char *pData, unsigned long ulCount)
220{
221        /* HTMLÀ» ±×¸®´Â µÎ °¡Áö °èÅë.
222          1. host mmi : »ç¿ëÀÚ°¡ ¸ÞÀÎ ¸Þ´º¿¡¼­ Card App List Áß¿¡ Çϳª¸¦ ¼±ÅÃÇÏ´Â °æ¿ì.
223          2. card mmi : Card¿¡¼­ MMI message¸¦ º¸³»´Â °æ¿ì.
224        */
225        if (IS_HOST_DLG()) {
226                if (DLG_NB()==dialogNb) {
227                        dprint(2, "host html data received, dlg# %u, %u bytes\n", dialogNb, ulCount);
228                        HTML_Parse(pData); // 2010.01.06. foxhunt : È­¸é¿¡ html Ç¥½Ã
229                }
230                else {
231                        dprint(0, "!! unmatched dlg\n"); // ¾û¶×ÇÑ dialog number..
232                }
233        }
234        else { // IS_CARD_MMI()
235                dprint(2, "card mmi html received. dlg# %u, %u bytes\n", dialogNb, ulCount);
236               
237                // ¼ö½ÅÇÑ Card MMI¸¦ Àü¿ª º¯¼ö¿¡ ÀúÀå
238                CardMmi = ReceiveCardMmi(pData);
239                dprint(3, "%s [2]/////\n %s\n", __FUNCTION__, CardMmi);
240               
241                DMG_MenuStart(MID_HTML_MMI_CARD);
242                SET_CARD_MMI(dialogNb);
243        }
244
245        if (dprintable(2)) {
246                int len;
247                char buf[110];
248                DHL_OS_Printf("--------------------------\n");
249                for ( ; ulCount>0; pData+=len, ulCount-=len)
250                {
251                        len = min(ulCount, 100);
252                        memcpy(buf, pData, len);
253                        buf[len] = 0;
254                        DHL_OS_Printf(buf);
255                }
256                DHL_OS_Printf("\n--------------------------\n");
257        }       
258}
259
260
261void URLReportErrorCb(UINT8 dialogNb, int nErrorNumber)
262{
263#if EXAMPLE
264        char errText[]="<body><center><br><br><br><font size=+5>"
265                "The page cannot be displayed</font><br><br><br><br>"
266                "<font size=-1>The page you are looking for is currently unavailable.</center></body>";
267#endif
268
269        if (IS_HOST_DLG() && DLG_NB()==dialogNb) {
270                dprint(0, "host html report error, dlg# %u, err %u\n", dialogNb, nErrorNumber);
271
272                // Ȥ½Ã "Waiting..." µîÀÇ ¸Þ½ÃÁö¸¦ Ç¥½ÃÇØµÐ »óŶó¸é Áö¿ö¾ß ÇÔ.
273                // "Not found" ¿Í °°Àº ¸Þ½ÃÁö¸¦ Ç¥½ÃÇØÁ൵ ÁÁÀ½.
274               
275                // todo..
276        }
277        else if (IS_CARD_MMI() && DLG_NB()==dialogNb) {
278                dprint(0, "card mmi url error, dlg# %u, err %u\n", dialogNb, nErrorNumber);
279               
280                // todo..               
281        }
282}
283
284
285/*
286        cardÀÇ open_mmi_req()¿¡ ´ëÇÑ callback ÀÌ´Ù.
287        mmi¸¦ Ç¥½Ã ÇÒ ¼ö ÀÖ´ÂÁö ¿©ºÎ È®ÀοëÀÓ. accept or deny.
288
289        accept ÇÏ°Ô µÇ¸é podlib ³»ºÎ¿¡¼­ server query¸¦ ÀÚµ¿À¸·Î ÁøÇàÇÑ´Ù.
290*/
291podResult PrepareDialogCb(unsigned char ucDialogNumber, int nDisplayType)
292{
293        // check if dialog can be drawn..
294        // ¸¸¾à TV ¸Þ´º°¡ ±×·ÁÁ® ÀÖÀ» °æ¿ì ¸Þ´º¸¦ Á¦°ÅÇÏ°í °è¼Ó ÁøÇàÇϰųª, ¾Æ´Ï¸é mmi¸¦ reject ÇÏ¸é µÊ.
295       
296        // card mmi°¡ Ç¥½ÃµÈ »óŶó¸é ÀÌÀü card mmi¸¦ Á¦°ÅÇÑ´Ù.
297        if (IS_CARD_MMI()) {
298                UINT8 card_mmi_dlg = DLG_NB();
299                dprint(2, "!! prev card mmi exist. dlg#%u. cancel first..\n", card_mmi_dlg);
300               
301                //PODIF_APPUI_HostCloseDialog(card_mmi_dlg);
302                  /* 2010.04.01 foxhunt
303                         * host mmi¿¡¼­ card mmi ¿À¸é Á×´Â ¹®Á¦ ¼öÁ¤
304                         * ClearScreen´Â »ç¿ëÇØµµ µÇÁö¸¸, PODIF_APPUI_HostCloseDialog »ç¿ëÇϸé hang-up ¹ß»ý */
305               
306                //ClearScreen(0, TRUE); // 2010.02.17 foxhunt : ±âÁ¸ card mmi Á¦°Å¸¦ À§ÇÑ È­¸é clear Ãß°¡
307                  /* 2010.04.13 foxhunt
308                   * Card MMIµµ ProcÀ¸·Î ±¸ÇöµÇ¾ú±â ¶§¹®¿¡ È­¸é ÀÚü Clear¸¦ ÇØÁÙ ÇÊ¿ä´Â ¾ø´Ù. */
309               
310                CLEAR_DLG();
311        }
312        else if (IS_HOST_DLG()) {
313                UINT8 host_dlg = DLG_NB();
314                dprint(2, "host dlg exist. cancel first..\n");
315               
316                //PODIF_APPUI_HostCloseDialog(host_dlg);
317                //ClearScreen(0, TRUE); // 2010.02.17 foxhunt : ±âÁ¸ card mmi Á¦°Å¸¦ À§ÇÑ È­¸é clear Ãß°¡
318                CLEAR_DLG();
319        }
320               
321        return PODRESULT_OK;
322}
323
324
325/*
326        cardÀÇ close_mmi_req()¿¡ ´ëÇÑ callback À̹ǷÎ,
327        ÀÌ dialog´Â card dialog ÀÌ´Ù.
328
329        close_mmi_cnf()´Â podlib ³»ºÎ¿¡¼­ º¸³½´Ù.
330*/
331podResult CloseDialogCb(unsigned char ucDialogNumber)
332{
333        if (IS_CARD_MMI()) {
334                if (DLG_NB()==ucDialogNumber) {
335                        dprint(2, "close card mmi, dlg#%u\n", ucDialogNumber);
336                       
337                        APP_POD_CloseDialog();
338                         // 2010.04.06 foxhunt : card mmi°¡ Áߺ¹Çؼ­ ¿Ã ¶§ Áö¿öÁÖ¾î¾ß ÇÑ´Ù.
339                        DMG_MenuExit(MID_HTML_MMI_CARD);
340                         // 2010.04.13 foxhunt : ProcÈ­ µÇ¾îÀֱ⠶§¹®¿¡ MenuExit¸¦ ÇØÁÖ´Â °ÍÀÌ ¿Ç´Ù.
341                        CLEAR_DLG();
342                }
343                else {
344                        dprint(0, "!! card trying close dlg#%u, but cur mmi is %u.\n", 
345                                ucDialogNumber, DLG_NB());
346                }
347        }
348        else {
349                dprint(0, "!! no card mmi %u exist\n", ucDialogNumber);
350        }
351        return PODRESULT_OK;
352}
353
354
355/*
356        urlÀº apinfoÀÇ application À̰ųª, html page³»ÀÇ link urlÀ̾î¾ß ÇÑ´Ù.
357*/
358void APP_POD_OpenDialog(char *url)
359{
360        UINT8 dialogNb;
361        podResult pr;
362       
363        if (IS_CARD_MMI() || IS_HOST_DLG()) {
364                dprint(0, "!! prev %s dlgdlg#%u on. erase first..\n", 
365                        IS_CARD_MMI() ? "card" : "host", DLG_NB());
366
367                PODIF_APPUI_HostCloseDialog(DLG_NB());
368                //APP_POD_CloseDialog();
369                CLEAR_DLG();
370        }
371       
372        pr = PODIF_APPUI_HostOpenDialog(url, &dialogNb);
373        if (pr == PODRESULT_OK) 
374        {
375                SET_HOST_DLG(dialogNb);
376                //HTML_PrintWaitingScreen();  // waiting message¸¦ Ç¥½Ã.
377        }
378        else
379                dprint(0, "!! open dlg err %d\n", pr);
380}
381
382
383/*
384        host dialogµç, card dialogµç, È­¸é¿¡ ÀÖ´Â dialog¸¦ close ÇÑ´Ù.
385*/
386void APP_POD_CloseDialog(void)
387{
388        if (IS_CARD_MMI() || IS_HOST_DLG()) {
389                // È­¸é¿¡¼­ »èÁ¦.
390                dprint(2, "close %s dlg #%u\n", IS_CARD_MMI() ? "card" : "host", DLG_NB());
391                //PODIF_APPUI_HostCloseDialog(DLG_NB());
392               
393                ClearScreen(0, TRUE);
394                CLEAR_DLG();
395        }
396        else {
397                dprint(0, "!! try closing non-existing dlg..\n");
398        }
399}
400
401
402/******************************************************************************************
403FUNCTION:
404  - ReceiveCardMmi
405
406Purpose:
407  - return card mmi dialog
408******************************************************************************************/
409unsigned char* ReceiveCardMmi(unsigned char *pData)
410{
411#if 0
412        return pData;
413         // URLReceivedCb±îÁö´Â °ªÀÌ Àß Àü´ÞµÇ³ª, App_Proc_Html_MMI_Card¿¡¼­ garbage°ª º¸ÀÓ.
414       
415#else
416        int len;
417        unsigned char *str, *ptr;
418       
419        len = strlen(pData); // pData length
420       
421        // create str memory. (len+1Àº ¸¶Áö¸· char¿¡ null°ª Æ÷ÇÔ)
422        str = (unsigned char *)OS_Malloc(len+1);
423       
424        // copy pData to str
425        ptr = memcpy(str, pData, len);
426       
427        // search null char location. and then inserte null char.
428        ptr = ptr+len;
429        *ptr = '\0';
430       
431        dprint(3, "%s [1]/////\n %s\n", __FUNCTION__, str);
432       
433        return (str);
434#endif // #if 0
435}
436
437
438/*
439        PrintApInfo ¸¦ ÀÌ¿ëÇÏ¿© card menu urlÀ» Á¶È¸ÇÑ ÈÄ¿¡
440        ÀÌ ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© htmlÀ» °¡Á®¿Ã ¼ö ÀÖ´Ù.
441        °³¹ß¿ë CoreCross, Evolution Conax CAS Ä«µåÀÇ ¿¹:
442  (0) 0 0000, Conax Conditional Access, CableCARD:///CA.html
443  (1) 1 0000, Host/CableCARD Binding, CableCARD:///CpMsg.html
444  (2) 3 0000, SCTE55-2 Network, CableCARD:///OOB.html
445  (3) 8 0000, Network Interface, CableCARD:///NetIF.html
446  (4) 5 0000, Copy Protection, CableCARD:///BuildCopyProtMenu.html
447  (5) 6 0000, Host Diagnostics, CableCARD:///GenDiag.html
448  (6) 7 0000, CableCARD Diagnostics, CableCARD:///CCDiag.html
449*/
450void TestPodDialog(char *url)
451{
452        DHL_RESULT dhr;
453        UINT8 dlgnum;
454        dhr = PODIF_APPUI_HostOpenDialog(url, &dlgnum);
455
456        if (!dhr) {
457                printf("assigned dialog num: %d\n", dlgnum);
458        }
459        else {
460                printf("!! opendlg err %d\n", dhr);
461        }
462}
463
464
465
466
467
468#if COMMENT
469________(){}
470#endif
471
472void SourceIdToFreqCb(UINT16 sourceId, UINT32 *freqHz, tDHL_Demod *mod)
473{
474        // todo..
475        dprint(0, "!! not yet impl..\n");
476        DHL_ASSERT(0, "");
477
478        if (sourceId == 0) // or invalid
479                *freqHz = 0;
480        else { 
481                *freqHz = 567000000;
482                *mod = eDHL_DEMOD_256QAM;
483        }
484}
485
486
487podResult InbandTuneCb(UINT32 freqHz, tDHL_Demod mod, UINT8 *ltsid)
488{
489        DHL_RESULT dhr;
490        tDHL_TunerID tuner_id = 0;
491        tDHL_Demod demod;
492
493
494        dhr = DHL_FE_Start(tuner_id, freqHz/1000, mod);
495        if (dhr) {
496                dprint(0, "DHL_FE_Start failed %d\n", dhr);
497                return PODRESULT_FAILED;
498        }
499
500        UINT32 tickStart = OS_GetTickCount();
501        BOOL bLock;
502        while ((OS_GetTickCount() - tickStart) < OS_GetTicksPerSecond()*5) {
503                dhr = DHL_FE_GetLockStatus(tuner_id, &bLock, &demod);
504                if (dhr == DHL_OK && bLock) {
505                        dprint(2, "ibtune success\n");
506                        return PODRESULT_OK;
507                }
508        }
509        dprint(2, "!! ibtune timeout err\n");
510
511        // signal lock ¿©ºÎ°¡ ¾Æ´Ï¶ó pll lock ¿©ºÎ¶ó¸é Ç×»ó accepted º¸³»¸é µÈ´Ù.
512        return PODRESULT_OK;
513}
514
515
516
517
518
519#if COMMENT
520________(){}
521#endif
522
523static SysTimeContext g_PodStc = 
524{
525        0, /* BOOL bTimebaseAdjusted  */
526        //946357200, /* 2010/1/1 0:0:0 EST */
527        938358000, /* 2009/10/1 0:0:0 KST */
528        -5, /* int nTimeZone; */
529        0, /* BOOL bDaylightSavingOn; */        /* 1:day light saving , 0: no day light saving  */
530        13, /* int GPS_UTC_offset; */   
531        0, 0
532};
533
534
535void GetSysTimeCb(UINT32 *sysUtcTime, UINT8 *gps2UtcOffset)
536{
537        DMW_GetUTCTime(&g_PodStc, sysUtcTime);
538        *gps2UtcOffset = (UINT8)DMW_GetGPS_UTC_offset(&g_PodStc);
539
540        STime_t s;
541        DMW_GetLocalTime(&g_PodStc, &s);
542        //dprint(2, "time: %u %d/%d/%d %d:%d:%d\n", *sysUtcTime, s.year, s.month, s.day, s.hour, s.min, s.sec);
543}
544
545
546
547
548
549#if COMMENT
550________(){}
551#endif
552
553#define MAX_CP_PROGRAMS         7
554#define TS_CA_DESCRIPTOR         0x09
555
556typedef struct {
557        UINT16 index;
558        UINT8 ltsid;
559        UINT16 programNum;
560        UINT16 ca_pid;
561} CP_PROGRAM_INFO; 
562
563CP_PROGRAM_INFO gCpProgInfo[MAX_CP_PROGRAMS];
564UINT8 gCpProgNum=0;
565
566/* arzhna, 100407
567   pmt¸¦ ÀúÀåÇß´Ù°¡ Card¸¦ »°´Ù ²È¾ÒÀ»¶§, ´Ù½Ã ca pmt¸¦ Àü´ÞÇØÁÖ¾î¾ßÇÑ´Ù.
568   ¹Ì¸® ca pmt¿ë pmt sectionÀ» ÀúÀåÇØ µÎ¾ú´Ù°¡ Àü´ÞÇÑ´Ù.
569*/
570
571typedef struct {
572        UINT8 *pmtSection;
573        UINT32 pmtSectionLength;
574} CA_PMT_INFO;
575
576CA_PMT_INFO g_ca_pmt;
577
578DHL_OS_SEMA_ID app_podSema4;
579
580
581CA_PMT_INFO *App_LockPmtMutex()
582{
583        DHL_OS_TakeSemaphore(app_podSema4, DHL_TIMEOUT_FOREVER);
584        return &g_ca_pmt;
585}
586
587void App_UnlockPmtMutex(void)
588{
589        DHL_OS_GiveSemaphore(app_podSema4);
590}
591
592void p_set_pod_ca_pmt(CA_PMT_INFO *pPmt)
593{
594        // arzhna, 100412
595        // pmt¸¦ ÀúÀåÇÏ´Â ¹æ¹ý¿¡¼­ flattenµÈ pmt sectionÀ» ÀúÀåÇÑ´Ù.
596        CA_PMT_INFO *ca_pmt = App_LockPmtMutex();
597
598        ca_pmt->pmtSection = pPmt->pmtSection;
599        ca_pmt->pmtSectionLength = pPmt->pmtSectionLength;
600       
601        dprint(2, "%d pmtSection = 0x%x, pmtSectionLength=%d\n",__LINE__, ca_pmt->pmtSection, ca_pmt->pmtSectionLength);
602
603        App_UnlockPmtMutex();
604}
605
606
607/*
608        ÀÌ ÇÔ¼ö´Â ¼ø¼öÇÏ°Ô cardÀÇ in/out ¿©ºÎ¸¸À» ¾Ë·ÁÁØ´Ù.
609        op state Á¤º¸°¡ ÇÊ¿äÇÏ¸é ´Ù¸¥ API¸¦ »ç¿ë ÇÒ °Í.
610*/
611BOOL APP_POD_IsPodInserted(void)
612{
613        return (App_Op_IsCardMode());
614}
615
616
617// arzhna, 100218,
618// descriptor¿¡¼­ CA PID¸¦ ÃßÃâÇÏ´Â ÇÔ¼ö
619void APP_ParseCAPid(MPEG_PMT* pPmt)
620{
621        ErrCode err;
622        int i;
623        UINT8 *ca_descriptor;
624
625        dprint(0,"numStream=%d\n",pPmt->numStreams);
626
627        // ¸ÕÀú stream levelÀÇ descriptor¿¡¼­ ca pid¸¦ ÃßÃâÇÑ´Ù.
628        // ¸¸¾à ¾øÀ¸¸é program levelÀÇ descriptor¿¡¼­ ÃßÃâÇÑ´Ù.
629        for(i=0;i<pPmt->numStreams;i++){
630                err = GetMpegDescriptor(pPmt->streams[i].descriptors, pPmt->streams[i].descriptor_length, TS_CA_DESCRIPTOR, 0, &ca_descriptor);
631                if(err){
632                        err = GetMpegDescriptor(pPmt->descriptors, pPmt->descriptor_length, TS_CA_DESCRIPTOR, 0, &ca_descriptor);
633                        if(err)
634                                ca_descriptor = NULL;
635                }
636
637                if(ca_descriptor!=NULL)
638                        gCpProgInfo[gCpProgNum].ca_pid = ((ca_descriptor[4] & 0x1F) << 8) + ca_descriptor[5];
639                else
640                        gCpProgInfo[gCpProgNum].ca_pid = 0;
641               
642
643                gCpProgInfo[gCpProgNum].index = gCpProgNum;
644                gCpProgInfo[gCpProgNum].programNum = pPmt->program_number;
645                gCpProgInfo[gCpProgNum].ltsid = 0;      // UDCP¿¡¼­´Â ÇϳªÀÇ ÇÁ·Î±×·¥¸¸ ó¸®ÇϹǷΠltsid´Â Ç×»ó 0
646                gCpProgNum++;
647        }
648}
649
650
651// arzhna, 100129
652// PMT Change°¡ ¹ß»ýÇÒ °æ¿ì Callback¿¡ ÀÇÇØ È£ÃâµÇ´Â ÇÔ¼ö
653// APP_Fnc_ChTune.cÀÇ callback ó¸®ÇÔ¼ö¿¡ ÀÇÇØ È£ÃâµÈ´Ù.
654void APP_POD_NotifyPmtChange(MPEG_PMT *pPmt)
655{
656        DHL_RESULT result;
657        CA_PMT_INFO *ca_pmt = App_LockPmtMutex();
658        int i;
659
660        dprint(1, "PODIF_CA_PMTChange(pmt 0x%x)\n", pPmt);
661
662        if (pPmt == NULL) {
663                // pPmt°¡ NULLÀÎ °æ¿ì´Â ca descrambling°ú´Â »ó°ü ¾ø´Â ¼­ºñ½ºÀÎ °æ¿ìÀÌ´Ù. (¿¹: ¾Æ³¯·Î±× ä³Î)
664                //
665                // Á¦´ë·Î ÇÏ·Á¸é ca_pmt_cmd_id 4 (not_selected) ¸í·ÉÀ¸·Î ca_pmt¸¦ º¸³»¼­ CA ¸®¼Ò½º¸¦ free ½Ã۸é ÁÁÀºµ¥,
666                // ±×³É ³öµÖµµ ¹«¹æÇÏ´Ù.
667                //
668                goto notifyExit;
669        }
670       
671        // arzhna, 100218
672        // CP¸¦ À§ÇÑ DES Key¸¦ ¸¸µé±â À§Çؼ­´Â CA PID°¡ ÇÊ¿äÇÏ´Ù.
673        // MPEG PMT ³»ÀÇ descriptor ´Â CA PID¸¦ Æ÷ÇÔÇÑ´Ù. 
674        //
675        // arzhna, 100526
676        // CA PID °¹¼ö°¡ MAX_CP_PROGRAMS °¹¼öº¸´Ù ¸¹À» °æ¿ì ÃʰúµÇ´Â CA PID´Â ¹ö¸°´Ù.
677        if(gCpProgNum>0)
678        {
679                for(i=0;i<gCpProgNum;i++){
680                        if(i>=MAX_CP_PROGRAMS){
681                                dprint(0, "total cp programs is too many(%d), (%d) program is skipped.\n", gCpProgNum, i);
682                                continue;
683                        }
684                        PODIF_CP_RemoveProgram(i);
685                }
686                gCpProgNum=0;
687        }
688               
689        APP_ParseCAPid(pPmt);
690        dprint(0, "gCpProgNum=%d\n",gCpProgNum);
691       
692        for(i=0;i<gCpProgNum;i++){
693                if(i>=MAX_CP_PROGRAMS){
694                        dprint(0, "total cp programs is too many(%d), (%d) program is skipped.\n", gCpProgNum, i);
695                        continue;
696                }
697                PODIF_CP_AddProgram(gCpProgInfo[i].index, gCpProgInfo[i].programNum, gCpProgInfo[i].ca_pid, gCpProgInfo[i].ltsid);
698        }
699
700        // FlattenPMT¿¡¼­ »õ·Î memory allocÀ» ÇϹǷΠ±âÁ¸¿¡ ÀúÀåµÈ pmt sectionÀÌ Á¸ÀçÇϸé freeÇØÁÖ¾î¾ß ÇÑ´Ù.
701        if( ca_pmt->pmtSection != NULL ){
702                dprint(2, "free previous pmt section\n");
703                dprint(2, "%d pmtSection = 0x%x, pmtSectionLength=%d\n",__LINE__,ca_pmt->pmtSection, ca_pmt->pmtSectionLength);
704                OS_Free((void *)&(ca_pmt->pmtSection));
705        }
706
707        // ÀÎÀÚ·Î ¹ÞÀº pmt´Â pasrsed pmt À̹ǷΠraw pmt·Î convert ÇØ¾ß ÇÑ´Ù.
708        // driverÀÇ ca pmt »ý¼º ºÎºÐ¿¡¼­ raw pmt°¡ ¾Æ´Â parsed pmt·Î ¸¸µéµµ·Ï ¼öÁ¤ÇÏ´Â °ÍÀÌ ÁÁÀ¸³ª
709        // ÀÏ´Ü ¿©±â¼­ raw pmt·Î ¸¸µé¾î Àü´ÞÇϵµ·Ï ÇÑ´Ù.
710        result = FlattenPMT((const MPEG_PMT*)pPmt, &(ca_pmt->pmtSectionLength), &(ca_pmt->pmtSection));
711        if(result){
712                dprint(0, "FlattenPMT error!!!\n");
713                goto notifyExit;
714        }
715       
716        // ÇöÀç pmt sectionÀ» ÀúÀåÇÑ´Ù.
717        dprint(2, "%d pmtSection = 0x%x, pmtSectionLength=%d\n",__LINE__,ca_pmt->pmtSection, ca_pmt->pmtSectionLength);
718        p_set_pod_ca_pmt(ca_pmt);
719
720        // card°¡ ÀåÂøµÇ¸é Àü´ÞÇÑ´Ù.
721        if(APP_POD_IsPodInserted()){
722        // PODIF_CA_PMTChange()ÀÇ ÀÎÀÚÁß int nSize, unsigned short *pusPidList, int nNbPidÀº »ç¿ëÇÏÁö ¾Ê´Â´Ù.   
723                result = PODIF_CA_PMTChange(CA_PMT_CMD_OK_DESCRAMBLING, ca_pmt->pmtSection, ca_pmt->pmtSectionLength, NULL, 0);
724               
725                if(result){
726                        dprint(0, "PODIF_CA_PMTChange error!!!\n");
727                }
728        }
729
730notifyExit:                     
731        App_UnlockPmtMutex();
732}
733
734
735// 100217, ARZHNA
736// Card°¡ Inserted µÇ¸é TS Route¸¦ Card·Î º¯°æÇØÁÖ±â À§ÇÑ ÇÔ¼ö
737// bRouteEnable ÀÌ 1À̸é Card·Î ts route°¡ º¯°æµÈ´Ù.
738void APP_POD_SetTsRoute(BOOL bRouteEnable)
739{
740        tDHL_TSD *tsd;
741
742        dprint(2,"TS Route to card %s\n", bRouteEnable ? "enabled" : "disabled");
743        tsd = DHL_DMX_GetTsd();
744        DHL_DMX_RouteTS(tsd, bRouteEnable);
745}
746
747
748// 100406, ARZHNA
749// ÀÌ callbackÀÌ È£ÃâµÇ¸é ca pmt¸¦ notify ÇØÁØ´Ù.
750void NotifyCAInitCb(void)
751{       
752        int result=0;
753        CA_PMT_INFO *ca_pmt = App_LockPmtMutex();
754        dprint(2, "%d pmtSection = 0x%x, pmtSectionLength=%d\n",__LINE__,ca_pmt->pmtSection, ca_pmt->pmtSectionLength);
755       
756        if(ca_pmt->pmtSection!=NULL){
757                // PODIF_CA_PMTChange()ÀÇ ÀÎÀÚÁß int nSize, unsigned short *pusPidList, int nNbPidÀº »ç¿ëÇÏÁö ¾Ê´Â´Ù.   
758                result = PODIF_CA_PMTChange(CA_PMT_CMD_OK_DESCRAMBLING, ca_pmt->pmtSection, ca_pmt->pmtSectionLength, NULL, 0);
759       
760                if(result){
761                        dprint(0, "PODIF_CA_PMTChange error!!!\n");
762                }
763        }else{
764                dprint(0,"### Saved ca pmt is null\n");
765        }
766        App_UnlockPmtMutex();
767}
768
769
770
771
772
773#if COMMENT
774________(){}
775#endif
776
777/*
778        oob si ¿¡ ÀÇÇÑ channel db update count.
779        ÀÌ °ªÀÌ 0º¸´Ù Å©¸é ÇöÀç ¸¸µé¾îÁø ä³Î DB´Â OOB DB¶ó°í º¼ ¼ö ÀÖ´Ù.
780*/
781UINT32 s_si_cdb_update_count;
782
783UINT32 APP_ScteSiChListUpdateCount()
784{
785        return s_si_cdb_update_count;
786}
787
788
789/*
790        ä³Î ¸ÊÀ» »ý¼ºÇÑ´Ù.
791        ¿©·¯°¡Áö ÀÌÀ¯·Î ÀÌ ÇÔ¼ö´Â menu task¿¡¼­ ¼öÇàµÇ¾î¾ß¸¸ ÇÑ´Ù.
792
793        Á÷Á¢ È£ÃâÇÏ´Â ´ë½Å ¸Þ½ÃÁö 󸮷Π¼öÇàÇÒ °Í.
794                DMG_SetUserDefined(UD_ID_SI_PROCESS, UD_PARAM_SI_PROC_CHLIST, 0);
795*/
796void APP_ScteSiUpdateChList(void)
797{
798        static UINT32 tick_last_updated;
799
800        // ³Ê¹« ºó¹øÈ÷ ÀÚÁÖ update µÇÁö ¾Êµµ·Ï °£°Ý À¯Áö.
801        if (s_si_cdb_update_count == 0 ||
802                (OS_GetTickCount() - tick_last_updated)/OS_GetTicksPerSecond() >= 2)
803        {
804                dprint(2, "\n update channel list..\n");
805                DMW_SCTESI_ChListUpdate(0);
806                s_si_cdb_update_count++;
807                tick_last_updated = OS_GetTickCount();
808               
809                DMW_CDB_PrintUcm(0);
810               
811                // ÇöÀç »óŰ¡ OOB Waiting or OOB ActiveÀ̰í, OOB DB°¡ 0 ÀÌ»óÀÏ ¶§
812                //if(App_Op_GetOperationState()==eUDCP_OP_OOB_WAITING && App_Ucm_GetTotalUcmCount()>0)
813                if(App_Op_IsOobMode() && s_si_cdb_update_count>0)
814                        DMG_SetUserDefined(UD_ID_OP_STATE, UD_PARAM_OP_OOB_ACTIVE, 0);
815        }
816        else {
817                dprint(2, " skip update this time..\n");
818        }
819}
820
821
822/*
823        ScteSiScan MW¿¡ µî·ÏµÈ event callback. ´ç¿¬È÷ È£ÃâµÇ´Â task´Â scte si taskÀÌ´Ù.
824        Å×À̺íÀÌ ¼ö½ÅµÇ¸é callback µÈ´Ù.
825
826        ½ÇÁ¦ »óȲ¿¡¼­ ÁÁÀº ¹æ¹ý:
827        update °£°ÝÀ» µÎµÇ,     2ºÐÀÌ Áö³ªµµ udpate °¡ ¾ÈµÇ¸é °­Á¦ update.
828*/
829STATUS APP_ScteSiEventProc(DmcSiEventType evt, UINT32 param1, UINT32 param2)
830{
831        if (evt == siEvent_TableUpdated)
832        {
833                SI_table_type_k tt = (SI_table_type_k) param1;
834                DmcSiTableReceivedCbParam *cpb = (DmcSiTableReceivedCbParam *) param2;
835                char buf[100];
836               
837                dprint(0, "======== table updated (%s) ==========\n", SCTESI_MgtTableTypeString(tt, buf, 0));
838
839                DmcSiScanStatus stat;
840                Dmc_ScteSiGetStatus(&stat);
841               
842                // ÇöÀç state°¡ Card InbandÀ̰í, raw sectionÀÌ 1°³ ÀÌ»óÀÏ ¶§
843                //if(App_Op_GetOperationState()==eUDCP_OP_CARD_INB && stat.raw_section_count>0) {
844                if(App_Op_GetOperationState()!=eUDCP_OP_CABLE_INB && stat.raw_section_count>0) {
845                        DMG_SetUserDefined(UD_ID_OP_STATE, UD_PARAM_OP_OOB_WAITING, 0);
846                }
847       
848                if (cpb->table_type == tt_SiSTT)
849                {
850                        // cpb->u.stt_info.stt ¿Í °°Àº paramÀ» ÀÌ¿ëÇÏ¿© time sync.
851                        /*
852                                App_SetTimeBySTT();
853
854                                À§¿Í °°ÀÌ Á÷Á¢ Sync API¸¦ È£ÃâÇÏ¸é µÎ°¡Áö ¹®Á¦°¡ ÀÖÀ» ¼ö ÀÖ´Ù.
855                                1. ÀÌ ½ÃÁ¡¿¡¼­ OP_STATE°¡ OOB ¸ðµå·Î Àüȯ µÈ »óÅÂÀΰ¡?
856                                        ÃÖÃÊ·Î ¼ö½ÅµÇ´Â tableÀÇ °æ¿ì op state Àüȯ º¸´Ù ¸ÕÀú ó¸® µÉ ¼ö ÀÖ´Ù.
857                                        --> op state ÀüȯÀº ¾Æ·¡¿¡¼­ 󸮵ǹǷÎ, ¾È µÉ °ÍÀÓ..
858                                       
859                                2. stt´Â MWÀÇ context¿¡ ÀúÀå µÈ »óÅÂÀΰ¡?
860                                        ÀÌ callback¿¡¼­ Àü´Þ ¹ÞÀº table Á¤º¸(stt_info.flat_stt)¸¦ Ȱ¿ëÇÏÁö ¾Ê°í,
861                                        App_SetTimeBySTT()¿¡¼­´Â Á÷Á¢ MW¿¡ query API¸¦ È£ÃâÇÏ¿© »ç¿ëÇϹǷÎ,
862                                        query API¿¡ Á¦´ë·Î µÈ ÀÀ´äÀÌ ¸®Å쵃 ¼ö ÀÖ´Â »óÅÂÀ̾î¾ß ÇÑ´Ù.
863
864                                --> stt sync ¿ª½Ã menu task·Î À̵¿½ÃŲ´Ù.
865                        */
866                        DMG_SetUserDefined(UD_ID_SI_PROCESS, UD_PARAM_SI_PROC_STT, 0);
867                }
868                if(cpb->channel_data_ready && cpb->channel_need_rebuild)
869                {
870                        dprint(0, "trigger update chlist..\n");
871                        DMG_SetUserDefined(UD_ID_SI_PROCESS, UD_PARAM_SI_PROC_CHLIST, 0);
872                }
873        }
874       
875        return statusOK;
876}
877
878
879void APP_ScteSiStart(void)
880{
881        // ½ÇÁ¦·Î´Â Application levelÀÇ user procÀÌ µÇ¾î¾ß ÇÔ.
882        Dmc_ScteSiRegisterEventCallback(APP_ScteSiEventProc);
883       
884        // run time (cable card inserted)
885        // ½ÇÁ¦·Î´Â CableCard°¡ ÀåÂø µÇ°í, Extended channel ÀνÄÀÌ ¿Ï·á µÈ ÈÄ¿¡ ½ÇÇà.
886        Dmc_ScteSiStartMonitor();
887
888        // OOB DB°¡ ´õ ÀÌ»ó À¯È¿ÇÏÁö ¾Ê´Ù´Â flag¸¦ ¼³Á¤..
889        s_si_cdb_update_count = 0;
890}
891
892
893void APP_ScteSiStop(void)
894{
895        Dmc_ScteSiStopMonitor();
896       
897        Dmc_ScteSiDeleteAllTables();
898
899        // OOB DB°¡ ´õ ÀÌ»ó À¯È¿ÇÏÁö ¾Ê´Ù´Â flag¸¦ ¼³Á¤..
900        s_si_cdb_update_count = 0;
901}
902
903
904
905
906
907#if COMMENT
908________(){}
909#endif
910
911PODIF_CTRL_CALLBACK s_podcallback_ctrl = 
912{
913        CardInsertedCb,
914};
915
916PODIF_APPUI_CALLBACK s_podcallback_appui = 
917{
918        .ApplicationRegisterCb = ApplicationRegisterCb,
919        .URLReceivedCb = URLReceivedCb,
920        .URLReportErrorCb = URLReportErrorCb,
921        .PrepareDialogCb = PrepareDialogCb,
922        .CloseDialogCb = CloseDialogCb,
923};
924
925PODIF_EXTCH_CALLBACK s_podcallback_extch = 
926{
927        DMW_SCTESI_FlowReplyEventCb,
928        DMW_SCTESI_FlowLostEventCb,
929        DMW_SCTESI_BaseMpegSectionEventCb,
930        DMW_SCTESI_FlowDataEventCb,
931};
932
933PODIF_HC_CALLBACK s_podcallback_hc = 
934{
935        SourceIdToFreqCb,
936        InbandTuneCb,
937        NotifyCAInitCb,
938};
939
940PODIF_SYSTIME_CALLBACK s_podcallback_systime = 
941{
942        GetSysTimeCb,
943};
944
945
946void APP_POD_Start(void)
947{
948        DHL_RESULT dhr;
949       
950        PODIF_CALLBACK podcallback = {
951                .ctrl  = s_podcallback_ctrl,
952                .appui = s_podcallback_appui,
953                .hc    = s_podcallback_hc,
954                .extch = s_podcallback_extch,
955                .systime = s_podcallback_systime,
956        };
957
958        dhr = PODIF_Init();
959        if (dhr) {
960                return;
961        }
962
963        PODIF_Start(&podcallback);
964}
965
966
967void APP_POD_Stop(void)
968{
969        PODIF_Shutdown();
970}
971
972
973void APP_POD_Init(void)
974{
975        CA_PMT_INFO *ca_pmt;
976       
977        dprint(1, "%s\n", __FUNCTION__);
978        DHL_FE_Open(FE_FDC_TUNER_ID);
979
980        if (1) {
981                DHL_DESCRAMBLE_SETTINGS dsc_settings;
982                dsc_settings.mode = eDHL_DSC_MODE_3DES_ECB;
983                DHL_DSC_Init(&dsc_settings);
984        }
985
986        Dmc_ScteSiScanInit();
987
988        DMW_SCTESI_ChListInit();
989
990        DHL_DBG_RegisterVarSymbol(DHL_VAR_SYM_ARGS(gDelayBetweenSiFeedingMs));
991
992        HTML_IsOnScreen(); // ±×³É link¸¦ À§Çؼ­..
993
994        app_podSema4 = DHL_OS_CreateMutexSemaphore("AppPod");
995        if (app_podSema4 == 0) {
996                dprint(0, "!! create av sema4 failed");
997        }
998
999        ca_pmt = App_LockPmtMutex();
1000        ca_pmt->pmtSection = NULL;
1001        ca_pmt->pmtSectionLength = 0;
1002               
1003        App_UnlockPmtMutex();
1004}
1005
1006
1007void PodTest_SetCpKey(BOOL bOn, BOOL bParityForceAdjust)
1008{
1009        unsigned char VidEvenControlWord[] = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x02,0x03,0x04,0x05,0x06,0x07,0x00,0x01 };
1010        unsigned char VidOddControlWord[]  = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x02,0x03,0x04,0x05,0x06,0x07,0x00,0x01 };
1011        //unsigned char AudEvenControlWord[] = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x02,0x03,0x04,0x05,0x06,0x07,0x00,0x01 };
1012        //unsigned char AudOddControlWord[]  = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x02,0x03,0x04,0x05,0x06,0x07,0x00,0x01 };
1013
1014        // odd parity Ãß°¡ÇÑ key..
1015        unsigned char VidEvenControlWord2[] = { 0x80,0x01,0x02,0x83,0x04,0x85,0x86,0x07, 0x02,0x83,0x04,0x85,0x86,0x07,0x80,0x01 };
1016        unsigned char VidOddControlWord2[]  = { 0x80,0x01,0x02,0x83,0x04,0x85,0x86,0x07, 0x02,0x83,0x04,0x85,0x86,0x07,0x80,0x01 };
1017
1018        DHL_DESCRAMBLE_KEY key;
1019
1020        if (bParityForceAdjust) {
1021                printf("adjust control word parity\n");
1022                key.evenKeyData = VidEvenControlWord2;
1023                key.oddKeyData = VidOddControlWord2;
1024                key.oddKeySize = key.evenKeySize = sizeof(VidEvenControlWord2);
1025        }
1026        else {
1027                key.evenKeyData = VidEvenControlWord;
1028                key.oddKeyData = VidOddControlWord;
1029                key.oddKeySize = key.evenKeySize = sizeof(VidEvenControlWord);
1030        }
1031       
1032        DHL_RESULT dhr;
1033
1034        if (bOn) 
1035        {
1036                dhr = DHL_DSC_SetKey(&key);
1037                if (dhr) {
1038                        dprint(0, "!!!! set cpkey err %d\n", dhr);
1039                }
1040        }
1041        else
1042        {
1043                DHL_DSC_UnsetKey();
1044        }
1045}
1046
1047#endif /* SUPPORT_POD */
1048
1049
1050
1051/* end of file */
Note: See TracBrowser for help on using the repository browser.