The i.MX6UL processor provides a CMOS Sensor Interface (CSI). The ConnectCore 6UL SBC Pro supports a parallel camera via a connector composed of an 8-bit data line bus, a master clock, three synchronization signals (PIXCLK, HSYNC, and VSYNC), a pair of GPIO control signals, and the I2C1 bus.
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
) -
OmniVision ov5640 camera support (
CONFIG_MXC_CAMERA_OV5640_V2
)
These options are enabled as built-in on the default ConnectCore 6UL kernel configuration file.
Kernel driver
The drivers for CSI capture are located at:
File | Description |
---|---|
CSI capture driver |
|
Omnivision OV5640 CSI camera sensor driver |
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)
&csi {
port {
csi_ep0: endpoint@0 {
remote-endpoint = <&ov5640_ep>;
};
};
};
Camera sensor (I2C1 slave)
&i2c1 {
ov5640: ov5640@3c {
compatible = "ov5640";
reg = <0x3c>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_csi>;
clocks = <&clks IMX6UL_CLK_CSI>;
clock-names = "csi_mclk";
pwn-gpios = <&mca_ioexp_gpio 31 GPIO_ACTIVE_LOW>;
rst-gpios = <&mca_ioexp_gpio 22 GPIO_ACTIVE_HIGH>;
csi_id = <0>;
mclk = <24000000>;
mclk_source = <0>;
digi,defer-probe;
port {
ov5640_ep: endpoint {
remote-endpoint = <&csi_ep0>;
};
};
};
};
IOMUX configuration
imx6ul-ccimx6ul {
pinctrl_csi: csigrp {
fsl,pins = <
MX6UL_PAD_CSI_MCLK__CSI_MCLK 0x10071
MX6UL_PAD_CSI_PIXCLK__CSI_PIXCLK 0x1b088
MX6UL_PAD_CSI_VSYNC__CSI_VSYNC 0x1b088
MX6UL_PAD_CSI_HSYNC__CSI_HSYNC 0x1b088
MX6UL_PAD_CSI_DATA00__CSI_DATA02 0x1b088
MX6UL_PAD_CSI_DATA01__CSI_DATA03 0x1b088
MX6UL_PAD_CSI_DATA02__CSI_DATA04 0x1b088
MX6UL_PAD_CSI_DATA03__CSI_DATA05 0x1b088
MX6UL_PAD_CSI_DATA04__CSI_DATA06 0x1b088
MX6UL_PAD_CSI_DATA05__CSI_DATA07 0x1b088
MX6UL_PAD_CSI_DATA06__CSI_DATA08 0x1b088
MX6UL_PAD_CSI_DATA07__CSI_DATA09 0x1b088
>;
};
};
Enabling the camera
On the ConnectCore 6UL SBC Pro, the camera is multiplexed with the microSD card functionality since both interfaces share the same lines. The default device tree enables the microSD card by default so the camera is disabled by default.
To enable the camera:
-
Enable the
csi
node on the platform device tree (the node is commented by default):ConnectCore 6UL SBC Pro device tree/* * CSI camera conflicts with microSD/eMMC. * Before enabling the camera you need to disable * usdhc2 node. */ &csi { status = "okay"; };
-
Enable the Omnivision camera node
ov5640
(the node is commented by default):ConnectCore 6UL SBC Pro device tree/* * CSI camera conflicts with microSD/eMMC. * Before enabling the camera you need to disable * usdhc2 node. */ &ov5640 { status = "okay"; };
-
Disable the microSD by setting the usdhc2 node status property to "disabled":
ConnectCore 6UL SBC Pro device tree/* USDHC2 (microSD, conflicts with eMMC) */ &usdhc2 { pinctrl-assert-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>; broken-cd; /* no carrier detect line (use polling) */ status = "disabled"; };
Using the camera
Identify the camera
When the camera is connected to the ConnectCore 6UL SBC Pro and it has been enabled in the device tree, the system identifies the camera sensor on the I2C bus and assigns it a video device node /dev/videoX
where X is an integer number.
You can determine the device index assigned to the camera on the kernel boot-up messages:
capture device registered as /dev/video0
The following examples assume the camera is /dev/video0 and the display PXP (pixel pipeline) is /dev/video1 .
|
Preview a camera image using gstreamer
Capture the camera image and preview it using gstreamer:
# gst-launch-1.0 imxv4l2src device=/dev/video0 ! imxv4l2sink device=/dev/video1
Take a picture with the camera using gstreamer
Capture a still image with the camera and save it using gstreamer:
# gst-launch-1.0 imxv4l2src device=/dev/video0 num-buffers=1 ! 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 imxv4l2src num-buffers=90 ! 'video/x-raw, width=320, height=240, framerate=(fraction)15/1' ! avimux ! filesink location=output.avi