static Void *VcapVencVdecVdis_ipcBitsRecvFxn(Void * prm) { VcapVencVdecVdis_IpcBitsCtrl *ipcBitsCtrl = (VcapVencVdecVdis_IpcBitsCtrl *) prm; VcapVencVdecVdis_IpcBitsCtrlThrObj *thrObj = &ipcBitsCtrl->thrObj; VcapVencVdecVdis_IpcBitsCtrlFileObj *fObj = &ipcBitsCtrl->fObj; UInt32 printStatsInterval = OSA_getCurTimeInMsec(); UInt32 elaspedTime; while (FALSE == thrObj->exitBitsInThread) { OSA_semWait(&thrObj->bitsInNotifySem,OSA_TIMEOUT_FOREVER); VcapVencVdecVdis_ipcBitsProcessFullBufs(thrObj, fObj, ipcBitsCtrl->decInfo); elaspedTime = OSA_getCurTimeInMsec() - printStatsInterval; if (elaspedTime >= 10000) { #if 1 VcapVencVdecVdis_printAvgStatistics(elaspedTime, TRUE); #endif printStatsInterval = OSA_getCurTimeInMsec(); } } return NULL; }
Int32 System_ipcListMPCreate(UInt32 regionId, UInt32 linkId, ListMP_Handle *pOutHndl, ListMP_Handle *pInHndl, GateMP_Handle * pOutHndleGate, GateMP_Handle * pInHndleGate) { Int32 status; char listMPOutName[64]; char listMPInName[64]; ListMP_Params listMPParams; GateMP_Params gateMPParams; status = System_ipcGetListMPName(linkId, listMPOutName, listMPInName); UTILS_assert(status==OSA_SOK); GateMP_Params_init(&gateMPParams); gateMPParams.regionId = regionId; gateMPParams.remoteProtect = GateMP_RemoteProtect_CUSTOM1; *pOutHndleGate = GateMP_create(&gateMPParams); UTILS_assert(*pOutHndleGate!=NULL); ListMP_Params_init(&listMPParams); listMPParams.name = listMPOutName; listMPParams.regionId = regionId; listMPParams.gate = *pOutHndleGate; printf(" %u: SYSTEM: Creating ListMP [%s] in region %d ...\n", OSA_getCurTimeInMsec(), listMPParams.name, listMPParams.regionId ); *pOutHndl = ListMP_create(&listMPParams); UTILS_assert(*pOutHndl!=NULL); GateMP_Params_init(&gateMPParams); gateMPParams.regionId = regionId; gateMPParams.remoteProtect = GateMP_RemoteProtect_CUSTOM1; *pInHndleGate = GateMP_create(&gateMPParams); UTILS_assert(*pInHndleGate!=NULL); ListMP_Params_init(&listMPParams); listMPParams.name = listMPInName; listMPParams.regionId = regionId; listMPParams.gate = *pInHndleGate; printf(" %u: SYSTEM: Creating ListMP [%s] in region %d ...\n", OSA_getCurTimeInMsec(), listMPParams.name, listMPParams.regionId ); *pInHndl = ListMP_create(&listMPParams); UTILS_assert(*pInHndl!=NULL); return status; }
Int32 System_ipcDeInit() { printf(" %u: SYSTEM: IPC de-init in progress !!!\n", OSA_getCurTimeInMsec()); System_ipcNotifyDeInit(); System_ipcMsgQDeInit(); SysLink_destroy (); printf(" %u: SYSTEM: IPC de-init DONE !!!\n", OSA_getCurTimeInMsec()); return OSA_SOK; }
Int32 System_ipcInit() { printf(" %u: SYSTEM: IPC init in progress !!!\n", OSA_getCurTimeInMsec()); SysLink_setup (); System_ipcMsgQInit(); System_ipcNotifyInit(); printf(" %u: SYSTEM: IPC init DONE !!!\n", OSA_getCurTimeInMsec()); return OSA_SOK; }
Int32 VcapVenc_resetStatistics() { UInt32 chId; VcapVenc_ChInfo *pChInfo; for(chId=0; chId<VENC_CHN_MAX; chId++) { pChInfo = &gVcapVenc_ctrl.chInfo[chId]; pChInfo->totalDataSize = 0; pChInfo->numKeyFrames = 0; pChInfo->numFrames = 0; pChInfo->maxWidth = 0; pChInfo->minWidth = 0xFFF; pChInfo->maxHeight= 0; pChInfo->minHeight= 0xFFF; pChInfo->maxLatency= 0; pChInfo->minLatency= 0xFFF; } gVcapVenc_ctrl.statsStartTime = OSA_getCurTimeInMsec(); return 0; }
int OSA_prfEnd(OSA_PrfHndl *hndl, Uint32 value) { hndl->curTime = OSA_getCurTimeInMsec() - hndl->curTime; hndl->count++; hndl->totalTime += hndl->curTime; if (hndl->curTime > hndl->maxTime) { hndl->maxTime = hndl->curTime; } if (hndl->curTime < hndl->minTime) { hndl->minTime = hndl->curTime; } hndl->curValue = value; hndl->totalValue += value; if (value > hndl->maxValue) { hndl->maxValue = value; } if (value < hndl->minValue) { hndl->minValue = value; } return OSA_SOK; }
Int32 SD_Demo_resetStatistics() { UInt32 chId; SD_Demo_ChInfo *pChInfo; for(chId=0; chId<gSD_Demo_ctrl.numCapChannels; chId++) { pChInfo = &gSD_Demo_Ipc_Ctrl.chInfo[chId]; pChInfo->totalDataSize = 0; pChInfo->numKeyFrames = 0; pChInfo->numFrames = 0; pChInfo->maxWidth = 0; pChInfo->minWidth = 0xFFF; pChInfo->maxHeight= 0; pChInfo->minHeight= 0xFFF; pChInfo->maxLatency= 0; pChInfo->minLatency= 0xFFF; } gSD_Demo_Ipc_Ctrl.statsStartTime = OSA_getCurTimeInMsec(); return 0; }
Int32 VcapVencVdecVdis_printStatistics(Bool resetStats, Bool allChs) { UInt32 chId; VcapVencVdecVdis_ChInfo *pChInfo; float elaspedTime; elaspedTime = OSA_getCurTimeInMsec() - gVcapVencVdecVdis_ipcBitsCtrl.statsStartTime; elaspedTime /= 1000.0; // in secs if(allChs) { printf( "\n" "\n *** Encode Bitstream Received Statistics *** " "\n" "\n Elased time = %6.1f secs" "\n" "\n CH | Bitrate (Kbps) | FPS | Key-frame FPS | Width (max/min) | Height (max/min) | Latency (max/min)" "\n --------------------------------------------------------------------------------------------------", elaspedTime ); for(chId=0; chId<VENC_CHN_MAX;chId++) { pChInfo = &gVcapVencVdecVdis_ipcBitsCtrl.chInfo[chId]; if(pChInfo->numFrames) { printf("\n %2d | %14.2f | %3.1f | %13.1f | %5d / %6d | %6d / %6d | %6d / %6d", chId, (pChInfo->totalDataSize*8.0/elaspedTime)/1024.0, pChInfo->numFrames*1.0/elaspedTime, pChInfo->numKeyFrames*1.0/elaspedTime, pChInfo->maxWidth, pChInfo->minWidth, pChInfo->maxHeight, pChInfo->minHeight, pChInfo->maxLatency, pChInfo->minLatency ); } } printf("\n"); if(resetStats) VcapVencVdecVdis_resetStatistics(); } else { } return 0; }
Int32 SD_Demo_printStatistics(Bool resetStats) { UInt32 chId; SD_Demo_ChInfo *pChInfo; float elaspedTime; elaspedTime = OSA_getCurTimeInMsec() - gSD_Demo_Ipc_Ctrl.statsStartTime; elaspedTime /= 1000.0; // in secs printf( "\n" "\n *** Encode Bitstream Received Statistics *** " "\n" "\n Elased time = %6.1f secs" "\n" "\n CH | Bitrate (Kbps) | FPS | Key-frame FPS | Width (max/min) | Height (max/min) | Latency (max/min)" "\n --------------------------------------------------------------------------------------------------", elaspedTime ); for(chId=0; chId<gSD_Demo_ctrl.numCapChannels; chId++) { pChInfo = &gSD_Demo_Ipc_Ctrl.chInfo[chId]; if(pChInfo->numFrames) { printf("\n %2d | %14.2f | %3.1f | %13.1f | %5d / %6d | %6d / %6d | %6d / %6d", chId, (pChInfo->totalDataSize*8.0/elaspedTime)/1024.0, pChInfo->numFrames*1.0/elaspedTime, pChInfo->numKeyFrames*1.0/elaspedTime, pChInfo->maxWidth, pChInfo->minWidth, pChInfo->maxHeight, pChInfo->minHeight, pChInfo->maxLatency, pChInfo->minLatency ); } } printf("\n"); if(resetStats) SD_Demo_resetStatistics(); return 0; }
UInt32 System_ipcListMPAllocListElemMem(UInt32 regionId, UInt32 size) { IHeap_Handle heapHndl; Error_Block eb; UInt32 shAddr; heapHndl = SharedRegion_getHeap(regionId); UTILS_assert(heapHndl!=NULL); Error_init(&eb); shAddr = (UInt32) Memory_alloc ((IHeap_Handle)heapHndl, size, 0, &eb); UTILS_assert(shAddr!=(UInt32)NULL); printf(" %u: SYSTEM: ListElem Shared Addr = 0x%08x\n", OSA_getCurTimeInMsec(), shAddr ); return shAddr; }
/*---------------------------------------------------------------------------- grpx_link init/exit function -----------------------------------------------------------------------------*/ int grpx_link_init(grpx_plane_type planeType) { UInt32 outWidth, outHeight; VGRPX_CREATE_PARAM_S createPrm; VGRPX_BUFFER_INFO_S bufInfo; app_grpx_t *grpx = &grpx_obj; dprintf("\n"); dprintf("Starting !!!\n") memset(grpx, 0, sizeof(app_grpx_t)); if(planeType >= GRPX_FORMAT_MAX) { return -1; } else { grpx->planeType = planeType; } grpx->bytes_per_pixel = 4; if(planeType==GRPX_FORMAT_RGB565) grpx->bytes_per_pixel = 2; grpx->curWidth = GRPX_PLANE_WIDTH; grpx->curHeight = GRPX_PLANE_HEIGHT; Demo_swMsGetOutSize(Vdis_getResolution(VDIS_DEV_HDMI), &outWidth, &outHeight); createPrm.grpxId = HDMI_GRPX_ID; createPrm.bufferInfo.bufferPhysAddr = 0; createPrm.bufferInfo.bufferPitch = 0; createPrm.bufferInfo.bufferWidth = grpx->curWidth; createPrm.bufferInfo.bufferHeight = grpx->curHeight; if(planeType==GRPX_FORMAT_RGB565) createPrm.bufferInfo.dataFormat = VGRPX_DATA_FORMAT_RGB565; else createPrm.bufferInfo.dataFormat = VGRPX_DATA_FORMAT_ARGB888; createPrm.bufferInfo.scanFormat = VGRPX_SF_PROGRESSIVE; createPrm.dynPrm.scaleEnable = TRUE; createPrm.dynPrm.transperencyEnable = TRUE; createPrm.dynPrm.transperencyColor = RGB_KEY_24BIT_GRAY; createPrm.dynPrm.inWidth = grpx->curWidth; createPrm.dynPrm.inHeight = grpx->curHeight; createPrm.dynPrm.displayWidth = outWidth; createPrm.dynPrm.displayHeight = outHeight; createPrm.dynPrm.displayStartX = 0; createPrm.dynPrm.displayStartY = 0; Vgrpx_create(HDMI_GRPX_ID, &createPrm); Vgrpx_getInfo(HDMI_GRPX_ID, &bufInfo); grpx->buf_size = bufInfo.bufferPitch*bufInfo.bufferHeight; grpx->buf[0] = (unsigned char *)Vgrpx_mmap(bufInfo.bufferPhysAddr, grpx->buf_size, FALSE); if (grpx->buf[0] == NULL) { eprintf("GRPX0: mmap() failed !!!\n"); return -1; } Demo_swMsGetOutSize(Vdis_getResolution(VDIS_DEV_SD), &outWidth, &outHeight); createPrm.grpxId = SDTV_GRPX_ID; createPrm.bufferInfo.bufferPhysAddr = bufInfo.bufferPhysAddr; createPrm.bufferInfo.bufferPitch = bufInfo.bufferPitch; createPrm.bufferInfo.bufferWidth = bufInfo.bufferWidth; createPrm.bufferInfo.bufferHeight = bufInfo.bufferHeight; createPrm.bufferInfo.dataFormat = bufInfo.dataFormat; createPrm.bufferInfo.scanFormat = bufInfo.scanFormat; createPrm.dynPrm.scaleEnable = TRUE; createPrm.dynPrm.transperencyEnable = TRUE; createPrm.dynPrm.transperencyColor = RGB_KEY_24BIT_GRAY; createPrm.dynPrm.inWidth = grpx->curWidth; createPrm.dynPrm.inHeight = grpx->curHeight; createPrm.dynPrm.displayWidth = outWidth; createPrm.dynPrm.displayHeight = outHeight; createPrm.dynPrm.displayStartX = 0; createPrm.dynPrm.displayStartY = 0; Vgrpx_create(SDTV_GRPX_ID, &createPrm); Vgrpx_enable(HDMI_GRPX_ID, TRUE); Vgrpx_enable(SDTV_GRPX_ID, TRUE); { UInt32 curTime = OSA_getCurTimeInMsec(); //# init fb - fill RGB_KEY draw_fill_color(grpx->buf[0]); curTime = OSA_getCurTimeInMsec() - curTime; dprintf("### Memfill time = %d msecs\n", curTime); } dprintf("Start DONE !!!\n"); dprintf("\n"); return 0; }
Int32 System_ipcListMPOpen(UInt32 linkId, ListMP_Handle *pOutHndl, ListMP_Handle *pInHndl) { Int32 retryCount; Int32 status; char listMPOutName[64]; char listMPInName[64]; status = System_ipcGetListMPName(linkId, listMPOutName, listMPInName); UTILS_assert(status==OSA_SOK); retryCount = 10; while(retryCount) { OSA_printf(" %u: SYSTEM: Opening ListMP [%s] ...\n", OSA_getCurTimeInMsec(), listMPOutName ); status = ListMP_open(listMPOutName, pOutHndl); if(status==ListMP_E_NOTFOUND) { OSA_printf("%s:ListMP not found",listMPOutName); OSA_waitMsecs(1000); } else { if(status==ListMP_E_FAIL) { UTILS_assert(0); } else { if(status==ListMP_S_SUCCESS) break; } } retryCount--; if(retryCount<=0) UTILS_assert(0); } retryCount = 10; while(retryCount) { printf(" %u: SYSTEM: Opening ListMP [%s] ...\n", OSA_getCurTimeInMsec(), listMPInName ); status = ListMP_open(listMPInName, pInHndl); if(status==ListMP_E_NOTFOUND) OSA_waitMsecs(1000); else if(status==ListMP_E_FAIL) { UTILS_assert(0); } else if(status==ListMP_S_SUCCESS) break; retryCount--; if(retryCount<=0) UTILS_assert(0); } return status; }
int OSA_prfBegin(OSA_PrfHndl *hndl) { hndl->curTime = OSA_getCurTimeInMsec(); return OSA_SOK; }
int MEM_STATS_showStats( UInt32 masterId1, UInt32 masterId2, char *masterName1, char *masterName2, UInt32 samplingPeriodMsec, UInt32 loopCount ) { Uint32 newCount[2], oldCount[2], curCount[2], curTime, elaspedTime; float value[2]; Uint32 filter1, filter2; filter1 = filter2 = 1; if(masterId1==MASTERID_ALL) filter1 = 0; if(masterId2==MASTERID_ALL) filter2 = 0; *gMEM_STATS_ctrl.PERF_CNT_CFG = (((filter2) & 0x1) << 31) | (((filter1) & 0x1) << 15) ; *gMEM_STATS_ctrl.PERF_CNT_SEL = (((masterId2*4) & 0xFF) << 24) | (((masterId1*4) & 0xFF) << 8) ; oldCount[0] = *gMEM_STATS_ctrl.PERF_CNT_1; oldCount[1] = *gMEM_STATS_ctrl.PERF_CNT_2; curTime = OSA_getCurTimeInMsec(); do { OSA_waitMsecs(samplingPeriodMsec); newCount[0] = *gMEM_STATS_ctrl.PERF_CNT_1; newCount[1] = *gMEM_STATS_ctrl.PERF_CNT_2; elaspedTime = OSA_getCurTimeInMsec() - curTime; curTime = OSA_getCurTimeInMsec(); if(newCount[0] < oldCount[0]) { // wrap around happended curCount[0] = (0xFFFFFFFF - oldCount[0])+newCount[0]; } else { curCount[0] = newCount[0] - oldCount[0]; } if(newCount[1] < oldCount[1]) { // wrap around happended curCount[1] = (0xFFFFFFFF - oldCount[1])+newCount[1]; } else { curCount[1] = newCount[1] - oldCount[1]; } oldCount[0] = newCount[0]; oldCount[1] = newCount[1]; // in counts/secs value[0] = (curCount[0]*1000.0/elaspedTime); value[1] = (curCount[1]*1000.0/elaspedTime); // in million counts/sec value[0] /= 1000*1000; value[1] /= 1000*1000; printf(" # [%10s] %8.3f M req/sec\n", masterName1, value[0]); printf(" # [%10s] %8.3f M req/sec\n", masterName2, value[1]); } while(--loopCount); return 0; }
Int32 System_ipcMsgQSendMsg(UInt32 linkId, UInt32 cmd, Void *pPrm, UInt32 prmSize, Bool waitAck, UInt32 timeout) { Int32 status=OSA_SOK; SystemIpcMsgQ_Msg *pMsgCommon; UInt32 procId; Void *pMsgPrm; UTILS_assert(prmSize<=SYSTEM_IPC_MSGQ_MSG_SIZE_MAX); procId = SYSTEM_GET_PROC_ID(linkId); #ifdef TI_8107_BUILD if(procId==SYSTEM_PROC_DSP) { printf(" %u: MSGQ: WARNING: Trying to send command [0x%04x] to link [%d] on processor [%s], BUT [%s] is NOT present on this platform !!!\n", OSA_getCurTimeInMsec(), cmd, SYSTEM_GET_LINK_ID(linkId), MultiProc_getName(procId), MultiProc_getName(procId) ); /* return SUCCESS so that calling API can continue */ return status; } #endif UTILS_assert( procId < SYSTEM_PROC_MAX); /*wuzc modify for malloc fail*/ OSA_mutexLock(&gSystem_ipcObj.msgQLock); pMsgCommon = (SystemIpcMsgQ_Msg *)MessageQ_alloc( SYSTEM_IPC_MSGQ_HEAP, sizeof(*pMsgCommon)+prmSize ); UTILS_assert(pMsgCommon!=NULL); if(prmSize && pPrm) { pMsgPrm = SYSTEM_IPC_MSGQ_MSG_PAYLOAD_PTR(pMsgCommon); memcpy(pMsgPrm, pPrm, prmSize); } pMsgCommon->linkId = linkId; pMsgCommon->cmd = cmd; pMsgCommon->prmSize = prmSize; pMsgCommon->waitAck = waitAck; pMsgCommon->status = OSA_SOK; MessageQ_setReplyQueue(gSystem_ipcObj.selfAckMsgQ, (MessageQ_Msg)pMsgCommon); MessageQ_setMsgId(pMsgCommon, linkId); //OSA_mutexLock(&gSystem_ipcObj.msgQLock); status = MessageQ_put(gSystem_ipcObj.remoteProcMsgQ[procId], (MessageQ_Msg)pMsgCommon); if(status!=MessageQ_S_SUCCESS) { printf(" %u: MSGQ: MsgQ put for [%s] failed !!!\n", OSA_getCurTimeInMsec(), MultiProc_getName(procId) ); MessageQ_free((MessageQ_Msg)pMsgCommon); OSA_mutexUnlock(&gSystem_ipcObj.msgQLock); return status; } if(waitAck) { SystemIpcMsgQ_Msg *pAckMsg; status = MessageQ_get(gSystem_ipcObj.selfAckMsgQ, (MessageQ_Msg*)&pAckMsg, timeout); if(status!=MessageQ_S_SUCCESS) { printf(" %u: MSGQ: MsgQ Ack get from [%s] failed !!!\n", OSA_getCurTimeInMsec(), MultiProc_getName(procId) ); MessageQ_free((MessageQ_Msg)pMsgCommon); OSA_mutexUnlock(&gSystem_ipcObj.msgQLock); return status; } if(prmSize && pPrm) { pMsgPrm = SYSTEM_IPC_MSGQ_MSG_PAYLOAD_PTR(pAckMsg); memcpy(pPrm, pMsgPrm, prmSize); } status = pAckMsg->status; MessageQ_free((MessageQ_Msg)pAckMsg); } OSA_mutexUnlock(&gSystem_ipcObj.msgQLock); return status; }
Void *System_ipcMsgQTaskMain(Void *arg) { UInt32 prmSize; SystemIpcMsgQ_Msg *pMsgCommon; Void *pPrm; Int32 status; while(1) { status = MessageQ_get(gSystem_ipcObj.selfMsgQ, (MessageQ_Msg*)&pMsgCommon, OSA_TIMEOUT_FOREVER); if(status==MessageQ_E_UNBLOCKED) break; if(status!=MessageQ_S_SUCCESS) { printf(" %u: MSGQ: MsgQ get failed !!!\n", OSA_getCurTimeInMsec() ); continue; } #if 0 printf(" %u: MSGQ: Received command [0x%04x] (prmSize = %d) for [%s][%02d] (waitAck=%d)\n", OSA_getCurTimeInMsec(), pMsgCommon->cmd, pMsgCommon->prmSize, MultiProc_getName(SYSTEM_GET_PROC_ID(pMsgCommon->linkId)), SYSTEM_GET_LINK_ID(pMsgCommon->linkId), pMsgCommon->waitAck ); #endif prmSize = pMsgCommon->prmSize; pPrm = SYSTEM_IPC_MSGQ_MSG_PAYLOAD_PTR(pMsgCommon); if(pMsgCommon->cmd==SYSTEM_CMD_GET_INFO) { UTILS_assert(prmSize == sizeof(System_LinkInfo)); pMsgCommon->status = System_linkGetInfo_local(pMsgCommon->linkId, pPrm); } else { pMsgCommon->status = System_linkControl_local( pMsgCommon->linkId, pMsgCommon->cmd, pPrm, prmSize, pMsgCommon->waitAck ); } if(pMsgCommon->waitAck) { MessageQ_QueueId replyMsgQ; replyMsgQ = MessageQ_getReplyQueue(pMsgCommon); status = MessageQ_put(replyMsgQ, (MessageQ_Msg)pMsgCommon); if(status!=MessageQ_S_SUCCESS) { printf(" %u: MSGQ: MsgQ Ack put failed !!!\n", OSA_getCurTimeInMsec() ); MessageQ_free((MessageQ_Msg)pMsgCommon); } } else { MessageQ_free((MessageQ_Msg)pMsgCommon); } } return NULL; }