1 /* 2 * Copyright (c) 2022 Unionman Technology Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef GE2D_PORT_H_ 17 #define GE2D_PORT_H_ 18 19 #define ge2d_fail (-1) 20 #define ge2d_success (0) 21 22 #define OSD0 (0) 23 #define OSD1 (1) 24 25 #define SRC1_GB_ALPHA_ENABLE (0x80000000) 26 27 #ifdef __DEBUG 28 #define D_GE2D(fmt, args...) printf(fmt, ## args) 29 #else 30 #define D_GE2D(fmt, args...) 31 #endif 32 #define E_GE2D(fmt, args...) printf(fmt, ## args) 33 34 #if defined (__cplusplus) 35 extern "C" { 36 #endif 37 38 #define GE2D_MAX_PLANE (4) 39 40 enum GE2DCanvas { 41 GE2D_CANVAS_OSD0 = 0, 42 GE2D_CANVAS_OSD1, 43 GE2D_CANVAS_ALLOC, 44 GE2D_CANVAS_TYPE_INVALID, 45 }; 46 47 enum GE2DMemtype { 48 GE2D_MEM_ION, 49 GE2D_MEM_DMABUF, 50 GE2D_MEM_INVALID, 51 }; 52 53 enum GE2DLayerMode { 54 GE2D_LAYER_MODE_INVALID = 0, 55 GE2D_LAYER_MODE_NON = 1, 56 GE2D_LAYER_MODE_PREMULTIPLIED = 2, 57 GE2D_LAYER_MODE_COVERAGE = 3, 58 }; 59 60 /* Blend modes, settable per layer */ 61 enum GE2DBlendMode { 62 GE2D_BLEND_MODE_INVALID = 0, 63 64 /* colorOut = colorSrc */ 65 GE2D_BLEND_MODE_NONE = 1, 66 67 /* colorOut = colorSrc + colorDst * (1 - alphaSrc) */ 68 GE2D_BLEND_MODE_PREMULTIPLIED = 2, 69 70 /* colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc) */ 71 GE2D_BLEND_MODE_COVERAGE = 3, 72 }; 73 74 /** 75 * pixel format definitions, export from android graphics.h 76 */ 77 enum GE2DPixelFormat { 78 GE2D_PIXEL_FORMAT_INVALID = 0, 79 GE2D_PIXEL_FORMAT_RGBA_8888 = 1, 80 GE2D_PIXEL_FORMAT_RGBX_8888 = 2, 81 GE2D_PIXEL_FORMAT_RGB_888 = 3, 82 GE2D_PIXEL_FORMAT_RGB_565 = 4, 83 GE2D_PIXEL_FORMAT_BGRA_8888 = 5, 84 GE2D_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar YYYYUV,actually is is YU12 85 GE2D_PIXEL_FORMAT_Y8 = 0x20203859, // YYYY 86 GE2D_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16 YYYY.....UVUV 87 GE2D_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21 YCrCb YYYY.....VU 88 GE2D_PIXEL_FORMAT_YCbCr_422_UYVY = 0x14, // UYVY U0-Y0-V0-Y1 U2-Y2-V2-Y3 U4 89 GE2D_PIXEL_FORMAT_BGR_888, 90 GE2D_PIXEL_FORMAT_YCbCr_420_SP_NV12, // NV12 YCbCr YYYY.....UV 91 }; 92 93 /* if customized matrix is used, set this flag in format */ 94 #define MATRIX_CUSTOM (0x80000000) 95 96 enum GE2DRotation { 97 GE2D_ROTATION_0, 98 GE2D_ROTATION_90, 99 GE2D_ROTATION_180, 100 GE2D_ROTATION_270, 101 }; 102 103 enum GE2DOP { 104 GE2D_OP_FILLRECTANGLE, 105 GE2D_OP_BLEND, 106 GE2D_OP_STRETCHBLIT, 107 GE2D_OP_BLIT, 108 GE2D_OP_NONE, 109 }; 110 111 typedef struct { 112 int x; 113 int y; 114 int w; 115 int h; 116 } rectangle_t; 117 118 typedef struct buffer_info { 119 unsigned int mem_alloc_type; 120 unsigned int memtype; 121 char* vaddr[GE2D_MAX_PLANE]; 122 unsigned long offset[GE2D_MAX_PLANE]; 123 unsigned int canvas_w; 124 unsigned int canvas_h; 125 rectangle_t rect; 126 int format; 127 unsigned int rotation; 128 int shared_fd[GE2D_MAX_PLANE]; 129 unsigned char plane_alpha; 130 unsigned char layer_mode; 131 unsigned char fill_color_en; 132 unsigned int def_color; 133 int plane_number; 134 } buffer_info_t; 135 136 struct ge2d_matrix_s { 137 unsigned int pre_offset0; 138 unsigned int pre_offset1; 139 unsigned int pre_offset2; 140 unsigned int coef0; 141 unsigned int coef1; 142 unsigned int coef2; 143 unsigned int coef3; 144 unsigned int coef4; 145 unsigned int coef5; 146 unsigned int coef6; 147 unsigned int coef7; 148 unsigned int coef8; 149 unsigned int offset0; 150 unsigned int offset1; 151 unsigned int offset2; 152 /* input y/cb/cr saturation enable */ 153 unsigned char sat_in_en; 154 }; 155 156 typedef struct aml_ge2d_info { 157 int ge2d_fd; /* ge2d_fd */ 158 int ion_fd; /* ion_fd, no use */ 159 unsigned int offset; 160 unsigned int blend_mode; 161 enum GE2DOP ge2d_op; 162 buffer_info_t src_info[2]; 163 buffer_info_t dst_info; 164 unsigned int color; 165 unsigned int gl_alpha; 166 unsigned int const_color; 167 /* means do multi ge2d op */ 168 unsigned int dst_op_cnt; 169 int cap_attr; 170 int b_src_swap; 171 struct ge2d_matrix_s matrix_custom; 172 unsigned int reserved; 173 } aml_ge2d_info_t; 174 175 int ge2d_open(void); 176 int ge2d_close(int fd); 177 int ge2d_get_cap(int fd); 178 int ge2d_process(int fd, aml_ge2d_info_t *pge2dinfo); 179 int ge2d_process_ion(int fd, aml_ge2d_info_t *pge2dinfo); 180 181 #if defined (__cplusplus) 182 } 183 #endif 184 185 #endif 186