Show Contents

# Camera

Note This section contains Linux BSP documentation for kernel v4.1. Click here for v4.9 BSP documentation.

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 ov5642 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 ov5642 camera support (CONFIG_MXC_SUBDEV_CAMERA_OV5642)

These options are enabled as built-in on the default ConnectCore 6UL kernel configuration file.

## Platform driver mapping

The drivers for CSI capture are located at:

File | Description
--- | ---
drivers/media/platform/mxc/subdev/mx6s_capture.c | CSI capture driver
drivers/media/platform/mxc/subdev/ov5642.c | Omnivision OV5642 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.txt.

The device tree must contain entries for:

- The V4L2 capture interface
- The camera sensor
- The IOMUX

### V4L2 capture interface (CSI)

    ConnectCore 6UL SBC Pro device tree

    &csi {
            port {
                    csi_ep: endpoint {
                            remote-endpoint = <&ov5642_ep>;
                    };
            };
    };

### Camera sensor (I2C1 slave)

    ConnectCore 6UL SBC Pro device tree

    &i2c1 {
            ov5642: ov5642@3c {
                    compatible = "ov564x";
                    reg = <0x3c>;
                    pinctrl-names = "default";
                    pinctrl-0 = <&pinctrl_csi>;
                    clocks = <&clks IMX6UL_CLK_CSI>;
                    clock-names = "csi_mclk";
                    csi_id = <0>;
                    mclk = <24000000>;
                    mclk_source = <0>;
                    port {
                            ov5642_ep: endpoint {
                                    remote-endpoint = <&csi_ep>;
                            };
                    };
            };
    };

### IOMUX configuration

    ConnectCore 6UL SBC Pro device tree

    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 ov5642 (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.
     */
    &ov5642 {
             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

### Preview a camera image using gstreamer

This shows you how to capture the camera image and preview it on the display using gstreamer. The example assumes the camera is /dev/video0 and the display PXP (pixel pipeline) is /dev/video1:

    gst-launch-1.0 imxv4l2src device=/dev/video0 ! imxv4l2sink device=/dev/video1

### Take a picture with the camera using gstreamer

This shows you how to capture a still image with the camera and save it to a file using gstreamer. The example assumes the camera is /dev/video0 and the display PXP (pixel pipeline) is /dev/video1:

    gst-launch-1.0 imxv4l2src device=/dev/video0 num-buffers=1 ! jpegenc ! filesink location=sample.jpg

### Record a video with the camera using gstreamer

This shows you how to capture a moving image with the camera and save it to a file using gstreamer. The example assumes the camera is /dev/video0 and the display PXP (pixel pipeline) is /dev/video1:

    gst-launch-1.0 imxv4l2src num-buffers=90 ! 'video/x-raw, width=320, height=240, framerate=(fraction)15/1' ! avimux ! filesink location=output.avi

© 2018 Digi International Inc. All rights reserved.
Camera updated on 22 January 2018 02:43:37 PM