pcm_extplug.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (c) 2019-2025 Allwinner Technology Co., Ltd. ALL rights reserved.
  3. *
  4. * Allwinner is a trademark of Allwinner Technology Co.,Ltd., registered in
  5. * the the people's Republic of China and other countries.
  6. * All Allwinner Technology Co.,Ltd. trademarks are used with permission.
  7. *
  8. * DISCLAIMER
  9. * THIRD PARTY LICENCES MAY BE REQUIRED TO IMPLEMENT THE SOLUTION/PRODUCT.
  10. * IF YOU NEED TO INTEGRATE THIRD PARTY’S TECHNOLOGY (SONY, DTS, DOLBY, AVS OR MPEGLA, ETC.)
  11. * IN ALLWINNERS’SDK OR PRODUCTS, YOU SHALL BE SOLELY RESPONSIBLE TO OBTAIN
  12. * ALL APPROPRIATELY REQUIRED THIRD PARTY LICENCES.
  13. * ALLWINNER SHALL HAVE NO WARRANTY, INDEMNITY OR OTHER OBLIGATIONS WITH RESPECT TO MATTERS
  14. * COVERED UNDER ANY REQUIRED THIRD PARTY LICENSE.
  15. * YOU ARE SOLELY RESPONSIBLE FOR YOUR USAGE OF THIRD PARTY’S TECHNOLOGY.
  16. *
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY ALLWINNER"AS IS" AND TO THE MAXIMUM EXTENT
  19. * PERMITTED BY LAW, ALLWINNER EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND,
  20. * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION REGARDING
  21. * THE TITLE, NON-INFRINGEMENT, ACCURACY, CONDITION, COMPLETENESS, PERFORMANCE
  22. * OR MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  23. * IN NO EVENT SHALL ALLWINNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  25. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26. * LOSS OF USE, DATA, OR PROFITS, OR BUSINESS INTERRUPTION)
  27. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  28. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  30. * OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. #ifndef __AW_ALSA_PCM_EXTPLUG_H
  33. #define __AW_ALSA_PCM_EXTPLUG_H
  34. #include <aw-alsa-lib/pcm.h>
  35. /** hw constraints for extplug */
  36. enum {
  37. SND_PCM_EXTPLUG_HW_FORMAT, /**< format */
  38. SND_PCM_EXTPLUG_HW_CHANNELS, /**< channels */
  39. SND_PCM_EXTPLUG_HW_PARAMS /**< max number of hw constraints */
  40. };
  41. /** Handle of external filter plugin */
  42. typedef struct snd_pcm_extplug snd_pcm_extplug_t;
  43. /** Callback table of extplug */
  44. typedef struct snd_pcm_extplug_callback snd_pcm_extplug_callback_t;
  45. /** Handle of extplug */
  46. struct snd_pcm_extplug {
  47. /**
  48. * name of this plugin; must be filled before calling #snd_pcm_extplug_create()
  49. */
  50. const char *name;
  51. /**
  52. * callbacks of this plugin; must be filled before calling #snd_pcm_extplug_create()
  53. */
  54. const snd_pcm_extplug_callback_t *callback;
  55. /**
  56. * private data, which can be used freely in the driver callbacks
  57. */
  58. void *private_data;
  59. /**
  60. * PCM handle filled by #snd_pcm_extplug_create()
  61. */
  62. snd_pcm_t *pcm;
  63. /**
  64. * stream direction; read-only status
  65. */
  66. snd_pcm_stream_t stream;
  67. /**
  68. * format hw parameter; filled after hw_params is caled
  69. */
  70. snd_pcm_format_t format;
  71. /**
  72. * subformat hw parameter; filled after hw_params is caled
  73. */
  74. //snd_pcm_subformat_t subformat;
  75. /**
  76. * channels hw parameter; filled after hw_params is caled
  77. */
  78. unsigned int channels;
  79. /**
  80. * rate hw parameter; filled after hw_params is caled
  81. */
  82. unsigned int rate;
  83. /**
  84. * slave_format hw parameter; filled after hw_params is caled
  85. */
  86. snd_pcm_format_t slave_format;
  87. /**
  88. * slave_channels hw parameter; filled after hw_params is caled
  89. */
  90. unsigned int slave_channels;
  91. };
  92. /** Callback table of extplug */
  93. struct snd_pcm_extplug_callback {
  94. /**
  95. * transfer between source and destination; this is a required callback
  96. */
  97. snd_pcm_sframes_t (*transfer)(snd_pcm_extplug_t *ext,
  98. const snd_pcm_channel_area_t *dst_areas,
  99. snd_pcm_uframes_t dst_offset,
  100. const snd_pcm_channel_area_t *src_areas,
  101. snd_pcm_uframes_t src_offset,
  102. snd_pcm_uframes_t size);
  103. /**
  104. * close the PCM; optional
  105. */
  106. int (*close)(snd_pcm_extplug_t *ext);
  107. /**
  108. * hw_params; optional
  109. */
  110. int (*hw_params)(snd_pcm_extplug_t *ext, snd_pcm_hw_params_t *params);
  111. /**
  112. * hw_free; optional
  113. */
  114. int (*hw_free)(snd_pcm_extplug_t *ext);
  115. /**
  116. * dump; optional
  117. */
  118. void (*dump)(snd_pcm_extplug_t *ext);
  119. /**
  120. * init; optional initialization called at prepare or reset
  121. */
  122. int (*init)(snd_pcm_extplug_t *ext);
  123. /**
  124. * query the channel maps; optional; since v1.0.2
  125. */
  126. //snd_pcm_chmap_query_t **(*query_chmaps)(snd_pcm_extplug_t *ext);
  127. /**
  128. * get the channel map; optional; since v1.0.2
  129. */
  130. //snd_pcm_chmap_t *(*get_chmap)(snd_pcm_extplug_t *ext);
  131. /**
  132. * set the channel map; optional; since v1.0.2
  133. */
  134. //int (*set_chmap)(snd_pcm_extplug_t *ext, const snd_pcm_chmap_t *map);
  135. };
  136. int snd_pcm_extplug_create(snd_pcm_extplug_t *extplug, const char *name,
  137. const char *spcm_name, snd_pcm_stream_t stream, int mode);
  138. /* clear hw_parameter setting */
  139. void snd_pcm_extplug_params_reset(snd_pcm_extplug_t *ext);
  140. /* hw_parameter setting */
  141. int snd_pcm_extplug_set_param_list(snd_pcm_extplug_t *extplug, int type, unsigned int num_list, const unsigned int *list);
  142. int snd_pcm_extplug_set_param_minmax(snd_pcm_extplug_t *extplug, int type, unsigned int min, unsigned int max);
  143. int snd_pcm_extplug_set_slave_param_list(snd_pcm_extplug_t *extplug, int type, unsigned int num_list, const unsigned int *list);
  144. int snd_pcm_extplug_set_slave_param_minmax(snd_pcm_extplug_t *extplug, int type, unsigned int min, unsigned int max);
  145. /**
  146. * set the parameter constraint with a single value
  147. */
  148. static __inline__ int snd_pcm_extplug_set_param(snd_pcm_extplug_t *extplug, int type, unsigned int val)
  149. {
  150. return snd_pcm_extplug_set_param_list(extplug, type, 1, &val);
  151. }
  152. /**
  153. * set the parameter constraint for slave PCM with a single value
  154. */
  155. static __inline__ int snd_pcm_extplug_set_slave_param(snd_pcm_extplug_t *extplug, int type, unsigned int val)
  156. {
  157. return snd_pcm_extplug_set_slave_param_list(extplug, type, 1, &val);
  158. }
  159. #endif /* __AW_ALSA_PCM_EXTPLUG_H */