upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / media / video / samsung / mfc5x / mfc_interface.h
1 /*
2  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
3  *              http://www.samsung.com/
4  *
5  * Global header for Samsung MFC (Multi Function Codec - FIMV) driver
6  *
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.
10  *
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
14  *
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  *
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.
22  */
23
24 #ifndef __MFC_INTERFACE_H
25 #define __MFC_INTERFACE_H __FILE__
26
27 #include "mfc_errno.h"
28 #include "SsbSipMfcApi.h"
29
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)
34
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)
40
41 #define IOCTL_MFC_SET_CONFIG            (0x00800101)
42 #define IOCTL_MFC_GET_CONFIG            (0x00800102)
43
44 #define IOCTL_MFC_SET_BUF_CACHE         (0x00800201)
45
46 /* MFC H/W support maximum 32 extra DPB. */
47 #define MFC_MAX_EXTRA_DPB               5
48 #define MFC_MAX_DISP_DELAY              0xF
49
50 #define MFC_LIB_VER_MAJOR               1
51 #define MFC_LIB_VER_MINOR               00
52
53 #define BUF_L_UNIT                      (1024)
54 #define Align(x, alignbyte)             (((x)+(alignbyte)-1)/(alignbyte)*(alignbyte))
55
56
57 enum inst_type {
58     DECODER = 0x1,
59     ENCODER = 0x2,
60 };
61
62 typedef enum {
63     MFC_UNPACKED_PB = 0,
64     MFC_PACKED_PB = 1
65 } mfc_packed_mode;
66
67
68 typedef enum
69 {
70         MFC_USE_NONE = 0x00,
71         MFC_USE_YUV_BUFF = 0x01,
72         MFC_USE_STRM_BUFF = 0x10
73 } s3c_mfc_interbuff_status;
74
75 #ifndef FPS
76 typedef struct
77 {
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;
83 #endif
84
85 struct mfc_strm_ref_buf_arg {
86         unsigned int strm_ref_y;
87         unsigned int mv_ref_yc;
88 };
89
90 struct mfc_frame_buf_arg {
91         unsigned int luma;
92         unsigned int chroma;
93 };
94
95
96 struct mfc_enc_init_common_arg {
97         SSBSIP_MFC_CODEC_TYPE in_codec_type;    /* [IN] codec type */
98
99         int in_width;           /* [IN] width of YUV420 frame to be encoded */
100         int in_height;          /* [IN] height of YUV420 frame to be encoded */
101
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 */
105
106         /* [IN] RC enable */
107         /* [IN] RC enable (0:disable, 1:frame level RC) */
108         int in_rc_fr_en;
109         int in_rc_bitrate;      /* [IN]  RC parameter (bitrate in kbps) */
110
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) */
114
115         /* [IN] Multi-slice mode (0:single, 1:multiple) */
116         int in_ms_mode;
117         /* [IN] Multi-slice size (in num. of mb or byte) */
118         int in_ms_arg;
119
120         int in_mb_refresh;      /* [IN]  Macroblock refresh */
121
122         /* [IN] Enable (1) / Disable (0) padding with the specified values */
123         int in_pad_ctrl_on;
124
125         /* [IN] pad value if pad_ctrl_on is Enable */
126         int in_y_pad_val;
127         int in_cb_pad_val;
128         int in_cr_pad_val;
129
130         /* linear or tiled */
131         int in_frame_map;
132
133         unsigned int in_pixelcache;
134
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;
140 };
141
142 struct mfc_enc_init_h263_arg {
143         int in_rc_framerate;    /* [IN]  RC parameter (framerate) */
144 };
145
146 struct mfc_enc_init_mpeg4_arg {
147         int in_profile;         /* [IN] profile */
148         int in_level;           /* [IN] level */
149
150         int in_vop_quant_b;     /* [IN] VOP quant for B frame */
151
152         /* [IN] B frame number */
153         int in_bframenum;
154
155         /* [IN] Quarter-pel MC enable (1:enabled, 0:disabled) */
156         int in_quart_pixel;
157
158         int in_TimeIncreamentRes;       /* [IN] VOP time resolution */
159         int in_VopTimeIncreament;       /* [IN] Frame delta */
160 };
161
162 struct mfc_enc_init_h264_arg {
163         int in_profile;         /* [IN] profile */
164         int in_level;           /* [IN] level */
165
166         int in_vop_quant_b;     /* [IN] VOP quant for B frame */
167
168         /* [IN] B frame number */
169         int in_bframenum;
170
171         /* [IN] interlace mode(0:progressive, 1:interlace) */
172         int in_interlace_mode;
173
174         /* [IN]  reference number */
175         int in_reference_num;
176         /* [IN]  reference number of P frame */
177         int in_ref_num_p;
178
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) */
189
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 */
195         int in_deblock_beta;
196
197         /* [IN]  ( 0 : CAVLC, 1 : CABAC ) */
198         int in_symbolmode;
199         /* [IN] (0: only 4x4 transform, 1: allow using 8x8 transform) */
200         int in_transform8x8_mode;
201
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;
206 };
207
208 struct mfc_enc_init_arg {
209         struct mfc_enc_init_common_arg cmn;
210         union {
211                 struct mfc_enc_init_h264_arg h264;
212                 struct mfc_enc_init_mpeg4_arg mpeg4;
213                 struct mfc_enc_init_h263_arg h263;
214         } codec;
215 };
216
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 */
226
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 */
233
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;
240 #endif
241 };
242
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    */
248
249         unsigned int in_crc;            /* [IN] */
250         unsigned int in_pixelcache;     /* [IN] */
251         unsigned int in_slice;          /* [IN] */
252         unsigned int in_numextradpb;    /* [IN] */
253
254         unsigned int in_mapped_addr;
255
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 */
260
261         int out_dpb_cnt;        /* [OUT] the number of buffers which is nessary during decoding. */
262
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;
267 };
268
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 */
273         int in_strm_size;
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;
294
295         int out_crop_right_offset;
296         int out_crop_left_offset;
297         int out_crop_bottom_offset;
298         int out_crop_top_offset;
299
300         /* in new driver, each buffer offset must be return to the user */
301         int out_y_offset;
302         int out_c_offset;
303
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;
310 #endif
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 */
315
316         int out_disp_pic_frame_type;             /* [OUT] display picture frame type information */
317 };
318
319 struct mfc_get_config_arg {
320         /* [IN] Configurable parameter type */
321         int in_config_param;
322
323         /* [IN] Values to get for the configurable parameter. */
324         /* Maximum four integer values can be obtained; */
325         int out_config_value[4];
326 };
327
328 struct mfc_set_config_arg {
329         /* [IN] Configurable parameter type */
330         int in_config_param;
331
332         /* [IN]  Values to be set for the configurable parameter. */
333         /* Maximum four integer values can be set. */
334         int in_config_value[4];
335 };
336
337 struct mfc_get_real_addr_arg {
338         unsigned int key;
339         unsigned int addr;
340 };
341
342 struct mfc_buf_alloc_arg {
343         enum inst_type type;
344         int size;
345         /*
346         unsigned int mapped;
347         */
348         unsigned int align;
349
350         unsigned int addr;
351         /*
352         unsigned int phys;
353         */
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)
358         unsigned int cookie;
359 #else
360         unsigned int offset;
361 #endif
362 };
363
364 struct mfc_buf_free_arg {
365         unsigned int addr;
366 };
367
368
369 /* RMVME */
370 struct mfc_mem_alloc_arg {
371         enum inst_type type;
372         int buff_size;
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)
378         unsigned int cookie;
379 #else
380         unsigned int offset;
381 #endif
382 };
383
384 struct mfc_mem_free_arg {
385         unsigned int key;
386 };
387 /* RMVME */
388
389 union mfc_args {
390         /*
391         struct mfc_enc_init_arg enc_init;
392
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;
396         */
397         struct mfc_enc_init_arg enc_init;
398         struct mfc_enc_exe_arg enc_exe;
399
400         struct mfc_dec_init_arg dec_init;
401         struct mfc_dec_exe_arg dec_exe;
402
403         struct mfc_get_config_arg get_config;
404         struct mfc_set_config_arg set_config;
405
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;
409
410         /* RMVME */
411         struct mfc_mem_alloc_arg mem_alloc;
412         struct mfc_mem_free_arg mem_free;
413         /* RMVME */
414 };
415
416 struct mfc_common_args {
417         enum mfc_ret_code ret_code;     /* [OUT] error code */
418         union mfc_args args;
419 };
420
421 struct mfc_enc_vui_info {
422         int aspect_ratio_idc;
423 };
424
425 struct mfc_dec_fimv1_info {
426         int width;
427         int height;
428 };
429
430 struct mfc_enc_hier_p_qp {
431         int t0_frame_qp;
432         int t2_frame_qp;
433         int t3_frame_qp;
434 };
435
436 typedef struct
437 {
438         int magic;
439         int hMFC;
440         int hVMEM;
441         int width;
442         int height;
443         int sizeStrmBuf;
444         struct mfc_frame_buf_arg sizeFrmBuf;
445         int displayStatus;
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;
463         int encodedDataSize;
464         unsigned int encodedframeType;
465         struct mfc_frame_buf_arg encodedphyFrmBuf;
466
467         unsigned int dec_crc;
468         unsigned int dec_pixelcache;
469         unsigned int dec_slice;
470         unsigned int dec_numextradpb;
471
472         int input_cookie;
473         int input_secure_id;
474         int input_size;
475 } _MFCLIB;
476
477 #define ENC_PROFILE_LEVEL(profile, level)      ((profile) | ((level) << 8))
478 #define ENC_RC_QBOUND(min_qp, max_qp)          ((min_qp) | ((max_qp) << 8))
479
480 #endif /* __MFC_INTERFACE_H */