Video codec support in hardware on the 820c


#1

I got the 820c and installed the gstreamer package. Can someone tell me which of the H.264/265 plugins uses the 820 HEVC video hardware accelerator?

Thx,
Y-


#2

hi,

the hw video acceleration is provided by a v4l2 driver in the kernel. From the user space perspectives, the v4l2 driver (e.g. /dev/videoX) can be used directly through the v4l2 ‘API’. For an example of how to use v4l2 API, you can check this code: https://github.com/robclark/kmscube/tree/v4l2-video.

The v4l2 API is ‘generic’ and not tied to any specific SoC, several ARM SoC use it for video acceleration (including Snapdragon). As such there is a Gstreamer plugin (in -good set) called v4l2videodec that implements the v4l2 API, and which can be used with v4l2 compliant drivers.

In fact, with our release v4l2videodec should be the default elements used by Gstreamer, such that

gst-play-1.0 <file> --videosink glimagesink

should work and use video acceleration. To check that video acceleration is being used you can run

cat /proc/interupts | grep venus

and see the count going up.

Even if that works, the ‘automatic’ pipeline won’t be fully optimized, and there are some video buffer copies that are done by Gstreamer, mostly because Gstreamer doesn’t figure out how to allocate memory in the most optimized way (which would allow zero-copy pipeline). To allocate memory optimally, you need to tweak the Gstreamer pipeline, for example the following command would run an optimized video pipeline:

GST_GL_PLATFORM=egl gst-launch-1.0 filesrc location=<path to file> ! qtdemux name=m m.video_0 ! h264parse ! v4l2video0dec capture-io-mode=dmabuf ! glimagesink

You will need to adjust the command based on the codec/file you are using, of course.

All of the above applies to both DB410c and DB820c, by the way.

There is currently a bug under investigation and 4K video clips don’t work with Gstreamer (but they work with the v4l2 test app mentioned at the beginning).


#3

Thanks. Does the gstreamer for the 820c support H.264/265 encode and decode using the hardware?

gst-inspect returns:
linaro@linaro-developer:~$ gst-inspect-1.0 | grep 264
libav: avenc_h264_omx: libav OpenMAX IL H.264 video encoder encoder
libav: avdec_h264: libav H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 decoder
libav: avmux_ipod: libav iPod H.264 MP4 (MPEG-4 Part 14) muxer
rtp: rtph264depay: RTP H264 depayloader
rtp: rtph264pay: RTP H264 payloader
typefindfunctions: video/x-h264: h264, x264, 264
videoparsersbad: h264parse: H.264 parser
uvch264: uvch264mjpgdemux: UVC H264 MJPG Demuxer
uvch264: uvch264src: UVC H264 Source
linaro@linaro-developer:~$ gst-inspect-1.0 | grep 265
libav: avdec_h265: libav HEVC (High Efficiency Video Coding) decoder
rtp: rtph265depay: RTP H265 depayloader
rtp: rtph265pay: RTP H265 payloader
libde265: libde265dec: HEVC/H.265 decoder
x265: x265enc: x265enc
typefindfunctions: video/x-h265: h265, x265, 265
videoparsersbad: h265parse: H.265 parser
linaro@linaro-developer:~$

so it looks like there is a 264 encode/decode and a 265 decode but no 265 encode (in hardware)… right?
thx,


#4

hi,

these are the s/w codecs from libav/ffmpeg, you can check “gst-inspect-1.0 avdec_h265” for more details.

On the Snapdragon s/w , the h/w codecs are provided as v4l2 kernel drivers (using the v4l2 memory2memory2 API). And Gst has support for such decoder:

gst-inspect-1.0 | grep v4l2

video4linux2: v4l2video0dec: V4L2 Video Decoder

So v4l2video0dec is the plugin that provides video decoder capability , using the hw.

I will need to check what is the status of h265 in v4l2videodec, as I don’t remember if it was merged.

