media_mem.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * Copyright (c) 2018 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file Media memory interface
  8. */
  9. #ifndef __MEDIA_MEMORY_H__
  10. #define __MEDIA_MEMORY_H__
  11. /**
  12. * @defgroup media_memory_apis Media Memory APIs
  13. * @ingroup media_system_apis
  14. * @{
  15. */
  16. /** ---media service global memory type--- */
  17. typedef enum {
  18. /** playback input stream buffer */
  19. INPUT_PLAYBACK,
  20. /** capture input stream buffer */
  21. INPUT_CAPTURE,
  22. /** playback output stream buffer, after decode and mix*/
  23. OUTPUT_PLAYBACK,
  24. /** capture output stream buffer, after aec and encode*/
  25. OUTPUT_CAPTURE,
  26. /** decoder output stream buffer*/
  27. OUTPUT_DECODER,
  28. /** decoder output resample buffer*/
  29. OUTPUT_RESAMPLE,
  30. /** encoder input stream buffer */
  31. INPUT_ENCBUF,
  32. /** AEC reference stream buffer */
  33. AEC_REFBUF0,
  34. /** audiostream internal input pcm buffer */
  35. INPUT_PCM,
  36. /** audiostream internal output pcm buffer */
  37. OUTPUT_PCM,
  38. /** audiostream internal output pcm buffer */
  39. INPUT_RESAMPLE,
  40. /* ---bt stream global memory--- */
  41. /** bt upload sco send cache buffer */
  42. OUTPUT_SCO,
  43. /** bt upload sco send temp buffer */
  44. TX_SCO,
  45. /** bt upload sco send cache buffer */
  46. RX_SCO,
  47. /** ---other global memory--- */
  48. SBC_DECODER_GLOBAL_DATA,
  49. SBC_DECODER_SHARE_DATA,
  50. SBC_ENCODER_GLOBAL_DATA,
  51. SBC_ENCODER_SHARE_DATA,
  52. SBC_ENCODER_2_GLOBAL_DATA,
  53. SBC_ENCODER_2_SHARE_DATA,
  54. DECODER_GLOBAL_DATA,
  55. DECODER_SHARE_DATA,
  56. ENCODER_GLOBAL_DATA,
  57. ENCODER_SHARE_DATA,
  58. USB_UPLOAD_CACHE,
  59. USB_UPLOAD_PAYLOAD,
  60. TWS_LOCAL_INPUT, /* tws local stream */
  61. TTS_STACK,
  62. CODEC_STACK,
  63. TOOL_ASQT_STUB_BUF,
  64. TOOL_ASQT_DUMP_BUF,
  65. TOOL_ECTT_BUF,
  66. /* libraries's exported buffer */
  67. AEC_GLOBAL_DATA,
  68. AEC_SHARE_DATA,
  69. PLC_GLOBAL_DATA,
  70. PLC_SHARE_DATA,
  71. RESAMPLE_GLOBAL_DATA,
  72. RESAMPLE_SHARE_DATA,
  73. RESAMPLE_FRAME_DATA,
  74. PARSER_STACK,
  75. PARSER_CHUCK,
  76. OUTPUT_PARSER,
  77. BT_TRANSMIT_INPUT,
  78. BT_TRANSMIT_OUTPUT,
  79. /* stream header for snoop tws */
  80. OUTPUT_PKG_HDR,
  81. /** capture input isr reload buffer for adc driver */
  82. INPUT_RELOAD_CAPTURE,
  83. DAE_PARAM,
  84. ENCODE_TIME,
  85. ENCODE_HEADER,
  86. /** encoder input stream buffer */
  87. MCU_INPUT_ENCBUF,
  88. /** encoder output stream buffer*/
  89. MCU_OUTPUT_ENCBUF,
  90. PARSER_EVT_BUFFER,
  91. MIX_INPUT_BUF,
  92. MIX_RES_BUF,
  93. } cache_pool_type_e;
  94. /**
  95. * @brief get cache mem pool address
  96. *
  97. * This routine provides to get target memory addr
  98. *
  99. * @param mem_type memory type @see cache_pool_type_e
  100. * @param stream_type indicator for meida sence
  101. *
  102. * @return pointer of mem addr
  103. */
  104. void *media_mem_get_cache_pool(int mem_type, int stream_type);
  105. /**
  106. * @brief get cache mem pool size
  107. *
  108. * This routine provides to get target memory size
  109. *
  110. * @param mem_type memory type @see cache_pool_type_e
  111. * @param stream_type indicator for meida sence
  112. *
  113. * @return size of memory
  114. */
  115. int media_mem_get_cache_pool_size(int mem_type, int stream_type);
  116. typedef enum {
  117. MCU_MEMORY,
  118. DSP_MEMORY,
  119. MCU_DSP_SHARE_MEMORY,
  120. } media_memory_type_e;
  121. /**
  122. * @brief malloc memory from media heap
  123. *
  124. * This routine provides to malloc memory from media heap
  125. *
  126. * @param size sizeof memory want to malloc
  127. * @param memory_type indicator memory type
  128. *
  129. * @return pointer of media mem addr
  130. */
  131. void *media_mem_malloc(int size, int memory_type);
  132. /**
  133. * @brief free media memory
  134. *
  135. * This routine provides to free media memory
  136. *
  137. * @param ptr addr of memory want to free
  138. *
  139. * @return N/A
  140. */
  141. void media_mem_free(void *ptr);
  142. /**
  143. * @} end defgroup media_memory_apis
  144. */
  145. #endif /* __MEDIA_MEMORY_H__ */