1 /* 2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 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 HI_GO_GDEV_H 17 #define HI_GO_GDEV_H 18 19 #include "hi_go_comm.h" 20 #include "hi_go_surface.h" 21 22 #ifdef __cplusplus 23 #if __cplusplus 24 extern "C" { 25 #endif /* __cplusplus */ 26 #endif /* __cplusplus */ 27 28 /* Definition of the graphics layer ID. */ 29 typedef enum { 30 HIGO_LAYER_SD_0 = 0, 31 HIGO_LAYER_SD_1, 32 HIGO_LAYER_HD_0, 33 HIGO_LAYER_HD_1, 34 HIGO_LAYER_HD_2, 35 HIGO_LAYER_HD_3, 36 HIGO_LAYER_AD_0, 37 HIGO_LAYER_AD_1, 38 HIGO_LAYER_BUTT, 39 } HIGO_LAYER_E; 40 41 /* Standard-definition (SD) graphics layer 0. */ 42 #define HIGO_LAYER_RGB0 HIGO_LAYER_SD_0 43 44 /* SD graphics layer 1. */ 45 #define HIGO_LAYER_RGB1 HIGO_LAYER_SD_1 46 47 #define GRAPHICS_LAYER_MAX_NUM 4 48 49 /* 50 * The following macro defines the buffer mode of each graphics layer of the HiGo. 51 * The canvas buffer is used for drawing, 52 * and the display buffer is used for display output. 53 * 54 * display bufferʾbuffer. 55 */ 56 #define HIGO_LAYER_BUFFER_SINGLE 0x02 /* 57 * One canvas buffer, and no display buffer. 58 * 59 */ 60 #define HIGO_LAYER_BUFFER_DOUBLE 0x04 /* 61 * One canvas buffer, and one display buffer. Dual buffers are supported. 62 * 63 */ 64 #define HIGO_LAYER_BUFFER_TRIPLE 0x08 /* 65 * One canvas buffer, and two display buffers. 66 * The flip function is supported. 67 * 68 * ˢµʱȴ 69 */ 70 #define HIGO_LAYER_BUFFER_OVER 0x10 /* 71 * One canvas buffer, and two display buffers. 72 * The flip function is supported. 73 * If tasks are being performed during refresh, 74 * the current frame is discarded. 75 * 76 * ˢµʱæǰ֡ 77 */ 78 #define HIGO_LAYER_BUFFER_FENCE 0x12 /* fence refresh type, fenceˢģʽ */ 79 80 /* 81 * Refresh mode of graphics layers for complying with old definitions. The mode is not recommended. 82 * 83 */ 84 typedef enum { 85 HIGO_LAYER_FLUSH_FLIP = HIGO_LAYER_BUFFER_TRIPLE, 86 HIGO_LAYER_FLUSH_DOUBBUFER = HIGO_LAYER_BUFFER_DOUBLE, 87 HIGO_LAYER_FLUSH_NORMAL = HIGO_LAYER_BUFFER_SINGLE, 88 HIGO_LAYER_FLUSH_OVER = HIGO_LAYER_BUFFER_OVER, 89 HIGO_LAYER_FLUSH_FENCE = HIGO_LAYER_BUFFER_FENCE, 90 HIGO_LAYER_FLUSH_BUTT 91 } HIGO_LAYER_FLUSHTYPE_E; 92 93 /* 94 * Anti-flicker level, ranging from low to high. The higher the level, 95 * the better the anti-flicker effect, but the more blurred the picture. 96 * 97 */ 98 typedef enum { 99 HIGO_LAYER_DEFLICKER_NONE = 0, 100 HIGO_LAYER_DEFLICKER_LOW, 101 HIGO_LAYER_DEFLICKER_MIDDLE, 102 HIGO_LAYER_DEFLICKER_HIGH, 103 HIGO_LAYER_DEFLICKER_AUTO, 104 HIGO_LAYER_DEFLICKER_BUTT 105 } HIGO_LAYER_DEFLICKER_E; 106 107 /* Frame encode format. */ 108 typedef enum { 109 HIGO_ENCPICFRM_MONO = 0x0, /* Normal display, no 3D TV. */ 110 HIGO_ENCPICFRM_STEREO_SIDEBYSIDE_HALF, /* 111 * L/R frames are downscaled horizontally by 2 andpacked side-by-side 112 * into a single frame, left on lefthalf of frame. 113 * 114 */ 115 HIGO_ENCPICFRM_STEREO_TOPANDBOTTOM, /* 116 * L/R frames are downscaled vertically by 2 andpacked 117 * into a single frame, left on top. 118 * 119 */ 120 HIGO_ENCPICFRM_BUTT 121 } HIGO_ENCPICFRM_E; 122 123 /* 3D STEREO mode. */ 124 typedef enum { 125 HIGO_STEREO_MODE_HW_FULL = 0x0, /* 126 * 3d stereo function use hardware and transfer full frame to vo, 127 * note: hardware doesn't support the mode 128 * if encoder picture delivery method is top and bottom 129 */ 130 HIGO_STEREO_MODE_HW_HALF, /* 3d stereo function use hardware and transfer half frame to vo */ 131 HIGO_STEREO_MODE_SW_EMUL, /* 3d stereo function use software emulation */ 132 HIGO_STEREO_MODE_BUTT 133 } HIGO_STEREO_MODE_E; 134 135 /* Layer attribute parameters. */ 136 typedef struct { 137 HI_S32 ScreenWidth; /* 138 * Height of a graphics layer on the screen. 139 * The value must be greater than 0. 140 * 141 */ 142 HI_S32 ScreenHeight; /* 143 * Width of a graphics layer on the screen. 144 * The value must be greater than 0. 145 * 146 */ 147 HI_S32 CanvasWidth; /* Width of the canvas buffer of a graphics layer. If the value is 0, 148 * no canvas buffer is created. 149 * 150 */ 151 HI_S32 CanvasHeight; /* 152 * Height of the canvas buffer of a graphics layer. 153 * If the value is 0, no canvas buffer is created. 154 * 155 */ 156 HI_S32 DisplayWidth; /* 157 * Width of the display buffer of a graphics layer. 158 * If the value is 0, the value of ScreenWidth is used. 159 * 160 */ 161 HI_S32 DisplayHeight; /* 162 * Height of the display buffer of a graphics layer. 163 * If the value is 0, the value of ScreenHeight is used. 164 * 165 */ 166 HIGO_LAYER_FLUSHTYPE_E LayerFlushType; /* 167 * Refresh mode of the layer. You can choose the refresh mode 168 * based on the actual scenario to improve the refresh efficiency. 169 * If the value is 0, the dual-buffer+flip refresh mode is used by default. 170 * 171 * ˢЧ,0ʱĬʹ˫+Flipˢģʽ 172 */ 173 HIGO_LAYER_DEFLICKER_E AntiLevel; /* Anti-flicker level of a graphics layer. */ 174 HIGO_PF_E PixelFormat; /* 175 * Pixel format of a graphics layer. The format must be supported by 176 * the hardware layer. You need to choose the pixel format parameters of 177 * the layer based on hardware devices. 178 * 179 * ݲͬӲ豸ѡͼظʽ 180 */ 181 HIGO_LAYER_E LayerID; /* 182 * Hardware ID of a graphics layer. The supported graphics layer depends on 183 * the chip platform. For example, the Hi3720 supports an HD graphics layer 184 * and an SD graphics layer. 185 * 186 */ 187 } HIGO_LAYER_INFO_S; 188 189 /* Status of a graphics layer. */ 190 typedef struct { 191 HI_BOOL bShow; /* Whether to display a graphics layer. */ 192 } HIGO_LAYER_STATUS_S; 193 194 typedef struct { 195 HI_COLOR ColorKey; /* Transparency of a graphics layer. */ 196 HI_BOOL bEnableCK; /* Whether the colorkey of a graphics layer is enabled. */ 197 } HIGO_LAYER_KEY_S; 198 199 typedef struct { 200 HI_BOOL bAlphaEnable; /* Alpha pixel enable flag. */ 201 HI_BOOL bAlphaChannel; /* Alpha channel enable flag. */ 202 HI_U8 Alpha0; /* Alpha0 value. It is valid in ARGB1555 format. */ 203 HI_U8 Alpha1; /* Alpha1 value. It is valid in ARGB1555 format. */ 204 HI_U8 GlobalAlpha; /* 205 * Global alpha. This value is valid only when the alpha channel is valid. 206 * 207 */ 208 } HIGO_LAYER_ALPHA_S; 209 210 typedef struct { 211 HI_HANDLE Layer; /* The layer the scrolltext want to show */ 212 HI_RECT stScrollRect; /* the position you wanted to show on the layer */ 213 HIGO_PF_E ePixelFormat; /* the color format of scrolltext content */ 214 HI_U16 u16CacheNum; /* The cached buffer number for store scrolltext content */ 215 HI_U16 u16RefreshFreq; /* The refresh frequency you wanted */ 216 HI_BOOL bDeflicker; /* Whether enable antificker */ 217 } HIGO_SCROLLTEXT_ATTR_S; 218 219 typedef struct { 220 HI_U32 u32PhyAddr; /* The physical address of the scrolltext content buffer */ 221 HI_U8 *pu8VirAddr; /* The virtual address of the scrolltext content buffer */ 222 HI_U32 u32BufferLen; /* The virtual or physical address Length of the scrolltext content buffer */ 223 HI_U32 u32Stride; /* The stride of the scrolltext content buffer */ 224 } HIGO_SCROLLTEXT_DATA_S; 225 226 HI_S32 HI_GO_InitDisplay(HI_VOID); 227 228 HI_S32 HI_GO_DeinitDisplay(HI_VOID); 229 230 HI_S32 HI_GO_GetLayerDefaultParam(HIGO_LAYER_E LayerID, HIGO_LAYER_INFO_S *pLayerInfo); 231 232 HI_S32 HI_GO_CreateLayer(const HIGO_LAYER_INFO_S *pLayerInfo, HI_HANDLE *pLayer); 233 234 HI_S32 HI_GO_DestroyLayer(HI_HANDLE Layer); 235 236 HI_S32 HI_GO_SetLayerPos(HI_HANDLE Layer, HI_U32 u32StartX, HI_U32 u32StartY); 237 238 HI_S32 HI_GO_GetLayerPos(HI_HANDLE Layer, HI_U32 *pStartX, HI_U32 *pStartY); 239 240 HI_S32 HI_GO_SetScreenSize(HI_HANDLE Layer, HI_U32 u32SWidth, HI_U32 u32SHeight); 241 242 HI_S32 HI_GO_GetScreenSize(HI_HANDLE Layer, HI_U32 *pSWidth, HI_U32 *pSHeight); 243 244 HI_S32 HI_GO_SetLayerAlpha(HI_HANDLE Layer, HI_U8 Alpha); 245 246 HI_S32 HI_GO_SetLayerPreMul(HI_HANDLE Layer, HI_BOOL bPreMul); 247 248 HI_S32 HI_GO_GetLayerAlpha(HI_HANDLE Layer, HI_U8 *pAlpha); 249 250 HI_S32 HI_GO_GetLayerSurface(HI_HANDLE Layer, HI_HANDLE *pSurface); 251 252 HI_S32 HI_GO_ShowLayer(HI_HANDLE Layer, HI_BOOL bVisbile); 253 254 HI_S32 HI_GO_GetLayerStatus(HI_HANDLE Layer, HIGO_LAYER_STATUS_S *pLayerStatus); 255 256 HI_S32 HI_GO_RefreshLayer(HI_HANDLE Layer, const HI_RECT *pRect); 257 258 HI_S32 HI_GO_SetLayerSurface(HI_HANDLE Layer, HI_HANDLE hSurface); 259 260 HI_S32 HI_GO_SetLayerBGColor(HI_HANDLE Layer, HI_COLOR Color); 261 262 HI_S32 HI_GO_GetLayerBGColor(HI_HANDLE Layer, HI_COLOR *pColor); 263 264 HI_S32 HI_GO_SetDisplaySize(HI_HANDLE Layer, HI_U32 u32DWidth, HI_U32 u32DHeight); 265 266 HI_S32 HI_GO_GetDisplaySize(HI_HANDLE Layer, HI_U32 *pDWidth, HI_U32 *pDHeight); 267 268 HI_S32 HI_GO_SetFlushType(HI_HANDLE Layer, HIGO_LAYER_FLUSHTYPE_E FlushType); 269 270 HI_S32 HI_GO_GetFlushType(HI_HANDLE Layer, HIGO_LAYER_FLUSHTYPE_E *pFlushType); 271 272 HI_S32 HI_GO_SetLayerColorkey(HI_HANDLE Layer, const HIGO_LAYER_KEY_S *pKey); 273 274 HI_S32 HI_GO_GetLayerColorkey(HI_HANDLE Layer, HIGO_LAYER_KEY_S *pKey); 275 276 HI_S32 HI_GO_SetLayerPalette(HI_HANDLE Layer, const HI_PALETTE Palette); 277 278 HI_S32 HI_GO_GetLayerPalette(HI_HANDLE Layer, HI_PALETTE Palette); 279 280 HI_S32 HI_GO_WaitForBlank(HI_HANDLE Layer); 281 282 HI_S32 HI_GO_SetLayerAlphaEx(HI_HANDLE Layer, HIGO_LAYER_ALPHA_S *pAlphaInfo); 283 284 HI_S32 HI_GO_GetLayerAlphaEx(HI_HANDLE Layer, HIGO_LAYER_ALPHA_S *pAlphaInfo); 285 286 HI_S32 HI_GO_SetLayerZorder(HI_HANDLE Layer, HIGO_ZORDER_E enZOrder); 287 288 HI_S32 HI_GO_GetLayerZorder(HI_HANDLE Layer, HI_U32 *pu32ZOrder); 289 290 HI_S32 HI_GO_SetStereoMode(HI_HANDLE Layer, HIGO_STEREO_MODE_E InputEnc); 291 292 HI_S32 HI_GO_GetStereoMode(HI_HANDLE Layer, const HIGO_STEREO_MODE_E *pInputEnc); 293 294 HI_S32 HI_GO_SetStereoDepth(HI_HANDLE Layer, HI_S32 s32StereoDepth); 295 296 HI_S32 HI_GO_GetStereoDepth(HI_HANDLE Layer, HI_S32 *ps32StereoDepth); 297 298 HI_S32 HI_GO_SetCompression(HI_HANDLE Layer, HI_BOOL bEnable); 299 300 HI_S32 HI_GO_GetCompression(HI_HANDLE Layer, const HI_BOOL *pbEnable); 301 302 HI_S32 HI_GO_CreateScrollText(HIGO_SCROLLTEXT_ATTR_S *pstScrollAttr, HI_HANDLE *phScrollText); 303 304 HI_S32 HI_GO_FillScrollText(HI_HANDLE hScrollText, HIGO_SCROLLTEXT_DATA_S *pstScrollData); 305 306 HI_S32 HI_GO_PauseScrollText(HI_HANDLE hScrollText); 307 308 HI_S32 HI_GO_ResumeScrollText(HI_HANDLE hScrollText); 309 310 HI_S32 HI_GO_DestoryScrollText(HI_HANDLE hScrollText); 311 312 #ifdef __cplusplus 313 #if __cplusplus 314 } 315 #endif 316 #endif 317 318 #endif 319