1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
From b57fbbe50c9b2656fad86a1a7eeabfd2b2a50935 Mon Sep 17 00:00:00 2001
From: Jonas Karlman <jonas@kwiboo.se>
Date: Sun, 14 Dec 2025 01:14:17 +0000
Subject: [PATCH 13/13] avutil/hwcontext_v4l2request: Add support for
BROADCOM_SAND128 pix fmts
Add support for NV12_COL128 and NV12_10_COL128 used by downstream
Raspberry Pi HEVC decoder.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
libavutil/hwcontext_v4l2request.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
--- a/libavutil/hwcontext_v4l2request.c
+++ b/libavutil/hwcontext_v4l2request.c
@@ -107,6 +107,12 @@ static const struct {
.bit_depth = 10,
},
#endif
+#if defined(V4L2_PIX_FMT_NV12_COL128) && defined(V4L2_PIX_FMT_NV12_10_COL128)
+ { V4L2_PIX_FMT_NV12_COL128, AV_PIX_FMT_YUV420P, DRM_FORMAT_NV12, DRM_FORMAT_MOD_BROADCOM_SAND128, 8 },
+#if defined(DRM_FORMAT_P030)
+ { V4L2_PIX_FMT_NV12_10_COL128, AV_PIX_FMT_YUV420P10, DRM_FORMAT_P030, DRM_FORMAT_MOD_BROADCOM_SAND128, 10 },
+#endif
+#endif
};
static int v4l2request_set_drm_descriptor(AVDRMFrameDescriptor *desc,
@@ -169,6 +175,25 @@ static int v4l2request_set_drm_descripto
}
#endif
+#if defined(V4L2_PIX_FMT_NV12_COL128) && defined(V4L2_PIX_FMT_NV12_10_COL128)
+ // Raspberry Pi formats need special handling
+ if (pixelformat == V4L2_PIX_FMT_NV12_COL128 ||
+ pixelformat == V4L2_PIX_FMT_NV12_10_COL128) {
+ desc->objects[0].format_modifier =
+ DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(layer->planes[0].pitch);
+ layer->planes[1].offset = 128 *
+ (V4L2_TYPE_IS_MULTIPLANAR(format->type) ?
+ format->fmt.pix_mp.height :
+ format->fmt.pix.height);
+ layer->planes[0].pitch = (V4L2_TYPE_IS_MULTIPLANAR(format->type) ?
+ format->fmt.pix_mp.width :
+ format->fmt.pix.width);
+ if (pixelformat == V4L2_PIX_FMT_NV12_10_COL128)
+ layer->planes[0].pitch *= 2;
+ layer->planes[1].pitch = layer->planes[0].pitch;
+ }
+#endif
+
return 0;
}
|