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.

Use Previewer and Resizer within user application on DM3730

Other Parts Discussed in Thread: DM3730

I have a CMOS image sensor as the input to a DM3730 EVM.  I believe the default configuration for image capture is CCDC->PREV->RSZ->MEM.  This works fine for video preview (720p) mode.  However, I need to capture a 14MP (4416x3312) image and due to the line size limitation (4096) of the previewer I need a way to change the image chain to CCDC->MEM->PREV->MEM->RSZ->MEM.  I need to know if the previewer and resizer can be used within my user-space DMAI application in one-shot mode.  I think there is support for using the resizer in this fashion, but I’m not sure about the previewer.  If it’s possible, is there an example somewhere?  I’m using DVSDK 4.02.00.06 (with Linux kernel 2.6.32) on the DM3730 EVM.

 

Thanks,

Jason

  • I was able to get raw bayer data into memory, so I have achieved the CCDC->MEM part of my desired stage.  Now, I am using the driver found in omap_previewer.c to open an instance of the preview driver in user space and attempting to use it.  The driver opens properly, but fails when I try to queue buffers to it.  I am trying this in 720p mode first, so there should not be any size limitations.  I'm getting a memory alignment error, even though my buffers seem to be aligned properly.  After further investigation, the ISP memory map function seems to be providing a bogus address to the preview registers.  Here is the output I get, followed by the snippet of code that sets up the previewer and its buffers:

     

    CREATED CAPTURE DEVICE
    Opened Previewer Successfully!
    Set up previewer parameters successfully!
    Allocated buffers successfully for previewer
    0x43872040, 0x43a44040     <----- My input and output user space preview buffers (malloc'ed and 32-byte aligned)
    sgtable_len: sg[0] not iommu pagesize(fc0)
    sgtable_len: sg[0] not iommu pagesize(fc0)
    addr=fffffff4   <----- Address that the preview registers are getting from the ispmmu_vmap function
    omap3isp omap3isp: preview: Address should be in 32 byte boundary
    Previewer failed
    PREV_QUEUEBUF I ERROR

     

    *****SOURCE CODE*****

    prevfd = open ("/dev/omap-previewer", O_RDWR);
        if (prevfd == -1) {
            printf("failed to open Previewer device\n");
            goto cleanup;
        }else{
            printf("Opened Previewer Successfully!\n");
        }
       
         //Set up initial parameters for previewer
        prevParams.features = PREV_CFA | PREV_DEFECT_COR | PREV_NOISE_FILTER | PREV_GAMMA_BYPASS;
        prevParams.features &= ~(PREV_AVERAGER | PREV_INVERSE_ALAW |
                      PREV_HORZ_MEDIAN_FILTER |
            //          PREV_GAMMA_BYPASS |
                      PREV_DARK_FRAME_SUBTRACT |
                      PREV_LENS_SHADING |
                      PREV_DARK_FRAME_CAPTURE |
                      PREV_CHROMA_SUPPRESS |
                      PREV_LUMA_ENHANCE);
        prevParams.pix_fmt = YCPOS_YCrYCb;
        prevParams.rgb2ycbcr = flr_prev_csc[0];            //1 is BW, 2 is Sepia, 0 is normal
        prevParams.rgb2rgb = unity_rgb2rgb;
        //Black Adjustment
        prevParams.blk_adj.red = FLR_BLKADJ_RED;
        prevParams.blk_adj.green = FLR_BLKADJ_GREEN;
        prevParams.blk_adj.blue = FLR_BLKADJ_BLUE;
        //White Balance
        prevParams.wbal.coef0 = FLR_WBAL_COEF0_ES1;
        prevParams.wbal.coef1 = FLR_WBAL_COEF1_ES1;
        prevParams.wbal.coef2 = FLR_WBAL_COEF2_ES1;
        prevParams.wbal.coef3 = FLR_WBAL_COEF3_ES1;
        prevParams.wbal.dgain = FLR_WBAL_DGAIN;
        //Gamma Correction
        prevParams.gtable.bluetable = bluegamma_table;
        prevParams.gtable.greentable = greengamma_table;
        prevParams.gtable.redtable = redgamma_table;
        //Defect Correction (check these settings - stole from default config in kernel)
        prevParams.dcor.couplet_mode_en = 1;
        for (i = 0; i < 4; i++)
            prevParams.dcor.detect_correct[i] = 0xE;
        //Noise Filter (check these settings - stole from default config in kernel)
        prevParams.nf.spread = FLR_NF_STRGTH;
        memcpy(prevParams.nf.table, noise_filter_table, sizeof(prevParams.nf.table));
        //Color Filter Array
        prevParams.cfa.cfafmt = CFAFMT_BAYER;
        prevParams.cfa.cfa_table = cfa_coef_table;
        prevParams.cfa.cfa_gradthrs_horz = FLR_CFA_GRADTHRS_HORZ;
        prevParams.cfa.cfa_gradthrs_vert = FLR_CFA_GRADTHRS_VERT;
        //Contrast, Brightness
        prevParams.contrast = 0x10;
        prevParams.brightness = 0x01;
        //Lens Shading (not used)
        //Averaging (not used)
        //Luma Enhancement (not used)
        //Chroma Suppression (not used)
       
        //Set up the size of the frame
        prevParams.size_params.hstart = 0;
        prevParams.size_params.vstart = 0;
        prevParams.size_params.hsize = 1152;        //it won't accept 1104...
        prevParams.size_params.vsize = 828;
        prevParams.size_params.pixsize = PREV_INWIDTH_10BIT;
        prevParams.size_params.in_pitch = prevParams.size_params.hsize*2;
        prevParams.size_params.out_pitch = prevParams.size_params.in_pitch;
       
        if(ioctl(prevfd, PREV_SET_PARAM, &prevParams) < 0){
            printf("Set preview parameters failed\n");
            goto cleanup;
        }else{
            printf("Set up previewer parameters successfully!\n");
        }

       //structure to store buffer request parameters
        reqbufprev.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        reqbufprev.count = 2;                               //number of buffers
        reqbufprev.memory = V4L2_MEMORY_USERPTR;            //Type of buffer exchange mechanism
        if(ioctl(prevfd, PREV_REQBUF, &reqbufprev)< 0) {
            printf("PREV_REQBUF failed\n");
            goto cleanup;
        }else{
            printf("Previewer Buffer setup Successfull!\n");
        }
        
        //Query Buf to get the buffer descriptors
        prev_i_buf.index = 0;                             //buffer index - 0
        prev_i_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;    //Input buffer
        prev_i_buf.memory = V4L2_MEMORY_USERPTR;
        prev_o_buf.index = 1;                             //buffer index - 1
        prev_o_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;    //Output buffer
        prev_o_buf.memory = V4L2_MEMORY_USERPTR;
       
        if(ioctl(prevfd, PREV_QUERYBUF, &prev_i_buf) < 0){
            printf("Failed to Request buffer descriptor for previewer input\n");
            goto cleanup;
        }
        if(ioctl(prevfd, PREV_QUERYBUF, &prev_o_buf) < 0){
            printf("Failed to Request buffer descriptor for previewer output\n");
            goto cleanup;
        }

        prevInBuf = (Int8*)malloc(1152*828*2 + 64);
        prevInBuf_a = (Int8*)((int)((char *)prevInBuf+64) & (~0x3F));
        prevOutBuf = (Int8*)malloc(1152*828*2 + 64);
        prevOutBuf_a = (Int8*)((int)((char *)prevOutBuf+64) & (~0x3F));
       
        printf("\n %p, %p\n", prevInBuf_a, prevOutBuf_a);

        memcpy(prevInBuf_a, inBuf, 1104*828*2);
           
            //Run frame through previewer
            prev_i_buf.m.userptr = (long unsigned int)prevInBuf_a;
            prev_o_buf.m.userptr = (long unsigned int)prevOutBuf_a;
           
            if (ioctl(prevfd, PREV_QUEUEBUF, &prev_i_buf) < 0) {
                printf("PREV_QUEUEBUF I ERROR \n");
            }
            if (ioctl(prevfd, PREV_QUEUEBUF, &prev_o_buf) < 0) {
                printf("PREV_QUEUEBUF O ERROR \n");
            }
           
            if(ioctl(prevfd, PREV_PREVIEW, &i) < 0){
                printf("Previewer failed\n");
            }