This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DSP MMU Error Fault! MMU_IRQSTATUS = [0x1]. Virtual DSP addr reference that generated the interrupt = [0x11000000].

Other Parts Discussed in Thread: TVP5146M2

this is code :

app.c:

/*
 *  ======== app.c ========
 */
#include <xdc/std.h>
#include <ti/sdo/ce/Engine.h>
#include <ti/sdo/ce/osal/Memory.h>
#include <ti/sdo/ce/universal/universal.h>
#include <desay/rvm/rvm_desay.h>
#include <ti/sdo/ce/trace/gt.h>


#include <ti/sdo/linuxutils/cmem/include/cmem.h>

#include <string.h>  /* for memset */

#include <stdio.h>
#include <stdlib.h>
#include "smain.h"
#include "RVM_include_1.h"

static String progName     = "app";
static String universalName  = "rvm";
static String engineName   = "rvm";
extern GT_Mask curMask;
#ifndef BUFALIGN
#define BUFALIGN 128
#else
#define BUFALIGN Memory_DEFAULTALIGNMENT
#endif

#define BUF_SIZE 720*480*2
struct RVM_LookupTable appLUT[1] = {LUT_1};
static XDAS_Int8 *  outbuf;
/*
 *  ======== smain ========
 */
Int smain(Int argc, String argv[], void * s_ptr,struct  RVM_LookupTable  * str_ptr)
{

    printf("smain A!!!\n");
    Engine_Handle ce = NULL;
    UNIVERSAL_Handle hUniversal = NULL;
    UNIVERSAL_InArgs            universalInArgs;
    UNIVERSAL_OutArgs           universalOutArgs;
    XDM1_BufDesc   inputbuf;
    XDM1_BufDesc  outputbuf;
    int    i,n;
    int tmp;
    unsigned int  b_tmp = 3;
    UInt32 tmp_addr;
    Engine_Error err;


    XDAS_Int32 status = 0;
    inputbuf.numBufs=8;
    outputbuf.numBufs=1;

    universalOutArgs.size=sizeof(universalOutArgs);
   
    universalInArgs.size=sizeof(universalInArgs);

    Memory_AllocParams allocParams;
    allocParams = Memory_DEFAULTPARAMS;
    allocParams.type = Memory_CONTIGPOOL;
    allocParams.flags = Memory_NONCACHED;
    allocParams.align = BUFALIGN;
    allocParams.seg = 0;

    printf("smain B!!!\n");
    outbuf = (XDAS_Int8 *)Memory_alloc(BUF_SIZE*sizeof(XDAS_Int8),/*NULL*/&allocParams);
   if(outbuf == NULL) {
 printf("\n outbuf alloc failed!!!\n");
        goto end;
    }


    printf("smain C!!!\n");
    printf("\noutbuf set value!!!\n");
    memset(outbuf,0,BUF_SIZE*sizeof(XDAS_Int8));


    printf("\nsmain D!!! \n ");
  
    printf("\noutputbuf set !!!\n");
    outputbuf.descs[0].bufSize = BUF_SIZE*sizeof(XDAS_Int8);
    outputbuf.descs[0].buf=outbuf;
  
    printf("\ninputbuf set !!!\n");
    inputbuf.descs[0].bufSize = BUF_SIZE*sizeof(XDAS_Int8);
    inputbuf.descs[0].buf = (XDAS_Int8 *) s_ptr;
    printf("\ninputbuf descs[0] set over !!!\n");
    tmp_addr = Memory_getBufferPhysicalAddress(inputbuf.descs[0].buf,BUF_SIZE*sizeof(XDAS_Int8), &b_tmp);
    GT_1trace(curMask, GT_1CLASS, "inputbuf.descs[0].buf pa is:0x%x.\n",(unsigned long)tmp_addr);
    if((tmp = (memcmp(inputbuf.descs[0].buf, s_ptr,BUF_SIZE*sizeof(XDAS_Int8)))) != 0){
 printf("\n in and out data is diff!!!\n");
  GT_0trace(curMask, GT_1CLASS, "App-> memcmp error.\n");
    }

    inputbuf.descs[1].bufSize = MAX_RVM_BLOCK_COUNT * sizeof(unsigned char);
    inputbuf.descs[1].buf = (XDAS_Int8 *)(&(str_ptr->inputBlockHeight[0]));
    printf("\ninputbuf descs[1] set over !!!\n");
    tmp_addr = Memory_getBufferPhysicalAddress(inputbuf.descs[1].buf,MAX_RVM_BLOCK_COUNT * sizeof(unsigned char), &b_tmp);
    GT_1trace(curMask, GT_1CLASS, "inputbuf.descs[1].buf pa is:0x%x.\n",(unsigned long)tmp_addr);
    if((tmp=(memcmp(inputbuf.descs[1].buf,&appLUT[0].inputBlockHeight[0],MAX_RVM_BLOCK_COUNT * sizeof(unsigned char)))) != 0){
 printf("\n in and out data is diff!!!\n");
  GT_0trace(curMask, GT_1CLASS, "App-> memcmp error.\n");
    }
 

    inputbuf.descs[2].bufSize = MAX_RVM_BLOCK_COUNT * sizeof(unsigned char);
    inputbuf.descs[2].buf = (XDAS_Int8 *)(&(str_ptr->inputBlockWidth[0]));
    printf("\ninputbuf descs[2] set over !!!\n");
    tmp_addr = Memory_getBufferPhysicalAddress(inputbuf.descs[2].buf,MAX_RVM_BLOCK_COUNT * sizeof(unsigned char), &b_tmp);
    GT_1trace(curMask, GT_1CLASS, "inputbuf.descs[2].buf pa is:0x%x.\n",(unsigned long)tmp_addr);

    inputbuf.descs[3].bufSize = MAX_RVM_BLOCK_COUNT * sizeof(unsigned long);
    inputbuf.descs[3].buf = (XDAS_Int8 *)(&(str_ptr->inputBlockOffset[0]));
    printf("\ninputbuf descs[3] set over !!!\n");
    tmp_addr = Memory_getBufferPhysicalAddress(inputbuf.descs[3].buf,MAX_RVM_BLOCK_COUNT * sizeof(unsigned long), &b_tmp);
    GT_1trace(curMask, GT_1CLASS, "inputbuf.descs[3].buf pa is:0x%x.\n",(unsigned long)tmp_addr);

    inputbuf.descs[4].bufSize = MAX_RVM_BLOCK_COUNT * sizeof(unsigned long);
    inputbuf.descs[4].buf = (XDAS_Int8 *)(&(str_ptr->outputBlockOffset[0]));
    printf("\ninputbuf descs[4] set over !!!\n");
    tmp_addr = Memory_getBufferPhysicalAddress(inputbuf.descs[4].buf,MAX_RVM_BLOCK_COUNT * sizeof(unsigned long), &b_tmp);
    GT_1trace(curMask, GT_1CLASS, "inputbuf.descs[4].buf pa is:0x%x.\n",(unsigned long)tmp_addr);

    inputbuf.descs[5].bufSize = MAX_RVM_BLOCK_COUNT * sizeof(long long);
    inputbuf.descs[5].buf = (XDAS_Int8 *)(&(str_ptr->rightEdgePadBytes[0]));
    printf("\ninputbuf descs[5] set over !!!\n");
    tmp_addr = Memory_getBufferPhysicalAddress(inputbuf.descs[5].buf,MAX_RVM_BLOCK_COUNT * sizeof(long long), &b_tmp);
    GT_1trace(curMask, GT_1CLASS, "inputbuf.descs[5].buf pa is:0x%x.\n",(unsigned long)tmp_addr);

    inputbuf.descs[6].bufSize = MAX_RVM_BLOCK_COUNT * MAX_RVM_BLOCK_SIZE * MAX_RVM_BLOCK_SIZE * sizeof(unsigned short);
    inputbuf.descs[6].buf = (XDAS_Int8 *)(&(str_ptr->param1[0]));
    printf("\ninputbuf descs[6] set over !!!\n");
    tmp_addr = Memory_getBufferPhysicalAddress(inputbuf.descs[6].buf,MAX_RVM_BLOCK_COUNT * MAX_RVM_BLOCK_SIZE * MAX_RVM_BLOCK_SIZE * sizeof(unsigned short), &b_tmp);
    GT_1trace(curMask, GT_1CLASS, "inputbuf.descs[6].buf pa is:0x%x.\n",(unsigned long)tmp_addr);

    inputbuf.descs[7].bufSize = MAX_RVM_BLOCK_COUNT * MAX_RVM_BLOCK_SIZE * MAX_RVM_BLOCK_SIZE * sizeof(unsigned int);   
    inputbuf.descs[7].buf = (XDAS_Int8 *)(&(str_ptr->param2[0]));
    printf("\ninputbuf descs[7] set over !!!\n");
    tmp_addr = Memory_getBufferPhysicalAddress(inputbuf.descs[7].buf,MAX_RVM_BLOCK_COUNT * MAX_RVM_BLOCK_SIZE * MAX_RVM_BLOCK_SIZE * sizeof(unsigned int), &b_tmp);
    GT_1trace(curMask, GT_1CLASS, "inputbuf.descs[7].buf pa is:0x%x.\n",(unsigned long)tmp_addr);
    if((tmp=(memcmp(inputbuf.descs[7].buf,&appLUT[0].param2[0],MAX_RVM_BLOCK_COUNT * MAX_RVM_BLOCK_SIZE * MAX_RVM_BLOCK_SIZE * sizeof(unsigned int)))) != 0){
 printf("\n in and out data is diff!!!\n");
  GT_0trace(curMask, GT_1CLASS, "App-> memcmp error.\n");
    }

   
    GT_1trace(curMask, GT_1CLASS, "s_ptr adrr is:0x%x.\n",(unsigned long)s_ptr);

    GT_1trace(curMask, GT_1CLASS, "str_ptr adrr is:0x%x.\n",(unsigned long)str_ptr);
    GT_1trace(curMask, GT_1CLASS, "outbuf adrr is:0x%x.\n",(unsigned long)outbuf);

    GT_2trace(curMask, GT_1CLASS, "inputbuf.descs[0].buf adrr is:0x%x;size is:%d\n",(unsigned long)inputbuf.descs[0].buf,BUF_SIZE*sizeof(XDAS_Int8));
    GT_2trace(curMask, GT_1CLASS, "inputbuf.descs[1].buf adrr is:0x%x;size is:%d\n",(unsigned long)inputbuf.descs[1].buf,MAX_RVM_BLOCK_COUNT*sizeof(unsigned char));
    GT_2trace(curMask, GT_1CLASS, "inputbuf.descs[2].buf adrr is:0x%x;size is:%d\n",(unsigned long)inputbuf.descs[2].buf,MAX_RVM_BLOCK_COUNT*sizeof(unsigned char));
    GT_2trace(curMask, GT_1CLASS, "inputbuf.descs[3].buf adrr is:0x%x;size is:%d\n",(unsigned long)inputbuf.descs[3].buf,MAX_RVM_BLOCK_COUNT * sizeof(unsigned long));
    GT_2trace(curMask, GT_1CLASS, "inputbuf.descs[4].buf adrr is:0x%x;size is:%d\n",(unsigned long)inputbuf.descs[4].buf,MAX_RVM_BLOCK_COUNT * sizeof(unsigned long));
    GT_2trace(curMask, GT_1CLASS, "inputbuf.descs[5].buf adrr is:0x%x;size is:%d\n",(unsigned long)inputbuf.descs[5].buf,MAX_RVM_BLOCK_COUNT * sizeof(long long));
    GT_2trace(curMask, GT_1CLASS, "inputbuf.descs[6].buf adrr is:0x%x;size is:%d\n",(unsigned long)inputbuf.descs[6].buf,MAX_RVM_BLOCK_COUNT * MAX_RVM_BLOCK_SIZE * MAX_RVM_BLOCK_SIZE * sizeof(unsigned short));
    GT_2trace(curMask, GT_1CLASS, "inputbuf.descs[7].buf adrr is:0x%x;size is:%d\n",(unsigned long)inputbuf.descs[7].buf,MAX_RVM_BLOCK_COUNT * MAX_RVM_BLOCK_SIZE * MAX_RVM_BLOCK_SIZE * sizeof(unsigned int));
    GT_2trace(curMask, GT_1CLASS, "outputbuf.descs[0].buf adrr is:0x%x;size is:%d\n",(unsigned long)outputbuf.descs[0].buf,BUF_SIZE*sizeof(XDAS_Int8));

 

    GT_0trace(curMask, GT_1CLASS, "App-> Application started.\n");

    /* reset, load, and start DSP Engine */
    if ((ce = Engine_open(engineName, NULL, NULL)) == NULL) {
        fprintf(stderr, "%s: error: can't open engine %s\n",
            progName, engineName);
 GT_2trace(curMask, GT_1CLASS,"%s: error: can't open engine %s\n", progName,engineName);
        goto end;
    }
    i = Engine_getMemId(ce);
    printf("\nMemIdis: %d \n",i);
    /* allocate and initialize universal alg on the engine */
    hUniversal = UNIVERSAL_create(ce, universalName,NULL);
    if (hUniversal == NULL) {
        printf( "App-> ERROR: can't open codec %s\n", universalName);
        goto end;
    }

    printf("\n UNIVERSAL_create function use is ok!!!\n");
  

    GT_0trace(curMask, GT_1CLASS, "App-> start Processing frame ...\n");


//    GT_1trace(curMask, GT_1CLASS, "inputbuf.descs[0].buf adrr is:0x%x.\n",(unsigned long)inputbuf.descs[0].buf);

    status = UNIVERSAL_process(hUniversal, &inputbuf,
                &outputbuf, NULL, &universalInArgs, &universalOutArgs);
    GT_1trace(curMask, GT_1CLASS, "App-> UNIVERSAL_process status is %d.\n",status);
    GT_0trace(curMask, GT_1CLASS, "App-> Application prinf the outputbuf.\n");
   
    if((tmp=(memcmp(inputbuf.descs[0].buf,outputbuf.descs[0].buf,BUF_SIZE*sizeof(XDAS_Int8)))) != 0){
 printf("\n in and out data is diff!!!\n");
  GT_0trace(curMask, GT_1CLASS, "App-> memcmp error.\n");
    }

    GT_1trace(curMask, GT_1CLASS, "App-> memcmp tmp is %d.\n",tmp);
    GT_0trace(curMask, GT_1CLASS, "App->end  Application .\n");
    memcpy(s_ptr,outbuf,BUF_SIZE*sizeof(XDAS_Int8));

   
    i = Engine_getCpuLoad(ce);
    printf("\nCpuLoad is: 0.%d\n",i);

    err = Engine_getLastError(ce);
    printf("\nLastError is: %d \n",err);

    i = Engine_getUsedMem(ce);
    printf("\nUsedMem is:%d \n",i);if((tmp=(memcmp(inputbuf.descs[1].buf,&appLUT[0].inputBlockHeight[0],MAX_RVM_BLOCK_COUNT * sizeof(unsigned char)))) != 0){
 printf("\n in and out data is diff!!!\n");
  GT_0trace(curMask, GT_1CLASS, "App-> memcmp error.\n");
    }

end:
    printf("\n start to exeute the end!!!");
    /* teardown the codec */
    if (hUniversal) {
        UNIVERSAL_delete(hUniversal);
 printf("\n UNIVERSAL delete !!!\n");
    }

    /* close the engine */
    if (ce) {
        Engine_close(ce);
 printf("\n  Engine_close \n");
    }
    if (outbuf) {
        Memory_free(outbuf, BUF_SIZE*sizeof(XDAS_Int8), /*NULL*/&allocParams);
 printf("\n free outbuf\n");
    }


    GT_0trace(curMask, GT_1CLASS, "app Memory_free ok.\n");
    GT_0trace(curMask, GT_1CLASS, "app done.\n");
    return (0);
}

