/* 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, ¶ms, 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); }
/* * ======== 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 GT_5trace(curTrace, GT_ENTER, "VIDENCCOPY_TI_process(0x%x, 0x%x, 0x%x, " "0x%x, 0x%x)\n", h, inBufs, outBufs, inArgs, outArgs); /* validate arguments - this codec only supports "base" xDM. */ if ((inArgs->size != sizeof(*inArgs)) || (outArgs->size != sizeof(*outArgs))) { GT_2trace(curTrace, GT_ENTER, "VIDENCCOPY_TI_process, unsupported size " "(0x%x, 0x%x)\n", inArgs->size, 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 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, ¶ms, 0); /* Use DMA to copy data */ ACPY3_start(videncObj->dmaHandle1D1D8B); /* wait for transfer to finish */ ACPY3_wait(videncObj->dmaHandle1D1D8B); } GT_1trace(curTrace, GT_2CLASS, "VIDENCCOPY_TI_process> " "ACPY3 Processed %d bytes.\n", minSamples); #else GT_3trace(curTrace, GT_2CLASS, "VIDENCCOPY_TI_process> " "memcpy (0x%x, 0x%x, %d)\n", outBufs->bufs[curBuf], inBufs->bufs[curBuf], minSamples); /* process the data: read input, produce output */ memcpy(outBufs->bufs[curBuf], inBufs->bufs[curBuf], minSamples); #endif outArgs->bytesGenerated += minSamples; } /* 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); }