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