The i.MX8M Nano processor provides an Image Sensor Interface (ISI) module that interfaces a pixel link source to obtain the image data for processing in its pipeline channel.
On the ConnectCore 8M Nano 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:
-
IMX8 Camera Controller (CONFIG_IMX8_CAPTURE_DRIVER)
-
IMX8 MIPI CSI2 Controller (CONFIG_IMX8_MIPI_CSI2)
-
Maxim OV5640_MIPI_V3 driver support (CONFIG_MXC_CAMERA_OV5640_MIPI_V3)
These options are enabled as built-in on the default ConnectCore 8M Nano kernel configuration file.
Kernel driver
The drivers for CSI capture are located at:
File | Description |
---|---|
IMX8 Image Subsystem driver |
|
IMX8 MIPI CSI2 Controller |
|
OV5640_MIPI_V3 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)
&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;
};
};
};
Camera sensor (I2C2 slave)
&i2c2 {
/* MIPI-CSI camera */
ov5640_mipi: ov5640_mipi@3c {
compatible = "ovti,ov5640_mipi_v3";
reg = <0x3c>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mipi>;
clocks = <&clk IMX8MN_CLK_CLKO1>;
clock-names = "csi_mclk";
assigned-clocks = <&clk IMX8MN_CLK_CLKO1>;
assigned-clock-parents = <&clk IMX8MN_CLK_24M>;
assigned-clock-rates = <24000000>;
csi_id = <0>;
rst-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
mclk = <24000000>;
mclk_source = <0>;
mipi_csi;
port {
ov5640_mipi_ep: endpoint {
remote-endpoint = <&mipi_csi0_ep>;
};
};
};
};
IOMUX configuration
&iomuxc {
pinctrl_mipi: mipi {
fsl,pins = <
/* MIPI_CSI_RESET_N */
MX8MN_IOMUXC_GPIO1_IO12_GPIO1_IO12 0x19
>;
};
};
Using the camera
Identify the camera
When the camera is connected to the ConnectCore 8M Nano Development Kit and it has been enabled in the device tree, 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:
[ 3.389860] ov5640_probe camera mipi ov5640, is found
[ 3.395590] mx8-img-md: Registered mxc_isi.0.capture as /dev/video0....
[ 3.407800] mx8-img-md: Registered sensor subdevice: ov5640_mipi_v3 2-003c (1)
[ 3.428468] mx8-img-md: created link [ov5640_mipi_v3 2-003c] => [mxc-mipi-csi2-sam.0]
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 or framebuffer sink:
~# gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=320,height=240 ! waylandsink ~# gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=320,height=240 ! fbdevsink
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=320,height=240 ! jpegenc ! filesink location=sample.jpg
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=320,height=240 ! avimux ! filesink location=output.avi