1 /* 2 * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 * Authors: 4 * Cerf Yu <cerf.yu@rock-chips.com> 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef _RGA2_DRIVER_COMPAT_IOCTL_H_ 20 #define _RGA2_DRIVER_COMPAT_IOCTL_H_ 21 22 #ifdef __cplusplus 23 extern "C" 24 { 25 #endif 26 27 typedef struct rga2_img_info_t { 28 #if defined(__arm64__) || defined(__aarch64__) 29 unsigned long yrgb_addr; /* yrgb mem addr */ 30 unsigned long uv_addr; /* cb/cr mem addr */ 31 unsigned long v_addr; /* cr mem addr */ 32 #else 33 unsigned int yrgb_addr; /* yrgb mem addr */ 34 unsigned int uv_addr; /* cb/cr mem addr */ 35 unsigned int v_addr; /* cr mem addr */ 36 #endif 37 unsigned int format; //definition by RK_FORMAT 38 unsigned short act_w; 39 unsigned short act_h; 40 unsigned short x_offset; 41 unsigned short y_offset; 42 43 unsigned short vir_w; 44 unsigned short vir_h; 45 46 unsigned short endian_mode; //for BPP 47 unsigned short alpha_swap; 48 } rga2_img_info_t; 49 50 typedef struct rga2_rect { 51 unsigned short xmin; 52 unsigned short xmax; // width - 1 53 unsigned short ymin; 54 unsigned short ymax; // height - 1 55 } rga2_rect_t; 56 57 typedef struct rga2_color_fill { 58 short gr_x_a; 59 short gr_y_a; 60 short gr_x_b; 61 short gr_y_b; 62 short gr_x_g; 63 short gr_y_g; 64 short gr_x_r; 65 short gr_y_r; 66 67 //u8 cp_gr_saturation; 68 } rga2_color_fill_t; 69 70 typedef struct rga2_point { 71 unsigned short x; 72 unsigned short y; 73 } rga2_point_t; 74 75 typedef struct rga2_line_draw { 76 rga2_point_t start_point; /* LineDraw_start_point */ 77 rga2_point_t end_point; /* LineDraw_end_point */ 78 unsigned int color; /* LineDraw_color */ 79 unsigned int flag; /* (enum) LineDrawing mode sel */ 80 unsigned int line_width; /* range 1~16 */ 81 } rga2_line_draw_t; 82 83 typedef struct rga2_fading { 84 unsigned char b; 85 unsigned char g; 86 unsigned char r; 87 unsigned char res; 88 } rga2_fading_t; 89 90 typedef struct rga2_mmu { 91 unsigned char mmu_en; 92 #if defined(__arm64__) || defined(__aarch64__) 93 unsigned long base_addr; 94 #else 95 unsigned int base_addr; 96 #endif 97 unsigned int mmu_flag; /* [0] mmu enable [1] src_flush [2] dst_flush [3] CMD_flush [4~5] page size*/ 98 } rga2_mmu_t; 99 100 /* color space convert coefficient. */ 101 typedef struct rga2_csc_coe { 102 int16_t r_v; 103 int16_t g_y; 104 int16_t b_u; 105 int32_t off; 106 } rga2_csc_coe_t; 107 108 typedef struct rga2_full_csc { 109 unsigned char flag; 110 rga2_csc_coe_t coe_y; 111 rga2_csc_coe_t coe_u; 112 rga2_csc_coe_t coe_v; 113 } rga2_full_csc_t; 114 115 struct rga2_req { 116 unsigned char render_mode; /* (enum) process mode sel */ 117 118 rga2_img_info_t src; /* src image info */ 119 rga2_img_info_t dst; /* dst image info */ 120 rga2_img_info_t pat; /* patten image info */ 121 122 #if defined(__arm64__) || defined(__aarch64__) 123 unsigned long rop_mask_addr; /* rop4 mask addr */ 124 unsigned long LUT_addr; /* LUT addr */ 125 #else 126 unsigned int rop_mask_addr; /* rop4 mask addr */ 127 unsigned int LUT_addr; /* LUT addr */ 128 #endif 129 130 rga2_rect_t clip; /* dst clip window default value is dst_vir */ 131 /* value from [0, w-1] / [0, h-1]*/ 132 133 int sina; /* dst angle default value 0 16.16 scan from table */ 134 int cosa; /* dst angle default value 0 16.16 scan from table */ 135 136 unsigned short alpha_rop_flag; /* alpha rop process flag */ 137 /* ([0] = 1 alpha_rop_enable) */ 138 /* ([1] = 1 rop enable) */ 139 /* ([2] = 1 fading_enable) */ 140 /* ([3] = 1 PD_enable) */ 141 /* ([4] = 1 alpha cal_mode_sel) */ 142 /* ([5] = 1 dither_enable) */ 143 /* ([6] = 1 gradient fill mode sel) */ 144 /* ([7] = 1 AA_enable) */ 145 /* ([8] = 1 nn_quantize) */ 146 /* ([9] = 1 Real color mode) */ 147 148 unsigned char scale_mode; /* 0 nearst / 1 bilnear / 2 bicubic */ 149 150 unsigned int color_key_max; /* color key max */ 151 unsigned int color_key_min; /* color key min */ 152 153 unsigned int fg_color; /* foreground color */ 154 unsigned int bg_color; /* background color */ 155 156 rga2_color_fill_t gr_color; /* color fill use gradient */ 157 158 rga2_line_draw_t line_draw_info; 159 160 rga2_fading_t fading; 161 162 unsigned char PD_mode; /* porter duff alpha mode sel */ 163 164 unsigned char alpha_global_value; /* global alpha value */ 165 166 unsigned short rop_code; /* rop2/3/4 code scan from rop code table*/ 167 168 unsigned char bsfilter_flag; /* [2] 0 blur 1 sharp / [1:0] filter_type*/ 169 170 unsigned char palette_mode; /* (enum) color palatte 0/1bpp, 1/2bpp 2/4bpp 3/8bpp*/ 171 172 unsigned char yuv2rgb_mode; /* (enum) BT.601 MPEG / BT.601 JPEG / BT.709 */ 173 174 unsigned char endian_mode; /* 0/big endian 1/little endian*/ 175 176 unsigned char rotate_mode; /* (enum) rotate mode */ 177 /* 0x0, no rotate */ 178 /* 0x1, rotate */ 179 /* 0x2, x_mirror */ 180 /* 0x3, y_mirror */ 181 182 unsigned char color_fill_mode; /* 0 solid color / 1 patten color */ 183 184 rga2_mmu_t mmu_info; /* mmu information */ 185 186 unsigned char alpha_rop_mode; /* ([0~1] alpha mode) */ 187 /* ([2~3] rop mode) */ 188 /* ([4] zero mode en) */ 189 /* ([5] dst alpha mode) (RGA1) */ 190 191 unsigned char src_trans_mode; 192 193 unsigned char dither_mode; 194 195 rga2_full_csc_t full_csc; /* full color space convert */ 196 197 unsigned char CMD_fin_int_enable; 198 199 /* completion is reported through a callback */ 200 void (*complete)(int retval); 201 }; 202 203 #ifdef __cplusplus 204 } 205 #endif 206 207 #endif /* _RGA2_DRIVER_COMPATIBLE_IOCTL_H_ */