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 /* This header is for communication between userspace driver and kernel driver */ 18 19 #ifndef __IEP_H__ 20 #define __IEP_H__ 21 22 #include <sys/ioctl.h> 23 #include "rk_type.h" 24 25 /* Capability for current iep version using by userspace to determine iep features */ 26 typedef struct IepHwCap_t { 27 RK_U8 scaling_supported; 28 RK_U8 i4_deinterlace_supported; 29 RK_U8 i2_deinterlace_supported; 30 RK_U8 compression_noise_reduction_supported; 31 RK_U8 sampling_noise_reduction_supported; 32 RK_U8 hsb_enhancement_supported; 33 RK_U8 cg_enhancement_supported; 34 RK_U8 direct_path_supported; 35 RK_U16 max_dynamic_width; 36 RK_U16 max_dynamic_height; 37 RK_U16 max_static_width; 38 RK_U16 max_static_height; 39 RK_U8 max_enhance_radius; 40 } IepHwCap; 41 42 #define IEP_IOC_MAGIC 'i' 43 44 #define IEP_SET_PARAMETER_REQ _IOW(IEP_IOC_MAGIC, 1, unsigned long) 45 #define IEP_SET_PARAMETER_DEINTERLACE _IOW(IEP_IOC_MAGIC, 2, unsigned long) 46 #define IEP_SET_PARAMETER_ENHANCE _IOW(IEP_IOC_MAGIC, 3, unsigned long) 47 #define IEP_SET_PARAMETER_CONVERT _IOW(IEP_IOC_MAGIC, 4, unsigned long) 48 #define IEP_SET_PARAMETER_SCALE _IOW(IEP_IOC_MAGIC, 5, unsigned long) 49 #define IEP_GET_RESULT_SYNC _IOW(IEP_IOC_MAGIC, 6, unsigned long) 50 #define IEP_GET_RESULT_ASYNC _IOW(IEP_IOC_MAGIC, 7, unsigned long) 51 #define IEP_SET_PARAMETER _IOW(IEP_IOC_MAGIC, 8, unsigned long) 52 #define IEP_RELEASE_CURRENT_TASK _IOW(IEP_IOC_MAGIC, 9, unsigned long) 53 #define IEP_GET_IOMMU_STATE _IOR(IEP_IOC_MAGIC, 10, unsigned long) 54 #define IEP_QUERY_CAP _IOR(IEP_IOC_MAGIC, 11, IepHwCap) 55 56 enum { 57 DEI_MODE_BYPASS_DIS = 0x0, 58 DEI_MODE_I4O2 = 0x1, 59 DEI_MODE_I4O1B = 0x2, 60 DEI_MODE_I4O1T = 0x3, 61 DEI_MODE_I2O1B = 0x4, 62 DEI_MODE_I2O1T = 0x5, 63 DEI_MODE_BYPASS = 0x6, 64 }; 65 66 // for rgb_enhance_mode 67 enum { 68 RGB_ENHANCE_BYPASS = 0x0, 69 RGB_ENHANCE_DENOISE = 0x1, 70 RGB_ENHANCE_DETAIL = 0x2, 71 RGB_ENHANCE_EDGE = 0x3, 72 }; 73 74 // for rgb_contrast_enhance_mode 75 enum { 76 RGB_CONTRAST_CC_P_DDE = 0x0, // cg prior to dde 77 RGB_CONTRAST_DDE_P_CC = 0x1, // dde prior to cg 78 }; 79 80 // for video mode 81 enum { 82 BLACK_SCREEN = 0x0, 83 BLUE_SCREEN = 0x1, 84 COLOR_BAR = 0x2, 85 NORMAL_MODE = 0x3, 86 }; 87 88 /* 89 // Alpha Red Green Blue 90 { 4, 32, {{32,24, 24,16, 16, 8, 8, 0 }}, GGL_RGBA }, // IEP_FORMAT_ARGB_8888 91 { 4, 32, {{32,24, 8, 0, 16, 8, 24,16 }}, GGL_RGB }, // IEP_FORMAT_ABGR_8888 92 { 4, 32, {{ 8, 0, 32,24, 24,16, 16, 8 }}, GGL_RGB }, // IEP_FORMAT_RGBA_8888 93 { 4, 32, {{ 8, 0, 16, 8, 24,16, 32,24 }}, GGL_BGRA }, // IEP_FORMAT_BGRA_8888 94 { 2, 16, {{ 0, 0, 16,11, 11, 5, 5, 0 }}, GGL_RGB }, // IEP_FORMAT_RGB_565 95 { 2, 16, {{ 0, 0, 5, 0, 11, 5, 16,11 }}, GGL_RGB }, // IEP_FORMAT_RGB_565 96 */ 97 98 // for hardware format value 99 enum { 100 IEP_MSG_FMT_ARGB_8888 = 0x0, 101 IEP_MSG_FMT_ABGR_8888 = 0x1, 102 IEP_MSG_FMT_RGBA_8888 = 0x2, 103 IEP_MSG_FMT_BGRA_8888 = 0x3, 104 IEP_MSG_FMT_RGB_565 = 0x4, 105 IEP_MSG_FMT_BGR_565 = 0x5, 106 107 IEP_MSG_FMT_YCbCr_422_SP = 0x10, 108 IEP_MSG_FMT_YCbCr_422_P = 0x11, 109 IEP_MSG_FMT_YCbCr_420_SP = 0x12, 110 IEP_MSG_FMT_YCbCr_420_P = 0x13, 111 IEP_MSG_FMT_YCrCb_422_SP = 0x14, 112 IEP_MSG_FMT_YCrCb_422_P = 0x15, // same as IEP_FORMAT_YCbCr_422_P 113 IEP_MSG_FMT_YCrCb_420_SP = 0x16, 114 IEP_MSG_FMT_YCrCb_420_P = 0x17, // same as IEP_FORMAT_YCbCr_420_P 115 }; 116 117 /* 118 * + <--------------+ virtual width +------------> + 119 * | | 120 * +-------------------------------------------------+---+---+ 121 * | | ^ 122 * | + <---+ actual width +--> + | | 123 * | | | | | 124 * | +---------------------------+---+--+ | | 125 * | | | ^ | + 126 * | | | + | virtual 127 * | | | actual | height 128 * | | | height | + 129 * | | | + | | 130 * | | | ^ | | 131 * | +---------------------------+---+--+ | | 132 * | | ^ 133 * +-------------------------------------------------+---+---+ 134 */ 135 // NOTE: This is for kernel driver communication. keep it for compatibility 136 typedef struct IepMsgImg_t { 137 RK_U16 act_w; // act_width 138 RK_U16 act_h; // act_height 139 RK_S16 x_off; // x offset for the vir,word unit 140 RK_S16 y_off; // y offset for the vir,word unit 141 142 RK_U16 vir_w; // unit :pix 143 RK_U16 vir_h; // unit :pix 144 RK_U32 format; 145 RK_U32 mem_addr; 146 RK_U32 uv_addr; 147 RK_U32 v_addr; 148 149 RK_U8 rb_swap; // not be used 150 RK_U8 uv_swap; // not be used 151 152 RK_U8 alpha_swap; // not be used 153 } IepMsgImg; 154 155 typedef struct IepMsg_t { 156 IepMsgImg src; // src active window 157 IepMsgImg dst; // src virtual window 158 159 IepMsgImg src1; 160 IepMsgImg dst1; 161 162 IepMsgImg src_itemp; 163 IepMsgImg src_ftemp; 164 165 IepMsgImg dst_itemp; 166 IepMsgImg dst_ftemp; 167 168 RK_U8 dither_up_en; 169 RK_U8 dither_down_en; //not to be used 170 171 RK_U8 yuv2rgb_mode; 172 RK_U8 rgb2yuv_mode; 173 174 RK_U8 global_alpha_value; 175 176 RK_U8 rgb2yuv_clip_en; 177 RK_U8 yuv2rgb_clip_en; 178 179 RK_U8 lcdc_path_en; 180 RK_S32 off_x; 181 RK_S32 off_y; 182 RK_S32 width; 183 RK_S32 height; 184 RK_S32 layer; 185 186 RK_U8 yuv_3D_denoise_en; 187 188 /// yuv color enhance 189 RK_U8 yuv_enhance_en; 190 RK_S32 sat_con_int; 191 RK_S32 contrast_int; 192 RK_S32 cos_hue_int; 193 RK_S32 sin_hue_int; 194 RK_S8 yuv_enh_brightness; // -32 < brightness < 31 195 RK_U8 video_mode; // 0 ~ 3 196 RK_U8 color_bar_y; // 0 ~ 127 197 RK_U8 color_bar_u; // 0 ~ 127 198 RK_U8 color_bar_v; // 0 ~ 127 199 200 201 RK_U8 rgb_enhance_en; // I don't know its usage 202 203 RK_U8 rgb_color_enhance_en; // sw_rgb_color_enh_en 204 RK_U32 rgb_enh_coe; 205 206 RK_U8 rgb_enhance_mode; // sw_rgb_enh_sel,dde sel 207 208 RK_U8 rgb_cg_en; // sw_rgb_con_gam_en 209 RK_U32 cg_tab[192]; 210 211 // sw_con_gam_order; 0 cg prior to dde, 1 dde prior to cg 212 RK_U8 rgb_contrast_enhance_mode; 213 214 RK_S32 enh_threshold; 215 RK_S32 enh_alpha; 216 RK_S32 enh_radius; 217 218 RK_U8 scale_up_mode; 219 220 RK_U8 field_order; 221 RK_U8 dein_mode; 222 //DIL High Frequency 223 RK_U8 dein_high_fre_en; 224 RK_U8 dein_high_fre_fct; 225 //DIL EI 226 RK_U8 dein_ei_mode; 227 RK_U8 dein_ei_smooth; 228 RK_U8 dein_ei_sel; 229 RK_U8 dein_ei_radius; // when dein_ei_sel=0 will be used 230 231 RK_U8 dil_mtn_tbl_en; 232 RK_U32 dil_mtn_tbl[8]; 233 234 RK_U8 vir_addr_enable; 235 236 void *base; 237 } IepMsg; 238 239 #endif /* __IEP_H__ */ 240