/*
 *  @(#) desay.apps.darklight; 1, 0, 0,136; 9-20-2010 16:40:14; /db/atree/library/trees/ce/ce-r09x/src/ xlibrary

 */
main_native.c:

#include <xdc/std.h>

#include <ti/sdo/ce/CERuntime.h>
#include <ti/sdo/ce/trace/gt.h>

#include <ti/sdo/linuxutils/cmem/include/cmem.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#include <getopt.h>           

#include <fcntl.h>            
#include <unistd.h>
#include <errno.h>
#include <malloc.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <time.h>

#include <asm/types.h>        
#include <linux/videodev2.h>
#include <linux/fb.h>

#include "RVM_include_1.h"
//#include "RVM_include_4_bw.h"
#include "smain.h"

#define CLEAR(x) memset (&(x), 0, sizeof (x))
#define MIN_BUFFERS 4

struct buffer {
        void *                  start;
        size_t                  length;
};

static char *           dev_name        = "/dev/video0";
static int              fd              = -1;
static int   fb  = -1;
struct buffer *         buffers         = NULL;
static unsigned int     n_buffers       = 0;
static long int  screensize  = 0;
static unsigned long file_length;
static char *  fb_mem  = 0;


const short coeff[5]={ 8192, 11229, -2757, -5720, 14192};