For the encoder, there is a similar plugin “v4l2videoenc” which was merged recently in gst master branch, and which is not available in gst 1.10 or 1.12. But we have instructions in our latest DB410c release to pull in the relevant patches (http://builds.96boards.org/releases/dragonboard410c/linaro/debian/17.06/).


#5

So to get the 264/265 encoder does one need to rebuild the kernel and gstreamer, or just gstreamer?
Thx,
Y-


#6

you only need to rebuild gstreamer.


#7

I found these instructions for building gstreamer but they are for the tegra. I assume that building for the 820c would be close to this. I will use the 1.13 version:


#8

as mentioned earlier in this thread, we have instructions to rebuild Gstreamer with v4l2h264encoder support. The instructions are in the DB410c release notes here:

http://builds.96boards.org/releases/dragonboard410c/linaro/debian/17.06/

Search for “Video record pipeline”. While the instructions are for db410c, the gstreamer information is generic and will work for db820c as well.

And rebuilding Gstreamer won’t be needed after they release 1.14 version, since all patches will be there.


#9

FYI:

I followed these steps, and after I copied the firmware files to /lib/firmware, the 820c just locks up on boot:

wget http://builds.96boards.org/snapshots/dragonboard820c/linaro/debian/latest/boot-linaro-stretch-qcom-snapdragon-arm64-.img.gz
gunzip boot-linaro-stretch-qcom-snapdragon-arm64-
.img.gz
abootimg -u boot-linaro-stretch-qcom-snapdragon-arm64-.img -c "cmdline=root=/dev/disk/by-partlabel/userdata rw rootwait console=tty0 console=ttyMSM0,115200n8"
fastboot flash boot boot-linaro-stretch-qcom-snapdragon-arm64-
.img

wget http://builds.96boards.org/snapshots/dragonboard820c/linaro/debian/latest/linaro-stretch-developer-qcom-snapdragon-arm64-.img.gz
gunzip linaro-stretch-developer-qcom-snapdragon-arm64-
.img.gz
fastboot flash userdata linaro-stretch-developer-qcom-snapdragon-arm64-*.img

$ cat /etc/apt/sources.list
deb http://http.debian.net/debian/ sid main contrib non-free
deb-src http://http.debian.net/debian/ sid main contrib non-free

apt update
apt dist-upgrade
apt install lxqt
apt install chromium gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0

[ 3.904520] arm-smmu b40000.arm,smmu: stage 1 translation
[ 3.904522] arm-smmu b40000.arm,smmu: address translation ops
[ 3.904525] arm-smmu b40000.arm,smmu: non-coherent table walk
[ 3.904527] arm-smmu b40000.arm,smmu: (IDR0.CTTW overridden by FW configuration)
[ 3.904530] arm-smmu b40000.arm,smmu: stream matching with 2 register groups
[ 3.904556] arm-smmu b40000.arm,smmu: 2 context banks (0 stage-2 only)
[ 3.904582] arm-smmu b40000.arm,smmu: Supported page sizes: 0x63315000
[ 3.904584] arm-smmu b40000.arm,smmu: Stage-1: 48-bit VA -> 36-bit IPA
[ 3.905581] iommu: Adding device b00000.gpu to group 1
[ 3.905785] adreno b00000.gpu: Linked as a consumer to b40000.arm,smmu
[ 3.906042] msm 900000.mdss: 900000.mdss supply vdd not found, using dummy regulator
[ 3.906808] msm 900000.mdss: bound 901000.mdp (ops mdp5_ops)
[ 3.907241] hdmi_msm 9a0000.hdmi-tx: failed to init hdcp: disabled
[ 3.907546] msm 900000.mdss: bound 9a0000.hdmi-tx (ops msm_hdmi_ops)
[ 3.907558] msm 900000.mdss: bound b00000.gpu (ops a3xx_ops)
[ 4.055510] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[ 4.055512] [drm] Driver supports precise vblank timestamp query.
[ 4.056605] [drm] Initialized msm 1.2.0 20130625 for 900000.mdss on minor 0
[ 4.056629] [drm] Cannot find any crtc or sizes - going 1024x768
[ 4.140271] Console: switching to colour frame buffer device 128x48
[ 4.140985] scsi 0:0:0:3: Direct-Access TOSHIBA THGLF2G8J4LBATRH 0101 PQ: 0 ANSI: 6
[ 4.141973] sd 0:0:0:2: [sdc] 1024 4096-byte logical blocks: (4.19 MB/4.00 MiB)
[ 4.142185] sd 0:0:0:2: [sdc] Write Protect is off
[ 4.142502] sd 0:0:0:2: [sdc] Write cache: enabled, read cache: enabled, supports DPO and FUA
[ 4.142920] scsi 0:0:0:4: Direct-Access TOSHIBA THGLF2G8J4LBATRH 0101 PQ: 0 ANSI: 6
[ 4.143747] sd 0:0:0:3: [sdd] 32768 4096-byte logical blocks: (134 MB/128 MiB)
[ 4.143901] sd 0:0:0:3: [sdd] Write Protect is off
[ 4.144223] sd 0:0:0:3: [sdd] Write cache: enabled, read cache: enabled, supports DPO and FUA
[ 4.145381] scsi 0:0:0:5: Direct-Access TOSHIBA THGLF2G8J4LBATRH 0101 PQ: 0 ANSI: 6
[ 4.148480] sd 0:0:0:5: [sdf] 393216 4096-byte logical blocks: (1.61 GB/1.50 GiB)
[ 4.148623] sd 0:0:0:5: [sdf] Write Protect is off
[ 4.148913] sd 0:0:0:5: [sdf] Write cache: enabled, read cache: enabled, supports DPO and FUA
[ 4.149326] sd 0:0:0:4: [sde] 1048576 4096-byte logical blocks: (4.29 GB/4.00 GiB)
[ 4.153541] sdf: sdf1 sdf2 sdf3
[ 4.153714] sd 0:0:0:4: [sde] Write Protect is off
[ 4.155850] sd 0:0:0:5: [sdf] Attached SCSI disk
[ 4.156589] sdc: sdc1
[ 4.156725] sd 0:0:0:4: [sde] Write cache: enabled, read cache: enabled, supports DPO and FUA
[ 4.159980] sdd: sdd1 sdd2 sdd3
[ 4.161332] sd 0:0:0:2: [sdc] Attached SCSI disk
[ 4.164677] sde: sde1 sde2 sde3 sde4 sde5 sde6 sde7 sde8 sde9 sde10 sde11 sde12 sde13 sde14 sde15 sde16 sde17 sde18 sde19 sde20 sde212
[ 4.165049] sd 0:0:0:3: [sdd] Attached SCSI disk
[ 4.169072] sd 0:0:0:4: [sde] Attached SCSI disk
[ 4.310021] msm 900000.mdss: fb0: msm frame buffer device
[ 4.317970] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 4.323133] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 1
[ 4.328603] xhci-hcd xhci-hcd.1.auto: hcc params 0x0228f665 hci version 0x100 quirks 0x02010010
[ 4.335228] xhci-hcd xhci-hcd.1.auto: irq 300, io mem 0x06a00000
[ 4.344277] hub 1-0:1.0: USB hub found
[ 4.350063] hub 1-0:1.0: 1 port detected
[ 4.355357] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 4.360560] xhci-hcd xhci-hcd.1.auto: new USB bus registered, assigned bus number 2
[ 4.365870] usb usb2: We don’t know the algorithms for LPM for this host, disabling LPM.
[ 4.372939] hub 2-0:1.0: USB hub found
[ 4.380909] hub 2-0:1.0: 1 port detected
[ 4.386876] input: gpio_keys as /devices/platform/gpio_keys/input/input0
[ 4.392496] hctosys: unable to open rtc device (rtc0)
[ 4.398750] ALSA device list:
[ 4.403951] No soundcards found.
[ 4.409457] Freeing unused kernel memory: 1088K
Loading, please wait…
starting version 232
[ 4.683451] atl1c 0002:01:00.0 enP2p1s0: renamed from eth0
[ 4.688914] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[ 4.846071] hub 1-1:1.0: USB hub found
[ 4.851388] hub 1-1:1.0: 4 ports detected
[ 4.951186] usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd
[ 5.006050] hub 2-1:1.0: USB hub found
[ 5.011304] hub 2-1:1.0: 4 ports detected
Begin: Loading essential drivers … done.
Begin: Running /scripts/init-premount … done.
Begin: Mounting root file system … Begin: Running /scripts/local-top … done.
Begin: Running /scripts/local-premount … [ 5.107072] raid6: int64x1 gen() 1202 MB/s
[ 5.179069] raid6: int64x1 xor() 725 MB/s
[ 5.251090] raid6: int64x2 gen() 1564 MB/s
[ 5.323071] raid6: int64x2 xor() 1020 MB/s
[ 5.395099] raid6: int64x4 gen() 1997 MB/s
[ 5.467072] raid6: int64x4 xor() 1217 MB/s
[ 5.539070] raid6: int64x8 gen() 2094 MB/s
[ 5.611070] raid6: int64x8 xor() 1293 MB/s
[ 5.683103] raid6: neonx1 gen() 1925 MB/s
[ 5.755087] raid6: neonx1 xor() 1343 MB/s
[ 5.827091] raid6: neonx2 gen() 2427 MB/s
[ 5.899069] raid6: neonx2 xor() 1783 MB/s
[ 5.967082] raid6: neonx4 gen() 2996 MB/s
[ 6.035073] raid6: neonx4 xor() 2061 MB/s
[ 6.103074] raid6: neonx8 gen() 2695 MB/s
[ 6.171075] raid6: neonx8 xor() 1758 MB/s
[ 6.174765] raid6: using algorithm neonx4 gen() 2996 MB/s
[ 6.178409] raid6: … xor() 2061 MB/s, rmw enabled
[ 6.183230] raid6: using intx1 recovery algorithm
[ 6.189309] xor: measuring software checksum speed
[ 6.231069] 8regs : 3702.000 MB/sec
[ 6.271065] 8regs_prefetch: 3379.000 MB/sec
[ 6.311064] 32regs : 4124.000 MB/sec
[ 6.351066] 32regs_prefetch: 3931.000 MB/sec
[ 6.354240] xor: using function: 32regs (4124.000 MB/sec)
[ 6.375854] Btrfs loaded, crc32c=crc32c-generic
Scanning for Btrfs filesystems
done.
Begin: Will now check root file system … fsck from util-linux 2.29.2
fsck: error 2 (No such file or directory) while executing fsck.ext4 for /dev/sda9
fsck exited with status code 8
done.
Warning: File system check failed but did not detect errors
[ 11.615469] EXT4-fs (sda9): mounted filesystem with ordered data mode. Opts: (null)
done.
Begin: Running /scripts/local-bottom … done.
Begin: Running /scripts/init-bottom … done.
[ 11.766811] systemd[1]: System time before build time, advancing clock.
[ 11.792495] ip_tables: © 2000-2006 Netfilter Core Team

