as_dae.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright (c) 2017 Actions Semi Co., Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. * Author: jpl<jianpingliao@actions-semi.com>
  16. *
  17. * Change log:
  18. * 2019/12/16: Created by jpl.
  19. */
  20. #ifndef __AS_DAE_H__
  21. #define __AS_DAE_H__
  22. #include "as_dae_setting.h"
  23. #define MAX_CHANNEL_AS_DAE_INOUT 4
  24. /*!
  25. * \brief
  26. * dae process input/output pcm structure
  27. */
  28. typedef struct
  29. {
  30. /*! [INPUT]: input/output pcm array.
  31. * pcm[0] is left channel, pcm[1] is right channel, pcm[2] is mic input (single channel).
  32. **/
  33. void *pcm[MAX_CHANNEL_AS_DAE_INOUT];
  34. /*! [INPUT] input pcm channels */
  35. int channels;
  36. /*! [INPUT] input pcm samples (pairs) */
  37. int samples;
  38. /*! [INPUT] input pcm sample bits, 16, 24 or 32 */
  39. int sample_bits;
  40. /*! [INPUT] input pcm fraction bits */
  41. int frac_bits;
  42. } as_dae_inout_pcm_t;
  43. /*!
  44. * \brief
  45. * dae ops error code
  46. */
  47. typedef enum
  48. {
  49. /*! unexpected error */
  50. DAE_RET_UNEXPECTED = -3,
  51. /*! not enough memory */
  52. DAE_RET_OUTOFMEMORY,
  53. /*! unsupported format */
  54. DAE_RET_UNSUPPORTED,
  55. /*! no error */
  56. DAE_RET_OK,
  57. /*! data underflow */
  58. DAE_RET_DATAUNDERFLOW,
  59. } as_dae_ret_t;
  60. /*!
  61. * \brief
  62. * dae ops command
  63. */
  64. typedef enum
  65. {
  66. /* open, without argument */
  67. DAE_CMD_OPEN = 0,
  68. /* close */
  69. DAE_CMD_CLOSE,
  70. /* get status */
  71. DAE_CMD_GET_STATUS,
  72. /* frame process, with argument address of structure as_dae_frame_info_t */
  73. DAE_CMD_FRAME_PROCESS,
  74. /* set dae parameter buffer address, with argument address of structure as_dae_para_info_t */
  75. DAE_CMD_SET_DAE_PARA,
  76. /* get maximum energy and RMS energy */
  77. DAE_CMD_GET_ENERGY,
  78. /* get frequency energy */
  79. DAE_CMD_GET_FREQ_POINT_ENERGY,
  80. /** get memory require size(bytes) */
  81. DAE_CMD_MEM_REQUIRE,
  82. /** get codec verison */
  83. DAE_CMD_GET_VERSION,
  84. /** enable fade, with argument address of structure as_dae_para_info_t */
  85. DAE_CMD_ENA_FADE,
  86. /* update soft volume, with argument address of structure as_dae_para_info_t */
  87. DAE_CMD_UPDATE_SOFT_VOLUME,
  88. } as_dae_ex_ops_cmd_t;
  89. typedef enum
  90. {
  91. /* fade in processing*/
  92. DAE_FADE_IN_PROCESSING = 0,
  93. /* fade in standby(not working or processed)*/
  94. DAE_FADE_IN_STANDBY,
  95. /* fade out processing*/
  96. DAE_FADE_OUT_PROCESSING,
  97. /* fade out standby(not working or processed)*/
  98. DAE_FADE_OUT_STANDBY,
  99. /* mic channal fade in processing*/
  100. DAE_MIC_FADE_IN_PROCESSING,
  101. /* mic channal fade in standby(not working or processed)*/
  102. DAE_MIC_FADE_IN_STANDBY,
  103. /* mic channal fade out processing*/
  104. DAE_MIC_FADE_OUT_PROCESSING,
  105. /* mic channal fade out standby(not working or processed)*/
  106. DAE_MIC_FADE_OUT_STANDBY,
  107. } as_dae_status_e;
  108. typedef struct
  109. {
  110. /* [OUTPUT]: SPEAKER fade in status */
  111. short fade_in_status;
  112. /* [OUTPUT]: SPEAKER fade out status */
  113. short fade_out_status;
  114. /* [OUTPUT]: MIC fade in status */
  115. short mic_fade_in_status;
  116. /* [OUTPUT]: MIC fade out status */
  117. short mic_fade_out_status;
  118. } as_dae_status_t;
  119. typedef struct
  120. {
  121. /* [OUTPUT]: SPEAKER average energy of current frame */
  122. short energy;
  123. /* [OUTPUT]: SPEAKER maximum energy of current frame */
  124. short energy_max;
  125. /* [OUTPUT]: MIC average energy of current frame */
  126. short mic_energy;
  127. /* [OUTPUT]: MIC maximum energy of current frame */
  128. short mic_energy_max;
  129. } as_dae_energy_t;
  130. /**
  131. * @brief as dae operation
  132. *
  133. * This routine provides as dae operation
  134. *
  135. * @param hnd handle of as dae
  136. * @param cmd operation cmd, type of as_dae_ex_ops_cmd_t
  137. * for DAE_CMD_MEM_REQUIRE, args type is as_mem_info_t* in audio_codec.h
  138. * for DAE_CMD_OPEN, args for reserve
  139. * for DAE_CMD_SET_DAE_PARA, args type is as_dae_para_info_t* in as_dae_setting.h
  140. * for DAE_CMD_FRAME_PROCESS, args type is as_dae_inout_pcm_t*
  141. * for DAE_CMD_GET_STATUS, args type is as_dae_status_t*
  142. * for DAE_CMD_GET_ENERGY, args type is as_dae_energy_t*
  143. * for DAE_CMD_GET_FREQ_POINT_ENERGY, args type is short array whose size is freq_point_num*sizeof(short),
  144. * freq_point_num can see freq_display_para in as_dae_setting.h, which is set by DAE_CMD_SET_DAE_PARA.
  145. * @param args args of dae parama addr
  146. *
  147. * @return type of as_dae_ret_t;
  148. */
  149. int as_dae_ops(void *hnd, as_dae_ex_ops_cmd_t cmd, unsigned int args);
  150. #endif /* __AS_DAE_H__ */