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.

DM355: send frame via IPIPE

Other Parts Discussed in Thread: TVP5146

Hello!

I wrote programm to capture image from CMOS-matrix, encode JPEG and to send image via RTSP_stream. I have successfully see MJPEG stream via VLC, but I get green image and I think that IPIPE can solve this problem.

I looked sample in dvsdk_2_00_00_22/PSP_02_00_00_140/examples/dm355/ipipe and wrote my function:

short initIPIPE(Buffer_Handle *hBufPtr)
{
    struct ipipe_reqbufs reqbufs;
    struct ipipe_buffer t_buff;
    int ret;
    ipipeFd = open(IPIPE_DEVICE, O_RDWR);
    if (-1 == ipipeFd) {
        cout << "Can't open " << IPIPE_DEVICE << "!" << endl;
        return ipipeFd;
    }
    ret = configureIPIPE(ipipeFd);
    if (0 != ret) {
        cout << "Can't configure IPIPE!" << endl;
        return ret;
    }
    reqbufs.buf_type = IPIPE_BUF_OUT;
    reqbufs.size = imageHeight * (((imageWidth << 1) + 31) & (~31));
    reqbufs.count = NUM_BUF;
    ret = ioctl(ipipeFd, IPIPE_REQBUF, &reqbufs);
    if (-1 == ret ) {
        cout << "Can't get IPIPE requested buffer ("  << strerror(errno) << "!" << endl;
    return ret;
    }
    t_buff.index = 0;
    t_buff.buf_type = IPIPE_BUF_OUT;
    ret = ioctl(ipipeFd, IPIPE_QUERYBUF, &t_buff);
    if (-1 == ret) {
        cout << "Can't get IPIPE out buffer address ("  << strerror(errno) << "!" << endl;
    return ret;
    }
    BufferGfx_Attrs gfxAttrs  = BufferGfx_Attrs_DEFAULT;
    gfxAttrs.dim.width        = imageWidth;
    gfxAttrs.dim.height       = imageHeight;
    gfxAttrs.dim.lineLength   = imageWidth << 1;
    gfxAttrs.colorSpace       = ColorSpace_UYVY;
    gfxAttrs.bAttrs.reference = TRUE;
    Buffer_setNumBytesUsed(*hBufPtr, t_buff.size);
    Int8 *virtPtr;
    virtPtr = (Int8 *)mmap(NULL, t_buff.size, PROT_READ | PROT_WRITE,  MAP_SHARED, ipipeFd, t_buff.offset);
    if (virtPtr == MAP_FAILED) {
        cout << "Can't mmap IPIPE buffer (" << strerror(errno) << ")!" << endl;
        return -1;
    }
    Buffer_setUseMask(*hBufPtr, gfxAttrs.bAttrs.useMask);
    Buffer_setUserPtr(*hBufPtr, virtPtr);
    return 0;
}

short processIPIPE(Buffer_Handle hInBuf, Buffer_Handle hOutBuf)
{
    struct ipipe_convert convert;
    if (-1 == configureIPIPE(ipipeFd)) {
        cout << "Can't configure IPIPE!" << endl;
        return -1;
    }
    convert.in_buff.buf_type = IPIPE_BUF_IN;
    convert.in_buff.index = -1;
    convert.in_buff.offset = (unsigned int)Buffer_getUserPtr(hInBuf);
    convert.in_buff.size = Buffer_getNumBytesUsed(hInBuf);
    convert.out_buff.index = -1;
    convert.out_buff.buf_type = IPIPE_BUF_OUT;
    convert.out_buff.offset = (unsigned int)Buffer_getUserPtr(hOutBuf);
    convert.out_buff.size = Buffer_getNumBytesUsed(hOutBuf);
    if (-1 == ioctl(ipipeFd, IPIPE_START, &convert)) {
        cout << "IPIPE don't convert image!" << endl;
        return -1;
    }
    return 0;
}

