1 /*
2  * Copyright (C) 2016 Rockchip Electronics Co., Ltd.
3  * Authors:
4  *  Zhiqin Wei <wzq@rock-chips.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef _rockchip_rga_h_
20 #define _rockchip_rga_h_
21 
22 #include <stdint.h>
23 #include <sys/types.h>
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <errno.h>
28 #include <time.h>
29 #include <unistd.h>
30 #include <sys/mman.h>
31 #include <linux/stddef.h>
32 
33 #include "drmrga.h"
34 #include "GrallocOps.h"
35 #include "RgaUtils.h"
36 #include "rga.h"
37 
38 //////////////////////////////////////////////////////////////////////////////////
39 #include "RgaSingleton.h"
40 
41 class RockchipRga : public RgaSingleton<RockchipRga> {
42 public:
43 
get()44     static inline RockchipRga& get()
45     {
46         return getInstance();
47     }
48 
49     int         RkRgaInit();
50     void        RkRgaDeInit();
51     void        RkRgaGetContext(void **ctx);
52     int         RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info,
53                                     int width, int height, int bpp, int flags);
54     int         RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
55     int         RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
56     int         RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp, int flags);
57     int         RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
58     int         RkRgaGetMmap(bo_t *bo_info);
59     int         RkRgaUnmap(bo_t *bo_info);
60     int         RkRgaFree(bo_t *bo_info);
61     int         RkRgaGetBufferFd(bo_t *bo_info, int *fd);
62     int         RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
63     int         RkRgaCollorFill(rga_info *dst);
64     int         RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
65     int         RkRgaFlush();
RkRgaSetLogOnceFlag(int log)66     void        RkRgaSetLogOnceFlag(int log)
67     {
68         mLogOnce = log;
69     }
RkRgaSetAlwaysLogFlag(bool log)70     void        RkRgaSetAlwaysLogFlag(bool log)
71     {
72         mLogAlways = log;
73     }
74     void        RkRgaLogOutRgaReq(struct rga_req rgaReg);
75     int         RkRgaLogOutUserPara(rga_info *rgaInfo);
RkRgaIsReady()76     inline bool RkRgaIsReady()
77     {
78         return mSupportRga;
79     }
80 
81     RockchipRga();
82     ~RockchipRga();
83 private:
84     bool mSupportRga;
85     int mLogOnce;
86     int mLogAlways;
87     void *mContext;
88 
89     friend class RgaSingleton<RockchipRga>;
90 };
91 #endif
92