bcm27xx: add support for linux v5.15
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0199-media-uapi-hevc-Add-scaling-matrix-control.patch
1 From 49bdb5120b45a6c92e6f10d1d2db85f9d88ba1e3 Mon Sep 17 00:00:00 2001
2 From: Jernej Skrabec <jernej.skrabec@siol.net>
3 Date: Fri, 13 Dec 2019 17:04:25 +0100
4 Subject: [PATCH] media: uapi: hevc: Add scaling matrix control
5
6 Taken from https://patchwork.linuxtv.org/patch/60728/
7 Changes (mainly documentation) have been requested.
8
9 HEVC has a scaling matrix concept. Add support for it.
10
11 Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
12 ---
13 .../media/v4l/ext-ctrls-codec.rst | 41 +++++++++++++++++++
14 .../media/v4l/pixfmt-compressed.rst | 5 ++-
15 drivers/media/v4l2-core/v4l2-ctrls.c | 10 +++++
16 include/media/hevc-ctrls.h | 11 +++++
17 4 files changed, 65 insertions(+), 2 deletions(-)
18
19 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
20 +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
21 @@ -3181,6 +3181,47 @@ enum v4l2_mpeg_video_hevc_size_of_length
22
23 \normalsize
24
25 +``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (struct)``
26 + Specifies the scaling matrix (as extracted from the bitstream) for
27 + the associated HEVC slice data. The bitstream parameters are
28 + defined according to :ref:`hevc`, section 7.4.5 "Scaling list
29 + data semantics". For further documentation, refer to the above
30 + specification, unless there is an explicit comment stating
31 + otherwise.
32 +
33 + .. note::
34 +
35 + This compound control is not yet part of the public kernel API and
36 + it is expected to change.
37 +
38 +.. c:type:: v4l2_ctrl_hevc_scaling_matrix
39 +
40 +.. cssclass:: longtable
41 +
42 +.. flat-table:: struct v4l2_ctrl_hevc_scaling_matrix
43 + :header-rows: 0
44 + :stub-columns: 0
45 + :widths: 1 1 2
46 +
47 + * - __u8
48 + - ``scaling_list_4x4[6][16]``
49 + -
50 + * - __u8
51 + - ``scaling_list_8x8[6][64]``
52 + -
53 + * - __u8
54 + - ``scaling_list_16x16[6][64]``
55 + -
56 + * - __u8
57 + - ``scaling_list_32x32[2][64]``
58 + -
59 + * - __u8
60 + - ``scaling_list_dc_coef_16x16[6]``
61 + -
62 + * - __u8
63 + - ``scaling_list_dc_coef_32x32[2]``
64 + -
65 +
66 ``V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (enum)``
67 Specifies the decoding mode to use. Currently exposes slice-based and
68 frame-based decoding but new modes might be added later on.
69 --- a/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
70 +++ b/Documentation/userspace-api/media/v4l/pixfmt-compressed.rst
71 @@ -195,8 +195,9 @@ Compressed Formats
72 Metadata associated with the frame to decode is required to be passed
73 through the following controls:
74 ``V4L2_CID_MPEG_VIDEO_HEVC_SPS``,
75 - ``V4L2_CID_MPEG_VIDEO_HEVC_PPS``, and
76 - ``V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS``.
77 + ``V4L2_CID_MPEG_VIDEO_HEVC_PPS``,
78 + ``V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS``, and
79 + ``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX``.
80 See the :ref:`associated Codec Control IDs <v4l2-mpeg-hevc>`.
81 Buffers associated with this pixel format must contain the appropriate
82 number of macroblocks to decode a full corresponding frame.
83 --- a/drivers/media/v4l2-core/v4l2-ctrls.c
84 +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
85 @@ -1042,6 +1042,7 @@ const char *v4l2_ctrl_get_name(u32 id)
86 case V4L2_CID_MPEG_VIDEO_HEVC_SPS: return "HEVC Sequence Parameter Set";
87 case V4L2_CID_MPEG_VIDEO_HEVC_PPS: return "HEVC Picture Parameter Set";
88 case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS: return "HEVC Slice Parameters";
89 + case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX: return "HEVC Scaling Matrix";
90 case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE: return "HEVC Decode Mode";
91 case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE: return "HEVC Start Code";
92
93 @@ -1527,6 +1528,9 @@ void v4l2_ctrl_fill(u32 id, const char *
94 case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
95 *type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
96 break;
97 + case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX:
98 + *type = V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX;
99 + break;
100 case V4L2_CID_UNIT_CELL_SIZE:
101 *type = V4L2_CTRL_TYPE_AREA;
102 *flags |= V4L2_CTRL_FLAG_READ_ONLY;
103 @@ -2238,6 +2242,9 @@ static int std_validate_compound(const s
104
105 break;
106
107 + case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
108 + break;
109 +
110 case V4L2_CTRL_TYPE_AREA:
111 area = p;
112 if (!area->width || !area->height)
113 @@ -2954,6 +2961,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(s
114 case V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:
115 elem_size = sizeof(struct v4l2_ctrl_hdr10_mastering_display);
116 break;
117 + case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
118 + elem_size = sizeof(struct v4l2_ctrl_hevc_scaling_matrix);
119 + break;
120 case V4L2_CTRL_TYPE_AREA:
121 elem_size = sizeof(struct v4l2_area);
122 break;
123 --- a/include/media/hevc-ctrls.h
124 +++ b/include/media/hevc-ctrls.h
125 @@ -19,6 +19,7 @@
126 #define V4L2_CID_MPEG_VIDEO_HEVC_SPS (V4L2_CID_CODEC_BASE + 1008)
127 #define V4L2_CID_MPEG_VIDEO_HEVC_PPS (V4L2_CID_CODEC_BASE + 1009)
128 #define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS (V4L2_CID_CODEC_BASE + 1010)
129 +#define V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (V4L2_CID_CODEC_BASE + 1011)
130 #define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS (V4L2_CID_CODEC_BASE + 1012)
131 #define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (V4L2_CID_CODEC_BASE + 1015)
132 #define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE (V4L2_CID_CODEC_BASE + 1016)
133 @@ -27,6 +28,7 @@
134 #define V4L2_CTRL_TYPE_HEVC_SPS 0x0120
135 #define V4L2_CTRL_TYPE_HEVC_PPS 0x0121
136 #define V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS 0x0122
137 +#define V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX 0x0123
138 #define V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS 0x0124
139
140 enum v4l2_mpeg_video_hevc_decode_mode {
141 @@ -238,4 +240,13 @@ struct v4l2_ctrl_hevc_decode_params {
142 */
143 #define V4L2_CID_HANTRO_HEVC_SLICE_HEADER_SKIP (V4L2_CID_CODEC_HANTRO_BASE + 0)
144
145 +struct v4l2_ctrl_hevc_scaling_matrix {
146 + __u8 scaling_list_4x4[6][16];
147 + __u8 scaling_list_8x8[6][64];
148 + __u8 scaling_list_16x16[6][64];
149 + __u8 scaling_list_32x32[2][64];
150 + __u8 scaling_list_dc_coef_16x16[6];
151 + __u8 scaling_list_dc_coef_32x32[2];
152 +};
153 +
154 #endif