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 __MPP_RGA_H__ 18 #define __MPP_RGA_H__ 19 20 /* NOTE: RGA support sync mode and async mode. We use sync mode only. */ 21 #define RGA_BLIT_SYNC 0x5017 22 #define RGA_BLIT_ASYNC 0x5018 23 #define RGA_FLUSH 0x5019 24 #define RGA_GET_RESULT 0x501a 25 26 typedef enum RgaFormat_e { 27 RGA_FMT_RGBA_8888 = 0x0, 28 RGA_FMT_RGBX_8888 = 0x1, 29 RGA_FMT_RGB_888 = 0x2, 30 RGA_FMT_BGRA_8888 = 0x3, 31 RGA_FMT_RGB_565 = 0x4, 32 RGA_FMT_RGBA_5551 = 0x5, 33 RGA_FMT_RGBA_4444 = 0x6, 34 RGA_FMT_BGR_888 = 0x7, 35 36 RGA_FMT_YCbCr_422_SP = 0x8, 37 RGA_FMT_YCbCr_422_P = 0x9, 38 RGA_FMT_YCbCr_420_SP = 0xa, 39 RGA_FMT_YCbCr_420_P = 0xb, 40 41 RGA_FMT_YCrCb_422_SP = 0xc, 42 RGA_FMT_YCrCb_422_P = 0xd, 43 RGA_FMT_YCrCb_420_SP = 0xe, 44 RGA_FMT_YCrCb_420_P = 0xf, 45 46 RGA_FMT_BPP1 = 0x10, 47 RGA_FMT_BPP2 = 0x11, 48 RGA_FMT_BPP4 = 0x12, 49 RGA_FMT_BPP8 = 0x13, 50 RGA_FMT_BUTT, 51 } RgaFormat; 52 53 typedef struct RgaImg_t { 54 RK_ULONG yrgb_addr; /* yrgb addr */ 55 RK_ULONG uv_addr; /* cb/cr addr */ 56 RK_ULONG v_addr; /* cr addr */ 57 RK_U32 format; // definition by RgaFormat 58 59 RK_U16 act_w; // width 60 RK_U16 act_h; // height 61 RK_U16 x_offset; // offset from left 62 RK_U16 y_offset; // offset from top 63 64 RK_U16 vir_w; // horizontal stride 65 RK_U16 vir_h; // vertical stride 66 67 RK_U16 endian_mode; // for BPP 68 RK_U16 alpha_swap; 69 } RgaImg; 70 71 typedef struct RgaRect_t { 72 RK_U16 xmin; 73 RK_U16 xmax; 74 RK_U16 ymin; 75 RK_U16 ymax; 76 } RgaRect; 77 78 typedef struct RgaPoint_t { 79 RK_U16 x; 80 RK_U16 y; 81 } RgaPoint; 82 83 typedef struct RgaColorFill_t { 84 RK_S16 gr_x_a; 85 RK_S16 gr_y_a; 86 RK_S16 gr_x_b; 87 RK_S16 gr_y_b; 88 RK_S16 gr_x_g; 89 RK_S16 gr_y_g; 90 RK_S16 gr_x_r; 91 RK_S16 gr_y_r; 92 } RgaColorFill; 93 94 typedef struct RgaLineDraw_t { 95 RgaPoint start_point; 96 RgaPoint end_point; 97 RK_U32 color; 98 RK_U32 flag; 99 RK_U32 line_width; 100 } RgaLineDraw; 101 102 typedef struct RgaFading_t { 103 RK_U8 b; 104 RK_U8 g; 105 RK_U8 r; 106 RK_U8 res; 107 } RgaFading; 108 109 typedef struct RgaMmu_t { 110 RK_U8 mmu_en; 111 RK_ULONG base_addr; 112 RK_U32 mmu_flag; 113 } RgaMmu; 114 115 // structure for userspace / kernel communication 116 typedef struct RgaRequest_t { 117 RK_U8 render_mode; 118 119 RgaImg src; 120 RgaImg dst; 121 RgaImg pat; 122 123 RK_ULONG rop_mask_addr; /* rop4 mask addr */ 124 RK_ULONG LUT_addr; /* LUT addr */ 125 126 RgaRect clip; /* dst clip window default value is dst_vir */ 127 /* value from [0, w-1] / [0, h-1]*/ 128 129 RK_S32 sina; /* dst angle default value 0 16.16 scan from table */ 130 RK_S32 cosa; /* dst angle default value 0 16.16 scan from table */ 131 132 /* alpha rop process flag */ 133 /* ([0] = 1 alpha_rop_enable) */ 134 /* ([1] = 1 rop enable) */ 135 /* ([2] = 1 fading_enable) */ 136 /* ([3] = 1 PD_enable) */ 137 /* ([4] = 1 alpha cal_mode_sel) */ 138 /* ([5] = 1 dither_enable) */ 139 /* ([6] = 1 gradient fill mode sel) */ 140 /* ([7] = 1 AA_enable) */ 141 RK_U16 alpha_rop_flag; 142 RK_U8 scale_mode; /* 0 nearst / 1 bilnear / 2 bicubic */ 143 144 RK_U32 color_key_max; /* color key max */ 145 RK_U32 color_key_min; /* color key min */ 146 147 RK_U32 fg_color; /* foreground color */ 148 RK_U32 bg_color; /* background color */ 149 150 RgaColorFill gr_color; /* color fill use gradient */ 151 152 RgaLineDraw line_draw_info; 153 154 RgaFading fading; 155 156 RK_U8 PD_mode; /* porter duff alpha mode sel */ 157 RK_U8 alpha_global_value; /* global alpha value */ 158 RK_U16 rop_code; /* rop2/3/4 code scan from rop code table*/ 159 RK_U8 bsfilter_flag; /* [2] 0 blur 1 sharp / [1:0] filter_type*/ 160 RK_U8 palette_mode; /* (enum) color palatte 0/1bpp, 1/2bpp 2/4bpp 3/8bpp */ 161 RK_U8 yuv2rgb_mode; /* (enum) BT.601 MPEG / BT.601 JPEG / BT.709 */ 162 RK_U8 endian_mode; 163 164 /* (enum) rotate mode */ 165 /* 0x0, no rotate */ 166 /* 0x1, rotate */ 167 /* 0x2, x_mirror */ 168 /* 0x3, y_mirror */ 169 RK_U8 rotate_mode; 170 171 RK_U8 color_fill_mode; /* 0 solid color / 1 patten color */ 172 173 RgaMmu mmu_info; /* mmu information */ 174 175 /* ([0~1] alpha mode) */ 176 /* ([2~3] rop mode) */ 177 /* ([4] zero mode en) */ 178 /* ([5] dst alpha mode) */ 179 RK_U8 alpha_rop_mode; 180 RK_U8 src_trans_mode; 181 RK_U8 CMD_fin_int_enable; 182 183 /* completion is reported through a callback */ 184 void (*complete)(int retval); 185 } RgaReq; 186 187 #endif // __MPP_RGA_H__ 188