Beispiel #1
0
void DMA_start(void* handle)
{

	 ACPY3_start((IDMA3_Handle)handle);

            /* wait for transfer to finish  */
           // ACPY3_wait(videncObj->dmaHandle1D1D8B);
}
Beispiel #2
0
/*
 *  ======== VIDENCCOPY_TI_process ========
 */
XDAS_Int32 VIDENCCOPY_TI_process(IVIDENC_Handle h, XDM_BufDesc *inBufs,XDM_BufDesc *outBufs, IVIDENC_InArgs *inArgs, IVIDENC_OutArgs *outArgs)
{
    XDAS_Int32 curBuf;
    XDAS_UInt32 minSamples;

#ifdef USE_ACPY3
    const Uint32 maxTransferChunkSize       = 0xffff;
    Uint32       thisTransferChunkSize      = 0x0;
    Uint32       remainingTransferChunkSize;
    Uint32       thisTransferSrcAddr, thisTransferDstAddr;

    ACPY3_Params params;
    VIDENCCOPY_TI_Obj *videncObj = (VIDENCCOPY_TI_Obj *)h;
#endif

    Log_print5(Diags_ENTRY, "[+E] VIDENCCOPY_TI_process(0x%x, 0x%x, 0x%x, "
            "0x%x, 0x%x)",
            (IArg)h, (IArg)inBufs, (IArg)outBufs, (IArg)inArgs, (IArg)outArgs);

    /* validate arguments - this codec only supports "base" xDM. */
    if ((inArgs->size != sizeof(*inArgs)) ||
        (outArgs->size != sizeof(*outArgs))) {

        Log_print2(Diags_ENTRY,
                "[+E] VIDENCCOPY_TI_process, unsupported size (0x%x, 0x%x)",
                (IArg)(inArgs->size), (IArg)(outArgs->size));

        return (IVIDENC_EFAIL);
    }

#ifdef USE_ACPY3
    /*
     * Activate Channel  scratch DMA channels.
     */
    //ACPY3_activate(videncObj->dmaHandle1D1D8B);
#endif

    /* outArgs->bytesGenerated reports the total number of bytes generated */
    outArgs->bytesGenerated = 0;

    /*
     * A couple constraints for this simple "copy" codec:
     *    - Video encoding presumes a single input buffer, so only one input
     *      buffer will be encoded, regardless of inBufs->numBufs.
     *    - Given a different size of an input and output buffers, only
     *      encode (i.e., copy) the lesser of the sizes.
     */



    for (curBuf = 0; (curBuf < inBufs->numBufs) &&
        (curBuf < outBufs->numBufs); curBuf++) {

        /* there's an available in and out buffer, how many samples? */
        minSamples = inBufs->bufSizes[curBuf] < outBufs->bufSizes[curBuf] ?
            inBufs->bufSizes[curBuf] : outBufs->bufSizes[curBuf];

#ifdef USE_ACPY3

#if 0
        thisTransferSrcAddr        = (Uint32)inBufs->bufs[curBuf];
        thisTransferDstAddr        = (Uint32)outBufs->bufs[curBuf];
        remainingTransferChunkSize = minSamples;

        while (remainingTransferChunkSize > 0) {

            if (remainingTransferChunkSize > maxTransferChunkSize) {
               thisTransferChunkSize = maxTransferChunkSize;
            }
            else {
               thisTransferChunkSize = remainingTransferChunkSize;
            }

            /* Configure the logical channel */
            params.transferType = ACPY3_1D1D;
            params.srcAddr      = (void *)thisTransferSrcAddr;
            params.dstAddr      = (void *)thisTransferDstAddr;
            params.elementSize  = thisTransferChunkSize;
            params.numElements  = 1;
            params.waitId       = 0;
            params.numFrames    = 1;

            remainingTransferChunkSize -= thisTransferChunkSize;
            thisTransferSrcAddr += thisTransferChunkSize;
            thisTransferDstAddr += thisTransferChunkSize;

            /* Configure logical dma channel */
            ACPY3_configure(videncObj->dmaHandle1D1D8B, &params, 0);

            /* Use DMA to copy data */
            ACPY3_start(videncObj->dmaHandle1D1D8B);

            /* wait for transfer to finish  */
            ACPY3_wait(videncObj->dmaHandle1D1D8B);
        }
        Log_print1(Diags_USER2, "[+2] VIDENCCOPY_TI_process> "
                "ACPY3 Processed %d bytes.", (IArg)minSamples);
#endif
#else
        Log_print3(Diags_USER2, "[+2] VIDENCCOPY_TI_process> "
                "memcpy (0x%x, 0x%x, %d)",
                (IArg)(outBufs->bufs[curBuf]), (IArg)(inBufs->bufs[curBuf]),
                (IArg)minSamples);

        /* process the data: read input, produce output */
        memcpy(outBufs->bufs[curBuf], inBufs->bufs[curBuf], minSamples);
#endif

        outArgs->bytesGenerated += minSamples;
    }


#ifdef USE_ACPY3
    /*
     * Deactivate Channel  scratch DMA channels.
     */
    //ACPY3_deactivate(videncObj->dmaHandle1D1D8B);

	//videncObj->p_data //avi mem

	runOnce(videncObj->p_data, videncObj->p_ddr_data, videncObj->p_DARAM0, videncObj->dmaHandle1D1D8B);
	DspModule(inBufs->bufs[0], outBufs->bufs[0]);

	//memcpy(outBufs->bufs[0] + 8,&(videncObj->p_DARAM0),4);
	runOver();

#endif


	

    /* Fill out the rest of the outArgs struct */
    outArgs->extendedError = 0;
    outArgs->encodedFrameType = 0;    /* TODO */
    outArgs->inputFrameSkip = IVIDEO_FRAME_ENCODED;
    outArgs->reconBufs.numBufs = 0;   /* important: indicate no reconBufs */
    return (IVIDENC_EOK);
}
/* ARGSUSED - this line tells the TI compiler not to warn about unused args. */
XDAS_Int32 VIDENC1COPY_TI_process(IVIDENC1_Handle h, IVIDEO1_BufDescIn *inBufs,
    XDM_BufDesc *outBufs, IVIDENC1_InArgs *inArgs, IVIDENC1_OutArgs *outArgs)
{
    XDAS_Int32 numInBytes;

#ifdef USE_ACPY3
    const Uint32 maxTransferChunkSize       = 0xffff;
    Uint32       thisTransferChunkSize      = 0x0;
    Uint32       remainingTransferChunkSize;
    Uint32       thisTransferSrcAddr, thisTransferDstAddr;

    ACPY3_Params params;
    VIDENC1COPY_TI_Obj *videncObj = (VIDENC1COPY_TI_Obj *)h;
#endif
    /*
     * Validate arguments - this codec supports "base" XDM and an extended
     * inArgs.
     */
    if (((inArgs->size != sizeof(*inArgs)) &&
            (inArgs->size != sizeof(IVIDENC1CPY_InArgs))) ||
        (outArgs->size != sizeof(*outArgs))) {

        XDM_SETUNSUPPORTEDPARAM(outArgs->extendedError);

        return (IVIDENC1_EUNSUPPORTED);
    }

    /* validate that there's at least a single inBuf and outBuf */
    if ((inBufs->numBufs < 1) || (outBufs->numBufs < 1)) {
        XDM_SETUNSUPPORTEDPARAM(outArgs->extendedError);

        return (IVIDENC1_EFAIL);
    }

    /* validate inputID */
    if (inArgs->inputID == 0) {
        XDM_SETUNSUPPORTEDPARAM(outArgs->extendedError);

        return (IVIDENC1_EFAIL);
    }

    /* there's an available in and out buffer, how many samples? */
    numInBytes = inBufs->bufDesc[0].bufSize < outBufs->bufSizes[0] ?
        inBufs->bufDesc[0].bufSize : outBufs->bufSizes[0];

    /* and honor the extended maxBytes if it was provided */
    if (inArgs->size == sizeof(IVIDENC1CPY_InArgs)) {
        if (numInBytes > ((IVIDENC1CPY_InArgs *)inArgs)->maxBytes) {
            numInBytes = ((IVIDENC1CPY_InArgs *)inArgs)->maxBytes;
        }
    }
#ifdef USE_ACPY3
    /*
     * Activate Channel scratch DMA channels.
     */
    ACPY3_activate(videncObj->dmaHandle1D1D8B);

    thisTransferSrcAddr        = (Uint32)inBufs->bufDesc[0].buf;
    thisTransferDstAddr        = (Uint32)outBufs->bufs[0];
    remainingTransferChunkSize = numInBytes;

    while (remainingTransferChunkSize > 0) {

        if (remainingTransferChunkSize > maxTransferChunkSize) {
           thisTransferChunkSize = maxTransferChunkSize;
        }
        else {
           thisTransferChunkSize = remainingTransferChunkSize;
        }

        /* Configure the logical channel */
        params.transferType = ACPY3_1D1D;
        params.srcAddr      = (void *)thisTransferSrcAddr;
        params.dstAddr      = (void *)thisTransferDstAddr;
        params.elementSize  = thisTransferChunkSize;
        params.numElements  = 1;
        params.waitId       = 0;
        params.numFrames    = 1;

        remainingTransferChunkSize -= thisTransferChunkSize;
        thisTransferSrcAddr += thisTransferChunkSize;
        thisTransferDstAddr += thisTransferChunkSize;

        /* Configure logical dma channel */
        ACPY3_configure(videncObj->dmaHandle1D1D8B, &params, 0);

        /* Use DMA to copy data */
        ACPY3_start(videncObj->dmaHandle1D1D8B);

        /* wait for transfer to finish  */
        ACPY3_wait(videncObj->dmaHandle1D1D8B);
    }

    /*
     * Deactivate Channel scratch DMA channels.
     */
    ACPY3_deactivate(videncObj->dmaHandle1D1D8B);

    /*
     * Because we used DMA, the algo processor didn't accessed either of the
     * 2 data buffers.
     */
    XDM_CLEARACCESSMODE_READ(inBufs->bufDesc[0].accessMask);
    XDM_CLEARACCESSMODE_WRITE(inBufs->bufDesc[0].accessMask);

    XDM_CLEARACCESSMODE_READ(outArgs->encodedBuf.accessMask);
    XDM_CLEARACCESSMODE_WRITE(outArgs->encodedBuf.accessMask);

#else
    /* everything looks good, do the 'encode', set outArgs and return */
    memcpy(outBufs->bufs[0], inBufs->bufDesc[0].buf, numInBytes);

    /* memcpy read from inBuf and wrote to encodedBuf (in our case, outBuf) */
    XDM_CLEARACCESSMODE_WRITE(inBufs->bufDesc[0].accessMask);
    XDM_SETACCESSMODE_READ(inBufs->bufDesc[0].accessMask);

    XDM_CLEARACCESSMODE_READ(outArgs->encodedBuf.accessMask);
    XDM_SETACCESSMODE_WRITE(outArgs->encodedBuf.accessMask);
#endif

    /* outArgs->bytesGenerated reports the total number of bytes encoded */
    outArgs->bytesGenerated = numInBytes;

    /* report that the encoded data is in outArgs->encodedBuf */
    outArgs->encodedBuf.buf = outBufs->bufs[0];
    outArgs->encodedBuf.bufSize = outBufs->bufSizes[0];

    /* Fill out the rest of the outArgs struct */
    outArgs->extendedError = 0;
    outArgs->encodedFrameType = 0;     /* TODO */
    outArgs->inputFrameSkip = IVIDEO_FRAME_ENCODED;
    outArgs->outputID = inArgs->inputID;

    /* TODO - add support for reconBufs */
    outArgs->reconBufs.numBufs = 0;

    return (IVIDENC1_EOK);
}