...
Config render params by 3.2.2 v4l2-ctl capture command
4 Some considerations for storing camera video data in a file system
Writing video data from V4L2 video buffer to the file system involves two issues:
CPU read memory speed
File system write speed
In the sp7350 environment, the file system write speed during testing can be resolved by writing data to /tmp(RAM).
There are some issues with the CPU reading speed when reading data generated by Camera, which will be explained in detail below:
Three memory management models(vb2_mem_ops) have been implemented under the V4L2 video buffer 2 framework, namely dma-contiguous, dma-scatter gas, and vmalloc. According to the hardware characteristics of sp7350, the V4L2 buffer model used to receive MIPICSI-RX data can only be defined as dma-contiguous. The DMA mappings type requested by dma-contiguous is Consistent DMA mappings.
Consistent DMA mappings which are usually mapped at driver initialization, unmapped at the end and for which the hardware should guarantee that the device and the CPU can access the data in parallel and will see updates made by each other without any explicit software flushing(This function is usually achieved by disabling the CPU cache).
When the CPU reads data from the V4L2 video buffer and writes it to a file, it cannot use CPU cache to read the contents of the V4L2 video buffer. The situation will cause an increase in the required number of reads and CPU loading when reading the same data.
4.1 Why remap V4L2 video buffer dma memory
By remapping the DMA buffer, the CPU can use CPU cache to read V4L2 video buffer, improving CPU read performance and reducing CPU loading.
4.2 How to remap V4L2 video buffer dma
After system startup, execute the following command to enable remapping V4L2 video buffer.(Default disbale)
Code Block |
---|
echo Y > /sys/module/videobuf2_dma_contig/parameters/dmaremap |
Execute the following command to disable remapping V4L2 video buffer:
Code Block |
---|
echo N > /sys/module/videobuf2_dma_contig/parameters/dmaremap |
4.3 Test report
UYVY 1920*1080@30FPS (bitrate 124.416MB/s):
Code Block |
---|
v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --set-parm=30 --stream-mmap=10 --stream-to=/tmp/OV5640_UYVY_1080P_001.raw --stream-skip=3 --stream-count=180 |
CPU Loading | FPS | |
---|---|---|
Enable remap | 32% | 30 fps |
Disable remap | 100% | 15 fps |
UYVY 1280*720@30FPS (bitrate 55.296 MB/s):
Code Block |
---|
v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=UYVY --set-parm=30 --stream-mmap=10 --stream-to=/tmp/OV5640_UYVY_720P_001.raw --stream-skip=3 --stream-count=180 |
CPU Loading | FPS | |
---|---|---|
Enable remap | 14.6% | 30 fps |
Disable remap | 88.1% | 30 fps |
UYVY 640*480@30FPS (bitrate 18.432MB/s):
Code Block |
---|
v4l2-ctl -d /dev/video0 --set-fmt-video=width=640,height=480,pixelformat=UYVY --set-parm=30 --stream-mmap=10 --stream-to=/tmp/OV5640_UYVY_480P_001.raw --stream-skip=3 --stream-count=180 |
CPU Loading | FPS | |
---|---|---|
Enable remap | 5.2% | 30 fps |
Disable remap | 34.7% | 30 fps |