int buf_size = 720*480*2;
struct buf_info {
 void *user_addr;
 unsigned long phy_addr;
};

struct buf_info user_io_buffers[MIN_BUFFERS];

void * pbuffer;
struct buf_info  pass_struct;


void IMG_ycbcr422pl_to_rgb565_cn

(

    const short             coeff[5],  

    const unsigned char     *yuv_data,  

    unsigned short *restrict rgb_data,

    unsigned                num_pixels

)

{

    int     i;                    

    int     y0, y1;               

    int     cb, cr;              

    int     y0t,y1t;               

    int     rt, gt, bt;           


    int     r0, g0, b0;          

    int     r1, g1, b1;           

    int     r0t,g0t,b0t;          

    int     r1t,g1t,b1t;          

    int     r0s,g0s,b0s;           

    int     r1s,g1s,b1s;          

 

    short   luma = coeff[0];      

    short   r_cr = coeff[1];       

    short   g_cb = coeff[2];       

    short   g_cr = coeff[3];       

    short   b_cb = coeff[4];      

 

    unsigned short  rgb0, rgb1;    

 

    i = num_pixels >> 1;

    printf("\n start to change yuv to rgb!!!\n");

    while (i-->0)

    {
 cb = *yuv_data++ - 128;

        y0 = *yuv_data++  - 16;

        cr = *yuv_data++ - 128;

        y1 = *yuv_data++  - 16;


        rt  = r_cr * (short)cr;

        gt  = g_cb * (short)cb + g_cr * (short)cr;

        bt  = b_cb * (short)cb;

 

        y0t = luma * (short)y0;

        y1t = luma * (short)y1;

 

        r0  = y0t + rt; r1 = y1t + rt;

        g0  = y0t + gt; g1 = y1t + gt;

        b0  = y0t + bt; b1 = y1t + bt;

        r0t = r0 >> 16;

        g0t = g0 >> 15;

        b0t = b0 >> 16;

        r1t = r1 >> 16;

        g1t = g1 >> 15;

        b1t = b1 >> 16;

 

        r0s = r0t < 0 ? 0 : r0t > 31 ? 31 : r0t;

        g0s = g0t < 0 ? 0 : g0t > 63 ? 63 : g0t;


        b0s = b0t < 0 ? 0 : b0t > 31 ? 31 : b0t;

        r1s = r1t < 0 ? 0 : r1t > 31 ? 31 : r1t;

        g1s = g1t < 0 ? 0 : g1t > 63 ? 63 : g1t;

        b1s = b1t < 0 ? 0 : b1t > 31 ? 31 : b1t;

 
        rgb0 = (r0s << 11) + (g0s <<  5) + (b0s <<  0);

        rgb1 = (r1s << 11) + (g1s <<  5) + (b1s <<  0);

        *rgb_data++ = rgb0;

        *rgb_data++ = rgb1;

    }

 
    printf("\n  change yuv to rgb is over!!! \n");
    return;

}

