pcm_plugin.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #ifndef __PCM_PLUGIN_H
  2. #define __PCM_PLUGIN_H
  3. /*
  4. * Digital Audio (Plugin interface) abstract layer
  5. * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #ifdef CONFIG_SND_PCM_OSS_PLUGINS
  24. #define snd_pcm_plug_stream(plug) ((plug)->stream)
  25. enum snd_pcm_plugin_action {
  26. INIT = 0,
  27. PREPARE = 1,
  28. };
  29. struct snd_pcm_channel_area {
  30. void *addr; /* base address of channel samples */
  31. unsigned int first; /* offset to first sample in bits */
  32. unsigned int step; /* samples distance in bits */
  33. };
  34. struct snd_pcm_plugin_channel {
  35. void *aptr; /* pointer to the allocated area */
  36. struct snd_pcm_channel_area area;
  37. snd_pcm_uframes_t frames; /* allocated frames */
  38. unsigned int enabled:1; /* channel need to be processed */
  39. unsigned int wanted:1; /* channel is wanted */
  40. };
  41. struct snd_pcm_plugin_format {
  42. snd_pcm_format_t format;
  43. unsigned int rate;
  44. unsigned int channels;
  45. };
  46. struct snd_pcm_plugin {
  47. const char *name; /* plug-in name */
  48. int stream;
  49. struct snd_pcm_plugin_format src_format; /* source format */
  50. struct snd_pcm_plugin_format dst_format; /* destination format */
  51. int src_width; /* sample width in bits */
  52. int dst_width; /* sample width in bits */
  53. snd_pcm_access_t access;
  54. snd_pcm_sframes_t (*src_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t dst_frames);
  55. snd_pcm_sframes_t (*dst_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t src_frames);
  56. snd_pcm_sframes_t (*client_channels)(struct snd_pcm_plugin *plugin,
  57. snd_pcm_uframes_t frames,
  58. struct snd_pcm_plugin_channel **channels);
  59. snd_pcm_sframes_t (*transfer)(struct snd_pcm_plugin *plugin,
  60. const struct snd_pcm_plugin_channel *src_channels,
  61. struct snd_pcm_plugin_channel *dst_channels,
  62. snd_pcm_uframes_t frames);
  63. int (*action)(struct snd_pcm_plugin *plugin,
  64. enum snd_pcm_plugin_action action,
  65. unsigned long data);
  66. struct snd_pcm_plugin *prev;
  67. struct snd_pcm_plugin *next;
  68. struct snd_pcm_substream *plug;
  69. void *private_data;
  70. void (*private_free)(struct snd_pcm_plugin *plugin);
  71. char *buf;
  72. snd_pcm_uframes_t buf_frames;
  73. struct snd_pcm_plugin_channel *buf_channels;
  74. char extra_data[0];
  75. };
  76. int snd_pcm_plugin_build(struct snd_pcm_substream *handle,
  77. const char *name,
  78. struct snd_pcm_plugin_format *src_format,
  79. struct snd_pcm_plugin_format *dst_format,
  80. size_t extra,
  81. struct snd_pcm_plugin **ret);
  82. int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin);
  83. int snd_pcm_plugin_clear(struct snd_pcm_plugin **first);
  84. int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames);
  85. snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size);
  86. snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size);
  87. #define FULL ROUTE_PLUGIN_RESOLUTION
  88. #define HALF ROUTE_PLUGIN_RESOLUTION / 2
  89. int snd_pcm_plugin_build_io(struct snd_pcm_substream *handle,
  90. struct snd_pcm_hw_params *params,
  91. struct snd_pcm_plugin **r_plugin);
  92. int snd_pcm_plugin_build_linear(struct snd_pcm_substream *handle,
  93. struct snd_pcm_plugin_format *src_format,
  94. struct snd_pcm_plugin_format *dst_format,
  95. struct snd_pcm_plugin **r_plugin);
  96. int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *handle,
  97. struct snd_pcm_plugin_format *src_format,
  98. struct snd_pcm_plugin_format *dst_format,
  99. struct snd_pcm_plugin **r_plugin);
  100. int snd_pcm_plugin_build_rate(struct snd_pcm_substream *handle,
  101. struct snd_pcm_plugin_format *src_format,
  102. struct snd_pcm_plugin_format *dst_format,
  103. struct snd_pcm_plugin **r_plugin);
  104. int snd_pcm_plugin_build_route(struct snd_pcm_substream *handle,
  105. struct snd_pcm_plugin_format *src_format,
  106. struct snd_pcm_plugin_format *dst_format,
  107. struct snd_pcm_plugin **r_plugin);
  108. int snd_pcm_plugin_build_copy(struct snd_pcm_substream *handle,
  109. struct snd_pcm_plugin_format *src_format,
  110. struct snd_pcm_plugin_format *dst_format,
  111. struct snd_pcm_plugin **r_plugin);
  112. int snd_pcm_plug_format_plugins(struct snd_pcm_substream *substream,
  113. struct snd_pcm_hw_params *params,
  114. struct snd_pcm_hw_params *slave_params);
  115. snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format,
  116. struct snd_mask *format_mask);
  117. int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin);
  118. snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *handle,
  119. struct snd_pcm_plugin_channel *src_channels,
  120. snd_pcm_uframes_t size);
  121. snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *handle,
  122. struct snd_pcm_plugin_channel *dst_channels_final,
  123. snd_pcm_uframes_t size);
  124. snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *handle,
  125. char *buf, snd_pcm_uframes_t count,
  126. struct snd_pcm_plugin_channel **channels);
  127. snd_pcm_sframes_t snd_pcm_plugin_client_channels(struct snd_pcm_plugin *plugin,
  128. snd_pcm_uframes_t frames,
  129. struct snd_pcm_plugin_channel **channels);
  130. int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_channel,
  131. size_t dst_offset,
  132. size_t samples, snd_pcm_format_t format);
  133. int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel,
  134. size_t src_offset,
  135. const struct snd_pcm_channel_area *dst_channel,
  136. size_t dst_offset,
  137. size_t samples, snd_pcm_format_t format);
  138. void *snd_pcm_plug_buf_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t size);
  139. void snd_pcm_plug_buf_unlock(struct snd_pcm_substream *plug, void *ptr);
  140. snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream,
  141. const char *ptr, snd_pcm_uframes_t size,
  142. int in_kernel);
  143. snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream,
  144. char *ptr, snd_pcm_uframes_t size, int in_kernel);
  145. snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream,
  146. void **bufs, snd_pcm_uframes_t frames,
  147. int in_kernel);
  148. snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream,
  149. void **bufs, snd_pcm_uframes_t frames,
  150. int in_kernel);
  151. #else
  152. static inline snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size) { return drv_size; }
  153. static inline snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size) { return clt_size; }
  154. static inline int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask) { return format; }
  155. #endif
  156. #ifdef PLUGIN_DEBUG
  157. #define pdprintf(fmt, args...) printk(KERN_DEBUG "plugin: " fmt, ##args)
  158. #else
  159. #define pdprintf(fmt, args...)
  160. #endif
  161. #endif /* __PCM_PLUGIN_H */