⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tmdlmbs2.c

📁 PNX1500上做视频缩放MBS的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
        // allocate memory for the task info structure        if ( (pMbsInst->pTaskInfo != Null) &&              (curNrTasks != pMbsInst->totalNrOfTasks) )        {            free(pMbsInst->pTaskInfo);            pMbsInst->pTaskInfo = Null;        }			        if (pMbsInst->pTaskInfo == Null)        {            if ((pMbsInst->pTaskInfo = (ptmdlMbsTaskInfo_t)                 malloc ((pMbsInst->totalNrOfTasks) * sizeof(tmdlMbsTaskInfo_t)))                == Null)            {                status = TMDL_ERR_MBS_INIT_FAILED;            }        }        if (status != TMDL_ERR_MBS_INIT_FAILED)        {            setupProgress = 1;            //  allocate memory for the task lists                        // if memspace exist, check if reusable else delete && create JOPI                        if ( (pMbsInst->mbsMemSpace != Null) &&                  (curNrTasks != pMbsInst->totalNrOfTasks) )            {   // for those cases where instance setup is called more than once                // and the number of tasks is different                // we have to deallocate previous memory spaces                tmmlDelete (pMbsInst->mbsMemSpace);   //  free mem handle                pMbsInst->mbsMemSpace = Null;            }                        if (pMbsInst->mbsMemSpace == Null)            {                status = tmmlCreate (                    &(pMbsInst->mbsMemSpace),                    pMbsInst->totalNrOfTasks * MBS_CMD_BUFFER_SIZE + 128,                    (tmmlMmspCreateFlags_t)                    (tmmlMmspMpCached | tmmlMmspExtendible));                pMbsInst->ptlMemory = Null;                if (status == TM_OK)                {                    status = tmmlMalloc (                        pMbsInst->mbsMemSpace,          // memspace                        pMbsInst->totalNrOfTasks * MBS_CMD_BUFFER_SIZE,                        (pVoid) &(pMbsInst->ptlMemory), // address                        tmmlMallocCacheAligned );       // attribute                    MBS2_ERR_CHECK((status == TM_OK),                                   TMDL_ERR_MBS_INIT_FAILED,                                   "tmdlMbsInstanceSetup: Malloc Failed");                }            }        }    }    if (status == TM_OK)    {        setupProgress = 2;        for (i = 0; i < pMbsInst->totalNrOfTasks; ++i )        {            //  initialize each task to default values            pMbsInst->pTaskInfo[i].empty = True;            pMbsInst->pTaskInfo[i].internallySliced = False;            pMbsInst->pTaskInfo[i].taskHandle = i + 1;            pMbsInst->pTaskInfo[i].taskStatus = tmdlMbsTaskIdle;            pMbsInst->pTaskInfo[i].pCallback = Null;            pCmdBuffer = (pUInt32)                ((UInt32) pMbsInst->ptlMemory + (i * MBS_CMD_BUFFER_SIZE));            pMbsInst->pTaskInfo[i].pCtrlRegs = pCmdBuffer;            pMbsInst->pTaskInfo[i].pNextCmd = pCmdBuffer;            pMbsInst->pTaskInfo[i].taskBase  = (UInt32) pCmdBuffer -                pMbsInst->virt2physOffset;        }    }    if ((status == TM_OK) && (pSetup->nrOfClutModules != 0))    {            // allocate memory for the CLUT modules
			        if ( (pMbsInst->pClutInfo != Null) &&              (curNrClutModules != pSetup->nrOfClutModules) )        {            free(pMbsInst->pClutInfo);            pMbsInst->pClutInfo = Null;        }			        if (pMbsInst->pClutInfo == Null)        {            if ((pMbsInst->pClutInfo = (ptmdlClutModuleInfo_t)                 malloc (pSetup->nrOfClutModules *                         sizeof(tmdlClutModuleInfo_t))) == Null)            {                status = TMDL_ERR_MBS_INIT_FAILED;            }        }        if (status == TM_OK)        {            for (i = 0; i < pSetup->nrOfClutModules; i++)            {                pMbsInst->pClutInfo [i].empty = True;            }        }    }    if (status == TM_OK)    {        pMbsInst->setupDone = True;    }    else    {        //  error, release any allocated resources        switch (setupProgress)        {        case 2:                         //  free task list memory            tmmlFree (pMbsInst->ptlMemory);            pMbsInst->ptlMemory = Null;            //  fall thru        case 1:                         //  free task information memory            free (pMbsInst->pTaskInfo);            pMbsInst->pTaskInfo = Null;            break;        default:            break;        }    }    return status;}   //  tmdlMbsInstanceSetup//-----------------------------------------------------------------------------// FUNCTION:    tmdlMbsRegisterCallback://// DESCRIPTION: Allows device library users to install a callback function//              which will be called when specified events occur.//// RETURN:      Resulting error condition//// NOTES:       The event mask for the callback is initialized to none.//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsRegisterCallback (    tmInstance_t            instance,   //  I: instance    tmCallback_t            pCallback,  //  I: pointer to callback function    UInt32                  userData    //  I: user data to return to callback    ){    UInt32  i;    ptmdlMbsInstance_t  pMbsInst = (ptmdlMbsInstance_t) instance;    // make sure we have a valid instance    DBG_ASSERT2( instance != 0, ("tmdlMbsRegisterCallback: Instance = 0") );    DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY,                  ("tmdlMbsRegisterCallback: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) );    MBS2_ERR_CHECK( pMbsInst->streamMode == False,                    TMDL_ERR_MBS_NOT_SUPPORTED,                    "tmdlMbsRegisterCallback: Not supported in Stream Mode");    //  save the new callback function and user data, and clear all events    for (i = 0; i < pMbsInst->totalNrOfTasks; i +=  pMbsInst->nrOfSlicedTasks )    {        pMbsInst->pTaskInfo[i].pCallback = pCallback;        pMbsInst->pTaskInfo[i].userData = userData;        pMbsInst->pTaskInfo[i].eventMask = tmdlMbsEvtNone;    }    return TM_OK;}//-----------------------------------------------------------------------------// FUNCTION:    tmdlMbsSetEventMask://// DESCRIPTION: Allows the device library user to indicate which events generate//              a call to it's callback function.//// RETURN:      Resulting error condition//// NOTES:       None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsSetEventMask (    tmInstance_t            instance,   //  I: instance    UInt32                  eventMask   //  I: bitwise OR of events    ){    UInt32  i;    ptmdlMbsInstance_t  pMbsInst = (ptmdlMbsInstance_t) instance;    // make sure we have a valid instance    DBG_ASSERT2( instance != 0, ("tmdlMbsSetEventMask: Instance = 0") );    DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY,                  ("tmdlMbsSetEventMask: key 0x%X != 0x%X",                   pMbsInst->key, MBS_INSTANCE_KEY) );    MBS2_ERR_CHECK( pMbsInst->streamMode == False,                    TMDL_ERR_MBS_NOT_SUPPORTED,                    "tmdlMbsSetEventMask: Not supported in Stream Mode");    //  store the new event mask in each task    for (i = 0; i < pMbsInst->totalNrOfTasks;  i +=  pMbsInst->nrOfSlicedTasks )    {        pMbsInst->pTaskInfo[i].eventMask = eventMask;    }    return TM_OK;}//-----------------------------------------------------------------------------// FUNCTION:    tmdlMbsInstanceConfig://// DESCRIPTION: The MBS DevLib is task based, and therefore provides no per//              instance configuration that can be changed.  This function//              will always return an error.//// RETURN:      TMDL_ERR_MBS_NOT_SUPPORTED//// NOTES:       None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsInstanceConfig (    tmInstance_t            instance,    //  I: instance    UInt32                  commandID,   //  I: command ID    pVoid                   parameter    // IO: ptr to parameter    ){    (void) instance;    (void) commandID;    (void) parameter;    return TMDL_ERR_MBS_NOT_SUPPORTED;}//-----------------------------------------------------------------------------// FUNCTION:    tmdlMbsGetPowerState://// DESCRIPTION: get power state (on, standby, suspend, or off)//// RETURN:      resulting error condition//// NOTES:       None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsGetPowerState (    tmInstance_t            instance,    //  I: instance    ptmPowerState_t         pPowerState  //  O: buffer receiving power state    ){    (void) instance;    DBG_ASSERT2( pPowerState != Null, ("tmdlMbsGetPowerState: pPowerState = Null") );    *pPowerState = tmPowerOn;    return TM_OK;}//-----------------------------------------------------------------------------// FUNCTION:    tmdlMbsSetPowerState://// DESCRIPTION: set power state (on, standby, suspend, or off)//// RETURN:      resulting error condition//// NOTES:       None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsSetPowerState (    tmInstance_t        instance,   //  I: instance to stop    tmPowerState_t      powerState  //  I: new power state    ){    (void) instance;    (void) powerState;    return TMDL_ERR_MBS_NOT_SUPPORTED;}//-----------------------------------------------------------------------------// FUNCTION:    tmdlMbsGetSWVersion://// DESCRIPTION: Return the software version of the MBS Device Library.//// RETURN:      resulting error condition//// NOTES:       user must allocate sw version structure//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsGetSWVersion (    ptmSWVersion_t            pSWVersion   //  O: buffer receiving version    ){    DBG_ASSERT2( pSWVersion != Null, ("tmdlMbsGetSWVersion: pSWVersion = Null") );        pSWVersion->compatibilityNr = MBS_DL_COMP_NUM;    pSWVersion->majorVersionNr  = MBS_DL_MAJOR_VER;    pSWVersion->minorVersionNr  = MBS_DL_MINOR_VER;    return TM_OK;}//-----------------------------------------------------------------------------// FUNCTION:    tmdlMbsGetNumberOfUnits://// DESCRIPTION: This function returns the number of MBS units in the system.//// RETURN:      Resulting error condition//// NOTES:       None//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsGetNumberOfUnits (    UInt32*                 pNrOfUnits      //  O: number of MBS HW units    ){    tmErrorCode_t   status;    Int32   nrOfUnits;    DBG_ASSERT2( pNrOfUnits != Null, ("tmdlMbsGetNumberOfUnits: pNrOfUnits = Null") );    status = MbsInit (&nrOfUnits);    *pNrOfUnits = (UInt32) nrOfUnits;    return status;}//-----------------------------------------------------------------------------// FUNCTION:    tmdlMbsGetScaleFactor://// DESCRIPTION: This function returns the scale factor used by the hardware to//              perform scaling.//// RETURN:      tmErrorCode_t = resulting error condition or TM_OK//// NOTES:       filter must be tmdlMbsFilterDirect or tmdlMbsFilterTransposed.//              tmdlMbsFilterTransposed is only supported for horizontal//              downscaling.////              If dynamicZoom is False, the scale factor will be rounded to//              multiple of the number of phases. This function is not entirely//              correct for transposed filtering and should not be used for that.//              Use the internal function tmdlMbsGetScaleFactor2 for that.////              The returned scale factor is based on the input and output sizes//              times a hardware factor of 0x10000 (representing 1:1), and is

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -