📄 tmdlmbs2.c
字号:
if (status == TM_OK) { if (pMbsInst->pTaskInfo != Null) { free (pMbsInst->pTaskInfo); pMbsInst->pTaskInfo = Null; } if (pMbsInst->pClutInfo != Null) { free (pMbsInst->pClutInfo); pMbsInst->pClutInfo = Null; } } } if (status == TM_OK) { if (MbsInstanceCountDec (unit) == 0) { // eh04#468 // Destroy the clock for frequency switching of mbs unit. if (Null != gMbsUnitClock[unit]) { MbsCloseFreqClock(gMbsUnitClock[unit]); gMbsUnitClock[unit] = Null; } // eh04#468 END if (pMbsInst->streamMode) { MbsStreamModeClear (unit); } else { MbsDisableTaskDispatching (pMbsInst); } } if (pMbsInst->ptlMemory != Null) { // free task list memory tmmlFree (pMbsInst->ptlMemory); pMbsInst->ptlMemory = Null; } // close video measurement instance if (pMbsInst->vidMeasInstance) { tmdlVidMeasClose (pMbsInst->vidMeasInstance); pMbsInst->vidMeasInstance = 0; } mbsMemSpace = pMbsInst->mbsMemSpace; pMbsInst->setupDone = False; // indicate setup not done pMbsInst->key = 0; // clear key free (pMbsInst); // free instance memory if (mbsMemSpace != Null) { tmmlDelete (mbsMemSpace); // free mem handle } } return status;} // tmdlMbsClose//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsGetClockFreq://// DESCRIPTION: Returns the clock frequency of the MBS.//// RETURN: Resulting error condition//// NOTES: None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsGetClockFreq ( tmInstance_t instance, // I: instance ptmdlMbs2_clockFreq_t pClockFreq // O: buffer receiving frequency ){ ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; // make sure we have a valid instance DBG_ASSERT2( instance != 0, ("tmdlMbsGetClockFreq: Instance = 0") ); DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY, ("tmdlMbsGetClockFreq: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) ); // make sure setup is a valid pointer DBG_ASSERT2( pClockFreq != Null, ("tmdlMbsGetClockFreq: pClockFreq = Null") ); *pClockFreq = mbsClockFreq [pMbsInst->unit]; return TM_OK;}//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsGetDefaultClockFreq://// DESCRIPTION: Returns the default clock frequency of the MBS//// RETURN: Resulting error condition//// NOTES: None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsUnitGetDefaultClockFreq ( tmUnitSelect_t unit, // I: mbs unit ptmdlMbs2_clockFreq_t pClockFreq // O: buffer receiving frequency ){ DBG_ASSERT(pClockFreq != Null) *pClockFreq = gMbsInitialClockFreq [unit]; return TM_OK;}//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsSetClockFreq://// DESCRIPTION: Sets the clock frequency of the MBS.//// RETURN: Resulting error condition//// NOTES: None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsSetClockFreq ( tmInstance_t instance, // I: instance tmdlMbs2_clockFreq_t clockFreq // O: new clock frequency ){ ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; tmErrorCode_t error = TM_OK; // make sure we have a valid instance DBG_ASSERT2( instance != 0, ("tmdlMbsSetClockFreq: Instance = 0") ); DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY, ("tmdlMbsSetClockFreq: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) ); DBG_ASSERT2( clockFreq < tmdlMbs2_clockFreqCount, ("tmdlMbsSetClockFreq: clockFreq %d >= %d", clockFreq, tmdlMbs2_clockFreqCount ) ); error = MbsSetClockFreq (pMbsInst, clockFreq); // To make this function working again in combination with the change to update the frequency per task. // Fix for bl18#54 gMbsInitialClockFreq [pMbsInst->unit] = clockFreq; return error;}//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsEnableStreamMode://// DESCRIPTION: This function enables the streaming mode for the specified// instance. The intent of this mode is for use in Viper2 where// video data will be streamed directly between the hardware// modules without going to memory.//// RETURN: TM_OK streaming mode enabled// TMDL_ERR_MBS_INIT_FAILED another instance already has this// unit opened in normal (interrupt) mode, OR// tmdlMbsInstanceSetup has already been called.//// NOTES: Only one instance per unit is allowed in streaming mode.//// This function must be called after tmdlMbsOpen(M) AND before// tmdlMbsInstanceSetup.//// The instance runs with interrupts disabled; therfore, the// following functions are not supported in streaming mode://// tmdlMbsRegisterCallback// tmdlMbsSetEventMask// tmdlMbsTaskGetStatus// tmdlMbsTaskAbort//// With task status not supported, the instance owner is// responsible for making sure the task's task list is not// updated (overwritten), or the task is destroyed// (tmdlQvcpTaskDestroy) before the hardware has executed the// task. The following functions update the task list when// called://// tmdlMbsTaskUpdateMsa3Control// tmdlMbsTaskUpdateSrcPosition// tmdlMbsTaskUpdateDei// tmdlMbsTaskUpdateEddi// tmdlMbsTaskUpdateHorzCoeffs// tmdlMbsTaskUpdateVertCoeffs//// The following functions set update flags and update the task// list when tmdlMbsTaskUpdate or tmdlMbsTaskDispatch is called://// tmdlMbsTaskUpdateRects// tmdlMbsTaskUpdateFilterSetup// tmdlMbsTaskUpdateDynZoom// tmdlMbsTaskUpdateHorzOutputShift// tmdlMbsTaskUpdateVertOutputShift//// No task queuing is supported. tmdlMbsTaskDispatch places the// task directly into the hardware FIFO. The instance owner is// responsible for preventing FIFO overflow.//// Video Measurement is not supported in streaming mode; therefore// the following functions are not supported in streaming mode://// tmdlMbsTaskUpdateMeas// tmdlMbsTaskUpdateMeasBuffer//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsEnableStreamMode ( tmInstance_t instance // I: instance ){ ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; // make sure we have a valid instance DBG_ASSERT2( instance != 0, ("tmdlMbsEnableStreamMode: Instance = 0") ); DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY, ("tmdlMbsEnableStreamMode: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) ); // stream mode must be set before instance setup MBS2_ERR_CHECK(pMbsInst->setupDone == False, TMDL_ERR_MBS_INIT_FAILED, "tmdlMbsEnableStreamMode: Instance already initialized"); // only one instance allowed when opening in stream mode MBS2_ERR_CHECK((MbsInstanceCount (pMbsInst->unit) == 1), TMDL_ERR_MBS_INIT_FAILED, "tmdlMbsEnableStreamMode: Instance count != 1"); MbsStreamModeSet (pMbsInst->unit); pMbsInst->streamMode = True; pMbsInst->useVidMeas = False; return TM_OK;} // tmdlMbsEnableStreamMode//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsGetInstanceSetup://// DESCRIPTION: Get current setup or default setup if not setup yet.//// RETURN: Resulting error condition//// NOTES: None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsGetInstanceSetup ( tmInstance_t instance, // I: instance ptmdlMbsInstanceSetup_t pSetup // O: buffer receiving pars ){ ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; // make sure we have a valid instance DBG_ASSERT2( instance != 0, ("tmdlMbsGetInstanceSetup: Instance = 0") ); DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY, ("tmdlMbsGetInstanceSetup: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) ); // make sure setup is a valid pointer DBG_ASSERT2( pSetup != Null, ("tmdlMbsGetInstanceSetup: pSetup = Null") ); *pSetup = pMbsInst->setup; return TM_OK;}//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsInstanceSetup://// DESCRIPTION: Setup default settings for this MBS instance.//// RETURN: Resulting error condition// TMDL_ERR_MBS_INIT_FAILED - Setup called more than once//// NOTES: The MBS is ready to accept tasks after successful completion// of tmdlMbsInstanceSetup.//// tmdlMbsInstanceSetup CAN ONLY BE CALLED ONCE PER INSTANCE//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsInstanceSetup ( tmInstance_t instance, // I: instance ptmdlMbsInstanceSetup_t pSetup // I: ptr to new setup structure ){ tmErrorCode_t status = TM_OK; UInt32 totalNrOfTasks; ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; pUInt32 pCmdBuffer; UInt32 i; UInt32 setupProgress = 0; UInt32 curNrTasks; UInt32 curNrClutModules; // make sure we have a valid instance DBG_ASSERT2( instance != 0, ("tmdlMbsInstanceSetup: Instance = 0") ); DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY, ("tmdlMbsInstanceSetup: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) ); // make sure setup is a valid pointer DBG_ASSERT2( pSetup != Null, ("tmdlMbsInstanceSetup: pSetup = Null") ); // make sure the user is not trying to change the instance // setup info MBS2_ERR_CHECK((pMbsInst->setupDone == False), TMDL_ERR_MBS_INIT_FAILED, "tmdlMbsInstanceSetup: Trying to reinitialize!"); DBG_ASSERT2(pMbsInst->streamMode == False || pSetup->maxHorizontalResolution <= MBS_LINEBUFFER_SIZE, ("tmdlMbsInstanceSetup: Cannot support HW streaming and Internal Slicing")); pMbsInst->nrOfSlicedTasks = ((pSetup->maxHorizontalResolution / MBS_LINEBUFFER_SIZE) + ((pSetup->maxHorizontalResolution % MBS_LINEBUFFER_SIZE) != 0)) * ((pSetup->maxVerticalResolution / pMbsInst->maxInternalSliceVerticalSize) + ((pSetup->maxVerticalResolution % pMbsInst->maxInternalSliceVerticalSize) != 0)); totalNrOfTasks = (pSetup->nrOfTasks * pMbsInst->nrOfSlicedTasks); // setup must have at least 1 task MBS2_ERR_CHECK(totalNrOfTasks != 0, TMDL_ERR_MBS_BAD_PARAMETER, "tmdlMbsInstanceSetup:"); curNrTasks = totalNrOfTasks; curNrClutModules = pMbsInst->setup.nrOfClutModules; status = tmmlGetOffsetPhysToVirt ( tmmlMpCached, (pInt32) &(pMbsInst->virt2physOffset)); if ((status == TM_OK) && !pMbsInst->streamMode) { status = MbsInitTaskDispatching (pMbsInst); } if (status == TM_OK) { // copy setup structure into instance pMbsInst->setup = *pSetup; pMbsInst->totalNrOfTasks = totalNrOfTasks;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -