• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 
42     switch (color) {
43         case PIXEL_FMT_RGB_565:          /**< RGB565 format */
44             rkFormat = RK_FORMAT_RGB_565;
45             *isYuv = 0;
46             break;
47         case PIXEL_FMT_RGBA_4444:        /**< RGBA4444 format */
48             rkFormat = RK_FORMAT_RGBA_4444;
49             *isYuv = 0;
50             break;
51         case PIXEL_FMT_RGBA_5551:        /**< RGBA5551 format */
52             rkFormat = RK_FORMAT_RGBA_5551;
53             *isYuv = 0;
54             break;
55         case PIXEL_FMT_RGBX_8888:        /**< RGBX8888 format */
56             rkFormat = RK_FORMAT_RGBX_8888;
57             *isYuv = 0;
58             break;
59         case PIXEL_FMT_RGBA_8888:        /**< RGBA8888 format */
60             rkFormat = RK_FORMAT_RGBA_8888;
61             *isYuv = 0;
62             break;
63         case PIXEL_FMT_RGB_888:          /**< RGB888 format */
64             rkFormat = RK_FORMAT_RGB_888;
65             *isYuv = 0;
66             break;
67         case PIXEL_FMT_BGR_565:          /**< BGR565 format */
68             rkFormat = RK_FORMAT_BGR_565;
69             *isYuv = 0;
70             break;
71         case PIXEL_FMT_BGRA_4444:        /**< BGRA4444 format */
72             rkFormat = RK_FORMAT_BGRA_4444;
73             *isYuv = 0;
74             break;
75         case PIXEL_FMT_BGRA_5551:        /**< BGRA5551 format */
76             rkFormat = RK_FORMAT_BGRA_5551;
77             *isYuv = 0;
78             break;
79         case PIXEL_FMT_BGRX_8888:        /**< BGRX8888 format */
80             rkFormat = RK_FORMAT_BGRX_8888;
81             *isYuv = 0;
82             break;
83         case PIXEL_FMT_BGRA_8888:        /**< BGRA8888 format */
84             rkFormat = RK_FORMAT_BGRA_8888;
85             *isYuv = 0;
86             break;
87         case PIXEL_FMT_YCBCR_422_SP:     /**< YCBCR422 semi-planar format */
88             rkFormat = RK_FORMAT_YCbCr_420_SP;
89             *isYuv = 1;
90             break;
91         case PIXEL_FMT_YCRCB_422_SP:     /**< YCRCB422 semi-planar format */
92             rkFormat = RK_FORMAT_YCrCb_422_SP;
93             *isYuv = 1;
94             break;
95         case PIXEL_FMT_YCBCR_420_SP:     /**< YCBCR420 semi-planar format */
96             rkFormat = RK_FORMAT_YCbCr_420_SP;
97             *isYuv = 1;
98             break;
99         case PIXEL_FMT_YCRCB_420_SP:     /**< YCRCB420 semi-planar format */
100             rkFormat = RK_FORMAT_YCrCb_420_SP;
101             *isYuv = 1;
102             break;
103         case PIXEL_FMT_YCBCR_422_P:      /**< YCBCR422 planar format */
104             rkFormat = RK_FORMAT_YCbCr_422_P;
105             *isYuv = 1;
106             break;
107         case PIXEL_FMT_YCRCB_422_P:      /**< YCRCB422 planar format */
108             rkFormat = RK_FORMAT_YCrCb_422_P;
109             *isYuv = 1;
110             break;
111         case PIXEL_FMT_YCBCR_420_P:      /**< YCBCR420 planar format */
112             rkFormat = RK_FORMAT_YCbCr_420_P;
113             *isYuv = 1;
114             break;
115         case PIXEL_FMT_YCRCB_420_P:      /**< YCRCB420 planar format */
116             rkFormat = RK_FORMAT_YCrCb_420_P;
117             *isYuv = 1;
118             break;
119         case PIXEL_FMT_YUYV_422_PKG:     /**< YUYV422 packed format */
120             rkFormat = RK_FORMAT_YUYV_422;
121             *isYuv = 1;
122             break;
123         case PIXEL_FMT_UYVY_422_PKG:     /**< UYVY422 packed format */
124             rkFormat = RK_FORMAT_UYVY_422;
125             *isYuv = 1;
126             break;
127         case PIXEL_FMT_YVYU_422_PKG:     /**< YVYU422 packed format */
128             rkFormat = RK_FORMAT_YUYV_422;
129             *isYuv = 1;
130             break;
131         case PIXEL_FMT_VYUY_422_PKG:     /**< VYUY422 packed format */
132             rkFormat = RK_FORMAT_VYUY_422;
133             *isYuv = 1;
134             break;
135         default:
136 //          PIXEL_FMT_CLUT8:        /**< CLUT8 format */
137 //          PIXEL_FMT_CLUT1,            /**< CLUT1 format */
138 //          PIXEL_FMT_CLUT4,            /**< CLUT4 format */
139 //          PIXEL_FMT_RGBA_5658,        /**< RGBA5658 format */
140 //          PIXEL_FMT_RGBX_4444,        /**< RGBX4444 format */
141 //          PIXEL_FMT_RGB_444,          /**< RGB444 format */
142 //          PIXEL_FMT_RGBX_5551,        /**< RGBX5551 format */
143 //          PIXEL_FMT_RGB_555,          /**< RGB555 format */
144 //          PIXEL_FMT_BGRX_4444,        /**< BGRX4444 format */
145 //          PIXEL_FMT_BGRX_5551,        /**< BGRX5551 format */
146 //          PIXEL_FMT_YUV_422_I,        /**< YUV422 interleaved format */
147             rkFormat = RK_FORMAT_UNKNOWN;
148             break;
149     }
150     return rkFormat;
151 }
152 
rkFillRect(ISurface * iSurface,IRect * rect,uint32_t color,GfxOpt * opt)153 int32_t rkFillRect(ISurface *iSurface, IRect *rect, uint32_t color, GfxOpt *opt)
154 {
155     rga_buffer_t dst;
156     im_rect imRect;
157     IM_STATUS ret;
158     uint8_t isYuv;
159 
160     errno_t eok = memset_s((void *)&imRect, sizeof(imRect), 0, sizeof(imRect));
161     if (eok != EOK) {
162         DISPLAY_LOGE("memset_s failed");
163         return false;
164     }
165     imRect.x = rect->x;
166     imRect.y = rect->y;
167     imRect.width = rect->w;
168     imRect.height = rect->h;
169 
170     eok = memset_s((void *)&dst, sizeof(dst), 0, sizeof(dst));
171     if (eok != EOK) {
172         DISPLAY_LOGE("memset_s failed");
173         return false;
174     }
175     dst.phy_addr = 0; // (void*)iSurface->phyAddr;
176     dst.vir_addr = 0; // iSurface->virAddr;
177     dst.fd = (int32_t)iSurface->phyAddr;
178     if ((int)dst.phy_addr == 0 && dst.fd == 0 && dst.vir_addr == NULL) {
179         DISPLAY_LOGE("source iSurface address error");
180         return DISPLAY_PARAM_ERR;
181     }
182     DISPLAY_LOGE("gfx vir %{public}p phy 0x%{public}x fd %{public}d", dst.vir_addr, (int32_t)dst.phy_addr, dst.fd);
183     dst.width = iSurface->width;
184     dst.height = iSurface->height;
185     dst.wstride = ALIGN_UP(iSurface->width, 16);
186     dst.hstride = ALIGN_UP(iSurface->height, 16);
187     dst.format = colorSpaceModeChange(iSurface->enColorFmt, &isYuv);
188     dst.color_space_mode = IM_COLOR_SPACE_DEFAULT;
189     dst.color = color;
190     if (opt->enGlobalAlpha)
191         dst.global_alpha = opt->globalAlpha;
192     ret = imfill(dst, imRect, color);
193     if (ret != IM_STATUS_SUCCESS)
194         return DISPLAY_FAILURE;
195     else
196         return DISPLAY_SUCCESS;
197 }
198 
blendTypeChange(BlendType blendType)199 int32_t blendTypeChange(BlendType blendType)
200 {
201     int32_t rkBlendType;
202 
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 ((int)srcRgaBuffer.phy_addr == 0 && srcRgaBuffer.fd == 0 && srcRgaBuffer.vir_addr == NULL) {
347         DISPLAY_LOGE("source iSurface address error");
348         return DISPLAY_PARAM_ERR;
349     }
350 
351     DISPLAY_LOGE("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, ALIGN_UP(srcSurface->width, 16),
353         ALIGN_UP(srcSurface->height, 16), srcRgaBuffer.vir_addr);
354     DISPLAY_LOGE("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, ALIGN_UP(dstSurface->width, 16),
356         ALIGN_UP(dstSurface->height, 16), dstRgaBuffer.vir_addr);
357 
358     srect.x = srcRect->x;
359     srect.y = srcRect->y;
360     srect.height = srcRect->h;
361     srect.width = srcRect->w;
362     drect.x = dstRect->x;
363     drect.y = dstRect->y;
364     drect.height = dstRect->h;
365     drect.width = dstRect->w;
366 
367     if (opt->blendType) {
368         rkBlendType = blendTypeChange(opt->blendType);
369         if (rkBlendType > 0) {
370             usage |= rkBlendType;
371             if (rkBlendType == IM_ALPHA_BLEND_DST_OVER || rkBlendType == IM_ALPHA_BLEND_SRC_OVER)
372                 usage |= IM_ALPHA_BLEND_PRE_MUL;
373         } else if (rkBlendType == IM_STATUS_NOT_SUPPORTED) {
374             return DISPLAY_NOT_SUPPORT;
375         }
376     }
377     if (opt->rotateType) {
378         rkRotateType = TransformTypeChange(opt->rotateType);
379         if (rkRotateType != 0)
380             usage |= rkRotateType;
381     }
382     if (opt->mirrorType == MIRROR_LR || opt->mirrorType == MIRROR_TB) {
383         rkMirrorType = mirrorTypeChange(opt->mirrorType);
384         if (rkMirrorType != 0)
385             usage |= rkMirrorType;
386     }
387     if (opt->enableScale) {
388         DISPLAY_LOGE("gfx scale from (%{puhblic}d, %{public}d) to (%{public}d, %{public}d)", srcRgaBuffer.width,
389                      srcRgaBuffer.height, dstRgaBuffer.width, dstRgaBuffer.height);
390     }
391     usage |= IM_SYNC;
392     if (isYuv == 1) {
393         if (rkBlendType == IM_ALPHA_BLEND_SRC_OVER || rkBlendType == IM_ALPHA_BLEND_SRC) {
394             usage = 0;
395             if (opt->enableScale == 0) {
396                 eok = memset_s(&srect, sizeof(srect), 0, sizeof(srect));
397                 if (eok != EOK) {
398                     DISPLAY_LOGE("memset_s failed");
399                     return false;
400                 }
401                 srect.width = srcRgaBuffer.width;
402                 srect.height = srcRgaBuffer.height;
403 
404                 eok = memset_s(&drect, sizeof(drect), 0, sizeof(drect));
405                 if (eok != EOK) {
406                     DISPLAY_LOGE("memset_s failed");
407                     return false;
408                 }
409                 drect.x = dstRgaBuffer.width - srcRgaBuffer.width;
410                 drect.y = dstRgaBuffer.height - srcRgaBuffer.height;
411                 drect.width = srcRgaBuffer.width;
412                 drect.height = srcRgaBuffer.height;
413             }
414             usage = rkRotateType | rkMirrorType | IM_SYNC;
415             ret = improcess(srcRgaBuffer, dstRgaBuffer, bRgbBuffer, srect, drect, prect, usage);
416             if (ret != IM_STATUS_SUCCESS) {
417                 DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
418             }
419         } else if (rkBlendType == IM_ALPHA_BLEND_DST_OVER) {
420             if (grallocFucs == NULL) {
421                 ret = GrallocInitialize(&grallocFucs);
422                 DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("Gralloc init failed"));
423             }
424             AllocInfo info = {
425                 .width = dstRgaBuffer.width,
426                 .height = dstRgaBuffer.height,
427                 .usage = HBM_USE_MEM_DMA | HBM_USE_CPU_READ | HBM_USE_CPU_WRITE,
428                 .format = PIXEL_FMT_RGBA_8888, // srcSurface->enColorFmt,
429             };
430             BufferHandle *buffer = NULL;
431 
432             ret = grallocFucs->AllocMem(&info, &buffer);
433             DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not alloc memory"));
434 
435             bRgbBuffer.width = dstRgaBuffer.width;
436             bRgbBuffer.height = dstRgaBuffer.height;
437             bRgbBuffer.wstride = dstRgaBuffer.wstride;
438             bRgbBuffer.hstride = dstRgaBuffer.hstride;
439             bRgbBuffer.format = RK_FORMAT_RGBA_8888; // srcRgaBuffer.format;
440             bRgbBuffer.phy_addr = 0; // (void *) buffer->phyAddr;
441             bRgbBuffer.vir_addr = 0; // buffer->virAddr;
442             bRgbBuffer.color_space_mode = dstRgaBuffer.color_space_mode;
443             bRgbBuffer.fd = (int32_t)buffer->phyAddr;
444             int ret = memcpy_s(&prect, sizeof(drect), &drect, sizeof(drect));
445             if (!ret) {
446                 printf("memcpy_s failed!\n");
447             }
448             ret = improcess(srcRgaBuffer, bRgbBuffer, dstRgaBuffer, srect, prect, drect, usage);
449             if (ret != IM_STATUS_SUCCESS) {
450                 DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
451             } else {
452                 ret = imcopy(bRgbBuffer, dstRgaBuffer);
453                 if (ret != IM_STATUS_SUCCESS) {
454                     DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
455                 }
456             }
457             grallocFucs->FreeMem(buffer);
458         }
459     } else {
460         ret = improcess(srcRgaBuffer, dstRgaBuffer, bRgbBuffer, srect, drect, prect, usage);
461         if (ret != IM_STATUS_SUCCESS) {
462             DISPLAY_LOGE("gfx improcess %{public}s", imStrError(ret));
463         }
464     }
465     if (ret != IM_STATUS_SUCCESS)
466         return DISPLAY_FAILURE;
467     else
468         return DISPLAY_SUCCESS;
469 }
470 
rkBlit(ISurface * srcSurface,IRect * srcRect,ISurface * dstSurface,IRect * dstRect,GfxOpt * opt)471 int32_t rkBlit(ISurface *srcSurface, IRect *srcRect, ISurface *dstSurface, IRect *dstRect, GfxOpt *opt)
472 {
473     CHECK_NULLPOINTER_RETURN_VALUE(srcSurface, DISPLAY_NULL_PTR);
474     CHECK_NULLPOINTER_RETURN_VALUE(srcRect, DISPLAY_NULL_PTR);
475     CHECK_NULLPOINTER_RETURN_VALUE(dstSurface, DISPLAY_NULL_PTR);
476     CHECK_NULLPOINTER_RETURN_VALUE(dstRect, DISPLAY_NULL_PTR);
477     CHECK_NULLPOINTER_RETURN_VALUE(opt, DISPLAY_NULL_PTR);
478 
479     if (doFlit(srcSurface, srcRect, dstSurface, dstRect, opt) < 0)
480         return DISPLAY_FAILURE;
481     else
482         return DISPLAY_SUCCESS;
483 }
484 
rkSync(int32_t timeOut)485 int32_t rkSync(int32_t timeOut)
486 {
487     return DISPLAY_SUCCESS;
488 }
489 
GfxInitialize(GfxFuncs ** funcs)490 int32_t GfxInitialize(GfxFuncs **funcs)
491 {
492     DISPLAY_CHK_RETURN((funcs == NULL), DISPLAY_PARAM_ERR, DISPLAY_LOGE("info is null"));
493     GfxFuncs *gfxFuncs = (GfxFuncs *)malloc(sizeof(GfxFuncs));
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 false;
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_LOGI("%s: gfx uninitialize success", __func__);
515     return DISPLAY_SUCCESS;
516 }
517