im2d_common.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (C) 2022 Rockchip Electronics Co., Ltd.
  3. * Authors:
  4. * Cerf Yu <cerf.yu@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 _im2d_common_h_
  19. #define _im2d_common_h_
  20. #include "im2d_type.h"
  21. /**
  22. * Query RGA basic information, supported resolution, supported format, etc.
  23. *
  24. * @param name
  25. * RGA_VENDOR
  26. * RGA_VERSION
  27. * RGA_MAX_INPUT
  28. * RGA_MAX_OUTPUT
  29. * RGA_INPUT_FORMAT
  30. * RGA_OUTPUT_FORMAT
  31. * RGA_EXPECTED
  32. * RGA_ALL
  33. *
  34. * @returns a string describing properties of RGA.
  35. */
  36. IM_EXPORT_API const char* querystring(int name);
  37. /**
  38. * String to output the error message
  39. *
  40. * @param status
  41. * process result value.
  42. *
  43. * @returns error message.
  44. */
  45. #define imStrError(...) \
  46. ({ \
  47. const char* im2d_api_err; \
  48. int __args[] = {__VA_ARGS__}; \
  49. int __argc = sizeof(__args)/sizeof(int); \
  50. if (__argc == 0) { \
  51. im2d_api_err = imStrError_t(IM_STATUS_INVALID_PARAM); \
  52. } else if (__argc == 1){ \
  53. im2d_api_err = imStrError_t((IM_STATUS)__args[0]); \
  54. } else { \
  55. im2d_api_err = ("Fatal error, imStrError() too many parameters\n"); \
  56. printf("Fatal error, imStrError() too many parameters\n"); \
  57. } \
  58. im2d_api_err; \
  59. })
  60. IM_C_API const char* imStrError_t(IM_STATUS status);
  61. /**
  62. * check im2d api header file
  63. *
  64. * @param header_version
  65. * Default is RGA_CURRENT_API_HEADER_VERSION, no need to change if there are no special cases.
  66. *
  67. * @returns no error or else negative error code.
  68. */
  69. #ifdef __cplusplus
  70. IM_API IM_STATUS imcheckHeader(im_api_version_t header_version = RGA_CURRENT_API_HEADER_VERSION);
  71. #endif
  72. /**
  73. * check RGA basic information, supported resolution, supported format, etc.
  74. *
  75. * @param src
  76. * @param dst
  77. * @param pat
  78. * @param src_rect
  79. * @param dst_rect
  80. * @param pat_rect
  81. * @param mode_usage
  82. *
  83. * @returns no error or else negative error code.
  84. */
  85. #define imcheck(src, dst, src_rect, dst_rect, ...) \
  86. ({ \
  87. IM_STATUS __ret = IM_STATUS_NOERROR; \
  88. rga_buffer_t __pat; \
  89. im_rect __pat_rect; \
  90. memset(&__pat, 0, sizeof(rga_buffer_t)); \
  91. memset(&__pat_rect, 0, sizeof(im_rect)); \
  92. int __args[] = {__VA_ARGS__}; \
  93. int __argc = sizeof(__args)/sizeof(int); \
  94. if (__argc == 0) { \
  95. __ret = imcheck_t(src, dst, __pat, src_rect, dst_rect, __pat_rect, 0); \
  96. } else if (__argc == 1){ \
  97. __ret = imcheck_t(src, dst, __pat, src_rect, dst_rect, __pat_rect, __args[0]); \
  98. } else { \
  99. __ret = IM_STATUS_FAILED; \
  100. printf("check failed\n"); \
  101. } \
  102. __ret; \
  103. })
  104. #define imcheck_composite(src, dst, pat, src_rect, dst_rect, pat_rect, ...) \
  105. ({ \
  106. IM_STATUS __ret = IM_STATUS_NOERROR; \
  107. int __args[] = {__VA_ARGS__}; \
  108. int __argc = sizeof(__args)/sizeof(int); \
  109. if (__argc == 0) { \
  110. __ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, 0); \
  111. } else if (__argc == 1){ \
  112. __ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, __args[0]); \
  113. } else { \
  114. __ret = IM_STATUS_FAILED; \
  115. printf("check failed\n"); \
  116. } \
  117. __ret; \
  118. })
  119. IM_C_API IM_STATUS imcheck_t(const rga_buffer_t src, const rga_buffer_t dst, const rga_buffer_t pat,
  120. const im_rect src_rect, const im_rect dst_rect, const im_rect pat_rect, const int mode_usage);
  121. /* Compatible with the legacy symbol */
  122. IM_C_API void rga_check_perpare(rga_buffer_t *src, rga_buffer_t *dst, rga_buffer_t *pat,
  123. im_rect *src_rect, im_rect *dst_rect, im_rect *pat_rect, int mode_usage);
  124. /**
  125. * block until all execution is complete
  126. *
  127. * @param release_fence_fd
  128. * RGA job release fence fd
  129. *
  130. * @returns success or else negative error code.
  131. */
  132. IM_EXPORT_API IM_STATUS imsync(int release_fence_fd);
  133. /**
  134. * config
  135. *
  136. * @param name
  137. * enum IM_CONFIG_NAME
  138. * @param value
  139. *
  140. * @returns success or else negative error code.
  141. */
  142. IM_EXPORT_API IM_STATUS imconfig(IM_CONFIG_NAME name, uint64_t value);
  143. #endif /* #ifndef _im2d_common_h_ */