dm8127 dsp edma 拷貝資料

smilestone322發表於2015-04-17

edma簡介

http://blog.sina.com.cn/s/blog_4512a68501000ah4.html

http://blog.sina.com.cn/s/blog_4512a68501000ah3.html

 

/* FD link copy frames */

/* ===================================================================
 *  @func     FdLink_copyFrames                                               
 *                                                                    
 *  @desc     Function does the following                             
 *                                                                    
 *  @modif    This function modifies the following structures         
 *                                                                    
 *  @inputs   This function takes the following inputs                
 *            <argument name>                                         
 *            Description of usage                                    
 *            <argument name>                                         
 *            Description of usage                                    
 *                                                                    
 *  @outputs  <argument name>                                         
 *            Description of usage                                    
 *                                                                    
 *  @return   Return value of this function if any                    
 *  ==================================================================
 */                                                                   
Int32 FdLink_copyFrames(FdLink_Obj * pObj)
{
    Int32 status;

    Int32 frameId;

    UInt32 edmaWidth, edmaHeight;

    FVID2_Frame *pEmptyFrame;

    FVID2_Frame *pFullFrame;

    FVID2_FrameList frameList;

    System_LinkInQueParams *pInQueParams;

    /* Get the full frames from the previous link */
    pInQueParams = &pObj->createArgs.inQueParams;

    System_getLinksFullFrames(pInQueParams->prevLinkId,
                              pInQueParams->prevLinkQueId, &frameList);

    if (frameList.numFrames)
    {
        for (frameId = 0; frameId < frameList.numFrames; frameId++)
        {
            /* Post Frame Sync SWOSD sem */
            SwosdLink_postFrameSyncSem(pObj->createArgs.swOsdId);

            /* Get the FD empty bufs if any */
            status =
                Utils_bufGetEmptyFrame(&pObj->outFrameQue, &pEmptyFrame,
                                       BIOS_NO_WAIT);

            if ((status == FVID2_SOK) && (pEmptyFrame != NULL))
            {
                pFullFrame = frameList.frames[frameId];

                /* copy the frame */
                edmaWidth = pObj->algHndl.fdWidth;
                edmaHeight = pObj->algHndl.fdHeight;
                pEmptyFrame->timeStamp = pFullFrame->timeStamp;

      <span style="color:#ff0000;">          /* copy only Y plane as FD works only on Y plane */
                DM81XX_EDMA3_setParams(FD_LINK_EDMA3_CH_ID, // chId
                                       FD_LINK_EDMA3_QUEUE_ID,  // dmaQueue
                                       (UInt32) pFullFrame->addr[0][0], // srcAddr
                                       (UInt32) pEmptyFrame->addr[0][0],    // dstAddr
                                       edmaWidth,          // edmaWidth
                                       edmaHeight,         // edmaHeight
                                       edmaWidth,          // srcLineOffset
                                       edmaWidth);         // dstLineOffset

                /* Trigger the edma transfer */
                DM81XX_EDMA3_triggerTransfer(FD_LINK_EDMA3_CH_ID);

</span>                /* put the buffer into full queue */
                status = Utils_bufPutFullFrame(&pObj->outFrameQue, pEmptyFrame);

                UTILS_assert(status == FVID2_SOK);
            }
        }

        /* Put the full buffers bacl to previous link */
        System_putLinksEmptyFrames(pInQueParams->prevLinkId,
                                   pInQueParams->prevLinkQueId, &frameList);
    }

    return FVID2_SOK;
}


 

Int32 VaLink_algCopyFrames(VaLink_Obj *pObj)
{
    Int32 status;
	Int32 ret = FVID2_EFAIL;
    Int32 frameId;
    UInt32 edmaWidth, edmaHeight;
    FVID2_Frame *pEmptyFrame;
    FVID2_Frame *pFullFrame;
    FVID2_FrameList frameList;
    System_LinkInQueParams *pInQueParams;
	VaLink_algObj *pAlgObj = &pObj->algObj;

    /* Get the full frames from the previous link */
    pInQueParams = &pObj->createArgs.inQueParams;

    System_getLinksFullFrames(pInQueParams->prevLinkId,
                              pInQueParams->prevLinkQueId, &frameList);

    if (frameList.numFrames)
    {
        for (frameId = 0; frameId < frameList.numFrames; frameId++)
        {
            if(Utils_doSkipFrame(&pAlgObj->frameSkipContext) == FALSE)
			{
				/* Get the VA empty bufs if any */
				status = Utils_bufGetEmptyFrame(&pObj->outFrameQue, &pEmptyFrame,BIOS_NO_WAIT);

				if ((status == FVID2_SOK) && (pEmptyFrame != NULL))
				{
					pFullFrame = frameList.frames[frameId];

					/* copy the frame */
					edmaWidth  = pObj->inQueInfo.chInfo[0].width;
					edmaHeight = pObj->inQueInfo.chInfo[0].height;

					/* copy Y plane */
					<span style="color:#ff0000;">DM81XX_EDMA3_setParams(VA_LINK_EDMA3_CH_ID,</span> 			// chId
										   VA_LINK_EDMA3_QUEUE_ID,  		// dmaQueue
										   (UInt32)pFullFrame->addr[0][0], 	// srcAddr
										   (UInt32)pEmptyFrame->addr[0][0],	// dstAddr
										   edmaWidth,          				// edmaWidth
										   edmaHeight,         				// edmaHeight
										   edmaWidth,          				// srcLineOffset
										   edmaWidth);         				// dstLineOffset

					<span style="color:#ff0000;">/* Trigger the edma transfer */
					DM81XX_EDMA3_triggerTransfer(VA_LINK_EDMA3_CH_ID);

</span>					pEmptyFrame->timeStamp = pFullFrame->timeStamp;

					/* put the buffer into full queue */
					status = Utils_bufPutFullFrame(&pObj->outFrameQue, pEmptyFrame);
					UTILS_assert(status == FVID2_SOK);

					ret = FVID2_SOK;
				}
			}
        }

        /* Put the full buffers bacl to previous link */
        System_putLinksEmptyFrames(pInQueParams->prevLinkId,
                                   pInQueParams->prevLinkQueId, &frameList);
    }

    return ret;
}

相關文章