/*
 *  ======= ACPY3_start ========
 *  Submit a single or linked transfer using the most recently.
 *  configured transfer parameter settings.
 */
void ACPY3_start(IDMA3_Handle handle)
{
    GT_1trace(ti_sdo_fc_acpy3_GTMask, GT_ENTER, "ACPY3_start> Enter "
            "(handle=0x%x)\n",handle);

    if (handle->transferPending) {

        /* Wait for previously started transfer (if any) to complete */

        GT_0trace(ti_sdo_fc_acpy3_GTMask, GT_4CLASS, "ACPY3_start> Waiting for"
                " previously started transfer\n");

        ACPY3_wait(handle);
    }

    /*
     * As soon as channel is clear mark the channel state to indicate a
     * new transfer is being issued and 'transfer is pending'.
     * Only a subsequent 'ACPY3_wait' will clear the pending state.
     */
    handle->transferPending = TRUE;

    GT_0trace(ti_sdo_fc_acpy3_GTMask, GT_ENTER, "ACPY3_start> Exit\n");

}
/*
 *  ======= ACPY3_waitLinked ========
 * Blocking wait for an individual transfer in a Linked transfer to finish.
 * Requires the individual transfer indicated by the 'waitId'
 * to be configured as synchronous, otherwise returns immediately.
 */
Void ACPY3_waitLinked(IDMA3_Handle handle, unsigned short waitId)
{

    GT_2trace(CURTRACE, GT_ENTER, "ACPY3_waitLinked> Enter "
            "(handle=0x%x, waitId=%d)\n", handle, waitId);

    GT_assert(CURTRACE, (handle != NULL) && (waitId < handle->numTccs));

    ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks,
            handle, ACPY3_INSTR_WAITLINKED_ENTER);
    /*
     * Wait for a channel only once. Set the 'pending' flag whenever new
     * transfer is submitted, then clear it when ACPY3_wait* is issued.
     */
    if (handle->transferPending == FALSE) {
        ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks,
                handle, ACPY3_INSTR_WAITLINKED_EXIT);

        GT_0trace(CURTRACE, GT_4CLASS, "ACPY3_waitLinked> "
                "No transfer pending \n");

        GT_0trace(CURTRACE, GT_ENTER, 
                "ACPY3_waitLinked> Exit\n");

        return;  /* already  waited since last start. */
    }

    if (waitId == (handle->numTccs - 1)) {

        GT_0trace(CURTRACE, GT_4CLASS, "ACPY3_waitLinked> "
                "Waiting on the last transfer\n");

        ACPY3_wait(handle);
    }
    else {
        doTransfer(handle);
    }

    /*
     * Mark channel handle state to indicate pending transfer has completed
     * and 'wait' done
     */
    handle->transferPending = FALSE;

    ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks,
            handle, ACPY3_INSTR_WAITLINKED_EXIT);

    GT_0trace(CURTRACE, GT_ENTER, "ACPY3_waitLinked> Exit\n");
}
/*
 *  ======= ACPY3_waitLinked ========
 * Blocking wait for an individual transfer in a Linked transfer to finish.
 * Requires the individual transfer indicated by the 'waitId'
 * to be configured as synchronous, otherwise returns immediately.
 */