static int read_frame (pbuffer)
{

 unsigned int i;
 struct timeval tpstart,tpend;
 clock_t start,end;
   float timeuse;
 int ret = 10;

 struct fb_var_screeninfo vinfo;
 struct fb_fix_screeninfo finfo;
 unsigned short * buff = NULL;
 unsigned short * tmp_buf = NULL;
 int  location=0;
 int x=0;
 int y=0;

 buff = malloc(sizeof(unsigned short)*720*480*2);
 memset(buff,NULL,sizeof(unsigned short)*720*480*2);

 tmp_buf = malloc(480*sizeof(unsigned short)); 
 memset(tmp_buf,NULL,480*sizeof(unsigned short));

 fb=open("/dev/fb0",O_RDWR);
 if(fb == -1){
  printf("\n fb0 can not open!!!\n"); 
 }


 if((ret = ioctl(fb, FBIOGET_FSCREENINFO, &finfo)) ==-1){
  printf("\n get lcd  finfo error!\n "); 
  perror("\n FBIOGET_FSCREENINFO in the read_frame");
 }
 printf("\nSN_A_A_B: FBIOGET_FSCREENINFO ret is:%d,finfo.line_length is:%d,finfo.smem_len is:%d,finfo.smem_start is:0x%x\n",ret,finfo.line_length,finfo.smem_len,finfo.smem_start);
 if((ret = ioctl(fb, FBIOGET_VSCREENINFO, &vinfo)) == -1){
  printf("\n get lcd  vinfo error!\n ");
  perror("\n BIOGET_VSCREENINFO in the read_frame");
 }
 printf("\nSN_A_A_C: FBIOGET_VSCREENINFO ret is:%d",ret);
 screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

 printf("\nSN_A_A_D:height is:%d, width is:%d,vinfo.bits_per_pixel is:%d\n",vinfo.height,vinfo.width,vinfo.bits_per_pixel);
 printf("\nSN_A_A_E:vinfo.xres is:%d, vinfo.yres is:%d,vinfo.xoffset is:%d,vinfo.yoffset is:%d\n",vinfo.xres,vinfo.yres,vinfo.xoffset,vinfo.yoffset);

 fb_mem=(char*)mmap(0,screensize,PROT_READ|PROT_WRITE,MAP_SHARED,fb,0); 
 printf("\nSN_A_A:fb_mem:0x%x\n", (unsigned int)fb_mem);
 if(fb_mem == MAP_FAILED){
  printf("\n fb device mem map failed!\n"); 
 }

 printf("\n pbuffer is :0x%x",pbuffer);
 IMG_ycbcr422pl_to_rgb565_cn( coeff,  ( unsigned char *)pbuffer,   buff,   720*480  );

 printf("\nSN_A_F:\n");
 start = clock();

 for(y=0; y < vinfo.yres ;y++)
 {
  for(x=0; x < vinfo.xres; x++)
   {

    location=(x+vinfo.xoffset)*(vinfo.bits_per_pixel/8)+
(y+vinfo.yoffset)*(finfo.line_length);
//    *((unsigned short *)(fb_mem+location))=*(buff+y*720+x);
    *(tmp_buf+x)=*(buff+y*720+x);
 
   }

  memcpy(fb_mem+y*finfo.line_length,tmp_buf,480*sizeof(unsigned short));
  memset(tmp_buf,NULL,480*sizeof(unsigned short));
 }

 end = clock();
 timeuse = (double)(end - start)/CLOCKS_PER_SEC;
 printf("\nUsed Time:%f in the read_frame\n",timeuse);
 printf("\nSN_A_G:\n");

 printf("\n SN_A_H:%d\n",ret);


 if(munmap(fb_mem,screensize)== -1){
  printf("\n munmap fb error!!!\n"); 
 }
 
 free(tmp_buf);
 tmp_buf = NULL;
 
 
free(buff);
 buff = NULL;
 close(fb);

 return 1;
}

