[ALSA] PCM midlevel & PCM OSS - make procfs & OSS plugin code optional
[deliverable/linux.git] / sound / core / oss / pcm_plugin.h
1 #ifndef __PCM_PLUGIN_H
2 #define __PCM_PLUGIN_H
3
4 /*
5 * Digital Audio (Plugin interface) abstract layer
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
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
25 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
26
27 #include <linux/bitmap.h>
28
29 static inline unsigned long *bitmap_alloc(unsigned int nbits)
30 {
31 return kmalloc(BITS_TO_LONGS(nbits), GFP_KERNEL);
32 }
33
34 #define snd_pcm_plug_stream(plug) ((plug)->stream)
35
36 enum snd_pcm_plugin_action {
37 INIT = 0,
38 PREPARE = 1,
39 };
40
41 struct snd_pcm_channel_area {
42 void *addr; /* base address of channel samples */
43 unsigned int first; /* offset to first sample in bits */
44 unsigned int step; /* samples distance in bits */
45 };
46
47 struct snd_pcm_plugin_channel {
48 void *aptr; /* pointer to the allocated area */
49 struct snd_pcm_channel_area area;
50 snd_pcm_uframes_t frames; /* allocated frames */
51 unsigned int enabled:1; /* channel need to be processed */
52 unsigned int wanted:1; /* channel is wanted */
53 };
54
55 struct snd_pcm_plugin_format {
56 int format;
57 unsigned int rate;
58 unsigned int channels;
59 };
60
61 struct snd_pcm_plugin {
62 const char *name; /* plug-in name */
63 int stream;
64 struct snd_pcm_plugin_format src_format; /* source format */
65 struct snd_pcm_plugin_format dst_format; /* destination format */
66 int src_width; /* sample width in bits */
67 int dst_width; /* sample width in bits */
68 int access;
69 snd_pcm_sframes_t (*src_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t dst_frames);
70 snd_pcm_sframes_t (*dst_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t src_frames);
71 snd_pcm_sframes_t (*client_channels)(struct snd_pcm_plugin *plugin,
72 snd_pcm_uframes_t frames,
73 struct snd_pcm_plugin_channel **channels);
74 int (*src_channels_mask)(struct snd_pcm_plugin *plugin,
75 unsigned long *dst_vmask,
76 unsigned long **src_vmask);
77 int (*dst_channels_mask)(struct snd_pcm_plugin *plugin,
78 unsigned long *src_vmask,
79 unsigned long **dst_vmask);
80 snd_pcm_sframes_t (*transfer)(struct snd_pcm_plugin *plugin,
81 const struct snd_pcm_plugin_channel *src_channels,
82 struct snd_pcm_plugin_channel *dst_channels,
83 snd_pcm_uframes_t frames);
84 int (*action)(struct snd_pcm_plugin *plugin,
85 enum snd_pcm_plugin_action action,
86 unsigned long data);
87 struct snd_pcm_plugin *prev;
88 struct snd_pcm_plugin *next;
89 struct snd_pcm_substream *plug;
90 void *private_data;
91 void (*private_free)(struct snd_pcm_plugin *plugin);
92 char *buf;
93 snd_pcm_uframes_t buf_frames;
94 struct snd_pcm_plugin_channel *buf_channels;
95 unsigned long *src_vmask;
96 unsigned long *dst_vmask;
97 char extra_data[0];
98 };
99
100 int snd_pcm_plugin_build(struct snd_pcm_substream *handle,
101 const char *name,
102 struct snd_pcm_plugin_format *src_format,
103 struct snd_pcm_plugin_format *dst_format,
104 size_t extra,
105 struct snd_pcm_plugin **ret);
106 int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin);
107 int snd_pcm_plugin_clear(struct snd_pcm_plugin **first);
108 int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames);
109 snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size);
110 snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size);
111
112 #define FULL ROUTE_PLUGIN_RESOLUTION
113 #define HALF ROUTE_PLUGIN_RESOLUTION / 2
114
115 int snd_pcm_plugin_build_io(struct snd_pcm_substream *handle,
116 struct snd_pcm_hw_params *params,
117 struct snd_pcm_plugin **r_plugin);
118 int snd_pcm_plugin_build_linear(struct snd_pcm_substream *handle,
119 struct snd_pcm_plugin_format *src_format,
120 struct snd_pcm_plugin_format *dst_format,
121 struct snd_pcm_plugin **r_plugin);
122 int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *handle,
123 struct snd_pcm_plugin_format *src_format,
124 struct snd_pcm_plugin_format *dst_format,
125 struct snd_pcm_plugin **r_plugin);
126 int snd_pcm_plugin_build_rate(struct snd_pcm_substream *handle,
127 struct snd_pcm_plugin_format *src_format,
128 struct snd_pcm_plugin_format *dst_format,
129 struct snd_pcm_plugin **r_plugin);
130 int snd_pcm_plugin_build_route(struct snd_pcm_substream *handle,
131 struct snd_pcm_plugin_format *src_format,
132 struct snd_pcm_plugin_format *dst_format,
133 int *ttable,
134 struct snd_pcm_plugin **r_plugin);
135 int snd_pcm_plugin_build_copy(struct snd_pcm_substream *handle,
136 struct snd_pcm_plugin_format *src_format,
137 struct snd_pcm_plugin_format *dst_format,
138 struct snd_pcm_plugin **r_plugin);
139
140 int snd_pcm_plug_format_plugins(struct snd_pcm_substream *substream,
141 struct snd_pcm_hw_params *params,
142 struct snd_pcm_hw_params *slave_params);
143
144 int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask);
145
146 int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin);
147
148 snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *handle,
149 struct snd_pcm_plugin_channel *src_channels,
150 snd_pcm_uframes_t size);
151 snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *handle,
152 struct snd_pcm_plugin_channel *dst_channels_final,
153 snd_pcm_uframes_t size);
154
155 snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *handle,
156 char *buf, snd_pcm_uframes_t count,
157 struct snd_pcm_plugin_channel **channels);
158
159 snd_pcm_sframes_t snd_pcm_plugin_client_channels(struct snd_pcm_plugin *plugin,
160 snd_pcm_uframes_t frames,
161 struct snd_pcm_plugin_channel **channels);
162
163 int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_channel,
164 size_t dst_offset,
165 size_t samples, int format);
166 int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel,
167 size_t src_offset,
168 const struct snd_pcm_channel_area *dst_channel,
169 size_t dst_offset,
170 size_t samples, int format);
171
172 void *snd_pcm_plug_buf_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t size);
173 void snd_pcm_plug_buf_unlock(struct snd_pcm_substream *plug, void *ptr);
174 snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream,
175 const char *ptr, snd_pcm_uframes_t size,
176 int in_kernel);
177 snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream,
178 char *ptr, snd_pcm_uframes_t size, int in_kernel);
179 snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream,
180 void **bufs, snd_pcm_uframes_t frames,
181 int in_kernel);
182 snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream,
183 void **bufs, snd_pcm_uframes_t frames,
184 int in_kernel);
185
186 #define ROUTE_PLUGIN_RESOLUTION 16
187
188 int getput_index(int format);
189 int copy_index(int format);
190 int conv_index(int src_format, int dst_format);
191
192 void zero_channel(struct snd_pcm_plugin *plugin,
193 const struct snd_pcm_plugin_channel *dst_channel,
194 size_t samples);
195
196 #else
197
198 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; }
199 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; }
200 static inline int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask) { return format; }
201
202 #endif
203
204 #ifdef PLUGIN_DEBUG
205 #define pdprintf( fmt, args... ) printk( "plugin: " fmt, ##args)
206 #else
207 #define pdprintf( fmt, args... )
208 #endif
209
210 #endif /* __PCM_PLUGIN_H */
This page took 0.035106 seconds and 5 git commands to generate.