Welcome to Debian GNU/Linux buster/sid!

[ OK ] Listening on Journal Socket.
[ OK ] Started Forward Password Requests to Wall Directory Watch.
[ OK ] Started Dispatch Password Requests to Console Directory Watch.
[ OK ] Listening on Journal Audit Socket.
[ OK ] Listening on Syslog Socket.
[ OK ] Listening on /dev/initctl Compatibility Named Pipe.
[ OK ] Reached target Remote File Systems.
[ OK ] Created slice User and Session Slice.
[ OK ] Listening on udev Control Socket.
[ OK ] Reached target Encrypted Volumes.
[ OK ] Listening on udev Kernel Socket.
[ OK ] Created slice System Slice.
[ OK ] Created slice system-getty.slice.
[ OK ] Created slice system-serial\x2dgetty.slice.
Starting Remount Root and Kernel File Systems…
Mounting POSIX Message Queue File System…
Starting Load Kernel Modules…
Mounting Huge Pages File System…
[ OK ] Reached target Slices.
Mounting Debug File System…
Starting Create list of required st��…ce nodes for the current kernel…
[ OK ] Listening on Journal Socket (/dev/log).
Starting Journal Service…
[ OK ] Listening on Network Service Netlink Socket.
[ OK ] Set up automount Arbitrary Executab��…rmats File System Automount Point.
Starting Nameserver information manager…
Starting Set the console keyboard layout…
[ OK ] Reached target Swap.
[ OK ] Mounted Debug File System.
[ OK ] Mounted POSIX Message Queue File System.
[ OK ] Mounted Huge Pages File System.
[ OK ] Started Remount Root and Kernel File Systems.
[ OK ] Started Load Kernel Modules.
[ OK ] Started Create list of required sta��…vice nodes for the current kernel.
[ OK ] Started Nameserver information manager.
Starting Create Static Device Nodes in /dev…
Starting Apply Kernel Variables…
Mounting Configuration File System…
Starting Load/Save Random Seed…
Starting udev Coldplug all Devices…
[ OK ] Mounted Configuration File System.
[ OK ] Started Journal Service.
[ OK ] Started Apply Kernel Variables.
[ OK ] Started Create Static Device Nodes in /dev.
[ OK ] Started Load/Save Random Seed.
Starting udev Kernel Device Manager…
Starting Flush Journal to Persistent Storage…
[ 12.281831] systemd-journald[1643]: Received request to flush runtime journal from PID 1
[ OK ] Started Flush Journal to Persistent Storage.
[ OK ] Started Set the console keyboard layout.
[ OK ] Reached target Local File Systems (Pre).
[ OK ] Reached target Local File Systems.
Starting Set console font and keymap…
Starting Raise network interfaces…
Starting Create Volatile Files and Directories…
[ OK ] Started udev Kernel Device Manager.
[ OK ] Started Set console font and keymap.
[ OK ] Started Create Volatile Files and Directories.
Starting Network Time Synchronization…
Starting Update UTMP about System Boot/Shutdown…
Starting Network Service…
[ OK ] Started Update UTMP about System Boot/Shutdown.
[ OK ] Started Network Service.
[ OK ] Started udev Coldplug all Devices.
[ OK ] Started Network Time Synchronization.
[ OK ] Reached target System Initialization.
[ OK ] Listening on ACPID Listen Socket.
[ OK ] Listening on OpenBSD Secure Shell server socket.
[ OK ] Listening on D-Bus System Message Bus Socket.
[ OK ] Reached target Sockets.
[ OK ] Started ACPI Events Check.
[ OK ] Reached target Paths.
[ OK ] Started Daily Cleanup of Temporary Directories.
[ OK ] Reached target Basic System.
[ OK ] Started Regular background program processing daemon.
Starting DUN service…
Starting RealtimeKit Scheduling Policy Service…
Starting LSB: Load kernel modules needed to enable cpufreq scaling…
Starting System Logging Service…
Starting Initialize hardware monitoring sensors…
Starting Login Service…
Starting Modem Manager…
Starting Start the WCN core…
[ OK ] Started ACPI event daemon.
Starting Restore /etc/resolv.conf i��…fore the ppp link was shut down…
[ 12.943622] iommu: Adding device c00000.video-codec to group 2
Starting Provide limited super user privileges to specific users…
Starting Telephony service…
[ 12.978493] qcom-venus c00000.video-codec: Linked as a consumer to d40000.arm,smmu-venus
[ 12.988658] Failed to set up IOMMU for device c00000.video-codec:firmware; retaining platform DMA ops
[ 12.993055] c00000.video-codec:firmware: assigned reserved memory node venus@90400000
[ OK ] Started D-Bus System Message Bus.
[ 13.138516] Bluetooth: Core ver 2.22
[ 13.143249] NET: Registered protocol family 31
[ 13.147020] Bluetooth: HCI device and connection manager initialized
[ 13.156257] Bluetooth: HCI socket layer initialized
[ OK ] Started RealtimeKit Scheduling Policy Servic[ 13.160050] Bluetooth: L2CAP socket layer initialized
e.
[ 13.166051] ath10k_pci 0000:01:00.0: enabling device (0000 -> 0002)
[ 13.166701] ath10k_pci 0000:01:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0
[ 13.182147] Bluetooth: SCO socket layer initialized
[ OK ] Started Telephony service.

