V4L2 Framework | MIPI Camera Instruction Debugging Notes

Foreword:

In this article, I will introduce how to use the Rockchip platform and OV2640 camera for debugging and analysis of video equipment. I will use some common commands and tools to show how to view and set the format, resolution, control parameters, etc. of the video device, as well as how to capture and convert image data. You'll also learn how to use Media Controller to view your device's topology and connectivity. These contents are essential for understanding and optimizing the performance and quality of video equipment.

About v4l2_subdev

v4l2_subdev is an important concept in the V4L2 framework. In V4L2, sub-devices (such as cameras, audio codecs, etc.) exist in the form of v4l2_subdev structures. This structure contains a series of operations (ops) that define how the master device controls the sub-devices. In your question, g_frame_interval is one of these operations.

v4l2_subdevThe definition of the structure can be found in the source code of the Linux kernel, usually in the include/media/v4l2-subdev.h file.

reference

References:

  1. V4L2 documentation
  2. V4L2 subdevice API
  3. Linux kernel source code
  4. Rockchip official wiki
  5. Camera | 5.Linux v4l2 architecture (based on rk3568)
  6. Camera | 7. Rockchip rk3568 platform camera controller MIPI-CSI driver architecture review

Common functions involved in node creation in the V4L2 driver:

  1. v4l2_device_register: Register V4L2 devices and create corresponding device nodes.
  2. v4l2_device_unregister: Log out of the V4L2 device and delete the corresponding device node.
  3. video_device_alloc: Allocatestruct video_device structure and associate device nodes.
  4. video_device_release: Releasestruct video_device structure and related resources.
  5. video_register_device: Register the video device and create the corresponding device node.
  6. video_unregister_device: Log out of the video device and delete the corresponding device node.

What you want to modify is the configuration related to image transmission. These parameters are usually set in structures such as v4l2_subdev_mbus_code_enum or v4l2_mbus_config. These parameters control respectively:

  1. V4L2_MBUS_PCLK_SAMPLE_RISING: Sample data on the rising edge of PIXCLK.
  2. V4L2_MBUS_MASTER: The device works in Master mode.
  3. V4L2_MBUS_VSYNC_ACTIVE_HIGH: The VSYNC signal is valid at high level.
  4. V4L2_MBUS_HSYNC_ACTIVE_HIGH: The HSYNC signal is valid at high level.
  5. V4L2_MBUS_DATA_ACTIVE_HIGH: The data line is active when high.

There seems to be no relevant configuration location in the ov2640_init_cfg function. These configurations may be performed in other places, such as in the driver's probe function or in the corresponding sensor driver.

step

0.[Project] Code location and file path

[Project]Code and file locations
  • Code location: V:\rockchip\rk3568_android13
  • 关键文品路路道
    • kernel-5.10/arch/arm64/configs/rockchip_defconfig: Rockchip default configuration file.
    • kernel-5.10/drivers/media/i2c/Makefile: Makefile of I2C media driver.
    • kernel-5.10/drivers/media/i2c/ov2640.c: OV2640 camera driver.
    • kernel-5.10/drivers/media/platform/rockchip/cif/capture.c: Rockchip CIF capture driver.
    • kernel-5.10/arch/arm64/boot/dts/rockchip/rk3568-evb1-ddr4-v10-xxx.dtsi: RK3568 device tree file.

1. Debugging preparations

Debugging steps
  1. Hardware connection: Connect the [project] development board to the computer via USB cable, and connect the development board to the camera.
  2. Driver and device tree check: Ensure that the correct driver and device tree images are programmed on the development board.
I2C communication check
  • Use i2cdetect command to check the I2C device recognition:
1|rk3568_t:/ # i2cdetect -y 1
  • Use the i2cdump command to read the register value of a specific I2C device:
rk3568_t:/ # i2cdump -y -f 1 0x30
  • Use the i2cset command to set the register value of the I2C device:
rk3568_t:/ # i2cset -f -y 1 0x30 0xff 0x00 b
Commonly used debugging commands
  1. Collection statue
  • Use v4l2-ctl to grab a frame:
v4l2-ctl -d /dev/video0 --set-fmt-video=width=320,height=240,pixelformat=UYVY --stream-mmap --stream-to=./cif.out --stream-count=1
  • Use ffmpeg under Linux to convert image formats:
ffmpeg -f rawvideo -s 320x240 -pix_fmt uyvy422 -i cif.out cif.png

Insert image description here

  1. 抓取视频
  • Grab video frames, e.g. 5 seconds of 30fps video:
v4l2-ctl -d /dev/video0 --set-fmt-video=width=320,height=240,pixelformat=UYVY --stream-mmap --stream-to=./video.out --stream-count=150
  • Convert video format using ffmpeg:
ffmpeg -f rawvideo -framerate 30 -video_size 320x240 -pix_fmt uyvy422 -i video.out video.mp4

Insert image description here

Through these steps and commands, you can debug the [project] development board and camera, including hardware connection check, I2C communication test, image and video capture and conversion.

2. View device list

Order

Open a terminal on your computer and enter the following command to check available video devices and their device files:

v4l2-ctl --list-devices
Output explanation
  • This command displays all connected video devices and their device files.
  • Output example:
rk3568_t:/ # v4l2-ctl --list-devices
rkisp-statistics (platform: rkisp):
        /dev/video12
        /dev/video13
        /dev/video21
        /dev/video22

rkcif (platform:rkcif_dvp):
        /dev/video0
        /dev/video4

rkisp_mainpath (platform:rkisp-vir0):
        /dev/video5
        /dev/video6
        /dev/video7
        /dev/video8
        /dev/video9
        /dev/video10
        /dev/video11

rkisp_mainpath (platform:rkisp-vir1):
        /dev/video14
        /dev/video15
        /dev/video16
        /dev/video17
        /dev/video18
        /dev/video19
        /dev/video20
  • /dev/video0It is a video device file, mainly used to read and write image data.
  • /dev/v4l-subdev0It is a sub-device file used to configure camera parameters.

3. Check the formats and resolutions supported by the video device

This command will display all formats and resolutions supported by the video device, as well as the corresponding frame rate for each format. For example:

Order

To view all formats and resolutions supported by a specific video device, enter the following command:

rk3568_t:/ # v4l2-ctl --device=/dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture Multiplanar
        Pixel Format: 'NV16'
        Name        : Y/CbCr 4:2:2
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 1
        Type        : Video Capture Multiplanar
        Pixel Format: 'NV61'
        Name        : Y/CrCb 4:2:2
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 2
        Type        : Video Capture Multiplanar
        Pixel Format: 'NV12'
        Name        : Y/CbCr 4:2:0
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 3
        Type        : Video Capture Multiplanar
        Pixel Format: 'NV21'
        Name        : Y/CrCb 4:2:0
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 4
        Type        : Video Capture Multiplanar
        Pixel Format: 'YUYV'
        Name        : YUYV 4:2:2
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 5
        Type        : Video Capture Multiplanar
        Pixel Format: 'YVYU'
        Name        : YVYU 4:2:2
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 6
        Type        : Video Capture Multiplanar
        Pixel Format: 'UYVY'
        Name        : UYVY 4:2:2
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 7
        Type        : Video Capture Multiplanar
        Pixel Format: 'VYUY'
        Name        : VYUY 4:2:2
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 8
        Type        : Video Capture Multiplanar
        Pixel Format: 'RGB3'
        Name        : 24-bit RGB 8-8-8
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 9
        Type        : Video Capture Multiplanar
        Pixel Format: 'BGR3'
        Name        : 24-bit BGR 8-8-8
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 10
        Type        : Video Capture Multiplanar
        Pixel Format: 'RGBP'
        Name        : 16-bit RGB 5-6-5
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 11
        Type        : Video Capture Multiplanar
        Pixel Format: 'BGRH'
        Name        : 18-bit BGRX 6-6-6-14
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 12
        Type        : Video Capture Multiplanar
        Pixel Format: 'RGGB'
        Name        : 8-bit Bayer RGRG/GBGB
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 13
        Type        : Video Capture Multiplanar
        Pixel Format: 'GRBG'
        Name        : 8-bit Bayer GRGR/BGBG
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 14
        Type        : Video Capture Multiplanar
        Pixel Format: 'GBRG'
        Name        : 8-bit Bayer GBGB/RGRG
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 15
        Type        : Video Capture Multiplanar
        Pixel Format: 'BA81'
        Name        : 8-bit Bayer BGBG/GRGR
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 16
        Type        : Video Capture Multiplanar
        Pixel Format: 'RG10'
        Name        : 10-bit Bayer RGRG/GBGB
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 17
        Type        : Video Capture Multiplanar
        Pixel Format: 'BA10'
        Name        : 10-bit Bayer GRGR/BGBG
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 18
        Type        : Video Capture Multiplanar
        Pixel Format: 'GB10'
        Name        : 10-bit Bayer GBGB/RGRG
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 19
        Type        : Video Capture Multiplanar
        Pixel Format: 'BG10'
        Name        : 10-bit Bayer BGBG/GRGR
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 20
        Type        : Video Capture Multiplanar
        Pixel Format: 'RG12'
        Name        : 12-bit Bayer RGRG/GBGB
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 21
        Type        : Video Capture Multiplanar
        Pixel Format: 'BA12'
        Name        : 12-bit Bayer GRGR/BGBG
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 22
        Type        : Video Capture Multiplanar
        Pixel Format: 'GB12'
        Name        : 12-bit Bayer GBGB/RGRG
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 23
        Type        : Video Capture Multiplanar
        Pixel Format: 'BG12'
        Name        : 12-bit Bayer BGBG/GRGR
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 24
        Type        : Video Capture Multiplanar
        Pixel Format: 'BYR2'
        Name        : 16-bit Bayer BGBG/GRGR
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 25
        Type        : Video Capture Multiplanar
        Pixel Format: 'GB16'
        Name        : 16-bit Bayer GBGB/RGRG
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 26
        Type        : Video Capture Multiplanar
        Pixel Format: 'GR16'
        Name        : 16-bit Bayer GRGR/BGBG
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 27
        Type        : Video Capture Multiplanar
        Pixel Format: 'RG16'
        Name        : 16-bit Bayer RGRG/GBGB
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 28
        Type        : Video Capture Multiplanar
        Pixel Format: 'Y16 '
        Name        : 16-bit Greyscale
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 29
        Type        : Video Capture Multiplanar
        Pixel Format: 'GREY'
        Name        : 8-bit Greyscale
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 30
        Type        : Video Capture Multiplanar
        Pixel Format: 'EBD8'
        Name        : Embedded data 8-bit
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 31
        Type        : Video Capture Multiplanar
        Pixel Format: 'SPD6'
        Name        : Shield pix data 16-bit
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 32
        Type        : Video Capture Multiplanar
        Pixel Format: 'Y12 '
        Name        : 12-bit Greyscale
                Size: Stepwise 64x64 - 800x600 with step 8/8

        Index       : 33
        Type        : Video Capture Multiplanar
        Pixel Format: 'Y10 '
        Name        : 10-bit Greyscale
                Size: Stepwise 64x64 - 800x600 with step 8/8