And programm:
Buffer_Handle hIPIPEBuf;
if (-1 == initIPIPE(&hIPIPEBuf)) {
        cout << "Can't init IPIPE!" << endl;
        closeIPIPE(hIPIPEBuf);
        clear();
}
while (true) {
    if (Dmai_EOK != Capture_get(hCapture, &hCapBuf)) {
        cout << "Failed to get capture buffer!" << endl;
        clear();
    }
    if (Dmai_EOK != Framecopy_execute(hFramecopy, hCapBuf, hDstBuf)) {
        cout << "Failed to execute frame copy job!" << endl;
        clear();

    }
    processIPIPE(hDstBuf, hIPIPEBuf);
    ..........................
}

Information about hIPIPEBuf:
[1073957228] @ 0x41b94000 (0x84700000 phys) numBytes 614400 (1073862896) useMask 1 (17148) ref yes

Information about hDstBuf:
[0] @ 0x43475000 (0x87300000 phys) numBytes 0 (614400) useMask 0 (1) ref no                                                                                                                                         
        Width 640, Height 480, LineLength 1280                                                                                                                                                                      
[1] @ 0x436f5000 (0x87080000 phys) numBytes 0 (614400) useMask 0 (1) ref no                                                                                                                                         
        Width 640, Height 480, LineLength 1280                                                                                                                                                                      
[2] @ 0x43975000 (0x86e00000 phys) numBytes 0 (614400) useMask 0 (1) ref no                                                                                                                                         
        Width 640, Height 480, LineLength 1280

lsmod:
dm355_ipipe_driver 26024 0 - Live 0xbf01d000                                                                                                                                                                       
dm350mmap 5268 0 - Live 0xbf01a000                                                                                                                                                                                 
cmemk 28044 0 - Live 0xbf012000
davinci_capture 42120 0 - Live 0xbf006000
capture_driver 7768 1 davinci_capture, Live 0xbf003000
tvp5146 6856 1 davinci_capture, Live 0xbf000000

When I start programm I don't get any error and this output:
CPU load 17%                                                                   
CPU load 1%                                                                    
CPU load 0%

When I try to get stream via vlc I get Floating point exception.

I have found what problem in the ioctl(ipipeFd, IPIPE_START, &convert), but why?

Where I have error and how can I solve it?

