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