bcm27xx-gpu-fw: update to latest version
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0506-media-uapi-hevc-Add-scaling-matrix-control.patch
1 From 70b5a28786215c996503210abd3e44c200771640 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/uapi/v4l/ext-ctrls-codec.rst | 41 +++++++++++++++++++
14 .../media/uapi/v4l/pixfmt-compressed.rst | 1 +
15 drivers/media/v4l2-core/v4l2-ctrls.c | 10 +++++
16 include/media/hevc-ctrls.h | 11 +++++
17 4 files changed, 63 insertions(+)
18
19 --- a/Documentation/media/uapi/v4l/ext-ctrls-codec.rst
20 +++ b/Documentation/media/uapi/v4l/ext-ctrls-codec.rst
21 @@ -4174,6 +4174,47 @@ enum v4l2_mpeg_video_hevc_size_of_length
22 - ``padding[6]``
23 - Applications and drivers must set this to zero.
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/media/uapi/v4l/pixfmt-compressed.rst
70 +++ b/Documentation/media/uapi/v4l/pixfmt-compressed.rst
71 @@ -203,6 +203,7 @@ Compressed Formats
72 * ``V4L2_CID_MPEG_VIDEO_HEVC_SPS``
73 * ``V4L2_CID_MPEG_VIDEO_HEVC_PPS``
74 * ``V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS``
75 + * ``V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX``
76 See the :ref:`associated Codec Control IDs <v4l2-mpeg-hevc>`.
77 Buffers associated with this pixel format must contain the appropriate
78 number of macroblocks to decode a full corresponding frame.
79 --- a/drivers/media/v4l2-core/v4l2-ctrls.c
80 +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
81 @@ -974,6 +974,7 @@ const char *v4l2_ctrl_get_name(u32 id)
82 case V4L2_CID_MPEG_VIDEO_HEVC_SPS: return "HEVC Sequence Parameter Set";
83 case V4L2_CID_MPEG_VIDEO_HEVC_PPS: return "HEVC Picture Parameter Set";
84 case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS: return "HEVC Slice Parameters";
85 + case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX: return "HEVC Scaling Matrix";
86 case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE: return "HEVC Decode Mode";
87 case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE: return "HEVC Start Code";
88
89 @@ -1406,6 +1407,9 @@ void v4l2_ctrl_fill(u32 id, const char *
90 case V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS:
91 *type = V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS;
92 break;
93 + case V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX:
94 + *type = V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX;
95 + break;
96 case V4L2_CID_UNIT_CELL_SIZE:
97 *type = V4L2_CTRL_TYPE_AREA;
98 *flags |= V4L2_CTRL_FLAG_READ_ONLY;
99 @@ -1852,6 +1856,9 @@ static int std_validate_compound(const s
100 zero_padding(*p_hevc_slice_params);
101 break;
102
103 + case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
104 + break;
105 +
106 case V4L2_CTRL_TYPE_AREA:
107 area = p;
108 if (!area->width || !area->height)
109 @@ -2540,6 +2547,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(s
110 case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
111 elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
112 break;
113 + case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
114 + elem_size = sizeof(struct v4l2_ctrl_hevc_scaling_matrix);
115 + break;
116 case V4L2_CTRL_TYPE_AREA:
117 elem_size = sizeof(struct v4l2_area);
118 break;
119 --- a/include/media/hevc-ctrls.h
120 +++ b/include/media/hevc-ctrls.h
121 @@ -19,6 +19,7 @@
122 #define V4L2_CID_MPEG_VIDEO_HEVC_SPS (V4L2_CID_MPEG_BASE + 1008)
123 #define V4L2_CID_MPEG_VIDEO_HEVC_PPS (V4L2_CID_MPEG_BASE + 1009)
124 #define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS (V4L2_CID_MPEG_BASE + 1010)
125 +#define V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (V4L2_CID_MPEG_BASE + 1011)
126 #define V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE (V4L2_CID_MPEG_BASE + 1015)
127 #define V4L2_CID_MPEG_VIDEO_HEVC_START_CODE (V4L2_CID_MPEG_BASE + 1016)
128
129 @@ -26,6 +27,7 @@
130 #define V4L2_CTRL_TYPE_HEVC_SPS 0x0120
131 #define V4L2_CTRL_TYPE_HEVC_PPS 0x0121
132 #define V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS 0x0122
133 +#define V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX 0x0123
134
135 enum v4l2_mpeg_video_hevc_decode_mode {
136 V4L2_MPEG_VIDEO_HEVC_DECODE_MODE_SLICE_BASED,
137 @@ -209,4 +211,13 @@ struct v4l2_ctrl_hevc_slice_params {
138 __u64 flags;
139 };
140
141 +struct v4l2_ctrl_hevc_scaling_matrix {
142 + __u8 scaling_list_4x4[6][16];
143 + __u8 scaling_list_8x8[6][64];
144 + __u8 scaling_list_16x16[6][64];
145 + __u8 scaling_list_32x32[2][64];
146 + __u8 scaling_list_dc_coef_16x16[6];
147 + __u8 scaling_list_dc_coef_32x32[2];
148 +};
149 +
150 #endif