ui_memsetcpy.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * Copyright (c) 2020 Actions Technology Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief UI specific memeset/memcpy
  9. */
  10. #ifndef ZEPHYR_FRAMEWORK_INCLUDE_DISPLAY_UI_MEMSETCPY_H_
  11. #define ZEPHYR_FRAMEWORK_INCLUDE_DISPLAY_UI_MEMSETCPY_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <string.h>
  15. /**
  16. * @defgroup display-util Display Utilities
  17. * @ingroup display_libraries
  18. * @{
  19. */
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /*
  24. * @brief memset 8-bit pattern
  25. *
  26. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  27. * buf may acccess uncached, cache invalidation on buf may be required.
  28. *
  29. * @param buf buf address
  30. * @param c 8-bit pattern to set
  31. * @param n number of elements in 8-bit
  32. *
  33. * @retval N/A
  34. */
  35. void ui_memset(void * buf, uint8_t c, size_t n);
  36. /*
  37. * @brief memset 16-bit pattern
  38. *
  39. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  40. * buf may acccess uncached, cache invalidation on buf may be required.
  41. *
  42. * @param buf buf address
  43. * @param c16 16-bit pattern to set
  44. * @param n16 number of elements in 16-bit
  45. *
  46. * @retval N/A
  47. */
  48. void ui_memset16(void * buf, uint16_t c16, size_t n16);
  49. /*
  50. * @brief memset 24-bit pattern
  51. *
  52. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  53. * buf may acccess uncached, cache invalidation on buf may be required.
  54. *
  55. * @param buf buf address
  56. * @param c16 24-bit pattern to set
  57. * @param n24 number of elements in 24-bit
  58. *
  59. * @retval N/A
  60. */
  61. void ui_memset24(void * buf, const uint8_t c24[3], size_t n24);
  62. /*
  63. * @brief memset 32-bit pattern
  64. *
  65. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  66. * buf may acccess uncached, cache invalidation on buf may be required.
  67. *
  68. * @param buf buf address
  69. * @param c32 32-bit pattern to set
  70. * @param n32 number of elements in 32-bit
  71. *
  72. * @retval N/A
  73. */
  74. void ui_memset32(void * buf, uint32_t c32, size_t n32);
  75. /*
  76. * @brief ui_memset2d
  77. *
  78. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  79. * dest may acccess uncached, cache invalidation on buf may be required.
  80. *
  81. * @param buf buffer address
  82. * @param stride number of bytes between consecutive rows in buffer
  83. * @param c value to set
  84. * @param len number of bytes in each line to clear zero
  85. * @param lines number of lines
  86. *
  87. * @retval N/A
  88. */
  89. void ui_memset2d(void * buf, uint16_t stride, uint8_t c, uint16_t len, uint16_t lines);
  90. /*
  91. * @brief ui_memset2d
  92. *
  93. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  94. * dest may acccess uncached, cache invalidation on buf may be required.
  95. *
  96. * @param buf buffer address
  97. * @param stride number of bytes between consecutive rows in buffer
  98. * @param c16 16-bit value to set
  99. * @param len16 number of elements in 16-bit in each line to clear zero
  100. * @param len number of bytes in each line to clear zero
  101. * @param lines number of lines
  102. *
  103. * @retval N/A
  104. */
  105. void ui_memset2d_16(void * buf, uint16_t stride, uint16_t c16, uint16_t len16, uint16_t lines);
  106. /*
  107. * @brief ui_memset2d
  108. *
  109. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  110. * dest may acccess uncached, cache invalidation on buf may be required.
  111. *
  112. * @param buf buffer address
  113. * @param stride number of bytes between consecutive rows in buffer
  114. * @param c24 24-bit value to set
  115. * @param len24 number of elements in 24-bit in each line to clear zero
  116. * @param lines number of lines
  117. *
  118. * @retval N/A
  119. */
  120. void ui_memset2d_24(void * buf, uint16_t stride, const uint8_t c24[3], uint16_t len24, uint16_t lines);
  121. /*
  122. * @brief ui_memset2d
  123. *
  124. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  125. * dest may acccess uncached, cache invalidation on buf may be required.
  126. *
  127. * @param buf buffer address
  128. * @param stride number of bytes between consecutive rows in buffer
  129. * @param c32 32-bit value to set
  130. * @param len32 number of elements in 32-bit in each line to clear zero
  131. * @param lines number of lines
  132. *
  133. * @retval N/A
  134. */
  135. void ui_memset2d_32(void * buf, uint16_t stride, uint32_t c32, uint16_t len32, uint16_t lines);
  136. /*
  137. * @brief memcpy
  138. *
  139. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  140. * dest and src may acccess uncached, cache invalidation on buf may be required.
  141. *
  142. * @param dest dest address
  143. * @param src src address
  144. * @param n number of bytes
  145. *
  146. * @retval N/A
  147. */
  148. void ui_memcpy(void * dest, const void * src, size_t n);
  149. /*
  150. * @brief ui_memcpy2d
  151. *
  152. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  153. * dest and src may acccess uncached, cache invalidation on buf may be required.
  154. *
  155. * @param dest dest address
  156. * @param dest_stride number of bytes between consecutive rows in dest buffer
  157. * @param src src address
  158. * @param src_stride number of bytes between consecutive rows in src buffer
  159. * @param len number of bytes in each line to copy
  160. * @param lines number of lines
  161. *
  162. * @retval N/A
  163. */
  164. void ui_memcpy2d(void * dest, uint16_t dest_stride, const void * src,
  165. uint16_t src_stride, uint16_t len, uint16_t lines);
  166. /*
  167. * @brief ui_memcpy_region
  168. *
  169. * @note This function is asynchronous. Call ui_memsetcpy_wait_finish() to synchronize.
  170. * dest and src may acccess uncached, cache invalidation on buf may be required.
  171. *
  172. * @param dest dest address
  173. * @param src src address
  174. * @param w number of bytes
  175. * @param h number of bytes
  176. *
  177. * @retval N/A
  178. */
  179. static inline void ui_memcpy_region(void * dest, const void * src, uint16_t w, uint16_t h)
  180. {
  181. ui_memcpy2d(dest, w, src, w, w, h);
  182. }
  183. /*
  184. * @brief wait prevous memset/memcpy finished
  185. *
  186. * @param timeout_ms time to wait, set negative value to wait forever.
  187. *
  188. * @retval 0 Finished.
  189. * @retval -EAGAIN Waiting period timed out.
  190. */
  191. int ui_memsetcpy_wait_finish(int timeout_ms);
  192. #ifdef __cplusplus
  193. }
  194. #endif
  195. /**
  196. * @}
  197. */
  198. #endif /* ZEPHYR_FRAMEWORK_INCLUDE_DISPLAY_UI_MEMSETCPY_H_ */