xref: /rockchip-linux_mpp/mpp/vproc/inc/iep_api.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  * Copyright 2015 Rockchip 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 __IEP_API_H__
18 #define __IEP_API_H__
19 
20 #include "rk_type.h"
21 #include "mpp_err.h"
22 
23 #include "iep_common.h"
24 
25 /*
26  * IepCmdParamSetSrc is parameter for:
27  * IEP_CMD_SET_SRC
28  * IEP_CMD_SET_DST
29  * IEP_CMD_SET_DEI_SRC1
30  * IEP_CMD_SET_DEI_DST1
31  */
32 typedef struct IepCmdParamImage_t {
33     IepImg  image;
34 } IepCmdParamImage;
35 
36 typedef enum IepDeiMode_e {
37     IEP_DEI_MODE_DISABLE,
38     IEP_DEI_MODE_I2O1,
39     IEP_DEI_MODE_I4O1,
40     IEP_DEI_MODE_I4O2,
41     IEP_DEI_MODE_BYPASS,
42     IEP_DEI_MODE_BUTT,
43 } IepDeiMode;
44 
45 typedef enum IepDeiFldOrder {
46     IEP_DEI_FLD_ORDER_TOP_FIRST,
47     IEP_DEI_FLD_ORDER_BOT_FIRST,
48     IEP_DEI_FLD_ORDER_BUTT,
49 } IepDeiFldOrder;
50 
51 /* IepCmdParamDeiCfg is parameter for IEP_CMD_SET_DEI_CFG */
52 typedef struct IepCmdParamDeiCfg_t {
53     IepDeiMode      dei_mode;
54     IepDeiFldOrder  dei_field_order;
55 
56     RK_U32          dei_high_freq_en;
57     RK_U32          dei_high_freq_fct;  // [0, 127]
58 
59     RK_U32          dei_ei_mode;        // deinterlace edge interpolation 0: disable, 1: enable
60     RK_U32          dei_ei_smooth;      // deinterlace edge interpolation for smooth effect 0: disable, 1: enable
61     RK_U32          dei_ei_sel;         // deinterlace edge interpolation select
62     RK_U32          dei_ei_radius;      // deinterlace edge interpolation radius [0, 3]
63 } IepCmdParamDeiCfg;
64 
65 typedef enum IepVideoMode_e {
66     IEP_VIDEO_MODE_BLACK_SCREEN,
67     IEP_VIDEO_MODE_BLUE_SCREEN,
68     IEP_VIDEO_MODE_COLOR_BAR,
69     IEP_VIDEO_MODE_NORMAL_VIDEO
70 } IepVideoMode;
71 
72 /* IepCmdParamYuvEnhance is parameter for IEP_CMD_SET_YUV_ENHANCE */
73 typedef struct IepCmdParamYuvEnhance_t {
74     float           saturation;         // [0, 1.992]
75     float           contrast;           // [0, 1.992]
76     RK_S8           brightness;         // [-32, 31]
77     float           hue_angle;          // [-30, 30]
78     IepVideoMode    video_mode;
79     RK_U8           color_bar_y;        // [0, 127]
80     RK_U8           color_bar_u;        // [0, 127]
81     RK_U8           color_bar_v;        // [0, 127]
82 } IepCmdParamYuvEnhance;
83 
84 typedef enum IepRgbEnhanceMode_e {
85     IEP_RGB_ENHANCE_MODE_NO_OPERATION,
86     IEP_RGB_ENHANCE_MODE_DENOISE,
87     IEP_RGB_ENHANCE_MODE_DETAIL_ENHANCE,
88     IEP_RGB_ENHANCE_MODE_EDGE_ENHANCE
89 } IepRgbEnhanceMode;
90 
91 typedef enum IepRgbEnhanceOrder_e {
92     IEP_RGB_ENHANCE_ORDER_CG_DDE,       // CG(Contrast & Gammar) prior to DDE (De-noise, Detail & Edge Enhance)
93     IEP_RGB_ENHANCE_ORDER_DDE_CG        // DDE prior to CG
94 } IepRgbEnhanceOrder;
95 
96 /* IepCmdParamRgbEnhance is parameter for IEP_CMD_SET_RGB_ENHANCE */
97 typedef struct IepCmdParamRgbEnhance {
98     float               coe;            // [0, 3.96875]
99     IepRgbEnhanceMode   mode;
100     RK_U8               cg_en;          // sw_rgb_con_gam_en
101     double              cg_rr;
102     double              cg_rg;
103     double              cg_rb;
104     IepRgbEnhanceOrder  order;
105 
106     /// more than this value considered as detail, and less than this value considered as noise.
107     RK_S32              threshold;      // [0, 255]
108 
109     /// combine the original pixel and enhanced pixel
110     /// if (enh_alpha_num / enh_alpha_base <= 1 ) enh_alpha_base = 8, else enh_alpha_base = 4
111     /// (1/8 ... 8/8) (5/4 ... 24/4)
112     RK_S32              alpha_num;      // [0, 24]
113     RK_S32              alpha_base;     // {4, 8}
114     RK_S32              radius;         // [1, 4]
115 } IepCmdParamRgbEnhance;
116 
117 typedef enum IepScaleAlg_e {
118     IEP_SCALE_ALG_HERMITE,
119     IEP_SCALE_ALG_SPLINE,
120     IEP_SCALE_ALG_CATROM,
121     IEP_SCALE_ALG_MITCHELL
122 } IepScaleAlg;
123 
124 /* IepCmdParamScale is parameter for IEP_CMD_SET_SCALE */
125 typedef struct IepCmdParamScale_t {
126     IepScaleAlg         scale_alg;
127 } IepCmdParamScale;
128 
129 typedef enum IepColorConvertMode_e {
130     IEP_COLOR_MODE_BT601_L,
131     IEP_COLOR_MODE_BT601_F,
132     IEP_COLOR_MODE_BT709_L,
133     IEP_COLOR_MODE_BT709_F
134 } IepColorConvertMode;
135 
136 /* IepCmdParamColorConvert is parameter for IEP_CMD_SET_COLOR_CONVERT */
137 typedef struct IepCmdParamColorConvert_t {
138     IepColorConvertMode rgb2yuv_mode;
139     IepColorConvertMode yuv2rgb_mode;
140     RK_U8               rgb2yuv_input_clip; // 0:R/G/B [0, 255], 1:R/G/B [16, 235]
141     RK_U8               yuv2rgb_input_clip; // 0:Y/U/V [0, 255], 1:Y [16, 235] U/V [16, 240]
142     RK_U8               global_alpha_value; // global alpha value for output ARGB
143     RK_U8               dither_up_en;
144     RK_U8               dither_down_en;
145 } IepCmdParamColorConvert;
146 
147 /* IepCap is parameter for IEP_CMD_QUERY_CAP */
148 typedef struct IepCap_t {
149     RK_U8   scaling_supported;
150     RK_U8   i4_deinterlace_supported;
151     RK_U8   i2_deinterlace_supported;
152     RK_U8   compression_noise_reduction_supported;
153     RK_U8   sampling_noise_reduction_supported;
154     RK_U8   hsb_enhancement_supported;
155     RK_U8   cg_enhancement_supported;
156     RK_U8   direct_path_supported;
157     RK_U16  max_dynamic_width;
158     RK_U16  max_dynamic_height;
159     RK_U16  max_static_width;
160     RK_U16  max_static_height;
161     RK_U8   max_enhance_radius;
162 } IepCap;
163 
164 typedef void* IepCtx;
165 
166 #ifdef __cplusplus
167 extern "C" {
168 #endif
169 
170 MPP_RET iep_init(IepCtx *ctx);
171 MPP_RET iep_deinit(IepCtx ctx);
172 MPP_RET iep_control(IepCtx ctx, IepCmd cmd, void *param);
173 
174 iep_com_ctx* rockchip_iep_api_alloc_ctx(void);
175 void rockchip_iep_api_release_ctx(iep_com_ctx *com_ctx);
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif /* __IEP_API_H__ */
182