Output explanation
  • The command will list all video formats and their resolutions supported by the specified video device (such as/dev/video0).
  • Output example description:
    • Index: Listed format index number.
    • Type: Describes the capture type, such as "Video Capture Multiplanar".
    • Pixel Format: Format identifier of image data, such as ‘NV16’, ‘NV12’, ‘RGB3’, etc.
    • Name: The specific name of the format, describing the pixel arrangement and color encoding method, such as 'YUYV 4:2:2', '24-bit RGB 8-8-8' wait.
    • Size: Supported resolution range and step size, such as "Stepwise 64x64 - 800x600 with step 8/8", indicating that resolutions from 64x64 to 800x600 are supported, and the width and height are incremented in steps of 8.
  • Each format entry provides detailed information, including supported pixel formats, color coding, resolution range, and step size. This information is used to understand and select an appropriate video capture format.

4. Set the format and resolution of the video device

Order

To set the format and resolution of a video device, use the following command:

v4l2-ctl --device=/dev/video0 --set-fmt-video=width=800,height=600,pixelformat=UYVY
Command explanation
  • –device=/dev/video0: Specify the video device file to be configured.
  • –set-fmt-video: This is a set command used to configure the video capture format.
  • width=800,height=600: Set the width and height of the video. In this example, the resolution is set to 800x600.
  • pixelformat=UYVY: Specifies the pixel format used. In this example, the format is set to UYVY, which is a YUV encoding format.
Precautions
  • The parameter value set must be supported by the video device. If the entered parameters are not supported by the device, the command will report an error.
  • Before setting the format and resolution, it is recommended to use the v4l2-ctl --list-formats-ext command to view all formats and resolutions supported by the device to ensure that the selected parameters are valid.
  • This command is useful for tuning a video device to meet specific application or performance requirements.

Through this command, you can adjust the specific parameters of video capture as needed to obtain the best video quality and performance.

5. Check the control parameters supported by the camera

Order
rk3568_t:/ # v4l2-ctl --device=/dev/v4l-subdev0 --list-ctrls

User Controls

                horizontal_flip 0x00980914 (bool)   : default=0 value=0

