DESK-MX9-L/Peripherals/MIPI

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2024/01/30 DESK-MX9-L-5.x.x release



Peripheral MIPI[edit | edit source]

Device tree configuration[edit | edit source]

Here below is an example of device tree configuration used on standard DAVE's kit for the AURA SOM:

From imx93-aura-cb2001.dts:

...
/ {
...
	regulators {
...
		ov5640_reg_2v8: ov5640_reg_2v8 {
			compatible = "regulator-fixed";
			regulator-name = "ov5640_reg_2v8";
			regulator-min-microvolt = <2800000>;
			regulator-max-microvolt = <2800000>;
			regulator-always-on;
		};

		ov5640_reg_1v8: ov5640_reg_1v8 {
			compatible = "regulator-fixed";
			regulator-name = "ov5640_reg_1v8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-always-on;
		};

		ov5640_reg_1v5: ov5640_reg_1v5 {
			compatible = "regulator-fixed";
			regulator-name = "ov5640_reg_1v5";
			regulator-min-microvolt = <1500000>;
			regulator-max-microvolt = <1500000>;
			regulator-always-on;
		};
...
	};
...
};
...
&lpi2c3 {
...
	ov5640_mipi: ov5640_mipi@3c {
		compatible = "ovti,ov5640";
		reg = <0x3c>;
		clocks = <&clk IMX93_CLK_CCM_CKO3>;
		assigned-clocks = <&clk IMX93_CLK_CCM_CKO3>;
		assigned-clock-rates = <24000000>;
		clock-names = "xclk";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_mipi_cam>;
		reset-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;

		csi_id = <0>;
		mclk = <24000000>;
		mclk_source = <0>;
		mipi_csi;

		DOVDD-supply = <&ov5640_reg_1v8>;
		AVDD-supply = <&ov5640_reg_2v8>;
		DVDD-supply = <&ov5640_reg_1v5>;
		status = "okay";

		port {
			ov5640_mipi1_ep: endpoint {
				remote-endpoint = <&mipi_csi_ep>;
				data-lanes = <2>;
				cfg-clk-range = <28>;
				hs-clk-range = <0x16>;
			};
		};
	};
...
};
...
&mipi_csi {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	port@0 {
		reg = <0>;
		mipi_csi_ep: endpoint {
			remote-endpoint = <&ov5640_mipi1_ep>;
			data-lanes = <2>;
			cfg-clk-range = <28>;
			hs-clk-range = <0x16>;
			bus-type = <4>;
		};
	};
};
...
&iomuxc {
...
	pinctrl_mipi_cam: mipi_cam {
		fsl,pins = <
			MX93_PAD_SAI1_TXFS__GPIO1_IO11			0x31e
		>;
	};
...
};

Accessing the peripheral[edit | edit source]

Linux messages at boot time[edit | edit source]

MIPI CSI driver initialized and if a MIPI camera is inserted, it has been recognized and its video driver is loaded:

...
[    1.877299] i2c 2-003c: Fixed dependency cycle(s) with /soc@0/bus@42800000/camera/csi@4ae00000/port@0/endpoint
[    1.888225] ov5640 2-003c: ov5640_write_reg: error: reg=3008, val=82
[    2.064939] mxc-md 42800000.bus:camera: deferring csi device registration
[    2.072752] dwc-mipi-csi2-host 4ae00000.csi: lanes: 2, name: mxc-mipi-csi2.0
[    2.109933] mx8-img-md: Registered sensor subdevice: ov5640 2-003c (1)
[    2.123066] mx8-img-md: created link [mxc-mipi-csi2.0] => [mxc_isi.0]
[    2.129497] mx8-img-md: created link [ov5640 2-003c] => [mxc-mipi-csi2.0]
...

Then, check if the camera is correctly recognized.

root@desk-mx93:~# ls -la /dev/video0 
crw-rw---- 1 root video 81, 0 Mar  3 11:31 /dev/video0
root@desk-mx93:~#

Usage with gstreamer[edit | edit source]

Video capture and display using Pcam 5C OV5640 MIPI camera:


200px-Emblem-important.svg.png

At every power-on cycle the first camera usage is not working. Run gstreamer, wait for some seconds then close it with Ctrl+C and restart the application again

root@desk-mx93:~# gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480 ! waylandsink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[ 1864.940941] mxc-mipi-csi2.0: format: 0x2008
[ 1864.950148] bypass csc
[ 1864.952512] input fmt YUV4
[ 1864.955219] output fmt YUYV
[ 1865.066804] dwc-mipi-csi2-host 4ae00000.csi: enter enable=1
Redistribute latency...
handling interrupt.:99.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:06.73270[ 1871.190805] dwc-mipi-csi2-host 4ae00000.csi: enter enable=0
5712
Setting pipeline to NULL ...
Total showed frames (137), playing for (0:00:06.732670920), fps (20.349).
Freeing pipeline ...
root@desk-mx93:~#

Additional information[edit | edit source]

More information about gstreamer on its web site.

More information about i.MX gstreamer plugin on the gstreamer-imx web site