source: svn/newcon3bcm2_21bu/dst/dmw/src/psi/DMW_PsiLinkedList.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: 3.0 KB
Line 
1/*
2        DMW_PsiLinkedList.c
3
4        DST TV MW PSI Scan Module
5
6        PSI Database entry linked list implementation
7
8        Copyright 2006~2009 Digital STREAM Technology, Inc.
9        All Rights Reserved
10
11*/
12
13
14#include "DMW_Platform.h"
15
16#include "DMW_PsiLinkedList.h"
17
18
19
20#if COMMENT
21____DbgPrint____(){}
22#endif
23
24DHL_MODULE("psils", 0);
25
26
27#if COMMENT
28____List____(){}
29#endif
30
31
32//extern
33S_PSIM_CHINFO *g_PsiDB;
34
35
36
37S_PSIM_CHINFO *PSI_FirstChInfo(void)
38{
39        return g_PsiDB;
40}
41
42/*
43        ¸µÅ© ¸®½ºÆ®·Î ¿¬°áµÈ ChInfo ¸®½ºÆ® Áß¿¡¼­ ÇØ´ç id¸¦ °®´Â node¸¦ ã¾Æ¼­ ¸®ÅÏÇÏ´Â ÇÔ¼ö
44
45        @start °¡ NULL ÀÌ¸é ¸Ç Ã³À½ CHINFO ¸®ÅÏ.
46*/
47S_PSIM_CHINFO *PSI_SearchChInfo(S_PSIM_CHINFO *start, int id)
48{
49        // Note!!
50        // this function should be called in Mutex Locked State if current task is not EpgTask
51       
52        S_PSIM_CHINFO *chInfo = start;
53       
54        while (chInfo && chInfo->id != id)
55                chInfo = chInfo->next;
56               
57        return chInfo;
58}
59
60S_PSIM_CHINFO *PSI_GetChInfo(int id)
61{
62        return PSI_SearchChInfo(PSI_FirstChInfo(), id);
63}
64
65S_PSIM_CHINFO *PSI_NextChInfo(S_PSIM_CHINFO *cur)
66{
67        return cur ? cur->next : NULL;
68}
69
70void PSI_InsertChInfo(S_PSIM_CHINFO *chInfo)
71{
72        // insert epg db list chain.. id ¼ø¼­·Î sorting ÇÑ´Ù.
73        int id = chInfo->id;
74        S_PSIM_CHINFO *node, *prev;
75
76        if (chInfo->prev || chInfo->next) {
77                dprint(0, "!! inserting non-orphan node?\n");
78                //chInfo->prev = chInfo->next = 0;
79                return;
80        }
81       
82        node = g_PsiDB;
83        prev = NULL;
84        dprint(3, "traverse chanInfo chain from 0x%x\n", node);
85        while (node && node->id < id) {
86                prev = node;
87                node = node->next;
88        }
89        // node°¡ NULL À̰ųª node->id > id ÀÎ °æ¿ì.. ÀÌ node ¾ÕºÎºÐ¿¡ ³ÖÀ¸¸é µÈ´Ù.
90        //  prev  ¿Í   node »çÀÌ¿¡ Ãß°¡.
91        dprint(3, "insert new chanInfo between 0x%x and 0x%x\n", prev, node);
92        chInfo->prev = prev;
93        chInfo->next = node;
94       
95        if (prev) prev->next = chInfo;
96        if (node) node->prev = chInfo;
97       
98        if (prev == NULL) 
99                g_PsiDB = chInfo;
100
101}
102
103void PSI_RemoveChInfo(S_PSIM_CHINFO *chInfo)
104{
105        if (chInfo->prev)
106                chInfo->prev->next = chInfo->next;
107        else
108                g_PsiDB = chInfo->next;
109       
110        if (chInfo->next)
111                chInfo->next->prev = chInfo->prev;
112}
113
114S_PSIM_CHINFO *PSI_NewChInfo(int id)
115{
116        // search if same rf DB exist..
117        S_PSIM_CHINFO *chInfo;
118
119        chInfo = PSI_GetChInfo(id);
120        if (chInfo)
121                return chInfo;
122
123        // id°¡ ÀÏÄ¡ÇÏ´Â DB°¡ ÇöÀç Á¸ÀçÇÏÁö ¾Ê´Â´Ù. »õ·Î ¸¸µé¾î¾ß ÇÑ´Ù.
124        // create new channel Info..
125        dprint(1, "alloc new channInfo for id %d\n", id);
126        chInfo = DHL_OS_Malloc(sizeof(S_PSIM_CHINFO));
127        if (chInfo == NULL) {
128                dprint(0, "!! chanInfo out of memory\n");
129                // call eventproc
130                //Dmc_EpgSendUserEvent(context, epgEventError, (UINT32)statusOutOfMemory, (UINT32) DMW_CDB_ErrString(statusOutOfMemory));
131               
132                // epg stop..
133                //OS_GiveSemaphore(gDmcEpgCommandAckSema4);
134                //break;
135                return NULL;
136        }
137       
138        dprint(3, "new chanInfo created..\n");
139        chInfo->id = id;
140        chInfo->magic = CHANNEL_INFO_MAGIC;
141
142#if DMW_PSI_SUPPORT_ELAPSED_TIMER
143        // cafrii 060814 add
144        DMW_ResetCounter(&chInfo->counter);
145        DMW_HoldCounter(&chInfo->counter);
146#endif
147        return chInfo;
148}
149
150
151
152
Note: See TracBrowser for help on using the repository browser.