楼主。最近还有在搞DaVinci么?我用的是天漠的Devkit8500.现在在尝试添加自己的算法时遇到了问题。我只是在videnc_copy这个codec修改了如下
/*
* ======== VIDENCCOPY_TI_alloc ========
*/
Int VIDENCCOPY_TI_alloc(const IALG_Params *algParams,
IALG_Fxns **pf, IALG_MemRec memTab[])
{
if (curTrace.modName == NULL) { /* initialize GT (tracing) */
GT_create(&curTrace, GTNAME);
}
GT_3trace(curTrace, GT_ENTER, "VIDENCCOPY_TI_alloc(0x%x, 0x%x, 0x%x)\n",
algParams, pf, memTab);
/* Request memory for my object */
memTab[0].size = sizeof(VIDENCCOPY_TI_Obj);
memTab[0].alignment = 0;
memTab[0].space = IALG_EXTERNAL;
memTab[0].attrs = IALG_PERSIST;
memTab[1].size = sizeof(IplImage);
memTab[1].alignment = 0;
memTab[1].space = IALG_EXTERNAL;
memTab[1].attrs = IALG_PERSIST;
memTab[2].size = sizeof(IplImage);
memTab[2].alignment = 0;
memTab[2].space = IALG_EXTERNAL;
memTab[2].attrs = IALG_PERSIST;
memTab[3].size = 640*480*sizeof(XDAS_UInt8);
memTab[3].alignment = 0;
memTab[3].space = IALG_EXTERNAL;
memTab[3].attrs = IALG_PERSIST;
memTab[4].size = 320*480*sizeof(XDAS_UInt8);
memTab[4].alignment = 0;
memTab[4].space = IALG_EXTERNAL;
memTab[4].attrs = IALG_PERSIST;
memTab[5].size = 320*480*sizeof(XDAS_UInt8);
memTab[5].alignment = 0;
memTab[5].space = IALG_EXTERNAL;
memTab[5].attrs = IALG_PERSIST;
return (6);
}
/*
* ======== VIDENCCOPY_TI_free ========
*/
Int VIDENCCOPY_TI_free(IALG_Handle handle, IALG_MemRec memTab[])
{
VIDENCCOPY_TI_Obj *VIDENC_COPY = (VIDENCCOPY_TI_Obj *)handle;
GT_2trace(curTrace, GT_ENTER, "VIDENCCOPY_TI_free(0x%lx, 0x%lx)\n",
handle, memTab);
VIDENCCOPY_TI_alloc(NULL, NULL, memTab);
memTab[0].base = handle;
memTab[1].base = VIDENC_COPY->IMG_Y;
memTab[1].size = sizeof(IplImage);
memTab[2].base = VIDENC_COPY->IMG_H;
memTab[2].size = sizeof(IplImage);
memTab[3].base = VIDENC_COPY->CamY;
memTab[3].size = 640 * 480 *sizeof(XDAS_UInt8);
memTab[4].base = VIDENC_COPY->CamU;
memTab[4].size = 320 * 480 *sizeof(XDAS_UInt8);
memTab[5].base = VIDENC_COPY->CamV;
memTab[5].size = 320 * 480 *sizeof(XDAS_UInt8);
return (6);
}
/*
* ======== VIDENCCOPY_TI_initObj ========
*/
Int VIDENCCOPY_TI_initObj(IALG_Handle handle,
const IALG_MemRec memTab[], IALG_Handle p,
const IALG_Params *algParams)
{
VIDENCCOPY_TI_Obj *VIDENC_COPY = (VIDENCCOPY_TI_Obj *)handle;
VIDENC_COPY->IMG_Y = memTab[1].base;
VIDENC_COPY->IMG_H = memTab[2].base;
VIDENC_COPY->CamY = memTab[3].base;
VIDENC_COPY->CamU = memTab[4].base;
VIDENC_COPY->CamV = memTab[5].base;
GT_4trace(curTrace, GT_ENTER,
"VIDENCCOPY_TI_initObj(0x%x, 0x%x, 0x%x, 0x%x)\n", handle, memTab,
p, algParams);
return (IALG_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;
XDAS_UInt32 m,n,l;
Uint8* pointer;
XDAS_UInt8 *CameraY;
XDAS_UInt8 *CameraU;
XDAS_UInt8 *CameraV;
VIDENCCOPY_TI_Obj *VIDENC_COPY = (VIDENCCOPY_TI_Obj *)h;
#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);
}
CameraY = VIDENC_COPY -> CamY;
CameraU = VIDENC_COPY -> CamU;
CameraV = VIDENC_COPY -> CamV;
pointer = (Uint8 *)inBufs->bufs;
l=0;
for(m=0;m<480;m++)
{
for(n=0;n<320;n++)
{
*(CameraY) = *( pointer + (m*320+n)*4);
CameraY ++;
*(CameraU) = *( pointer + (m*320+n)*4 + 1);
CameraU ++;
*(CameraY) = *( pointer + (m*320+n)*4 + 2);
CameraY ++;
*(CameraV) = *( pointer + (m*320+n)*4 + 3);
CameraV ++;
}
}
VIDENC_COPY -> IMG_Y -> imageData = VIDENC_COPY -> CamY;
VIDENCCOPY_TI_MyYCbCr2Hue (VIDENC_COPY -> IMG_Y -> imageData, VIDENC_COPY -> CamU, VIDENC_COPY -> CamV, VIDENC_COPY -> IMG_H ->imageData, VIDENCCOPY_TI_CapSize);
#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++) {*/
for (curBuf = 0; curBuf < 640*480; 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], VIDENC_COPY -> IMG_Y ->imageData, 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);
}
编译是成功的,但是在运行时却出现如下问题
DSP MMU Error Fault! MMU_IRQSTATUS = [0x1]. Virtual DSP addr reference that generated the interrupt = [0x85900000].
我加载cmemk时用的命令是这个insmod cmemk.ko allowOverlap=1 phys_start=0x84f00000 phys_end=0x85900000 pools=1x5250000,5x829440,1x345600,1x691200,1x1 allowOverlap=1,楼主有遇到这个问题么?我用的是dvsdk4_03,有什么解决思路可以供我参考么?
谢谢 |