HDMI-to-CSI & Raspberry Pi 5 // Part 1
For our project VM-1 I've prototyped the use of the Waveshare HDMI-to-CSI adapter using GStreamer on the Raspberry Pi 4. Unfortunately this setup does not work anymore for the new Raspberry 5.
These are the instructions that do not to work anymore: https://www.waveshare.com/wiki/HDMI_to_CSI_Adapter
Luckily it seems that the Waveshare adapter is pretty much the same hardware as the Geekworm C790. On their Wiki they describe the necessary steps to to get the adaptor running and how captured frames can be written to disk. This is all done using the v4l2-ctl (Video for Linux) command line tool.
https://wiki.geekworm.com/CSI_Manual_on_Pi_5
These are the steps that work for me.
# 01. Connect HDMI device, eg. camera
# 02. List all available v4l2 devices
# (important is the mediaX device under rp1-cfe, eg. media3)
v4l2-ctl --list-devices
# 03. Show media device information
# important is the device that is listed under the entity named tc358743
# eg. /dev/v4l-subdev2
media-ctl -d /dev/media3 -p
# 04. Get, extract and set edid files
wget https://files.waveshare.com/upload/8/89/TC358743-Driver.zip
unzip TC358743-Driver.zip
cd ~/TC358743-Driver
v4l2-ctl -d /dev/v4l-subdev2 --set-edid=file=./edid/1080p30edid
# 05. Query timings
v4l2-ctl -d /dev/v4l-subdev2 --query-dv-timings
# 06. Set timings
v4l2-ctl -d /dev/v4l-subdev2 --set-dv-bt-timings query
# 07. Initialize media device
media-ctl -d /dev/media3 -r
# 08. Connect CSI2's pad4 to rp1-cfe-csi2_ch0's pad0
media-ctl -d /dev/media3 -l ''\''csi2'\'':4 -> '\''rp1-cfe-csi2_ch0'\'':0 [1]'
# 09. Configure the media node
media-ctl -d /dev/media3 -V ''\''csi2'\'':0 [fmt:RGB888_1X24/1920x1080 field:none colorspace:srgb]'
media-ctl -d /dev/media3 -V ''\''csi2'\'':4 [fmt:RGB888_1X24/1920x1080 field:none colorspace:srgb]'
# 10. Set output format
v4l2-ctl -v width=1920,height=1080,pixelformat=RGB3
# 11. Capture test frames
v4l2-ctl --verbose -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='RGB3' --stream-mmap=4 --stream-skip=3 --stream-count=2 --stream-to=hdmiin.yuv --stream-poll
# 12. View stream with ffplay
v4l2-ctl --verbose -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='RGB3' --stream-mmap=4 --stream-skip=3 --stream-poll --stream-to - | ffplay -f rawvideo -pixel_format rgb24 -video_size 1920x1080 -i -