Using Video Camera IMX708
In this guide, we will step-by-step guide you to use video camera IMX708 on SP7350 platforms.
Table of Contents
1 IMX708 Specification
Back-illuminated and stacked CMOS 12-megapixel image sensor
Pixel Size: 1.4 x 1.4 μm
HorizoHorizontal/vertical: 4608 × 2592 pixels
Sensor size: 7.4mm sensor diagonal
Optical size: 1/2.43"
Maximum exposure times (seconds): 112
HDR mode (up to 3 megapixel output)
video modes: 2304 × 1296p56, 2304 × 1296p30 HDR, 1536 × 864p120
2 Setup
2.1 Enable IMX708 in Linux Kernel Configuration
1 Enter the kernel configuration by running the following command in the top directory of project.
make kconfig
2 Selects sub-menus: Device Drivers>Multimedia support>Media ancillary drivers>Camera sensor devices
3 Select “Sony IMX708 sensor support” and press <Y>. 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 IMX708 source for driver
2.2.1 Using SP7350 MIPI/CSI-RX4
Open IMX708_IN4 macro to add IMX708 node and link mipicsirx4.
2.2.2 Using SP7350 Other MIPI/CSI-RX
Define IMX708 node in i2c node:
i2c {
#address-cells = <1>;
#size-cells = <0>;
imx708: imx708@1a {
compatible = "sony,imx708";
reg = <0x1a>;
clocks = <&imx708_clk>;
clock-names = "inclk";
vana1-supply = <&imx708_vana1_2v8>; /* 2.8v */
vana2-supply = <&imx708_vana2_1v8>;/* 1.8v */
vdig-supply = <&imx708_vdig_1v1>; /* 1.1v */
vddl-supply = <&imx708_vddl_1v8>; /* 1.8v */
port {
imx708_ep: endpoint {
remote-endpoint = <&csi_ep>;
data-lanes = <1 2>;
clock-noncontinuous;
link-frequencies = /bits/ 64 <450000000>;
};
};
};
};
port: Should contain one endpoint sub-node used to model connection to the video receiver according to the specification defined in Documentation/devicetree/bindings/media/video-interfaces.txt.
Video receiver endpoint sub-node should defined in mipicsirx node. For example:
mipicsirx: csirx@f8005480 {
port@0 {
reg = <0>;
/* MIPI CSI-2 bus endpoint */
csi_ep: endpoint {
remote-endpoint = <&imx708_ep>;
bus-type = <4>;
clock-lanes = <0>;
data-lanes = <1 2>;
};
};
2.3 Compile and Burn
Downloading and Compiling Code | 7. Build code
2.4 Connect Sensor Module
Using C3V-W board MIPI-CSI-RX4, as follows:
2.5 Check
After the burning is completed, start the board. The system should print the following information through the serial port.
After the system startup is completed, the video device can be viewed.
3 Test
3.1 v4l2-ctl Command
This command is used to control V4L2 devices from the command line. It allows you to query device capabilities, set device parameters, and capture video and still image.
Use v4l2-ctl --all --device /dev/video0 command getting device all information.
3.2 Capture Image
3.2.1 Config Video Device
Use v4l2-ctl -d /dev/video0 --set-ctrl params=value setting device controls.
set exposure(exposure 0x00980911 (int) : min=1 max=2602 step=1 default=1600 value=1600
):
set analogue_gain(analogue_gain 0x009e0903 (int): min=112 max=960 step=1 default=112 value=112
)
set digital_gain(digital_gain 0x009f0905 (int) : min=256 max=65535 step=1 default=256 value=256)
Change image brightness by changing the exposure, analogue_gain and digital_gain.
3.2.2 Capture
Use v4l2-ctl --list-formats-ext --device /dev/video0
querying device video format.
Use v4l2-ctl --stream
capture image.
--set-fmt-video=width=2304,height=1296,pixelformat=pRAA set image format
--stream-count <count> stream <count> buffers. The default is to keep streaming forever. This count does not include the number of initial skipped buffers as is passed by --stream-skip.
--stream-skip <count> skip the first <count> buffers. The default is 0.
--stream-to <file> stream to this file. The default is to discard the data. If <file> is '-', then the data is written to stdout and the --silent option is turned on automatically.
--stream-mmap <count> capture video using mmap() [VIDIOC_(D)QBUF] count: the number of buffers to allocate. The default is 3.
After executing the capture command, the stream data is written to /home/root/imx708.raw
.
3.3 Display Image Raw Data
3.3.1 Download and Install Raw Image Viewer
Download raw image viewer from PixelViewer | Carina Studio. And PixelViewer is an open source project based cross-platform image which viewer supports reading raw Luminance/YUV/RGB/ARGB/Bayer pixels data from file and rendering it.
3.3.2 Use PixelViewer to Open Image
Config render params by 3.2.2 v4l2-ctl capture command
3.3 HDR
Enable HDR
capture image
image render:
comparison:
By comparing the brightness of the light position, it can be seen that HDR improves the image effect。