dmx.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:36k
- #include <string.h>
- #include "stevt.h"
- #include "stsys.h"
- #include "stcommon.h"
- #include "stpti.h"
- #include "errors.h"
- #include "osp.h"
- #include "dmx.h"
- #include "stpti_hal.h"
- #include "appltype.h"
- #include "sti5105.h"
- #include "swconfig.h"
- #if defined(DUAL_DVR)
- #define KB_PTI_MAX_NUM 3
- #elif defined(PIP_SUPPORT)
- #define KB_PTI_MAX_NUM 2
- #else
- #define KB_PTI_MAX_NUM 1
- #endif
- /* STPTI */
- #define PTI_DEVICE STPTI_DEVICE_PTI_4
- #define PTI_TCDEVICEADDRESS (STPTI_DevicePtr_t)PTI_BASE_ADDRESS
- #define PTI_INTERRUPTNUMBER PTI_INTERRUPT
- #define PTI_SECTIONFILTERMODE STPTI_FILTER_OPERATING_MODE_32x8
- #define PTI_DVBTCLOADER STPTI_DVBTCLoaderUL
- #define PTIB_TCDEVICEADDRESS 0
- #define PTIB_INTERRUPTNUMBER 0
- #define DMX_SECTION_SIZE (4*1024)
- #if (KB_PTI_MAX_NUM==3)
- ST_DeviceName_t g_KB_PTIDeviceNameMultiple[KB_PTI_MAX_NUM] = {"PTI0","PTI1","PTI2"};
- #elif (KB_PTI_MAX_NUM==2)
- ST_DeviceName_t g_KB_PTIDeviceNameMultiple[KB_PTI_MAX_NUM] = {"PTI0","PTI1"};
- #else
- ST_DeviceName_t g_KB_PTIDeviceNameMultiple[KB_PTI_MAX_NUM] = {"PTI0"};
- #endif
- STPTI_Handle_t g_KB_PTIHandleMultiple[KB_PTI_MAX_NUM];
- #define DEFAULT_PTI (0)
- #define DMX_TOTAL_KEY_PAIRS (12) /* total number of key index */
- extern ST_Partition_t *NcachePartition; /* non-cached partition */
- extern ST_Partition_t *SystemPartition; /* general partition */
- typedef struct
- {
- BOOL Allocated; /* indicates whether channel is allocated */
- BOOL Started; /* indicates whether channel is started */
- BOOL InternalUnlock; /* indicates whether channel data is released internal */
- KB_DMXChannelType Type; /* channel type enumeration */
- STPTI_Slot_t SlotHandle; /* Slot handle */
- STPTI_Pid_t Pid; /* PID */
- STPTI_Buffer_t BufferHandle; /* PTI Destination Buffer handle */
- UINT32 BufferSize; /* PTI Destination Buffer size */
- UINT8 *UserBuffer_p; /* User Buffer */
- UINT32 UserBufferSize; /* User Buffer */
- STPTI_Signal_t SignalHandle; /* PTI Destination Signal handle */
- STPTI_Descrambler_t DescramblerHandle; /* The ID of the descrambler currently used */
- KB_DMX_NotifyFunc NotifyFunctionPtr;
-
- }DMX_Channel;
- /*********************** Use generic slots *********************/
- const STPTI_SlotType_t STPTI_SlotTypes[] =
- {
- STPTI_SLOT_TYPE_NULL, /* Invalid */
- STPTI_SLOT_TYPE_PES, /* GENERIC_PES */
- STPTI_SLOT_TYPE_SECTION,/* SECTION */
- STPTI_SLOT_TYPE_EMM, /* EMM */
- STPTI_SLOT_TYPE_ECM, /* ECM */
- STPTI_SLOT_TYPE_RAW, /* RAW */
- };
- typedef struct _backdata{
- UINT32 channelID;
- UINT32 filterID;
- }BackData;
- #define BACKDATA_N 500
- static BackData g_backdata[BACKDATA_N];
- #define BACKID_N 100
- //static UINT32 g_backid[BACKID_N];
- #define EXM_BUFF_LEN 1024
- static STPTI_Signal_t g_SignalHandle_for_TF;
- static UINT8 Exm_Buf[EXM_BUFF_LEN];
- static DMX_Channel gChnnlInfo[KB_DMX_TOTAL_GENERIC_CHANNELS];
- static STPTI_Signal_t gSinHandle;
- extern ST_Partition_t *DemuxPartition;
- static UINT8 *Dmx_Buf;
- static void Dmx_Task(void *params);
- static INT32 KD_DmxAllocateBuf(UINT32 channelID, UINT32 bufferSize);
- static void* KD_DMXAllocate(UINT32 size);
- static void KD_DMXFree(void *ptr);
- /* Semaphore for protect channel operation */
- static UINT32 Dmx_SemLock;
- /* get the first empty channel */
- static INT32 GetFirstEmptyChannelID(void)
- {
- INT32 i;
- for(i = 0; i < KB_DMX_TOTAL_GENERIC_CHANNELS; i++)
- {
- if(gChnnlInfo[i].Allocated == FALSE)
- {
- break;
- }
- }
- return i;
- }
- static void Dmx_Task(void *params)
- {
- ST_ErrorCode_t ST_ErrorCode;
- STPTI_Buffer_t WhichBufferGotSignal;
- DMX_Channel *pChInfo;
-
- UINT32 DataSize;
- U32 NumFilterMatches = 0;
- BOOL CRCValid;
- INT32 chId;
-
- while(1)
- {
- ST_ErrorCode = STPTI_SignalWaitBuffer(gSinHandle, &WhichBufferGotSignal, STPTI_TIMEOUT_INFINITY);
- /* STPTI_SignalWaitBuffer() generated an error */
- if (ST_ErrorCode == ST_ERROR_TIMEOUT)
- {
- continue;
- }
- /* if not a harmless timeout then get rid of anything in the STPTI internal buffer */
- else if (ST_ErrorCode != ST_NO_ERROR)
- {
- STPTI_BufferFlush(WhichBufferGotSignal);
- continue;
- }
- /* Find the channel, that buffer handle equal WhichBufferGotSignal */
- for(chId = 0; chId < KB_DMX_TOTAL_GENERIC_CHANNELS; chId++)
- {
- if( (gChnnlInfo[chId].Allocated == TRUE)
- && (gChnnlInfo[chId].BufferHandle == WhichBufferGotSignal) )
- {
- /* got it */
- break;
- }
- }
- if(chId >= KB_DMX_TOTAL_GENERIC_CHANNELS)
- {
- STPTI_BufferFlush(WhichBufferGotSignal);
- continue;
- }
- KB_OSPSemGet(Dmx_SemLock, KB_Wait, 0);
-
- pChInfo = &gChnnlInfo[chId];
- DataSize = 0;
- Dmx_Buf = KD_DMXAllocate(DMX_SECTION_SIZE);
- if(Dmx_Buf == NULL)
- {
- DBGPrint("Dmx_Buf == NULLn");
- KB_OSPSemSet(Dmx_SemLock);
- continue;
- }
-
- switch(STPTI_SlotTypes[pChInfo->Type])
- {
- case STPTI_SLOT_TYPE_PES:
- #ifdef STPTI_DVB_SUPPORT
- ST_ErrorCode = STPTI_BufferReadPes(pChInfo->BufferHandle, (U8*)Dmx_Buf, (U32)DMX_SECTION_SIZE,
- NULL, 0, (U32*)&DataSize,
- STPTI_COPY_TRANSFER_BY_MEMCPY);
- #else
- STPTI_BufferFlush(WhichBufferGotSignal);
- KD_DMXFree(Dmx_Buf);
- KB_OSPSemSet(Dmx_SemLock);
- continue;
- #endif
- break;
-
- case STPTI_SLOT_TYPE_SECTION: /* three type are same: section */
- case STPTI_SLOT_TYPE_EMM:
- case STPTI_SLOT_TYPE_ECM:
- ST_ErrorCode = STPTI_BufferReadSection(pChInfo->BufferHandle, NULL, 0, &NumFilterMatches, &CRCValid,
- (U8*)Dmx_Buf, (U32)DMX_SECTION_SIZE, NULL, 0,
- (U32*)&DataSize, STPTI_COPY_TRANSFER_BY_MEMCPY);
- break;
-
- case STPTI_SLOT_TYPE_RAW:
- ST_ErrorCode = STPTI_BufferReadTSPacket(pChInfo->BufferHandle, (U8*)Dmx_Buf, (U32)DMX_SECTION_SIZE,
- NULL, 0, (U32*)&DataSize,
- STPTI_COPY_TRANSFER_BY_MEMCPY);
- break;
- default:
- /* do no support type */
- STPTI_BufferFlush(WhichBufferGotSignal);
- KD_DMXFree(Dmx_Buf);
- KB_OSPSemSet(Dmx_SemLock);
- continue;
- break;
- }
-
- if (ST_ErrorCode != ST_NO_ERROR) /* unexpected fault reading data */
- {
- STPTI_BufferFlush(WhichBufferGotSignal);
- KD_DMXFree(Dmx_Buf);
- KB_OSPSemSet(Dmx_SemLock);
- continue;
- }
- if(DataSize == 0)
- {
- KD_DMXFree(Dmx_Buf);
- KB_OSPSemSet(Dmx_SemLock);
- continue;
- }
- if(pChInfo->NotifyFunctionPtr != NULL)
- {
- pChInfo->NotifyFunctionPtr(chId, Dmx_Buf, DataSize);
- if(pChInfo->InternalUnlock == TRUE)
- {
- KD_DMXFree(Dmx_Buf);
- }
- }
- KB_OSPSemSet(Dmx_SemLock);
-
- }
- }
- static INT32 Associate(UINT32 channelID, UINT32 filterID)
- {
- int i;
- for(i=0;i<BACKDATA_N;i++){
- if(g_backdata[i].channelID==channelID&&g_backdata[i].filterID==filterID)
- break;
- }
- if(i==BACKDATA_N){
- for(i=0;i<BACKDATA_N;i++){
- if(g_backdata[i].channelID==0&&g_backdata[i].filterID==0){
- g_backdata[i].channelID=channelID;
- g_backdata[i].filterID=filterID;
- break;
- }
- }
- if(i==BACKDATA_N)
- return RETFIAL1;
- }
- else
- return RETFIAL1;
- return RETOK;
-
- }
- static INT32 Disassociate(UINT32 channelID, UINT32 filterID)
- {
- int i;
- for(i=0;i<BACKDATA_N;i++){
- if(g_backdata[i].channelID==channelID&&g_backdata[i].filterID==filterID){
- g_backdata[i].channelID=0;
- g_backdata[i].filterID=0;
- break;
- }
- }
- if(i==BACKDATA_N)
- return RETFIAL1;
-
- return RETOK;
-
- }
- #if 0
- static void AddDescramblerId(UINT32 descramblerID)
- {
- int i;
- for(i=0;i<BACKID_N;i++){
- if(g_backid[i]==0){
- g_backid[i]=descramblerID;
- break;
- }
- }
- }
- static BOOL RemoveDescramblerId(UINT32 descramblerID)
- {
- int i;
- for(i=0;i<BACKID_N;i++){
- if(g_backid[i]==descramblerID){
- g_backid[i]=0;
- return TRUE;
- }
- }
- return FALSE;
- }
- static BOOL IsDescramblerId(UINT32 descramblerID)
- {
- int i;
- for(i=0;i<BACKID_N;i++){
- if(g_backid[i]==descramblerID)
- return TRUE;
- }
- return FALSE;
- }
- #endif
- INT32 KB_DmxInit(void)
- {
- INT32 i, Index;
- ST_ErrorCode_t ST_ErrorCode;
- STPTI_InitParams_t STPTI_InitParams;
- STPTI_OpenParams_t STPTI_OpenParams;
-
- UINT32 taskId;
- KB_OSPSemInit("DMXS", 1, J_OSP_WAIT_FIFO, &Dmx_SemLock);
-
- /* Init the data struct info */
- for(i = 0; i < KB_DMX_TOTAL_GENERIC_CHANNELS; i++)
- {
- gChnnlInfo[i].Allocated = FALSE;
- gChnnlInfo[i].Started = FALSE;
- gChnnlInfo[i].InternalUnlock = TRUE;
- gChnnlInfo[i].Type = DMX_CHANNEL_INVALID;
- gChnnlInfo[i].SlotHandle = STPTI_NullHandle();
- gChnnlInfo[i].Pid = STPTI_InvalidPid();
- gChnnlInfo[i].BufferHandle = STPTI_NullHandle();
- gChnnlInfo[i].BufferSize = 0;
- gChnnlInfo[i].UserBuffer_p = NULL;
- gChnnlInfo[i].UserBufferSize = 0;
- gChnnlInfo[i].SignalHandle = STPTI_NullHandle();
- gChnnlInfo[i].DescramblerHandle = STPTI_NullHandle();
- gChnnlInfo[i].NotifyFunctionPtr = NULL;
- }
- /* Init stpti */
- STPTI_InitParams.Device = PTI_DEVICE;
- STPTI_InitParams.TCDeviceAddress_p = (STPTI_DevicePtr_t)PTI_TCDEVICEADDRESS;
- STPTI_InitParams.InterruptNumber = PTI_INTERRUPTNUMBER;
- STPTI_InitParams.DescramblerAssociation = STPTI_DESCRAMBLER_ASSOCIATION_ASSOCIATE_WITH_PIDS;
- STPTI_InitParams.Partition_p = SystemPartition;
- STPTI_InitParams.NCachePartition_p = NcachePartition;
- strcpy( STPTI_InitParams.EventHandlerName, "EVT" );
- STPTI_InitParams.EventProcessPriority = STPTI_EVENT_PROCESS_PRIORITY;
- STPTI_InitParams.InterruptProcessPriority = STPTI_INTERRUPT_PROCESS_PRIORITY;
- #if defined(STPTI_CAROUSEL_SUPPORT)
- STPTI_InitParams.CarouselProcessPriority = 0;
- STPTI_InitParams.CarouselEntryType = STPTI_CAROUSEL_ENTRY_TYPE_SIMPLE;
- #endif
- STPTI_InitParams.InterruptLevel = PTI_INTERRUPT_LEVEL;
- STPTI_InitParams.SectionFilterOperatingMode = PTI_SECTIONFILTERMODE;
- #if defined(STPTI_INDEX_SUPPORT)
- STPTI_InitParams.IndexAssociation = STPTI_INDEX_ASSOCIATION_ASSOCIATE_WITH_SLOTS;
- STPTI_InitParams.IndexProcessPriority = 0;
- #endif
- STPTI_InitParams.StreamID = STPTI_STREAM_ID_NOTAGS;
- STPTI_InitParams.PacketArrivalTimeSource = STPTI_ARRIVAL_TIME_SOURCE_PTI;
- for(Index = 0; Index < KB_PTI_MAX_NUM ; Index++)
- {
- STPTI_InitParams.TCLoader_p = PTI_DVBTCLOADER; /* for PTI4 */
- STPTI_InitParams.TCCodes = STPTI_SUPPORTED_TCCODES_SUPPORTS_DVB;
-
- STPTI_InitParams.NumberOfSlots = KB_DMX_TOTAL_GENERIC_CHANNELS;
- STPTI_InitParams.DiscardOnCrcError = FALSE;
- /* initialises PTI device */
- ST_ErrorCode = STPTI_Init(g_KB_PTIDeviceNameMultiple[Index], &STPTI_InitParams);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- STTBX_Print(("%sn", STPTI_GetRevision() ));
- STPTI_OpenParams.DriverPartition_p = SystemPartition;
- STPTI_OpenParams.NonCachedPartition_p = NcachePartition;
- /* open PTI device */
- STTBX_Print(("PTI_Open = "));
- ST_ErrorCode = STPTI_Open(g_KB_PTIDeviceNameMultiple[Index], &STPTI_OpenParams, &g_KB_PTIHandleMultiple[Index]);
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- if (ST_ErrorCode != ST_NO_ERROR) return RETFIAL1;
- ST_ErrorCode = STPTI_EnableErrorEvent(g_KB_PTIDeviceNameMultiple[Index], STPTI_EVENT_SECTIONS_DISCARDED_ON_CRC_CHECK_EVT);
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- ST_ErrorCode = STPTI_EnableErrorEvent(g_KB_PTIDeviceNameMultiple[Index], STPTI_EVENT_TC_CODE_FAULT_EVT);
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- ST_ErrorCode = STPTI_EnableErrorEvent(g_KB_PTIDeviceNameMultiple[Index], STPTI_EVENT_INVALID_PARAMETER_EVT);
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- ST_ErrorCode = STPTI_EnableErrorEvent(g_KB_PTIDeviceNameMultiple[Index], STPTI_EVENT_BUFFER_OVERFLOW_EVT);
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- /* Enable receipt of a number of STPTI events */
- ST_ErrorCode = STPTI_EnableErrorEvent(g_KB_PTIDeviceNameMultiple[Index], STPTI_EVENT_CC_ERROR_EVT);
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- ST_ErrorCode = STPTI_EnableErrorEvent(g_KB_PTIDeviceNameMultiple[Index], STPTI_EVENT_INTERRUPT_FAIL_EVT);
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- ST_ErrorCode = STPTI_EnableErrorEvent(g_KB_PTIDeviceNameMultiple[Index], STPTI_EVENT_INVALID_LINK_EVT);
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- ST_ErrorCode = STPTI_EnableErrorEvent(g_KB_PTIDeviceNameMultiple[Index], STPTI_EVENT_PACKET_ERROR_EVT);
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- }
- ST_ErrorCode = STPTI_SignalAllocate(g_KB_PTIHandleMultiple[DEFAULT_PTI], &gSinHandle);
- if (ST_ErrorCode != ST_NO_ERROR) return( ST_ErrorCode );
- KB_OSPTaskInit("DMXT", 10240, Dmx_Task, DMX_PRIORITY, NULL, &taskId);
-
- return( ST_ErrorCode );
- }
- INT32 KB_DmxAllocateChnnl(KB_DMXChannelType channelType, UINT32 bufferSize, BOOL isInternal, UINT32 *channelID)
- {
- INT32 rc = RETFIAL1;
- ST_ErrorCode_t ST_ErrorCode;
- STPTI_SlotData_t STPTI_SlotData;
- INT32 index;
-
- if( (channelType == DMX_CHANNEL_INVALID) || (channelID == NULL) )
- {
- return RETFAIL3;
- }
- *channelID = KB_DMX_TOTAL_GENERIC_CHANNELS;
-
- STPTI_SlotData.SlotType = STPTI_SlotTypes[channelType];
- STPTI_SlotData.SlotFlags.SignalOnEveryTransportPacket = FALSE;
- STPTI_SlotData.SlotFlags.CollectForAlternateOutputOnly = FALSE;
- STPTI_SlotData.SlotFlags.AlternateOutputInjectCarouselPacket = FALSE;
- STPTI_SlotData.SlotFlags.StoreLastTSHeader = FALSE;
- STPTI_SlotData.SlotFlags.InsertSequenceError = FALSE;
- STPTI_SlotData.SlotFlags.OutPesWithoutMetadata = FALSE;
- STPTI_SlotData.SlotFlags.ForcePesLengthToZero = FALSE;
- STPTI_SlotData.SlotFlags.AppendSyncBytePrefixToRawData = FALSE;
- STPTI_SlotData.SlotFlags.SoftwareCDFifo = FALSE;
- index = GetFirstEmptyChannelID();
- if(index == KB_DMX_TOTAL_GENERIC_CHANNELS)
- {
- return rc;
- }
- else
- {
- ST_ErrorCode = STPTI_SlotAllocate( g_KB_PTIHandleMultiple[DEFAULT_PTI],
- &gChnnlInfo[index].SlotHandle,
- &STPTI_SlotData);
- if (ST_ErrorCode == ST_NO_ERROR)
- {
- gChnnlInfo[index].Allocated = TRUE;
- gChnnlInfo[index].Type = channelType;
-
- if(RETOK == KD_DmxAllocateBuf(index, bufferSize))
- {
- gChnnlInfo[index].InternalUnlock = isInternal;
- *channelID = index;
- rc = RETOK;
- }
- else
- {
- /* can't allocate buffer, so deallocate the slot */
- STPTI_SlotDeallocate(gChnnlInfo[index].SlotHandle);
- gChnnlInfo[index].SlotHandle = STPTI_NullHandle();
- gChnnlInfo[index].Allocated = FALSE;
- gChnnlInfo[index].Type = DMX_CHANNEL_INVALID;
- }
- }
- }
-
- return rc;
- }
- INT32 KB_DmxFreeChnnl(UINT32 channelID)
- {
- DMX_Channel *pChInfo;
- if(channelID >= KB_DMX_TOTAL_GENERIC_CHANNELS) return RETFAIL3;
- if(gChnnlInfo[channelID].Allocated == FALSE)
- {
- /* This channel has not been allocated. return success immediately */
- return RETOK;
- }
- pChInfo = &gChnnlInfo[channelID];
- /* Stop the channel first */
- if(pChInfo->Started == TRUE)
- {
- pChInfo->Started = FALSE;
- }
- if(pChInfo->BufferHandle != STPTI_NullHandle())
- {
- STPTI_SlotUnLink(pChInfo->SlotHandle);
- if(pChInfo->SignalHandle != STPTI_NullHandle())
- {
- STPTI_SignalDisassociateBuffer(pChInfo->SignalHandle, pChInfo->BufferHandle);
- pChInfo->SignalHandle = STPTI_NullHandle();
- }
- STPTI_BufferDeallocate(pChInfo->BufferHandle);
- pChInfo->BufferHandle = STPTI_NullHandle();
- }
- STPTI_SlotDeallocate(pChInfo->SlotHandle);
- pChInfo->SlotHandle = STPTI_NullHandle();
- pChInfo->Allocated = FALSE;
- pChInfo->Type = DMX_CHANNEL_INVALID;
- pChInfo->InternalUnlock = TRUE;
- return RETOK;
- }
- INT32 KB_DmxSetChnnlPID(UINT32 channelID, UINT16 pid)
- {
- ST_ErrorCode_t ST_ErrorCode;
- INT32 rc;
- if( (channelID >= KB_DMX_TOTAL_GENERIC_CHANNELS)
- || (gChnnlInfo[channelID].Allocated == FALSE) )
- {
- return RETFAIL3;
- }
- ST_ErrorCode = STPTI_SlotClearPid(gChnnlInfo[channelID].SlotHandle);
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- rc = RETFIAL1;
- }
- ST_ErrorCode = STPTI_SlotSetPid(gChnnlInfo[channelID].SlotHandle, (STPTI_Pid_t)pid);
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- rc = RETFIAL1;
- }
- else
- {
- gChnnlInfo[channelID].Pid = pid;
- if(gChnnlInfo[channelID].BufferHandle != STPTI_NullHandle())
- {
- STPTI_BufferFlush(gChnnlInfo[channelID].BufferHandle);
- }
- rc = RETOK;
- }
- return rc;
- }
- INT32 KB_DmxControlChnnl(UINT32 channelID, UINT32 channelCmd)
- {
- ST_ErrorCode_t ST_ErrorCode = ST_NO_ERROR;
-
- if( (channelID >= KB_DMX_TOTAL_GENERIC_CHANNELS)
- || (gChnnlInfo[channelID].Allocated == FALSE) )
- {
- return RETFAIL3;
- }
-
- switch(channelCmd)
- {
- case KB_DMX_START:
- ST_ErrorCode = STPTI_SlotSetPid(gChnnlInfo[channelID].SlotHandle, (STPTI_Pid_t)gChnnlInfo[channelID].Pid);
- break;
- case KB_DMX_STOP:
- ST_ErrorCode = STPTI_SlotClearPid(gChnnlInfo[channelID].SlotHandle);
- break;
- case KB_DMX_RESET:
- break;
- }
-
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- return RETFIAL1;
- }
-
- return RETOK;
- }
- INT32 KB_DmxRegNotice(UINT32 channelID, KB_DMX_NotifyFunc funcPtr)
- {
- if( (channelID >= KB_DMX_TOTAL_GENERIC_CHANNELS)
- || (gChnnlInfo[channelID].Allocated == FALSE) )
- {
- return RETFAIL3;
- }
- gChnnlInfo[channelID].NotifyFunctionPtr = funcPtr;
- return RETOK;
- }
- /* filter functions */
- INT32 KB_DmxAllocateFilter(KB_DMXFilterType filterType, UINT32 filterDepth, UINT32 *filterID)
- {
- ST_ErrorCode_t ST_ErrorCode;
- STPTI_FilterType_t stpti_FilterType;
-
- if(filterID == NULL)
- {
- return RETFAIL3;
- }
- switch(filterType)
- {
- case DMX_SECTION_FILTER:
- stpti_FilterType = STPTI_FILTER_TYPE_SECTION_FILTER_SHORT_MODE;
- break;
-
- case DMX_SECTION_FILTER_NEG_MATCH_MODE:
- stpti_FilterType = STPTI_FILTER_TYPE_SECTION_FILTER_NEG_MATCH_MODE;
- break;
-
- case DMX_PES_FILTER:
- stpti_FilterType = STPTI_FILTER_TYPE_PES_FILTER;
- break;
-
- case DMX_TSHEADER_FILTER:
- stpti_FilterType = STPTI_FILTER_TYPE_TSHEADER_FILTER;
- break;
- default:
- return RETFIAL1;
- break;
- }
- filterDepth = filterDepth; /* avoid compiler warning */
- *filterID = STPTI_NullHandle();
- ST_ErrorCode = STPTI_FilterAllocate(g_KB_PTIHandleMultiple[DEFAULT_PTI],
- stpti_FilterType,
- (STPTI_Filter_t*)filterID);
-
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- return RETFIAL1;
- }
-
- return RETOK;
- }
- INT32 KB_DmxFreeFilter(UINT32 filterID)
- {
- ST_ErrorCode_t ST_ErrorCode;
-
- if(filterID == STPTI_NullHandle()) return RETFAIL3;
- ST_ErrorCode = STPTI_FilterDeallocate((STPTI_Filter_t)filterID);
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- return RETFIAL1;
- }
-
- return RETOK;
- }
- INT32 KB_DmxSetFilter(UINT32 filterID, UINT8* filterMatch, UINT8* filterMask, UINT32 filterNegate)
- {
- ST_ErrorCode_t ST_ErrorCode;
- STPTI_FilterData_t FilterData;
- WORD2BYTE *DataMask;
- UINT8 stFilterMatch[16];
- UINT8 stFilterMask[16];
-
- if( (filterID == STPTI_NullHandle())
- || (filterMatch == NULL) || (filterMask == NULL) )
- {
- return RETFAIL3;
- }
- filterNegate = filterNegate; /* No effect. Only avoid compiler warning */
-
- /* incoming data is in the following format:
- * BYTE DESCRIPTION BYTE_POSITION_IN_SF EXAMPLE
- * =============================================================
- * 0 TABLE_ID (8) MS_WORD.BYTE0 PAT_TABLE_ID
- * 1,2 SECTION_LENGTH (12) - -
- * 3,4 TP_STREAM_ID (16) MS_WORD.BYTE1,2 0x0000
- * 5.6-7 RESERVED (2) MS_WORD.BYTE3.6-7 0x3
- * 5.5-1 VERSION_NUMBER (5) MS_WORD.BYTE3.5-1 0
- * 5.0 CUR_NXT_INDICATOR (1) MS_WORD.BYTE3.0 0
- * 6 SECTION_NUMBER (8) LS_WORD.BYTE0 0
- * 7 LAST_SECTION_NUMBER (8) LS_WORD.BYTE1 0
- * 8 - LS_WORD.BYTE2 0
- * 9 - LS_WORD.BYTE3 0
- */
- memset(stFilterMatch, 0, sizeof(stFilterMatch));
- memset(stFilterMask, 0, sizeof(stFilterMask));
- DataMask = (WORD2BYTE *)&stFilterMatch[0];
- DataMask->byte.ucByte0 = filterMatch[0];
- DataMask->byte.ucByte1 = filterMatch[3];
- DataMask->byte.ucByte2 = filterMatch[4];
- DataMask->byte.ucByte3 = filterMatch[5];
- DataMask = (WORD2BYTE *)&stFilterMatch[4];
- DataMask->byte.ucByte0 = filterMatch[6];
- DataMask->byte.ucByte1 = filterMatch[7];
- DataMask = (WORD2BYTE *)&stFilterMask[0];
- DataMask->byte.ucByte0 = filterMask[0];
- DataMask->byte.ucByte1 = filterMask[3];
- DataMask->byte.ucByte2 = filterMask[4];
- DataMask->byte.ucByte3 = filterMask[5];
- DataMask = (WORD2BYTE *)&stFilterMask[4];
- DataMask->byte.ucByte0 = filterMask[6];
- DataMask->byte.ucByte1 = filterMask[7];
-
- FilterData.FilterBytes_p = (U8*)stFilterMatch;
- FilterData.FilterMasks_p = (U8*)stFilterMask;
- FilterData.FilterType = STPTI_FILTER_TYPE_SECTION_FILTER_SHORT_MODE;
- FilterData.FilterRepeatMode = STPTI_FILTER_REPEAT_MODE_STPTI_FILTER_REPEATED;
- FilterData.InitialStateEnabled = TRUE;
- FilterData.u.SectionFilter.DiscardOnCrcError = TRUE;
- FilterData.u.SectionFilter.ModePattern_p = NULL;
- FilterData.u.SectionFilter.NotMatchMode = FALSE;
-
- ST_ErrorCode = STPTI_FilterSet((STPTI_Filter_t)filterID, &FilterData);
-
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- return RETFIAL1;
- }
-
- return RETOK;
- }
- //-add by shriek-
- INT32 KB_DmxSetFilterByType(UINT32 filterID, UINT8* filterMatch, UINT8* filterMask, UINT32 filterNegate, STPTI_FilterType_t filterType)
- {
- ST_ErrorCode_t ST_ErrorCode;
- STPTI_FilterData_t FilterData;
- WORD2BYTE *DataMask;
- UINT8 stFilterMatch[16];
- UINT8 stFilterMask[16];
-
- if( (filterID == STPTI_NullHandle())
- || (filterMatch == NULL) || (filterMask == NULL) )
- {
- return RETFAIL3;
- }
- filterNegate = filterNegate; /* No effect. Only avoid compiler warning */
-
- /* incoming data is in the following format:
- * BYTE DESCRIPTION BYTE_POSITION_IN_SF EXAMPLE
- * =============================================================
- * 0 TABLE_ID (8) MS_WORD.BYTE0 PAT_TABLE_ID
- * 1,2 SECTION_LENGTH (12) - -
- * 3,4 TP_STREAM_ID (16) MS_WORD.BYTE1,2 0x0000
- * 5.6-7 RESERVED (2) MS_WORD.BYTE3.6-7 0x3
- * 5.5-1 VERSION_NUMBER (5) MS_WORD.BYTE3.5-1 0
- * 5.0 CUR_NXT_INDICATOR (1) MS_WORD.BYTE3.0 0
- * 6 SECTION_NUMBER (8) LS_WORD.BYTE0 0
- * 7 LAST_SECTION_NUMBER (8) LS_WORD.BYTE1 0
- * 8 - LS_WORD.BYTE2 0
- * 9 - LS_WORD.BYTE3 0
- */
- memset(stFilterMatch, 0, sizeof(stFilterMatch));
- memset(stFilterMask, 0, sizeof(stFilterMask));
- DataMask = (WORD2BYTE *)&stFilterMatch[0];
- DataMask->byte.ucByte0 = filterMatch[0];
- DataMask->byte.ucByte1 = filterMatch[3];
- DataMask->byte.ucByte2 = filterMatch[4];
- DataMask->byte.ucByte3 = filterMatch[5];
- DataMask = (WORD2BYTE *)&stFilterMatch[4];
- DataMask->byte.ucByte0 = filterMatch[6];
- DataMask->byte.ucByte1 = filterMatch[7];
- DataMask = (WORD2BYTE *)&stFilterMask[0];
- DataMask->byte.ucByte0 = filterMask[0];
- DataMask->byte.ucByte1 = filterMask[3];
- DataMask->byte.ucByte2 = filterMask[4];
- DataMask->byte.ucByte3 = filterMask[5];
- DataMask = (WORD2BYTE *)&stFilterMask[4];
- DataMask->byte.ucByte0 = filterMask[6];
- DataMask->byte.ucByte1 = filterMask[7];
-
- FilterData.FilterBytes_p = (U8*)stFilterMatch;
- FilterData.FilterMasks_p = (U8*)stFilterMask;
- FilterData.FilterType = STPTI_FILTER_TYPE_SECTION_FILTER_SHORT_MODE;
- FilterData.FilterRepeatMode = filterType;
- FilterData.InitialStateEnabled = TRUE;
- FilterData.u.SectionFilter.DiscardOnCrcError = TRUE;
- FilterData.u.SectionFilter.ModePattern_p = NULL;
- FilterData.u.SectionFilter.NotMatchMode = FALSE;
-
- ST_ErrorCode = STPTI_FilterSet((STPTI_Filter_t)filterID, &FilterData);
-
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- printf("n [KB_DmxSetFilterByType]: ST_ErrorCode=%d",ST_ErrorCode);
- return RETFIAL1;
- }
-
- return RETOK;
- }
- INT32 KB_DmxAssociateFilter(UINT32 channelID, UINT32 filterID)
- {
- ST_ErrorCode_t ST_ErrorCode;
-
- if( (channelID >= KB_DMX_TOTAL_GENERIC_CHANNELS)
- || (gChnnlInfo[channelID].Allocated == FALSE)
- || (filterID == STPTI_NullHandle()) )
- {
- return RETFAIL3;
- }
-
- ST_ErrorCode = STPTI_FilterAssociate((STPTI_Filter_t)filterID, gChnnlInfo[channelID].SlotHandle);
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- return RETFIAL1;
- }
- Associate(channelID, filterID);
-
- return RETOK;
- }
- INT32 KB_DmxDisassociateFilter(UINT32 channelID, UINT32 filterID)
- {
- ST_ErrorCode_t ST_ErrorCode;
-
- if( (channelID >= KB_DMX_TOTAL_GENERIC_CHANNELS)
- || (gChnnlInfo[channelID].Allocated == FALSE)
- || (filterID == STPTI_NullHandle()) )
- {
- return RETFAIL3;
- }
- if(Disassociate(channelID, filterID)==RETFIAL1)
- return RETFIAL1;
- ST_ErrorCode = STPTI_FilterDisassociate((STPTI_Filter_t)filterID, gChnnlInfo[channelID].SlotHandle);
-
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- return RETFIAL1;
- }
-
- return RETOK;
- }
- /* buffer functions */
- static INT32 KD_DmxAllocateBuf(UINT32 channelID, UINT32 bufferSize)
- {
- ST_ErrorCode_t ST_ErrorCode;
- DMX_Channel *pChInfo;
-
- if( (channelID >= KB_DMX_TOTAL_GENERIC_CHANNELS)
- || (gChnnlInfo[channelID].Allocated == FALSE) )
- {
- return RETFAIL3;
- }
- if(0 == bufferSize)
- {
- return RETFAIL3;
- }
-
- pChInfo = &gChnnlInfo[channelID];
-
- if(pChInfo->BufferHandle != STPTI_NullHandle()) /* Already allocated buffer for this slot */
- {
- return RETFIAL1;
- }
- ST_ErrorCode = STPTI_BufferAllocate(g_KB_PTIHandleMultiple[DEFAULT_PTI],
- (U32)bufferSize, 1, &(pChInfo->BufferHandle));
-
- if(ST_NO_ERROR != ST_ErrorCode) goto Err_End;
-
- pChInfo->BufferSize = bufferSize;
- ST_ErrorCode = STPTI_SlotLinkToBuffer(pChInfo->SlotHandle, pChInfo->BufferHandle);
- if(ST_NO_ERROR != ST_ErrorCode) goto Err_Buf;
- STPTI_SlotClearPid(pChInfo->SlotHandle);
- STPTI_BufferFlush(pChInfo->BufferHandle);
- pChInfo->SignalHandle = gSinHandle;// 所有buffer均用同一个signal
- ST_ErrorCode = STPTI_SignalAssociateBuffer(pChInfo->SignalHandle, pChInfo->BufferHandle);
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- pChInfo->SignalHandle = STPTI_NullHandle();
- goto Err_Buf;
- }
- return RETOK;
-
- Err_Buf:
- STPTI_SlotUnLink(pChInfo->SlotHandle);
- STPTI_BufferDeallocate(pChInfo->BufferHandle);
- pChInfo->BufferHandle = STPTI_NullHandle();
- pChInfo->BufferSize = 0;
-
- Err_End:
- return RETFIAL1;
- }
- INT32 KB_DmxUnlock(UINT32 channelID, UINT8* bufferPtr)
- {
- if( (channelID >= KB_DMX_TOTAL_GENERIC_CHANNELS)
- || (gChnnlInfo[channelID].Allocated == FALSE) )
- {
- return RETFAIL3;
- }
- if(gChnnlInfo[channelID].InternalUnlock == TRUE)
- {
- return RETFIAL1;
- }
- KD_DMXFree(bufferPtr);
-
- return RETOK;
- }
- static void* KD_DMXAllocate(UINT32 size)
- {
- return memory_allocate(DemuxPartition, (size_t)size);
-
- }
- static void KD_DMXFree(void *ptr)
- {
- if(ptr == NULL) return;
- memory_deallocate(DemuxPartition, ptr);
- }
- /* descrambler functions */
- INT32 KB_DmxOpenDescrambler(void)
- {
- ST_ErrorCode_t Error;
- STPTI_Descrambler_t DescramblerHandle;
-
- if (ST_NO_ERROR != (Error = STPTI_DescramblerAllocate(g_KB_PTIHandleMultiple[DEFAULT_PTI], &DescramblerHandle, STPTI_DESCRAMBLER_TYPE_DVB_DESCRAMBLER )))
- {
- return RETFIAL1;
- }
- return (INT32)DescramblerHandle;
- }
- INT32 KB_DmxCloseDescrambler(UINT32 descramblerID)
- {
- ST_ErrorCode_t Error;
-
- if (ST_NO_ERROR != (Error = STPTI_DescramblerDeallocate((STPTI_Descrambler_t)descramblerID)))
- {
- return RETFIAL1;
- }
- return RETOK;
- }
- INT32 KB_DmxSetEventKey(UINT32 descramblerID, const UINT8* evenKey)
- {
- ST_ErrorCode_t Error;
- if(evenKey == NULL)
- {
- return RETFAIL3;
- }
- if (ST_NO_ERROR != (Error = STPTI_DescramblerSet((STPTI_Descrambler_t)descramblerID, STPTI_KEY_PARITY_EVEN_PARITY, STPTI_KEY_USAGE_VALID_FOR_TRANSPORT, (U8*)evenKey)))
- {
- return RETFIAL1;
- }
-
- return RETOK;
- }
- INT32 KB_DmxSetOddKey(UINT32 descramblerID, const UINT8* oddKey)
- {
- ST_ErrorCode_t Error;
- if(oddKey == NULL)
- {
- return RETFAIL3;
- }
- if (ST_NO_ERROR != (Error = STPTI_DescramblerSet((STPTI_Descrambler_t)descramblerID, STPTI_KEY_PARITY_ODD_PARITY, STPTI_KEY_USAGE_VALID_FOR_TRANSPORT, (U8*)oddKey)))
- {
- return RETFIAL1;
- }
-
- return RETOK;
- }
- INT32 KB_DmxSetDescPID(UINT32 descramblerID, UINT16 pid)
- {
- ST_ErrorCode_t Error;
- STPTI_SlotOrPid_t SlotOrPid;
-
- SlotOrPid.Pid = (STPTI_Pid_t)pid;
- if (ST_NO_ERROR != (Error = STPTI_DescramblerAssociate((STPTI_Descrambler_t)descramblerID, SlotOrPid)))
- {
- return RETFIAL1;
- }
- return RETOK;
- }
- INT32 KD_DmxCloseDescPID(UINT32 descramblerID, UINT16 pid)
- {
- ST_ErrorCode_t Error;
- STPTI_SlotOrPid_t SlotOrPid;
-
- SlotOrPid.Pid = (STPTI_Pid_t)pid;
- if (ST_NO_ERROR != (Error = STPTI_DescramblerDisassociate((STPTI_Descrambler_t)descramblerID, SlotOrPid)))
- {
- return RETFIAL1;
- }
- return RETOK;
- }
- static INT32 KD_DmxAllocateBuffCA(UINT32 channelID, UINT32 bufferSize)
- {
- ST_ErrorCode_t ST_ErrorCode;
- DMX_Channel *pChInfo;
-
- if( (channelID >= KB_DMX_TOTAL_GENERIC_CHANNELS)
- || (gChnnlInfo[channelID].Allocated == FALSE) )
- {
- return RETFAIL3;
- }
- if(0 == bufferSize)
- {
- return RETFAIL3;
- }
-
- pChInfo = &gChnnlInfo[channelID];
-
- if(pChInfo->BufferHandle != STPTI_NullHandle()) /* Already allocated buffer for this slot */
- {
- return RETFIAL1;
- }
- ST_ErrorCode = STPTI_BufferAllocate(g_KB_PTIHandleMultiple[DEFAULT_PTI],
- (U32)bufferSize, 1, &(pChInfo->BufferHandle));
-
- if(ST_NO_ERROR != ST_ErrorCode) goto Err_End;
-
- pChInfo->BufferSize = bufferSize;
- ST_ErrorCode = STPTI_SlotLinkToBuffer(pChInfo->SlotHandle, pChInfo->BufferHandle);
- if(ST_NO_ERROR != ST_ErrorCode) goto Err_Buf;
- STPTI_SlotClearPid(pChInfo->SlotHandle);
- STPTI_BufferFlush(pChInfo->BufferHandle);
- pChInfo->SignalHandle = g_SignalHandle_for_TF;// 所有Ecm Emm均用同一个signal
- ST_ErrorCode = STPTI_SignalAssociateBuffer(pChInfo->SignalHandle, pChInfo->BufferHandle);
- if(ST_NO_ERROR != ST_ErrorCode)
- {
- pChInfo->SignalHandle = STPTI_NullHandle();
- goto Err_Buf;
- }
- return RETOK;
-
- Err_Buf:
- STPTI_SlotUnLink(pChInfo->SlotHandle);
- STPTI_BufferDeallocate(pChInfo->BufferHandle);
- pChInfo->BufferHandle = STPTI_NullHandle();
- pChInfo->BufferSize = 0;
-
- Err_End:
- return RETFIAL1;
- }
- INT32 KD_DmxAllocateChnnlCA(KB_DMXChannelType channelType, UINT32 bufferSize, BOOL isInternal, UINT32 *channelID)
- {
- INT32 rc = RETFIAL1;
- ST_ErrorCode_t ST_ErrorCode;
- STPTI_SlotData_t STPTI_SlotData;
- INT32 index;
-
- if( (channelType == DMX_CHANNEL_INVALID) || (channelID == NULL) )
- {
- return RETFAIL3;
- }
- *channelID = KB_DMX_TOTAL_GENERIC_CHANNELS;
-
- STPTI_SlotData.SlotType = STPTI_SlotTypes[channelType];
- STPTI_SlotData.SlotFlags.SignalOnEveryTransportPacket = FALSE;
- STPTI_SlotData.SlotFlags.CollectForAlternateOutputOnly = FALSE;
- STPTI_SlotData.SlotFlags.AlternateOutputInjectCarouselPacket = FALSE;
- STPTI_SlotData.SlotFlags.StoreLastTSHeader = FALSE;
- STPTI_SlotData.SlotFlags.InsertSequenceError = FALSE;
- STPTI_SlotData.SlotFlags.OutPesWithoutMetadata = FALSE;
- STPTI_SlotData.SlotFlags.ForcePesLengthToZero = FALSE;
- STPTI_SlotData.SlotFlags.AppendSyncBytePrefixToRawData = FALSE;
- STPTI_SlotData.SlotFlags.SoftwareCDFifo = FALSE;
- index = GetFirstEmptyChannelID();
- if(index == KB_DMX_TOTAL_GENERIC_CHANNELS)
- {
- }
- else
- {
- ST_ErrorCode = STPTI_SlotAllocate( g_KB_PTIHandleMultiple[DEFAULT_PTI],
- &gChnnlInfo[index].SlotHandle,
- &STPTI_SlotData);
- if (ST_ErrorCode == ST_NO_ERROR)
- {
- gChnnlInfo[index].Allocated = TRUE;
- gChnnlInfo[index].Type = channelType;
-
- if(RETOK == KD_DmxAllocateBuffCA(index, bufferSize))
- {
- gChnnlInfo[index].InternalUnlock = isInternal;
- *channelID = index;
- rc = RETOK;
- }
- else
- {
- /* can't allocate buffer, so deallocate the slot */
- STPTI_SlotDeallocate(gChnnlInfo[index].SlotHandle);
- gChnnlInfo[index].SlotHandle = STPTI_NullHandle();
- gChnnlInfo[index].Allocated = FALSE;
- gChnnlInfo[index].Type = DMX_CHANNEL_INVALID;
- }
- }
-
- }
-
- return rc;
- }
- static void Exm_Task(void *params)
- {
- ST_ErrorCode_t ST_ErrorCode;
- STPTI_Buffer_t WhichBufferGotSignal;
- DMX_Channel *pChInfo;
-
- UINT32 DataSize;
- U32 NumFilterMatches = 0;
- BOOL CRCValid;
- INT32 chId;
-
- while(1)
- {
- ST_ErrorCode = STPTI_SignalWaitBuffer(g_SignalHandle_for_TF, &WhichBufferGotSignal, STPTI_TIMEOUT_INFINITY);
- /* STPTI_SignalWaitBuffer() generated an error */
- if (ST_ErrorCode == ST_ERROR_TIMEOUT)
- {
- continue;
- }
- /* if not a harmless timeout then get rid of anything in the STPTI internal buffer */
- else if (ST_ErrorCode != ST_NO_ERROR)
- {
- STPTI_BufferFlush(WhichBufferGotSignal);
- continue;
- }
- /* Find the channel, that buffer handle equal WhichBufferGotSignal */
- for(chId = 0; chId < KB_DMX_TOTAL_GENERIC_CHANNELS; chId++)
- {
- if( (gChnnlInfo[chId].Allocated == TRUE)
- && (gChnnlInfo[chId].BufferHandle == WhichBufferGotSignal) )
- {
- /* got it */
- break;
- }
- }
- if(chId >= KB_DMX_TOTAL_GENERIC_CHANNELS)
- {
- STPTI_BufferFlush(WhichBufferGotSignal);
- continue;
- }
- pChInfo = &gChnnlInfo[chId];
- DataSize = 0;
- memset(Exm_Buf,0,EXM_BUFF_LEN);
- switch(STPTI_SlotTypes[pChInfo->Type])
- {
- case STPTI_SLOT_TYPE_PES:
- #ifdef STPTI_DVB_SUPPORT
- ST_ErrorCode = STPTI_BufferReadPes(pChInfo->BufferHandle, (U8*)Exm_Buf, (U32)EXM_BUFF_LEN,
- NULL, 0, (U32*)&DataSize,
- STPTI_COPY_TRANSFER_BY_MEMCPY);
- #else
- STPTI_BufferFlush(WhichBufferGotSignal);
- continue;
- #endif
- break;
-
- case STPTI_SLOT_TYPE_SECTION: /* three type are same: section */
- case STPTI_SLOT_TYPE_EMM:
- case STPTI_SLOT_TYPE_ECM:
- ST_ErrorCode = STPTI_BufferReadSection(pChInfo->BufferHandle, NULL, 0, &NumFilterMatches, &CRCValid,
- (U8*)Exm_Buf, (U32)EXM_BUFF_LEN, NULL, 0,
- (U32*)&DataSize, STPTI_COPY_TRANSFER_BY_MEMCPY);
- break;
-
- case STPTI_SLOT_TYPE_RAW:
- ST_ErrorCode = STPTI_BufferReadTSPacket(pChInfo->BufferHandle, (U8*)Exm_Buf, (U32)EXM_BUFF_LEN,
- NULL, 0, (U32*)&DataSize,
- STPTI_COPY_TRANSFER_BY_MEMCPY);
- break;
- default:
- /* do no support type */
- STPTI_BufferFlush(WhichBufferGotSignal);
- continue;
- break;
- }
-
- if (ST_ErrorCode != ST_NO_ERROR) /* unexpected fault reading data */
- {
- STPTI_BufferFlush(WhichBufferGotSignal);
- continue;
- }
- if(DataSize == 0)
- {
- continue;
- }
- if(pChInfo->NotifyFunctionPtr != NULL)
- {
- pChInfo->NotifyFunctionPtr(chId, Exm_Buf, DataSize);
- }
- }
- }
- INT32 KD_DmxInitCA(void)
- {
- ST_ErrorCode_t ST_ErrorCode;
- UINT32 taskId;
- ST_ErrorCode = STPTI_SignalAllocate(g_KB_PTIHandleMultiple[DEFAULT_PTI], &g_SignalHandle_for_TF);
- if (ST_ErrorCode != ST_NO_ERROR) return( ST_ErrorCode );
- KB_OSPTaskInit("EXMT", 10240, Exm_Task, DMX_PRIORITY, NULL, &taskId);
-
- return( ST_ErrorCode );
- }
- /* EOF --------------------------------------------------------------------- */