/* * ======== SWOSD_TI_initResources ======== */ static IRES_Status SWOSD_TI_initResources(IALG_Handle h, IRES_ResourceDescriptor *desc, IRES_YieldFxn yieldFxn, IRES_YieldArgs yieldArgs) { SWOSD_TI_Obj *alg = (SWOSD_TI_Obj *)h; SWOSD_DMAObj *dmaHandle = (SWOSD_DMAObj *)&alg->dmaHandle; UInt8 i; ECPY_init(); /* * Resource manager has returned a resource handle. Save it in the * algorithm's instance object */ for(i = 0; i < SWOSD_DMA_CH_MAX; i++) { IRES_EDMA3CHAN2_Handle edma3Handle = (IRES_EDMA3CHAN2_Handle) desc[i].handle; alg->edmaHandle[i] = edma3Handle; alg->ecpyHandle[i] = ECPY_createHandle(edma3Handle, h); dmaHandle->edma3ResourceHandles[i] = edma3Handle; /* Initialize EDMA resource structures for H264VDEC_DMAOpen() call */ dmaHandle->edma_params_array[i] = (UInt32 *) edma3Handle->assignedPaRamAddresses[0]; dmaHandle->edma_tcc_array[i] = edma3Handle->assignedTccIndices[0]; dmaHandle->edma_phy_to_lgl_map[i] = edma3Handle->assignedEdmaChannelIndex; } dmaHandle->num_edma_channels = SWOSD_DMA_CH_MAX; dmaHandle->channel_mask_low = 0; dmaHandle->channel_mask_high = 0; return (IRES_OK); }
/********************************************************************************* * FUNCTION PURPOSE: Allocate EdmaMgr handle ********************************************************************************* DESCRIPTION: This function allocates an EDMA channel Parameters : Inputs: max_linked_transfer : maximum number of linked transfers required for the channel. Output: Valid EdmaMgr handle on success; NULL handle if there is an error. *********************************************************************************/ EdmaMgr_Handle EdmaMgr_alloc(int32_t max_linked_transfers) { IRES_ResourceDescriptor resDesc; IRES_Status ires_status; int32_t scratchId = -1; int32_t i; /* Find free channel */ for (i = 0; i < EDMA_MGR_MAX_NUM_CHANNELS; i++) if (EdmaMgr_channels[i].edmaArgs.numPaRams == 0) break; if (i >= EDMA_MGR_MAX_NUM_CHANNELS) return ((EdmaMgr_Handle)NULL); EdmaMgr_channels[i].edmaArgs.numPaRams = max_linked_transfers; /* Prepare IRES resource descriptor */ resDesc.resourceName = IRES_EDMA3CHAN_PROTOCOLNAME; resDesc.revision = &_iresEDMA3ChanRevision; resDesc.protocolArgs = (IRES_ProtocolArgs *)&(EdmaMgr_channels[i].edmaArgs); resDesc.handle = (IRES_Handle)EdmaMgr_channels[i].edmaHandle; /* Allocate EDMA Resources */ ires_status = RMAN_allocateResources((Int)EdmaMgr_channels, &resDesc, 1, scratchId); if (ires_status != IRES_OK) { EdmaMgr_channels[i].edmaArgs.numPaRams = 0; return ((EdmaMgr_Handle)NULL); } EdmaMgr_channels[i].edmaHandle = (IRES_EDMA3CHAN_Handle) resDesc.handle; /* Create ECPY handle */ EdmaMgr_channels[i].ecpyHandle = ECPY_createHandle((IRES_EDMA3CHAN2_Handle)resDesc.handle, (IALG_Handle)&EdmaMgr_channels[i]); if (EdmaMgr_channels[i].ecpyHandle == NULL) { RMAN_freeAllocatedResources((Int)EdmaMgr_channels, &resDesc, 1, scratchId); EdmaMgr_channels[i].edmaHandle = NULL; EdmaMgr_channels[i].edmaArgs.numPaRams = 0; return ((EdmaMgr_Handle)NULL); } EdmaMgr_channels[i].xferPending = FALSE; /* HW assign */ ECPY_activate(EdmaMgr_channels[i].ecpyHandle); ECPY_setEarlyCompletionMode(EdmaMgr_channels[i].ecpyHandle, FALSE); return ((EdmaMgr_Handle)&EdmaMgr_channels[i]); }