Extend backend to populate V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS / _LT_RPS for VDPU381 HEVC (RK3588) #3
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Extend backend to populate V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS / _LT_RPS for VDPU381 HEVC
Context
Linux 7.0 (Detlev Casanova / Collabora v8 series,
lkml.org/lkml/2026/1/9/1334) landed RK3588/RK3576 HEVC support and introduced two new V4L2 stateless HEVC controls:V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS— short-term reference picture set parametersV4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS— long-term reference picture set parametersThe struct definitions (
include/uapi/linux/v4l2-controls.h):(LT_RPS has its own struct shape; not pasted here but defined in the same header.)
The backend (
marfrit/libva-v4l2-request-fourier @ 7ac934e, the iter38b that fresnel certified) does not know about these controls — they were added to the kernel UAPI after the backend's iter38 close. Searching the backend source confirms zero hits.Symptom on ampere (RK3588)
ampere-fourieriter1 Phase 0 captured a reproducible kernel OOPS on the first HEVC decode attempt:Originally filed against
marfrit/kernel-agent#11as a kernel bug; reclassified after the ampere-kernel-decoders iter1 prior-art survey.Verified mechanism (reading the kernel source at
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c:500-509+:380-410): ifctx->has_sps_st_rpsis set (VDPU381 variant_ops sets it), the kernel callsv4l2_ctrl_findfor the new CID. With the control unset by userspace, the kernel may auto-allocate it with non-NULL but uninitializedp_cur.p. The early-returnif (!run->ext_sps_st_rps) return;doesn't fire, and the subsequentmemcmp(cache, run->ext_sps_st_rps, sizeof(struct))faults in__pi_memcmp.What the backend needs to do
VAPictureParameterBufferHEVCdoes carry equivalent fields, so this is a translation problem, not a new-bitstream-parsing problem.struct v4l2_ctrl_hevc_ext_sps_st_rps[num_short_term_ref_pic_sets](up to 65 entries), populate from VAAPI fields, set viaVIDIOC_S_EXT_CTRLSusingV4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS. Same for LT_RPS with the long-term equivalent.S_EXT_CTRLS. Per memoryfeedback_per_driver_kludge_gating, the gate goes ondriver_data->driver_kind.VIDIOC_QUERYCTRLat init.Prerequisite: bump
linux-api-headerson the test hostampere is currently on
linux-api-headers 6.19-1which doesn't define the constants. Either:hevc-ctrls/for similar shims pre-merger).Recommend the latter for now — same precedent as fresnel-fourier iter25 (
rkvdec image_fmt pre-seed) where the backend shipped its own UAPI shim until the kernel side stabilized.Acceptance
LIBVA_DRIVER_NAME=v4l2_request ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -i bbb_60s_720p.hevc.mp4 -vf hwdownload -f null -on ampere completes without kernel OOPS, ideally producing a byte-correct NV12 frame stream. Re-run ampere-fourier Phase 3 with HEVC added and validate against the C1-C6 criteria.Risk: mechanism reconstruction may be incomplete
The "non-NULL uninitialized
p_cur.p" path is my best read of the kernel source, but it isn't yet test-verified. If a minimal backend patch that just registers the new CIDs (even with all-zero or dummy data) leaves the OOPS in place, the actual root cause is something else and we re-openkernel-agent#11.Refs
lkml.org/lkml/2026/1/9/1334collabora.com/news-and-blog/news-and-events/from-panthor-to-rk3588-advancing-graphics-video-soc-support-linux-kernel-7.html~/src/ampere-kernel-decoders/phase0_findings.mdmarfrit/kernel-agent#11marfrit/libva-v4l2-request-fourier @ 7ac934e@claude-noether what sources actually use HVEC typically? I use YouTube and mediathek.ard.de - if they do not use HVEC, HVEC should be outscoped and documented as such for all related projects.
Triage 2026-05-18 + answering @marfrit's scoping question.
What actually uses HEVC
For the workloads you named:
ffprobeagainst a 4K ARD show if you care, but the default H.264 path covers the bulk.youtube-dlof Twitch/YouTube content for offlineNet: for the YouTube + Mediathek combination, HEVC on ampere has near-zero practical use today. AV1 (kernel-agent#12's sibling thread for libva-v4l2-request-fourier#2) would actually move the needle for YouTube. VP9 is the highest-volume codec for that workload.
For HEVC specifically, fresnel (RK3399) covers it cleanly — rkvdec via libva-v4l2-request-fourier iter38/iter39 produces bit-exact HEVC HW==SW including 10-bit Main10 (verified today during marfrit-packages#21 fix). If you want to decode an HEVC local file, do it on fresnel; ampere doesn't add anything for HEVC.
Implication for this issue cluster
Three currently-open HEVC-on-ampere items:
If HEVC on ampere is out of scope for the fleet, all three can close as
won't fix — HEVC handled by fresnel; ampere's HEVC silicon stays uninitialized. The libva backend already routes HEVC profiles correctly today (per the iter38 multi-device probe), so droppingVAProfileHEVC*from ampere's vainfo just means consumers fall back to SW or use fresnel.If HEVC on ampere is in scope (e.g. you do have local 4K HEVC files you want to play on ampere because of its bigger screen / battery), keep all three open and the priority is:
Recommendation
Out-of-scope HEVC on ampere unless you can point at a concrete HEVC source in your workflow. The decision update to apply if you go that way (I can do this for you if you confirm):
feedback_codec_scope_per_host.md(or extend an existing project doc) so future triage doesn't re-litigate.Confirm with a 👍 / "go" / "scope out HEVC on ampere" and I'll execute the closures + memory update. If you want to keep HEVC alive for now, comment back and I'll leave all three open as-is.
EWONTFIX 2026-05-18.
HEVC on ampere (RK3588) is scoped out indefinitely. Joint decision covering this issue plus kernel-agent#14 (kernel stack-uninit OOPS), kernel-agent#15 (HEVC_SLICE_PARAMS registration), and libva-v4l2-request-fourier#3 (libva backend EXT_SPS_*_RPS submission).
Rationale
daedalus-fourierREADME's "YouTube ∩ Pi5-HW = ∅" framing) — HEVC on ampere doesn't move that needle.Reopen criteria
Reopen any of the three if a concrete HEVC workflow emerges on ampere (4K local file collection, HEVC-encoded archive that doesn't fit on fresnel, specific app that requires HEVC and runs only on ampere). The kernel side fix in #14 + #15 is closed-form (one-liner each); the libva side in #3 is straightforward bitstream-translation work. None of the analysis is lost; it's all archived in the closed issues' bodies + comments.
Closing.