extern Int smain(Int argc, String argv[],void * s_ptr ,struct RVM_LookupTable * str_ptr);
/* trace info: module name, mask */
#define MOD_NAME "desay.apps.rvm"
GT_Mask curMask = {0,0};


Int main(Int argc, String argv[])
{
 int rvt = 0;
    
 CERuntime_init();
 
 CMEM_init();
   
 GT_init();
 
   
 GT_create(&curMask, MOD_NAME);

   
 GT_set(MOD_NAME "=01234567");

 GT_0trace(curMask, GT_2CLASS, "main> " MOD_NAME "\n");
     
        struct v4l2_capability cap;
 struct v4l2_format fmt;
 struct v4l2_buffer buf;
 struct RVM_LookupTable appLUT[1] = {LUT_1};
 unsigned int i=0;
 unsigned int tmp = -1;
 enum v4l2_buf_type type;
 struct timeval tpstart,tpend;
   float timeuse;

        system("/bin/cat /proc/cmem");
 fd = open (dev_name, O_RDWR | O_NONBLOCK);
 if(fd ==-1){
  printf("\n v4l2 device can not!!! \n");  
 }

 GT_1trace(curMask, GT_2CLASS, "SN_A:%d\n", fd);

 if((rvt = ioctl (fd, VIDIOC_QUERYCAP, &cap)) == -1 ){
  printf( "\n camera can not have function!!!\n");
  perror("\n VIDIOC_QUERYCAP "); 
 }
 GT_1trace(curMask, GT_2CLASS, "SN_B:%d\n", rvt);
 if (!(rvt=(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))) {
                printf("%s is no video capture device\n",dev_name);
        }
 GT_1trace(curMask, GT_2CLASS, "SN_B+:%d\n", rvt);
 if (!(rvt=(cap.capabilities & V4L2_CAP_STREAMING))) {
                printf("%s is no video stream device\n",dev_name);
        }
 GT_1trace(curMask, GT_2CLASS, "SN_B++:%d\n", rvt);
 GT_0trace(curMask, GT_2CLASS, "set camare fmt!!!\n");

 CLEAR (fmt);
 fmt.type                = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 fmt.fmt.pix.width       = 720;//480;
 fmt.fmt.pix.height      = 480;//720;


 fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY;
 fmt.fmt.pix.field       =  V4L2_FIELD_INTERLACED;
 if((rvt = ioctl (fd, VIDIOC_S_FMT, &fmt)) == -1){
  printf("\n set fmt failed!!!\n"); 
 }
 
 GT_2trace(curMask, GT_2CLASS, "SN_C:rvt is:%d,fmt.fmt.pix.sizeimage is %d\n", rvt,fmt.fmt.pix.sizeimage);

 file_length = fmt.fmt.pix.bytesperline * fmt.fmt.pix.height;

 struct v4l2_requestbuffers req;
 CLEAR (req);
 req.count               = MIN_BUFFERS;
 req.type                = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 req.memory              = V4L2_MEMORY_USERPTR;

 if((rvt = ioctl(fd,VIDIOC_REQBUFS,&req)) ==-1){
  printf("\n  data dequeue failed!!! \n");
  perror("\n VIDIOC_REQBUFS "); 
 }
 GT_1trace(curMask, GT_2CLASS, "SN_D:%d\n", rvt);

 if (req.count < 2){
     printf("\nInsufficient buffer memory\n");
 }
 printf("\n req.count is:%d in the main funciton!!!\n",req.count);


 CMEM_AllocParams  alloc_params;
 printf("\n calling cmem utilities for allocating frame buffers\n"); 

 alloc_params.type = CMEM_POOL;
 alloc_params.flags = CMEM_NONCACHED;
 alloc_params.alignment = 128;

  printf("\nthe buf size = %d \n", buf_size);
  printf("\nthe struct of RVM_LookupTable  size is:%d\n",sizeof(struct RVM_LookupTable));
 
 for (n_buffers=0; n_buffers < MIN_BUFFERS; n_buffers++) {
  user_io_buffers[n_buffers].user_addr = CMEM_alloc(buf_size, &alloc_params);
  if (user_io_buffers[n_buffers].user_addr) {
   user_io_buffers[n_buffers].phy_addr = CMEM_getPhys(user_io_buffers[n_buffers].user_addr);
   if (0 == user_io_buffers[n_buffers].phy_addr) {
    printf("Failed to get phy cmem buffer address:user_io_buffers\n");
    return -1;
   }
  } else {
   printf("Failed to allocate cmem buffer\n");
   return -1;
  }
  printf("Driver buffer:Got %p from CMEM, phy = %p\n", user_io_buffers[n_buffers].user_addr, user_io_buffers[n_buffers].phy_addr);
 }

 printf("\n calling cmem utilities for allocating frame buffers\n");
 

// pass_struct.user_addr = (struct RVM_LookupTable *) CMEM_alloc(sizeof(struct RVM_LookupTable), &alloc_params);

 pass_struct.user_addr = CMEM_alloc(sizeof(struct RVM_LookupTable), &alloc_params);
 if (pass_struct.user_addr) {
   pass_struct.phy_addr = CMEM_getPhys(pass_struct.user_addr);
   if (0 == pass_struct.phy_addr) {
    printf("Failed to get phy cmem buffer address: pass_struct\n");
    return -1;
   }
  } else {
   printf("Failed to allocate cmem buffer\n");
   return -1;
  }
 printf("pass_struct:Got %p from CMEM, phy = %p\n", pass_struct.user_addr, pass_struct.phy_addr);
 memcpy((struct RVM_LookupTable *)pass_struct.user_addr,appLUT,sizeof(struct RVM_LookupTable));
 if((i=(memcmp(pass_struct.user_addr,appLUT,sizeof(struct RVM_LookupTable)))) != 0){
  printf("\n in and out data is diff!!!;;;i:%d\n",i);
   GT_0trace(curMask, GT_1CLASS, "App-> memcmp error.\n");
        }


 system("/bin/cat /proc/cmem");
 for (n_buffers = 0; n_buffers <  req.count; ++n_buffers)
 {

   CLEAR (buf);
   buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
   buf.memory = V4L2_MEMORY_USERPTR;
   buf.index  = n_buffers;
   buf.m.userptr = (unsigned long) user_io_buffers[n_buffers].user_addr;
   buf.length = buf_size;
   if ((rvt = ioctl (fd, VIDIOC_QBUF, &buf)) == -1){
      printf ("\nVIDIOC_QBUF failed\n");
   perror("\n VIDIOC_QBUF");
   }
   GT_1trace(curMask, GT_2CLASS, "SN_G:%d\n", rvt);
   printf("\n buf.index  is: %d \n ",buf.index ); 

   printf("\n the i value is:%d in the n_buffers loop \n",i);
 }
 GT_0trace(curMask, GT_2CLASS, "\n capture data from camare!!! \n"); 
 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 if ((rvt = ioctl (fd, VIDIOC_STREAMON, &type)) == -1){
      printf ("\nVIDIOC_STREAMON failed\n");
   perror("\n VIDIOC_STREAMON ");
 }
 GT_1trace(curMask, GT_2CLASS, "SN_H:%d\n", rvt);

 for (;;)
 {
    fd_set fds;
     struct timeval tv;
     int r;
     FD_ZERO (&fds);
     FD_SET (fd, &fds);
     tv.tv_sec = 2;
     tv.tv_usec = 0;
     GT_0trace(curMask, GT_2CLASS, "\n enter in the infine loop! \n");
     r = select (fd + 1, &fds, NULL, NULL, &tv);
      if (-1 == r) {
       if (EINTR == errno)
       continue;
      printf ("\nselect err\n");
      }
     else if (0 == r) {
      fprintf (stderr, "select timeout\n");
      exit (EXIT_FAILURE);
      }
     else{
   GT_1trace(curMask, GT_2CLASS, "SN_I:in the infine loop the value of r is :%d\n", r);
   if(FD_ISSET(fd,&fds))
   {

    if((rvt = ioctl(fd, VIDIOC_DQBUF, &buf)) == -1){
     printf("\n data can not take out from video!!\n");
     perror("\n VIDIOC_DQBUF"); 
    }
    assert (buf.index < n_buffers);
       printf ("\n buf.index dq is: %d\n",buf.index);
    tmp = buf.index;
    gettimeofday(&tpstart,NULL);
//    rvt = smain(argc, argv,(void *)user_io_buffers[buf.index].user_addr);
//    rvt = smain(argc, argv,(void *)user_io_buffers[buf.index].user_addr,appLUT[0]);
    rvt = smain(argc, argv,(void *)user_io_buffers[buf.index].user_addr,(struct RVM_LookupTable *)pass_struct.user_addr);
    gettimeofday(&tpend,NULL);
      timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+tpend.tv_usec-tpstart.tv_usec;
      timeuse/=1000000;
      printf("Used Time:%f\n",timeuse);
    if(rvt != 0){
      GT_1trace(curMask, GT_2CLASS, "SN_J:in the infine loop the value of rvt is :%d,DSP run  error,Please check out the alg!!!\n", rvt);
         break;
    }
    

    rvt = read_frame (user_io_buffers[buf.index].user_addr);
    
    printf("\n the buf.index value is:%d in the read_frame!!!,tmp is:%d\n",buf.index,tmp);

    if(rvt != 1){
      GT_1trace(curMask, GT_2CLASS, "SN_K:in the infine loop the value of rvt is :%d\n", rvt);
         break;
    }

    buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    buf.memory = V4L2_MEMORY_USERPTR;
    buf.m.userptr = (unsigned long) user_io_buffers[buf.index].user_addr;
    buf.length = buf_size;
    if((rvt = ioctl (fd, VIDIOC_QBUF, &buf))== -1){
     printf("\n buf can not put in video!!!\n");
     perror("\n VIDIOC_QBUF ");  
    }
    printf("\n buf into incoming queue!!!\n");
    printf("\n the buf.index value is:%d in the loop!!!,tmp is:%d\n",buf.index,tmp);    
   }
    }

 }

  if ((rvt = ioctl (fd, VIDIOC_STREAMOFF, &type)) == -1){
       printf ("\nVIDIOC_STREAMOFF failed\n");
    perror("\n VIDIOC_STREAMOFF");
   }
  GT_1trace(curMask, GT_2CLASS, "SN_L:%d\n", rvt);

  CMEM_free(pass_struct.user_addr, &alloc_params);
  pass_struct.user_addr = NULL;


  for (i = 0; i < n_buffers; ++i){
   CMEM_free(user_io_buffers[i].user_addr, &alloc_params);
   user_io_buffers[i].user_addr = NULL;

  }
  
  CMEM_exit();

  close(fd);

    return 0;
}

