42 #include "dsmcc_version.h"
46 #define MAIN_STACK_SIZE 0x2000
47 #define TIMER_RESOLUTION 100
48 #define RESTART_TIME 200
50 #define START_MAGIC 0xDEED
51 #define CLDSM_MAGIC 0xBADE
53 #define ERA_SHIFT (32 - ERA_BITS)
54 #define ERA_LAST ((1 << ERA_BITS) - 1)
55 #define ERA_FIRST 0x00
57 #if defined(NDEBUG) && !defined(DSM_DBG_MASK)
58 #define DSM_DBG_MASK 0
61 #define GETENV_DSMDBG(mskitem) \
62 strcpy(mskptr,#mskitem); \
63 value = getenv(envname); \
64 if (value != NULL) { \
65 if (atoi(value) == 1) mask |= mskitem; \
66 else mask &= ~mskitem; }
81 DSM_MSG_PMT_DATA = 0x02,
84 DSM_MSG_NEW_SECTION = 0x100,
85 DSM_MSG_CACHE_SECTION,
86 DSM_MSG_UPDATE_FILTER,
99 typedef struct s_PmtInfo
106 typedef struct s_DsmMessage
117 typedef struct s_timer
119 struct s_timer *next;
125 typedef struct s_msgqueue
134 typedef struct s_DsmControl
142 S_MsgQueue queues[QP_TOTAL];
154 H_DsmCarousel carousel;
172 unsigned int gDebugState = DSM_DBG_MASK;
175 S_DsmControl *instanceHead = NULL;
177 static BOOLEAN DsmStart( H_DsmControl dsmctrl, U16BIT serviceId, U32BIT couId, U8BIT sikind );
178 static void DsmRestart( H_DsmControl dsmctrl, U16BIT serviceId );
182 static BOOLEAN QueueWrite( S_MsgQueue *queue, S_Message *pmsg )
189 if (next == queue->ends)
193 if (next == queue->read)
199 *(queue->write) = *pmsg;
207 static BOOLEAN QueueRead( S_MsgQueue *queue, S_Message *pmsg )
212 if (queue->read == queue->write)
221 if (next == queue->ends)
232 static U16BIT CheckTimers( S_DsmControl *dsmctrl, U32BIT now )
239 era = now >> ERA_SHIFT;
240 timeout = TIMEOUT_NEVER;
245 pTimer = dsmctrl->timers;
246 while (pTimer != NULL && pTimer->trigger <= now &&
247 (pTimer->trigger >> ERA_SHIFT) != ERA_FIRST)
249 dsmctrl->timers = pTimer->next;
251 if ((pTimer->handle.u32 >> 16) == CLDSM_MAGIC)
257 else if ((pTimer->handle.u32 >> 16) == START_MAGIC)
259 restartid = pTimer->usrData.u16;
261 dsmctrl->api.memFree(pTimer);
263 pTimer = dsmctrl->timers;
268 timeout = (U16BIT)((S32BIT)pTimer->trigger - (S32BIT)now);
274 pTimer = dsmctrl->timers;
275 while (pTimer != NULL &&
276 (pTimer->trigger <= now || (pTimer->trigger >> ERA_SHIFT) == ERA_LAST))
278 dsmctrl->timers = pTimer->next;
280 if ((pTimer->handle.u32 >> 16) == CLDSM_MAGIC)
286 else if ((pTimer->handle.u32 >> 16) == START_MAGIC)
288 restartid = pTimer->usrData.u16;
290 dsmctrl->api.memFree(pTimer);
292 pTimer = dsmctrl->timers;
297 timeout = (U16BIT)(pTimer->trigger - now);
303 pTimer = dsmctrl->timers;
304 while (pTimer != NULL && pTimer->trigger <= now)
306 dsmctrl->timers = pTimer->next;
308 if ((pTimer->handle.u32 >> 16) == CLDSM_MAGIC)
314 else if ((pTimer->handle.u32 >> 16) == START_MAGIC)
316 restartid = pTimer->usrData.u16;
318 dsmctrl->api.memFree(pTimer);
320 pTimer = dsmctrl->timers;
325 timeout = (U16BIT)(pTimer->trigger - now);
330 DsmRestart(dsmctrl, (U16BIT)restartid);
335 static void DsmMain(
void *arg)
337 S_DsmControl *dsmctrl = (S_DsmControl *)arg;
338 S_MsgQueue *queues = dsmctrl->queues;
339 void *apimutex = dsmctrl->api.mutex;
343 BOOLEAN closing = FALSE;
345 FUNCTION_START(DsmMain);
347 sema_timeout = TIMEOUT_NEVER;
348 si_time = 0xFFFFFFFF;
354 if (QueueRead(queues + QP_TOP, &msg) ||
355 QueueRead(queues + QP_HIGH, &msg) ||
356 QueueRead(queues + QP_LOW, &msg))
360 case DSM_MSG_PAT_DATA:
368 if (dsmctrl->status == (U8BIT)BL_WAITING)
370 DsmStart( dsmctrl, dsmctrl->serviceId, dsmctrl->couId, dsmctrl->sikind );
376 case DSM_MSG_PMT_DATA:
382 SIQ_ProcessPmt( dsmctrl->siq, table, msg.u.tinfo.xid, msg.u.tinfo.version );
390 case DSM_MSG_PMT_REMOVED:
397 case DSM_MSG_NEW_SECTION:
398 case DSM_MSG_CACHE_SECTION:
403 if (msg.type == DSM_MSG_NEW_SECTION)
409 case DSM_MSG_UPDATE_FILTER:
414 case DSM_MSG_CLOSE_DOWN:
422 ASSERT(dsmctrl->dsi);
425 sema_timeout = CheckTimers(dsmctrl, now);
426 if (now + sema_timeout > si_time)
428 sema_timeout = (U16BIT)(si_time - now);
434 if (QueueRead(queues + QP_TOP, &msg) ||
435 QueueRead(queues + QP_HIGH, &msg) ||
436 QueueRead(queues + QP_LOW, &msg))
440 case DSM_MSG_NEW_SECTION:
441 case DSM_MSG_PMT_DATA:
442 case DSM_MSG_PAT_DATA:
447 case DSM_MSG_PMT_REMOVED:
448 case DSM_MSG_CACHE_SECTION:
449 case DSM_MSG_CLOSE_DOWN:
450 case DSM_MSG_UPDATE_FILTER:
457 dsmctrl->task = NULL;
458 FUNCTION_FINISH(DsmMain);
461 static void ProcessPmt( S_DsmControl *dsmctrl, U16BIT serviceId, U8BIT *pmt )
467 msg.type = DSM_MSG_PMT_REMOVED;
468 msg.u.tinfo.xid = serviceId;
469 if (!QueueWrite(dsmctrl->queues + QP_TOP, &msg))
471 ERRPRINT(
"failed to add to Q")
478 else if (
SIQ_RequirePmt(dsmctrl->siq, pmt, &msg.u.tinfo.xid, &msg.u.tinfo.version) == SIQ_UPDATE)
480 ASSERT(msg.u.tinfo.xid == serviceId);
482 if (msg.pSection == NULL)
484 ERRPRINT(
"failed to alloc buffer")
488 msg.type = DSM_MSG_PMT_DATA;
489 len = ((pmt[1] << 8 | pmt[2]) & 0xfff) + 3;
490 memcpy(msg.pSection, pmt, len);
491 if (!QueueWrite(dsmctrl->queues + QP_TOP, &msg))
493 ERRPRINT(
"failed to add to Q")
504 static void DvbPmtCallback( U16BIT serviceId, U8BIT *pmt )
506 S_DsmControl *dsmctrl;
507 FUNCTION_START(UpdateFilter)
508 dsmctrl = instanceHead;
509 while (dsmctrl != NULL)
511 if (dsmctrl->status != (U8BIT)BL_WAITING &&
512 dsmctrl->dsi == NULL && dsmctrl->siq && dsmctrl->task)
515 ProcessPmt(dsmctrl, serviceId, pmt);
517 dsmctrl = dsmctrl->next;
519 FUNCTION_FINISH(UpdateFilter)
522 static BOOLEAN UsingPmtsFromDvb(
void )
524 S_DsmControl *dsmctrl;
525 FUNCTION_START(UsingPmtsFromDvb)
526 dsmctrl = instanceHead;
527 while (dsmctrl != NULL)
529 if (dsmctrl->dsi == NULL)
534 dsmctrl = dsmctrl->next;
536 FUNCTION_FINISH(UsingPmtsFromDvb)
540 static
void ProcessDsi( DMXREF demux, U16BIT nbytes, PIDFILT pfid )
543 S_DsmControl *dsmctrl;
544 U8BIT header[SECTION_HEADER_LENGTH];
548 sectionLen = (((header[1] & 0x0F) << 8) | header[2]) + 3;
549 if (nbytes != sectionLen)
551 ERRPRINT(
"Length mis-match for section (bytes=%#x != data1=%#x,data2=%#x)",
552 nbytes, header[1], header[2] )
556 dsmctrl = instanceHead;
557 while (dsmctrl != NULL)
559 if (dsmctrl->dsi != NULL && demux == dsmctrl->dmxref)
561 if (
DSI_RequireTable(dsmctrl->dsi, header, &emsg.u.tinfo.xid, &emsg.u.tinfo.version))
563 emsg.type = (E_DsmMsgType)*header;
565 if (emsg.pSection == NULL)
567 ERRPRINT(
"failed to alloc buffer")
572 !QueueWrite(dsmctrl->queues + QP_TOP, &emsg))
574 ERRPRINT(
"failed to add to Q")
584 dsmctrl = dsmctrl->next;
603 static void ProcessSection( DMXREF demux, U16BIT nbytes, PIDFILT pfid )
608 S_DsmControl *dsmctrl;
609 U8BIT header[SECTION_HEADER_LENGTH];
611 FUNCTION_START(ProcessSection)
614 sectionLen = (((header[1] & 0x0F) << 8) | header[2]) + 3;
615 if (*header < 0x3B || *header > 0x3D)
617 ERRPRINT(
"Bad table id=0x%x", *header)
619 else if (nbytes < sectionLen)
621 ERRPRINT(
"Demux not providing enough bytes for section (bytes=%#x != data1=%#x,data2=%#x)",
622 nbytes, header[1], header[2] )
626 dsmctrl = instanceHead;
627 while (dsmctrl != NULL)
629 if (demux == dsmctrl->dmxref)
634 case SFM_UPDATE_CACHE:
636 if (emsg.pSection == NULL)
638 ERRPRINT(
"SFM_CacheBuffer failed for %#x", emsg.u.hBuffer)
643 if (nbytes != sectionLen && CDSM_UtilCalculateCRC(emsg.pSection, sectionLen))
656 queue = &dsmctrl->queues[QP_LOW];
659 case SFM_UPDATE_HIGH:
660 queue = &dsmctrl->queues[QP_HIGH];
666 if (emsg.pSection == NULL)
668 ERRPRINT(
"Memory failure for size=%#x", sectionLen)
672 emsg.type = DSM_MSG_NEW_SECTION;
674 (nbytes != sectionLen && CDSM_UtilCalculateCRC(emsg.pSection, sectionLen)) ||
675 !QueueWrite(queue, &emsg))
686 dsmctrl = dsmctrl->next;
690 FUNCTION_FINISH(ProcessSection)
706 void *hBuffer, E_SFM_STATUS status )
709 S_DsmControl *dsmctrl;
710 FUNCTION_START(CacheMatch)
711 dsmctrl = instanceHead;
712 while (dsmctrl != NULL)
714 if (dsmctrl->sfm == sfm)
716 emsg.pSection = pSection;
717 emsg.u.hBuffer = hBuffer;
718 emsg.type = DSM_MSG_CACHE_SECTION;
725 if (!QueueWrite(dsmctrl->queues + QP_LOW, &emsg))
735 case SFM_UPDATE_HIGH:
736 if (!QueueWrite(dsmctrl->queues + QP_HIGH, &emsg))
748 dsmctrl = dsmctrl->next;
750 FUNCTION_FINISH(CacheMatch)
761 static void UpdateFilter(
H_SfmInstance sfm, H_DmxPidFilter hPF )
764 S_DsmControl *dsmctrl;
765 FUNCTION_START(UpdateFilter)
766 dsmctrl = instanceHead;
767 while (dsmctrl != NULL)
769 if (dsmctrl->sfm == sfm)
771 emsg.pSection = NULL;
772 emsg.u.hBuffer = hPF;
773 emsg.type = DSM_MSG_UPDATE_FILTER;
774 if (!QueueWrite(dsmctrl->queues + QP_TOP, &emsg))
784 dsmctrl = dsmctrl->next;
786 FUNCTION_FINISH(UpdateFilter)
789 U32BIT StubRequestTable(
void *pmtref, U16BIT pid, U16BIT xid, U8BIT tid )
791 return 0x55000000 | (U32BIT)(tid << 16) | xid;
794 static void StubCancelTable(
void *ref, U32BIT rid )
806 setup.memAlloc = config->memAlloc;
807 setup.memFree = config->memFree;
809 if (!(config->controlFlags & GET_PMT_DIRECT_FROM_HW_FLAG))
811 setup.dvpRequestTable = StubRequestTable;
812 setup.dvpCancelTable = StubCancelTable;
813 if (!UsingPmtsFromDvb())
815 STB_SIRegisterPmtObserver( DvbPmtCallback );
823 setup.pmtref = pmtref;
825 setup.parsePmtInit = config->parsePmtInit;
826 setup.parsePmtDone = config->parsePmtDone;
827 setup.parseDataBroadcastId = config->parseDataBroadcastId;
828 setup.parseSsuSelectorBytes = config->parseSsuSelectorBytes;
830 setup.notifyAitInfo = config->notifyAitInfo;
834 if (gDebugState & DS_ALL)
837 setup.dbgState = gDebugState & DS_ALL;
842 #if DSM_DP_LEVEL >= 2
845 setup.dbgPrintf = DBG_DebugPrintf;
872 if (setup.sfmMutex == NULL)
880 if (setup.cacheMutex == NULL)
889 if (setup.bufferMutex == NULL)
898 setup.memAlloc = config->memAlloc;
899 setup.memFree = config->memFree;
904 setup.hwFilterCallback = ProcessSection;
906 setup.updateFilter = UpdateFilter;
908 setup.maxPidFilters = 4;
909 setup.maxSecFiltersPerPid = 1;
911 setup.sectionBuffCacheSize = config->sectionBuffCacheSize;
913 if (setup.sectionBuffCacheSize)
915 setup.cacheMatch = CacheMatch;
917 setup.maxAvailableSectionFilters = NUM_SECTION_FILTERS_DEFAULT;
921 if (gDebugState & DF_ALL)
924 setup.dbgState = gDebugState & DF_ALL;
929 #if DSM_DP_LEVEL >= 2
932 setup.dbgPrintf = DBG_DebugPrintf;
962 static E_DscError StartTimer( H_DsmControl dsmctrl, U16BIT magic,
963 U32BIT timePeriod,
void *clDsmTmrUserData,
void **pTimerHandle )
965 S_Timer *pNewTimer, **ppTimer;
966 U32BIT trigger, tval;
971 pNewTimer = dsmctrl->api.memAlloc(
sizeof(S_Timer));
972 if (pNewTimer == NULL)
974 *pTimerHandle = NULL;
975 err = CLDSM_ERR_ALLOC_FAILED;
980 pNewTimer->trigger = trigger;
981 pNewTimer->usrData.ptr = clDsmTmrUserData;
982 era = trigger >> ERA_SHIFT;
985 counter = dsmctrl->counter;
986 pNewTimer->handle.u32 = (((U32BIT)magic) << 16) | (U32BIT)counter;
988 ppTimer = &dsmctrl->timers;
989 while (*ppTimer != NULL)
991 tval = (*ppTimer)->trigger;
992 if (tval > trigger &&
993 (era != ERA_FIRST || (tval >> ERA_SHIFT) != ERA_LAST))
998 ppTimer = &((*ppTimer)->next);
1000 pNewTimer->next = *ppTimer;
1001 *ppTimer = pNewTimer;
1007 *pTimerHandle = pNewTimer->handle.ptr;
1013 static E_DscError StartTimerFunc( H_DsmControl dsmctrl,
1014 U32BIT timePeriod,
void *clDsmTmrUserData,
void **pTimerHandle )
1016 return StartTimer(dsmctrl, CLDSM_MAGIC, timePeriod, clDsmTmrUserData, pTimerHandle);
1019 static void StopTimer( H_DsmControl dsmctrl, U32BIT handle )
1021 S_Timer *pTimer, **ppTimer;
1023 ppTimer = &dsmctrl->timers;
1024 while (*ppTimer != NULL)
1027 if (handle == pTimer->handle.u32)
1029 *ppTimer = pTimer->next;
1030 dsmctrl->api.memFree(pTimer);
1033 ppTimer = &(pTimer->next);
1038 static void StopTimerFunc( H_DsmControl dsmctrl,
void *timerHandle )
1041 th.ptr = timerHandle;
1042 StopTimer( dsmctrl, th.u32 );
1045 static void dsmccErrorFunc( E_DscError err,
void *args )
1049 static H_DsiInstance CreateDsi( S_DsmControl *dsmctrl,
S_DsmccConfig *config)
1057 void DestroyDsi( S_DsmControl *dsmctrl )
1059 if (dsmctrl->dsi != NULL)
1062 dsmctrl->dsi = NULL;
1069 void *memContext = NULL;
1070 E_DscError cldsmErr = CLDSM_OK;
1074 CDSM_SetPrintFuncs( DBG_ErrorPrintf, DBG_WarnPrintf, DBG_DebugPrintf, DBG_InfoPrintf );
1078 setup.siqInstance = CreateSiq( config, dsmctrl->dsi );
1079 if (setup.siqInstance == NULL)
1085 setup.sfmInstance = CreateSfm( config );
1086 if (setup.sfmInstance == NULL)
1088 if (!(config->controlFlags & GET_PMT_DIRECT_FROM_HW_FLAG) &&
1089 !UsingPmtsFromDvb())
1091 STB_SIUnregisterPmtObserver( DvbPmtCallback );
1093 DestroySiq( setup.siqInstance );
1099 setup.allocFunc = config->memAlloc;
1100 setup.freeFunc = config->memFree;
1102 setup.errorFunc = dsmccErrorFunc;
1104 setup.startTimerFunc = StartTimerFunc;
1105 setup.stopTimerFunc = StopTimerFunc;
1116 setup.notifyCarouselLoadEventFunc = config->carouselLoad;
1118 setup.notifyStreamEventFunc = DsmccStreamEventFunc;
1119 setup.progressFunc = NULL;
1120 setup.dsmControl = dsmctrl;
1122 setup.ssuFuncs = config->ssuFuncs;
1125 setup.memMgrSetup = NULL;
1126 setup.maxAvailableSectionFilters = NUM_SECTION_FILTERS_DEFAULT;
1127 setup.timeUnitResolution = TIMER_RESOLUTION;
1128 setup.storeSIQueryResults = TRUE;
1129 setup.turboCaching = (config->controlFlags & DISABLE_AUTO_CACHING_FLAG) ? FALSE : TRUE;
1130 setup.multipleSsuDownloads = FALSE;
1131 setup.notifyDeferredServiceFunc = NULL;
1132 setup.maxMemorySize = DSMCC_DEFAULT_CACHE_SIZE;
1134 cldsmErr = CDSM_SysCreate( &setup, &cldsm, &memContext );
1136 if (cldsmErr == CLDSM_OK)
1140 dsmctrl->api.cldsm = cldsm;
1141 dsmctrl->sfm = setup.sfmInstance;
1142 dsmctrl->siq = setup.siqInstance;
1143 dsmctrl->debugMask = gDebugState;
1148 DestroySfm( setup.sfmInstance );
1149 if (!(config->controlFlags & GET_PMT_DIRECT_FROM_HW_FLAG) &&
1150 !UsingPmtsFromDvb())
1152 STB_SIUnregisterPmtObserver( DvbPmtCallback );
1154 DestroySiq( setup.siqInstance );
1162 static void DestroyDsmcc( S_DsmControl *dsmctrl )
1164 E_DscError err = CLDSM_OK;
1171 ERRPRINT(
"err=%d", err)
1173 err =
CDSM_SysDestroy(dsmctrl->api.cldsm, &siqInstance, &sfmInstance);
1174 if (err == CLDSM_OK)
1176 dsmctrl->api.cldsm = NULL;
1178 ASSERT(dsmctrl->sfm == sfmInstance);
1179 dsmctrl->sfm = NULL;
1180 DestroySfm( sfmInstance );
1182 ASSERT(dsmctrl->siq == siqInstance);
1183 dsmctrl->siq = NULL;
1184 DestroySiq( siqInstance );
1186 if (dsmctrl->dsi != NULL)
1188 DestroyDsi( dsmctrl );
1190 else if (!UsingPmtsFromDvb())
1192 STB_SIUnregisterPmtObserver( DvbPmtCallback );
1197 ERRPRINT(
"err=%d", err)
1205 static void DestroySecBuff( H_SbmInstance sbm )
1219 static H_SbmInstance CreateSecBuff( S_DsmControl *dsmctrl, U16BIT size )
1224 if (setup.mtx_sem == NULL)
1231 setup.memAlloc = dsmctrl->api.memAlloc;
1232 setup.memFree = dsmctrl->api.memFree;
1235 setup.bufferSize = ((size + 15) >> 4);
1249 static void DestoryResources( S_DsmControl *dsmctrl )
1252 if (dsmctrl->sbm != NULL)
1254 DestroySecBuff( dsmctrl->sbm );
1255 dsmctrl->sbm = NULL;
1257 for (i = 0; i != QP_TOTAL; i++)
1259 if (dsmctrl->queues[i].mutex != NULL)
1264 if (dsmctrl->q_count_sema != NULL)
1267 dsmctrl->q_count_sema = NULL;
1269 if (dsmctrl->timerMtx != NULL)
1272 dsmctrl->timerMtx = NULL;
1274 if (dsmctrl->api.mutex != NULL)
1277 dsmctrl->api.mutex = NULL;
1281 static BOOLEAN CreateResources( S_DsmControl *dsmctrl, U16BIT size )
1287 if (dsmctrl->api.mutex == NULL)
1295 if (dsmctrl->timerMtx == NULL)
1298 dsmctrl->api.mutex = NULL;
1305 if (dsmctrl->q_count_sema == NULL)
1313 pmsg = (S_Message *)(dsmctrl + 1);
1314 for (i = 0; i != QP_TOTAL; i++)
1317 if (dsmctrl->queues[i].mutex == NULL)
1323 dsmctrl->queues[i].begin = pmsg;
1324 dsmctrl->queues[i].write = pmsg;
1325 dsmctrl->queues[i].read = pmsg;
1326 pmsg += size * (i + 1);
1327 dsmctrl->queues[i].ends = pmsg;
1329 if (i == QP_TOTAL && !CreateSecBuff(dsmctrl, size))
1336 DestoryResources(dsmctrl);
1343 static BOOLEAN DsmStart( H_DsmControl dsmctrl, U16BIT serviceId, U32BIT couId, U8BIT sikind )
1346 BOOLEAN result = FALSE;
1348 dsmctrl->carousel = NULL;
1349 dsmctrl->restart = 0;
1350 dsmctrl->counter = 0;
1351 dsmctrl->sikind = sikind;
1352 dsmctrl->status = (U8BIT)BL_BOOTING;
1354 if (sikind == SIQUERY_SSU_PID)
1362 if (err == CLDSM_OK)
1365 (E_SIQueryKind)sikind, &dsmctrl->carousel );
1366 if (err == CLDSM_OK)
1368 DBGPRINT(DM_CONTROL,
"OK %p", dsmctrl)
1370 dsmctrl->status = (U8BIT)BL_LOADED;
1372 else if (err != CLDSM_ERR_SI_QUERY_FAILED || couId != INVALID_CAROUSEL_ID)
1374 ERRPRINT(
"err=%d", err)
1376 dsmctrl->status = (U8BIT)BL_FAILED;
1380 if (err == CLDSM_ERR_SI_QUERY_FAILED && couId == INVALID_CAROUSEL_ID)
1383 DBGPRINT(DM_CONTROL,
"Schedule re-start %p", dsmctrl)
1384 dsmctrl->status = (U16BIT)BL_FAILED;
1386 StartTimer(dsmctrl, START_MAGIC, RESTART_TIME, th.ptr, &th.ptr);
1387 dsmctrl->restart = th.u32;
1393 static
void DsmRestart( H_DsmControl dsmctrl, U16BIT serviceId )
1397 dsmctrl->restart = 0;
1399 sid = CDSM_SysCurrServiceId(dsmctrl->api.cldsm);
1400 if (sid != serviceId)
1402 err = CLDSM_ERR_NO_CURRENT_SERVICE_SET;
1406 err = CLDSM_ERR_CAROUSELS_STILL_LOADED;
1411 SIQUERY_BOOT_CAROUSEL, &dsmctrl->carousel );
1412 if (err == CLDSM_OK)
1414 DBGPRINT(DM_CONTROL,
"srvId=%d", serviceId)
1415 dsmctrl->status = (U8BIT)BL_LOADED;
1417 else if (err == CLDSM_ERR_SI_QUERY_FAILED)
1419 DBGPRINT(DM_CONTROL,
"srvId=%d err=%d", serviceId, err)
1423 ERRPRINT(
"srvId=%d err=%d", serviceId, err)
1427 if (err == CLDSM_ERR_SI_QUERY_FAILED)
1431 StartTimer(dsmctrl, START_MAGIC, RESTART_TIME, th.ptr, &th.ptr);
1432 dsmctrl->restart = th.u32;
1436 static BOOLEAN DsiStart( H_DsmControl dsmctrl, U16BIT serviceId, U32BIT couId, U8BIT sikind )
1440 DBGPRINT(DM_CONTROL,
"%p sid=%d", dsmctrl, serviceId)
1442 ASSERT(dsmctrl->dsi);
1444 dsmctrl->serviceId = serviceId;
1445 dsmctrl->couId = couId;
1446 dsmctrl->sikind = sikind;
1447 dsmctrl->status = (U8BIT)BL_WAITING;
1448 result =
DSI_Start( dsmctrl->dsi, dsmctrl->transId, dsmctrl->dmxref );
1453 while (dsmctrl->status == (U8BIT)BL_WAITING || dsmctrl->status == (U8BIT)BL_BOOTING)
1460 result = (dsmctrl->status == (U8BIT)BL_LOADED) ? TRUE : FALSE;
1472 static void DebugInstanceSetMask(H_DsmControl dsmctrl, U32BIT mask)
1474 FUNCTION_START(DebugInstanceSetMask)
1475 if (dsmctrl->debugMask != mask)
1477 ERRPRINT(
"dsmctrl %p; mask %x",dsmctrl,mask)
1478 dsmctrl->debugMask = mask;
1480 #if DSM_DP_LEVEL >= 2
1486 (F_Printf)STB_SPDebugNoCnWrite,
1490 (F_Printf)STB_SPDebugNoCnWrite,
1494 FUNCTION_FINISH(DebugInstanceSetMask)
1509 S_DsmControl *dsmctrl;
1510 U16BIT i, msz, size;
1511 size = config->sectionBuffPoolSize;
1512 size *=
sizeof(S_Message);
1513 for (i = 1, msz = 0; i != (QP_TOTAL + 1); i++)
1517 dsmctrl = config->memAlloc(
sizeof(S_DsmControl) + msz);
1518 if (dsmctrl != NULL)
1520 memset(dsmctrl, 0,
sizeof(S_DsmControl));
1521 dsmctrl->api.memAlloc = config->memAlloc;
1522 dsmctrl->api.memFree = config->memFree;
1523 if (!CreateResources(dsmctrl, config->sectionBuffPoolSize))
1526 config->memFree( dsmctrl );
1529 else if ((config->controlFlags & GET_PMT_DIRECT_FROM_HW_FLAG) &&
1530 !CreateDsi(dsmctrl, config))
1533 DestoryResources( dsmctrl );
1534 config->memFree( dsmctrl );
1537 else if (!CreateDsmcc(dsmctrl, config))
1540 if (config->controlFlags & GET_PMT_DIRECT_FROM_HW_FLAG)
1542 DestroyDsi( dsmctrl );
1544 else if (!UsingPmtsFromDvb())
1546 STB_SIUnregisterPmtObserver( DvbPmtCallback );
1548 DestoryResources( dsmctrl );
1549 config->memFree( dsmctrl );
1554 dsmctrl->task =
STB_OSCreateTask( DsmMain, (
void *)dsmctrl, MAIN_STACK_SIZE,
1555 (U8BIT)config->taskPriority, (U8BIT *)
"DsmMain" );
1558 DBGPRINT(DM_CONTROL,
"OK %p", dsmctrl)
1559 dsmctrl->next = instanceHead;
1560 instanceHead = dsmctrl;
1565 DestroyDsmcc( dsmctrl );
1566 DestoryResources( dsmctrl );
1567 config->memFree( dsmctrl );
1583 S_DsmControl **pDsmctrl;
1584 if (dsmctrl != NULL)
1586 pDsmctrl = &instanceHead;
1587 while (*pDsmctrl != NULL)
1589 if (*pDsmctrl == dsmctrl)
1591 DBGPRINT(DM_CONTROL,
"%p", dsmctrl)
1594 emsg.type = DSM_MSG_CLOSE_DOWN;
1595 while (!QueueWrite(dsmctrl->queues + QP_TOP, &emsg))
1600 while (dsmctrl->task != NULL)
1604 *pDsmctrl = dsmctrl->next;
1605 DestroyDsmcc( dsmctrl );
1606 DestoryResources( dsmctrl );
1607 dsmctrl->api.memFree( dsmctrl );
1610 pDsmctrl = &((*pDsmctrl)->next);
1637 U32BIT boot_carousel_id, DMXREF dmxref )
1640 locator->transport_stream_id, dmxref );
1641 return DSMCC_StartFs( dsmctrl, locator->service_id, boot_carousel_id );
1654 U16BIT tran_id, DMXREF dmxref )
1656 DBGPRINT(DM_CONTROL,
"%p onet=%x tran=%x dmx=%x",
1657 dsmctrl, onet_id, tran_id, dmxref)
1660 dsmctrl->dmxref = dmxref;
1661 dsmctrl->transId = tran_id;
1662 dsmctrl->networkId = onet_id;
1688 BOOLEAN
DSMCC_StartFs( H_DsmControl dsmctrl, U16BIT service_id, U32BIT carousel_id )
1692 DBGPRINT(DM_CONTROL,
"%p sid=%d cid=%d", dsmctrl, service_id, carousel_id)
1693 switch (carousel_id)
1695 case INVALID_CAROUSEL_ID:
1696 sikind = (U8BIT)SIQUERY_BOOT_CAROUSEL;
1699 case UNKNOWN_CAROUSEL_ID:
1700 sikind = (U8BIT)SIQUERY_FIND_CAROUSEL;
1704 sikind = (U8BIT)SIQUERY_CAROUSEL;
1706 if (service_id == CDSM_SysCurrServiceId( dsmctrl->api.cldsm ))
1708 ERRPRINT(
"%p already on service Id=%d", dsmctrl, service_id)
1711 else if (dsmctrl->dsi)
1713 result = DsiStart( dsmctrl, service_id, carousel_id, sikind );
1717 result = DsmStart( dsmctrl, service_id, carousel_id, sikind );
1735 DBGPRINT(DM_CONTROL,
"%p sid=%d oui=%x", dsmctrl, service_id, oui)
1736 if (service_id == CDSM_SysCurrServiceId( dsmctrl->api.cldsm ))
1738 ERRPRINT(
"%p already on service Id=%d", dsmctrl, service_id)
1741 else if (dsmctrl->dsi)
1743 result = DsiStart( dsmctrl, service_id, oui, (U8BIT)SIQUERY_SSU_CAROUSEL );
1747 result = DsmStart( dsmctrl, service_id, oui, (U8BIT)SIQUERY_SSU_CAROUSEL );
1765 DBGPRINT(DM_CONTROL,
"%p pid=%d oui=%x", dsmctrl, pid, oui)
1768 result = DsiStart( dsmctrl, pid, oui, (U8BIT)SIQUERY_SSU_PID );
1772 result = DsmStart( dsmctrl, pid, oui, (U8BIT)SIQUERY_SSU_PID );
1789 DBGPRINT(DM_CONTROL,
"%p sid=%d boot_crsl=%p curr_crsl=%p", dsmctrl,
1790 CDSM_SysCurrServiceId(dsmctrl->api.cldsm),
1793 if (dsmctrl->carousel != NULL)
1797 if (err != CLDSM_OK)
1799 ERRPRINT(
"err=%d", err)
1802 if (dsmctrl->status != (U8BIT)BL_WAITING && dsmctrl->restart != 0)
1804 StopTimer( dsmctrl, dsmctrl->restart );
1805 dsmctrl->restart = 0;
1808 if (err != CLDSM_OK)
1810 ERRPRINT(
"err=%d", err)
1813 if (err != CLDSM_OK)
1815 ERRPRINT(
"err=%d", err)
1819 dsmctrl->status = (U8BIT)BL_WAITING;
1839 if (dsmctrl->status != (U16BIT)BL_WAITING && dsmctrl->restart != 0)
1841 StopTimer( dsmctrl, dsmctrl->restart );
1842 dsmctrl->restart = 0;
1845 serviceId = CDSM_SysCurrServiceId( dsmctrl->api.cldsm );
1848 err = CLDSM_ERR_NO_CURRENT_SERVICE_SET;
1849 ERRPRINT(
"%p serviceId=%d", dsmctrl, serviceId)
1854 DBGPRINT(DM_CONTROL,
"%p sid=%d c_crsl=%p", dsmctrl, serviceId, hOC)
1858 if (err != CLDSM_OK)
1860 ERRPRINT(
"err=%d", err)
1865 SIQUERY_BOOT_CAROUSEL, &dsmctrl->carousel );
1866 if (err != CLDSM_OK)
1868 ERRPRINT(
"err=%d", err)
1872 if (err == CLDSM_ERR_SI_QUERY_FAILED)
1875 dsmctrl->status = (U16BIT)BL_FAILED;
1877 StartTimer(dsmctrl, START_MAGIC, RESTART_TIME, th.ptr, &th.ptr);
1878 dsmctrl->restart = th.u32;
1926 DBGPRINT(DM_CONTROL,
"%p c_crsl=%p", dsmctrl, hOC)
1948 DBGPRINT(DM_CONTROL,
"crsl=%p mode=%d", hOC, mode)
1952 if (err != CLDSM_OK)
1954 ERRPRINT(
"Unload Carousel err %d", err)
1974 DBGPRINT(DM_CONTROL,
"crsl=%p", hCarousel)
1978 if (err != CLDSM_OK)
1980 ERRPRINT(
"Unload Carousel err %d", err)
2010 DBGPRINT(DM_CONTROL,
"sid=%d", serviceId)
2022 return DSMCC_VER_STRING;
2033 S_DsmControl *dsmctrl;
2035 dsmctrl = instanceHead;
2036 while (dsmctrl != NULL)
2038 if (dsmctrl->dmxref == dmxref && CDSM_SysCurrServiceId(dsmctrl->api.cldsm) == serviceId)
2042 dsmctrl = dsmctrl->next;
2069 S_DsmControl *dsmctrl;
2075 dsmctrl = instanceHead;
2076 while (dsmctrl != NULL)
2078 DebugInstanceSetMask(dsmctrl, mask);
2079 dsmctrl = dsmctrl->next;
2083 USE_UNWANTED_PARAM(mask);
2087 U32BIT DebugInstanceGetMask(H_DsmControl dsmctrl)
2089 return dsmctrl->debugMask;
2100 S_DsmControl *dsmctrl;
2101 dsmctrl = instanceHead;
2102 while (dsmctrl != NULL)
2104 if (dsmctrl == instance)
2106 return dsmctrl->debugMask;
2108 dsmctrl = dsmctrl->next;
2111 USE_UNWANTED_PARAM(instance);
2125 S_DsmControl *dsmctrl;
2128 ERRPRINT(
"(instance %p, mask %x)",instance, mask)
2129 dsmctrl = instanceHead;
2130 while (dsmctrl != NULL)
2132 if (dsmctrl == instance)
2134 DebugInstanceSetMask(dsmctrl, mask);
2137 dsmctrl = dsmctrl->next;
2141 USE_UNWANTED_PARAM(instance);
2142 USE_UNWANTED_PARAM(mask);
2156 #if defined(NDEBUG) && defined(DEBUG_USE_GETENV)
2162 strcpy(envname,rootname);
2163 mskptr = envname + strlen(rootname);
2165 mask = dsmctrl->debugMask;
2167 GETENV_DSMDBG(DD_GEN )
2168 GETENV_DSMDBG(DD_OC )
2169 GETENV_DSMDBG(DD_SF )
2170 GETENV_DSMDBG(DD_TIMER )
2171 GETENV_DSMDBG(DD_SE )
2172 GETENV_DSMDBG(DD_LM )
2173 GETENV_DSMDBG(DD_OBJ )
2174 GETENV_DSMDBG(DD_DC )
2175 GETENV_DSMDBG(DD_QUERY )
2176 GETENV_DSMDBG(DD_MOD )
2177 GETENV_DSMDBG(DD_ALL )
2178 GETENV_DSMDBG(DS_MAIN )
2179 GETENV_DSMDBG(DS_QUERY )
2180 GETENV_DSMDBG(DS_CACHE )
2181 GETENV_DSMDBG(DS_PMT )
2182 GETENV_DSMDBG(DS_PAT )
2183 GETENV_DSMDBG(DS_FUNC )
2184 GETENV_DSMDBG(DS_ALL )
2185 GETENV_DSMDBG(DF_MAIN )
2186 GETENV_DSMDBG(DF_FILTER )
2187 GETENV_DSMDBG(DF_CACHE )
2188 GETENV_DSMDBG(DF_HWSF )
2189 GETENV_DSMDBG(DF_ALL )
2190 GETENV_DSMDBG(DM_SI )
2191 GETENV_DSMDBG(DM_CONTROL)
2192 GETENV_DSMDBG(DM_CLIENT )
2193 DBGPRINT(DM_CONTROL,
"mask=%x",mask)
2194 DebugInstanceSetMask(dsmctrl, mask);
2196 USE_UNWANTED_PARAM(dsmctrl);
2197 USE_UNWANTED_PARAM(rootname);
U32BIT STB_OSGetClockMilliseconds(void)
Get Current Computer Clock Time.
void SIQ_ServiceRemoved(H_SiqInstance siq, U16BIT serviceId)
Inform SIQ when a service has been removed from PAT. Not required if PAT is supplied to SIQ...
void * SFM_DsmccFilterAdd(H_SfmInstance sfm, P_SecFilter pFilter, H_DscSFRef dsmSfRef)
Add DSM-CC section filter. Called by DSM-CC component, and given in clDsmSysCreate setup...
DSM-CC API functions to control DSM-CC instance.
void SFM_CacheClear(H_SfmInstance sfm)
Clear all SFM cached section data. Not required to be called, if setup had sectionBuffCacheSize set t...
E_DscError CDSM_GetCarouselId(H_DsmCoreInst instance, H_DsmCarousel carouselHandle, U32BIT *pCarouselId)
Retrieve Carousel Id for the loaded DSM-CC Object Carousel.
void SIQ_ServiceInfoChangeUnsubscribe(H_SiqInstance siq, U16BIT serviceId)
Unsubscribe component to previously subscribed service change or alteration updates. Called by DSM-CC component, and given in clDsmSysCreate setup.
BOOLEAN STB_DMXCopyPIDFilterSect(DMXREF dmx, U8BIT *buffer, U16BIT size, PIDFILT pfid)
Copies a filtered section to caller's buffer.
void SFM_SetDsmInstance(H_SfmInstance sfm, H_DsmCoreInst dsmcc)
Set instance handle for DSM-CC that SFM is supporting.
void SIQ_RequestQueryStop(H_SiqInstance siq, void *queryHandle, H_SIQueryRef clDsmSIQueryRef)
Stop DSM-CC query request. Called by DSM-CC component, and given in clDsmSysCreate setup...
E_SFM_STATUS SFM_RequireSection(H_SfmInstance sfm, PIDFILT pfid, U8BIT *pHeader, void **phBuffer)
This function performs minimal checking of section header data to find out whether SFM requires this ...
void STB_OSTaskDelay(U16BIT timeout)
Delay Task for Specifed Time Period.
void DSMCC_DebugSetMask(U32BIT mask)
Set the DSMCC debug mask.
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.
H_DsmCarousel CDSM_CurrentCarousel(H_DsmCoreInst instance)
Retrieve handle to the current carousel for DSM-CC Instance.
Internal header for DSM-CC si support.
void STB_OSDeleteMutex(void *mutex)
Delete a mutex.
void SFM_DsmccFilterDelete(H_SfmInstance sfm, void *filterHandle, H_DscSFRef dsmSfRef)
Delete DSM-CC section filter. Called by DSM-CC component, and given in clDsmSysCreate setup...
BOOLEAN DSI_RequireTable(H_DsiInstance dsi, U8BIT *hdr, U16BIT *pXid, U8BIT *pVer)
Check whether SI table section data is required.
U8BIT * SBM_AllocateBuffer(H_SbmInstance sbm, U8BIT size1)
Allocate buffer for a DVB section.
H_SiqInstance SIQ_CreateInstance(S_SiqSetup *pSetup)
Create SIQ instance.
E_DscError CDSM_SetCurrentCarousel(H_DsmCoreInst instance, H_DsmCarousel carouselHandle)
Sets current carousel for DSM-CC Instance.
H_ObjCarousel DSMCC_CurrentCarousel(H_DsmControl dsmctrl)
Get currently loaded carousel handle.
BOOLEAN DSMCC_Start(H_DsmControl dsmctrl, S_DvbLocator *locator, U32BIT boot_carousel_id, DMXREF dmxref)
Start DSM-CC controling instance. This will start search for a boot carousel on service specified by ...
BOOLEAN DSMCC_StartFs(H_DsmControl dsmctrl, U16BIT service_id, U32BIT carousel_id)
Start DSM-CC controlling instance. This must follow call to DSMCC_SetTunedTransportInfo. The function will start search for an Object Carousel on the specified service. The search depends on the value given 'carousel_id' parameter. When carousel id is set to INVALID_CAROUSEL_ID, DSM-CC will attempt to start on a carousel which the client recognises in callback function 'parseDataBroadcastId'. Even when the PMT does not contain a recognised data broadcast id, this function will return TRUE, and the DSM-CC will keep searching. When the carousel id is set to a specific value or UNKNOWN_CAROUSEL_ID and a carousel of the required ID is not present, either this function will return FALSE or 'carouselLoad' callback will be passed a result of OC_LOAD_ABORTED_ERROR. When carousel id is set to UNKNOWN_CAROUSEL_ID, DSM-CC will attempt to start on whatever carousel is signalled in PMT for that service.
void SIQ_TransportChanged(H_SiqInstance siq, U16BIT origNetworkId, U16BIT transportId)
Inform SIQ when tuning to another transport stream. Not required if PAT is supplied to SIQ...
void SFM_DsmccFilterPriorityChange(H_SfmInstance sfm, void *filterHandle, H_DscSFRef dsmSfRef, E_SFPriority priority)
Change DSM-CC section filter priority Called by DSM-CC component, and given in clDsmSysCreate setup...
H_SbmInstance SBM_CreateInstance(S_SbmSetup *pSetup)
Create Section Buffer Manager instance, using setup structure.
E_DscError CDSM_SysProcessTimerEvent(H_DsmCoreInst instance, void *clDsmTmrUserData, E_TimerStatus status, void *timerHandle)
void DSI_CancelTable(H_DsiInstance dsi, U32BIT rid)
Cancel request for table data made by DSI_RequestTable()
void DSMCC_SetTunedTransportInfo(H_DsmControl dsmctrl, U16BIT onet_id, U16BIT tran_id, DMXREF dmxref)
Inform DSMCC instance of the tuned transport details. This must be called before calling DSMCC_StartF...
void SFM_SetDemuxHandle(H_SfmInstance sfm, DMXREF demux)
Set handle to be passed to F_DvpFilterSetup and F_DvpFilterRemove.
E_DscError CDSM_UnloadModule(H_DsmCoreInst idp, H_DsmCarousel hCarousel, U32BIT moduleRef)
Unload SSU module. To be called once the client has finished saving this module data.
Internal header for DSM-CC control module.
U8BIT * SFM_CacheBuffer(H_SfmInstance sfm, void *hBuffer)
Get section data buffer pointer in SFM's cache for the handle. This should only be called after SFM_R...
void SFM_DestroyInstance(H_SfmInstance sfm, void **pSfmMtx, void **pCchMtx, void **pBufMtx)
Destroy Section Filter Manager instance, and return mutexes so that they may be destroyed by client...
BOOLEAN DSMCC_StartSsu(H_DsmControl dsmctrl, U16BIT service_id, U32BIT oui)
Start DSM-CC controling instance. This must follow call to DSMCC_SetTunedTransportInfo. The function will start loading Update Carousel for SSU on specified service.
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 SIQ_SetDebugConfig(H_SiqInstance siq, F_Printf errPrintf, F_Printf dbgPrintf, U32BIT dbgState)
Set Debug config for SIQ.
void STB_OSMutexUnlock(void *mutex)
Unlock a mutex (a.k.a. 'leave', 'signal' or 'release')
E_DscError CDSM_LoadCarousel(H_DsmCoreInst instance, U16BIT service_id, U32BIT carousel_id, E_SIQueryKind kind, H_DsmCarousel *pclDsmCarouselHandle)
Request load of a DSM-CC Object Carousel (service domain).
H_SfmInstance SFM_CreateInstance(S_SfmSetup *pSetup)
Create Section Filter Manager instance, using setup structure.
void SIQ_ProcessPmt(H_SiqInstance siq, H_SiqPmtTable hNewTable, U16BIT serviceId, U8BIT version)
Provide PMT section data to SIQ. It assumes CRC has been checked and is passing valid PMT sections So...
void SFM_FilterUpdate(H_SfmInstance sfm, H_DmxPidFilter hPF)
Update SFM PID filter to configure HW for latest requirements.
void SIQ_SetDebugState(H_SiqInstance siq, U32BIT dbgState)
Set Debug state for SIQ.
Dsmcc's Section Filter Manager API.
U32BIT DSMCC_DebugInstanceGetMask(H_DsmControl instance)
Get the DSMCC debug mask for instance.
H_DsmControl DSMCC_Open(S_DsmccConfig *config)
Open DSM-CC and create controling instance.
void SBM_DestroyInstance(H_SbmInstance sbm, void **pBufMtx)
Destroy Section Filter Manager instance, and return mutexes so that they may be destroyed by client...
H_DsmControl DSMCC_FindInstance(U16BIT serviceId, DMXREF dmxref)
Find DSMCC instance that has beed started on specified service.
void DSMCC_SetFileSystemCacheLimit(H_DsmControl dsmctrl, U32BIT cacheSize)
Set limit of DSMCC dynamic memory usage for file system caching This function overrides the default s...
void * STB_OSCreateMutex(void)
Create a mutex.
Main API to DSM-CC core layer (provided functions and required callbacks).
void CDSM_SysSetMemoryMax(H_DsmCoreInst instance, U32BIT maxMemory)
Set maximum memory usage.
void SBM_ReleaseBuffer(H_SbmInstance sbm, U8BIT *buffer)
Release DVB section buffer allocated with SBM_AllocateBuffer.
E_DscError CDSM_UnloadCarousel(H_DsmCoreInst instance, H_DsmCarousel clDsmCarouselHandle, E_DsmRstMode mode)
Unload (or cancel the requested load of) a DSM-CC Object Carousel (service domain). The client MUST first unload all objects before calling this function (which implies it must also have previously closed and/or unsubscribed any events on any loaded objects). If there are any active object loads in the carousel when clDsmUnloadCarousel is called then the unload will not be executed and an error returned. If the carousel is in the process of loading and/or booting the load operation will be aborted (and the notifyCarouselLoadEventFunc callback made with status OC_LOAD_ABORTED_UNLOAD). Any carousel load request that returned a valid CDSM_CarouselHandle(ie. did not generate an error at clDsmLoadCarousel call time), must be explicitly unloaded via clDsmUnloadCarousel. This is necessary, whether the carousel was successfully loaded or the load was aborted due to timeout or error. Once unload is called for a carousel, the clDsmCarouselHandle is no longer valid and must not be used by the client/calling env. If it needs to access the carousel subsequently it must re-load it and get a new clDsmCarouselHandle value. To forcefully destroy loaded objects and/or carousels (eg. where the handles may be unknown/lost) then clDsmReset can be used with force switches. Note that this physically deletes them from the cache whereas unloading (objects or carousels) does not. CALLBACKS THAT MAY BE INITIATED DURING THIS CALL: delSectionFilterFunc stopTimerFunc stopSIQueryFunc unsubscribeSIChange notifyCarouselLoadEventFunc.
Section Buffer Manager (for use by Section Filter Manager and client) Provides mechanism to allocate ...
BOOLEAN STB_OSSemaphoreWaitTimeout(void *semaphore, U16BIT timeout)
Wait on Semaphore for Set Time Period in an Attempt to Acquire.
void DSMCC_SiqCacheClearPmt(H_DsmControl dsmctrl, U16BIT serviceId)
Clear cached PMT for particular service.
Dsmcc's Service Information Query API.
void DSMCC_Stop(H_DsmControl dsmctrl, E_DsmRstMode mode)
Stop DSM-CC controling instance. Causes all carousels to unload.
void DSMCC_DebugInstanceEnable(H_DsmControl dsmctrl, const char *rootname)
Enable DSMCC debug for an instance, by reading environment variables with name format: <rootname>_<ma...
H_SiqPmtTable SIQ_ParsePmt(H_SiqInstance siq, U8BIT *pmt)
Provide PMT section data to SIQ. It assumes CRC has been checked and is passing valid PMT sections So...
void SIQ_CacheClearPmt(H_SiqInstance siq, U16BIT serviceId)
Clear cached PMT information.
void SFM_CacheReleaseBuffer(H_SfmInstance sfm, U8BIT *pSection, void *hBuffer)
Release Cache buffer allocated by SFM_CacheBuffer.
BOOLEAN DSMCC_SetCurrentCarousel(H_DsmControl dsmctrl, H_ObjCarousel hOC)
Set current carousel. This does not unload any previously loaded carousels.
void SIQ_DestroyInstance(H_SiqInstance siq)
Destroy instance created by SIQ_CreateInstance.
void SIQ_UpdatePat(H_SiqInstance siq, U8BIT *dptr)
Provide SIQ with latest PAT data. Calling this function is optional. However, if not used...
void SFM_SetDebugConfig(H_SfmInstance sfm, F_Printf errPrintf, F_Printf dbgPrintf, U32BIT dbgState)
This allows controlling software to reconfigure SFM debug output.
void DSMCC_Reboot(H_DsmControl dsmctrl)
Reboot DSM-CC controling instance. Causes all carousels to unload and initiate search for boot carous...
E_DscError SIQ_ServiceInfoChangeSubscribe(H_SiqInstance siq, U16BIT serviceId)
Subscribe a component to receive notification of any changes or alterations to the service informatio...
void DSMCC_DebugInstanceSetMask(H_DsmControl instance, U32BIT mask)
Set the DSMCC debug mask.
void SFM_ProcessSection(H_SfmInstance sfm, U8BIT *pSection, void *hBuffer)
Process required section buffer. This should only be called after SFM_RequireSection has returned SFM...
E_DscError CDSM_SysSetCurrService(H_DsmCoreInst instance, U16BIT original_network_id, U16BIT transport_stream_id, U16BIT service_id)
Set/notify the current service (initially and when changing it). This MUST be called initially (ie...
void SIQ_SetDsmInstance(H_SiqInstance siq, H_DsmCoreInst dsm)
Set instance handle for DSM-CC that SIQ is supporting.
void STB_OSMutexLock(void *mutex)
Lock a mutex (a.k.a. 'enter', 'wait' or 'get').
void DsmccObjectLoadEventFunc(H_DsmObject objectHandle, E_ObjLoadStatus status, H_ObjUserData pUserData)
Callback function provided to DSM-CC library. Object load events are passed to this callback by the D...
U32BIT DSMCC_CurrentCarouselId(H_DsmControl dsmctrl)
Get currently loaded carousel ID.
void CDSM_SetPrintFuncs(F_Printf errorFunc, F_Printf warnFunc, F_Printf debugFunc, F_Printf infoFunc)
Sets debug print functions for four different levels of detail. Any of these parameters can be set to...
H_DsiInstance DSI_CreateInstance(H_DsmControl ctrl, F_FILTER_CALLBACK cbfunc, S_DsmccConfig *config)
Create instance of DSI.
E_SIQ_STATUS SIQ_RequirePmt(H_SiqInstance siq, U8BIT *pmt, U16BIT *pSid, U8BIT *pVer)
Ask SIQ whether PMT section data is required. It assumes CRC has been checked and is passing valid PM...
API to register PMT Observer with DVB SI task.
BOOLEAN DSMCC_StartSsuWithPid(H_DsmControl dsmctrl, U16BIT pid, U32BIT oui)
Start DSM-CC controling instance. This must follow call to DSMCC_SetTunedTransportInfo. The function will start loading Update Carousel for SSU on a single specified PID.
E_DscError CDSM_SysReset(H_DsmCoreInst instance, E_DsmRstMode mode)
Reset DSM-CC Core Layer instance. Resets conditions to the same state as after CDSM_SysCreate(ie. keeps setup parameters). In normal operation the client MUST first unsubscribe all events, close and and unload all objects and unload all carousels before calling this function. This will have also stopped/deleted all associated system resources (ie. SI queries, timers, SI change monitors, section filters). If any client transactions or system transactions are still active when clDsmReset is called the reset will not be executed and an error returned. NB. The calling environment (system side) must acknowledge stop commands for SI Queries and timers (via processSIQueryEvent, processTimerEvent) and that these may occur asynchronously (ie. after a delay). This means that there may still be some active system transactions for some time after all objects and carousels are unloaded. FORCING RESET IN ERROR CONDITIONS: If all client and system transactions are apparently completed but still returns an error (eg. because handles are unknown/lost or system resource stop requests are not acknowledged) then clDsmReset can be called with appropriate force switches to clear the error condition. Any client transaction errors must first be cleared before system transaction errors can be cleared and both force switches cannot be set at the same time. NB. Only use force switches in known error conditions. It is potentially fatal (may cause illegal memory access) to call the functions: streamEventUnsubscribe, unloadObject, unloadCarousel, processSIQueryEvent, processTimerEvent with old/stale handles after clDsmReset has been forced. CALLBACKS THAT MAY BE INITIATED DURING THIS CALL: deleteSectionFilter stopTimer stopSIQuery unsubscribeSIChange.
E_DscError CDSM_SysDestroy(H_DsmCoreInst instance, H_SiqInstance *pSiqInst, H_SfmInstance *pSfmInst)
Destroy DSM-CC Core Layer instance. De-allocates all 'static' memory used by the instance (via freeFu...
void DSMCC_Close(H_DsmControl dsmctrl)
Close DSM-CC controling instance, and destroy all resources.
const char * DSMCC_VersionString(void)
Returns version major.minor.patch as string.
void CDSM_SetDebugState(H_DsmCoreInst dsm, U32BIT dbgMask)
Set Debug mask for core DSM.
U32BIT(* F_DvpRequestTable)(void *ref, U16BIT pid, U16BIT xid, U8BIT tid)
SIQ requests table data - normally PMT, but could be UNT. Table data should be given to appropriate f...
void * STB_OSCreateTask(void(*function)(void *), void *param, U32BIT stack, U8BIT priority, U8BIT *name)
Create a New Task to the calling process. Upon success, the created task runs on its own stack...
void DSI_DestroyInstance(H_DsiInstance dsi)
Destroy instance created by SIQ_CreateInstance.
void DSMCC_UnloadCarousel(H_DsmControl dsmctrl, H_ObjCarousel hOC, E_DsmRstMode mode)
Unload specified Carousel.
void STB_SPDebugNoCnWrite(const char *format,...)
Writes debug string to the serial port without <CR><LF>
void * STB_OSCreateCountSemaphore(U32BIT value)
Create a counting semaphore.
void SFM_SetDebugState(H_SfmInstance sfm, U32BIT dbgState)
This allows controlling software to reconfigure SFM debug output.
BOOLEAN DSI_Start(H_DsiInstance dsi, U16BIT transId, DMXREF dmxref)
Start getting SI data from Demux.
void(* F_DvpCancelTable)(void *ref, U32BIT rid)
Cancel request for Table data made by F_DvpRequestTable()
void STB_OSDeleteSemaphore(void *semaphore)
Delete a Semaphore.
void CDSM_SetPrintState(U32BIT state)
Sets debug print state to select areas of debug.
E_DscError SIQ_RequestQueryStart(H_SiqInstance siq, P_SIQueryRequest pQuery, H_SIQueryRef clDsmSIQueryRef, void *clDsmSIUserData, P_SIQueryResult pResult)
Start DSM-CC query request. Called by DSM-CC component, and given in clDsmSysCreate setup...
void STB_OSSemaphoreSignal(void *semaphore)
Signal a Semaphore to Release it by decrementing its counter.
U32BIT DSMCC_DebugGetMask(void)
Get the DSMCC debug mask.
void DSMCC_SsuUnloadModule(H_DsmControl dsmctrl, H_DsmCarousel hCarousel, U32BIT moduleRef)
Unload SSU module. To be called once the client has finished saving this modules data. This is needed to.
Function prototypes for operating system.