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;
135 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;
142 struct mfc_enc_init_h263_arg {
143 int in_rc_framerate; /* [IN] RC parameter (framerate) */
146 struct mfc_enc_init_mpeg4_arg {
147 int in_profile; /* [IN] profile */
148 int in_level; /* [IN] level */
150 int in_vop_quant_b; /* [IN] VOP quant for B frame */
152 /* [IN] B frame number */
155 /* [IN] Quarter-pel MC enable (1:enabled, 0:disabled) */
158 int in_TimeIncreamentRes; /* [IN] VOP time resolution */
159 int in_VopTimeIncreament; /* [IN] Frame delta */
162 struct mfc_enc_init_h264_arg {
163 int in_profile; /* [IN] profile */
164 int in_level; /* [IN] level */
166 int in_vop_quant_b; /* [IN] VOP quant for B frame */
168 /* [IN] B frame number */
171 /* [IN] interlace mode(0:progressive, 1:interlace) */
172 int in_interlace_mode;
174 /* [IN] reference number */
175 int in_reference_num;
176 /* [IN] reference number of P frame */
179 int in_rc_framerate; /* [IN] RC parameter (framerate) */
180 int in_rc_mb_en; /* [IN] RC enable (0:disable, 1:MB level RC) */
181 /* [IN] MB level rate control dark region adaptive feature */
182 int in_rc_mb_dark_dis; /* (0:enable, 1:disable) */
183 /* [IN] MB level rate control smooth region adaptive feature */
184 int in_rc_mb_smooth_dis; /* (0:enable, 1:disable) */
185 /* [IN] MB level rate control static region adaptive feature */
186 int in_rc_mb_static_dis; /* (0:enable, 1:disable) */
187 /* [IN] MB level rate control activity region adaptive feature */
188 int in_rc_mb_activity_dis; /* (0:enable, 1:disable) */
190 /* [IN] disable deblocking filter idc */
191 int in_deblock_dis; /* (0: enable,1: disable, 2:Disable at slice boundary) */
192 /* [IN] slice alpha c0 offset of deblocking filter */
193 int in_deblock_alpha_c0;
194 /* [IN] slice beta offset of deblocking filter */
197 /* [IN] ( 0 : CAVLC, 1 : CABAC ) */
199 /* [IN] (0: only 4x4 transform, 1: allow using 8x8 transform) */
200 int in_transform8x8_mode;
202 /* [IN] Inter weighted parameter for mode decision */
203 int in_md_interweight_pps;
204 /* [IN] Intra weighted parameter for mode decision */
205 int in_md_intraweight_pps;
208 struct mfc_enc_init_arg {
209 struct mfc_enc_init_common_arg cmn;
211 struct mfc_enc_init_h264_arg h264;
212 struct mfc_enc_init_mpeg4_arg mpeg4;
213 struct mfc_enc_init_h263_arg h263;
217 struct mfc_enc_exe_arg {
218 SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */
219 unsigned int in_Y_addr; /*[IN]In-buffer addr of Y component */
220 unsigned int in_CbCr_addr;/*[IN]In-buffer addr of CbCr component */
221 unsigned int in_Y_addr_vir; /*[IN]In-buffer addr of Y component */
222 unsigned int in_CbCr_addr_vir;/*[IN]In-buffer addr of CbCr component */
223 unsigned int in_strm_st; /*[IN]Out-buffer start addr of encoded strm*/
224 unsigned int in_strm_end; /*[IN]Out-buffer end addr of encoded strm */
225 unsigned int in_frametag; /* [IN] unique frame ID */
227 unsigned int out_frame_type; /* [OUT] frame type */
228 int out_encoded_size; /* [OUT] Length of Encoded video stream */
229 unsigned int out_Y_addr; /*[OUT]Out-buffer addr of encoded Y component */
230 unsigned int out_CbCr_addr; /*[OUT]Out-buffer addr of encoded CbCr component */
231 unsigned int out_frametag_top; /* [OUT] unique frame ID of an output frame or top field */
232 unsigned int out_frametag_bottom;/* [OUT] unique frame ID of bottom field */
234 #if defined(CONFIG_VIDEO_MFC_VCM_UMP)
235 unsigned int out_y_secure_id;
236 unsigned int out_c_secure_id;
237 #elif defined(CONFIG_S5P_VMEM)
238 unsigned int out_y_cookie;
239 unsigned int out_c_cookie;
243 struct mfc_dec_init_arg {
244 SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */
245 int in_strm_buf; /* [IN] address of stream buffer */
246 int in_strm_size; /* [IN] filled size in stream buffer */
247 int in_packed_PB; /* [IN] Is packed PB frame or not, 1: packedPB 0: unpacked */
249 unsigned int in_crc; /* [IN] */
250 unsigned int in_pixelcache; /* [IN] */
251 unsigned int in_slice; /* [IN] */
252 unsigned int in_numextradpb; /* [IN] */
254 unsigned int in_mapped_addr;
256 int out_frm_width; /* [OUT] width of YUV420 frame */
257 int out_frm_height; /* [OUT] height of YUV420 frame */
258 int out_buf_width; /* [OUT] width of YUV420 frame */
259 int out_buf_height; /* [OUT] height of YUV420 frame */
261 int out_dpb_cnt; /* [OUT] the number of buffers which is nessary during decoding. */
263 int out_crop_right_offset; /* [OUT] crop information for h264 */
264 int out_crop_left_offset;
265 int out_crop_bottom_offset;
266 int out_crop_top_offset;
269 struct mfc_dec_exe_arg {
270 SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */
271 int in_strm_buf; /* [IN] the physical address of STRM_BUF */
272 /* [IN] Size of video stream filled in STRM_BUF */
274 /* [IN] the address of dpb FRAME_BUF */
275 struct mfc_frame_buf_arg in_frm_buf;
276 /* [IN] size of dpb FRAME_BUF */
277 struct mfc_frame_buf_arg in_frm_size;
278 /* [IN] Unique frame ID eg. application specific timestamp */
279 unsigned int in_frametag;
280 /* [IN] immdiate Display for seek,thumbnail and one frame */
281 int in_immediately_disp;
282 /* [OUT] the physical address of display buf */
283 int out_display_Y_addr;
284 /* [OUT] the physical address of display buf */
285 int out_display_C_addr;
286 int out_display_status;
287 /* [OUT] unique frame ID of an output frame or top field */
288 unsigned int out_frametag_top;
289 /* [OUT] unique frame ID of bottom field */
290 unsigned int out_frametag_bottom;
291 int out_pic_time_top;
292 int out_pic_time_bottom;
293 int out_consumed_byte;
295 int out_crop_right_offset;
296 int out_crop_left_offset;
297 int out_crop_bottom_offset;
298 int out_crop_top_offset;
300 /* in new driver, each buffer offset must be return to the user */
304 #if defined(CONFIG_VIDEO_MFC_VCM_UMP)
305 unsigned int out_y_secure_id;
306 unsigned int out_c_secure_id;
307 #elif defined(CONFIG_S5P_VMEM)
308 unsigned int out_y_cookie;
309 unsigned int out_c_cookie;
311 int out_img_width; /* [OUT] width of YUV420 frame */
312 int out_img_height; /* [OUT] height of YUV420 frame */
313 int out_buf_width; /* [OUT] width of YUV420 frame */
314 int out_buf_height; /* [OUT] height of YUV420 frame */
316 int out_disp_pic_frame_type; /* [OUT] display picture frame type information */
319 struct mfc_get_config_arg {
320 /* [IN] Configurable parameter type */
323 /* [IN] Values to get for the configurable parameter. */
324 /* Maximum four integer values can be obtained; */
325 int out_config_value[4];
328 struct mfc_set_config_arg {
329 /* [IN] Configurable parameter type */
332 /* [IN] Values to be set for the configurable parameter. */
333 /* Maximum four integer values can be set. */
334 int in_config_value[4];
337 struct mfc_get_real_addr_arg {
342 struct mfc_buf_alloc_arg {
354 #if defined(CONFIG_VIDEO_MFC_VCM_UMP)
355 /* FIMXE: invalid secure id == -1 */
356 unsigned int secure_id;
357 #elif defined(CONFIG_S5P_VMEM)
364 struct mfc_buf_free_arg {
370 struct mfc_mem_alloc_arg {
373 SSBIP_MFC_BUFFER_TYPE buf_cache_type;
374 unsigned int mapped_addr;
375 #if defined(CONFIG_VIDEO_MFC_VCM_UMP)
376 unsigned int secure_id;
377 #elif defined(CONFIG_S5P_VMEM)
384 struct mfc_mem_free_arg {
391 struct mfc_enc_init_arg enc_init;
393 struct mfc_enc_init_mpeg4_arg enc_init_mpeg4;
394 struct mfc_enc_init_mpeg4_arg enc_init_h263;
395 struct mfc_enc_init_h264_arg enc_init_h264;
397 struct mfc_enc_init_arg enc_init;
398 struct mfc_enc_exe_arg enc_exe;
400 struct mfc_dec_init_arg dec_init;
401 struct mfc_dec_exe_arg dec_exe;
403 struct mfc_get_config_arg get_config;
404 struct mfc_set_config_arg set_config;
406 struct mfc_buf_alloc_arg buf_alloc;
407 struct mfc_buf_free_arg buf_free;
408 struct mfc_get_real_addr_arg real_addr;
411 struct mfc_mem_alloc_arg mem_alloc;
412 struct mfc_mem_free_arg mem_free;
416 struct mfc_common_args {
417 enum mfc_ret_code ret_code; /* [OUT] error code */
421 struct mfc_enc_vui_info {
422 int aspect_ratio_idc;
425 struct mfc_dec_fimv1_info {
430 struct mfc_enc_hier_p_qp {
444 struct mfc_frame_buf_arg sizeFrmBuf;
446 int inter_buff_status;
447 unsigned int virFreeStrmAddr;
448 unsigned int phyStrmBuf;
449 unsigned int virStrmBuf;
450 unsigned int virMvRefYC;
451 struct mfc_frame_buf_arg phyFrmBuf;
452 struct mfc_frame_buf_arg virFrmBuf;
453 unsigned int mapped_addr;
454 unsigned int mapped_size;
455 struct mfc_common_args MfcArg;
456 SSBSIP_MFC_CODEC_TYPE codecType;
457 SSBSIP_MFC_DEC_OUTPUT_INFO decOutInfo;
458 unsigned int inframetag;
459 unsigned int outframetagtop;
460 unsigned int outframetagbottom;
461 unsigned int immediatelydisp;
462 unsigned int encodedHeaderSize;
464 unsigned int encodedframeType;
465 struct mfc_frame_buf_arg encodedphyFrmBuf;
467 unsigned int dec_crc;
468 unsigned int dec_pixelcache;
469 unsigned int dec_slice;
470 unsigned int dec_numextradpb;
477 #define ENC_PROFILE_LEVEL(profile, level) ((profile) | ((level) << 8))
478 #define ENC_RC_QBOUND(min_qp, max_qp) ((min_qp) | ((max_qp) << 8))
480 #endif /* __MFC_INTERFACE_H */