• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Rockchip Electronics 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 #include <stdio.h>
17 #include <string.h>
18 #include "im2d.h"
19 #include "rga.h"
20 #include "display_common.h"
21 #include "display_gralloc.h"
22 #include "securec.h"
23 #include "display_gfx.h"
24 
25 #define ALIGN_UP(x, a) ((((x) + ((a)-1)) / (a)) * (a))
26 GrallocFuncs *grallocFucs = NULL;
rkInitGfx()27 int32_t rkInitGfx()
28 {
29     DISPLAY_LOGE("%s\n", querystring(RGA_ALL));
30     return DISPLAY_SUCCESS;
31 }
32 
rkDeinitGfx()33 int32_t rkDeinitGfx()
34 {
35     return DISPLAY_SUCCESS;
36 }
37 
colorSpaceModeChange(PixelFormat color,uint8_t * isYuv)38 RgaSURF_FORMAT colorSpaceModeChange(PixelFormat color, uint8_t *isYuv)
39 {
40     RgaSURF_FORMAT rkFormat;
41     switch (color) {
42         case PIXEL_FMT_RGB_565: /**< RGB565 format */
43             rkFormat = RK_FORMAT_RGB_565;
44             *isYuv = 0;
45             break;
46         case PIXEL_FMT_RGBA_4444: /**< RGBA4444 format */
47             rkFormat = RK_FORMAT_RGBA_4444;
48             *isYuv = 0;
49             break;
50         case PIXEL_FMT_RGBA_5551: /**< RGBA5551 format */
51             rkFormat = RK_FORMAT_RGBA_5551;
52             *isYuv = 0;
53             break;
54         case PIXEL_FMT_RGBX_8888: /**< RGBX8888 format */
55             rkFormat = RK_FORMAT_RGBX_8888;
56             *isYuv = 0;
57             break;
58         case PIXEL_FMT_RGBA_8888: /**< RGBA8888 format */
59             rkFormat = RK_FORMAT_RGBA_8888;
60             *isYuv = 0;
61             break;
62         case PIXEL_FMT_RGB_888: /**< RGB888 format */
63             rkFormat = RK_FORMAT_RGB_888;
64             *isYuv = 0;
65             break;
66         case PIXEL_FMT_BGR_565: /**< BGR565 format */
67             rkFormat = RK_FORMAT_BGR_565;
68             *isYuv = 0;
69             break;
70         case PIXEL_FMT_BGRA_4444: /**< BGRA4444 format */
71             rkFormat = RK_FORMAT_BGRA_4444;
72             *isYuv = 0;
73             break;
74         case PIXEL_FMT_BGRA_5551: /**< BGRA5551 format */
75             rkFormat = RK_FORMAT_BGRA_5551;
76             *isYuv = 0;
77             break;
78         case PIXEL_FMT_BGRX_8888: /**< BGRX8888 format */
79             rkFormat = RK_FORMAT_BGRX_8888;
80             *isYuv = 0;
81             break;
82         case PIXEL_FMT_BGRA_8888: /**< BGRA8888 format */
83             rkFormat = RK_FORMAT_BGRA_8888;
84             *isYuv = 0;
85             break;
86         case PIXEL_FMT_YCBCR_422_SP: /**< YCBCR422 semi-planar format */
87             rkFormat = RK_FORMAT_YCbCr_420_SP;
88             *isYuv = 1;
89             break;
90         case PIXEL_FMT_YCRCB_422_SP: /**< YCRCB422 semi-planar format */
91             rkFormat = RK_FORMAT_YCrCb_422_SP;
92             *isYuv = 1;
93             break;
94         case PIXEL_FMT_YCBCR_420_SP: /**< YCBCR420 semi-planar format */
95             rkFormat = RK_FORMAT_YCbCr_420_SP;
96             *isYuv = 1;
97             break;
98         case PIXEL_FMT_YCRCB_420_SP: /**< YCRCB420 semi-planar format */
99             rkFormat = RK_FORMAT_YCrCb_420_SP;
100             *isYuv = 1;
101             break;
102         case PIXEL_FMT_YCBCR_422_P: /**< YCBCR422 planar format */
103             rkFormat = RK_FORMAT_YCbCr_422_P;
104             *isYuv = 1;
105             break;
106         case PIXEL_FMT_YCRCB_422_P: /**< YCRCB422 planar format */
107             rkFormat = RK_FORMAT_YCrCb_422_P;
108             *isYuv = 1;
109             break;
110         case PIXEL_FMT_YCBCR_420_P: /**< YCBCR420 planar format */
111             rkFormat = RK_FORMAT_YCbCr_420_P;
112             *isYuv = 1;
113             break;
114         case PIXEL_FMT_YCRCB_420_P: /**< YCRCB420 planar format */
115             rkFormat = RK_FORMAT_YCrCb_420_P;
116             *isYuv = 1;
117             break;
118         case PIXEL_FMT_YUYV_422_PKG: /**< YUYV422 packed format */
119             rkFormat = RK_FORMAT_YUYV_422;
120             *isYuv = 1;
121             break;
122         case PIXEL_FMT_UYVY_422_PKG: /**< UYVY422 packed format */
123             rkFormat = RK_FORMAT_UYVY_422;
124             *isYuv = 1;
125             break;
126         case PIXEL_FMT_YVYU_422_PKG: /**< YVYU422 packed format */
127             rkFormat = RK_FORMAT_YUYV_422;
128             *isYuv = 1;
129             break;
130         case PIXEL_FMT_VYUY_422_PKG: /**< VYUY422 packed format */
131             rkFormat = RK_FORMAT_VYUY_422;
132             *isYuv = 1;
133             break;
134         default:
135             //          PIXEL_FMT_CLUT8:        /**< CLUT8 format */
136             //          PIXEL_FMT_CLUT1,            /**< CLUT1 format */
137             //          PIXEL_FMT_CLUT4,            /**< CLUT4 format */
138             //          PIXEL_FMT_RGBA_5658,        /**< RGBA5658 format */
139             //          PIXEL_FMT_RGBX_4444,        /**< RGBX4444 format */
140             //          PIXEL_FMT_RGB_444,          /**< RGB444 format */
141             //          PIXEL_FMT_RGBX_5551,        /**< RGBX5551 format */
142             //          PIXEL_FMT_RGB_555,          /**< RGB555 format */
143             //          PIXEL_FMT_BGRX_4444,        /**< BGRX4444 format */
144             //          PIXEL_FMT_BGRX_5551,        /**< BGRX5551 format */
145             //          PIXEL_FMT_YUV_422_I,        /**< YUV422 interleaved format */
146             rkFormat = RK_FORMAT_UNKNOWN;
147             break;
148     }
149     return rkFormat;
150 }
151 
rkFillRect(ISurface * iSurface,IRect * rect,uint32_t color,GfxOpt * opt)152 int32_t rkFillRect(ISurface *iSurface, IRect *rect, uint32_t color, GfxOpt *opt)
153 {
154     rga_buffer_t dst;
155     im_rect imRect;
156     IM_STATUS ret;
157     uint8_t isYuv;
158 
159     errno_t eok = memset_s((void *)&imRect, sizeof(imRect), 0, sizeof(imRect));
160     if (eok != EOK) {
161         DISPLAY_LOGE("memset_s failed");
162         return false;
163     }
164     imRect.x = rect->x;
165     imRect.y = rect->y;
166     imRect.width = rect->w;
167     imRect.height = rect->h;
168 
169     eok = memset_s((void *)&dst, sizeof(dst), 0, sizeof(dst));
170     if (eok != EOK) {
171         DISPLAY_LOGE("memset_s failed");
172         return false;
173     }
174     dst.phy_addr = 0; // (void*)iSurface->phyAddr;
175     dst.vir_addr = 0; // iSurface->virAddr;
176     dst.fd = (int32_t)iSurface->phyAddr;
177     if (dst.fd == 0) {
178         DISPLAY_LOGE("source fd is invalid");
179         return DISPLAY_PARAM_ERR;
180     }
181     DISPLAY_DEBUGLOG("fd %{public}d", dst.fd);
182     dst.width = iSurface->width;
183     dst.height = iSurface->height;
184     dst.wstride = ALIGN_UP(iSurface->width, 16);
185     dst.hstride = ALIGN_UP(iSurface->height, 16);
186     dst.format = colorSpaceModeChange(iSurface->enColorFmt, &isYuv);
187     dst.color_space_mode = IM_COLOR_SPACE_DEFAULT;
188     dst.color = color;
189     if (opt->enGlobalAlpha) {
190         dst.global_alpha = opt->globalAlpha;
191     }
192     ret = imfill(dst, imRect, color);
193     if (ret != IM_STATUS_SUCCESS) {
194         return DISPLAY_FAILURE;
195     } else {
196         return DISPLAY_SUCCESS;
197     }
198 }
199 
blendTypeChange(BlendType blendType)200 int32_t blendTypeChange(BlendType blendType)
201 {
202     int32_t rkBlendType;
203     switch (blendType) {
204         case BLEND_SRC: /**< SRC blending */
205             rkBlendType = IM_ALPHA_BLEND_SRC;
206             break;
207         case BLEND_DST: /**< SRC blending */
208             rkBlendType = IM_ALPHA_BLEND_DST;
209             break;
210         case BLEND_SRCOVER: /**< SRC_OVER blending */
211             rkBlendType = IM_ALPHA_BLEND_SRC_OVER;
212             break;
213         case BLEND_DSTOVER: /**< DST_OVER blending */
214             rkBlendType = IM_ALPHA_BLEND_DST_OVER;
215             break;
216         default:
217             /* Fix up later */
218             //        BLEND_NONE         /**< No blending */
219             //        BLEND_CLEAR:            /**< CLEAR blending */
220             //        BLEND_SRCIN:            /**< SRC_IN blending */
221             //        BLEND_DSTIN:            /**< DST_IN blending */
222             //        BLEND_SRCOUT:           /**< SRC_OUT blending */
223             //        BLEND_DSTOUT:           /**< DST_OUT blending */
224             //        BLEND_SRCATOP:          /**< SRC_ATOP blending */
225             //        BLEND_DSTATOP:          /**< DST_ATOP blending */
226             //        BLEND_ADD:              /**< ADD blending */
227             //        BLEND_XOR:              /**< XOR blending */
228             //        BLEND_DST:              /**< DST blending */
229             //        BLEND_AKS:              /**< AKS blending */
230             //        BLEND_AKD:              /**< AKD blending */
231             //        BLEND_BUTT:              /**< Null operation */
232             rkBlendType = IM_STATUS_NOT_SUPPORTED;
233             break;
234     }
235     return rkBlendType;
236 }
237 
TransformTypeChange(TransformType type)238 int32_t TransformTypeChange(TransformType type)
239 {
240     int32_t rkRotateType;
241     switch (type) {
242         case ROTATE_90: /**< Rotation by 90 degrees */
243             rkRotateType = IM_HAL_TRANSFORM_ROT_90;
244             break;
245         case ROTATE_180: /**< Rotation by 180 degrees */
246             rkRotateType = IM_HAL_TRANSFORM_ROT_180;
247             break;
248         case ROTATE_270: /**< Rotation by 270 degrees */
249             rkRotateType = IM_HAL_TRANSFORM_ROT_270;
250             break;
251         default:
252             rkRotateType = 0; /**< No rotation */
253             break;
254     }
255     return rkRotateType;
256 }
257 
mirrorTypeChange(MirrorType type)258 int32_t mirrorTypeChange(MirrorType type)
259 {
260     int32_t rkMirrorType;
261     switch (type) {
262         case MIRROR_LR: /**< Left and right mirrors */
263             rkMirrorType = IM_HAL_TRANSFORM_FLIP_H;
264             break;
265         case MIRROR_TB: /**< Top and bottom mirrors */
266             rkMirrorType = IM_HAL_TRANSFORM_FLIP_V;
267             break;
268         default:
269             rkMirrorType = 0;
270             break;
271     }
272     return rkMirrorType;
273 }
274 
doFlit(ISurface * srcSurface,IRect * srcRect,ISurface * dstSurface,IRect * dstRect,GfxOpt * opt)275 int32_t doFlit(ISurface *srcSurface, IRect *srcRect, ISurface *dstSurface, IRect *dstRect, GfxOpt *opt)
276 {
277     int32_t usage = 0;
278     uint8_t isYuv = 0;
279     rga_buffer_t dstRgaBuffer, srcRgaBuffer, bRgbBuffer;
280     IM_STATUS ret = 0;
281     im_rect srect;
282     im_rect drect;
283     im_rect prect;
284     int32_t rkBlendType = 0;
285     int32_t rkRotateType = 0;
286     int32_t rkMirrorType = 0;
287 
288     errno_t eok = memset_s(&dstRgaBuffer, sizeof(dstRgaBuffer), 0, sizeof(dstRgaBuffer));
289     if (eok != EOK) {
290         DISPLAY_LOGE("memset_s failed");
291         return false;
292     }
293     eok = memset_s(&srcRgaBuffer, sizeof(srcRgaBuffer), 0, sizeof(srcRgaBuffer));
294     if (eok != EOK) {
295         DISPLAY_LOGE("memset_s failed");
296         return false;
297     }
298     eok = memset_s(&bRgbBuffer, sizeof(bRgbBuffer), 0, sizeof(bRgbBuffer));
299     if (eok != EOK) {
300         DISPLAY_LOGE("memset_s failed");
301         return false;
302     }
303     eok = memset_s(&srect, sizeof(srect), 0, sizeof(srect));
304     if (eok != EOK) {
305         DISPLAY_LOGE("memset_s failed");
306         return false;
307     }
308     eok = memset_s(&drect, sizeof(drect), 0, sizeof(drect));
309     if (eok != EOK) {
310         DISPLAY_LOGE("memset_s failed");
311         return false;
312     }
313     eok = memset_s(&prect, sizeof(prect), 0, sizeof(prect));
314     if (eok != EOK) {
315         DISPLAY_LOGE("memset_s failed");
316         return false;
317     }
318     if (opt->enGlobalAlpha) {
319         dstRgaBuffer.global_alpha = opt->globalAlpha;
320         srcRgaBuffer.global_alpha = opt->globalAlpha;
321     }
322     dstRgaBuffer.width = dstSurface->width;
323     dstRgaBuffer.height = dstSurface->height;
324     dstRgaBuffer.wstride = ALIGN_UP(dstSurface->width, 16);
325     dstRgaBuffer.hstride = ALIGN_UP(dstSurface->height, 16);
326     dstRgaBuffer.format = colorSpaceModeChange(dstSurface->enColorFmt, &isYuv);
327     dstRgaBuffer.phy_addr = 0; // (void *)dstSurface->phyAddr;
328     dstRgaBuffer.vir_addr = 0; // dstSurface->virAddr;
329     dstRgaBuffer.color_space_mode = IM_COLOR_SPACE_DEFAULT;
330     dstRgaBuffer.fd = (int32_t)dstSurface->phyAddr;
331     if (isYuv == 1) {
332         DISPLAY_LOGE("rk gfx do not support dst buffer is yuv format");
333         return DISPLAY_PARAM_ERR;
334     }
335 
336     srcRgaBuffer.width = srcSurface->width;
337     srcRgaBuffer.height = srcSurface->height;
338     srcRgaBuffer.wstride = ALIGN_UP(srcSurface->width, 16);
339     srcRgaBuffer.hstride = ALIGN_UP(srcSurface->height, 16);
340     srcRgaBuffer.phy_addr = 0; // (void *)srcSurface->phyAddr;
341     srcRgaBuffer.vir_addr = 0; // srcSurface->virAddr;
342     srcRgaBuffer.format = colorSpaceModeChange(srcSurface->enColorFmt, &isYuv);
343     srcRgaBuffer.color_space_mode = IM_COLOR_SPACE_DEFAULT;
344     srcRgaBuffer.fd = (int32_t)srcSurface->phyAddr;
345 
346     if (srcRgaBuffer.fd == 0) {
347         DISPLAY_LOGE("source fd is invalid");
348         return DISPLAY_PARAM_ERR;
349     }
350 
351     DISPLAY_DEBUGLOG("gfx src fd %{public}d, w %{public}d, h %{publuc}d, sw %{public}d sh %{public}d vir %{public}p",
352                      (int32_t)srcSurface->phyAddr, srcSurface->width, srcSurface->height,
353                      ALIGN_UP(srcSurface->width, 16), ALIGN_UP(srcSurface->height, 16), srcRgaBuffer.vir_addr);
354     DISPLAY_DEBUGLOG("gfx dst fd %{public}d, w %{public}d, h %{public}d, sw %{public}d sh %{public}d vir %{public}p",
355                      (int32_t)dstSurface->phyAddr, dstSurface->width, dstSurface->height,
356                      ALIGN_UP(dstSurface->width, 16), ALIGN_UP(dstSurface->height, 16), dstRgaBuffer.vir_addr);
357 
358     srect.x = srcRect->x;
359     srect.x = (srect.x == 1) ? 0 : srect.x;
360     srect.y = srcRect->y;
361     srect.y = (srect.y == 1) ? 0 : srect.y;
362     srect.height = srcRect->h;
363     srect.width = srcRect->w;
364     drect.x = dstRect->x;
365     drect.x = (drect.x == 1) ? 0 : drect.x;
366     drect.y = dstRect->y;
367     drect.y = (drect.y == 1) ? 0 : drect.y;
368     drect.height = dstRect->h;
369     drect.width = dstRect->w;
370 
371     if (opt->blendType) {
372         rkBlendType = blendTypeChange(opt->blendType);
373         if (rkBlendType > 0) {
374             usage |= rkBlendType;
375             if (rkBlendType == IM_ALPHA_BLEND_DST_OVER || rkBlendType == IM_ALPHA_BLEND_SRC_OVER) {
376                 usage |= IM_ALPHA_BLEND_PRE_MUL;
377             }
378         } else if (rkBlendType == IM_STATUS_NOT_SUPPORTED) {
379             return DISPLAY_NOT_SUPPORT;
380         }
381     }
382     if (opt->rotateType) {
383         rkRotateType = TransformTypeChange(opt->rotateType);
384         if (rkRotateType != 0) {
385             usage |= rkRotateType;
386         }
387     }
388     if (opt->mirrorType == MIRROR_LR || opt->mirrorType == MIRROR_TB) {
389         rkMirrorType = mirrorTypeChange(opt->mirrorType);
390         if (rkMirrorType != 0) {
391             usage |= rkMirrorType;
392         }
393     }
394     if (opt->enableScale) {
395         DISPLAY_LOGE("gfx scale from (%{puhblic}d, %{public}d) to (%{public}d, %{public}d)", srcRgaBuffer.width,
396                      srcRgaBuffer.height, dstRgaBuffer.width, dstRgaBuffer.height);
397     }
398     usage |= IM_SYNC;
399     if (isYuv == 1) {
400         if (rkBlendType == IM_ALPHA_BLEND_SRC_OVER || rkBlendType == IM_ALPHA_BLEND_SRC) {
401             usage = 0;
402             if (opt->enableScale == 0) {
403                 eok = memset_s(&srect, sizeof(srect), 0, sizeof(srect));
404                 if (eok != EOK) {
405                     DISPLAY_LOGE("memset_s failed");
406                     return false;
407                 }
408                 srect.width = srcRgaBuffer.width;
409                 srect.height = srcRgaBuffer.height;
410 
411                 eok = memset_s(&drect, sizeof(drect), 0, sizeof(drect));
412                 if (eok != EOK) {
413                     DISPLAY_LOGE("memset_s failed");
414                     return false;
415                 }
416                 drect.x = dstRgaBuffer.width - srcRgaBuffer.width;
417                 drect.y = dstRgaBuffer.height - srcRgaBuffer.height;
418                 drect.width = srcRgaBuffer.width;
419                 drect.height = srcRgaBuffer.height;
420             }
421             usage = rkRotateType | rkMirrorType | IM_SYNC;
422             ret = improcess(srcRgaBuffer, dstRgaBuffer, bRgbBuffer, srect, drect, prect, usage);
423             if (ret != IM_STATUS_SUCCESS) {
424                 DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
425             }
426         } else if (rkBlendType == IM_ALPHA_BLEND_DST_OVER) {
427             if (grallocFucs == NULL) {
428                 ret = GrallocInitialize(&grallocFucs);
429                 DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("Gralloc init failed"));
430             }
431             AllocInfo info = {
432                 .width = dstRgaBuffer.width,
433                 .height = dstRgaBuffer.height,
434                 .usage = HBM_USE_MEM_DMA | HBM_USE_CPU_READ | HBM_USE_CPU_WRITE,
435                 .format = PIXEL_FMT_RGBA_8888, // srcSurface->enColorFmt,
436             };
437             BufferHandle *buffer = NULL;
438 
439             ret = grallocFucs->AllocMem(&info, &buffer);
440             DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not alloc memory"));
441 
442             bRgbBuffer.width = dstRgaBuffer.width;
443             bRgbBuffer.height = dstRgaBuffer.height;
444             bRgbBuffer.wstride = dstRgaBuffer.wstride;
445             bRgbBuffer.hstride = dstRgaBuffer.hstride;
446             bRgbBuffer.format = RK_FORMAT_RGBA_8888; // srcRgaBuffer.format;
447             bRgbBuffer.phy_addr = 0;                 // (void *) buffer->phyAddr;
448             bRgbBuffer.vir_addr = 0;                 // buffer->virAddr;
449             bRgbBuffer.color_space_mode = dstRgaBuffer.color_space_mode;
450             bRgbBuffer.fd = (int32_t)buffer->phyAddr;
451             int ret = memcpy_s(&prect, sizeof(drect), &drect, sizeof(drect));
452             if (!ret) {
453                 printf("memcpy_s failed!\n");
454             }
455             ret = improcess(srcRgaBuffer, bRgbBuffer, dstRgaBuffer, srect, prect, drect, usage);
456             if (ret != IM_STATUS_SUCCESS) {
457                 DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
458             } else {
459                 ret = imcopy(bRgbBuffer, dstRgaBuffer);
460                 if (ret != IM_STATUS_SUCCESS) {
461                     DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
462                 }
463             }
464             grallocFucs->FreeMem(buffer);
465         }
466     } else {
467         ret = improcess(srcRgaBuffer, dstRgaBuffer, bRgbBuffer, srect, drect, prect, usage);
468         if (ret != IM_STATUS_SUCCESS) {
469             DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
470         }
471     }
472     if (ret != IM_STATUS_SUCCESS) {
473         return DISPLAY_FAILURE;
474     } else {
475         return DISPLAY_SUCCESS;
476     }
477 }
478 
rkBlit(ISurface * srcSurface,IRect * srcRect,ISurface * dstSurface,IRect * dstRect,GfxOpt * opt)479 int32_t rkBlit(ISurface *srcSurface, IRect *srcRect, ISurface *dstSurface, IRect *dstRect, GfxOpt *opt)
480 {
481     CHECK_NULLPOINTER_RETURN_VALUE(srcSurface, DISPLAY_NULL_PTR);
482     CHECK_NULLPOINTER_RETURN_VALUE(srcRect, DISPLAY_NULL_PTR);
483     CHECK_NULLPOINTER_RETURN_VALUE(dstSurface, DISPLAY_NULL_PTR);
484     CHECK_NULLPOINTER_RETURN_VALUE(dstRect, DISPLAY_NULL_PTR);
485     CHECK_NULLPOINTER_RETURN_VALUE(opt, DISPLAY_NULL_PTR);
486 
487     if (doFlit(srcSurface, srcRect, dstSurface, dstRect, opt) < 0) {
488         return DISPLAY_FAILURE;
489     } else {
490         return DISPLAY_SUCCESS;
491     }
492 }
493 
rkSync(int32_t timeOut)494 int32_t rkSync(int32_t timeOut)
495 {
496     return DISPLAY_SUCCESS;
497 }
498 
GfxInitialize(GfxFuncs ** funcs)499 int32_t GfxInitialize(GfxFuncs **funcs)
500 {
501     DISPLAY_CHK_RETURN((funcs == NULL), DISPLAY_PARAM_ERR, DISPLAY_LOGE("info is null"));
502     GfxFuncs *gfxFuncs = (GfxFuncs *)malloc(sizeof(GfxFuncs));
503     if (gfxFuncs == NULL) {
504         DISPLAY_LOGE("gfxFuncs is nullptr");
505         return DISPLAY_NULL_PTR;
506     }
507     errno_t eok = memset_s((void *)gfxFuncs, sizeof(GfxFuncs), 0, sizeof(GfxFuncs));
508     if (eok != EOK) {
509         DISPLAY_LOGE("memset_s failed");
510         free(gfxFuncs);
511         return DISPLAY_FAILURE;
512     }
513     gfxFuncs->InitGfx = rkInitGfx;
514     gfxFuncs->DeinitGfx = rkDeinitGfx;
515     gfxFuncs->FillRect = rkFillRect;
516     gfxFuncs->Blit = rkBlit;
517     gfxFuncs->Sync = rkSync;
518     *funcs = gfxFuncs;
519 
520     return DISPLAY_SUCCESS;
521 }
522 
GfxUninitialize(GfxFuncs * funcs)523 int32_t GfxUninitialize(GfxFuncs *funcs)
524 {
525     CHECK_NULLPOINTER_RETURN_VALUE(funcs, DISPLAY_NULL_PTR);
526     free(funcs);
527     DISPLAY_DEBUGLOG("%s: gfx uninitialize success", __func__);
528     return DISPLAY_SUCCESS;
529 }
530