Thank you and excuse me for my bad english.

  • Hi,

    Kirill said:
    I have found what problem in the ioctl(ipipeFd, IPIPE_START, &convert), but why?

    Can you provide the exact message that you get when IOCTL IPIPE_START is called? Based on the error message, we can try to analyse the parameters that you are setting. I hope you are using IPIPE only as in resizer mode as it seems your input is a YUV data coming from TVP5146.

    Regards,

    Anshuman

     

  • Hello Anshuman Saxena and thank you for your reply!

    I don't get any error.

    My function:
    ..................................
    cout << "before ipipe_start" << endl;
    if (-1 == ioctl(ipipeFd, IPIPE_START, &convert)) {
            cout << "IPIPE don't convert image!" << endl;
            return -1;
    }
    cout << "after ipipe_start" << endl;
    ...................................

    And programm output:
    before ipipe_start                                                                                                                                                                                         
    CPU load 16%                                                                                                                                                                                                  
    CPU load 1%                                                                                                                                                                                                      
    CPU load 0%

    Difference CPU load output in the 10 sec.

  • Hello!

    I have insert into kernel/linux-2.6.18_pro500/drivers/media/davinci/dm355_ipipe.c debug output (#define dprintk(fmt, arg...) printk("["DRIVERNAME"] " fmt"\n", ##arg)) and I get next result:

    [DM355IPIPE] Starting IPIPE_GET_PARAM
    [DM355IPIPE] Starting IPIPE_SET_PARAM
    [DM355IPIPE] Starting validate_params
    [DM355IPIPE] End validate_params
    [DM355IPIPE] Starting IPIPE_REQBUF
    [DM355IPIPE] Starting request_buffer
    [DM355IPIPE] End request_buffer
    [DM355IPIPE] Starting IPIPE_QUERYBUF
    [DM355IPIPE] Starting query_buffer
    [DM355IPIPE] End query_buffer
    [DM355IPIPE] Starting ipipe_mmap
    [DM355IPIPE] End ipipe_mmap
    [0] @ 0x44231000 (0x86b80000 phys) numBytes 0 (614400) useMask 0 (1) ref no
            Width 640, Height 480, LineLength 1280
    [DM355IPIPE] Starting IPIPE_GET_PARAM
    [DM355IPIPE] Starting IPIPE_SET_PARAM
    [DM355IPIPE] Starting validate_params
    [DM355IPIPE] End validate_params
    before ipipe_start
    [DM355IPIPE] Starting IPIPE_START
    [DM355IPIPE] Starting ipipe
    [DM355IPIPE] device->params->ipipeif_param.source != 0
    [DM355IPIPE] resizer_no_0
    [DM355IPIPE] resizer_no_1
    [DM355IPIPE] arg->out_buff.index < 0
    [DM355IPIPE] after regw_ip(0xff, IRQ_EN)
    [DM355IPIPE] after regw_ip(1, IPIPE_EN)
    [DM355IPIPE] before regw_if(1, IPIPEIF_ENABLE)
    [DM355IPIPE] before wait_for_completion_interruptible(&device->wfc)
    CPU load 18%
    CPU load 1%
    CPU load 0%

    If I press Ctr+C I get [DM355IPIPE] End ipipe. Why don't work interruptible?

  • Hi,

    There can be multiple reasons why the interrupt did not come. It depends on parameters that are being set for IPIPE, RSZ, IPIPEIF and CCDC. Can you provide me all the registers for the above modules?

    I have not used the DVSDK 2.00.xx for DM355, so i might not be able to directly comment on the driver details, but surely looking at the registers, i can help.

     

    Regards,

    anshuman

  • Now I work with MT9M131 matrix in BT6565 format, base resolution 640x480.

    CCDC configuration:
    ccdc_params_ycbcr params;
    params.pix_fmt      = CCDC_PIXFMT_YCBCR_8BIT;
    params.frm_fmt      = CCDC_FRMFMT_PROGRESSIVE;
    params.win.left     = 0;
    params.win.top      = 0;
    params.win.width    = imageWidth;
    params.win.height   = imageHeight;
    params.fid_pol      = CCDC_PINPOL_POSITIVE;
    params.vd_pol       = CCDC_PINPOL_POSITIVE;
    params.hd_pol       = CCDC_PINPOL_POSITIVE;
    params.bt656_enable = TRUE;
    params.pix_order    = CCDC_PIXORDER_YCBYCR;//CCDC_PIXORDER_CBYCRY;
    params.buf_type     = CCDC_BUFTYPE_FLD_SEPARATED;

    IPIPE configuration:
    struct ipipe_params params;
    //IPIPEIF
    params.ipipeif_param.data_shift = BITS9_0;
    params.ipipeif_param.clock_select = SDRAM_CLK;
    params.ipipeif_param.ialaw = ALAW_OFF;
    params.ipipeif_param.pack_mode = SIXTEEN_BIT;
    params.ipipeif_param.avg_filter = AVG_OFF;
    params.ipipeif_param.clk_div =
        (MT9V034 == matrixId ? DIVIDE_EIGHTH : DIVIDE_SIXTH);
    params.ipipeif_param.source =
        (CAPTURE_FORMAT_YUV == captureFormat ? SDRAM_YUV : SDRAM_RAW);
    params.ipipeif_param.decimation = DECIMATION_OFF;
    params.ipipeif_param.mode = CONTINUOUS;
    params.ipipeif_param.glob_hor_size = imageWidth + 8;
    params.ipipeif_param.glob_ver_size = imageHeight + 10;
    params.ipipeif_param.hnum = imageWidth;
    params.ipipeif_param.vnum = imageHeight;
    params.ipipeif_param.adofs = ((imageWidth << 1) + 31) & (~31);
    params.ipipe_mode = CONTINUOUS;
    params.ipipe_dpaths_fmt =
        (CAPTURE_FORMAT_YUV == captureFormat ? YUV2YUV : RAW2YUV);
    params.ipipe_dpaths_bypass =
        (CAPTURE_FORMAT_YUV == captureFormat ? RAW_MODE_OFF : RAW_MODE_ON);
    if (MT9V034 == matrixId) {
        params.ipipe_colpat_elep = GREEN_RED;
        params.ipipe_colpat_elop = RED;
        params.ipipe_colpat_olep = BLUE;
        params.ipipe_colpat_olop = GREEN_BLUE;
    } else {
        params.ipipe_colpat_elep = RED;
        params.ipipe_colpat_elop = GREEN_RED;
        params.ipipe_colpat_olep = BLUE;
        params.ipipe_colpat_olop = GREEN_BLUE;
    }
    params.ipipe_vsz = imageHeight;
    params.ipipe_hsz = imageWidth;
    //Defect correction
    params.def_cor.dfc_en = DISABLE;
    //Noise filter
    params.prog_nf.noise_fil_en = DISABLE;
    //Prefilter
    params.prefilter.pre_en = DISABLE;
    //RGB to RGB conversion (include GAMMA correction)
    params.rgb2rgb.gmm_cfg_bypr = GC_BYPASS;
    params.rgb2rgb.gmm_cfg_bypg = GC_BYPASS;
    params.rgb2rgb.gmm_cfg_bypb = GC_BYPASS;
    params.rgb2rgb.gmm_cfg_tbl = IPIPE_RAM;
    params.rgb2rgb.gmm_cfg_siz = IPIPE_128;
    //RGB to YUV (YCbCr) conversion
    params.rgb2yuv.yuv_phs_lpf = DISABLE;
    params.rgb2yuv.yuv_phs_position = CENTERING;
    //Edge Enchancer
    params.edge_enhancer.yee_en = DISABLE;
    params.edge_enhancer.yee_emf = DISABLE;
    //False Color Suppresion
    params.false_color_suppresion.fcs_en = DISABLE;
    params.rsz_seq_seq = DISABLE;
    params.rsz_seq_tmm = DISABLE;
    params.rsz_seq_hrv = DISABLE;
    params.rsz_seq_vrv = DISABLE;
    params.rsz_seq_crv = DISABLE;
    params.rsz_aal = DISABLE;
    params.rsz_en[0] = DISABLE;
    params.rsz_en[1] = DISABLE;

  • Hi,

    It seems like the following two lines might be possible cause of the problem. Why have you disabled the two resizer outputs? These are the output port of the IPIPE and hence if it is disbaled, you are not going to get any output and hence no interrupt.

    Kirill said:
    params.rsz_en[0] = DISABLE;
    params.rsz_en[1] = DISABLE;

    BTW, i asked for the actual physical register values. Can you provide the register values to me? You can refer to VPFE PRG for DM355 to get the exact address.

    Regards,

    Anshuman

    PS: Please mark this post as verified, if you think it has answered your question. Thanks.

  • Thank you Anshuman for your reply!

    I reconfigured IPIPE:
    //Resizer Rescale Parameters
    if (imageWidth > 640) {
        params.rsz_rsc_param[0].rsz_o_vsz = imageHeight - 1;
            params.rsz_rsc_param[0].rsz_o_hsz = imageWidth -1;
            params.rsz_rsc_param[0].rsz_v_dif = (imageHeight * 256 / imageHeight);
            params.rsz_rsc_param[0].rsz_h_dif = (imageWidth * 256 / imageWidth);
            params.rsz_rsc_param[0].rsz_h_typ = CUBIC;
            params.rsz_rsc_param[0].rsz_h_lse_sel = INTERNAL_VALUE;
    } else {
            params.rsz_rsc_param[1].rsz_o_vsz = imageHeight - 1;
            params.rsz_rsc_param[1].rsz_o_hsz = imageWidth -1;
            params.rsz_rsc_param[1].rsz_v_dif = (imageHeight * 256 / imageHeight);
            params.rsz_rsc_param[1].rsz_h_dif = (imageWidth * 256 / imageWidth);
            params.rsz_rsc_param[1].rsz_h_typ = CUBIC;
            params.rsz_rsc_param[1].rsz_h_lse_sel = INTERNAL_VALUE;
    }
    //Resizer RGB Conversion Parameters
    if (imageWidth > 640) {
            params.rsz2rgb[0].rsz_rgb_en = ENABLE;
            params.rsz2rgb[0].rsz_rgb_typ = OUTPUT_16BIT;
            params.rsz2rgb[0].rsz_rgb_msk0 = NOMASK;
            params.rsz2rgb[0].rsz_rgb_msk1 = NOMASK;
    } else {
            params.rsz2rgb[1].rsz_rgb_en = ENABLE;
            params.rsz2rgb[1].rsz_rgb_typ = OUTPUT_16BIT;
            params.rsz2rgb[1].rsz_rgb_msk0 = NOMASK;
            params.rsz2rgb[1].rsz_rgb_msk1 = NOMASK;
    }
    //Resizer External Memory Parameters
    if (imageWidth > 640) {
            params.ext_mem_param[0].rsz_sdr_oft = ((imageWidth * 2+ 31)&(~31));
            params.ext_mem_param[0].rsz_sdr_ptr_e = imageHeight;
    } else {
            params.ext_mem_param[1].rsz_sdr_oft = ((imageWidth * 2+ 31)&(~31));
            params.ext_mem_param[1].rsz_sdr_ptr_e = imageHeight;
    }
    if (imageWidth > 640) {
            params.rsz_en[0] = ENABLE;
            params.rsz_en[1] = DISABLE;
    } else {
            params.rsz_en[0] = DISABLE;
            params.rsz_en[1] = ENABLE;
    }

    But this don't solve problem.

    How can I get physical register values?
    I have regdump programm(DaVinci processor register dumper V0.0.2) and here it's ouput.
    # ./regdump sys
    --- System Module ---------------------
    01C40000: 00007F55  PINMUX0
    01C40004: 00145555  PINMUX1
    01C40008: 00000004  DSPBOOTADDR
    01C4000C: 1BFF55FF  SUSPSRC
    01C40010: 00000000  INTGEN
    01C40014: 00000108  BOOTCFG
    01C40028: 0B73B02F  JTAGID
    01C40030: 00000000  HPI_CTL
    01C40034: 000009D0  USBPHY_CTL
    01C40038: 00000014  CHP_SHRTSW
    01C4003C: 00050011  MSTPRI0
    01C40040: 00000400  MSTPRI1
    01C40044: 00000018  BPSS_CLKCTL
    01C40048: 00001760  VDD3P3V_PWDN
    01C4004C: 00000000  DRVVTPER

    # ./regdump venc
    --- VENC Registers ---------------------
    01C72400: 41C4A451  VMOD
    01C72404: 9122A750  VIDCTL
    01C72408: F34610EC  VDPRO
    01C7240C: 77989FA8  SYNCCTL
    01C72410: F0320DAB  HSPLS
    01C72414: 42347ED7  VSPLS
    01C72418: 99F89036  HINT
    01C7241C: 1A48B2C1  HSTART
    01C72420: A0F74626  HVALID
    01C72424: 1A2C693C  VINT
    01C72428: CA13F651  VSTART
    01C7242C: 18DE9A08  VVALID
    01C72430: 26783E70  HSDLY
    01C72434: 04C57762  VSDLY
    01C72438: 9001DB38  YCCCTL
    01C7243C: 00887CAD  RGBCTL
    01C72440: 5C74669C  RGBCLP
    01C72444: 920AF08A  LINECTL
    01C72448: 18600F6C  CULLLINE
    01C7244C: B368863A  LCDOUT
    01C72450: 5FE1D9A3  BRTS
    01C72454: F0B18580  BRTW
    01C72458: 778FC05A  ACCTL
    01C7245C: 24A83816  PWMP
    01C72460: 74927EC7  PWMW
    01C72464: 37E71D58  DCLKCTL
    01C72468: 7830D358  DCLKPTN0
    01C7246C: 34698EFB  DCLKPTN1
    01C72470: D6C660F6  DCLKPTN2
    01C72474: 2CA13256  DCLKPTN3
    01C72478: A7F3ECD5  DCLKPTN0A
    01C7247C: 924AD971  DCLKPTN1A
    01C72480: F692400B  DCLKPTN2A
    01C72484: 22A4F7D9  DCLKPTN3A
    01C72488: 2617FC3C  DCLKHS
    01C7248C: 8B551859  DCLKHSA
    01C72490: FD0A31B7  DCLKHR
    01C72494: 3A76A52E  DCLKVS
    01C72498: 2F70E2C6  DCLKVR
    01C7249C: 9964E884  CAPCTL
    01C724A0: 50004BBA  CAPDO
    01C724A4: 6D000ECE  CAPDE
    01C724A8: 99BCF169  ATR0
    01C724AC: EBA1569C  ATR1
    01C724B0: 5B528E78  ATR2
    01C724B4: 15F5603A  STN_LCDCT
    01C724B8: E767065A  VSTAT
    01C724BC: DD3CDD7B  RAMADR
    01C724C0: 913464BE  RAMPORT
    01C724C4: 049302A0  DACTST
    01C724C8: 518EB8D3  YCOLVL
    01C724CC: 5A3292D2  SCPROG
    01C724DC: 4C322182  CVBS
    01C724E0: 2AC3A043  CMPNT
    01C724E4: 662F1A22  ETMG0
    01C724E8: 2BFE1A12  ETMG1
    01C724EC: 91CA22B2  ETMG2
    01C724F0: 3AFF036D  ETMG3
    01C724F4: 6BC55033  DACSEL
    01C72500: C8CD5E7A  ARGBX0
    01C72504: 58B90E60  ARGBX1
    01C72508: 8F609035  ARGBX2
    01C7250C: F6768359  ARGBX3
    01C72510: 6317CE34  ARGBX4
    01C72514: 4A2F83C2  DRGBX0
    01C72518: D4E22740  DRGBX1
    01C7251C: F1A43649  DRGBX2
    01C72520: B08A9328  DRGBX3
    01C72524: C9D0583A  DRGBX4
    01C72528: F61E03A2  VSTARTA
    01C7252C: AAE7B4B2  OSDCLK0
    01C72530: AA8CC7DB  OSDCLK1
    01C72534: 18BA6F5E  HVLDCL0
    01C72538: 76ABC547  HVLDCL1
    01C7253C: 7542E815  OSDHAD

    P.S. Earlyer I work with dvsdk_1_30_01_41 and kernel 2.6.10 and did not have such problem.

     

  • You can use attached readl utility on the DM355 linux shell. Actually, i wanted to get the register dump for IPIPE, IPIPEIF and CCDC registers, not the VENC register. So can you provide those register details.

    Regards,

    Anshuman

    readl.zip
  • Hello Anshuman!

    I have read SPRUF71a and run readl, but I am not sure that I use right values:
    - for CCDC ./readl 0x01c70600 0 0x15c
    - for IPIPEIF ./readl 0x01c70100 0 0x28
    - for IPIPE ./readl 0x01c71000 0 0x400

    I dump values before runing programm and after (files with after suffix).

    Also after last reconfiguration, when I enabled resize, output from programm changed:
    [0] @ 0x44231000 (0x86b80000 phys) numBytes 0 (614400) useMask 0 (1) ref no    
            Width 640, Height 480, LineLength 1280                                                                         
    before ipipe_start                                                             
    after ipipe_start                                                              
    before ipipe_start

    Now it seems that IPIPE can process one buffer, but then it stops again.

     

    read.tar.gz