Void ACPY3_waitLinked(IDMA3_Handle handle, unsigned short waitId)
{

    Log_print2(Diags_ENTRY, "[+E] ACPY3_waitLinked> Enter "
            "(handle=0x%x, waitId=%d)", (IArg)handle, (IArg)waitId);

    Assert_isTrue((handle != NULL) && (waitId < handle->numTccs),
            (Assert_Id)NULL);

    ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks,
            handle, ACPY3_INSTR_WAITLINKED_ENTER);
    /*
     * Wait for a channel only once. Set the 'pending' flag whenever new
     * transfer is submitted, then clear it when ACPY3_wait* is issued.
     */
    if (handle->transferPending == FALSE) {
        ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks,
                handle, ACPY3_INSTR_WAITLINKED_EXIT);

        Log_print0(Diags_USER4, "[+4] ACPY3_waitLinked> No transfer pending");

        Log_print0(Diags_EXIT, "[+X] ACPY3_waitLinked> Exit");

        return;  /* already  waited since last start. */
    }

    if (waitId == (handle->numTccs - 1)) {

        Log_print0(Diags_USER4, "[+4] ACPY3_waitLinked> "
                "Waiting on the last transfer");

        ACPY3_wait(handle);
    }
    else {
        doTransfer(handle);
    }

    /*
     * Mark channel handle state to indicate pending transfer has completed
     * and 'wait' done
     */
    handle->transferPending = FALSE;

    ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks,
            handle, ACPY3_INSTR_WAITLINKED_EXIT);

    Log_print0(Diags_EXIT, "[+X] ACPY3_waitLinked> Exit");
}
/*
 *  ======= ACPY3_waitLinked ========
 * Blocking wait for an individual transfer in a Linked transfer to finish.
 * Requires the individual transfer indicated by the 'waitId'
 * to be configured as synchronous, otherwise returns immediately.
 */
Void ACPY3_waitLinked(IDMA3_Handle handle, unsigned short waitId)
{
    Log_print2(Diags_ENTRY, "[+E] ACPY3_waitLinked> Enter "
            "(handle=0x%x, waitId=%d)", (IArg)handle, (IArg)waitId);

    Assert_isTrue((handle != NULL) && (waitId <= handle->numTccs - 1),
            (Assert_Id)NULL);

    ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks,
            handle, ACPY3_INSTR_WAITLINKED_ENTER);

    /*
     * Wait for a channel only once. Set the 'pending' flag whenever new
     * transfer is submitted, then clear it when ACPY3_wait* is issued.
     */
    if (handle->transferPending == FALSE) {

        ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks,
                handle, ACPY3_INSTR_WAITLINKED_EXIT);

        Log_print0(Diags_USER4, "[+4] ACPY3_waitLinked> No transfer pending");

        Log_print0(Diags_EXIT, "[+X] ACPY3_waitLinked> Exit");

        return;  /* already  waited since last start. */
    }

    if (waitId == (handle->numTccs - 1) ) {

        Log_print0(Diags_USER4, "[+4] ACPY3_waitLinked> "
                "Waiting for the last transfer to complete");

        ACPY3_wait(handle);
    }
    else {
        waitForTransferToComplete(handle->tccTable[waitId + 1]);
    }
    /*
     * NOTE: Individual transfer TCC bits for intermediate transfers
     * are not cleared until the last transfer is waited on.
     */
     ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks,
            handle, ACPY3_INSTR_WAITLINKED_EXIT);

    Log_print0(Diags_EXIT, "[+X] ACPY3_waitLinked> Exit");

}
/*
 *  ======= ACPY3_waitLinked ========
 * Blocking wait for an individual transfer in a Linked transfer to finish.
 * Requires the individual transfer indicated by the 'waitId'
 * to be configured as synchronous, otherwise returns immediately.
 */
Void ACPY3_waitLinked(IDMA3_Handle handle, unsigned short waitId)
{
    GT_assert(CURTRACE, (handle != NULL) && (waitId <= handle->numTccs - 1));

    /*
     * Wait for a channel only once. Set the 'pending' flag whenever new
     * transfer is submitted, then clear it when ACPY3_wait* is issued.
     */
    if (handle->transferPending == FALSE) {
        return;  /* already  waited since last start. */
    }

    if (waitId == (handle->numTccs - 1) ) {
        ACPY3_wait(handle);
    }
    else {
        waitForTransferToComplete(handle->tccTable[waitId + 1]);
    }
    /*
     * NOTE: Individual transfer TCC bits for intermediate transfers
     * are not cleared until the last transfer is waited on.
     */
}
Exemple #6
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);
}
Exemple #7
0
void DMA_wait(void* handle)
{
	ACPY3_wait((IDMA3_Handle)handle);
}
/* 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);
}