📄 tmdlmbs2.c
字号:
//-----------------------------------------------------------------------------// (C) Copyright 2003 Philips Semiconductors, All rights reserved//// This source code and any compilation or derivative thereof is the sole// property of Philips Corporation and is provided pursuant to a Software// License Agreement. This code is the proprietary information of Philips// Corporation and is confidential in nature. Its use and dissemination by// any party other than Philips Corporation is strictly limited by the// confidential information provisions of the Agreement referenced above.//-----------------------------------------------------------------------------// FILE NAME: tmdlMbs2.c//// DESCRIPTION: This file contains the exported MBS2 Device library functions.//// DOCUMENT REF://// NOTES:////-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Standard include files://-----------------------------------------------------------------------------#include <stdlib.h>//-----------------------------------------------------------------------------// Project include files://-----------------------------------------------------------------------------#include <tmdlMbs.h>#include <tmosal.h>#include <tmml.h>#include <tmbslCore.h>#include "tmdlMbs2_Local.h"#include "tmdlMbs2_Support.h" // prototypes of support functions#include <tmdlMbs2_0119.h>#include <tmdlMbs2_Cfg.h>#include <tmStdLib.h>//-----------------------------------------------------------------------------// Global variables://-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Exported functions://-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsGetCapabilities://// DESCRIPTION: This function returns the capabilities of MBS Unit 0. To// obtain the capabilities of additional MBS units (if any), use// the tmdlMbsGetCapabilitiesM function.//// RETURN: Resulting error condition//// NOTES: None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsGetCapabilities ( ptmdlMbsCapabilities_t *ppCap // O: ptr to buffer receiving cap ){ return tmdlMbsGetCapabilitiesM (ppCap, tmUnit0);}//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsGetCapabilitiesM://// DESCRIPTION: This function returns the capabilities of the specified MBS// unit.//// RETURN: Resulting error condition//// NOTES: None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsGetCapabilitiesM ( ptmdlMbsCapabilities_t *ppCap, // O: pointer to buffer pointer tmUnitSelect_t unitSelect // I: selected hardware unit ){ tmErrorCode_t status; Int32 nrOfUnits; if ((status = MbsInit (&nrOfUnits)) == TM_OK) { if (unitSelect < nrOfUnits) { *ppCap = &(gMbsCaps [unitSelect]); status = TM_OK; } else { *ppCap = Null; status = TMDL_ERR_MBS_BAD_UNIT_NUMBER; } } return status;}//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsOpen://// DESCRIPTION: This function opens MBS Unit 0 for access. To open other// MBS units in the system (if any), use tmdlMbsOpenM. If the// function returns successfully, an MBS instance is returned.// The MBS instance is passed in as a parameter in subsequent// device library function calls. Use the tmdlMbsClose function// to close the MBS instance and free system resources after all// MBS instance accesses have been completed.//// RETURN: Resulting error condition//// NOTES: None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsOpen ( tmInstance_t *pInstance // O: instance pointer ){ return tmdlMbsOpenM (pInstance, tmUnit0);}//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsOpenM://// DESCRIPTION: This function opens the specified MBS Unit for access. If the// function returns successfully, a MBS instance is returned.// The MBS instance is passed in as a parameter in subsequent// device library function calls. Use the tmdlMbsClose function// to close the MBS instance and free system resources after all// MBS instance accesses are completed.//// RETURN: Resulting error condition//// NOTES: None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsOpenM ( tmInstance_t *pInstance, // O: instance pointer tmUnitSelect_t unitSelect // I: selected hardware unit ){ ptmdlMbsInstance_t pMbsInst = Null; tmErrorCode_t status = TM_OK; ptmbslCoreSystemInfo_t pSystemInfo; UInt32 openProgress = 0; Int32 nrOfUnits; static Bool clockInit [MBS_MAX_UNITCOUNT] = {False, False, False, False}; tmdlMbsInstanceSetup_t defaultSetup = { sizeof(tmdlMbsInstanceSetup_t), // size of this structure 1, // number of tasks 0, // number of clut modules#if ( (TMFL_PNX_ID == 1500)|| (TMFL_PNX_ID == 1700)) 1920, 1080#else MBS_LINEBUFFER_SIZE, MBS_MAX_VERTICAL_RESOLUTION#endif }; if ((status = MbsInit (&nrOfUnits)) == TM_OK) { MBS2_ERR_CHECK((unitSelect < nrOfUnits), TMDL_ERR_MBS_BAD_UNIT_NUMBER, "tmdlMbsOpenM: Bad unit number"); defaultSetup.nrOfTasks = tmdlMbs2_CfgGetTaskCount (); defaultSetup.nrOfClutModules = tmdlMbs2_CfgGetModuleCount (); MBS2_ERR_CHECK( MbsStreamMode (unitSelect) == False, TMDL_ERR_MBS_INIT_FAILED, "tmdlMbsOpenM: Unit already in Stream Mode"); MBS2_ERR_CHECK((defaultSetup.nrOfTasks != 0), TMDL_ERR_MBS_INIT_FAILED, "tmdlMbsOpenM: Default number of tasks == 0"); status = tmbslCoreGetSystemInfo (&pSystemInfo); // create memspace memory for the task lists // the memory space is solely used for task space allocation which // takes place during instance setup. By this time we know how // many task we deal with and can create a memory space that just // fits. // allocate memory for the new instance if (status == TM_OK) { openProgress = 1; if ((pMbsInst = (ptmdlMbsInstance_t) malloc (sizeof(tmdlMbsInstance_t))) == Null) { status = TMDL_ERR_MBS_INIT_FAILED; } else { openProgress = 2; pMbsInst->dmaBase = pSystemInfo->onChipDmaBaseAddr; pMbsInst->cpuId = pSystemInfo->cpuId; // default values for instance: pMbsInst->key = MBS_INSTANCE_KEY; pMbsInst->unit = unitSelect; pMbsInst->features = gMbsFeatures [unitSelect]; pMbsInst->mbsMemSpace = Null; pMbsInst->setupDone = False; pMbsInst->setup = defaultSetup; pMbsInst->pClutInfo = Null; pMbsInst->pTaskInfo = Null; pMbsInst->ptlMemory = Null; pMbsInst->streamMode = False; pMbsInst->useVidMeas = False; pMbsInst->maxInternalSliceVerticalSize = tmdlMbs2_CfgGetMaxNumLinesPerVerticalSlice(unitSelect); if ( pMbsInst->maxInternalSliceVerticalSize == 0 ) { pMbsInst->maxInternalSliceVerticalSize = MBS_MAX_VERTICAL_RESOLUTION; } if (!clockInit [(UInt32) unitSelect]) { if ((status = MbsInitClock (pMbsInst)) == TM_OK) { clockInit [(UInt32) unitSelect] = True; } } // eh04#468 // Create a clock to keep for frequency switching of mbs unit. // Do this once per unit. status = TM_OK; if( 0 == MbsInstanceCount(unitSelect)) { status = MbsOpenFreqClock(unitSelect, &gMbsUnitClock[unitSelect]); DBG_ASSERT(TM_OK == status); } // eh04#468 END } } if (status == TM_OK) { pMbsInst->vidMeasInstance = 0; if (pMbsInst->features & tmdlMbsFeatureMeas) { // open an instance of the Video Measurement library if ((status = tmdlVidMeasOpen (&pMbsInst->vidMeasInstance)) == TM_OK) { openProgress = 3; pMbsInst->useVidMeas = True; } } } if (status == TM_OK) { // return instance *pInstance = (tmInstance_t) pMbsInst; MbsInstanceCountInc (unitSelect); } } if (status != TM_OK) { // error occurred, release any resources switch (openProgress) { case 3: tmdlVidMeasClose (pMbsInst->vidMeasInstance); // fall thru case 2: free (pMbsInst); // free instance memory // fall thru case 1: // fall thru default: *pInstance = 0; // return Null instance ptr break; } } return status;} // tmdlMbsOpenM//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsClose://// DESCRIPTION: This function closes the specified MBS instance. After the// MBS instance is closed, the instance number is no longer valid// and cannot be used for device library function calls. All tasks// will be removed and destroyed.//// RETURN: Resulting error condition//// NOTES: None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsClose ( tmInstance_t instance // I: instance to give up ){ tmErrorCode_t status = TM_OK; ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; tmmlMmspHandle_t mbsMemSpace; UInt32 index; tmUnitSelect_t unit; // make sure we have a valid instance DBG_ASSERT2( instance != 0, ("tmdlMbsClose: Instance = 0") ); DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY, ("tmdlMbsClose: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) ); unit = pMbsInst->unit; if (pMbsInst->setupDone) { // abort any pending tasks for (index = 0; index < pMbsInst->totalNrOfTasks; ++index ) { if (!pMbsInst->pTaskInfo [index].empty) { if (pMbsInst->pTaskInfo [index].taskStatus == tmdlMbsTaskPending) { pMbsInst->pTaskInfo [index].abortTask = True; status = TMDL_ERR_MBS_BUSY; } else if (pMbsInst->pTaskInfo [index].taskStatus == tmdlMbsTaskInFifo) { status = TMDL_ERR_MBS_BUSY; } } } if ((status == TMDL_ERR_MBS_BUSY) && (MbsInstanceCount (unit) == 1)) { // if tasks busy and only 1 instance open, reset the MBS to // clear the tasks MbsTaskReset (unit, tmdlMbsResetTasks); status = TM_OK; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -