Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Table of Contents

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 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:

...

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

2.3.  Compile and Burn

https://sunplus.atlassian.net/wiki/spaces/C3/pages/1988034774/A+guide+to+downloading+and+compiling+SP7350+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.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.

...

Code Block
~ # ls /dev/video0
/dev/video0

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.

Code Block
~ # v4l2-ctl --all --device /dev/video0
Driver Info:
        Driver name      : sp_vin
        Card type        : SP_VIN
        Bus info         : platform:f8005980.video
        Driver version   : 5.10.201
        Capabilities     : 0xa5200001
                Video Capture
                Read/Write
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x25200001
                Video Capture
                Read/Write
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : sp_vin
        Model            : sunplus,sp7350-vin
        Serial           :
        Bus info         : platform:f8005980.video
        Media version    : 5.10.201
        Hardware revision: 0x00000000 (0)
        Driver version   : 5.10.201
Interface Info:
        ID               : 0x03000011
        Type             : V4L Video
Entity Info:
        ID               : 0x0000000f (15)
        Name             : VIN8 output
        Function         : V4L2 I/O
        Pad 0x01000010   : 0: Sink
          Link 0x02000013: from remote pad 0x1000003 of entity 'sp_csi2 f8005480.csirx' (Video Pixel Formatter): Data, Enabled
Priority: 2
Video input : 0 (VIN8 output: ok)
Format Video Capture:
        Width/Height      : 640/480
        Pixel Format      : 'RG10' (10-bit Bayer RGRG/GBGB)
        Field             : None
        Bytes per Line    : 1280
        Size Image        : 614400
        Colorspace        : sRGB
        Transfer Function : sRGB
        YCbCr/HSV Encoding: ITU-R 601
        Quantization      : Full Range
        Flags             :


User Controls

                       exposure 0x00980911 (int)    : min=4 max=1759 step=1 default=1600 value=1600
                horizontal_flip 0x00980914 (bool)   : default=0 value=0 flags=modify-layout
                  vertical_flip 0x00980915 (bool)   : default=0 value=0 flags=modify-layout
                alpha_component 0x00980929 (int)    : min=0 max=255 step=1 default=255 value=255

Image Source Controls

              vertical_blanking 0x009e0901 (int)    : min=4 max=65055 step=1 default=1283 value=1283
            horizontal_blanking 0x009e0902 (int)    : min=2808 max=2808 step=1 default=2808 value=2808 flags=read-only
                  analogue_gain 0x009e0903 (int)    : min=0 max=232 step=1 default=0 value=0
                red_pixel_value 0x009e0904 (int)    : min=0 max=1023 step=1 default=1023 value=1023
          green_red_pixel_value 0x009e0905 (int)    : min=0 max=1023 step=1 default=1023 value=1023
               blue_pixel_value 0x009e0906 (int)    : min=0 max=1023 step=1 default=1023 value=1023
         green_blue_pixel_value 0x009e0907 (int)    : min=0 max=1023 step=1 default=1023 value=1023

Image Processing Controls

                     pixel_rate 0x009f0902 (int64)  : min=182400000 max=182400000 step=1 default=182400000 value=182400000 flags=read-only
                   test_pattern 0x009f0903 (menu)   : min=0 max=4 default=0 value=0 (Disabled)
                                0: Disabled
                                1: Color Bars
                                2: Solid Color
                                3: Grey Color Bars
                                4: PN9
                   digital_gain 0x009f0905 (int)    : min=256 max=4095 step=1 default=256 value=256

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.

Code Block
~ # v4l2-ctl --list-formats-ext --device /dev/video0
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'RG10' (10-bit Bayer RGRG/GBGB)
                Size: Discrete 3280x2464
                Size: Discrete 1920x1080
                Size: Discrete 1640x1232
                Size: Discrete 640x480
        [1]: 'pRAA' (10-bit Bayer RGRG/GBGB Packed)
                Size: Discrete 3280x2464
                Size: Discrete 1920x1080
                Size: Discrete 1640x1232
                Size: Discrete 640x480
        [2]: 'RGGB' (8-bit Bayer RGRG/GBGB)
                Size: Discrete 3280x2464
                Size: Discrete 1920x1080
                Size: Discrete 1640x1232
                Size: Discrete 640x480

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.

Code Block
~ # v4l2-ctl --get-ctrl digital_gain
digital_gain: 256
~ # v4l2-ctl --set-ctrl digital_gain=2048
~ # v4l2-ctl --get-ctrl digital_gain
digital_gain: 2048

3.4.  Capture Image

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

...

--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.

...