Camera module MCAM400 (https://wiki.friendlyelec.com/wiki/index.php/Matrix_-_MCAM400) with OV4689 sensor was designed for NanoPi-M4 and similar boards.
But it's also compatible with NanoPC-T6.
See attached archive with DTS file rk3588-nanopi6-ov4689.dtsi.
Add line:
#include "rk3588-nanopi6-ov4689.dtsi"
at the beginning of file arch/arm64/boot/dts/rockchip/rk3588-nanopi6-rev01.dts and put rk3588-nanopi6-ov4689.dtsi to the same directory. Compile kernel and flash kernel.img and resource.img (see https://wiki.friendlyelec.com/wiki/index.php/NanoPC-T6#How_to_Compile).
After reboot camera MCAM400 will be available on slot CSI-0 (in this case use /dev/video22 below) or CSI-1 (use /dev/video31).
Capture 100 frames of uncompressed video to file:
v4l2-ctl -d /dev/video22 --set-fmt-video=width=1920,height=1080,pixelformat='NV12' --stream-mmap=4 --stream-poll --stream-to=test.yuv --stream-count=100
or
gst-launch-1.0 v4l2src device=/dev/video22 io-mode=4 num-buffers=100 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! filesink location=test.yuv
Then you can convert and compress test.yuv:
ffmpeg -y -pix_fmt nv12 -s 1920x1080 -r 30 -i test.yuv -c:v libx264 -pix_fmt yuv420p test.mp4
or
ffmpeg -y -pix_fmt nv12 -s 1920x1080 -r 30 -i test.yuv -c:v mjpeg -pix_fmt yuv420p test.avi
Note that capturing of uncompressed video requires fast "disk", use NVMe SSD or RAM disk (tmpfs).
Capture video and compress in single command:
gst-launch-1.0 v4l2src device=/dev/video22 io-mode=4 ! video/x-raw,width=1920,height=1080,format=NV12,framerate=30/1 ! mpph264enc ! queue ! h264parse ! mpegtsmux ! filesink location=test.ts
Show video on display:
gst-launch-1.0 v4l2src device=/dev/video22 io-mode=4 ! video/x-raw,width=1920,height=1080,format=NV12,framerate=30/1 ! videoconvert ! xvimagesink
If you want to get high speed video 1920x1080 at 120 fps, then you must replace file (keep the old one!) driver/media/i2c/ov4689.c with provided file ov4689.c (sensor register values in this file were got from https://blog.csdn.net/u010018991/article/details/102687614), recompile and flash kernel (keep old kernel with original driver to restore later!).
Measurement of speed:
v4l2-ctl -d /dev/video22 --set-fmt-video=width=1920,height=1080,pixelformat='NV12' --stream-mmap=4 --stream-skip=5 --stream-count=1000 --stream-poll --stream-to=/dev/null
If you want to save video to file instead of /dev/null, use very fast disk, as transfer rate of video is about 360 MB/sec.
Restore the old kernel if you do not need high speed more.
Also I included file rk3588-nanopi6-hdmiclk.dtsi for whose who use 2K display and cannot set resolution 2560x1440. I use this overlay (I do not remember where I found it first time) on different RK3588 boards. To apply it, add line:
#include "rk3588-nanopi6-hdmiclk.dtsi"
to rk3588-nanopi6-rev01.dts and put file to the same directory. Recompile and flash resource.img.
But it's also compatible with NanoPC-T6.
See attached archive with DTS file rk3588-nanopi6-ov4689.dtsi.
Add line:
#include "rk3588-nanopi6-ov4689.dtsi"
at the beginning of file arch/arm64/boot/dts/rockchip/rk3588-nanopi6-rev01.dts and put rk3588-nanopi6-ov4689.dtsi to the same directory. Compile kernel and flash kernel.img and resource.img (see https://wiki.friendlyelec.com/wiki/index.php/NanoPC-T6#How_to_Compile).
After reboot camera MCAM400 will be available on slot CSI-0 (in this case use /dev/video22 below) or CSI-1 (use /dev/video31).
Capture 100 frames of uncompressed video to file:
v4l2-ctl -d /dev/video22 --set-fmt-video=width=1920,height=1080,pixelformat='NV12' --stream-mmap=4 --stream-poll --stream-to=test.yuv --stream-count=100
or
gst-launch-1.0 v4l2src device=/dev/video22 io-mode=4 num-buffers=100 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! filesink location=test.yuv
Then you can convert and compress test.yuv:
ffmpeg -y -pix_fmt nv12 -s 1920x1080 -r 30 -i test.yuv -c:v libx264 -pix_fmt yuv420p test.mp4
or
ffmpeg -y -pix_fmt nv12 -s 1920x1080 -r 30 -i test.yuv -c:v mjpeg -pix_fmt yuv420p test.avi
Note that capturing of uncompressed video requires fast "disk", use NVMe SSD or RAM disk (tmpfs).
Capture video and compress in single command:
gst-launch-1.0 v4l2src device=/dev/video22 io-mode=4 ! video/x-raw,width=1920,height=1080,format=NV12,framerate=30/1 ! mpph264enc ! queue ! h264parse ! mpegtsmux ! filesink location=test.ts
Show video on display:
gst-launch-1.0 v4l2src device=/dev/video22 io-mode=4 ! video/x-raw,width=1920,height=1080,format=NV12,framerate=30/1 ! videoconvert ! xvimagesink
If you want to get high speed video 1920x1080 at 120 fps, then you must replace file (keep the old one!) driver/media/i2c/ov4689.c with provided file ov4689.c (sensor register values in this file were got from https://blog.csdn.net/u010018991/article/details/102687614), recompile and flash kernel (keep old kernel with original driver to restore later!).
Measurement of speed:
v4l2-ctl -d /dev/video22 --set-fmt-video=width=1920,height=1080,pixelformat='NV12' --stream-mmap=4 --stream-skip=5 --stream-count=1000 --stream-poll --stream-to=/dev/null
If you want to save video to file instead of /dev/null, use very fast disk, as transfer rate of video is about 360 MB/sec.
Restore the old kernel if you do not need high speed more.
Also I included file rk3588-nanopi6-hdmiclk.dtsi for whose who use 2K display and cannot set resolution 2560x1440. I use this overlay (I do not remember where I found it first time) on different RK3588 boards. To apply it, add line:
#include "rk3588-nanopi6-hdmiclk.dtsi"
to rk3588-nanopi6-rev01.dts and put file to the same directory. Recompile and flash resource.img.