* [PATCH 0/3] staging: media: cedrus: add VP9 decoding for H616
@ 2026-11-27 6:55 Jernej Skrabec
2026-11-27 6:55 ` [PATCH 1/3] staging: media: cedrus: take the output line stride from the capture format Jernej Skrabec
2026-11-27 6:55 ` [PATCH 2/3] staging: media: cedrus: factor out the format check Jernej Skrabec
0 siblings, 2 replies; 3+ messages in thread
From: Jernej Skrabec @ 2026-11-27 6:55 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Hans Verkuil
Cc: Maxime Ripard, Paul Kocialkowski, Greg Kroah-Hartman,
Chen-Yu Tsai, Samuel Holland, Nicolas Dufresne, linux-media,
linux-staging, linux-arm-kernel, linux-sunxi, linux-kernel,
Jernej Skrabec
This series adds VP9 decoding to the Cedrus driver for the H616 video
engine, which runs VP9 in its H.265 engine.
The backward probability adaptation is done in the driver with the
v4l2 VP9 helpers, using the symbol counts the hardware writes back.
Patches 1 and 2 are preparation: the output line stride is taken from
the capture format, and the format check is moved into a helper.
Patch 3 adds VP9 decoding. Like H.265, 10-bit frames are output with 8
bits per sample for now. P010 output for 10-bit VP9 and H.265 will
follow in a separate series. The decoder core is reset after every VP9
frame, as an H.265 picture of another context decoded next fails
otherwise.
The series is based on my Cedrus fixes series [1], which it depends on.
It doesn't depend on any other pending Cedrus work.
Testing
-------
All testing was done on an H616 board (T95 Max, 4 GiB DDR3, VE at
600 MHz) with FFmpeg's v4l2-request hwaccel. Hardware output was
compared per frame with the libvpx MD5 files or with FFmpeg's software
decoder; the other capture formats were compared plane by plane against
NV12 output, using an LD_PRELOAD shim that forces the capture format.
The 10-bit decoding itself was also checked with the P010 output of the
follow-up series, which matches the libvpx MD5 files.
Results:
- libvpx test vectors (303 profile 0, the profile 2 4:2:0 10-bit one):
275 match the libvpx MD5 files frame by frame, the failures are
listed below.
- fluster VP9-TEST-VECTORS: 242/305, the same vectors fail with
FFmpeg's software decoder (FFmpeg rescales frames after a size
change, so the stream MD5 of resized vectors can't match).
VP9-TEST-VECTORS-HIGH: 5/6, the 10-bit 4:2:0 vector fails as its
output has 8 bits per sample, the others are 4:2:2, 4:4:4 or 12-bit
and decoded in software.
- fluster JCT-VC-HEVC_V1 (129/147), JVT-AVC_V1 (130/135),
VP8-TEST-VECTORS (59/61) and MPEG2_VIDEO-MAIN (7/43): same results
as without this series.
- v4l2-compliance: 49 tests, 0 failures, 0 warnings. A test program for
invalid VP9 controls, formats and jobs (57 cases) passes.
- NV21, YU12, YV12 and, for 8-bit, ST12 output of 12 8-bit and 10-bit
VP9 streams (66x66 to 1920x1080) match NV12 output.
- Decoding VP9 and H.265 streams in parallel instances, in 46
combinations with each other and with H.264 and MPEG-2, gives the
same output as decoding them alone. Heavier parallel loads need the
decoder reset before every picture from a follow-up series.
- No IOMMU faults or timeouts in any of the above.
Known failures:
- vp92-2-20-10bit-yuv420: the output has 8 bits per sample.
- resize vectors (vp90-2-21-resize_inter_*, vp90-2-05-resize,
vp90-2-18-resize): FFmpeg reallocates the capture buffers on the
frame size change and then refers to frames of a different size,
which the hardware can't scale with this buffer layout.
- vp90-2-13-largescaling: not supported by the hardware.
- vp90-2-22-svc_1280x720_3: inter-layer prediction from a different
size, for the same reason as the resize vectors. FFmpeg's software
decoder fails it as well.
[1] https://lore.kernel.org/r/20261109175016.42061-1-jernej.skrabec@gmail.com
Please take a look.
Best regards,
Jernej
Jernej Skrabec (3):
staging: media: cedrus: take the output line stride from the capture
format
staging: media: cedrus: factor out the format check
staging: media: cedrus: add VP9 decoding support
drivers/staging/media/sunxi/cedrus/Makefile | 2 +-
drivers/staging/media/sunxi/cedrus/cedrus.c | 53 +-
drivers/staging/media/sunxi/cedrus/cedrus.h | 35 +
.../staging/media/sunxi/cedrus/cedrus_dec.c | 7 +
.../staging/media/sunxi/cedrus/cedrus_hw.c | 28 +-
.../staging/media/sunxi/cedrus/cedrus_hw.h | 1 +
.../staging/media/sunxi/cedrus/cedrus_regs.h | 131 ++
.../staging/media/sunxi/cedrus/cedrus_video.c | 50 +-
.../staging/media/sunxi/cedrus/cedrus_vp9.c | 1253 +++++++++++++++++
9 files changed, 1548 insertions(+), 12 deletions(-)
create mode 100644 drivers/staging/media/sunxi/cedrus/cedrus_vp9.c
base-commit: 27285b099fbc5cb2ae3aef20f3bbd7b3c88b3005
prerequisite-patch-id: 032ac086f7ba6944b648a3581a1c287ee06c42c9
prerequisite-patch-id: 30e6f5a647b929dcf501225d403dc1f68436079f
prerequisite-patch-id: 309f0f4b5228ee3b0d3e3b80426429a67e238d53
prerequisite-patch-id: a448a9c72886221eb9b1aea1778a88e163d96309
prerequisite-patch-id: c49f2932a2258bcf000e0e4907e9636b2958b350
prerequisite-patch-id: 3c5110c4b6f13079a09733b972de4cbf38d3119a
prerequisite-patch-id: 78a7e370ba08a94aaaf4cbce49f89432151a9089
prerequisite-patch-id: f62f865eccdab559e9effea5b002b227fc0e3bbf
prerequisite-patch-id: 9a09dbecbbba3731dd2518606a02e12d58e433a6
prerequisite-patch-id: a952ffa6ed148ba0f6b9f5253848b7c8fb2f89a8
prerequisite-patch-id: 9879769cc1ed540f2739c2bf8b43b42a41c6ad8b
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 1/3] staging: media: cedrus: take the output line stride from the capture format
2026-11-27 6:55 [PATCH 0/3] staging: media: cedrus: add VP9 decoding for H616 Jernej Skrabec
@ 2026-11-27 6:55 ` Jernej Skrabec
2026-11-27 6:55 ` [PATCH 2/3] staging: media: cedrus: factor out the format check Jernej Skrabec
1 sibling, 0 replies; 3+ messages in thread
From: Jernej Skrabec @ 2026-11-27 6:55 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Hans Verkuil
Cc: Maxime Ripard, Paul Kocialkowski, Greg Kroah-Hartman,
Chen-Yu Tsai, Samuel Holland, Nicolas Dufresne, linux-media,
linux-staging, linux-arm-kernel, linux-sunxi, linux-kernel,
Jernej Skrabec
cedrus_dst_format_set() programs the line stride of the untiled output
formats as the width aligned to 16, which is the bytesperline that
cedrus_prepare_format() gives these formats. Program bytesperline
itself instead, so that a decoder can use a larger stride, and so that
the stride is the one of the buffer when a decoder sets the format up
for a frame smaller than it.
Likewise, take the height as it is: cedrus_prepare_format() already
aligns it to 16 for these formats.
No functional change.
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
---
drivers/staging/media/sunxi/cedrus/cedrus_hw.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c
index b66d855daaf8..7e742cbb1cdd 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c
@@ -84,7 +84,7 @@ void cedrus_engine_disable(struct cedrus_dev *dev)
void cedrus_dst_format_set(struct cedrus_dev *dev,
struct v4l2_pix_format *fmt)
{
- unsigned int width = fmt->width;
+ unsigned int bytesperline = fmt->bytesperline;
unsigned int height = fmt->height;
u32 chroma_size;
u32 reg;
@@ -94,7 +94,7 @@ void cedrus_dst_format_set(struct cedrus_dev *dev,
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
- chroma_size = ALIGN(width, 16) * ALIGN(height, 16) / 2;
+ chroma_size = bytesperline * height / 2;
switch (fmt->pixelformat) {
case V4L2_PIX_FMT_NV12:
@@ -116,8 +116,8 @@ void cedrus_dst_format_set(struct cedrus_dev *dev,
reg = chroma_size / 2;
cedrus_write(dev, VE_PRIMARY_CHROMA_BUF_LEN, reg);
- reg = VE_PRIMARY_FB_LINE_STRIDE_LUMA(ALIGN(width, 16)) |
- VE_PRIMARY_FB_LINE_STRIDE_CHROMA(ALIGN(width, 16) / 2);
+ reg = VE_PRIMARY_FB_LINE_STRIDE_LUMA(bytesperline) |
+ VE_PRIMARY_FB_LINE_STRIDE_CHROMA(bytesperline / 2);
cedrus_write(dev, VE_PRIMARY_FB_LINE_STRIDE, reg);
break;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/3] staging: media: cedrus: factor out the format check
2026-11-27 6:55 [PATCH 0/3] staging: media: cedrus: add VP9 decoding for H616 Jernej Skrabec
2026-11-27 6:55 ` [PATCH 1/3] staging: media: cedrus: take the output line stride from the capture format Jernej Skrabec
@ 2026-11-27 6:55 ` Jernej Skrabec
1 sibling, 0 replies; 3+ messages in thread
From: Jernej Skrabec @ 2026-11-27 6:55 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Hans Verkuil
Cc: Maxime Ripard, Paul Kocialkowski, Greg Kroah-Hartman,
Chen-Yu Tsai, Samuel Holland, Nicolas Dufresne, linux-media,
linux-staging, linux-arm-kernel, linux-sunxi, linux-kernel,
Jernej Skrabec
cedrus_find_format() and cedrus_enum_fmt() check the capabilities and
the direction of a format in the same way. Move the check into a
helper, so that the VP9 decoder, added later, can exclude formats in
one place.
No functional change.
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
---
.../staging/media/sunxi/cedrus/cedrus_video.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
index 2521315abdb7..a46820a90d87 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
@@ -78,6 +78,17 @@ static struct cedrus_format cedrus_formats[] = {
#define CEDRUS_FORMATS_COUNT ARRAY_SIZE(cedrus_formats)
+static bool cedrus_check_format(struct cedrus_ctx *ctx,
+ const struct cedrus_format *fmt,
+ u32 directions)
+{
+ if (!cedrus_is_capable(ctx, fmt->capabilities) ||
+ !(fmt->directions & directions))
+ return false;
+
+ return true;
+}
+
static struct cedrus_format *cedrus_find_format(struct cedrus_ctx *ctx,
u32 pixelformat, u32 directions)
{
@@ -88,8 +99,7 @@ static struct cedrus_format *cedrus_find_format(struct cedrus_ctx *ctx,
for (i = 0; i < CEDRUS_FORMATS_COUNT; i++) {
fmt = &cedrus_formats[i];
- if (!cedrus_is_capable(ctx, fmt->capabilities) ||
- !(fmt->directions & directions))
+ if (!cedrus_check_format(ctx, fmt, directions))
continue;
if (fmt->pixelformat == pixelformat)
@@ -191,10 +201,7 @@ static int cedrus_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
index = 0;
for (i = 0; i < CEDRUS_FORMATS_COUNT; i++) {
- if (!cedrus_is_capable(ctx, cedrus_formats[i].capabilities))
- continue;
-
- if (!(cedrus_formats[i].directions & direction))
+ if (!cedrus_check_format(ctx, &cedrus_formats[i], direction))
continue;
if (index == f->index)
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-27 6:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 6:55 [PATCH 0/3] staging: media: cedrus: add VP9 decoding for H616 Jernej Skrabec
2026-11-27 6:55 ` [PATCH 1/3] staging: media: cedrus: take the output line stride from the capture format Jernej Skrabec
2026-11-27 6:55 ` [PATCH 2/3] staging: media: cedrus: factor out the format check Jernej Skrabec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox