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