Image Processing Controls

                   test_pattern 0x009f0903 (menu)   : min=0 max=1 default=0 value=0
  • –device=/dev/v4l-subdev0: Specify the subdevice file to be queried. This is typically the control interface for a camera or other video capture device.
  • –list-ctrls: This option is used to list all control parameters supported by the camera or video device.
Output explanation
  • The output will include different categories of control parameters, such as "User Controls" and "Image Processing Controls".
  • Each control parameter typically contains the following information:
    • Restraint name:Like horizontal_flip or test_pattern.
    • Parameter type: For example, (bool) represents a Boolean type, and (menu) represents a menu with fixed options.
    • Control identifier: For example, 0x00980914, this is a unique identifier used internally to identify the control.
    • Value range: For example, min=0 max=1 means the value range is from 0 to 1.
    • Default value: For example, default=0 represents the default setting of the control.
    • Current value: For example, value=0 represents the currently set value.
Precautions
  • This command is important for understanding and adjusting the camera's specific control parameters, especially when you need to fine-tune the camera's behavior.
  • Make sure to use the correct device file path /dev/v4l-subdev0 as different devices may have different paths.

Through this command, you can debug various functions and settings of the camera.

6. Set camera control parameters

Order

To set specific control parameters of the camera, use the following command:

v4l2-ctl --device=/dev/v4l-subdev0 --set-ctrl test_pattern=1
Command explanation
  • –device=/dev/v4l-subdev0: Specify the subdevice file to be configured. This usually refers to the control interface of a camera or other video capture device.
  • –set-ctrl: This is a setting command used to adjust the control parameters of the device.
  • test_pattern=1: Specify the control parameters to be set and their values. In this example, the test_pattern control parameter is set to 1.
Functions and uses
  • Setting commands allow adjusting various functions and behaviors of the camera, such as image flipping, color adjustment, exposure control, etc.
  • test_patternThe parameter may be used to enable or disable test mode, which is commonly used for camera debugging and performance testing. Setting this parameter to 1 may indicate activating test mode.
Precautions
  • Before setting the control parameters, it is best to use the v4l2-ctl --list-ctrls command to view all the control parameters supported by the camera and their current settings to ensure that the changes are appropriate.
  • Make sure that the parameter value is within the supported range, otherwise the command may report an error.

In this way, the camera's behavior and performance can be adjusted as needed for optimal image quality and performance.

7. Capture image data

Order

The following command is used to grab image data from a video device and save it to a file:

  1. Grab image data of a specific format and resolution:
v4l2-ctl -d /dev/video0 --set-fmt-video=width=320,height=240,pixelformat=UYVY --stream-mmap=3 --stream-skip=3 --stream-to=./cif.out --stream-count=1 --stream-poll
  1. Grab image data in different formats:
v4l2-ctl -d /dev/video0 --set-fmt-video=width=320,height=240,pixelformat=RGB565_2X8_BE --stream-mmap=3 --stream-skip=3 --stream-to=./cif.out --stream-count=1 --stream-poll
  1. Grab image data using current settings:
v4l2-ctl -d /dev/video0 --stream-mmap=3 --stream-skip=3 --stream-to=./cif.out --stream-count=1 --stream-poll
  1. Capture image data to a specified file:
v4l2-ctl --stream-mmap --stream-count=1 --stream-to=file.raw
  1. Grab image data using default settings and save:
v4l2-ctl -d /dev/video0 --stream-mmap --stream-count=1 --stream-to=image.raw
Command explanation
  • -d /dev/video0: Specify the video device.
  • –set-fmt-video: Set video format and resolution.
  • –stream-mmap: Use memory mapping to read data.
  • –stream-skip: Skip a specific number of frames.
  • –stream-to: Specify the output file name.
  • –stream-count: Set the number of frames to capture.
  • –stream-poll: Use polling to wait for frame data.
Success and failure output
  • Successful capture: The terminal will display frame rate information, such as 30.00 fps.
  • Fetching failed: An error message such as select timeout or VIDIOC_DQBUF: Resource temporarily unavailable may appear.
Error handling

If the crawl fails, you need to check the following aspects:

  • Whether the interface between the video device and the camera is connected correctly.
  • Whether the set video format and resolution are supported by the device.
  • Whether the timing of the camera and video equipment match.

With these commands, image data can be captured from a video device for testing, analysis, or other applications.

8. Display or analyze image data

