The {cpu-family} processor provides a Camera Sensor Interface (CSI) module that captures a MPI-CSI input and saves the pixels into memory.

On the ConnectCore 8M Mini Development Kit:

  • A MIPI CSI-2 connector is available.

The BSP includes support for the Omnivision ov5640 CSI camera model.

Kernel configuration

You can manage the CSI driver support and Video4Linux (V4L2) capture driver through the following kernel configuration options:

  • CSI camera support (CONFIG_VIDEO_MXC_CSI_CAMERA)

  • MXC MIPI CSI driver (CONFIG_MXC_MIPI_CSI)

  • OmniVision ov5640 camera support using mipi (CONFIG_MXC_CAMERA_OV5640_MIPI_V2)

These options are enabled as built-in on the default ConnectCore 8M Mini kernel configuration file.

Kernel driver

The drivers for CSI capture are located at:

File Description

drivers/media/platform/mxc/capture/mx6s_capture.c

i.MX6Sx SoC Camera Host driver

drivers/media/platform/mxc/capture/mxc_mipi_csi.c

Freescale MIPI-CSI2 receiver driver

drivers/media/platform/mxc/capture/ov5640_mipi_v2.c

OV5640 MIPI Camera Driver

Device tree bindings and customization

Common bindings for video receiver and transmitter interfaces are described at Documentation/devicetree/bindings/media/video-interfaces.txt.

The device tree must contain entries for:

  • The V4L2 capture interface

  • The camera sensor

  • The IOMUX

V4L2 capture interface (CSI)

ConnectCore 8M Mini Development Kit device tree
&csi1_bridge {
	fsl,mipi-mode;
	status = "okay";
	port {
		csi_ep: endpoint {
			remote-endpoint = <&csi_mipi_ep>;
		};
	};
};

[...]

&mipi_csi_1 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	/* Camera 0  MIPI CSI-2 (CSIS0) */
	port@0 {
		reg = <0>;
		mipi_csi0_ep: endpoint {
			remote-endpoint = <&ov5640_mipi_ep>;
			data-lanes = <2>;
			csis-hs-settle = <13>;
			csis-clk-settle = <2>;
			csis-wclk;
		};

		csi_mipi_ep: endpoint@2 {
			remote-endpoint = <&csi_ep>;
		};
	};
};

Camera sensor (I2C2 slave)

ConnectCore 8M Mini Development Kit device tree
&i2c2 {
	[...]

	/* MIPI-CSI camera */
	ov5640_mipi: ov5640_mipi@3c {
		compatible = "ovti,ov5640_mipi";
		reg = <0x3c>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_mipi>;
		clocks = <&clk IMX8MM_CLK_CLKO1>;
		clock-names = "csi_mclk";
		assigned-clocks = <&clk IMX8MM_CLK_CLKO1>;
		assigned-clock-parents = <&clk IMX8MM_CLK_24M>;
		assigned-clock-rates = <24000000>;
		csi_id = <0>;
		rst-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
		mclk = <24000000>;
		mclk_source = <0>;
		port {
			ov5640_mipi_ep: endpoint {
				remote-endpoint = <&mipi_csi0_ep>;
			};
		};
	};

	[...]
};

IOMUX configuration

ConnectCore 8M Mini Development Kit device tree
&iomuxc {
	[...]

	pinctrl_mipi: mipi {
		fsl,pins = <
			/* MIPI_CSI_RESET_N */
			MX8MM_IOMUXC_GPIO1_IO12_GPIO1_IO12 0x19
		>;
	};

	[...]
};

Using the camera

Identify the camera

When the camera is connected to the ConnectCore 8M Mini Development Kit, the system identifies the camera sensor on the I2C bus and assigns a video device node /dev/videoX to it, where X is an integer number. You can determine the device index assigned to the camera on the kernel boot-up messages:

[    1.446765] mx6s-csi 32e20000.csi1_bridge: initialising
[    1.452235] CSI: capture device registered as /dev/video0
[    1.457949] mxc_mipi-csi 32e30000.mipi_csi: 32e30000.mipi_csi supply mipi-phy not found, using dummy regulator
[    1.468151] mxc_mipi-csi 32e30000.mipi_csi: mipi csi v4l2 device registered
[    1.475125] CSI: Registered sensor subdevice: mxc_mipi-csi.0
[    1.480808] mxc_mipi-csi 32e30000.mipi_csi: lanes: 2, hs_settle: 13, clk_settle: 2, wclk: 1, freq: 333000000
[    4.383354] mxc_mipi-csi 32e30000.mipi_csi: Registered sensor subdevice: ov5640_mipi 2-003c
[    4.400476] ov5640_mipi 2-003c: Camera is found
The following examples assume the camera is /dev/video0.

Preview a camera image using gstreamer

Capture the camera image and preview it using gstreamer and Wayland sink:

# gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=1280,height=720 ! waylandsink

Take a picture with the camera using gstreamer

Capture a still image with the camera and save it using gstreamer:

# gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=1 ! video/x-raw,width=1280,height=720 ! jpegenc ! filesink location=sample.jpg

To show the captured image using gstreamer:

# gst-launch-1.0 filesrc location=sample.jpg ! jpegdec ! imagefreeze ! waylandsink

Record a video with the camera using gstreamer

Capture a moving image with the camera and save it using gstreamer:

# gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=90 ! video/x-raw,width=1280,height=720 ! avimux ! filesink location=output.avi