imx8mp clock configuration for MIPI CSI2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx8mp clock configuration for MIPI CSI2

904 Views
rajtend
Contributor III

Hello,

I am working on imx8mp PhyTec SoM module and connected a LVDS to MIPI bridge on CSI0 with a 2-lane configuration. The bridge is generating a test pattern and I am trying to understand on how to configure the clocks for this configuration.
I am able to capture the image from the camera, but it is not coming out to be right.
Below is the DTS configuration that I have been trying.
The commented lines, is everything I have tried so far.
The I2C of the bridge is working properly and I get debug output from it.
The bridge is using a pixel clock frequency of 74.25 MHz. It has been configured with 1920x1080 at 60Hz  signal.

Total Pixels Per Second=1920×1080×60=124,416,000

Data Rate=74.25×106×24 bits =1.782 Gbps (total). For two lanes it will be 891 Mbps.
And since DDR operates at twice rate, the clock frequency for MIPI will be 445.5 MHz.

Hence I tried configuring link-frequencies / clock-frequency to multiple of such values. However I don't get the right image.

In the kernel logs, I see the error:

 

 

[  472.546870] mxc-mipi-csi2.0: Frame End events: 3
[  472.551485] mxc-mipi-csi2.0: Frame Start events: 235
[  472.556446] mxc-mipi-csi2.0: Non-image data after odd frame events: 0
[  472.562882] mxc-mipi-csi2.0: Non-image data before odd frame events: 0
[  472.569406] mxc-mipi-csi2.0: Non-image data after even frame events: 0
[  472.575930] mxc-mipi-csi2.0: Non-image data before even frame events: 0
[  472.582540] mxc-mipi-csi2.0: Unknown Error events: 1277
[  472.587762] mxc-mipi-csi2.0: CRC Error events: 87
[  472.592464] mxc-mipi-csi2.0: ECC Error events: 43758
[  472.597425] mxc-mipi-csi2.0: FIFO Overflow Error events: 0
[  472.602907] mxc-mipi-csi2.0: Lost Frame End Error events: 231
[  472.608651] mxc-mipi-csi2.0: Lost Frame Start Error events: 3
[  472.614393] mxc-mipi-csi2.0: SOT Error events: 40031

 

 

 

My question is:
1. Am I missing anything in clock configuration?
2. Is there anything in ISI block, that I need to configuration?
3. Should there be anything else I should be concerned about? Any other parameters?

 

DTS configuration:

 

 

&cameradev {    
  status = "okay";    
        cap_device {    
               status = "okay";    
        };    
 };    
     
 &i2c3 {    
     status = "okay";    
         
     lvds_bridge {    
        reg = <0x5A>;    
        status = "okay";    
        compatible = "lt9211c";    
        #address-cells = <0x1>;    
        #size-cells = <0x0>;    
        //mclk = <24000000>;    
        //mclk_source = <0>;    
        //mipi-csi;    
         
        port {    
         lt9211c_ep: endpoint {    
          data-lanes = <1 2>;    
          clock-lanes = <0>;    
          bus-type = <4>;    
          clock-noncontinuous = <1>;    
          //link-frequencies = /bits/ 64 <450000000>;    
          remote-endpoint = <&mipi_csi0_ep>;    
          clock-frequency = <74250000>; // Pixel clock in Hz (74.25 MHz)     
          hsync-active = <0>;  // Sync polarity    
          vsync-active = <0>;           
          pclk-sample = <1>;   // Sample on rising edge    
         };                              
        };                                
                                          
     };                                                                                                                                                                                      
 };                                        
 
 &isi_0 {    
       status = "okay";    
        cap_device {
               status = "okay";
        };
        m2m_device {
         status = "disabled";
        };
 };
 
 &isi_1 {
         status = "disabled";
         cap_device {
                status = "okay";
         };
 };
 
 &mipi_csi_0 {
  status = "okay";
   #address-cells = <1>;
  #size-cells = <0>;
  
   //assigned-clocks = <&clk IMX8MP_CLK_MEDIA_CAM2_PIX>;
   //assigned-clock-parents = <&clk IMX8MP_SYS_PLL2_1000M>;
   //assigned-clock-rates = <500000000>;
   // clock-frequency = <500000000>;
   clock-frequency = <74250000>; // 74.25 MHz
   //max-pixel-frequency = /bits/ 64 <266000000>;
   //link-frequencies = /bits/ 64 <505500000>;
   //max-lane-frequency = /bits/ 64 <750000000>;
   //max-data-rate = /bits/ 64 <0>;
   //link-frequencies = /bits/ 64 <750000000>;
   //max-lane-frequency = /bits/ 64 <750000000>;
   //max-pixel-frequency = /bits/ 64 <266000000>;
   //max-data-rate = /bits/ 64 <0>;
   //link-frequencies = /bits/ 64 <505500000>;
   //clock-frequency = <505500000>;
  
   //link-frequencies = /bits/ 64 <1011000000>;
  //clock-frequency = <1011000000>;
  
   port@0 {
   reg = <0>;
   mipi_csi0_ep: endpoint {
    remote-endpoint = <&lt9211c_ep>;
     data-lanes = <2>;
     csis-hs-settle = <4>;
     csis-clk-settle = <2>;
     csis-wclk;
     bus-type = <4>;  /* 4 = MIPI CSI-2 D-PHY */
     //mclk = <24000000>;
     //mclk_source = <0>;
     //mclk = <74_250000>; // Pixel clock in Hz (74250 kHz)
     //link-frequencies = /bits/ 64 <505500000>; // Mentioned in the LT9211 datasheet
     //max-pixelrate = <74250000>; // Mentioned in the LT9211 datasheet
    };
  };
 };
 
 &mipi_csi_1 {
  status = "disabled";
   #address-cells = <1>;
  #size-cells = <0>;
  port@0 {
   reg = <1>;
   mipi_csi1_ep: endpoint {};
  };
 };
 

 

 

Captured image:

frame.png

Labels (1)
0 Kudos
Reply
2 Replies

828 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

Unfortunately we do not have this kind of connection available on our EVK, so we may not have examples or references on how to do this.

Also, note that the LVDS does not have connection to the MIPI-CSI2, please refer to the Reference manual Figure 13-1. Display, Imaging, Camera I/F Diagram.

For this I would suggest to reach out either phytec or your module/camera vendor for the correct device tree bindings needed for your implementation.

Best regards/Saludos,
Aldo.

0 Kudos
Reply

890 Views
rajtend
Contributor III

I am using following commands to capture the image:

root@phyboard-pollux-imx8mp-3:~# v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=RGB3
root@phyboard-pollux-imx8mp-3:~# v4l2-ctl --device /dev/video0 --stream-mmap --stream-count=1 --stream-to=frame.raw

And then I use FFMPEG to convert it to other format. FFMPEG throws an error:

ffmpeg -f rawvideo -pix_fmt rgb24 -s 1920x1080 -i frame.raw -frames:v 1 frame.png
ffmpeg version 4.4.5-0ubuntu1~22.04.sav0 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
  configuration: --prefix=/usr --extra-version='0ubuntu1~22.04.sav0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
[rawvideo @ 0x65301995c080] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'frame.raw':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 1244160 kb/s
  Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1920x1080, 1244160 kb/s, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> png (native))
Press [q] to stop, [?] for help
Output #0, image2, to 'frame.png':
  Metadata:
    encoder         : Lavf58.76.100
  Stream #0:0: Video: png, rgb24(progressive), 1920x1080, q=2-31, 200 kb/s, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc58.134.100 png
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=1.05x    
video:10kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
0 Kudos
Reply