2 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com/
5 * Global header for Samsung MFC (Multi Function Codec - FIMV) driver
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * Alternatively, Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
24 #ifndef __MFC_INTERFACE_H
25 #define __MFC_INTERFACE_H __FILE__
27 #include "mfc_errno.h"
28 #include "SsbSipMfcApi.h"
30 #define IOCTL_MFC_DEC_INIT (0x00800001)
31 #define IOCTL_MFC_ENC_INIT (0x00800002)
32 #define IOCTL_MFC_DEC_EXE (0x00800003)
33 #define IOCTL_MFC_ENC_EXE (0x00800004)
35 #define IOCTL_MFC_GET_IN_BUF (0x00800010)
36 #define IOCTL_MFC_FREE_BUF (0x00800011)
37 #define IOCTL_MFC_GET_REAL_ADDR (0x00800012)
38 #define IOCTL_MFC_GET_MMAP_SIZE (0x00800014)
39 #define IOCTL_MFC_SET_IN_BUF (0x00800018)
41 #define IOCTL_MFC_SET_CONFIG (0x00800101)
42 #define IOCTL_MFC_GET_CONFIG (0x00800102)
44 #define IOCTL_MFC_SET_BUF_CACHE (0x00800201)
46 /* MFC H/W support maximum 32 extra DPB. */
47 #define MFC_MAX_EXTRA_DPB 5
48 #define MFC_MAX_DISP_DELAY 0xF
50 #define MFC_LIB_VER_MAJOR 1
51 #define MFC_LIB_VER_MINOR 00
53 #define BUF_L_UNIT (1024)
54 #define Align(x, alignbyte) (((x)+(alignbyte)-1)/(alignbyte)*(alignbyte))
71 MFC_USE_YUV_BUFF = 0x01,
72 MFC_USE_STRM_BUFF = 0x10
73 } s3c_mfc_interbuff_status;
78 int luma0; /* per frame (or top field)*/
79 int chroma0; /* per frame (or top field)*/
80 int luma1; /* per frame (or bottom field)*/
81 int chroma1; /* per frame (or bottom field)*/
82 } SSBSIP_MFC_CRC_DATA;
85 struct mfc_strm_ref_buf_arg {
86 unsigned int strm_ref_y;
87 unsigned int mv_ref_yc;
90 struct mfc_frame_buf_arg {
96 struct mfc_enc_init_common_arg {
97 SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */
99 int in_width; /* [IN] width of YUV420 frame to be encoded */
100 int in_height; /* [IN] height of YUV420 frame to be encoded */
102 int in_gop_num; /* [IN] GOP Number (interval of I-frame) */
103 int in_vop_quant; /* [IN] VOP quant */
104 int in_vop_quant_p; /* [IN] VOP quant for P frame */
107 /* [IN] RC enable (0:disable, 1:frame level RC) */
109 int in_rc_bitrate; /* [IN] RC parameter (bitrate in kbps) */
111 int in_rc_qbound_min; /* [IN] RC parameter (Q bound Min) */
112 int in_rc_qbound_max; /* [IN] RC parameter (Q bound Max) */
113 int in_rc_rpara; /* [IN] RC parameter (Reaction Coefficient) */
115 /* [IN] Multi-slice mode (0:single, 1:multiple) */
117 /* [IN] Multi-slice size (in num. of mb or byte) */
120 int in_mb_refresh; /* [IN] Macroblock refresh */
122 /* [IN] Enable (1) / Disable (0) padding with the specified values */
125 /* [IN] pad value if pad_ctrl_on is Enable */
130 /* linear or tiled */
133 unsigned int in_pixelcache;
134 unsigned int in_mapped_addr;
136 struct mfc_strm_ref_buf_arg out_u_addr;
137 struct mfc_strm_ref_buf_arg out_p_addr;
138 struct mfc_strm_ref_buf_arg out_buf_size;
139 unsigned int out_header_size;
141 #if SUPPORT_SLICE_ENCODING
142 unsigned int in_output_mode;
146 struct mfc_enc_init_h263_arg {
147 int in_rc_framerate; /* [IN] RC parameter (framerate) */
150 struct mfc_enc_init_mpeg4_arg {
151 int in_profile; /* [IN] profile */
152 int in_level; /* [IN] level */
154 int in_vop_quant_b; /* [IN] VOP quant for B frame */
156 /* [IN] B frame number */
159 /* [IN] Quarter-pel MC enable (1:enabled, 0:disabled) */
162 int in_TimeIncreamentRes; /* [IN] VOP time resolution */
163 int in_VopTimeIncreament; /* [IN] Frame delta */
166 struct mfc_enc_init_h264_arg {
167 int in_profile; /* [IN] profile */
168 int in_level; /* [IN] level */
170 int in_vop_quant_b; /* [IN] VOP quant for B frame */
172 /* [IN] B frame number */
175 /* [IN] interlace mode(0:progressive, 1:interlace) */
176 int in_interlace_mode;
178 /* [IN] reference number */
179 int in_reference_num;
180 /* [IN] reference number of P frame */
183 int in_rc_framerate; /* [IN] RC parameter (framerate) */
184 int in_rc_mb_en; /* [IN] RC enable (0:disable, 1:MB level RC) */
185 /* [IN] MB level rate control dark region adaptive feature */
186 int in_rc_mb_dark_dis; /* (0:enable, 1:disable) */
187 /* [IN] MB level rate control smooth region adaptive feature */
188 int in_rc_mb_smooth_dis; /* (0:enable, 1:disable) */
189 /* [IN] MB level rate control static region adaptive feature */
190 int in_rc_mb_static_dis; /* (0:enable, 1:disable) */
191 /* [IN] MB level rate control activity region adaptive feature */
192 int in_rc_mb_activity_dis; /* (0:enable, 1:disable) */
194 /* [IN] disable deblocking filter idc */
195 int in_deblock_dis; /* (0: enable,1: disable, 2:Disable at slice boundary) */
196 /* [IN] slice alpha c0 offset of deblocking filter */
197 int in_deblock_alpha_c0;
198 /* [IN] slice beta offset of deblocking filter */
201 /* [IN] ( 0 : CAVLC, 1 : CABAC ) */
203 /* [IN] (0: only 4x4 transform, 1: allow using 8x8 transform) */
204 int in_transform8x8_mode;
206 /* [IN] Inter weighted parameter for mode decision */
207 int in_md_interweight_pps;
208 /* [IN] Intra weighted parameter for mode decision */
209 int in_md_intraweight_pps;
212 struct mfc_enc_init_arg {
213 struct mfc_enc_init_common_arg cmn;
215 struct mfc_enc_init_h264_arg h264;
216 struct mfc_enc_init_mpeg4_arg mpeg4;
217 struct mfc_enc_init_h263_arg h263;
221 struct mfc_enc_exe_arg {
222 SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */
223 unsigned int in_Y_addr; /*[IN]In-buffer addr of Y component */
224 unsigned int in_CbCr_addr;/*[IN]In-buffer addr of CbCr component */
225 unsigned int in_Y_addr_vir; /*[IN]In-buffer addr of Y component */
226 unsigned int in_CbCr_addr_vir;/*[IN]In-buffer addr of CbCr component */
227 unsigned int in_strm_st; /*[IN]Out-buffer start addr of encoded strm*/
228 unsigned int in_strm_end; /*[IN]Out-buffer end addr of encoded strm */
229 unsigned int in_frametag; /* [IN] unique frame ID */
231 unsigned int out_frame_type; /* [OUT] frame type */
232 int out_encoded_size; /* [OUT] Length of Encoded video stream */
233 unsigned int out_Y_addr; /*[OUT]Out-buffer addr of encoded Y component */
234 unsigned int out_CbCr_addr; /*[OUT]Out-buffer addr of encoded CbCr component */
235 unsigned int out_frametag_top; /* [OUT] unique frame ID of an output frame or top field */
236 unsigned int out_frametag_bottom;/* [OUT] unique frame ID of bottom field */
238 #if defined(CONFIG_VIDEO_MFC_VCM_UMP)
239 unsigned int out_y_secure_id;
240 unsigned int out_c_secure_id;
241 #elif defined(CONFIG_S5P_VMEM)
242 unsigned int out_y_cookie;
243 unsigned int out_c_cookie;
246 SSBSIP_MFC_MEMORY_TYPE memory_type; /* [OUT] memory type */
250 struct mfc_dec_init_arg {
251 SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */
252 int in_strm_buf; /* [IN] address of stream buffer */
253 int in_strm_size; /* [IN] filled size in stream buffer */
254 int in_packed_PB; /* [IN] Is packed PB frame or not, 1: packedPB 0: unpacked */
256 unsigned int in_crc; /* [IN] */
257 unsigned int in_pixelcache; /* [IN] */
258 unsigned int in_slice; /* [IN] */
259 unsigned int in_numextradpb; /* [IN] */
261 unsigned int in_mapped_addr;
263 int out_frm_width; /* [OUT] width of YUV420 frame */
264 int out_frm_height; /* [OUT] height of YUV420 frame */
265 int out_buf_width; /* [OUT] width of YUV420 frame */
266 int out_buf_height; /* [OUT] height of YUV420 frame */
268 int out_dpb_cnt; /* [OUT] the number of buffers which is nessary during decoding. */
270 int out_crop_right_offset; /* [OUT] crop information for h264 */
271 int out_crop_left_offset;
272 int out_crop_bottom_offset;
273 int out_crop_top_offset;
276 struct mfc_dec_exe_arg {
277 SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */
278 int in_strm_buf; /* [IN] the physical address of STRM_BUF */
279 /* [IN] Size of video stream filled in STRM_BUF */
281 /* [IN] the address of dpb FRAME_BUF */
282 struct mfc_frame_buf_arg in_frm_buf;
283 /* [IN] size of dpb FRAME_BUF */
284 struct mfc_frame_buf_arg in_frm_size;
285 /* [IN] Unique frame ID eg. application specific timestamp */
286 unsigned int in_frametag;
287 /* [IN] immdiate Display for seek,thumbnail and one frame */
288 int in_immediately_disp;
289 /* [OUT] the physical address of display buf */
290 int out_display_Y_addr;
291 /* [OUT] the physical address of display buf */
292 int out_display_C_addr;
293 int out_display_status;
294 /* [OUT] unique frame ID of an output frame or top field */
295 unsigned int out_frametag_top;
296 /* [OUT] unique frame ID of bottom field */
297 unsigned int out_frametag_bottom;
298 int out_pic_time_top;
299 int out_pic_time_bottom;
300 int out_consumed_byte;
302 int out_crop_right_offset;
303 int out_crop_left_offset;
304 int out_crop_bottom_offset;
305 int out_crop_top_offset;
307 /* in new driver, each buffer offset must be return to the user */
311 #if defined(CONFIG_VIDEO_MFC_VCM_UMP)
312 unsigned int out_y_secure_id;
313 unsigned int out_c_secure_id;
314 #elif defined(CONFIG_S5P_VMEM)
315 unsigned int out_y_cookie;
316 unsigned int out_c_cookie;
319 int out_img_width; /* [OUT] width of YUV420 frame */
320 int out_img_height; /* [OUT] height of YUV420 frame */
321 int out_buf_width; /* [OUT] width of YUV420 frame */
322 int out_buf_height; /* [OUT] height of YUV420 frame */
324 int out_disp_pic_frame_type; /* [OUT] display picture frame type information */
326 SSBSIP_MFC_MEMORY_TYPE memory_type; /* [OUT] memory type */
330 struct mfc_basic_config {
334 struct mfc_frame_packing {
336 unsigned int arrangement_id;
337 int arrangement_cancel_flag;
338 unsigned char arrangement_type;
339 int quincunx_sampling_flag;
340 unsigned char content_interpretation_type;
341 int spatial_flipping_flag;
342 int frame0_flipped_flag;
343 int field_views_flag;
344 int current_frame_is_frame0_flag;
345 unsigned char frame0_grid_pos_x;
346 unsigned char frame0_grid_pos_y;
347 unsigned char frame1_grid_pos_x;
348 unsigned char frame1_grid_pos_y;
351 union _mfc_config_arg {
352 struct mfc_basic_config basic;
353 struct mfc_frame_packing frame_packing;
356 struct mfc_config_arg {
358 union _mfc_config_arg args;
361 struct mfc_get_real_addr_arg {
366 struct mfc_buf_alloc_arg {
378 #if defined(CONFIG_VIDEO_MFC_VCM_UMP)
379 /* FIMXE: invalid secure id == -1 */
380 unsigned int secure_id;
381 #elif defined(CONFIG_S5P_VMEM)
388 struct mfc_buf_free_arg {
394 struct mfc_mem_alloc_arg {
397 SSBIP_MFC_BUFFER_TYPE buf_cache_type;
398 unsigned int mapped_addr;
399 #if defined(CONFIG_VIDEO_MFC_VCM_UMP)
400 unsigned int secure_id;
401 #elif defined(CONFIG_S5P_VMEM)
408 struct mfc_mem_free_arg {
415 struct mfc_enc_init_arg enc_init;
417 struct mfc_enc_init_mpeg4_arg enc_init_mpeg4;
418 struct mfc_enc_init_mpeg4_arg enc_init_h263;
419 struct mfc_enc_init_h264_arg enc_init_h264;
421 struct mfc_enc_init_arg enc_init;
422 struct mfc_enc_exe_arg enc_exe;
424 struct mfc_dec_init_arg dec_init;
425 struct mfc_dec_exe_arg dec_exe;
427 struct mfc_config_arg config;
429 struct mfc_buf_alloc_arg buf_alloc;
430 struct mfc_buf_free_arg buf_free;
431 struct mfc_get_real_addr_arg real_addr;
434 struct mfc_mem_alloc_arg mem_alloc;
435 struct mfc_mem_free_arg mem_free;
438 SSBSIP_MFC_MEMORY_TYPE memory_type;
442 struct mfc_common_args {
443 enum mfc_ret_code ret_code; /* [OUT] error code */
447 struct mfc_enc_vui_info {
448 int aspect_ratio_idc;
451 struct mfc_dec_fimv1_info {
456 struct mfc_enc_hier_p_qp {
462 struct mfc_enc_set_config {
475 struct mfc_frame_buf_arg sizeFrmBuf;
477 int inter_buff_status;
478 unsigned int virFreeStrmAddr;
479 unsigned int phyStrmBuf;
480 unsigned int virStrmBuf;
481 unsigned int virMvRefYC;
482 struct mfc_frame_buf_arg phyFrmBuf;
483 struct mfc_frame_buf_arg virFrmBuf;
484 unsigned int mapped_addr;
485 unsigned int mapped_size;
486 struct mfc_common_args MfcArg;
487 SSBSIP_MFC_CODEC_TYPE codecType;
488 SSBSIP_MFC_DEC_OUTPUT_INFO decOutInfo;
489 unsigned int inframetag;
490 unsigned int outframetagtop;
491 unsigned int outframetagbottom;
492 unsigned int immediatelydisp;
493 unsigned int encodedHeaderSize;
495 unsigned int encodedframeType;
496 struct mfc_frame_buf_arg encodedphyFrmBuf;
498 unsigned int dec_crc;
499 unsigned int dec_pixelcache;
500 unsigned int dec_slice;
501 unsigned int dec_numextradpb;
502 unsigned int dec_packedPB_detect;
508 unsigned int encode_cnt;
512 #define ENC_PROFILE_LEVEL(profile, level) ((profile) | ((level) << 8))
513 #define ENC_RC_QBOUND(min_qp, max_qp) ((min_qp) | ((max_qp) << 8))
515 #endif /* __MFC_INTERFACE_H */