• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef ANDROID
40 #include "RgaSingleton.h"
41 #endif
42 
43 #ifdef ANDROID
44 #include <utils/Singleton.h>
45 #include <utils/Thread.h>
46 #include <hardware/hardware.h>
47 
48 namespace android {
49 #endif
50 
51     class RockchipRga :public Singleton<RockchipRga> {
52       public:
53 
get()54         static inline RockchipRga& get() {
55             return getInstance();
56         }
57 
58         int         RkRgaInit();
59         void        RkRgaDeInit();
60         void        RkRgaGetContext(void **ctx);
61 #ifndef ANDROID /* LINUX */
62         int         RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info,
63                                      int width, int height, int bpp, int flags);
64         int         RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
65         int         RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
66         int         RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp, int flags);
67         int         RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
68         int         RkRgaGetMmap(bo_t *bo_info);
69         int         RkRgaUnmap(bo_t *bo_info);
70         int         RkRgaFree(bo_t *bo_info);
71         int         RkRgaGetBufferFd(bo_t *bo_info, int *fd);
72 #else
73         int         RkRgaGetBufferFd(buffer_handle_t handle, int *fd);
74         int         RkRgaGetHandleMapCpuAddress(buffer_handle_t handle, void **buf);
75 #endif
76         int         RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
77         int         RkRgaCollorFill(rga_info *dst);
78         int         RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
79         int         RkRgaFlush();
80 
81 
RkRgaSetLogOnceFlag(int log)82         void        RkRgaSetLogOnceFlag(int log) {
83             mLogOnce = log;
84         }
RkRgaSetAlwaysLogFlag(bool log)85         void        RkRgaSetAlwaysLogFlag(bool log) {
86             mLogAlways = log;
87         }
88         void        RkRgaLogOutRgaReq(struct rga_req rgaReg);
89         int         RkRgaLogOutUserPara(rga_info *rgaInfo);
RkRgaIsReady()90         inline bool RkRgaIsReady() {
91             return mSupportRga;
92         }
93 
94         RockchipRga();
95         ~RockchipRga();
96       private:
97         bool                            mSupportRga;
98         int                             mLogOnce;
99         int                             mLogAlways;
100         void *                          mContext;
101 
102         friend class Singleton<RockchipRga>;
103     };
104 
105 #ifdef ANDROID
106 }; // namespace android
107 #endif
108 
109 #endif
110 
111