• 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 ((int)dst.phy_addr == 0 && dst.fd == 0 && dst.vir_addr == NULL) {
178         DISPLAY_LOGE("source iSurface address error");
179         return DISPLAY_PARAM_ERR;
180     }
181     DISPLAY_DEBUGLOG("gfx vir %{public}p phy 0x%{public}x fd %{public}d", dst.vir_addr, (int32_t)dst.phy_addr, 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     ret = imfill(dst, imRect, color);
192     if (ret != IM_STATUS_SUCCESS)
193         return DISPLAY_FAILURE;
194     else
195         return DISPLAY_SUCCESS;
196 }
197 
blendTypeChange(BlendType blendType)198 int32_t blendTypeChange(BlendType blendType)
199 {
200     int32_t rkBlendType;
201     switch (blendType) {
202         case BLEND_SRC:              /**< SRC blending */
203             rkBlendType = IM_ALPHA_BLEND_SRC;
204             break;
205         case BLEND_DST:              /**< SRC blending */
206             rkBlendType = IM_ALPHA_BLEND_DST;
207             break;
208         case BLEND_SRCOVER:          /**< SRC_OVER blending */
209             rkBlendType = IM_ALPHA_BLEND_SRC_OVER;
210             break;
211         case BLEND_DSTOVER:          /**< DST_OVER blending */
212             rkBlendType = IM_ALPHA_BLEND_DST_OVER;
213             break;
214         default:
215             /* Fix up later */
216 //        BLEND_NONE         /**< No blending */
217 //        BLEND_CLEAR:            /**< CLEAR blending */
218 //        BLEND_SRCIN:            /**< SRC_IN blending */
219 //        BLEND_DSTIN:            /**< DST_IN blending */
220 //        BLEND_SRCOUT:           /**< SRC_OUT blending */
221 //        BLEND_DSTOUT:           /**< DST_OUT blending */
222 //        BLEND_SRCATOP:          /**< SRC_ATOP blending */
223 //        BLEND_DSTATOP:          /**< DST_ATOP blending */
224 //        BLEND_ADD:              /**< ADD blending */
225 //        BLEND_XOR:              /**< XOR blending */
226 //        BLEND_DST:              /**< DST blending */
227 //        BLEND_AKS:              /**< AKS blending */
228 //        BLEND_AKD:              /**< AKD blending */
229 //        BLEND_BUTT:              /**< Null operation */
230             rkBlendType = IM_STATUS_NOT_SUPPORTED;
231             break;
232     }
233     return rkBlendType;
234 }
235 
TransformTypeChange(TransformType type)236 int32_t TransformTypeChange(TransformType type)
237 {
238     int32_t rkRotateType;
239     switch (type) {
240         case ROTATE_90:            /**< Rotation by 90 degrees */
241             rkRotateType = IM_HAL_TRANSFORM_ROT_90;
242             break;
243         case ROTATE_180:             /**< Rotation by 180 degrees */
244             rkRotateType = IM_HAL_TRANSFORM_ROT_180;
245             break;
246         case ROTATE_270:             /**< Rotation by 270 degrees */
247             rkRotateType = IM_HAL_TRANSFORM_ROT_270;
248             break;
249         default:
250             rkRotateType = 0;        /**< No rotation */
251             break;
252     }
253     return rkRotateType;
254 }
255 
mirrorTypeChange(MirrorType type)256 int32_t mirrorTypeChange(MirrorType type)
257 {
258     int32_t rkMirrorType;
259     switch (type) {
260         case MIRROR_LR:            /**< Left and right mirrors */
261             rkMirrorType = IM_HAL_TRANSFORM_FLIP_H;
262             break;
263         case MIRROR_TB:            /**< Top and bottom mirrors */
264             rkMirrorType = IM_HAL_TRANSFORM_FLIP_V;
265             break;
266         default:
267             rkMirrorType = 0;
268             break;
269     }
270     return rkMirrorType;
271 }
272 
doFlit(ISurface * srcSurface,IRect * srcRect,ISurface * dstSurface,IRect * dstRect,GfxOpt * opt)273 int32_t doFlit(ISurface *srcSurface, IRect *srcRect, ISurface *dstSurface, IRect *dstRect, GfxOpt *opt)
274 {
275     int32_t usage = 0;
276     uint8_t isYuv = 0;
277     rga_buffer_t dstRgaBuffer, srcRgaBuffer, bRgbBuffer;
278     IM_STATUS ret = 0;
279     im_rect srect;
280     im_rect drect;
281     im_rect prect;
282     int32_t rkBlendType = 0;
283     int32_t rkRotateType = 0;
284     int32_t rkMirrorType = 0;
285 
286     errno_t eok = memset_s(&dstRgaBuffer, sizeof(dstRgaBuffer), 0, sizeof(dstRgaBuffer));
287     if (eok != EOK) {
288         DISPLAY_LOGE("memset_s failed");
289         return false;
290     }
291     eok = memset_s(&srcRgaBuffer, sizeof(srcRgaBuffer), 0, sizeof(srcRgaBuffer));
292     if (eok != EOK) {
293         DISPLAY_LOGE("memset_s failed");
294         return false;
295     }
296     eok = memset_s(&bRgbBuffer, sizeof(bRgbBuffer), 0, sizeof(bRgbBuffer));
297     if (eok != EOK) {
298         DISPLAY_LOGE("memset_s failed");
299         return false;
300     }
301     eok = memset_s(&srect, sizeof(srect), 0, sizeof(srect));
302     if (eok != EOK) {
303         DISPLAY_LOGE("memset_s failed");
304         return false;
305     }
306     eok = memset_s(&drect, sizeof(drect), 0, sizeof(drect));
307     if (eok != EOK) {
308         DISPLAY_LOGE("memset_s failed");
309         return false;
310     }
311     eok = memset_s(&prect, sizeof(prect), 0, sizeof(prect));
312     if (eok != EOK) {
313         DISPLAY_LOGE("memset_s failed");
314         return false;
315     }
316     if (opt->enGlobalAlpha) {
317         dstRgaBuffer.global_alpha = opt->globalAlpha;
318         srcRgaBuffer.global_alpha = opt->globalAlpha;
319     }
320     dstRgaBuffer.width = dstSurface->width;
321     dstRgaBuffer.height = dstSurface->height;
322     dstRgaBuffer.wstride = ALIGN_UP(dstSurface->width, 16);
323     dstRgaBuffer.hstride = ALIGN_UP(dstSurface->height, 16);
324     dstRgaBuffer.format = colorSpaceModeChange(dstSurface->enColorFmt, &isYuv);
325     dstRgaBuffer.phy_addr = 0; // (void *)dstSurface->phyAddr;
326     dstRgaBuffer.vir_addr = 0; // dstSurface->virAddr;
327     dstRgaBuffer.color_space_mode = IM_COLOR_SPACE_DEFAULT;
328     dstRgaBuffer.fd = (int32_t)dstSurface->phyAddr;
329     if (isYuv == 1) {
330         DISPLAY_LOGE("rk gfx do not support dst buffer is yuv format");
331         return DISPLAY_PARAM_ERR;
332     }
333 
334     srcRgaBuffer.width = srcSurface->width;
335     srcRgaBuffer.height = srcSurface->height;
336     srcRgaBuffer.wstride = ALIGN_UP(srcSurface->width, 16);
337     srcRgaBuffer.hstride = ALIGN_UP(srcSurface->height, 16);
338     srcRgaBuffer.phy_addr = 0; // (void *)srcSurface->phyAddr;
339     srcRgaBuffer.vir_addr = 0; // srcSurface->virAddr;
340     srcRgaBuffer.format = colorSpaceModeChange(srcSurface->enColorFmt, &isYuv);
341     srcRgaBuffer.color_space_mode = IM_COLOR_SPACE_DEFAULT;
342     srcRgaBuffer.fd = (int32_t)srcSurface->phyAddr;
343 
344     if ((int)srcRgaBuffer.phy_addr == 0 && srcRgaBuffer.fd == 0 && srcRgaBuffer.vir_addr == NULL) {
345         DISPLAY_LOGE("source iSurface address error");
346         return DISPLAY_PARAM_ERR;
347     }
348 
349     DISPLAY_DEBUGLOG("gfx src fd %{public}d, w %{public}d, h %{publuc}d, sw %{public}d sh %{public}d vir %{public}p",
350         (int32_t)srcSurface->phyAddr, srcSurface->width, srcSurface->height, ALIGN_UP(srcSurface->width, 16),
351         ALIGN_UP(srcSurface->height, 16), srcRgaBuffer.vir_addr);
352     DISPLAY_DEBUGLOG("gfx dst fd %{public}d, w %{public}d, h %{public}d, sw %{public}d sh %{public}d vir %{public}p",
353         (int32_t)dstSurface->phyAddr, dstSurface->width, dstSurface->height, ALIGN_UP(dstSurface->width, 16),
354         ALIGN_UP(dstSurface->height, 16), dstRgaBuffer.vir_addr);
355 
356     srect.x = srcRect->x;
357     srect.y = srcRect->y;
358     srect.height = srcRect->h;
359     srect.width = srcRect->w;
360     drect.x = dstRect->x;
361     drect.x = (drect.x == 1) ? 0 : drect.x;
362     drect.y = dstRect->y;
363     drect.height = dstRect->h;
364     drect.width = dstRect->w;
365 
366     if (opt->blendType) {
367         rkBlendType = blendTypeChange(opt->blendType);
368         if (rkBlendType > 0) {
369             usage |= rkBlendType;
370             if (rkBlendType == IM_ALPHA_BLEND_DST_OVER || rkBlendType == IM_ALPHA_BLEND_SRC_OVER)
371                 usage |= IM_ALPHA_BLEND_PRE_MUL;
372         } else if (rkBlendType == IM_STATUS_NOT_SUPPORTED) {
373             return DISPLAY_NOT_SUPPORT;
374         }
375     }
376     if (opt->rotateType) {
377         rkRotateType = TransformTypeChange(opt->rotateType);
378         if (rkRotateType != 0)
379             usage |= rkRotateType;
380     }
381     if (opt->mirrorType == MIRROR_LR || opt->mirrorType == MIRROR_TB) {
382         rkMirrorType = mirrorTypeChange(opt->mirrorType);
383         if (rkMirrorType != 0)
384             usage |= rkMirrorType;
385     }
386     if (opt->enableScale) {
387         DISPLAY_LOGE("gfx scale from (%{puhblic}d, %{public}d) to (%{public}d, %{public}d)", srcRgaBuffer.width, srcRgaBuffer.height, dstRgaBuffer.width,
388                      dstRgaBuffer.height);
389     }
390     usage |= IM_SYNC;
391     if (isYuv == 1) {
392         if (rkBlendType == IM_ALPHA_BLEND_SRC_OVER || rkBlendType == IM_ALPHA_BLEND_SRC) {
393             usage = 0;
394             if (opt->enableScale == 0) {
395                 eok = memset_s(&srect, sizeof(srect), 0, sizeof(srect));
396                 if (eok != EOK) {
397                     DISPLAY_LOGE("memset_s failed");
398                     return false;
399                 }
400                 srect.width = srcRgaBuffer.width;
401                 srect.height = srcRgaBuffer.height;
402 
403                 eok = memset_s(&drect, sizeof(drect), 0, sizeof(drect));
404                 if (eok != EOK) {
405                     DISPLAY_LOGE("memset_s failed");
406                     return false;
407                 }
408                 drect.x = dstRgaBuffer.width - srcRgaBuffer.width;
409                 drect.y = dstRgaBuffer.height - srcRgaBuffer.height;
410                 drect.width = srcRgaBuffer.width;
411                 drect.height = srcRgaBuffer.height;
412             }
413             usage = rkRotateType | rkMirrorType | IM_SYNC;
414             ret = improcess(srcRgaBuffer, dstRgaBuffer, bRgbBuffer, srect, drect, prect, usage);
415             if (ret != IM_STATUS_SUCCESS) {
416                 DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
417             }
418         } else if (rkBlendType == IM_ALPHA_BLEND_DST_OVER) {
419             if (grallocFucs == NULL) {
420                 ret = GrallocInitialize(&grallocFucs);
421                 DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("Gralloc init failed"));
422             }
423             AllocInfo info = {
424                 .width = dstRgaBuffer.width,
425                 .height = dstRgaBuffer.height,
426                 .usage = HBM_USE_MEM_DMA | HBM_USE_CPU_READ | HBM_USE_CPU_WRITE,
427                 .format = PIXEL_FMT_RGBA_8888, // srcSurface->enColorFmt,
428             };
429             BufferHandle *buffer = NULL;
430 
431             ret = grallocFucs->AllocMem(&info, &buffer);
432             DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not alloc memory"));
433 
434             bRgbBuffer.width = dstRgaBuffer.width;
435             bRgbBuffer.height = dstRgaBuffer.height;
436             bRgbBuffer.wstride = dstRgaBuffer.wstride;
437             bRgbBuffer.hstride = dstRgaBuffer.hstride;
438             bRgbBuffer.format = RK_FORMAT_RGBA_8888; // srcRgaBuffer.format;
439             bRgbBuffer.phy_addr = 0; // (void *) buffer->phyAddr;
440             bRgbBuffer.vir_addr = 0; // buffer->virAddr;
441             bRgbBuffer.color_space_mode = dstRgaBuffer.color_space_mode;
442             bRgbBuffer.fd = (int32_t)buffer->phyAddr;
443             int ret = memcpy_s(&prect, sizeof(drect), &drect, sizeof(drect));
444             if (!ret) {
445                 printf("memcpy_s failed!\n");
446             }
447             ret = improcess(srcRgaBuffer, bRgbBuffer, dstRgaBuffer, srect, prect, drect, usage);
448             if (ret != IM_STATUS_SUCCESS) {
449                 DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
450             } else {
451                 ret = imcopy(bRgbBuffer, dstRgaBuffer);
452                 if (ret != IM_STATUS_SUCCESS) {
453                     DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
454                 }
455             }
456             grallocFucs->FreeMem(buffer);
457         }
458     } else {
459         ret = improcess(srcRgaBuffer, dstRgaBuffer, bRgbBuffer, srect, drect, prect, usage);
460         if (ret != IM_STATUS_SUCCESS) {
461             DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
462         }
463     }
464     if (ret != IM_STATUS_SUCCESS)
465         return DISPLAY_FAILURE;
466     else
467         return DISPLAY_SUCCESS;
468 }
469 
rkBlit(ISurface * srcSurface,IRect * srcRect,ISurface * dstSurface,IRect * dstRect,GfxOpt * opt)470 int32_t rkBlit(ISurface *srcSurface, IRect *srcRect, ISurface *dstSurface, IRect *dstRect, GfxOpt *opt)
471 {
472     CHECK_NULLPOINTER_RETURN_VALUE(srcSurface, DISPLAY_NULL_PTR);
473     CHECK_NULLPOINTER_RETURN_VALUE(srcRect, DISPLAY_NULL_PTR);
474     CHECK_NULLPOINTER_RETURN_VALUE(dstSurface, DISPLAY_NULL_PTR);
475     CHECK_NULLPOINTER_RETURN_VALUE(dstRect, DISPLAY_NULL_PTR);
476     CHECK_NULLPOINTER_RETURN_VALUE(opt, DISPLAY_NULL_PTR);
477 
478     if (doFlit(srcSurface, srcRect, dstSurface, dstRect, opt) < 0)
479         return DISPLAY_FAILURE;
480     else
481         return DISPLAY_SUCCESS;
482 }
483 
rkSync(int32_t timeOut)484 int32_t rkSync(int32_t timeOut)
485 {
486     return DISPLAY_SUCCESS;
487 }
488 
GfxInitialize(GfxFuncs ** funcs)489 int32_t GfxInitialize(GfxFuncs **funcs)
490 {
491     DISPLAY_CHK_RETURN((funcs == NULL), DISPLAY_PARAM_ERR, DISPLAY_LOGE("info is null"));
492     GfxFuncs *gfxFuncs = (GfxFuncs *)malloc(sizeof(GfxFuncs));
493     DISPLAY_CHK_RETURN((gfxFuncs == NULL), DISPLAY_NULL_PTR, DISPLAY_LOGE("gfxFuncs is nullptr"));
494     errno_t eok = memset_s((void *)gfxFuncs, sizeof(GfxFuncs), 0, sizeof(GfxFuncs));
495     if (eok != EOK) {
496         DISPLAY_LOGE("memset_s failed");
497         free(gfxFuncs);
498         return DISPLAY_FAILURE;
499     }
500     gfxFuncs->InitGfx = rkInitGfx;
501     gfxFuncs->DeinitGfx = rkDeinitGfx;
502     gfxFuncs->FillRect = rkFillRect;
503     gfxFuncs->Blit = rkBlit;
504     gfxFuncs->Sync = rkSync;
505     *funcs = gfxFuncs;
506 
507     return DISPLAY_SUCCESS;
508 }
509 
GfxUninitialize(GfxFuncs * funcs)510 int32_t GfxUninitialize(GfxFuncs *funcs)
511 {
512     CHECK_NULLPOINTER_RETURN_VALUE(funcs, DISPLAY_NULL_PTR);
513     free(funcs);
514     DISPLAY_DEBUGLOG("%s: gfx uninitialize success", __func__);
515     return DISPLAY_SUCCESS;
516 }
517