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 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
27 #include <linux/bitmap.h>
29 static inline unsigned long *bitmap_alloc(unsigned int nbits
)
31 return kmalloc(BITS_TO_LONGS(nbits
), GFP_KERNEL
);
34 #define snd_pcm_plug_stream(plug) ((plug)->stream)
36 enum snd_pcm_plugin_action
{
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 */
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 */
55 struct snd_pcm_plugin_format
{
58 unsigned int channels
;
61 struct snd_pcm_plugin
{
62 const char *name
; /* plug-in name */
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 */
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
,
87 struct snd_pcm_plugin
*prev
;
88 struct snd_pcm_plugin
*next
;
89 struct snd_pcm_substream
*plug
;
91 void (*private_free
)(struct snd_pcm_plugin
*plugin
);
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
;
100 int snd_pcm_plugin_build(struct snd_pcm_substream
*handle
,
102 struct snd_pcm_plugin_format
*src_format
,
103 struct snd_pcm_plugin_format
*dst_format
,
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
);
112 #define FULL ROUTE_PLUGIN_RESOLUTION
113 #define HALF ROUTE_PLUGIN_RESOLUTION / 2
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
,
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
);
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
);
144 int snd_pcm_plug_slave_format(int format
, struct snd_mask
*format_mask
);
146 int snd_pcm_plugin_append(struct snd_pcm_plugin
*plugin
);
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
);
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
);
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
);
163 int snd_pcm_area_silence(const struct snd_pcm_channel_area
*dst_channel
,
165 size_t samples
, int format
);
166 int snd_pcm_area_copy(const struct snd_pcm_channel_area
*src_channel
,
168 const struct snd_pcm_channel_area
*dst_channel
,
170 size_t samples
, int format
);
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
,
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
,
182 snd_pcm_sframes_t
snd_pcm_oss_readv3(struct snd_pcm_substream
*substream
,
183 void **bufs
, snd_pcm_uframes_t frames
,
186 #define ROUTE_PLUGIN_RESOLUTION 16
188 int getput_index(int format
);
189 int copy_index(int format
);
190 int conv_index(int src_format
, int dst_format
);
192 void zero_channel(struct snd_pcm_plugin
*plugin
,
193 const struct snd_pcm_plugin_channel
*dst_channel
,
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
; }
205 #define pdprintf( fmt, args... ) printk( "plugin: " fmt, ##args)
207 #define pdprintf( fmt, args... )
210 #endif /* __PCM_PLUGIN_H */