Since the captured image data is usually in original format, it cannot be opened directly by ordinary image viewers. Specialized tools or code are required to process, display or analyze this data. Here are a few example commands for using the ffmpeg tool to convert and view raw image data:

  1. Set camera format and capture data:
v4l2-ctl --device /dev/video0 --set-fmt-video=width=320,height=240,pixelformat=RG10
v4l2-ctl --device /dev/video0 --stream-mmap --stream-count=1 --stream-to=output.raw
  1. Convert to JPEG format using ffmpeg:
ffmpeg -f rawvideo -pixel_format rg10 -video_size 320x240 -i output.raw output.jpg
  1. Convert raw data in UYVY format to PNG:
ffmpeg -f rawvideo -pixel_format uyvy422 -video_size 320x240 -i file.raw -f image2 -vcodec png file.png
  1. Convert data in YUYV format to PNG:
ffmpeg -f rawvideo -s 320x240 -pix_fmt yuyv422 -i cif.out cif.png
Key points of using ffmpeg
  • -f rawvideo: Specifies the input file format as raw video data.
  • -pixel_format: Specified primitive number deferential image prime form, like rg10, uyvy422, < a i=4> etc. yuyv422
  • -video_size: Specify the resolution of the video, such as 320x240.
  • -i: Specified import subject.
  • -f image2 -vcodec png: Specifies the output format as PNG.
  • Export subject: output.jpg, file.png, cif.png, etc.

Use these commands to convert raw video data into common image formats so that it can be viewed or further analyzed using standard image viewers. These transformation steps are critical for processing and analyzing raw camera data.

9. Media Controller and Device Topology

Order

Use the following command to view device information connected to the media controller:

rk3568_t:/ # media-ctl -p /dev/media0
Opening media device /dev/media0
Enumerating entities
Found 7 entities
Enumerating pads and links
Media controller API version 0.0.107

Media device information
------------------------
driver          rkcif
model           rkcif_dvp
serial
bus info
hw revision     0x0
driver version  0.0.107

Device topology
- entity 1: stream_cif_dvp_id0 (1 pad, 1 link)
            type Node subtype V4L
            device node name /dev/video0
        pad0: Sink
                <- "ov2640 1-0030":0 [ENABLED]

- entity 5: stream_cif_dvp_id1 (1 pad, 0 link)
            type Node subtype V4L
            device node name /dev/video1
        pad0: Sink

- entity 9: stream_cif_dvp_id2 (1 pad, 0 link)
            type Node subtype V4L
            device node name /dev/video2
        pad0: Sink

- entity 13: stream_cif_dvp_id3 (1 pad, 0 link)
             type Node subtype V4L
             device node name /dev/video3
        pad0: Sink

- entity 17: ov2640 1-0030 (1 pad, 1 link)
             type V4L2 subdev subtype Sensor
             device node name /dev/v4l-subdev0
        pad0: Source
                [fmt:UYVY2X8/800x600
                 crop.bounds:(0,0)/320x240
                 crop:(0,0)/320x240]
                -> "stream_cif_dvp_id0":0 [ENABLED]

- entity 19: rkcif-dvp-sof (0 pad, 0 link)
             type V4L2 subdev subtype Unknown
             device node name /dev/v4l-subdev1

- entity 26: rkcif-mipi-luma (0 pad, 0 link)
             type Node subtype V4L
             device node name /dev/video4

Command output explanation
  • Opening media device /dev/media0: Opening media device /dev/media0.
  • Enumerating entities: Enumerate entities in the media controller (such as cameras, video capture devices, etc.).
  • Found 7 entities: Found 7 entities.
  • Enumerating pads and links: Enumerate the interfaces (pads) of entities and the connections between them (links).
  • Media controller API version: Displays the version of the media controller API.
Device Information
  • driver, model: Displays the driver and model names.
  • hw revision, driver version: Hardware revision and driver version information.
Device topology
  • Details for each entity are listed, including:
    • Entity: Entity number and name.
    • Type, subtype: Entity type and subtype.
    • Device node name: Device node name, such as /dev/video0.
    • Pads: Entity interface (pad).
    • Links: The connections between entities.

For example:

  • entity 1: stream_cif_dvp_id0: Represents a video stream entity, the device node is /dev/video0, has a Sink type interface, and is connected to the entity "ov2640 1-0030” connection.
scenes to be used
  • Understand the detailed structure of the video devices connected to the system, especially when doing complex video streaming or debugging.
  • It provides a comprehensive view of the device, including each device's functionality, interface types, and connection relationships between them.

