The i.MX93 processor provides a Camera Sensor Interface (CSI) module that captures a MPI-CSI input and saves the pixels into memory.
On the ConnectCore 93 Development Kit:
-
A MIPI CSI-2 connector is available.
The BSP includes support for an Omnivision OV5640 MIPI camera model.
Make sure you use the correct cable to connect the MIPI camera to the ConnectCore 93 Development Kit. Using the wrong cable may damage the camera. For ConnectCore 93 Development Kit, use a 15 pin, 1mm pitch FFC cable with contacts on top on one side, bottom on the other. Pin 1 of the ConnectCore 93 Development Kit connector aligns with pin 15 of the camera connector. |
The i.MX93 processor supports a Parallel Camera interface that is not supported at the moment. |
Kernel configuration
You can manage the CSI driver support and Video4Linux (V4L2) capture driver through the following kernel configuration options:
-
IMX8 Media Device Driver (
CONFIG_IMX8_MEDIA_DEVICE
) -
IMX8 Image Sensor Interface Core Driver (
CONFIG_IMX8_ISI_CORE
) -
IMX93 MIPI CSI2 DWC Controller (
CONFIG_DWC_MIPI_CSI2_HOST
) -
OmniVision OV5640 sensor support (
CONFIG_VIDEO_OV5640
)
These options are enabled as built-in on the default ConnectCore 93 kernel configuration file.
Kernel driver
The drivers for CSI capture are located at:
File | Description |
---|---|
IMX8 Media Device Driver |
|
IMX8 Image Sensor Interface Core Driver |
|
IMX93 MIPI CSI2 DWC Controller |
|
OmniVision OV5640 sensor support |
Device tree bindings and customization
Common bindings for video receiver and transmitter interfaces are described at Documentation/devicetree/bindings/media/video-interfaces.yaml
.
The device tree must contain entries for:
-
The V4L2 capture interface
-
The camera sensor
-
The IOMUX
V4L2 capture interface (CSI)
&mipi_csi {
status = "okay";
/* Camera 0 MIPI CSI */
port {
mipi_csi0_ep: endpoint {
remote-endpoint = <&ov5640_mipi_ep>;
data-lanes = <2>;
cfg-clk-range = <28>;
hs-clk-range = <0x16>;
bus-type = <4>;
};
};
};
Camera sensor (LPI2C3 slave)
&lpi2c3 {
[...]
/* MIPI-CSI camera */
ov5640_mipi: ov5640_mipi@3c {
compatible = "ovti,ov5640";
reg = <0x3c>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mipi>;
clocks = <&mipi_csi_xtal24m>;
clock-names = "xclk";
csi_id = <0>;
powerdown-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
mclk = <24000000>;
mclk_source = <0>;
mipi_csi;
status = "okay";
port {
ov5640_mipi_ep: endpoint {
remote-endpoint = <&mipi_csi0_ep>;
data-lanes = <1 2>;
clocks-lanes = <0>;
};
};
};
};
[...]
/* fixed 24MHz crystal for mipi camera */
mipi_csi_xtal24m: mipi_csi_xtal24m {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <24000000>;
clock-output-names = "xtal_24MHz";
};
IOMUX configuration
&iomuxc {
[...]
/* MIPI Camera */
pinctrl_mipi: mipi {
fsl,pins = <
/* MIPI_CSI_RESET_N */
MX93_PAD_GPIO_IO22__GPIO2_IO22 0x31e
>;
};
[...]
};
Use the camera
Identify the camera
When the camera is connected to the ConnectCore 93 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:
[ 2.454301] mx8-img-md: Registered mxc_isi.0.capture as /dev/video0
[ 2.460675] mx8-img-md: Registered sensor subdevice: ov5640 2-003c (1)
[ 2.467215] mx8-img-md: created link [mxc_isi.0] => [mxc_isi.0.capture]
[ 2.473849] mx8-img-md: created link [mxc-mipi-csi2.0] => [mxc_isi.0]
[ 2.480303] mx8-img-md: created link [ov5640 2-003c] => [mxc-mipi-csi2.0]
[ 2.487102] mxc-md 42800000.bus:camera: mxc_md_create_links
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 ! imxvideoconvert_pxp ! video/x-raw,width=1280,height=720,framerate=15/1 ! videoconvert ! video/x-raw,format=I420 ! jpegenc ! avimux ! filesink location=output.avi