source: svn/newcon3bcm2_21bu/dst/app/src/Function/App_Fnc_Ucm.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: 21.4 KB
Line 
1/****************************************************************************
2* NAME: App_Fnc_Ucm.c
3*----------------------------------------------------------------------------
4* Copyright (c) DIGITAL STREAM Technology Inc.
5*----------------------------------------------------------------------------
6* CREATED_BY: Yong Dae Park
7* CREATION_DATE: 2009/09/08
8* $Author: x2silo $
9* $Revision: 1.1 $
10* $Date: 2009/07/08 15:08:26 $
11*----------------------------------------------------------------------------
12* PURPOSE:
13*       -
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 "App_Fnc_Ucm.h"
22
23#include "App_Fnc_ChTune.h"
24
25
26
27
28
29/*_____ D E F I N I T I O N ____________________________________*/
30
31#if COMMENT
32_____DbgPrint_____(){}
33#endif
34
35DHL_MODULE("@f_ucm", 0);
36
37
38
39
40
41#if COMMENT
42____Config____(){}
43#endif
44
45#define APP_REGISTER_DEBUG_SYMBOL 0
46
47
48
49
50
51#if COMMENT
52____Types____(){}
53#endif
54
55
56
57
58
59#if COMMENT
60____Variables____(){}
61#endif
62
63static DST_CURCHANNEL p_cur_channel, temp_cur_channel;
64static DHL_OS_SEMA_ID p_ch_info_mutex;
65
66
67/*_____ F U N C T I O N ________________________________________*/
68
69#if COMMENT
70____Function____(){}
71#endif
72
73STATUS App_GetUcmShortInfo(int uid, tApp_UcmShortInfo *pinfo)
74{
75        int index;
76       
77        DMW_MSC_LockUcm();
78       
79        index=DMW_MSC_Uid2Index(uid);
80       
81        if(index==-1) {
82                DMW_MSC_UnlockUcm();
83                return statusError;
84        }
85       
86        if(pinfo) {
87                pinfo->uid=uid;
88          pinfo->major=g_UCM[index].Major;
89          pinfo->minor=g_UCM[index].Minor;
90          pinfo->rf=g_UCM[index].RF;
91         
92          pinfo->source_id=g_UCM[index].source_id;
93          pinfo->prog_number=g_UCM[index].Prog_number;
94          memcpy(pinfo->short_name, g_UCM[index].ShortName, 7*sizeof(UINT16));
95          pinfo->short_name[7]='\0';
96         
97          pinfo->pcr_pid=g_UCM[index].Pcr_pid;
98          pinfo->vid_pid=g_UCM[index].Video_pid;
99          pinfo->aud_pid=g_UCM[index].Audio_pid;
100         
101          pinfo->vid_type=g_UCM[index].Video_type;
102          pinfo->aud_type=g_UCM[index].Audio_type;
103         
104          pinfo->video_format=g_UCM[index].video_format;
105         
106          pinfo->bFav    = g_UCM[index].SurfIndex>0?TRUE:FALSE;
107                 
108          pinfo->vct_flag=g_UCM[index].VctFlag;
109        }
110       
111        DMW_MSC_UnlockUcm();
112       
113        return statusOK;
114}
115
116
117STATUS App_GetUcmInfo(int uid, tApp_UcmItem item, UINT32 *ret)
118{
119        int index;
120       
121        DMW_MSC_LockUcm();
122       
123        index=DMW_MSC_Uid2Index(uid);
124       
125        if(index==-1) {
126                DMW_MSC_UnlockUcm();
127                return statusError;
128        }
129       
130        switch(item) 
131        {
132                case eAPP_UCM_MAJOR: *ret=(UINT32)g_UCM[index].Major; break;
133                case eAPP_UCM_MINOR: *ret=(UINT32)g_UCM[index].Minor; break;
134                case eAPP_UCM_RF: *ret=(UINT32)g_UCM[index].RF; break;
135                case eAPP_UCM_VCT_FLAG: *ret=(UINT32)g_UCM[index].VctFlag; break;
136                case eAPP_UCM_PROG_NUMBER: *ret=(UINT32)g_UCM[index].Prog_number; break;
137                case eAPP_UCM_SERVICE_TYPE: *ret=(UINT32)g_UCM[index].Service_type; break;
138                case eAPP_UCM_SKIPPED: *ret=(UINT32)g_UCM[index].Skipped; break;
139                case eAPP_UCM_SURF_INDEX: *ret=(UINT32)g_UCM[index].SurfIndex; break;
140                case eAPP_UCM_SHORT_NAME: *ret=(UINT32)g_UCM[index].ShortName; break;
141                case eAPP_UCM_FREQ_OFFSET: *ret=(UINT32)g_UCM[index].freqOffset; break;
142                case eAPP_UCM_SOURCE_ID: *ret=(UINT32)g_UCM[index].source_id; break;
143                case eAPP_UCM_UID: *ret=(UINT32)g_UCM[index].Uid; break;
144                case eAPP_UCM_P_EPG_DB: *ret=(UINT32)g_UCM[index].pEpgDB; break;
145                case eAPP_UCM_PCR_PID: *ret=(UINT32)g_UCM[index].Pcr_pid; break;
146                case eAPP_UCM_VID_PID: *ret=(UINT32)g_UCM[index].Video_pid; break;
147                case eAPP_UCM_AUD_PID: *ret=(UINT32)g_UCM[index].Audio_pid; break;
148                case eAPP_UCM_AUD_TYPE: *ret=(UINT32)g_UCM[index].Audio_type; break;
149                case eAPP_UCM_PMT_PID: *ret=(UINT32)g_UCM[index].pmt_pid; break;
150                case eAPP_UCM_SIG_STR: *ret=(UINT32)g_UCM[index].signal_strength; break;
151                case eAPP_UCM_TSID: *ret=(UINT32)g_UCM[index].TSID; break;
152                case eAPP_UCM_CHANNEL_TSID: *ret=(UINT32)g_UCM[index].channel_tsid; break;
153                case eAPP_UCM_HIDDEN: *ret=(UINT32)g_UCM[index].hidden; break;
154                case eAPP_UCM_BLOCKED: *ret=(UINT32)g_UCM[index].blocked; break;
155                case eAPP_UCM_SCRAMBLED: *ret=(UINT32)g_UCM[index].scrambled; break;
156                case eAPP_UCM_FRESH: *ret=(UINT32)g_UCM[index].fresh; break;
157                case eAPP_UCM_NUM_CSD: *ret=(UINT32)g_UCM[index].num_csd; break;
158                case eAPP_UCM_MAX_CSD: *ret=(UINT32)g_UCM[index].max_csd; break;
159                case eAPP_UCM_P_CSD: *ret=(UINT32)g_UCM[index].csd; break;
160        }
161
162        DMW_MSC_UnlockUcm();
163       
164        return statusOK;
165}
166
167
168
169DST_CURCHANNEL *App_Ucm_GetCurChInfo(DST_CURCHANNEL* chinfo )
170{
171        if(!chinfo) {
172                chinfo=&p_cur_channel;
173                return &p_cur_channel;
174        }
175       
176        *chinfo=p_cur_channel;
177       
178        return chinfo;
179}
180
181
182void App_ChtuneSetChannelInfo_AudioPid(UINT16 audpid)
183{
184       
185        DHL_OS_TakeSemaphore(p_ch_info_mutex, DHL_TIMEOUT_FOREVER);
186       
187        p_cur_channel.uAudPid=audpid;
188       
189        DHL_OS_GiveSemaphore(p_ch_info_mutex);
190}
191
192
193void App_Ucm_SetChinfo_AddFav(int idx, BOOL bAdd, BOOL bFav)
194{
195        DMW_MSC_LockUcm();
196
197        if(bAdd)
198                g_UCM[idx].Skipped = 0;
199        else 
200                g_UCM[idx].Skipped = 1;
201               
202        if(bFav)
203                g_UCM[idx].SurfIndex = 1;
204        else 
205                g_UCM[idx].SurfIndex = 0;
206
207        DMW_MSC_UnlockUcm();
208}
209
210
211STATUS App_GetCurUcmShortInfo(tApp_UcmShortInfo *pinfo)
212{
213
214        return App_GetUcmShortInfo(p_cur_channel.nUid, pinfo);
215}
216
217
218BOOL App_Ucm_CheckHiddenCh(int index)
219{
220        return g_UCM[index].hidden;
221}
222
223BOOL App_Ucm_CheckDisabledCh(int index)
224{
225        return g_UCM[index].disabled;
226}
227
228STATUS App_Ucm_GetShortInfobyIndex(int index, tApp_UcmShortInfo *pinfo)
229{
230        if(pinfo == NULL)
231        {
232                dprint(0, "!! null pointer err \n");
233                return statusError;
234        }
235
236        if(index<0 || index>=g_UCM_number) {
237                dprint(0, "!! bad index err \n");
238                return statusError;
239        }
240       
241        DMW_MSC_LockUcm();
242       
243        pinfo->uid = g_UCM[index].Uid;
244        pinfo->major = g_UCM[index].Major;
245        pinfo->minor = g_UCM[index].Minor;
246        pinfo->rf = g_UCM[index].RF;
247        pinfo->source_id = g_UCM[index].source_id;
248        pinfo->prog_number = g_UCM[index].Prog_number;
249        memcpy(pinfo->short_name, g_UCM[index].ShortName, 7*sizeof(UINT16));
250        pinfo->pcr_pid = g_UCM[index].Pcr_pid;
251        pinfo->vid_pid = g_UCM[index].Video_pid;
252        pinfo->aud_pid = g_UCM[index].Audio_pid;
253
254        pinfo->service_type = g_UCM[index].Service_type;
255       
256        pinfo->bAdd      = g_UCM[index].Skipped == 0?TRUE:FALSE;
257        pinfo->bFav      = g_UCM[index].SurfIndex>0?TRUE:FALSE;
258        pinfo->bHidden=g_UCM[index].hidden?TRUE:FALSE;
259       
260        pinfo->vid_type=g_UCM[index].Video_type;
261        pinfo->aud_type=g_UCM[index].Audio_type;
262       
263        pinfo->vct_flag=g_UCM[index].VctFlag;
264       
265        pinfo->video_format=g_UCM[index].video_format;
266
267        DMW_MSC_UnlockUcm();
268        return statusOK;
269}
270
271
272int App_Ucm_GetTotalUcmCount(void)
273{
274        return g_UCM_number;
275}
276
277       
278int App_Ucm_GetNoHiddenUcmCount()
279{
280        int nTotalChCount = 0;
281        int i;
282       
283        DMW_MSC_LockUcm();
284
285        for(i=0;i<g_UCM_number;i++)
286        {
287       
288                if(g_UCM[i].hidden)     //hidden ä³ÎÀº À¯Àú¿¡°Ô ³ëÃâÇÒ ¼ö ¾ø´Ù.
289                        continue;
290       
291                nTotalChCount++;       
292        }
293       
294        DMW_MSC_UnlockUcm();
295
296        return nTotalChCount;
297}
298
299
300int App_Ucm_GetChNum(tApp_ChSelParam *pparam)
301{
302        int i, num_count=0;
303        tApp_ChSelParam def_param={FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE};
304       
305        if(!pparam) pparam=&def_param;
306       
307        DMW_MSC_LockUcm();
308       
309        for(i=0; i<g_UCM_number; i++) {
310                if(pparam->exc_hidden && g_UCM[i].hidden) continue;
311                if(pparam->exc_skip && g_UCM[i].Skipped) continue;
312                if(pparam->exc_disable && g_UCM[i].disabled) continue;
313                if(pparam->exc_audio && (g_UCM[i].Video_pid==0 && g_UCM[i].Audio_pid!=0)) continue;
314                if(pparam->exc_hd && g_UCM[i].video_format>=eDHL_DISP_1280x720p) continue;
315                if(pparam->exc_sd && 
316                        (g_UCM[i].video_format>=eDHL_DISP_720x480i
317                        && g_UCM[i].video_format<eDHL_DISP_1280x720p)) continue;
318                if(pparam->only_fav && g_UCM[i].SurfIndex<=0) continue;
319                       
320                num_count++;
321        }
322        DMW_MSC_UnlockUcm();
323       
324        return num_count;
325}
326
327
328int App_Ucm_GetNextChannel(int cur_uid, tApp_ChSelParam *pparam)
329{
330        int i, cur_idx;
331        tApp_ChSelParam def_param={TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE};
332       
333        if(!pparam) pparam=&def_param;
334       
335        DMW_MSC_LockUcm();
336       
337        //ÇöÀç ä³Î Á¤º¸..
338        cur_idx=DMW_MSC_Uid2Index(cur_uid);
339       
340        if(cur_idx<0) {
341                cur_idx=-1;
342        }
343       
344        for(i=cur_idx+1; i<g_UCM_number; i++)
345        {
346                if(pparam->exc_hidden && g_UCM[i].hidden) continue;
347                if((pparam->exc_skip && g_UCM[i].Skipped) && !(pparam->inc_cur_ch && g_UCM[i].Uid==p_cur_channel.nUid)) continue;
348                if(pparam->exc_disable && g_UCM[i].disabled) continue;
349                if(pparam->exc_audio && (g_UCM[i].Video_pid==0 && g_UCM[i].Audio_pid!=0)) continue;
350                if(pparam->exc_hd && g_UCM[i].video_format>=eDHL_DISP_1280x720p) continue;
351                if(pparam->exc_sd && 
352                        (g_UCM[i].Video_pid!=0
353                        && g_UCM[i].video_format<eDHL_DISP_1280x720p)) continue;
354                if(pparam->only_fav && g_UCM[i].SurfIndex<=0) continue;
355               
356                //¹ß°ßÇÔ.
357                DMW_MSC_UnlockUcm();
358               
359                return g_UCM[i].Uid;
360        }
361       
362        if(pparam->turn_around) 
363        {
364                for(i=0; i<cur_idx; i++)
365                {
366                        if(pparam->exc_hidden && g_UCM[i].hidden) continue;
367                        if(pparam->exc_skip && g_UCM[i].Skipped) continue;
368                        if(pparam->exc_audio && (g_UCM[i].Video_pid==0 && g_UCM[i].Audio_pid!=0)) continue;
369                        if(pparam->exc_hd && g_UCM[i].video_format>=eDHL_DISP_1280x720p) continue;
370                        if(pparam->exc_sd && 
371                                (g_UCM[i].Video_pid!=0 
372                                && g_UCM[i].video_format<eDHL_DISP_1280x720p)) continue;
373                        if(pparam->only_fav && g_UCM[i].SurfIndex<=0) continue;
374                               
375                        //¹ß°ßÇÔ.
376                        DMW_MSC_UnlockUcm();
377                       
378                        return g_UCM[i].Uid;
379                }
380        }
381       
382        DMW_MSC_UnlockUcm();
383       
384        return -1;
385}
386
387
388int App_Ucm_GetChannelNum(BOOL binc_skip)
389{
390        int i, num_ch=0;
391        int cur_ch_uid=p_cur_channel.nUid;
392       
393        DMW_MSC_LockUcm();
394       
395        for(i=0; i<g_UCM_number; i++) {
396                //±âº»ÀûÀ¸·Î disable hiddenÀº »ý·«ÇÔ.
397                if(g_UCM[i].disabled || g_UCM[i].hidden) continue;
398                       
399                if((!binc_skip && g_UCM[i].Skipped) && (g_UCM[i].Uid!=cur_ch_uid)) continue;
400               
401                num_ch++;
402        }
403
404        DMW_MSC_UnlockUcm();
405       
406        return num_ch;
407}
408
409
410
411//ÇöÀç cur_idx¸¦ ±âÁØÀ¸·Î ´ÙÀ½ idx¸¦ °Ë»öÇÔ.
412//cur_idx°¡ 0À̸é óÀ½ºÎÅÍ Ã£À½
413//bturn_around´Â ÀÇ¹Ì ¾øÀ½
414int App_Ucm_GetNextChannelNumber(int cur_idx, BOOL binc_skip, BOOL bturn_around)
415{
416#if 1
417        int i, next_idx=-1;
418        int cur_ch_uid=p_cur_channel.nUid;
419       
420        DMW_MSC_LockUcm();
421       
422        if(cur_idx==-1 || g_UCM[cur_idx].Minor==1) { //
423                for(i=cur_idx+1; i<g_UCM_number; i++) {
424                        //±âº»ÀûÀ¸·Î disable hiddenÀº »ý·«ÇÔ.
425                        if(g_UCM[i].disabled || g_UCM[i].hidden) continue;
426                               
427                        if((!binc_skip && g_UCM[i].Skipped) && (g_UCM[i].Uid!=cur_ch_uid)) continue;
428                       
429                        if(g_UCM[i].Minor==1) {
430                                next_idx=i;
431                                break;
432                        }
433                }
434               
435                //hd°¡ ¾ø´Ù¸é óÀ½ºÎÅÍ sd¸¦ °Ë»öÇØ¾ß ÇÔ.
436                for(i=0; next_idx==-1 && i<g_UCM_number; i++) {
437                //±âº»ÀûÀ¸·Î disable hiddenÀº »ý·«ÇÔ.
438                        if(g_UCM[i].disabled || g_UCM[i].hidden) continue;
439               
440                        if((!binc_skip && g_UCM[i].Skipped) && (g_UCM[i].Uid!=cur_ch_uid)) continue;
441                               
442                        if(g_UCM[i].Minor!=1) {
443                                next_idx=i;
444                                break;
445                        }
446                }
447               
448                //sd°¡ ¾ø´Ù¸é óÀ½ºÎÅÍ hd ´Ù½Ã °Ë»ö
449                for(i=0; next_idx==-1 && i<cur_idx; i++) {
450                        //±âº»ÀûÀ¸·Î disable hiddenÀº »ý·«ÇÔ.
451                        if(g_UCM[i].disabled || g_UCM[i].hidden) continue;
452                               
453                        if((!binc_skip && g_UCM[i].Skipped) && (g_UCM[i].Uid!=cur_ch_uid)) continue;
454                       
455                        if(g_UCM[i].Minor==1) {
456                                next_idx=i;
457                                break;
458                        }
459                }
460        }
461        else  {
462               
463                //¸ÕÀú ³¡±îÁö sd °Ë»ö
464                for(i=cur_idx+1; i<g_UCM_number; i++) {
465                //±âº»ÀûÀ¸·Î disable hiddenÀº »ý·«ÇÔ.
466                        if(g_UCM[i].disabled || g_UCM[i].hidden) continue;
467               
468                        if((!binc_skip && g_UCM[i].Skipped) && (g_UCM[i].Uid!=cur_ch_uid)) continue;
469                       
470                        if(g_UCM[i].Minor!=1) {
471                                next_idx=i;
472                                break;
473                        }       
474                }
475               
476                //óÀ½ºÎÅÍ ³¡±îÁö hd °Ë»ö
477                for(i=0; next_idx==-1 && i<g_UCM_number; i++) {
478                        //±âº»ÀûÀ¸·Î disable hiddenÀº »ý·«ÇÔ.
479                        if(g_UCM[i].disabled || g_UCM[i].hidden) continue;
480                               
481                        if((!binc_skip && g_UCM[i].Skipped) && (g_UCM[i].Uid!=cur_ch_uid)) continue;
482                       
483                        if(g_UCM[i].Minor==1) {
484                                next_idx=i;
485                                break;
486                        }
487                }
488               
489                //óÀ½ºÎÅÍ sd °Ë»ö
490                for(i=0; next_idx==-1 && i<cur_idx; i++) {
491                //±âº»ÀûÀ¸·Î disable hiddenÀº »ý·«ÇÔ.
492                        if(g_UCM[i].disabled || g_UCM[i].hidden) continue;
493               
494                        if((!binc_skip && g_UCM[i].Skipped) && (g_UCM[i].Uid!=cur_ch_uid)) continue;
495                       
496                        if(g_UCM[i].Minor!=1) {
497                                next_idx=i;
498                                break;
499                        }       
500                }
501        }
502       
503        DMW_MSC_UnlockUcm();
504       
505        return next_idx;
506
507#else
508        int i, j; //, cur_idx;
509        int major = 0;
510        int minor = 0;
511        int uid = 0;
512        int majorNum = 0;
513        BOOL bFind = FALSE;
514        BOOL bReset = FALSE;
515       
516        DMW_MSC_LockUcm();
517
518        for(i = 0; i < g_UCM_number; i++)
519        {
520                if (g_UCM[i].Minor==1)
521                        majorNum++;
522        }
523
524        if (cur_idx < majorNum)
525        {
526                for(i = 0; i < g_UCM_number; i++)
527                {
528                        if(g_UCM[i].Minor==1)
529                        {
530                                for (j = 0; j < cur_idx; j++)
531                                {
532                                        if (bTrue && !bTune)
533                                        {
534                                                if (g_UCM[i].Uid == App_ChLoadUid(j))
535                                                {
536                                                        bReset = TRUE;
537                                                        break;
538                                                }
539                                        }
540                                        else if (!bTrue && !bTune)
541                                        {
542                                                if (g_UCM[i].Uid == App_LoadUid(j))
543                                                {
544                                                        bReset = TRUE;
545                                                        break;
546                                                }
547                                        }
548                                        else if (!bTrue && bTune)
549                                        {
550                                                if (g_UCM[i].Uid == App_GetChUid(j))
551                                                {
552                                                        bReset = TRUE;
553                                                        break;
554                                                }
555                                        }
556                                }
557                               
558                                if (!bReset)
559                                {
560                                        if (bFind)
561                                        {
562                                                if (g_UCM[i].Major < major)
563                                                {
564                                                        major = g_UCM[i].Major;
565                                                        minor = g_UCM[i].Minor;
566                                                        uid = g_UCM[i].Uid;
567                                                        bFind = TRUE;
568                                                }
569                                        }
570                                        else
571                                        {
572                                                uid = g_UCM[i].Uid;
573                                                major = g_UCM[i].Major;
574                                                minor = g_UCM[i].Minor;
575                                                bFind = TRUE;
576                                        }
577                                }
578                                bReset = FALSE;
579                        }
580                }
581        }
582        else// if (g_UCM[i].Minor > 1)
583        {
584                for(i = 0; i < g_UCM_number; i++)
585                {
586                        if (g_UCM[i].Minor > 1)
587                        {
588                                for (j = 0; j < cur_idx; j++)
589                                {
590                                        if (bTrue && !bTune)
591                                        {
592                                                if (g_UCM[i].Uid == App_ChLoadUid(j))
593                                                {
594                                                        bReset = TRUE;
595                                                        break;
596                                                }
597                                        }
598                                        else if (!bTrue && !bTune)
599                                        {
600                                                if (g_UCM[i].Uid == App_LoadUid(j))
601                                                {
602                                                        bReset = TRUE;
603                                                        break;
604                                                }
605                                        }
606                                        else if (!bTrue && bTune)
607                                        {
608                                                if (g_UCM[i].Uid == App_GetChUid(j))
609                                                {
610                                                        bReset = TRUE;
611                                                        break;
612                                                }
613                                        }
614                                }
615                               
616                                if (!bReset)
617                                {
618                                        if (bFind)
619                                        {
620                                                if (g_UCM[i].Minor < minor)
621                                                {
622                                                        major = g_UCM[i].Major;
623                                                        minor = g_UCM[i].Minor;
624                                                        uid = g_UCM[i].Uid;
625                                                        bFind = TRUE;
626                                                }
627                                                else if (g_UCM[i].Minor == minor)
628                                                {
629                                                        if (g_UCM[i].Major < major)
630                                                        {
631                                                                major = g_UCM[i].Major;
632                                                                minor = g_UCM[i].Minor;
633                                                                uid = g_UCM[i].Uid;
634                                                                bFind = TRUE;
635                                                        }
636                                                }
637                                        }
638                                        else
639                                        {
640                                                uid = g_UCM[i].Uid;
641                                                major = g_UCM[i].Major;
642                                                minor = g_UCM[i].Minor;
643                                                bFind = TRUE;
644                                        }
645                                }
646
647                                bReset = FALSE;
648                        }
649                }
650        }
651
652        DMW_MSC_UnlockUcm();
653        if (bFind)
654                return uid;
655        else
656                return -1;
657#endif
658}
659
660int App_Ucm_GetPrevChannel(int cur_uid, tApp_ChSelParam *pparam)
661{
662        int i, cur_idx;
663        tApp_ChSelParam def_param={TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE};
664       
665        if(!pparam) pparam=&def_param;
666       
667        DMW_MSC_LockUcm();
668       
669        //ÇöÀç ä³Î Á¤º¸..
670        cur_idx=DMW_MSC_Uid2Index(cur_uid);
671       
672        if(cur_idx<0) {
673                cur_idx=g_UCM_number;
674        }
675       
676        for(i=cur_idx-1; i>=0; i--)
677        {
678                if(pparam->exc_hidden && g_UCM[i].hidden) continue;
679                if(pparam->exc_skip && g_UCM[i].Skipped) continue;
680                if(pparam->exc_disable && g_UCM[i].disabled) continue;
681                if(pparam->exc_audio && (g_UCM[i].Video_pid==0 && g_UCM[i].Audio_pid!=0)) continue;
682                if(pparam->exc_hd && g_UCM[i].video_format>=eDHL_DISP_1280x720p) continue;
683                if(pparam->exc_sd && 
684                        (g_UCM[i].Video_pid!=0 
685                        && g_UCM[i].video_format<eDHL_DISP_1280x720p)) continue;
686                if(pparam->only_fav && g_UCM[i].SurfIndex<=0) continue;
687                       
688                //¹ß°ßÇÔ.
689                DMW_MSC_UnlockUcm();
690               
691                return g_UCM[i].Uid;
692        }
693       
694        if(pparam->turn_around) 
695        {
696                for(i=g_UCM_number-1; i>cur_idx; i--)
697                {
698                        if(pparam->exc_hidden && g_UCM[i].hidden) continue;
699                        if(pparam->exc_skip && g_UCM[i].Skipped) continue;
700                        if(pparam->exc_audio && (g_UCM[i].Video_pid==0 && g_UCM[i].Audio_pid!=0)) continue;
701                        if(pparam->exc_hd && g_UCM[i].video_format>=eDHL_DISP_1280x720p) continue;
702                        if(pparam->exc_sd && 
703                                (g_UCM[i].Video_pid!=0 
704                                && g_UCM[i].video_format<eDHL_DISP_1280x720p)) continue;
705                        if(pparam->only_fav && g_UCM[i].SurfIndex<=0) continue;
706                               
707                        //¹ß°ßÇÔ.
708                        DMW_MSC_UnlockUcm();
709                       
710                        return g_UCM[i].Uid;
711                }
712        }
713       
714        DMW_MSC_UnlockUcm();
715       
716        return -1;
717}
718
719
720
721
722/*
723        uid ä³Î µé Áß¿¡¼­ ÀûÀýÇÑ Ã¤³ÎÀ» ¼±ÅÃÇÑ´Ù.
724*/
725int App_Ucm_SelectChannels(tApp_UcmSelectParam *param)
726{
727        //tApp_UcmSelectParam *param;
728        int uidToTune = -1;
729        int i, idx;
730
731        DMW_MSC_LockUcm();
732
733        if (param == NULL) 
734        {
735                dprint(2, "select any channel\n");
736
737                for (i=0; i<g_UCM_number; i++) 
738                {
739                        if (g_UCM[i].hidden == 0 && g_UCM[i].scrambled == 0) {
740                                uidToTune = g_UCM[i].Uid;
741                                break;
742                        }
743                }
744                for (i=0; uidToTune<0 && i<g_UCM_number; i++) 
745                {
746                        if (g_UCM[i].hidden == 0) {
747                                uidToTune = g_UCM[i].Uid;
748                                break;
749                        }
750                }
751                if (uidToTune < 0 && g_UCM_number > 0)
752                        uidToTune = g_UCM[0].Uid;
753
754                goto label_end;
755        }
756
757
758        dprint(2, "select channels among %d..\n", param->nUid);
759        for (i=0; i<param->nUid && param->uidBuf; i++)
760        {
761                idx = DMW_MSC_Uid2Index(param->uidBuf[i]);
762                if (idx >= 0 && idx < g_UCM_number) {
763                        dprint(3, "     uid %d, %c(%02d) %d-%d, #%d %s\n", 
764                                        param->uidBuf[i],
765                                        g_UCM[idx].Skipped ? ' ' : '+',
766                                        idx,
767                                        g_UCM[idx].Major, g_UCM[idx].Minor,
768                                        g_UCM[idx].Prog_number, g_UCM[idx].scrambled ? "scrambled" : "");
769                }
770                else
771                        dprint(3, "     uid %d, --\n"); 
772                        // DB¿¡¼­ ¸ø ãÀ½? ÀÌ·±°Ô ÀÖÀ¸¸é ¾ÈµÊ..
773        }
774
775        // tuning ÇÒ uid¸¦ ã´Â´Ù.
776        uidToTune = -1;
777
778        // 1. non-hidden, non-scrambled µÈ program_number ä³ÎÀ» ã´Â´Ù.
779
780        for (i=0; param->program_number>0 && i<param->nUid && param->uidBuf; i++)
781        {
782                idx = DMW_MSC_Uid2Index(param->uidBuf[i]);
783                if (idx < 0) continue;
784                if (g_UCM[idx].Prog_number == param->program_number &&
785                        g_UCM[idx].hidden == 0 &&
786                        g_UCM[idx].scrambled == 0) {
787                        uidToTune = param->uidBuf[i];
788                        dprint(2, "  uid %d is selected in 1st pass\n", uidToTune);
789                        break;
790                }
791        }
792
793        // 2. non-hidden, non-scrambled µÈ ÀÓÀÇ Ã¤³ÎÀ» ã´Â´Ù.
794        for (i=0; uidToTune<0 && i<param->nUid && param->uidBuf; i++)
795        {
796                idx = DMW_MSC_Uid2Index(param->uidBuf[i]);
797                if (idx < 0) continue;
798                if (g_UCM[idx].hidden == 0 &&
799                        g_UCM[idx].scrambled == 0) {
800                        uidToTune = param->uidBuf[i];
801                        dprint(2, "  uid %d is selected in 2nd pass\n", uidToTune);
802                        break;
803                }
804        }
805
806        // 3. non-hidden ä³ÎÀ» ã´Â´Ù.
807        for (i=0; uidToTune<0 && i<param->nUid && param->uidBuf; i++)
808        {
809                idx = DMW_MSC_Uid2Index(param->uidBuf[i]);
810                if (idx < 0) continue;
811                if (g_UCM[idx].hidden == 0) {
812                        uidToTune = param->uidBuf[i];
813                        dprint(2, "  uid %d is selected in 3rd pass\n", uidToTune);
814                        break;
815                }
816        }
817
818label_end:
819        DMW_MSC_UnlockUcm();
820
821        // ¼±Åà µÈ ä³Î uid¸¦ ¸®ÅÏ.
822        return uidToTune;
823}
824
825
826/*
827        ä³ÎDBÀÇ ¸ðµç ä³Î Áß¿¡¼­ ÁöÁ¤ÇÑ rf ¹øÈ£¸¦ °®´Â ä³ÎÀ» ¼±ÅÃÇÑ´Ù.
828
829        ¸®ÅÏ °ªÀº ÀÌ ÇÔ¼ö°¡ ½º½º·Î ÆÇ´ÜÇÏ¿© ¼±ÅÃÇÑ °¡Àå ÀûÀýÇÑ Ã¤³ÎÀÇ uid ÀÌ´Ù.
830        Çϳªµµ ¹ß°ßµÇÁö ¾Ê°Å³ª Çϸé -1 ¸®ÅÏ.
831*/
832int App_Ucm_FindChannelByRF(int rf, int nUidBufSize, int *pUidBuf)
833{
834        int i;
835        int nUid = 0;
836        int myUidBuf[1]; // ÃÖ¼ÒÇÑ ÇϳªÀÇ Ã¤³ÎÀº ¼±ÅÃÇØ¼­ ¸®ÅϰªÀ¸·Î ³Ñ°Ü¾ß ÇϹǷÎ..
837
838        // caller°¡ uid buf¸¦ ÁöÁ¤ÇÏÁö ¾ÊÀº °æ¿ì, ¿ì¸® stackÀÇ ÀÛÀº ¹öÆÛ »ç¿ë.
839        if (pUidBuf == NULL || nUidBufSize <= 0) {
840                pUidBuf = myUidBuf;
841                nUidBufSize = sizeof(myUidBuf)/sizeof(myUidBuf[0]);
842        }
843
844        DMW_MSC_LockUcm();
845        // 1. non-hidden, non-scrambled ä³Î..
846        for (i=0; i<g_UCM_number; i++) 
847        {
848                if (rf != g_UCM[i].RF) continue;
849
850                if (g_UCM[i].hidden == 0 && g_UCM[i].scrambled == 0 && g_UCM[i].disabled==0) {
851                        if (nUid < nUidBufSize  && pUidBuf)
852                                pUidBuf[nUid++] = g_UCM[i].Uid;
853                }
854        }
855#if 0
856        // 2. non-hidden ä³Î..
857        for (i=0; i<g_UCM_number; i++)
858        {
859                if (rf != g_UCM[i].RF) continue;
860
861                if (g_UCM[i].hidden == 0 && g_UCM[i].scrambled) {
862                        if (nUid < nUidBufSize  && pUidBuf)
863                                pUidBuf[nUid++] = g_UCM[i].Uid;
864                }
865        }
866        // 2. ÀÏ¹Ý Ã¤³Î..
867        for (i=0; i<g_UCM_number; i++)
868        {
869                if (rf != g_UCM[i].RF) continue;
870
871                if (g_UCM[i].hidden && g_UCM[i].scrambled) {
872                        if (nUid < nUidBufSize  && pUidBuf)
873                                pUidBuf[nUid++] = g_UCM[i].Uid;
874                }
875        }
876#endif
877
878        DMW_MSC_UnlockUcm();
879
880        return nUid;
881}
882
883
884
885
886
887#if COMMENT
888____Symbol____(){}
889#endif
890
891#if APP_REGISTER_DEBUG_SYMBOL
892
893static DHL_SymbolTable _UcmSymbolx[] =
894{
895        //DHL_FNC_SYM_ENTRY2("ucm", DMW_CDB_PrintUcm),
896        // Fnc_NvRam ¿¡ ÀÖ´Â °ÍÀÌ ´õ »ó¼¼ÇÔ.
897};
898
899static void RegisterSymbols(void)
900{
901        DHL_DBG_RegisterSymbols(_UcmSymbolx, DHL_NUMSYMBOLS(_UcmSymbolx));
902}
903
904#else
905static void RegisterSymbols(void) { }
906#endif  /* APP_REGISTER_DEBUG_SYMBOL */
907
908
909
910
911
912#if COMMENT
913____Init____(){}
914#endif
915       
916//  App_VideoInit
917//
918//  Video module ÃʱâÈ­.
919//
920void App_UcmInit(void)
921{
922        dprint(0, "%s:\n", __FUNCTION__);
923       
924        p_ch_info_mutex = DHL_OS_CreateMutexSemaphore("ucm_mtx");
925
926        RegisterSymbols();
927
928// TODO : bug·Î º¸ÀÓ , 100422
929        // Load
930
931        DMW_CDB_InitializeChannelLib((ChannelType)p_cur_channel.nChannelType, 0);
932        App_NVM_LoadUcm();
933}
934
935
936
937
938
939#if COMMENT
940____Test____(){}
941#endif
942
943#include "DMW_CodeConv.h"
944
945void add_long_name(int uid, char *name)
946{
947        int idx, len;
948        UINT16 *uc;
949       
950        DMW_MSC_LockUcm();
951        idx = DMW_MSC_Uid2Index(uid);
952        if (idx >= 0)
953        {
954                uc = DMW_ConvKs2Uc(name, -1);
955                //len = UniStrLen(uc);
956                UniStrNCopy(g_UCM[idx].LongName, uc, 30);
957
958                DMW_FreeUcString(uc);
959        }
960        DMW_MSC_UnlockUcm();
961}
962
963
964
965
966
967/* end of file */
Note: See TracBrowser for help on using the repository browser.