• 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 #include "RgaSingleton.h"
40 
41 class RockchipRga : public Singleton<RockchipRga> {
42 public:
43 
get()44     static inline RockchipRga& get() {
45         return getInstance();
46     }
47 
48     int         RkRgaInit();
49     void        RkRgaDeInit();
50     void        RkRgaGetContext(void **ctx);
51     int         RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info,
52                                     int width, int height, int bpp, int flags);
53     int         RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
54     int         RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
55     int         RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp, int flags);
56     int         RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
57     int         RkRgaGetMmap(bo_t *bo_info);
58     int         RkRgaUnmap(bo_t *bo_info);
59     int         RkRgaFree(bo_t *bo_info);
60     int         RkRgaGetBufferFd(bo_t *bo_info, int *fd);
61     int         RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
62     int         RkRgaCollorFill(rga_info *dst);
63     int         RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
64     int         RkRgaFlush();
RkRgaSetLogOnceFlag(int log)65     void        RkRgaSetLogOnceFlag(int log)
66     {
67         mLogOnce = log;
68     }
RkRgaSetAlwaysLogFlag(bool log)69     void        RkRgaSetAlwaysLogFlag(bool log)
70     {
71         mLogAlways = log;
72     }
73     void        RkRgaLogOutRgaReq(struct rga_req rgaReg);
74     int         RkRgaLogOutUserPara(rga_info *rgaInfo);
RkRgaIsReady()75     inline bool RkRgaIsReady()
76     {
77         return mSupportRga;
78     }
79 
80     RockchipRga();
81     ~RockchipRga();
82 private:
83     bool mSupportRga;
84     int mLogOnce;
85     int mLogAlways;
86     void *mContext;
87 
88     friend class Singleton<RockchipRga>;
89 };
90 #endif
91