main_bios.c:

/*
 * Copyright (c) 2010, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
/*
 *  ======== main.c ========
 */
/**
 *  @file       ti/add/apps/universal_add/main.c
 *
 *  @brief      This is a BIOS main() routine
 */
#include <xdc/std.h>
#include <ti/bios/include/std.h>

#include <ti/bios/include/tsk.h>
#include <ti/bios/include/sys.h>
#include <ti/sdo/ce/CERuntime.h>
#include <ti/sdo/ce/trace/gt.h>

#include <smain.h>

void * s_ptr;
struct RVM_LookupTable * str_ptr;
/* trace info: module name, mask */
#define MOD_NAME "desay.apps.rvm"
GT_Mask curMask = {0,0};

static String taskName = "rvm";

/**
 *  @brief      The BIOS main() entry point.
 *
 *  @remark     The purpose of this function is to create a BIOS worker task
 *              to house our example.
 *
 *  @remark     This is called during BIOS_init, but before the scheduler
 *              has begun running.
 */
Int main(Int argc, String argv[])
{
    TSK_Attrs attrs = TSK_ATTRS;
    attrs.stacksize = 4 * 1024;
    attrs.name = taskName;

    /* init Codec Engine */
    CERuntime_init();

    /* init trace */
    GT_init();

    /* create a mask to allow a trace-print welcome message below */
    GT_create(&curMask, MOD_NAME);

    /* Enable all trace for this module */
    GT_set(MOD_NAME "=01234567");

    GT_0trace(curMask, GT_2CLASS, "main> " MOD_NAME "\n");

    if (TSK_create((Fxn)smain, &attrs, argc, argv, s_ptr ,str_ptr) == NULL) {
        SYS_abort("main: failed to create smain thread.");
    }

    return (0);
}

