Hi all!
DM8127 on ipnc3.0,we want to use DMA copy the cmem data to system memory.
Them modifid codes are as follows:
unsigned char *snapbuf = NULL;
#define BUFSIZE (512*1024)
static int count = 0;
int filesize = 0;
int CacheMng_Video_CacheLock(int serial, VIDEO_BLK_INFO * pVidInfo)
{
.....
if(snapbuf == NULL)
{
snapbuf = malloc(BUFSIZE); //use system memroy
//use cmem memory
//CMEM_AllocParams prm;
//prm.type = CMEM_HEAP;
//prm.flags = CMEM_NONCACHED;
//prm.alignment = 32;
//snapbuf = (Uint8 *)CMEM_alloc(BUFSIZE,&prm);
if (snapbuf == NULL)
OSA_printf("#### zhangjp malloc error\n");
else
{
OSA_printf("#### zhangjp malloc ok\n");
memset(snapbuf,0,BUFSIZE);
}
}
.....
if (pFrame)
{
if(snapbuf != NULL)
{
int ret1 = 0;
char filename[32];
memset(filename,0,sizeof(filename));
if(count++%50 == 0)
{
filesize = pFrame->realsize;
memset(snapbuf,0,BUFSIZE);
CacheMng_MemCpy((void *)snapbuf,
(void *) (pVidInfo->start +pFrame->blkindex * pVidInfo->blk_sz),
filesize);
//memcpy(snapbuf,
// (char *) (pVidInfo->start +pFrame->blkindex * pVidInfo->blk_sz),
// pFrame->realsize);
usleep(300*1000);
sprintf(filename,"/tmp/%d.jpg",count);
ret1 = fileWriteFile(filename,snapbuf,filesize); //save pic to file
if (ret1 == OSA_SOK)
{
OSA_printf("write ok \n");
}
}
}
}
When we use cmem memory and CacheMng_MemCpy(),or use the system memory and
memcpy(),the save jpg file is ok.But use the system memory and
CacheMng_MemCpy() just as the above code,the save jpg file is wrong ,just as
follows pic:
The first half of snapbuf have valid data ,and the second half value are all 0.
Is CacheMng_MemCpy() only use cmem memory?
Thanks!