5 * Digital Audio (Plugin interface) abstract layer
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
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.
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.
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
25 #include <linux/bitmap.h>
27 static inline unsigned long *bitmap_alloc(unsigned int nbits
)
29 return kmalloc(BITS_TO_LONGS(nbits
), GFP_KERNEL
);
32 #define snd_pcm_plug_stream(plug) ((plug)->stream)
34 enum snd_pcm_plugin_action
{
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 */
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 */
53 struct snd_pcm_plugin_format
{
56 unsigned int channels
;
59 struct snd_pcm_plugin
{
60 const char *name
; /* plug-in name */
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 */
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
,
85 struct snd_pcm_plugin
*prev
;
86 struct snd_pcm_plugin
*next
;
87 struct snd_pcm_substream
*plug
;
89 void (*private_free
)(struct snd_pcm_plugin
*plugin
);
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
;
98 int snd_pcm_plugin_build(struct snd_pcm_substream
*handle
,
100 struct snd_pcm_plugin_format
*src_format
,
101 struct snd_pcm_plugin_format
*dst_format
,
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
);
110 #define FULL ROUTE_PLUGIN_RESOLUTION
111 #define HALF ROUTE_PLUGIN_RESOLUTION / 2
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
,
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
);
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
);
142 int snd_pcm_plug_slave_format(int format
, struct snd_mask
*format_mask
);
144 int snd_pcm_plugin_append(struct snd_pcm_plugin
*plugin
);
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
);
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
);
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
);
161 int snd_pcm_area_silence(const struct snd_pcm_channel_area
*dst_channel
,
163 size_t samples
, int format
);
164 int snd_pcm_area_copy(const struct snd_pcm_channel_area
*src_channel
,
166 const struct snd_pcm_channel_area
*dst_channel
,
168 size_t samples
, int format
);
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
,
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
,
180 snd_pcm_sframes_t
snd_pcm_oss_readv3(struct snd_pcm_substream
*substream
,
181 void **bufs
, snd_pcm_uframes_t frames
,
184 #define ROUTE_PLUGIN_RESOLUTION 16
186 int getput_index(int format
);
187 int copy_index(int format
);
188 int conv_index(int src_format
, int dst_format
);
190 void zero_channel(struct snd_pcm_plugin
*plugin
,
191 const struct snd_pcm_plugin_channel
*dst_channel
,
195 #define pdprintf( fmt, args... ) printk( "plugin: " fmt, ##args)
197 #define pdprintf( fmt, args... )
200 #endif /* __PCM_PLUGIN_H */