37 #define TIMEOUT_PAT 700
38 #define TIMEOUT_PMT 1000
39 #define TIMEOUT_DEFAULT 0x7FFF
41 #define DSI_RQST_MAGIC 0xBA000000
44 #define dsmctrl dsi->ctrl
49 typedef struct s_tablerequest
51 struct s_tablerequest *next;
59 typedef struct s_DsiInstance
64 F_FILTER_CALLBACK cbfunc;
66 S_TableRequest *tables;
79 U32BIT TimeoutPeriod(U8BIT tid)
90 return TIMEOUT_DEFAULT;
106 static SECFILT SectionFilterAdd( DMXREF dmx, PIDFILT pfid, U8BIT tid,
107 U8BIT tidMask, U16BIT tidExt, U16BIT tidExtMask )
109 U8BIT match[SECFILT_MASK_SIZE];
110 U8BIT mmask[SECFILT_MASK_SIZE];
114 if (sfid != INVALID_SECFILT)
117 match[1] = (U8BIT)(tidExt >> 8);
118 match[2] = (U8BIT)(tidExt & 0x00ff);
120 mmask[1] = (U8BIT)(tidExtMask >> 8);
121 mmask[2] = (U8BIT)(tidExtMask & 0x00ff);
122 for (i = 3; i != SECFILT_MASK_SIZE; i++)
132 static void ReleaseSi(H_DsiInstance dsi)
134 DBGPRINT(DM_SI,
"pflt=%x", dsi->pflt)
137 dsi->sflt = INVALID_SECFILT;
139 dsi->pflt = INVALID_PIDFILT;
142 static BOOLEAN RequestSi(H_DsiInstance dsi, U16BIT pid, U8BIT tid, U16BIT xid, U16BIT xmsk)
147 ASSERT(dsi->pflt == INVALID_PIDFILT);
148 ASSERT(dsi->sflt == INVALID_SECFILT);
150 dmxref = dsi->dmxref;
152 if (dsi->pflt == INVALID_PIDFILT)
154 ERRPRINT(
"Grab PID filter fail")
159 dsi->sflt = SectionFilterAdd( dmxref, dsi->pflt, tid, 0xFF, xid, xmsk);
160 if (dsi->sflt == INVALID_SECFILT)
162 ERRPRINT(
"Grab SEC filter fail")
164 dsi->pflt = INVALID_PIDFILT;
170 DBGPRINT(DM_SI,
"tid=%d xid=%d pflt=%x", tid, xid, dsi->pflt)
177 S_TableRequest* FindTableRqst(H_DsiInstance dsi, U16BIT xid, U8BIT tid)
179 S_TableRequest *rqst;
181 while (rqst != NULL && (rqst->xid != xid || rqst->tid != tid))
200 dsi = config->memAlloc(
sizeof(S_DsiInstance));
204 if (dsi->mutex == NULL)
206 ERRPRINT(
"mutex create fail")
207 config->memFree(dsi);
212 dsi->memAlloc = config->memAlloc;
213 dsi->memFree = config->memFree;
214 dsi->cbfunc = cbfunc;
216 dsi->pflt = INVALID_PIDFILT;
217 dsi->sflt = INVALID_SECFILT;
242 BOOLEAN
DSI_Start( H_DsiInstance dsi, U16BIT transId, DMXREF dmxref )
244 dsi->dmxref = dmxref;
255 S_TableRequest *rqst, *next;
256 if (dsi->pflt != INVALID_PIDFILT)
286 S_TableRequest *rqst;
290 rqst = FindTableRqst(dsi, xid, tid);
294 rqst->version = 0xFF;
296 result = DSI_RQST_MAGIC | (((U32BIT)tid) << 16) | xid;
300 rqst = dsi->memAlloc(
sizeof(S_TableRequest));
303 ERRPRINT(
"memory fail for serviceId=%d", xid);
311 rqst->version = 0xFF;
314 rqst->next = dsi->tables;
317 result = DSI_RQST_MAGIC | (((U32BIT)tid) << 16) | xid;
320 if (result && dsi->pflt == INVALID_PIDFILT)
322 if ( RequestSi(dsi, pid, tid, xid, 0xFFFF) )
326 rqst->timeout += TimeoutPeriod(tid);
339 S_TableRequest **pprqst, *rqst;
342 ASSERT((rid & 0xFF000000) == DSI_RQST_MAGIC);
345 ASSERT(dsi->pflt != INVALID_PIDFILT);
349 tid = (rid >> 16) & 0xFF;
352 pprqst = &(dsi->tables);
353 while (*pprqst != NULL)
356 if (rqst->xid == xid && rqst->tid == tid)
358 *pprqst = rqst->next;
362 pprqst = &(rqst->next);
375 U32BIT tdiff, least, tout;
376 S_TableRequest *rqst;
379 DBGPRINT(DM_SI,
"rid=%x pflt=%x", dsi->rid, dsi->pflt)
380 if (!dsi->rid && dsi->pflt != INVALID_PIDFILT)
384 if (dsi->pflt == INVALID_PIDFILT)
390 if (rqst->timeout <= now)
402 if (RequestSi(dsi, pid, tid, xid, 0xFFFF))
404 dsi->rid = DSI_RQST_MAGIC | (((U32BIT)tid) << 16) | xid;
405 rqst->timeout = now + TimeoutPeriod(tid);
409 least = TIMEOUT_DEFAULT;
414 tdiff = rqst->timeout - now;
415 tout = TimeoutPeriod(rqst->tid);
420 else if (tdiff > tout)
423 rqst->timeout = now + tout;
441 S_TableRequest *rqst;
447 version = (hdr[5] >> 1) & 0x1f;
448 xid = hdr[3] << 8 | hdr[4];
451 rqst = FindTableRqst(dsi, xid, tid);
452 if (rqst != NULL && rqst->version != version)
454 DBGPRINT(DM_SI,
"PMT xid=%d pflt=%x ver=%d", xid, dsi->pflt, version)
458 rqst->version = version;
U32BIT STB_OSGetClockMilliseconds(void)
Get Current Computer Clock Time.
PIDFILT STB_DMXGrabPIDFilter(DMXREF dmx, U16BIT pid, F_FILTER_CALLBACK func)
Get a New PID Filter & Setup Associated Buffer and Callback Function Address.
DSM-CC API functions to control DSM-CC instance.
void STB_DMXSetupSectFilter(DMXREF dmx, SECFILT sfid, U8BIT *match_ptr, U8BIT *mask_ptr, U8BIT not_equal_byte_index, BOOLEAN crc)
Configures a match and mask for a specified section filter.
U32BIT DSI_RequestTable(H_DsiInstance dsi, U16BIT pid, U16BIT xid, U8BIT tid)
Request Table data. It supplies Table soon after the call to this function, and then, whenever the Table version changes. This state continues until DSI_CancelTable is called.
Internal header for DSM-CC si support.
void STB_OSDeleteMutex(void *mutex)
Delete a mutex.
void STB_DMXStopPIDFilter(DMXREF dmx, PIDFILT pfid)
Stop Specified PID Filter Collecting Data.
BOOLEAN DSI_RequireTable(H_DsiInstance dsi, U8BIT *hdr, U16BIT *pXid, U8BIT *pVer)
Check whether SI table section data is required.
void DSI_CancelTable(H_DsiInstance dsi, U32BIT rid)
Cancel request for table data made by DSI_RequestTable()
U32BIT DSI_CheckRequests(H_DsiInstance dsi, U32BIT now)
Check outstanding PMT (and PAT) requests to see whether any need to be refreshed. ...
void DSI_Stop(H_DsiInstance dsi)
Stop getting SI data from Demux.
void STB_OSMutexUnlock(void *mutex)
Unlock a mutex (a.k.a. 'leave', 'signal' or 'release')
void * STB_OSCreateMutex(void)
Create a mutex.
void STB_DMXReleasePIDFilter(DMXREF dmx, PIDFILT pfid)
Releases a previously allocated PID filter.
SECFILT STB_DMXGrabSectFilter(DMXREF dmx, PIDFILT pfid)
Allocated a new section filter on the specified PID filter.
void STB_DMXStartPIDFilter(DMXREF dmx, PIDFILT pfid)
Start Specified PID Filter Collecting Data.
void STB_DMXReleaseSectFilter(DMXREF dmx, SECFILT sfid)
Releases a previously allocated section filter.
void STB_OSMutexLock(void *mutex)
Lock a mutex (a.k.a. 'enter', 'wait' or 'get').
H_DsiInstance DSI_CreateInstance(H_DsmControl ctrl, F_FILTER_CALLBACK cbfunc, S_DsmccConfig *config)
Create instance of DSI.
Interface to Platform Section Filtering.
void DSI_DestroyInstance(H_DsiInstance dsi)
Destroy instance created by SIQ_CreateInstance.
BOOLEAN DSI_Start(H_DsiInstance dsi, U16BIT transId, DMXREF dmxref)
Start getting SI data from Demux.
Function prototypes for operating system.