Template:C792-Software: Difference between revisions
| (4 intermediate revisions by the same user not shown) | |||
| Line 14: | Line 14: | ||
<mark>1.</mark> Update and upgrade your Raspberry Pi system (time required varies by country/region). | <mark>1.</mark> Update and upgrade your Raspberry Pi system (time required varies by country/region). | ||
sudo apt-get update | <pre style="margin-left: 1em;"> | ||
sudo apt-get update | |||
sudo apt-get upgrade | |||
</pre> | |||
<mark>2.</mark> Enable the camera module (enabled by default on Raspberry Pi Bullseye OS). | <mark>2.</mark> Enable the camera module (enabled by default on Raspberry Pi Bullseye OS). | ||
| Line 39: | Line 41: | ||
*Edit the <code>/boot/firmware/config.txt</code> file (sudo privileges required): | *Edit the <code>/boot/firmware/config.txt</code> file (sudo privileges required): | ||
<pre> | <pre style="margin-left: 1em;"> | ||
sudo nano /boot/firmware/config.txt | sudo nano /boot/firmware/config.txt | ||
</pre> | </pre> | ||
| Line 47: | Line 49: | ||
*Add the line: | *Add the line: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
dtoverlay=tc358743 | dtoverlay=tc358743 | ||
</pre> | </pre> | ||
*Add the line if your shield support audio like C790 or C792: | *Add the line if your shield support audio like C790 or C792: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
dtoverlay=tc358743-audio | dtoverlay=tc358743-audio | ||
</pre> | </pre> | ||
*Add the line '''only if''': your device (e.g., C790/C792) supports a 22-pin connector with all 4 lanes connected, and the compute module has the '''CAM1 interface''' with all 4 lanes connected: | *Add the line '''only if''': your device (e.g., C790/C792) supports a 22-pin connector with all 4 lanes connected, and the compute module has the '''CAM1 interface''' with all 4 lanes connected: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
dtoverlay=tc358743,4lane=1 | dtoverlay=tc358743,4lane=1 | ||
</pre> | </pre> | ||
| Line 65: | Line 67: | ||
*Use the following command to check the amount of memory allocated to the CMA heap: | *Use the following command to check the amount of memory allocated to the CMA heap: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
dmesg | grep cma | dmesg | grep cma | ||
</pre> | </pre> | ||
*The first line should look like: | *The first line should look like: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
pi@raspberrypi:~ $ dmesg | grep cma | pi@raspberrypi:~ $ dmesg | grep cma | ||
[0.000000] cma: Reserved 256 MiB at 0x000000001ec00000 | [0.000000] cma: Reserved 256 MiB at 0x000000001ec00000 | ||
| Line 76: | Line 78: | ||
*If the reported CMA allocated memory is less than 96MB, edit the <code>/boot/cmdline.txt</code> file and add the following at the start of the line <span class="tb_red">(do not add a newline character)</span>: | *If the reported CMA allocated memory is less than 96MB, edit the <code>/boot/cmdline.txt</code> file and add the following at the start of the line <span class="tb_red">(do not add a newline character)</span>: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
cma=96M | cma=96M | ||
</pre> | </pre> | ||
| Line 84: | Line 86: | ||
*Reboot the device. If everything works properly, you should see the <code>/dev/video0</code> device, and running the following command will show it is provided by Unicam: | *Reboot the device. If everything works properly, you should see the <code>/dev/video0</code> device, and running the following command will show it is provided by Unicam: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
v4l2-ctl --list-devices | v4l2-ctl --list-devices | ||
</pre> | </pre> | ||
| Line 92: | Line 94: | ||
*After connecting all cables, power on the Raspberry Pi and enter the commands below: | *After connecting all cables, power on the Raspberry Pi and enter the commands below: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
pi@raspberrypi:~ $ ls /dev/video0 | pi@raspberrypi:~ $ ls /dev/video0 | ||
/dev/video0 | /dev/video0 | ||
| Line 117: | Line 119: | ||
*Several EDID editors are available on the market. You need to first create an edid.txt file (you can use the <code>command nano edid.txt</code> to create and edit the file), then copy the content below into the edid.txt file: | *Several EDID editors are available on the market. You need to first create an edid.txt file (you can use the <code>command nano edid.txt</code> to create and edit the file), then copy the content below into the edid.txt file: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
00ffffffffffff005262888800888888 | 00ffffffffffff005262888800888888 | ||
1c150103800000780aEE91A3544C9926 | 1c150103800000780aEE91A3544C9926 | ||
| Line 137: | Line 139: | ||
*After the edid.txt file is created, execute the command <code>v4l2-ctl --set-edid=file=edid.txt --fix-edid-checksums</code> in the terminal, and you will see output similar to the following: | *After the edid.txt file is created, execute the command <code>v4l2-ctl --set-edid=file=edid.txt --fix-edid-checksums</code> in the terminal, and you will see output similar to the following: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
pi@raspberrypi:~ $ v4l2-ctl --set-edid=file=edid.txt --fix-edid-checksums | pi@raspberrypi:~ $ v4l2-ctl --set-edid=file=edid.txt --fix-edid-checksums | ||
| Line 165: | Line 167: | ||
*Detect the presence of HDMI signal input at present via command: | *Detect the presence of HDMI signal input at present via command: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
pi@raspberrypi:~ $ v4l2-ctl --query-dv-timings | pi@raspberrypi:~ $ v4l2-ctl --query-dv-timings | ||
Active width: 1280 | Active width: 1280 | ||
| Line 193: | Line 195: | ||
*Use the following command to select UYVY (however, your application may override this setting): | *Use the following command to select UYVY (however, your application may override this setting): | ||
<pre> | <pre style="margin-left: 1em;"> | ||
v4l2-ctl -v pixelformat=UYVY | v4l2-ctl -v pixelformat=UYVY | ||
</pre> | </pre> | ||
| Line 201: | Line 203: | ||
*Check if the audio driver/sound card is available for ALSA: | *Check if the audio driver/sound card is available for ALSA: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
pi@raspberrypi:~ $ arecord -l. | pi@raspberrypi:~ $ arecord -l. | ||
**** List of CAPTURE Hardware Devices ****. | **** List of CAPTURE Hardware Devices ****. | ||
| Line 215: | Line 217: | ||
*Install the GStreamer tools: | *Install the GStreamer tools: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
sudo apt install gstreamer1.0-tools | sudo apt install gstreamer1.0-tools | ||
</pre> | </pre> | ||
*Check the GStreamer tool version: | *Check the GStreamer tool version: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
pi@raspberrypi:~ $ gst-launch-1.0 --version | pi@raspberrypi:~ $ gst-launch-1.0 --version | ||
gst-launch-1.0 version 1.18.4 | gst-launch-1.0 version 1.18.4 | ||
| Line 232: | Line 234: | ||
<mark>'''[Application Example — Using GStreamer to Record Video and Audio]'''</mark> | <mark>'''[Application Example — Using GStreamer to Record Video and Audio]'''</mark> | ||
<pre> | <pre style="margin-left: 1em;"> | ||
# GStreamer v1.14 Command | # GStreamer v1.14 Command | ||
gst-launch-1.0 v4l2src io-mode=5 ! video/x-raw, format=UYVY, framerate=25/1 ! v4l2h264enc output-io-mode=4 ! video/x-h264,profile=high ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv alsasrc device=hw:1 ! audio/x-raw,rate=48000,channels=2 ! audioconvert ! avenc_aac bitrate=48000 ! aacparse ! queue ! mux. | gst-launch-1.0 v4l2src io-mode=5 ! video/x-raw, format=UYVY, framerate=25/1 ! v4l2h264enc output-io-mode=4 ! video/x-h264,profile=high ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv alsasrc device=hw:1 ! audio/x-raw,rate=48000,channels=2 ! audioconvert ! avenc_aac bitrate=48000 ! aacparse ! queue ! mux. | ||
| Line 239: | Line 241: | ||
<code>foo.mkv</code> is the output file. | <code>foo.mkv</code> is the output file. | ||
If your GStreamer version is 1.8 or higher, you can try the following test command. Additionally, <code>alsasrc device=hw:1</code> refers to the sound card for TC358743; you can check this with the command <code>arecord -l</code>. | If your GStreamer version is 1.8 or higher, you can try the following test command. Additionally, <code>alsasrc device=hw:1</code> refers to the sound card for TC358743; you can check this with the command <code>arecord -l</code>. | ||
<pre> | <pre style="margin-left: 1em;"> | ||
# Command to record video with audio(GStreamer 1.18.4) | # Command to record video with audio(GStreamer 1.18.4) | ||
gst-launch-1.0 -vvv v4l2src ! "video/x-raw,framerate=30/1,format=UYVY" ! v4l2h264enc extra-controls="controls,h264_profile=4,h264_level=13,video_bitrate=256000;" ! "video/x-h264,profile=high, level=(string)4.2" ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv alsasrc device=hw:1 ! audio/x-raw,rate=48000,channels=2 ! audioconvert ! avenc_aac bitrate=48000 ! aacparse ! queue ! mux. | gst-launch-1.0 -vvv v4l2src ! "video/x-raw,framerate=30/1,format=UYVY" ! v4l2h264enc extra-controls="controls,h264_profile=4,h264_level=13,video_bitrate=256000;" ! "video/x-h264,profile=high, level=(string)4.2" ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv alsasrc device=hw:1 ! audio/x-raw,rate=48000,channels=2 ! audioconvert ! avenc_aac bitrate=48000 ! aacparse ! queue ! mux. | ||
| Line 255: | Line 257: | ||
*Record video only: | *Record video only: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
gst-launch-1.0 -vvv v4l2src ! "video/x-raw,framerate=60/1,format=UYVY" ! v4l2h264enc extra-controls="controls,h264_profile=4,h264_level=13,video_bitrate=256000;" ! "video/x-h264,profile=high, level=(string)4.2" ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv | gst-launch-1.0 -vvv v4l2src ! "video/x-raw,framerate=60/1,format=UYVY" ! v4l2h264enc extra-controls="controls,h264_profile=4,h264_level=13,video_bitrate=256000;" ! "video/x-h264,profile=high, level=(string)4.2" ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv | ||
</pre> | </pre> | ||
*Record video and audio (if your module supports audio): | *Record video and audio (if your module supports audio): | ||
<pre> | <pre style="margin-left: 1em;"> | ||
gst-launch-1.0 -vvv v4l2src ! "video/x-raw,framerate=60/1,format=UYVY" ! v4l2h264enc extra-controls="controls,h264_profile=4,h264_level=13,video_bitrate=256000;" ! "video/x-h264,profile=high, level=(string)4.2" ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv alsasrc device=hw:1 ! audio/x-raw,rate=48000,channels=2 ! audioconvert ! avenc_aac bitrate=48000 ! aacparse ! queue ! mux. | gst-launch-1.0 -vvv v4l2src ! "video/x-raw,framerate=60/1,format=UYVY" ! v4l2h264enc extra-controls="controls,h264_profile=4,h264_level=13,video_bitrate=256000;" ! "video/x-h264,profile=high, level=(string)4.2" ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv alsasrc device=hw:1 ! audio/x-raw,rate=48000,channels=2 ! audioconvert ! avenc_aac bitrate=48000 ! aacparse ! queue ! mux. | ||
</pre> | </pre> | ||
| Line 280: | Line 282: | ||
Add the following two lines to the <code>/boot/firmware/config.txt</code> file: | Add the following two lines to the <code>/boot/firmware/config.txt</code> file: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
dtoverlay=tc358743,4lane=1 | dtoverlay=tc358743,4lane=1 | ||
dtoverlay=tc358743-audio | dtoverlay=tc358743-audio | ||
| Line 289: | Line 291: | ||
After adding the driver configuration, restart the Raspberry Pi for the changes to take effect. If the configuration is correct, execute the following command in the terminal: <code>ls /dev/video*</code>. The configuration is successful if video devices appear in the output: | After adding the driver configuration, restart the Raspberry Pi for the changes to take effect. If the configuration is correct, execute the following command in the terminal: <code>ls /dev/video*</code>. The configuration is successful if video devices appear in the output: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
pi@raspberrypi:~/Desktop $ ls /dev/video* | |||
/dev/video0 /dev/video19 /dev/video20 /dev/video22 /dev/video24 /dev/video26 /dev/video28 /dev/video3 /dev/video31 /dev/video33 /dev/video35 /dev/video5 /dev/video7 | |||
/dev/video1 /dev/video2 /dev/video21 /dev/video23 /dev/video25 /dev/video27 /dev/video29 /dev/video30 /dev/video32 /dev/video34 /dev/video4 /dev/video6 | |||
</pre> | </pre> | ||
| Line 299: | Line 301: | ||
First, execute the command <code>nano 1080p60edid</code> in the terminal to create an EDID file for 1080p60Hz. The content of this file is as follows: | First, execute the command <code>nano 1080p60edid</code> in the terminal to create an EDID file for 1080p60Hz. The content of this file is as follows: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
00 ff ff ff ff ff ff 00 52 62 00 37 00 00 00 00 | |||
01 1b 01 03 80 46 28 78 0a cf 74 a3 57 4c b0 23 | |||
09 48 4c 21 08 00 b3 00 95 00 a9 40 90 40 81 00 | |||
81 80 81 40 01 01 02 3a 80 18 71 38 2d 40 58 2c | |||
45 00 00 d0 52 00 00 1e 02 3a 80 d0 72 38 2d 40 | |||
10 2c 45 80 00 d0 52 00 00 1e 00 00 00 fc 00 33 | |||
32 46 48 44 5f 4c 43 44 5f 54 56 0a 00 00 00 fd | |||
00 30 3e 0f 46 11 00 0a 20 20 20 20 20 20 01 38 | |||
02 03 30 f1 52 10 9f 04 13 05 14 03 02 11 12 20 | |||
21 22 15 16 01 06 07 2c 09 07 07 15 07 50 57 06 | |||
00 3f 06 c0 83 01 00 00 67 03 0c 00 10 00 b0 2d | |||
01 1d 80 3e 73 38 2d 40 7e 2c 45 80 00 d0 52 00 | |||
00 1e 01 1d 80 d0 72 1c 2d 20 10 2c 25 80 00 d0 | |||
52 00 00 9e 01 1d 00 bc 52 d0 1e 20 b8 28 55 40 | |||
00 d0 52 00 00 1e 01 1d 80 18 71 1c 16 20 58 2c | |||
25 00 00 d0 52 00 00 9e 00 00 00 00 00 00 00 8f | |||
</pre> | </pre> | ||
| Line 322: | Line 324: | ||
Execute <code>nano testC7xx.sh</code> in the same directory to create a test script. The content of this file is as follows: | Execute <code>nano testC7xx.sh</code> in the same directory to create a test script. The content of this file is as follows: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
#!/bin/bash | #!/bin/bash | ||
MEDIADEVICE=-1 | MEDIADEVICE=-1 | ||
| Line 372: | Line 374: | ||
Execute <code>bash testC7xx.sh</code> directly in the terminal; the output is as follows: | Execute <code>bash testC7xx.sh</code> directly in the terminal; the output is as follows: | ||
<pre> | <pre style="margin-left: 1em;"> | ||
pi@raspberrypi:~/Desktop $ bash testC7xx.sh | pi@raspberrypi:~/Desktop $ bash testC7xx.sh | ||
Active width: 1920 | Active width: 1920 | ||
| Line 394: | Line 396: | ||
:If you have installed the Raspberry Pi Desktop version, you can use ffplay to play YUV files directly. | :If you have installed the Raspberry Pi Desktop version, you can use ffplay to play YUV files directly. | ||
<pre> | <pre style="margin-left: 1em;"> | ||
ffplay -f rawvideo -video_size 1920x1080 -pixel_format bgr24 test.yuv | ffplay -f rawvideo -video_size 1920x1080 -pixel_format bgr24 test.yuv | ||
</pre> | </pre> | ||