10. Detailed exploration of video device properties and settings

Order

Query all properties and configurations of the specified video device:

rk3568_t:/ # v4l2-ctl --all --device /dev/video0
Driver Info:
        Driver name      : rkcif
        Card type        : rkcif
        Bus info         : platform:rkcif_dvp
        Driver version   : 5.10.107
        Capabilities     : 0x84201000
                Video Capture Multiplanar
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04201000
                Video Capture Multiplanar
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : rkcif
        Model            : rkcif_dvp
        Serial           :
        Bus info         :
        Media version    : 5.10.107
        Hardware revision: 0x00000000 (0)
        Driver version   : 5.10.107
Interface Info:
        ID               : 0x03000002
        Type             : V4L Video
Entity Info:
        ID               : 0x00000001 (1)
        Name             : stream_cif_dvp_id0
        Function         : V4L2 I/O
        Pad 0x01000004   : Sink
          Link 0x02000018: from remote pad 0x1000012 of entity 'ov2640 1-0030': Data, Enabled
Priority: 2
Format Video Capture Multiplanar:
        Width/Height      : 800/600
        Pixel Format      : 'UYVY'
        Field             : None
        Number of planes  : 1
        Flags             :
        Colorspace        : Default
        Transfer Function : Default
        YCbCr Encoding    : Default
        Quantization      : Default
        Plane 0           :
           Bytes per Line : 320
           Size Image     : 153600
Crop: Left 0, Top 0, Width 320, Height 240
Selection: crop, Left 0, Top 0, Width 320, Height 240, Flags:
Selection: crop_bounds, Left 0, Top 0, Width 320, Height 240, Flags:
Selection: crop, Left 0, Top 0, Width 320, Height 240, Flags:
Selection: crop_bounds, Left 0, Top 0, Width 320, Height 240, Flags:
Command output explanation
  • Driver Info: Display driver information, including driver name, card type, bus information, driver version and device capabilities.
  • Capabilities: Lists the capabilities of the device, such as video capture, streaming, extended pixel format, etc.
  • Media Driver Info: Media driver information, including driver name, model, media version, hardware revision, etc.
  • Interface Info: Interface information, including ID and type.
  • Entity Info: Entity information, such as ID, name, function and connection with other entities.
Device configuration details
  • Format Video Capture Multiplanar: Displays the video capture format, including width and height, pixel format, color space, etc.
  • Crop and Selection: Display the crop settings and selection range of the device, including left, top, Width, height, etc.
scenes to be used
  • This command provides detailed configuration and setup information for the device.
  • It can be used in various scenarios such as debugging, performance analysis, and configuration confirmation.

Through this command, in-depth information about the video device can be obtained, including its supported formats, configuration details, and connection status with other devices or entities, which is useful for effective management and troubleshooting of video devices.

Question 1:

When using the Rockchip platform and connecting to the OV2640 camera, there was a problem of failure to obtain the frame interval. The log printed by the system isrkcif_update_sensor_info: get terminal ov2640 1-0030 g_frame_interval failed!

problem causes

This problem occurs in the rkcif_update_sensor_info function of rkcif. It is trying to get the frame interval (g_frame_interval) from the sub-device OV2640 camera, but the operation failed. . This usually means that somewhere in the driver, the frame interval is not being set correctly.

Solution

  1. Find and open the driver code of rkcif and find therkcif_update_sensor_info function.
  2. In therkcif_update_sensor_info function, find the setting part ofg_frame_interval. If the acquisition fails, force a default value to be set. For example:
ret = v4l2_subdev_call(terminal_sensor->sd, video, g_frame_interval, &terminal_sensor->fi);
if (ret) {
    
    
    v4l2_err(&stream->cifdev->v4l2_dev,
             "%s: get terminal %s g_frame_interval failed!\n",
             __func__, terminal_sensor->sd->name);
    // 如果获取失败,则设定一个默认值,比如30帧/秒
    terminal_sensor->fi.numerator = 1;
    terminal_sensor->fi.denominator = 30; // 默认设置为30FPS
}

Summarize:

In this article, I have introduced how to use the Rockchip platform and OV2640 camera for debugging and analysis of video equipment. Demonstrates how to use commands and tools such as v4l2-ctl, media-ctl, ffmpeg to operate and process video devices and image data. I hope this content can help you better understand and use video equipment. If you have any questions or suggestions, please feel free to leave a message.

Guess you like

Origin blog.csdn.net/SHH_1064994894/article/details/134846859