• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef __MSM_VIDC_UTILS_H__
3 #define __MSM_VIDC_UTILS_H__
4 
5 #include <linux/types.h>
6 
7 #define MSM_VIDC_EXTRADATA_NONE 0x00000000
8 struct msm_vidc_extradata_header {
9 	__u32 size;
10 	__u32 version; /** Keeping binary compatibility */
11 	__u32 port_index; /* with firmware and OpenMAX IL **/
12 	__u32 type; /* msm_vidc_extradata_type */
13 	__u32 data_size;
14 	__u32 data[1];
15 };
16 
17 /* msm_vidc_interlace_type */
18 #define MSM_VIDC_INTERLACE_FRAME_PROGRESSIVE 0x01
19 #define MSM_VIDC_INTERLACE_INTERLEAVE_FRAME_TOPFIELDFIRST 0x02
20 #define MSM_VIDC_INTERLACE_INTERLEAVE_FRAME_BOTTOMFIELDFIRST 0x04
21 #define MSM_VIDC_INTERLACE_FRAME_TOPFIELDFIRST 0x08
22 #define MSM_VIDC_INTERLACE_FRAME_BOTTOMFIELDFIRST 0x10
23 #define MSM_VIDC_INTERLACE_FRAME_MBAFF 0x20
24 /* Color formats */
25 #define MSM_VIDC_HAL_INTERLACE_COLOR_FORMAT_NV12	0x2
26 #define MSM_VIDC_HAL_INTERLACE_COLOR_FORMAT_NV12_UBWC	0x8002
27 #define MSM_VIDC_EXTRADATA_INTERLACE_VIDEO 0x00000002
28 struct msm_vidc_interlace_payload {
29 	__u32 format; /* Interlace format */
30 	__u32 color_format;
31 };
32 
33 #define MSM_VIDC_EXTRADATA_FRAME_RATE 0x00000007
34 struct msm_vidc_framerate_payload {
35 	__u32 frame_rate; /*In Q16 format */
36 };
37 
38 #define MSM_VIDC_EXTRADATA_TIMESTAMP 0x00000005
39 struct msm_vidc_ts_payload {
40 	__u32 timestamp_lo;
41 	__u32 timestamp_hi;
42 };
43 
44 #define MSM_VIDC_EXTRADATA_NUM_CONCEALED_MB 0x7F100001
45 struct msm_vidc_concealmb_payload {
46 	__u32 num_mbs;
47 };
48 
49 
50 #define MSM_VIDC_FRAME_RECONSTRUCTION_INCORRECT 0x0
51 #define MSM_VIDC_FRAME_RECONSTRUCTION_CORRECT 0x01
52 #define MSM_VIDC_FRAME_RECONSTRUCTION_APPROXIMATELY_CORRECT 0x02
53 #define MSM_VIDC_EXTRADATA_RECOVERY_POINT_SEI 0x00000009
54 struct msm_vidc_recoverysei_payload {
55 	__u32 flags;
56 };
57 
58 #define MSM_VIDC_EXTRADATA_ASPECT_RATIO 0x7F100003
59 struct msm_vidc_aspect_ratio_payload {
60 	__u32 size;
61 	__u32 version;
62 	__u32 port_index;
63 	__u32 aspect_width;
64 	__u32 aspect_height;
65 };
66 
67 struct msm_vidc_misr_info {
68 	__u32 misr_set;
69 	__u32 misr_dpb_luma[8];
70 	__u32 misr_dpb_chroma[8];
71 	__u32 misr_opb_luma[8];
72 	__u32 misr_opb_chroma[8];
73 };
74 #define MSM_VIDC_EXTRADATA_OUTPUT_CROP 0x0700000F
75 struct msm_vidc_output_crop_payload {
76 	__u32 size;
77 	__u32 version;
78 	__u32 port_index;
79 	__u32 left;
80 	__u32 top;
81 	__u32 display_width;
82 	__u32 display_height;
83 	__u32 width;
84 	__u32 height;
85 	__u32 frame_num;
86 	__u32 bit_depth_y;
87 	__u32 bit_depth_c;
88 	struct msm_vidc_misr_info misr_info[2];
89 };
90 
91 #define MSM_VIDC_EXTRADATA_INDEX 0x7F100002
92 struct msm_vidc_extradata_index {
93 	__u32 type;
94 	union {
95 		struct msm_vidc_aspect_ratio_payload aspect_ratio;
96 	};
97 };
98 
99 #define MSM_VIDC_EXTRADATA_PANSCAN_WINDOW 0x00000008
100 struct msm_vidc_panscan_window {
101 	__u32 panscan_height_offset;
102 	__u32 panscan_width_offset;
103 	__u32 panscan_window_width;
104 	__u32 panscan_window_height;
105 };
106 struct msm_vidc_panscan_window_payload {
107 	__u32 num_panscan_windows;
108 	struct msm_vidc_panscan_window wnd[1];
109 };
110 
111 
112 #define MSM_VIDC_USERDATA_TYPE_FRAME 0x1
113 #define MSM_VIDC_USERDATA_TYPE_TOP_FIELD 0x2
114 #define MSM_VIDC_USERDATA_TYPE_BOTTOM_FIELD 0x3
115 #define MSM_VIDC_EXTRADATA_STREAM_USERDATA 0x0000000E
116 struct msm_vidc_stream_userdata_payload {
117 	__u32 type;
118 	__u32 data[1];
119 };
120 
121 #define MSM_VIDC_EXTRADATA_FRAME_QP 0x0000000F
122 struct msm_vidc_frame_qp_payload {
123 	__u32 frame_qp;
124 	__u32 qp_sum;
125 	__u32 skip_qp_sum;
126 	__u32 skip_num_blocks;
127 	__u32 total_num_blocks;
128 };
129 
130 #define MSM_VIDC_EXTRADATA_FRAME_BITS_INFO 0x00000010
131 struct msm_vidc_frame_bits_info_payload {
132 	__u32 frame_bits;
133 	__u32 header_bits;
134 };
135 
136 #define MSM_VIDC_EXTRADATA_S3D_FRAME_PACKING 0x00000006
137 struct msm_vidc_s3d_frame_packing_payload {
138 	__u32 fpa_id;
139 	__u32 cancel_flag;
140 	__u32 fpa_type;
141 	__u32 quin_cunx_flag;
142 	__u32 content_interprtation_type;
143 	__u32 spatial_flipping_flag;
144 	__u32 frame0_flipped_flag;
145 	__u32 field_views_flag;
146 	__u32 current_frame_is_frame0_flag;
147 	__u32 frame0_self_contained_flag;
148 	__u32 frame1_self_contained_flag;
149 	__u32 frame0_graid_pos_x;
150 	__u32 frame0_graid_pos_y;
151 	__u32 frame1_graid_pos_x;
152 	__u32 frame1_graid_pos_y;
153 	__u32 fpa_reserved_byte;
154 	__u32 fpa_repetition_period;
155 	__u32 fpa_extension_flag;
156 };
157 
158 struct msm_vidc_roi_qp_payload {
159 	__s32 upper_qp_offset;
160 	__s32 lower_qp_offset;
161 	__u32 b_roi_info;
162 	__u32 mbi_info_size;
163 	__u32 data[1];
164 };
165 
166 #define MSM_VIDC_EXTRADATA_ROI_QP 0x00000013
167 struct msm_vidc_roi_deltaqp_payload {
168 	__u32 b_roi_info; /*Enable/Disable*/
169 	__u32 mbi_info_size; /*Size of QP data*/
170 	__u32 data[1];
171 };
172 
173 #define MSM_VIDC_EXTRADATA_MASTERING_DISPLAY_COLOUR_SEI 0x00000015
174 struct msm_vidc_mastering_display_colour_sei_payload {
175 	__u32 nDisplayPrimariesX[3];
176 	__u32 nDisplayPrimariesY[3];
177 	__u32 nWhitePointX;
178 	__u32 nWhitePointY;
179 	__u32 nMaxDisplayMasteringLuminance;
180 	__u32 nMinDisplayMasteringLuminance;
181 };
182 
183 #define MSM_VIDC_EXTRADATA_CONTENT_LIGHT_LEVEL_SEI 0x00000016
184 struct msm_vidc_content_light_level_sei_payload {
185 	__u32 nMaxContentLight;
186 	__u32 nMaxPicAverageLight;
187 };
188 
189 #define MSM_VIDC_EXTRADATA_HDR10PLUS_METADATA 0x0000001A
190 struct msm_vidc_hdr10plus_metadata_payload {
191 	__u32 size;
192 	__u32 data[1];
193 };
194 
195 #define  MSM_VIDC_EXTRADATA_CVP_METADATA 0x0000001B
196 struct msm_vidc_enc_cvp_metadata_payload {
197 	__u32 data[256];
198 };
199 
200 /* video_format */
201 #define MSM_VIDC_COMPONENT 0
202 #define MSM_VIDC_PAL 1
203 #define MSM_VIDC_NTSC 2
204 #define MSM_VIDC_SECAM 3
205 #define MSM_VIDC_MAC 4
206 #define MSM_VIDC_UNSPECIFIED_FORMAT 5
207 #define MSM_VIDC_RESERVED_1_FORMAT 6
208 #define MSM_VIDC_RESERVED_2_FORMAT 7
209 
210 /* See colour_primaries of ISO/IEC 14496 for significance */
211 /* color_primaries values */
212 #define MSM_VIDC_RESERVED_1 0
213 #define MSM_VIDC_BT709_5 1
214 #define MSM_VIDC_UNSPECIFIED 2
215 #define MSM_VIDC_RESERVED_2 3
216 #define MSM_VIDC_BT470_6_M 4
217 #define MSM_VIDC_BT601_6_625 5
218 #define MSM_VIDC_BT470_6_BG MSM_VIDC_BT601_6_625
219 #define MSM_VIDC_BT601_6_525 6
220 #define MSM_VIDC_SMPTE_240M 7
221 #define MSM_VIDC_GENERIC_FILM 8
222 #define MSM_VIDC_BT2020 9
223 
224 /* matrix_coeffs values */
225 #define MSM_VIDC_MATRIX_RGB 0
226 #define MSM_VIDC_MATRIX_BT_709_5 1
227 #define MSM_VIDC_MATRIX_UNSPECIFIED 2
228 #define MSM_VIDC_MATRIX_RESERVED 3
229 #define MSM_VIDC_MATRIX_FCC_47 4
230 #define MSM_VIDC_MATRIX_601_6_625 5
231 #define MSM_VIDC_MATRIX_BT470_BG MSM_VIDC_MATRIX_601_6_625
232 #define MSM_VIDC_MATRIX_601_6_525 6
233 #define MSM_VIDC_MATRIX_SMPTE_170M MSM_VIDC_MATRIX_601_6_525
234 #define MSM_VIDC_MATRIX_SMPTE_240M 7
235 #define MSM_VIDC_MATRIX_Y_CG_CO 8
236 #define MSM_VIDC_MATRIX_BT_2020 9
237 #define MSM_VIDC_MATRIX_BT_2020_CONST 10
238 
239 /* transfer_char values */
240 #define MSM_VIDC_TRANSFER_RESERVED_1 0
241 #define MSM_VIDC_TRANSFER_BT709_5 1
242 #define MSM_VIDC_TRANSFER_UNSPECIFIED 2
243 #define MSM_VIDC_TRANSFER_RESERVED_2 3
244 #define MSM_VIDC_TRANSFER_BT_470_6_M 4
245 #define MSM_VIDC_TRANSFER_BT_470_6_BG 5
246 #define MSM_VIDC_TRANSFER_601_6_625 6
247 #define MSM_VIDC_TRANSFER_601_6_525 MSM_VIDC_TRANSFER_601_6_625
248 #define MSM_VIDC_TRANSFER_SMPTE_240M 7
249 #define MSM_VIDC_TRANSFER_LINEAR 8
250 #define MSM_VIDC_TRANSFER_LOG_100_1 9
251 #define MSM_VIDC_TRANSFER_LOG_100_SQRT10_1 10
252 #define MSM_VIDC_TRANSFER_IEC_61966 11
253 #define MSM_VIDC_TRANSFER_BT_1361 12
254 #define MSM_VIDC_TRANSFER_SRGB 13
255 #define MSM_VIDC_TRANSFER_BT_2020_10 14
256 #define MSM_VIDC_TRANSFER_BT_2020_12 15
257 #define MSM_VIDC_TRANSFER_SMPTE_ST2084 16
258 #define MSM_VIDC_TRANSFER_SMPTE_ST428_1 17
259 #define MSM_VIDC_TRANSFER_HLG 18
260 
261 #define MSM_VIDC_EXTRADATA_VUI_DISPLAY_INFO 0x7F100006
262 struct msm_vidc_vui_display_info_payload {
263 	__u32 video_signal_present_flag;
264 	__u32 video_format;
265 	__u32 bit_depth_y;
266 	__u32 bit_depth_c;
267 	__u32 video_full_range_flag;
268 	__u32 color_description_present_flag;
269 	__u32 color_primaries;
270 	__u32 transfer_char;
271 	__u32 matrix_coeffs;
272 	__u32 chroma_location_info_present_flag;
273 	__u32 chroma_format_idc;
274 	__u32 separate_color_plane_flag;
275 	__u32 chroma_sample_loc_type_top_field;
276 	__u32 chroma_sample_loc_type_bottom_field;
277 };
278 
279 #define  MSM_VIDC_EXTRADATA_HDR_HIST 0x7F100008
280 struct msm_vidc_extradata_hdr_hist_payload {
281 	__u32 value_count[1024];
282 };
283 
284 #define MSM_VIDC_EXTRADATA_MPEG2_SEQDISP 0x0000000D
285 struct msm_vidc_mpeg2_seqdisp_payload {
286 	__u32 video_format;
287 	__u32 color_descp;
288 	__u32 color_primaries;
289 	__u32 transfer_char;
290 	__u32 matrix_coeffs;
291 	__u32 disp_width;
292 	__u32 disp_height;
293 };
294 
295 /* VPx color_space values */
296 #define MSM_VIDC_CS_UNKNOWN 0
297 #define MSM_VIDC_CS_BT_601 1
298 #define MSM_VIDC_CS_BT_709 2
299 #define MSM_VIDC_CS_SMPTE_170 3
300 #define MSM_VIDC_CS_SMPTE_240 4
301 #define MSM_VIDC_CS_BT_2020 5
302 #define MSM_VIDC_CS_RESERVED 6
303 #define MSM_VIDC_CS_RGB 7
304 #define MSM_VIDC_EXTRADATA_VPX_COLORSPACE_INFO 0x00000014
305 struct msm_vidc_vpx_colorspace_payload {
306 	__u32 color_space;
307 	__u32 yuv_range_flag;
308 	__u32 sumsampling_x;
309 	__u32 sumsampling_y;
310 };
311 
312 #define MSM_VIDC_EXTRADATA_METADATA_LTRINFO 0x7F100004
313 /* Don't use the #define below. It is to bypass checkpatch */
314 #define LTRINFO MSM_VIDC_EXTRADATA_METADATA_LTRINFO
315 struct msm_vidc_metadata_ltr_payload {
316 	__u32 ltr_use_mark;
317 };
318 
319 /* ptr[2]: event_notify: pixel_depth */
320 #define MSM_VIDC_BIT_DEPTH_8 0
321 #define MSM_VIDC_BIT_DEPTH_10 1
322 #define MSM_VIDC_BIT_DEPTH_UNSUPPORTED 0XFFFFFFFF
323 
324 /*  ptr[3]: event_notify: pic_struct */
325 #define MSM_VIDC_PIC_STRUCT_MAYBE_INTERLACED 0x0
326 #define MSM_VIDC_PIC_STRUCT_PROGRESSIVE 0x1
327 
328 /*default when layer ID isn't specified*/
329 #define MSM_VIDC_ALL_LAYER_ID 0xFF
330 
VENUS_EXTRADATA_SIZE(int width,int height)331 static inline unsigned int VENUS_EXTRADATA_SIZE(int width, int height)
332 {
333 	(void)height;
334 	(void)width;
335 
336 	/*
337 	 * In the future, calculate the size based on the w/h but just
338 	 * hardcode it for now since 16K satisfies all current usecases.
339 	 */
340 	return 16 * 1024;
341 }
342 
343 /* V4L2_CID_MPEG_VIDC_VENC_HDR_INFO payload index */
344 enum msm_vidc_hdr_info_types {
345 	MSM_VIDC_RGB_PRIMARY_00,
346 	MSM_VIDC_RGB_PRIMARY_01,
347 	MSM_VIDC_RGB_PRIMARY_10,
348 	MSM_VIDC_RGB_PRIMARY_11,
349 	MSM_VIDC_RGB_PRIMARY_20,
350 	MSM_VIDC_RGB_PRIMARY_21,
351 	MSM_VIDC_WHITEPOINT_X,
352 	MSM_VIDC_WHITEPOINT_Y,
353 	MSM_VIDC_MAX_DISP_LUM,
354 	MSM_VIDC_MIN_DISP_LUM,
355 	MSM_VIDC_RGB_MAX_CLL,
356 	MSM_VIDC_RGB_MAX_FLL,
357 };
358 
359 enum msm_vidc_plane_reserved_field_types {
360 	MSM_VIDC_BUFFER_FD,
361 	MSM_VIDC_DATA_OFFSET,
362 	MSM_VIDC_COMP_RATIO,
363 	MSM_VIDC_INPUT_TAG_1,
364 	MSM_VIDC_INPUT_TAG_2,
365 };
366 
367 enum msm_vidc_cb_event_types {
368 	MSM_VIDC_HEIGHT,
369 	MSM_VIDC_WIDTH,
370 	MSM_VIDC_BIT_DEPTH,
371 	MSM_VIDC_PIC_STRUCT,
372 	MSM_VIDC_COLOR_SPACE,
373 	MSM_VIDC_FW_MIN_COUNT,
374 };
375 #endif
376