Skip to content

Commit 9514063

Browse files
Hans Verkuilmchehab
authored andcommitted
media: mpeg2-ctrls.h: move MPEG2 state controls to non-public header
The MPEG2 state controls for the cedrus stateless MPEG2 driver are not yet stable. Move them out of the public headers into media/mpeg2-ctrls.h. Eventually, once this has stabilized, they will be moved back to the public headers. Unfortunately I had to cast the control type to a u32 in two switch statements to prevent a compiler warning about a control type define not being part of the enum. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
1 parent daa3fc4 commit 9514063

File tree

5 files changed

+94
-74
lines changed

5 files changed

+94
-74
lines changed

drivers/media/v4l2-core/v4l2-ctrls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
15631563
u64 offset;
15641564
s64 val;
15651565

1566-
switch (ctrl->type) {
1566+
switch ((u32)ctrl->type) {
15671567
case V4L2_CTRL_TYPE_INTEGER:
15681568
return ROUND_TO_RANGE(ptr.p_s32[idx], u32, ctrl);
15691569
case V4L2_CTRL_TYPE_INTEGER64:
@@ -2232,7 +2232,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
22322232
is_array = nr_of_dims > 0;
22332233

22342234
/* Prefill elem_size for all types handled by std_type_ops */
2235-
switch (type) {
2235+
switch ((u32)type) {
22362236
case V4L2_CTRL_TYPE_INTEGER64:
22372237
elem_size = sizeof(s64);
22382238
break;

include/media/mpeg2-ctrls.h

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* These are the MPEG2 state controls for use with stateless MPEG-2
4+
* codec drivers.
5+
*
6+
* It turns out that these structs are not stable yet and will undergo
7+
* more changes. So keep them private until they are stable and ready to
8+
* become part of the official public API.
9+
*/
10+
11+
#ifndef _MPEG2_CTRLS_H_
12+
#define _MPEG2_CTRLS_H_
13+
14+
#define V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (V4L2_CID_MPEG_BASE+250)
15+
#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_MPEG_BASE+251)
16+
17+
/* enum v4l2_ctrl_type type values */
18+
#define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0103
19+
#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0104
20+
21+
#define V4L2_MPEG2_PICTURE_CODING_TYPE_I 1
22+
#define V4L2_MPEG2_PICTURE_CODING_TYPE_P 2
23+
#define V4L2_MPEG2_PICTURE_CODING_TYPE_B 3
24+
#define V4L2_MPEG2_PICTURE_CODING_TYPE_D 4
25+
26+
struct v4l2_mpeg2_sequence {
27+
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence header */
28+
__u16 horizontal_size;
29+
__u16 vertical_size;
30+
__u32 vbv_buffer_size;
31+
32+
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */
33+
__u8 profile_and_level_indication;
34+
__u8 progressive_sequence;
35+
__u8 chroma_format;
36+
__u8 pad;
37+
};
38+
39+
struct v4l2_mpeg2_picture {
40+
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture header */
41+
__u8 picture_coding_type;
42+
43+
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture coding extension */
44+
__u8 f_code[2][2];
45+
__u8 intra_dc_precision;
46+
__u8 picture_structure;
47+
__u8 top_field_first;
48+
__u8 frame_pred_frame_dct;
49+
__u8 concealment_motion_vectors;
50+
__u8 q_scale_type;
51+
__u8 intra_vlc_format;
52+
__u8 alternate_scan;
53+
__u8 repeat_first_field;
54+
__u8 progressive_frame;
55+
__u8 pad;
56+
};
57+
58+
struct v4l2_ctrl_mpeg2_slice_params {
59+
__u32 bit_size;
60+
__u32 data_bit_offset;
61+
62+
struct v4l2_mpeg2_sequence sequence;
63+
struct v4l2_mpeg2_picture picture;
64+
65+
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Slice */
66+
__u8 quantiser_scale_code;
67+
68+
__u8 backward_ref_index;
69+
__u8 forward_ref_index;
70+
__u8 pad;
71+
};
72+
73+
struct v4l2_ctrl_mpeg2_quantization {
74+
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Quant matrix extension */
75+
__u8 load_intra_quantiser_matrix;
76+
__u8 load_non_intra_quantiser_matrix;
77+
__u8 load_chroma_intra_quantiser_matrix;
78+
__u8 load_chroma_non_intra_quantiser_matrix;
79+
80+
__u8 intra_quantiser_matrix[64];
81+
__u8 non_intra_quantiser_matrix[64];
82+
__u8 chroma_intra_quantiser_matrix[64];
83+
__u8 chroma_non_intra_quantiser_matrix[64];
84+
};
85+
86+
#endif

include/media/v4l2-ctrls.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
#include <linux/videodev2.h>
2323
#include <media/media-request.h>
2424

25+
/*
26+
* Include the mpeg2 stateless codec compound control definitions.
27+
* This will move to the public headers once this API is fully stable.
28+
*/
29+
#include <media/mpeg2-ctrls.h>
30+
2531
/* forward references */
2632
struct file;
2733
struct v4l2_ctrl_handler;

include/uapi/linux/v4l2-controls.h

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,6 @@ enum v4l2_mpeg_video_multi_slice_mode {
404404
#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_MPEG_BASE+228)
405405
#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_MPEG_BASE+229)
406406

407-
#define V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (V4L2_CID_MPEG_BASE+250)
408-
#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_MPEG_BASE+251)
409-
410407
#define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (V4L2_CID_MPEG_BASE+300)
411408
#define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_CID_MPEG_BASE+301)
412409
#define V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP (V4L2_CID_MPEG_BASE+302)
@@ -1097,69 +1094,4 @@ enum v4l2_detect_md_mode {
10971094
#define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3)
10981095
#define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4)
10991096

1100-
#define V4L2_MPEG2_PICTURE_CODING_TYPE_I 1
1101-
#define V4L2_MPEG2_PICTURE_CODING_TYPE_P 2
1102-
#define V4L2_MPEG2_PICTURE_CODING_TYPE_B 3
1103-
#define V4L2_MPEG2_PICTURE_CODING_TYPE_D 4
1104-
1105-
struct v4l2_mpeg2_sequence {
1106-
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence header */
1107-
__u16 horizontal_size;
1108-
__u16 vertical_size;
1109-
__u32 vbv_buffer_size;
1110-
1111-
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */
1112-
__u8 profile_and_level_indication;
1113-
__u8 progressive_sequence;
1114-
__u8 chroma_format;
1115-
__u8 pad;
1116-
};
1117-
1118-
struct v4l2_mpeg2_picture {
1119-
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture header */
1120-
__u8 picture_coding_type;
1121-
1122-
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture coding extension */
1123-
__u8 f_code[2][2];
1124-
__u8 intra_dc_precision;
1125-
__u8 picture_structure;
1126-
__u8 top_field_first;
1127-
__u8 frame_pred_frame_dct;
1128-
__u8 concealment_motion_vectors;
1129-
__u8 q_scale_type;
1130-
__u8 intra_vlc_format;
1131-
__u8 alternate_scan;
1132-
__u8 repeat_first_field;
1133-
__u8 progressive_frame;
1134-
__u8 pad;
1135-
};
1136-
1137-
struct v4l2_ctrl_mpeg2_slice_params {
1138-
__u32 bit_size;
1139-
__u32 data_bit_offset;
1140-
1141-
struct v4l2_mpeg2_sequence sequence;
1142-
struct v4l2_mpeg2_picture picture;
1143-
1144-
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Slice */
1145-
__u8 quantiser_scale_code;
1146-
1147-
__u8 backward_ref_index;
1148-
__u8 forward_ref_index;
1149-
__u8 pad;
1150-
};
1151-
1152-
struct v4l2_ctrl_mpeg2_quantization {
1153-
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Quant matrix extension */
1154-
__u8 load_intra_quantiser_matrix;
1155-
__u8 load_non_intra_quantiser_matrix;
1156-
__u8 load_chroma_intra_quantiser_matrix;
1157-
__u8 load_chroma_non_intra_quantiser_matrix;
1158-
1159-
__u8 intra_quantiser_matrix[64];
1160-
__u8 non_intra_quantiser_matrix[64];
1161-
__u8 chroma_intra_quantiser_matrix[64];
1162-
__u8 chroma_non_intra_quantiser_matrix[64];
1163-
};
1164-
11651097
#endif

include/uapi/linux/videodev2.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,8 +1622,6 @@ struct v4l2_ext_control {
16221622
__u8 __user *p_u8;
16231623
__u16 __user *p_u16;
16241624
__u32 __user *p_u32;
1625-
struct v4l2_ctrl_mpeg2_slice_params __user *p_mpeg2_slice_params;
1626-
struct v4l2_ctrl_mpeg2_quantization __user *p_mpeg2_quantization;
16271625
void __user *ptr;
16281626
};
16291627
} __attribute__ ((packed));
@@ -1669,8 +1667,6 @@ enum v4l2_ctrl_type {
16691667
V4L2_CTRL_TYPE_U8 = 0x0100,
16701668
V4L2_CTRL_TYPE_U16 = 0x0101,
16711669
V4L2_CTRL_TYPE_U32 = 0x0102,
1672-
V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS = 0x0103,
1673-
V4L2_CTRL_TYPE_MPEG2_QUANTIZATION = 0x0104,
16741670
};
16751671

16761672
/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */

0 commit comments

Comments
 (0)