Using Video Camera IMX219

In this guide, we will provide a step-by-step walkthrough on utilizing the OV5647 video camera on SP7350 platforms.

Table of Contents

1. IMX219 Specification

The Raspberry Pi Camera Module 2 is used here. The pin definition of the SP7350 EV board’s MIPI-CSI RX connectors is compatible with this camera. The camera mounts directly to our SP7350 EV board.

  • Back-illuminated CMOS image sensor Exmor RTM

  • 2-wire serial communication circuit on chip

  • CSI2 serial data output (selection of 4lane/2lane)

  • Timing generator, H and V driver circuits on chip

  • CDS/PGA on chip

  • 10-bit A/D converter on chip

  • Automatic optical black (OB) clamp circuit on chip

  • PLL on chip (rectangular wave)

  • High sensitivity, low dark current, no smear

  • Excellent anti-blooming characteristics

  • Variable-speed shutter function (1 H units)

  • R, G, B primary color pigment mosaic filters on chip

  • Max. 30 frame/s in all-pixel scan mode

  • Pixel rate: 280 [Mpixel/s] (All-pixels mode)

  • 180 frame/s @720p with 2x2 analog (special) binning, 60 frame/s @1080p with V-crop

  • Data rate: Max. 755 Mbps/lane(@4lane), 912Mbps/Lane(@2lane)

2. Setup a SP7350 Platform

The Raspberry Pi Camera Module 2 is used here. The v2 Camera Module has a Sony IMX219 8-megapixel sensor. The pin definition of the SP7350 EV board’s MIPI-CSI RX connectors is compatible with this module. The module mounts directly to our SP7350 EV board.

2.1.  Enable IMX219 Driver in Linux Kernel Configuration

Please follow the steps below.

Step 1: Enter kernel configuration

# cd ./linux/kernel # make menuconfig

Step 2: Selects sub-menus: Device Drivers > Multimedia support > Media ancillary drivers > Camera sensor devices

2.1_step2.jpg

Step 3: Select “Sony IMX219 sensor support” and press <Y>. And then save and exit.

2.2.  Modify Device-tree Source

Device-tree source files of SP7350 are located in linux/kernel/arch/arm64/boot/dts/sunplus/. Here lists all files for SP7350 boards:

Boards

Device-tree source files

C3V-W EVB

sp7350-ev.dts

Modify device tree source file to define IMX219 source for driver. We had added some compiler switches for IMX219 camera in the beginning of sp7350-ev.dts. These compiler switches are turned off by default. They are shown below. You can turn it on based on your usage. For example, if an IMX219 camera is connected to MIPI-CSI RX4 port, the compiler switch IMX219_IN4 should be turned on.

//#define IMX219_IN0 //#define IMX219_IN1 //#define IMX219_IN2 //#define IMX219_IN3 //#define IMX219_IN4 //#define IMX219_IN5

2.3.  Compile and Burn

Downloading and Compiling Code | 7. Build code

2.4.  Connect Sensor Module

A Raspberry Pi Camera Module 2 is connected to MIPI/CSI-RX4 port on C3V-W board. It’s shown below.

2.4.jpg

2.5.  Check

After the burning is completed, start the board. The probing logs for MIPI-CSI RX and VIN drivers can be found. It’s as follows. The video device video0 has been successfully registered.

[    1.333642] sp-csi2 f8005480.csirx: 2 lanes found [    1.338482] sp-vin f8005980.video: assigned reserved memory node mipicsirx@4f600000 [    1.345864] imx219 0-0010: Consider updating driver imx219 to match on endpoints [    1.353444] sp-vin f8005980.video: Device VIN8 registered as video0 [    1.359496] sp-vin f8005980.video: SP VIN driver probed

After the system startup is completed, the video device video0 can be found.

3. Test

The v4l2-ctl application is used here. v4l2-ctl is a command line tool for controlling video devices on Linux systems.

3.1.  Display Video Device Information

Running ‘v4l2-ctl –all-device‘ command displays all information about the video device video0. The results are as follows.

3.2.  List Supported Video Format and Resolution

Running ‘v4l2-ctl –list-format-ext’ command lists the supported video format and resolution of the video device vidoe0. The results are as follows.

3.3.  Configure Camera

Running ‘v4l2-ctl –get-ctrl’ gets the value of the controls. Running ‘v4l2-ctl –set-ctrl’ sets the value of the controls. The results are as follows.

3.4.  Capture Image

Running following command capture a RAW8 picture. The pixel format RGGB means 8-bit Bayer RGRG/GBGB.

The following is the description of these parameters.

-d <device>: Set video device

--set-fmt-video=width=<width>,height=<height>,pixelformat=<format>: Set image format

--stream-mmap <count>: The number of buffers to allocate. The default is 3.

--stream-to <file>: The captured image is saved to this file.

--stream-count <count>: How many images to capture.

4. Display Image

The PixelViewer application is used here. PixelViewer is an open source project based cross-platform image viewer. You can download it from it’s website.

PixelViewer | Carina Studio

Use PixelViewer to open the image file ‘imx219.raw’. Please follow the steps below to configure PixelViewer.

Step 1: Set ‘Format’ to Byer Pattern (8-bit)

Step 2: Set ’Bayer pattern’ to RGGB (2x2)

Step 3: Set ‘Dimension (px)’ to 1920 x 1080