Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright 2010 Samsung Electronics Co. LTD
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef _MFC_INTERFACE_H_
     18 #define _MFC_INTERFACE_H_
     19 
     20 #include "SsbSipMfcApi.h"
     21 
     22 #define IOCTL_MFC_DEC_INIT                     0x00800001
     23 #define IOCTL_MFC_ENC_INIT                     0x00800002
     24 #define IOCTL_MFC_DEC_EXE                      0x00800003
     25 #define IOCTL_MFC_ENC_EXE                      0x00800004
     26 
     27 #define IOCTL_MFC_GET_IN_BUF                   0x00800010
     28 #define IOCTL_MFC_FREE_BUF                     0x00800011
     29 #define IOCTL_MFC_GET_PHYS_ADDR                0x00800012
     30 
     31 #define IOCTL_MFC_SET_CONFIG                   0x00800101
     32 #define IOCTL_MFC_GET_CONFIG                   0x00800102
     33 
     34 /* MFC H/W support maximum 32 extra DPB */
     35 #define MFC_MAX_EXTRA_DPB                      5
     36 
     37 #define ENC_PROFILE_LEVEL(profile, level)      ((profile) | ((level) << 8))
     38 
     39 #define ENC_PROFILE_MPEG4_SP                   0
     40 #define ENC_PROFILE_MPEG4_ASP                  1
     41 #define ENC_PROFILE_H264_BP                    0
     42 #define ENC_PROFILE_H264_MAIN                  1
     43 #define ENC_PROFILE_H264_HIGH                  2
     44 
     45 #define ENC_RC_DISABLE                         0
     46 #define ENC_RC_ENABLE_MACROBLOCK               1
     47 #define ENC_RC_ENABLE_FRAME                    2
     48 
     49 #define ENC_RC_QBOUND(min_qp, max_qp)          ((min_qp) | ((max_qp) << 8))
     50 #define ENC_RC_MB_CTRL_DARK_DISABLE            (1 << 3)
     51 #define ENC_RC_MB_CTRL_SMOOTH_DISABLE          (1 << 2)
     52 #define ENC_RC_MB_CTRL_STATIC_DISABLE          (1 << 1)
     53 #define ENC_RC_MB_CTRL_ACTIVITY_DISABLE        (1 << 0)
     54 
     55 #define ALIGN_TO_16B(x)   ((((x) + (1 <<  4) - 1) >>  4) <<  4)
     56 #define ALIGN_TO_32B(x)   ((((x) + (1 <<  5) - 1) >>  5) <<  5)
     57 #define ALIGN_TO_64B(x)   ((((x) + (1 <<  6) - 1) >>  6) <<  6)
     58 #define ALIGN_TO_128B(x)  ((((x) + (1 <<  7) - 1) >>  7) <<  7)
     59 #define ALIGN_TO_2KB(x)   ((((x) + (1 << 11) - 1) >> 11) << 11)
     60 #define ALIGN_TO_4KB(x)   ((((x) + (1 << 12) - 1) >> 12) << 12)
     61 #define ALIGN_TO_8KB(x)   ((((x) + (1 << 13) - 1) >> 13) << 13)
     62 #define ALIGN_TO_64KB(x)  ((((x) + (1 << 16) - 1) >> 16) << 16)
     63 #define ALIGN_TO_128KB(x) ((((x) + (1 << 17) - 1) >> 17) << 17)
     64 
     65 typedef struct {
     66     int luma0;    // per frame (or top field)
     67     int chroma0;    // per frame (or top field)
     68     int luma1;    // per frame (or bottom field)
     69     int chroma1;    // per frame (or bottom field)
     70 } MFC_CRC_DATA;
     71 
     72 typedef enum {
     73     MFC_USE_NONE = 0x00,
     74     MFC_USE_YUV_BUFF = 0x01,
     75     MFC_USE_STRM_BUFF = 0x10
     76 } mfc_interbuff_status;
     77 
     78 typedef enum {
     79     MFC_UNPACKED_PB = 0,
     80     MFC_PACKED_PB = 1
     81 } mfc_packed_mode;
     82 
     83 typedef struct tag_strm_ref_buf_arg {
     84     unsigned int strm_ref_y;
     85     unsigned int mv_ref_yc;
     86 } mfc_strm_ref_buf_arg_t;
     87 
     88 typedef struct tag_frame_buf_arg {
     89     unsigned int luma;
     90     unsigned int chroma;
     91 } mfc_frame_buf_arg_t;
     92 
     93 typedef struct {
     94     SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type                                              */
     95     int in_width;                        /* [IN] width of YUV420 frame to be encoded                     */
     96     int in_height;                       /* [IN] height of YUV420 frame to be encoded                    */
     97     int in_profile_level;                /* [IN] profile & level                                         */
     98     int in_gop_num;                      /* [IN] GOP Number (interval of I-frame)                        */
     99     int in_frame_qp;                     /* [IN] the quantization parameter of the frame                 */
    100     int in_frame_P_qp;                   /* [IN] the quantization parameter of the P frame               */
    101     int in_frame_B_qp;                   /* [IN] the quantization parameter of the B frame               */
    102 
    103     int in_RC_frm_enable;                /* [IN] RC enable (0:disable, 1:frame level RC)                 */
    104     int in_RC_framerate;                 /* [IN] RC parameter (framerate)                                */
    105     int in_RC_bitrate;                   /* [IN] RC parameter (bitrate in kbps)                          */
    106     int in_RC_qbound;                    /* [IN] RC parameter (Q bound)                                  */
    107     int in_RC_rpara;                     /* [IN] RC parameter (Reaction Coefficient)                     */
    108 
    109     int in_MS_mode;                      /* [IN] Multi-slice mode (0:single, 1:multiple)                 */
    110     int in_MS_size;                      /* [IN] Multi-slice size (in num. of mb or byte)                */
    111     int in_mb_refresh;                   /* [IN] Macroblock refresh                                      */
    112     int in_interlace_mode;               /* [IN] interlace mode(0:progressive, 1:interlace)              */
    113     int in_BframeNum;                    /* [IN] B frame number                                          */
    114 
    115     int in_pad_ctrl_on;                  /* [IN] Enable (1) / Disable (0) padding                        */
    116     int in_luma_pad_val;                 /* [IN] pad value if pad_ctrl_on is Enable                      */
    117     int in_cb_pad_val;
    118     int in_cr_pad_val;
    119 
    120     unsigned int in_mapped_addr;
    121     mfc_strm_ref_buf_arg_t out_u_addr;
    122     mfc_strm_ref_buf_arg_t out_p_addr;
    123     mfc_strm_ref_buf_arg_t out_buf_size;
    124     unsigned int out_header_size;
    125 
    126     /* MPEG4 Only */
    127     int in_qpelME_enable;                /* [IN] Quarter-pel MC enable(1:enable, 0:disable)              */
    128     int in_time_increament_res;          /* [IN] time increment resolution                               */
    129     int in_time_vop_time_increament;     /* [IN] time increment                                          */
    130 } mfc_enc_init_mpeg4_arg_t;
    131 
    132 typedef mfc_enc_init_mpeg4_arg_t mfc_enc_init_h263_arg_t;
    133 
    134 typedef struct {
    135     SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type                                              */
    136     int in_width;                        /* [IN] width  of YUV420 frame to be encoded                    */
    137     int in_height;                       /* [IN] height of YUV420 frame to be encoded                    */
    138     int in_profile_level;                /* [IN] profile & level                                         */
    139     int in_gop_num;                      /* [IN] GOP Number (interval of I-frame)                        */
    140     int in_frame_qp;                     /* [IN] the quantization parameter of the frame                 */
    141     int in_frame_P_qp;                   /* [IN] the quantization parameter of the P frame               */
    142     int in_frame_B_qp;                   /* [IN] the quantization parameter of the B frame               */
    143 
    144     int in_RC_frm_enable;                /* [IN] RC enable (0:disable, 1:frame level RC)                 */
    145     int in_RC_framerate;                 /* [IN]  RC parameter (framerate)                               */
    146     int in_RC_bitrate;                   /* [IN]  RC parameter (bitrate in kbps)                         */
    147     int in_RC_qbound;                    /* [IN]  RC parameter (Q bound)                                 */
    148     int in_RC_rpara;                     /* [IN]  RC parameter (Reaction Coefficient)                    */
    149 
    150     int in_MS_mode;                      /* [IN] Multi-slice mode (0:single, 1:multiple)                 */
    151     int in_MS_size;                      /* [IN] Multi-slice size (in num. of mb or byte)                */
    152     int in_mb_refresh;                   /* [IN] Macroblock refresh                                      */
    153     int in_interlace_mode;               /* [IN] interlace mode(0:progressive, 1:interlace)              */
    154     int in_BframeNum;
    155 
    156     int in_pad_ctrl_on;                  /* [IN] Enable padding control                                  */
    157     int in_luma_pad_val;                 /* [IN] Luma pel value used to fill padding area                */
    158     int in_cb_pad_val;                   /* [IN] CB pel value used to fill padding area                  */
    159     int in_cr_pad_val;                   /* [IN] CR pel value used to fill padding area                  */
    160 
    161     unsigned int in_mapped_addr;
    162     mfc_strm_ref_buf_arg_t out_u_addr;
    163     mfc_strm_ref_buf_arg_t out_p_addr;
    164     mfc_strm_ref_buf_arg_t out_buf_size;
    165     unsigned int out_header_size;
    166 
    167     /* H264 Only */
    168     int in_RC_mb_enable;                 /* [IN] RC enable (0:disable, 1:MB level RC)                    */
    169     int in_reference_num;                /* [IN] The number of reference pictures used                   */
    170     int in_ref_num_p;                    /* [IN] The number of reference pictures used for P pictures    */
    171     int in_RC_mb_dark_disable;           /* [IN] Disable adaptive rate control on dark region            */
    172     int in_RC_mb_smooth_disable;         /* [IN] Disable adaptive rate control on smooth region          */
    173     int in_RC_mb_static_disable;         /* [IN] Disable adaptive rate control on static region          */
    174     int in_RC_mb_activity_disable;       /* [IN] Disable adaptive rate control on static region          */
    175     int in_deblock_filt;                 /* [IN] disable the loop filter                                 */
    176     int in_deblock_alpha_C0;             /* [IN] Alpha & C0 offset for H.264 loop filter                 */
    177     int in_deblock_beta;                 /* [IN] Beta offset for H.264 loop filter                       */
    178     int in_symbolmode;                   /* [IN] The mode of entropy coding(CABAC, CAVLC)                */
    179     int in_transform8x8_mode;            /* [IN] Allow 8x8 transform(only for high profile)              */
    180     int in_md_interweight_pps;           /* [IN] Inter weighted parameter for mode decision              */
    181     int in_md_intraweight_pps;           /* [IN] Intra weighted parameter for mode decision              */
    182 } mfc_enc_init_h264_arg_t;
    183 
    184 typedef struct {
    185     SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN]  codec type                                             */
    186     unsigned int in_Y_addr;              /* [IN]  In-buffer addr of Y component                          */
    187     unsigned int in_CbCr_addr;           /* [IN]  In-buffer addr of CbCr component                       */
    188     unsigned int in_Y_addr_vir;          /* [IN]  In-buffer addr of Y component                          */
    189     unsigned int in_CbCr_addr_vir;       /* [IN]  In-buffer addr of CbCr component                       */
    190     unsigned int in_strm_st;             /* [IN]  Out-buffer start addr of encoded strm                  */
    191     unsigned int in_strm_end;            /* [IN]  Out-buffer end addr of encoded strm                    */
    192     int in_frametag;                     /* [IN]  unique frame ID                                        */
    193 
    194     unsigned int out_frame_type;         /* [OUT] frame type                                             */
    195     int out_encoded_size;                /* [OUT] Length of Encoded video stream                         */
    196     unsigned int out_encoded_Y_paddr;    /* [OUT] physical Y address which is flushed                    */
    197     unsigned int out_encoded_C_paddr;    /* [OUT] physical C address which is flushed                    */
    198     int out_frametag_top;                /* [OUT] unique frame ID of an output frame or top field        */
    199     int out_frametag_bottom;             /* [OUT] unique frame ID of bottom field                        */
    200 } mfc_enc_exe_arg;
    201 
    202 typedef struct {
    203     SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN]  codec type                                             */
    204     unsigned int in_strm_buf;            /* [IN]  the physical address of STRM_BUF                       */
    205     int in_strm_size;                    /* [IN]  size of video stream filled in STRM_BUF                */
    206     int in_packed_PB;                    /* [IN]  Is packed PB frame or not, 1: packedPB  0: unpacked    */
    207 
    208     int out_img_width;                   /* [OUT] width  of YUV420 frame                                 */
    209     int out_img_height;                  /* [OUT] height of YUV420 frame                                 */
    210     int out_buf_width;                   /* [OUT] width  of YUV420 frame                                 */
    211     int out_buf_height;                  /* [OUT] height of YUV420 frame                                 */
    212     int out_dpb_cnt;                     /* [OUT] the number of buffers which is nessary during decoding */
    213 
    214     int out_crop_top_offset;             /* [OUT] crop information, top offset                           */
    215     int out_crop_bottom_offset;          /* [OUT] crop information, bottom offset                        */
    216     int out_crop_left_offset;            /* [OUT] crop information, left offset                          */
    217     int out_crop_right_offset;           /* [OUT] crop information, right offset                         */
    218 
    219     mfc_frame_buf_arg_t in_frm_buf;      /* [IN] the address of dpb FRAME_BUF                            */
    220     mfc_frame_buf_arg_t in_frm_size;     /* [IN] size of dpb FRAME_BUF                                   */
    221     unsigned int in_mapped_addr;
    222 
    223     mfc_frame_buf_arg_t out_u_addr;
    224     mfc_frame_buf_arg_t out_p_addr;
    225     mfc_frame_buf_arg_t out_frame_buf_size;
    226 } mfc_dec_init_arg_t;
    227 
    228 typedef struct {
    229     SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN]  codec type                                             */
    230     unsigned int in_strm_buf;            /* [IN]  the physical address of STRM_BUF                       */
    231     int in_strm_size;                    /* [IN]  Size of video stream filled in STRM_BUF                */
    232     mfc_frame_buf_arg_t in_frm_buf;      /* [IN]  the address of dpb FRAME_BUF                           */
    233     mfc_frame_buf_arg_t in_frm_size;     /* [IN]  size of dpb FRAME_BUF                                  */
    234     int in_frametag;                     /* [IN]  unique frame ID                                        */
    235 
    236     unsigned int out_display_Y_addr;     /* [OUT] the physical address of display buf                    */
    237     unsigned int out_display_C_addr;     /* [OUT] the physical address of display buf                    */
    238     int out_display_status;              /* [OUT] whether display frame exist or not.                    */
    239     int out_timestamp_top;               /* [OUT] presentation time of an output frame or top field      */
    240     int out_timestamp_bottom;            /* [OUT] presentation time of bottom field                      */
    241     int out_consume_bytes;               /* [OUT] consumed bytes when decoding finished                  */
    242     int out_frametag_top;                /* [OUT] unique frame ID of an output frame or top field        */
    243     int out_frametag_bottom;             /* [OUT] unique frame ID of bottom field                        */
    244     int out_res_change;                  /* [OUT] whether resolution is changed or not (0, 1, 2)         */
    245     int out_crop_top_offset;             /* [OUT] crop information, top offset                           */
    246     int out_crop_bottom_offset;          /* [OUT] crop information, bottom offset                        */
    247     int out_crop_left_offset;            /* [OUT] crop information, left offset                          */
    248     int out_crop_right_offset;           /* [OUT] crop information, right offset                         */
    249 } mfc_dec_exe_arg_t;
    250 
    251 typedef struct {
    252     int in_config_param;                 /* [IN]  Configurable parameter type                            */
    253     int out_config_value[4];             /* [IN]  Values to get for the configurable parameter.          */
    254 } mfc_get_config_arg_t;
    255 
    256 typedef struct {
    257     int in_config_param;                 /* [IN]  Configurable parameter type                            */
    258     int in_config_value[2];              /* [IN]  Values to be set for the configurable parameter.       */
    259     int out_config_value_old[2];         /* [OUT] Old values of the configurable parameters              */
    260 } mfc_set_config_arg_t;
    261 
    262 typedef struct tag_get_phys_addr_arg
    263 {
    264     unsigned int u_addr;
    265     unsigned int p_addr;
    266 } mfc_get_phys_addr_arg_t;
    267 
    268 typedef struct tag_mem_alloc_arg
    269 {
    270     SSBSIP_MFC_CODEC_TYPE codec_type;
    271     int buff_size;
    272     unsigned int mapped_addr;
    273     unsigned int out_uaddr;
    274     unsigned int out_paddr;
    275 } mfc_mem_alloc_arg_t;
    276 
    277 typedef struct tag_mem_free_arg_t
    278 {
    279     unsigned int u_addr;
    280 } mfc_mem_free_arg_t;
    281 
    282 typedef union {
    283     mfc_enc_init_mpeg4_arg_t enc_init_mpeg4;
    284     mfc_enc_init_h263_arg_t enc_init_h263;
    285     mfc_enc_init_h264_arg_t enc_init_h264;
    286     mfc_enc_exe_arg enc_exe;
    287 
    288     mfc_dec_init_arg_t dec_init;
    289     mfc_dec_exe_arg_t dec_exe;
    290 
    291     mfc_get_config_arg_t get_config;
    292     mfc_set_config_arg_t set_config;
    293 
    294     mfc_mem_alloc_arg_t mem_alloc;
    295     mfc_mem_free_arg_t mem_free;
    296     mfc_get_phys_addr_arg_t get_phys_addr;
    297 } mfc_args;
    298 
    299 typedef struct tag_mfc_args {
    300     SSBSIP_MFC_ERROR_CODE ret_code; /* [OUT] error code */
    301     mfc_args args;
    302 } mfc_common_args;
    303 
    304 typedef struct {
    305     int magic;
    306     int hMFC;
    307     int width;
    308     int height;
    309     int sizeStrmBuf;
    310     mfc_frame_buf_arg_t sizeFrmBuf;
    311     int displayStatus;
    312     int inter_buff_status;
    313     unsigned int virFreeStrmAddr;
    314     unsigned int phyStrmBuf;
    315     unsigned int virStrmBuf;
    316     unsigned int virMvRefYC;
    317     mfc_frame_buf_arg_t phyFrmBuf;
    318     mfc_frame_buf_arg_t virFrmBuf;
    319     unsigned int mapped_addr;
    320     mfc_common_args MfcArg;
    321     SSBSIP_MFC_CODEC_TYPE codec_type;
    322     SSBSIP_MFC_DEC_OUTPUT_INFO decOutInfo;
    323     unsigned int encodedHeaderSize;
    324     int encodedDataSize;
    325     unsigned int encodedframeType;
    326     int in_frametag;
    327     int out_frametag_top;
    328     int out_frametag_bottom;
    329     unsigned int encoded_Y_paddr;
    330     unsigned int encoded_C_paddr;
    331 } _MFCLIB;
    332 
    333 #endif /* _MFC_INTERFACE_H_ */
    334