Format: Log Type - Time(microsec) - Message - Optional Info
Log Type: B - Since Boot(Power On Reset), D - Delta, S - Statistic
S - QC_IMAGE_VERSION_STRING=BOOT.XF.1.0-00301
S - IMAGE_VARIANT_STRING=M8996LAB
S - OEM_IMAGE_VERSION_STRING=crm-ubuntu68
S - Boot Interface: UFS
S - Secure Boot: Off
S - Boot Config @ 0x00076044 = 0x000001c9
S - JTAG ID @ 0x000760f4 = 0x4003e0e1
S - OEM ID @ 0x000760f8 = 0x00000000
S - Serial Number @ 0x00074138 = 0xf387dff9
S - OEM Config Row 0 @ 0x00074188 = 0x0000000000000000
S - OEM Config Row 1 @ 0x00074190 = 0x0000000000000000
S - Feature Config Row 0 @ 0x000741a0 = 0x0050000010000100
S - Feature Config Row 1 @ 0x000741a8 = 0x00fff00001ffffff
S - Core 0 Frequency, 1228 MHz
B - 0 - PBL, Start
B - 10405 - bootable_media_detect_entry, Start
B - 51163 - bootable_media_detect_success, Start
B - 51166 - elf_loader_entry, Start
B - 53328 - auth_hash_seg_entry, Start
B - 53429 - auth_hash_seg_exit, Start
B - 90033 - elf_segs_hash_verify_entry, Start
B - 92535 - PBL, End
B - 94489 - SBL1, Start
B - 190350 - usb: hs_phy_nondrive_start
B - 190716 - usb: PLL lock success - 0x3
B - 193675 - usb: hs_phy_nondrive_finish
B - 197823 - boot_flash_init, Start
D - 30 - boot_flash_init, Delta
B - 204899 - sbl1_ddr_set_default_params, Start
D - 0 - sbl1_ddr_set_default_params, Delta
B - 212890 - boot_config_data_table_init, Start
D - 212920 - boot_config_data_table_init, Delta - (60 Bytes)
B - 430294 - CDT Version:3,Platform ID:24,Major ID:1,Minor ID:0,Subtype:0
B - 434960 - Image Load, Start
D - 23394 - PMIC Image Loaded, Delta - (37272 Bytes)
B - 458354 - pm_device_init, Start
B - 464118 - PON REASON:PM0:0x20060 PM1:0x20020
B - 500413 - PM_SET_VAL:Skip
D - 39894 - pm_device_init, Delta
B - 502335 - pm_driver_init, Start
D - 2897 - pm_driver_init, Delta
B - 508923 - pm_sbl_chg_init, Start
D - 91 - pm_sbl_chg_init, Delta
B - 515694 - vsense_init, Start
D - 30 - vsense_init, Delta
B - 523624 - Pre_DDR_clock_init, Start
D - 396 - Pre_DDR_clock_init, Delta
B - 529297 - ddr_initialize_device, Start
B - 532987 - 8996 v3.x detected, Max frequency = 1.8 GHz
B - 540582 - ddr_initialize_device, Delta
B - 542595 - Basic DDR tests done
B - 2103554 - clock_init, Start
D - 244 - clock_init, Delta
B - 2106147 - Image Load, Start
D - 6649 - QSEE Dev Config Image Loaded, Delta - (46008 Bytes)
B - 2113985 - Image Load, Start
D - 3843 - APDP Image Loaded, Delta - (0 Bytes)
B - 2142015 - usb: fedl, vbus_low
B - 2142076 - Image Load, Start
D - 16470 - XBLRamDump Image Loaded, Delta - (342782 Bytes)
B - 2213141 - usb: init start
B - 2214940 - usb: PLL lock success , 0x2
B - 2225432 - usb: SUPER , 0x900e


#10

hi,

i am able to sink audio/ video, but didn’t get audio at jack even doing the following setting

tinymix set ‘SLIMBUS_0_RX Audio Mixer MultiMedia1’ 1
tinymix set ‘SLIM RX0 MUX’ AIF_MIX1_PB
tinymix set ‘RX INT1_2 MUX’ RX0

can help??