RockchipRga.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef _rockchip_rga_h_
  19. #define _rockchip_rga_h_
  20. #include <stdint.h>
  21. #include <sys/types.h>
  22. #include <stdlib.h>
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <errno.h>
  26. #include <time.h>
  27. #include <unistd.h>
  28. #include <sys/mman.h>
  29. #include <linux/stddef.h>
  30. #include "drmrga.h"
  31. #include "GrallocOps.h"
  32. #include "RgaUtils.h"
  33. #include "rga.h"
  34. //////////////////////////////////////////////////////////////////////////////////
  35. #ifndef ANDROID
  36. #include "RgaSingleton.h"
  37. #endif
  38. #ifdef ANDROID
  39. #include <utils/Singleton.h>
  40. #include <utils/Thread.h>
  41. #include <hardware/hardware.h>
  42. namespace android {
  43. #endif
  44. class RockchipRga :public Singleton<RockchipRga> {
  45. public:
  46. static inline RockchipRga& get() {
  47. return getInstance();
  48. }
  49. int RkRgaInit();
  50. void RkRgaDeInit();
  51. void RkRgaGetContext(void **ctx);
  52. #ifndef ANDROID /* LINUX */
  53. int RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info,
  54. int width, int height, int bpp, int flags);
  55. int RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
  56. int RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
  57. int RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp, int flags);
  58. int RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
  59. int RkRgaGetMmap(bo_t *bo_info);
  60. int RkRgaUnmap(bo_t *bo_info);
  61. int RkRgaFree(bo_t *bo_info);
  62. int RkRgaGetBufferFd(bo_t *bo_info, int *fd);
  63. #else
  64. int RkRgaGetBufferFd(buffer_handle_t handle, int *fd);
  65. int RkRgaGetHandleMapCpuAddress(buffer_handle_t handle, void **buf);
  66. #endif
  67. int RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
  68. int RkRgaCollorFill(rga_info *dst);
  69. int RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
  70. int RkRgaFlush();
  71. void RkRgaSetLogOnceFlag(int log) {
  72. mLogOnce = log;
  73. }
  74. void RkRgaSetAlwaysLogFlag(bool log) {
  75. mLogAlways = log;
  76. }
  77. void RkRgaLogOutRgaReq(struct rga_req rgaReg);
  78. int RkRgaLogOutUserPara(rga_info *rgaInfo);
  79. inline bool RkRgaIsReady() {
  80. return mSupportRga;
  81. }
  82. RockchipRga();
  83. ~RockchipRga();
  84. private:
  85. bool mSupportRga;
  86. int mLogOnce;
  87. int mLogAlways;
  88. void * mContext;
  89. friend class Singleton<RockchipRga>;
  90. };
  91. #ifdef ANDROID
  92. }; // namespace android
  93. #endif
  94. #endif