/*
 *  @(#) desay.apps.darklight; 1, 0, 0,136; 9-20-2010 16:40:14; /db/atree/library/trees/ce/ce-r09x/src/ xlibrary

 */
CE_DEBUG reslut:

@0x000112a8:[T:0x4001e320] desay.apps.rvm - main> desay.apps.rvm
 2856.48>
 2856.48> Block 0: Pool 0: 2 bufs size 2035712 (2035712 requested)
 2856.48>
 2856.48> Pool 0 busy bufs:
 2856.48>
 2856.50> Pool 0 free buftvp514x 3-005c: tvp5146m2 found at 0xb8 (OMAP I2C adapter)
 2856.50> s:
 2856.50> id 0: phys addr 0x85e0f000
 2856.50> id 1: phys addr 0x85c1e000
 2856.50>
 2856.51> Block 0: Pool 1: 6 bufs size 692224 (692224 requested)
 2856.51>
 2856.51> Pool 1 busy bufs:
 2856.51>
 2856.51> Pool 1 free bufs:
 2856.51> id 0: phys addr 0x85b75000
 2856.51> id 1: phys addr 0x85acc000
 2856.51> id 2: phys addr 0x85a23000
 2856.51> id 3: phys addr 0x8597a000
 2856.53> id 4: phys addr 0x858d1000
 2856.53> id 5: phys addr 0x85828000
 2859.03> @0x002974c9:[T:0x4001e320] desay.apps.rvm - SN_A:4
 2859.03> @0x00297524:[T:0x4001e320] desay.apps.rvm - SN_B:0
 2859.04> @0x00297543:[T:0x4001e320] desay.apps.rvm - SN_B+:1
 2859.04> @0x00297543:[T:0x4001e320] desay.apps.rvm - SN_B++:67108864
 2859.04> @0x00297561:[T:0x4001e320] desay.apps.rvm - set camare fmt!!!
 2859.06> @0x00297768:[T:0x4001e320] desay.apps.rvm - SN_C:rvt is:0,fmt.fmt.pix.sizeimage is 691200
 2859.06> @0x002977a5:[T:0x4001e320] desay.apps.rvm - SN_D:0
 2859.06>
 2859.06>  req.count is:4 in the main funciton!!!
 2859.06>
 2859.07>  calling cmem utilities for allocating frame buffers
 2859.07>
 2859.07> the buf size = 691200
 2859.07>
 2859.07> the struct of RVM_LookupTable  size is:2033496
 2859.09> Driver buffer:Got 0x40984000 from CMEM, phy = 0x85b75000
 2859.09> Driver buffer:Got 0x40a2d000 from CMEM, phy = 0x85acc000
 2859.09> Driver buffer:Got 0x40ad6000 from CMEM, phy = 0x85a23000
 2859.09> Driver buffer:Got 0x40b7f000 from CMEM, phy = 0x8597a000
 2859.09>
 2859.11>  calling cmem utilities for allocating frame buffers
 2859.11> pass_struct:Got 0x40c28000 from CMEM, phy = 0x85e0f000
 2859.17>
 2859.17> Block 0: Pool 0: 2 bufs size 2035712 (2035712 requested)
 2859.17>
 2859.17> Pool 0 busy bufs:
 2859.18> id 0: phys addr 0x85e0f000 (noncached)
 2859.18>
 2859.18> Pool 0 free bufs:
 2859.18> id 1: phys addr 0x85c1e000
 2859.18>
 2859.18> Block 0: Pool 1: 6 bufs size 692224 (692224 requested)
 2859.18>
 2859.18> Pool 1 busy bufs:
 2859.20> id 3: phys addr 0x8597a000 (noncached)
 2859.20> id 2: phys addr 0x85a23000 (noncached)
 2859.20> id 1: phys addr 0x85acc000 (noncached)
 2859.20> id 0: phys addr 0x85b75000 (noncached)
 2859.20>
 2859.20> Pool 1 free bufs:
 2859.20> id 4: phys addr 0x858d1000
 2859.21> id 5: phys addr 0x85828000
 2859.21> @0x002ba3b3:[T:0x4001e320] desay.apps.rvm - SN_G:0
 2859.21>
 2859.21>  buf.index  is: 0
 2859.21> 
 2859.21>  the i value is:0 in the n_buffers loop
 2859.23> @0x002ba859:[T:0x4001e320] desay.apps.rvm - SN_G:0
 2859.23>
 2859.23>  buf.index  is: 1
 2859.23> 
 2859.23>  the i value is:0 in the n_buffers loop
 2859.23> @0x002bacc2:[T:0x4001e320] desay.apps.rvm - SN_G:0
 2859.23>
 2859.23>  buf.index  is: 2
 2859.23> 
 2859.25>  the i value is:0 in the n_buffers loop
 2859.25> @0x002bb10c:[T:0x4001e320] desay.apps.rvm - SN_G:0
 2859.25>
 2859.25>  buf.index  is: 3
 2859.25> 
 2859.25>  the i value is:0 in the n_buffers loop
 2859.25> @0x002bb12b:[T:0x4001e320] desay.apps.rvm -
 2859.26>  capture data from camare!!!
 2859.26> @0x002bbc60:[T:0x4001e320] desay.apps.rvm - SN_H:0
 2859.26> @0x002bbc9d:[T:0x4001e320] desay.apps.rvm -
 2859.26>  enter in the infine loop!
 2859.28> @0x002caa14:[T:0x4001e320] desay.apps.rvm - SN_I:in the infine loop the value of r is :1
 2859.28>
 2859.28>  buf.index dq is: 0
 2859.28> smain A!!!
 2859.28> smain B!!!
 2859.28> smain C!!!
 2859.28>
 2859.28> outbuf set value!!!
 2859.28>
 2859.28> smain D!!!
 2859.28> 
 2859.29> outputbuf set !!!
 2859.29>
 2859.29> inputbuf set !!!
 2859.29>
 2859.29> inputbuf descs[0] set over !!!
 2859.29> @0x002cf3a1:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[0].buf pa is:0x85b75000.
 2859.31>
 2859.31> inputbuf descs[1] set over !!!
 2859.31> @0x002dad5b:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[1].buf pa is:0x85e0f024.
 2859.31>
 2859.31> inputbuf descs[2] set over !!!
 2859.32> @0x002daf07:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[2].buf pa is:0x85e0f16e.
 2859.32>
 2859.32> inputbuf descs[3] set over !!!
 2859.34> @0x002daf25:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[3].buf pa is:0x85e0f2b8.
 2859.34>
 2859.34> inputbuf descs[4] set over !!!
 2859.34> @0x002daf44:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[4].buf pa is:0x85e0f7e0.
 2859.34>
 2859.34> inputbuf descs[5] set over !!!
 2859.36> @0x002daf81:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[5].buf pa is:0x85e0fd08.
 2859.36>
 2859.36> inputbuf descs[6] set over !!!
 2859.37> @0x002daf9f:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[6].buf pa is:0x85e10758.
 2859.37>
 2859.37> inputbuf descs[7] set over !!!
 2859.37> @0x002dafbe:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[7].buf pa is:0x85eb5758.
 2859.39> @0x002ee423:[T:0x4001e320] desay.apps.rvm - s_ptr adrr is:0x40984000.
 2859.39> @0x002ee47e:[T:0x4001e320] desay.apps.rvm - str_ptr adrr is:0x40c28000.
 2859.40> @0x002ee49d:[T:0x4001e320] desay.apps.rvm - outbuf adrr is:0x40e19000.
 2859.40> @0x002ee49d:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[0].buf adrr is:0x40984000;size is:691200
 2859.42> @0x002ee4bb:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[1].buf adrr is:0x40c28024;size is:330
 2859.43> @0x002ee4da:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[2].buf adrr is:0x40c2816e;size is:330
 2859.43> @0x002ee4da:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[3].bDSP MMU Error Fault!  MMU_IRQSTATUS = [0x1]. Virtual DSP addr reference that generated the interrupt = [0x11000000].
 2859.45> uf adrr is:0x40c282b8;size is:1320
 2859.45> @0x002ee4f8:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[4].buf adrr is:0x40c287e0;size is:1320
 2859.46> @0x002ee4f8:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[5].buf adrr is:0x40c28d08;size is:2640
 2859.46> @0x002ee517:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[6].buf adrr is:0x40c29758;size is:675840
 2859.48> @0x002ee517:[T:0x4001e320] desay.apps.rvm - inputbuf.descs[7].buf adrr is:0x40cce758;size is:1351680
 2859.50> @0x002ee535:[T:0x4001e320] desay.apps.rvm - outputbuf.descs[0].buf adrr is:0x40e19000;size is:691200
 2859.50> @0x002ee554:[T:0x4001e320] desay.apps.rvm - App-> Application started.
 2859.50>
 2859.50> MemIdis: 0
 2859.50>
 2859.50>  UNIVERSAL_create function use is ok!!!
 2859.51> @0x002f79be:[T:0x4001e320] desay.apps.rvm - App-> start Processing frame ...

how to solve the problem of "bDSP MMU Error Fault!  MMU_IRQSTATUS = [0x1]. Virtual DSP addr reference that generated the interrupt = [0x11000000].
"?please help me ,thanks!