1 | #ifndef __SOUND_PCM_H
|
---|
2 | #define __SOUND_PCM_H
|
---|
3 |
|
---|
4 | /*
|
---|
5 | * Digital Audio (PCM) abstract layer
|
---|
6 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
|
---|
7 | * Abramo Bagnara <abramo@alsa-project.org>
|
---|
8 | *
|
---|
9 | *
|
---|
10 | * This program is free software; you can redistribute it and/or modify
|
---|
11 | * it under the terms of the GNU General Public License as published by
|
---|
12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
13 | * (at your option) any later version.
|
---|
14 | *
|
---|
15 | * This program is distributed in the hope that it will be useful,
|
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | * GNU General Public License for more details.
|
---|
19 | *
|
---|
20 | * You should have received a copy of the GNU General Public License
|
---|
21 | * along with this program; if not, write to the Free Software
|
---|
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
23 | *
|
---|
24 | */
|
---|
25 |
|
---|
26 | #include <sound/asound.h>
|
---|
27 | #include <sound/memalloc.h>
|
---|
28 |
|
---|
29 | typedef sndrv_pcm_uframes_t snd_pcm_uframes_t;
|
---|
30 | typedef sndrv_pcm_sframes_t snd_pcm_sframes_t;
|
---|
31 | typedef enum sndrv_pcm_class snd_pcm_class_t;
|
---|
32 | typedef enum sndrv_pcm_subclass snd_pcm_subclass_t;
|
---|
33 | typedef enum sndrv_pcm_stream snd_pcm_stream_t;
|
---|
34 | typedef enum sndrv_pcm_access snd_pcm_access_t;
|
---|
35 | typedef enum sndrv_pcm_format snd_pcm_format_t;
|
---|
36 | typedef enum sndrv_pcm_subformat snd_pcm_subformat_t;
|
---|
37 | typedef enum sndrv_pcm_state snd_pcm_state_t;
|
---|
38 | typedef union sndrv_pcm_sync_id snd_pcm_sync_id_t;
|
---|
39 | typedef struct sndrv_pcm_info snd_pcm_info_t;
|
---|
40 | typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t;
|
---|
41 | typedef struct sndrv_pcm_hw_params snd_pcm_hw_params_t;
|
---|
42 | #ifndef TARGET_OS2
|
---|
43 | typedef enum sndrv_pcm_start snd_pcm_start_t;
|
---|
44 | typedef enum sndrv_pcm_xrun snd_pcm_xrun_t;
|
---|
45 | #endif
|
---|
46 | typedef enum sndrv_pcm_tstamp snd_pcm_tstamp_t;
|
---|
47 | typedef struct sndrv_pcm_sw_params snd_pcm_sw_params_t;
|
---|
48 | typedef struct sndrv_pcm_channel_info snd_pcm_channel_info_t;
|
---|
49 | typedef struct sndrv_pcm_status snd_pcm_status_t;
|
---|
50 | typedef struct sndrv_pcm_mmap_status snd_pcm_mmap_status_t;
|
---|
51 | typedef struct sndrv_pcm_mmap_control snd_pcm_mmap_control_t;
|
---|
52 | typedef struct sndrv_mask snd_mask_t;
|
---|
53 | typedef struct snd_sg_buf snd_pcm_sgbuf_t;
|
---|
54 |
|
---|
55 | #define snd_pcm_substream_chip(substream) ((substream)->private_data)
|
---|
56 | #define snd_pcm_chip(pcm) ((pcm)->private_data)
|
---|
57 |
|
---|
58 | typedef struct _snd_pcm_file snd_pcm_file_t;
|
---|
59 | typedef struct _snd_pcm_runtime snd_pcm_runtime_t;
|
---|
60 |
|
---|
61 | #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
|
---|
62 | #include "pcm_oss.h"
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | /*
|
---|
66 | * Hardware (lowlevel) section
|
---|
67 | */
|
---|
68 |
|
---|
69 | typedef struct _snd_pcm_hardware {
|
---|
70 | unsigned int info; /* SNDRV_PCM_INFO_* */
|
---|
71 | u64 formats; /* SNDRV_PCM_FMTBIT_* */
|
---|
72 | unsigned int rates; /* SNDRV_PCM_RATE_* */
|
---|
73 | unsigned int rate_min; /* min rate */
|
---|
74 | unsigned int rate_max; /* max rate */
|
---|
75 | unsigned int channels_min; /* min channels */
|
---|
76 | unsigned int channels_max; /* max channels */
|
---|
77 | size_t buffer_bytes_max; /* max buffer size */
|
---|
78 | size_t period_bytes_min; /* min period size */
|
---|
79 | size_t period_bytes_max; /* max period size */
|
---|
80 | unsigned int periods_min; /* min # of periods */
|
---|
81 | unsigned int periods_max; /* max # of periods */
|
---|
82 | size_t fifo_size; /* fifo size in bytes */
|
---|
83 | } snd_pcm_hardware_t;
|
---|
84 |
|
---|
85 | typedef struct _snd_pcm_ops {
|
---|
86 | int (*open)(snd_pcm_substream_t *substream);
|
---|
87 | int (*close)(snd_pcm_substream_t *substream);
|
---|
88 | int (*ioctl)(snd_pcm_substream_t * substream,
|
---|
89 | unsigned int cmd, void *arg);
|
---|
90 | int (*hw_params)(snd_pcm_substream_t * substream, snd_pcm_hw_params_t * params);
|
---|
91 | int (*hw_free)(snd_pcm_substream_t *substream);
|
---|
92 | int (*prepare)(snd_pcm_substream_t * substream);
|
---|
93 | int (*trigger)(snd_pcm_substream_t * substream, int cmd);
|
---|
94 | snd_pcm_uframes_t (*pointer)(snd_pcm_substream_t * substream);
|
---|
95 | int (*copy)(snd_pcm_substream_t *substream, int channel, snd_pcm_uframes_t pos,
|
---|
96 | void *buf, snd_pcm_uframes_t count);
|
---|
97 | int (*silence)(snd_pcm_substream_t *substream, int channel,
|
---|
98 | snd_pcm_uframes_t pos, snd_pcm_uframes_t count);
|
---|
99 | struct page *(*page)(snd_pcm_substream_t *substream, unsigned long offset);
|
---|
100 | int (*ack)(snd_pcm_substream_t *substream);
|
---|
101 | } snd_pcm_ops_t;
|
---|
102 |
|
---|
103 | /*
|
---|
104 | *
|
---|
105 | */
|
---|
106 |
|
---|
107 | #define SNDRV_PCM_DEVICES 8
|
---|
108 |
|
---|
109 | #define SNDRV_PCM_IOCTL1_FALSE ((void *)0)
|
---|
110 | #define SNDRV_PCM_IOCTL1_TRUE ((void *)1)
|
---|
111 |
|
---|
112 | #define SNDRV_PCM_IOCTL1_RESET 0
|
---|
113 | #define SNDRV_PCM_IOCTL1_INFO 1
|
---|
114 | #define SNDRV_PCM_IOCTL1_CHANNEL_INFO 2
|
---|
115 | #define SNDRV_PCM_IOCTL1_GSTATE 3
|
---|
116 |
|
---|
117 | #define SNDRV_PCM_TRIGGER_STOP 0
|
---|
118 | #define SNDRV_PCM_TRIGGER_START 1
|
---|
119 | #define SNDRV_PCM_TRIGGER_PAUSE_PUSH 3
|
---|
120 | #define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4
|
---|
121 | #define SNDRV_PCM_TRIGGER_SUSPEND 5
|
---|
122 | #define SNDRV_PCM_TRIGGER_RESUME 6
|
---|
123 |
|
---|
124 | #define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
|
---|
125 |
|
---|
126 | /* If you change this don't forget to change rates[] table in pcm_native.c */
|
---|
127 | #define SNDRV_PCM_RATE_5512 (1<<0) /* 5512Hz */
|
---|
128 | #define SNDRV_PCM_RATE_8000 (1<<1) /* 8000Hz */
|
---|
129 | #define SNDRV_PCM_RATE_11025 (1<<2) /* 11025Hz */
|
---|
130 | #define SNDRV_PCM_RATE_16000 (1<<3) /* 16000Hz */
|
---|
131 | #define SNDRV_PCM_RATE_22050 (1<<4) /* 22050Hz */
|
---|
132 | #define SNDRV_PCM_RATE_32000 (1<<5) /* 32000Hz */
|
---|
133 | #define SNDRV_PCM_RATE_44100 (1<<6) /* 44100Hz */
|
---|
134 | #define SNDRV_PCM_RATE_48000 (1<<7) /* 48000Hz */
|
---|
135 | #define SNDRV_PCM_RATE_64000 (1<<8) /* 64000Hz */
|
---|
136 | #define SNDRV_PCM_RATE_88200 (1<<9) /* 88200Hz */
|
---|
137 | #define SNDRV_PCM_RATE_96000 (1<<10) /* 96000Hz */
|
---|
138 | #define SNDRV_PCM_RATE_176400 (1<<11) /* 176400Hz */
|
---|
139 | #define SNDRV_PCM_RATE_192000 (1<<12) /* 192000Hz */
|
---|
140 |
|
---|
141 | #define SNDRV_PCM_RATE_CONTINUOUS (1<<30) /* continuous range */
|
---|
142 | #define SNDRV_PCM_RATE_KNOT (1<<31) /* supports more non-continuos rates */
|
---|
143 |
|
---|
144 | #define SNDRV_PCM_RATE_8000_44100 (SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_11025|\
|
---|
145 | SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_22050|\
|
---|
146 | SNDRV_PCM_RATE_32000|SNDRV_PCM_RATE_44100)
|
---|
147 | #define SNDRV_PCM_RATE_8000_48000 (SNDRV_PCM_RATE_8000_44100|SNDRV_PCM_RATE_48000)
|
---|
148 | #define SNDRV_PCM_RATE_8000_96000 (SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_64000|\
|
---|
149 | SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000)
|
---|
150 | #define SNDRV_PCM_RATE_8000_192000 (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\
|
---|
151 | SNDRV_PCM_RATE_192000)
|
---|
152 | #define SNDRV_PCM_FMTBIT_S8 (1 << SNDRV_PCM_FORMAT_S8)
|
---|
153 | #define SNDRV_PCM_FMTBIT_U8 (1 << SNDRV_PCM_FORMAT_U8)
|
---|
154 | #define SNDRV_PCM_FMTBIT_S16_LE (1 << SNDRV_PCM_FORMAT_S16_LE)
|
---|
155 | #define SNDRV_PCM_FMTBIT_S16_BE (1 << SNDRV_PCM_FORMAT_S16_BE)
|
---|
156 | #define SNDRV_PCM_FMTBIT_U16_LE (1 << SNDRV_PCM_FORMAT_U16_LE)
|
---|
157 | #define SNDRV_PCM_FMTBIT_U16_BE (1 << SNDRV_PCM_FORMAT_U16_BE)
|
---|
158 | #define SNDRV_PCM_FMTBIT_S24_LE (1 << SNDRV_PCM_FORMAT_S24_LE)
|
---|
159 | #define SNDRV_PCM_FMTBIT_S24_BE (1 << SNDRV_PCM_FORMAT_S24_BE)
|
---|
160 | #define SNDRV_PCM_FMTBIT_U24_LE (1 << SNDRV_PCM_FORMAT_U24_LE)
|
---|
161 | #define SNDRV_PCM_FMTBIT_U24_BE (1 << SNDRV_PCM_FORMAT_U24_BE)
|
---|
162 | #define SNDRV_PCM_FMTBIT_S32_LE (1 << SNDRV_PCM_FORMAT_S32_LE)
|
---|
163 | #define SNDRV_PCM_FMTBIT_S32_BE (1 << SNDRV_PCM_FORMAT_S32_BE)
|
---|
164 | #define SNDRV_PCM_FMTBIT_U32_LE (1 << SNDRV_PCM_FORMAT_U32_LE)
|
---|
165 | #define SNDRV_PCM_FMTBIT_U32_BE (1 << SNDRV_PCM_FORMAT_U32_BE)
|
---|
166 | #define SNDRV_PCM_FMTBIT_FLOAT_LE (1 << SNDRV_PCM_FORMAT_FLOAT_LE)
|
---|
167 | #define SNDRV_PCM_FMTBIT_FLOAT_BE (1 << SNDRV_PCM_FORMAT_FLOAT_BE)
|
---|
168 | #define SNDRV_PCM_FMTBIT_FLOAT64_LE (1 << SNDRV_PCM_FORMAT_FLOAT64_LE)
|
---|
169 | #define SNDRV_PCM_FMTBIT_FLOAT64_BE (1 << SNDRV_PCM_FORMAT_FLOAT64_BE)
|
---|
170 | #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE (1 << SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE)
|
---|
171 | #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE (1 << SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE)
|
---|
172 | #define SNDRV_PCM_FMTBIT_MU_LAW (1 << SNDRV_PCM_FORMAT_MU_LAW)
|
---|
173 | #define SNDRV_PCM_FMTBIT_A_LAW (1 << SNDRV_PCM_FORMAT_A_LAW)
|
---|
174 | #define SNDRV_PCM_FMTBIT_IMA_ADPCM (1 << SNDRV_PCM_FORMAT_IMA_ADPCM)
|
---|
175 | #define SNDRV_PCM_FMTBIT_MPEG (1 << SNDRV_PCM_FORMAT_MPEG)
|
---|
176 | #define SNDRV_PCM_FMTBIT_GSM (1 << SNDRV_PCM_FORMAT_GSM)
|
---|
177 | #define SNDRV_PCM_FMTBIT_SPECIAL (1 << SNDRV_PCM_FORMAT_SPECIAL)
|
---|
178 | #define SNDRV_PCM_FMTBIT_S24_3LE (1 << SNDRV_PCM_FORMAT_S24_3LE)
|
---|
179 | #define SNDRV_PCM_FMTBIT_U24_3LE (1 << SNDRV_PCM_FORMAT_U24_3LE)
|
---|
180 | #define SNDRV_PCM_FMTBIT_S24_3BE (1 << SNDRV_PCM_FORMAT_S24_3BE)
|
---|
181 | #define SNDRV_PCM_FMTBIT_U24_3BE (1 << SNDRV_PCM_FORMAT_U24_3BE)
|
---|
182 | #define SNDRV_PCM_FMTBIT_S20_3LE (1 << SNDRV_PCM_FORMAT_S20_3LE)
|
---|
183 | #define SNDRV_PCM_FMTBIT_U20_3LE (1 << SNDRV_PCM_FORMAT_U20_3LE)
|
---|
184 | #define SNDRV_PCM_FMTBIT_S20_3BE (1 << SNDRV_PCM_FORMAT_S20_3BE)
|
---|
185 | #define SNDRV_PCM_FMTBIT_U20_3BE (1 << SNDRV_PCM_FORMAT_U20_3BE)
|
---|
186 | #define SNDRV_PCM_FMTBIT_S18_3LE (1 << SNDRV_PCM_FORMAT_S18_3LE)
|
---|
187 | #define SNDRV_PCM_FMTBIT_U18_3LE (1 << SNDRV_PCM_FORMAT_U18_3LE)
|
---|
188 | #define SNDRV_PCM_FMTBIT_S18_3BE (1 << SNDRV_PCM_FORMAT_S18_3BE)
|
---|
189 | #define SNDRV_PCM_FMTBIT_U18_3BE (1 << SNDRV_PCM_FORMAT_U18_3BE)
|
---|
190 |
|
---|
191 | #ifdef SNDRV_LITTLE_ENDIAN
|
---|
192 | #define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE
|
---|
193 | #define SNDRV_PCM_FMTBIT_U16 SNDRV_PCM_FMTBIT_U16_LE
|
---|
194 | #define SNDRV_PCM_FMTBIT_S24 SNDRV_PCM_FMTBIT_S24_LE
|
---|
195 | #define SNDRV_PCM_FMTBIT_U24 SNDRV_PCM_FMTBIT_U24_LE
|
---|
196 | #define SNDRV_PCM_FMTBIT_S32 SNDRV_PCM_FMTBIT_S32_LE
|
---|
197 | #define SNDRV_PCM_FMTBIT_U32 SNDRV_PCM_FMTBIT_U32_LE
|
---|
198 | #define SNDRV_PCM_FMTBIT_FLOAT SNDRV_PCM_FMTBIT_FLOAT_LE
|
---|
199 | #define SNDRV_PCM_FMTBIT_FLOAT64 SNDRV_PCM_FMTBIT_FLOAT64_LE
|
---|
200 | #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE
|
---|
201 | #endif
|
---|
202 | #ifdef SNDRV_BIG_ENDIAN
|
---|
203 | #define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_BE
|
---|
204 | #define SNDRV_PCM_FMTBIT_U16 SNDRV_PCM_FMTBIT_U16_BE
|
---|
205 | #define SNDRV_PCM_FMTBIT_S24 SNDRV_PCM_FMTBIT_S24_BE
|
---|
206 | #define SNDRV_PCM_FMTBIT_U24 SNDRV_PCM_FMTBIT_U24_BE
|
---|
207 | #define SNDRV_PCM_FMTBIT_S32 SNDRV_PCM_FMTBIT_S32_BE
|
---|
208 | #define SNDRV_PCM_FMTBIT_U32 SNDRV_PCM_FMTBIT_U32_BE
|
---|
209 | #define SNDRV_PCM_FMTBIT_FLOAT SNDRV_PCM_FMTBIT_FLOAT_BE
|
---|
210 | #define SNDRV_PCM_FMTBIT_FLOAT64 SNDRV_PCM_FMTBIT_FLOAT64_BE
|
---|
211 | #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE
|
---|
212 | #endif
|
---|
213 |
|
---|
214 | struct _snd_pcm_file {
|
---|
215 | snd_pcm_substream_t * substream;
|
---|
216 | struct _snd_pcm_file * next;
|
---|
217 | };
|
---|
218 |
|
---|
219 | typedef struct _snd_pcm_hw_rule snd_pcm_hw_rule_t;
|
---|
220 |
|
---|
221 | typedef int (*snd_pcm_hw_rule_func_t)(snd_pcm_hw_params_t *params,
|
---|
222 | snd_pcm_hw_rule_t *rule);
|
---|
223 |
|
---|
224 | struct _snd_pcm_hw_rule {
|
---|
225 | unsigned int cond;
|
---|
226 | snd_pcm_hw_rule_func_t func;
|
---|
227 | int var;
|
---|
228 | int deps[4];
|
---|
229 | void *private;
|
---|
230 | };
|
---|
231 |
|
---|
232 | typedef struct _snd_pcm_hw_constraints {
|
---|
233 | snd_mask_t masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
|
---|
234 | SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];
|
---|
235 | snd_interval_t intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
|
---|
236 | SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
|
---|
237 | unsigned int rules_num;
|
---|
238 | unsigned int rules_all;
|
---|
239 | snd_pcm_hw_rule_t *rules;
|
---|
240 | } snd_pcm_hw_constraints_t;
|
---|
241 |
|
---|
242 | static inline snd_mask_t *constrs_mask(snd_pcm_hw_constraints_t *constrs,
|
---|
243 | snd_pcm_hw_param_t var)
|
---|
244 | {
|
---|
245 | return &constrs->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK];
|
---|
246 | }
|
---|
247 |
|
---|
248 | static inline snd_interval_t *constrs_interval(snd_pcm_hw_constraints_t *constrs,
|
---|
249 | snd_pcm_hw_param_t var)
|
---|
250 | {
|
---|
251 | return &constrs->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
|
---|
252 | }
|
---|
253 |
|
---|
254 | typedef struct {
|
---|
255 | unsigned int num;
|
---|
256 | unsigned int den_min, den_max, den_step;
|
---|
257 | } ratnum_t;
|
---|
258 |
|
---|
259 | typedef struct {
|
---|
260 | unsigned int num_min, num_max, num_step;
|
---|
261 | unsigned int den;
|
---|
262 | } ratden_t;
|
---|
263 |
|
---|
264 | typedef struct {
|
---|
265 | int nrats;
|
---|
266 | ratnum_t *rats;
|
---|
267 | } snd_pcm_hw_constraint_ratnums_t;
|
---|
268 |
|
---|
269 | typedef struct {
|
---|
270 | int nrats;
|
---|
271 | ratden_t *rats;
|
---|
272 | } snd_pcm_hw_constraint_ratdens_t;
|
---|
273 |
|
---|
274 | typedef struct {
|
---|
275 | unsigned int count;
|
---|
276 | unsigned int *list;
|
---|
277 | unsigned int mask;
|
---|
278 | } snd_pcm_hw_constraint_list_t;
|
---|
279 |
|
---|
280 | struct _snd_pcm_runtime {
|
---|
281 | /* -- Status -- */
|
---|
282 | snd_pcm_substream_t *trigger_master;
|
---|
283 | snd_timestamp_t trigger_tstamp; /* trigger timestamp */
|
---|
284 | int overrange;
|
---|
285 | snd_pcm_uframes_t avail_max;
|
---|
286 | snd_pcm_uframes_t hw_ptr_base; /* Position at buffer restart */
|
---|
287 | snd_pcm_uframes_t hw_ptr_interrupt; /* Position at interrupt time*/
|
---|
288 |
|
---|
289 | /* -- HW params -- */
|
---|
290 | snd_pcm_access_t access; /* access mode */
|
---|
291 | snd_pcm_format_t format; /* SNDRV_PCM_FORMAT_* */
|
---|
292 | snd_pcm_subformat_t subformat; /* subformat */
|
---|
293 | unsigned int rate; /* rate in Hz */
|
---|
294 | unsigned int channels; /* channels */
|
---|
295 | snd_pcm_uframes_t period_size; /* period size */
|
---|
296 | unsigned int periods; /* periods */
|
---|
297 | snd_pcm_uframes_t buffer_size; /* buffer size */
|
---|
298 | unsigned int tick_time; /* tick time */
|
---|
299 | snd_pcm_uframes_t min_align; /* Min alignment for the format */
|
---|
300 | size_t byte_align;
|
---|
301 | unsigned int frame_bits;
|
---|
302 | unsigned int sample_bits;
|
---|
303 | unsigned int info;
|
---|
304 | unsigned int rate_num;
|
---|
305 | unsigned int rate_den;
|
---|
306 |
|
---|
307 | /* -- SW params -- */
|
---|
308 | int tstamp_timespec; /* use timeval (0) or timespec (1) */
|
---|
309 | snd_pcm_tstamp_t tstamp_mode; /* mmap timestamp is updated */
|
---|
310 | unsigned int period_step;
|
---|
311 | unsigned int sleep_min; /* min ticks to sleep */
|
---|
312 | snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */
|
---|
313 | snd_pcm_uframes_t start_threshold;
|
---|
314 | snd_pcm_uframes_t stop_threshold;
|
---|
315 | snd_pcm_uframes_t silence_threshold; /* Silence filling happens when
|
---|
316 | noise is nearest than this */
|
---|
317 | snd_pcm_uframes_t silence_size; /* Silence filling size */
|
---|
318 | snd_pcm_uframes_t boundary; /* pointers wrap point */
|
---|
319 |
|
---|
320 | snd_pcm_uframes_t silence_start; /* starting pointer to silence area */
|
---|
321 | snd_pcm_uframes_t silence_filled; /* size filled with silence */
|
---|
322 |
|
---|
323 | snd_pcm_sync_id_t sync; /* hardware synchronization ID */
|
---|
324 |
|
---|
325 | /* -- mmap -- */
|
---|
326 | volatile snd_pcm_mmap_status_t *status;
|
---|
327 | volatile snd_pcm_mmap_control_t *control;
|
---|
328 | atomic_t mmap_count;
|
---|
329 |
|
---|
330 | /* -- locking / scheduling -- */
|
---|
331 | wait_queue_head_t sleep;
|
---|
332 | struct timer_list tick_timer;
|
---|
333 | struct fasync_struct *fasync;
|
---|
334 |
|
---|
335 | /* -- private section -- */
|
---|
336 | void *private_data;
|
---|
337 | void (*private_free)(snd_pcm_runtime_t *runtime);
|
---|
338 |
|
---|
339 | /* -- hardware description -- */
|
---|
340 | snd_pcm_hardware_t hw;
|
---|
341 | snd_pcm_hw_constraints_t hw_constraints;
|
---|
342 |
|
---|
343 | /* -- interrupt callbacks -- */
|
---|
344 | void (*transfer_ack_begin)(snd_pcm_substream_t *substream);
|
---|
345 | void (*transfer_ack_end)(snd_pcm_substream_t *substream);
|
---|
346 |
|
---|
347 | /* -- timer -- */
|
---|
348 | unsigned int timer_resolution; /* timer resolution */
|
---|
349 |
|
---|
350 | /* -- DMA -- */
|
---|
351 | unsigned char *dma_area; /* DMA area */
|
---|
352 | dma_addr_t dma_addr; /* physical bus address (not accessible from main CPU) */
|
---|
353 | size_t dma_bytes; /* size of DMA area */
|
---|
354 | struct snd_dma_buffer *dma_buffer_p; /* allocated buffer */
|
---|
355 |
|
---|
356 | #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
|
---|
357 | /* -- OSS things -- */
|
---|
358 | snd_pcm_oss_runtime_t oss;
|
---|
359 | #endif
|
---|
360 | };
|
---|
361 |
|
---|
362 | typedef struct _snd_pcm_group { /* keep linked substreams */
|
---|
363 | spinlock_t lock;
|
---|
364 | struct list_head substreams;
|
---|
365 | int count;
|
---|
366 | } snd_pcm_group_t;
|
---|
367 |
|
---|
368 | struct _snd_pcm_substream {
|
---|
369 | snd_pcm_t *pcm;
|
---|
370 | snd_pcm_str_t *pstr;
|
---|
371 | void *private_data; /* copied from pcm->private_data */
|
---|
372 | int number;
|
---|
373 | char name[32]; /* substream name */
|
---|
374 | int stream; /* stream (direction) */
|
---|
375 | size_t buffer_bytes_max; /* limit ring buffer size */
|
---|
376 | struct snd_dma_buffer dma_buffer;
|
---|
377 | unsigned int dma_buf_id;
|
---|
378 | size_t dma_max;
|
---|
379 | /* -- hardware operations -- */
|
---|
380 | snd_pcm_ops_t *ops;
|
---|
381 | /* -- runtime information -- */
|
---|
382 | snd_pcm_runtime_t *runtime;
|
---|
383 | /* -- timer section -- */
|
---|
384 | snd_timer_t *timer; /* timer */
|
---|
385 | int timer_running: 1; /* time is running */
|
---|
386 | spinlock_t timer_lock;
|
---|
387 | /* -- next substream -- */
|
---|
388 | snd_pcm_substream_t *next;
|
---|
389 | /* -- linked substreams -- */
|
---|
390 | struct list_head link_list; /* linked list member */
|
---|
391 | snd_pcm_group_t self_group; /* fake group for non linked substream (with substream lock inside) */
|
---|
392 | snd_pcm_group_t *group; /* pointer to current group */
|
---|
393 | /* -- assigned files -- */
|
---|
394 | snd_pcm_file_t *file;
|
---|
395 | struct file *ffile;
|
---|
396 | #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
|
---|
397 | /* -- OSS things -- */
|
---|
398 | snd_pcm_oss_substream_t oss;
|
---|
399 | #endif
|
---|
400 | snd_info_entry_t *proc_root;
|
---|
401 | snd_info_entry_t *proc_info_entry;
|
---|
402 | snd_info_entry_t *proc_hw_params_entry;
|
---|
403 | snd_info_entry_t *proc_sw_params_entry;
|
---|
404 | snd_info_entry_t *proc_status_entry;
|
---|
405 | snd_info_entry_t *proc_prealloc_entry;
|
---|
406 | };
|
---|
407 |
|
---|
408 | #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
|
---|
409 | #define SUBSTREAM_BUSY(substream) ((substream)->file != NULL || ((substream)->oss.file != NULL))
|
---|
410 | #else
|
---|
411 | #define SUBSTREAM_BUSY(substream) ((substream)->file != NULL)
|
---|
412 | #endif
|
---|
413 |
|
---|
414 |
|
---|
415 | struct _snd_pcm_str {
|
---|
416 | int stream; /* stream (direction) */
|
---|
417 | snd_pcm_t *pcm;
|
---|
418 | /* -- substreams -- */
|
---|
419 | unsigned int substream_count;
|
---|
420 | unsigned int substream_opened;
|
---|
421 | snd_pcm_substream_t *substream;
|
---|
422 | #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
|
---|
423 | /* -- OSS things -- */
|
---|
424 | snd_pcm_oss_stream_t oss;
|
---|
425 | #endif
|
---|
426 | snd_pcm_file_t *files;
|
---|
427 | snd_minor_t *reg;
|
---|
428 | snd_info_entry_t *proc_root;
|
---|
429 | snd_info_entry_t *proc_info_entry;
|
---|
430 | };
|
---|
431 |
|
---|
432 | struct _snd_pcm {
|
---|
433 | snd_card_t *card;
|
---|
434 | unsigned int device; /* device number */
|
---|
435 | unsigned int info_flags;
|
---|
436 | unsigned short dev_class;
|
---|
437 | unsigned short dev_subclass;
|
---|
438 | char id[64];
|
---|
439 | char name[80];
|
---|
440 | snd_pcm_str_t streams[2];
|
---|
441 | struct semaphore open_mutex;
|
---|
442 | wait_queue_head_t open_wait;
|
---|
443 | void *private_data;
|
---|
444 | void (*private_free) (snd_pcm_t *pcm);
|
---|
445 | #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
|
---|
446 | snd_pcm_oss_t oss;
|
---|
447 | #endif
|
---|
448 | };
|
---|
449 |
|
---|
450 | typedef struct _snd_pcm_notify {
|
---|
451 | int (*n_register) (snd_pcm_t * pcm);
|
---|
452 | int (*n_disconnect) (snd_pcm_t * pcm);
|
---|
453 | int (*n_unregister) (snd_pcm_t * pcm);
|
---|
454 | struct list_head list;
|
---|
455 | } snd_pcm_notify_t;
|
---|
456 |
|
---|
457 | /*
|
---|
458 | * Registering
|
---|
459 | */
|
---|
460 |
|
---|
461 | extern snd_pcm_t *snd_pcm_devices[];
|
---|
462 | extern snd_minor_t snd_pcm_reg[2];
|
---|
463 |
|
---|
464 | int snd_pcm_new(snd_card_t * card, char *id, int device,
|
---|
465 | int playback_count, int capture_count,
|
---|
466 | snd_pcm_t **rpcm);
|
---|
467 | int snd_pcm_new_stream(snd_pcm_t *pcm, int stream, int substream_count);
|
---|
468 |
|
---|
469 | int snd_pcm_notify(snd_pcm_notify_t *notify, int nfree);
|
---|
470 |
|
---|
471 | /*
|
---|
472 | * Native I/O
|
---|
473 | */
|
---|
474 |
|
---|
475 | extern rwlock_t snd_pcm_link_rwlock;
|
---|
476 |
|
---|
477 | int snd_pcm_info(snd_pcm_substream_t * substream, snd_pcm_info_t *info);
|
---|
478 | int snd_pcm_info_user(snd_pcm_substream_t * substream, snd_pcm_info_t *info);
|
---|
479 | int snd_pcm_status(snd_pcm_substream_t * substream, snd_pcm_status_t *status);
|
---|
480 | int snd_pcm_prepare(snd_pcm_substream_t *substream);
|
---|
481 | int snd_pcm_start(snd_pcm_substream_t *substream);
|
---|
482 | int snd_pcm_stop(snd_pcm_substream_t *substream, int status);
|
---|
483 | int snd_pcm_drain_done(snd_pcm_substream_t *substream);
|
---|
484 | #ifdef CONFIG_PM
|
---|
485 | int snd_pcm_suspend(snd_pcm_substream_t *substream);
|
---|
486 | int snd_pcm_suspend_all(snd_pcm_t *pcm);
|
---|
487 | #endif
|
---|
488 | int snd_pcm_kernel_playback_ioctl(snd_pcm_substream_t *substream, unsigned int cmd, void *arg);
|
---|
489 | int snd_pcm_kernel_capture_ioctl(snd_pcm_substream_t *substream, unsigned int cmd, void *arg);
|
---|
490 | int snd_pcm_kernel_ioctl(snd_pcm_substream_t *substream, unsigned int cmd, void *arg);
|
---|
491 | int snd_pcm_open(struct inode *inode, struct file *file);
|
---|
492 | int snd_pcm_release(struct inode *inode, struct file *file);
|
---|
493 | unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait);
|
---|
494 | unsigned int snd_pcm_capture_poll(struct file *file, poll_table * wait);
|
---|
495 | int snd_pcm_open_substream(snd_pcm_t *pcm, int stream, snd_pcm_substream_t **rsubstream);
|
---|
496 | void snd_pcm_release_substream(snd_pcm_substream_t *substream);
|
---|
497 | void snd_pcm_vma_notify_data(void *client, void *data);
|
---|
498 | int snd_pcm_mmap_data(snd_pcm_substream_t *substream, struct file *file, struct vm_area_struct *area);
|
---|
499 |
|
---|
500 | #if BITS_PER_LONG >= 64
|
---|
501 |
|
---|
502 | static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem)
|
---|
503 | {
|
---|
504 | *rem = *n % div;
|
---|
505 | *n /= div;
|
---|
506 | }
|
---|
507 |
|
---|
508 | #elif defined(i386)
|
---|
509 |
|
---|
510 | static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem)
|
---|
511 | {
|
---|
512 | u_int32_t low, high;
|
---|
513 | low = *n & 0xffffffff;
|
---|
514 | high = *n >> 32;
|
---|
515 | if (high) {
|
---|
516 | u_int32_t high1 = high % div;
|
---|
517 | high /= div;
|
---|
518 | asm("divl %2":"=a" (low), "=d" (*rem):"rm" (div), "a" (low), "d" (high1));
|
---|
519 | *n = (u_int64_t)high << 32 | low;
|
---|
520 | } else {
|
---|
521 | *n = low / div;
|
---|
522 | *rem = low % div;
|
---|
523 | }
|
---|
524 | }
|
---|
525 | #else
|
---|
526 |
|
---|
527 | static inline void divl(u_int32_t high, u_int32_t low,
|
---|
528 | u_int32_t div,
|
---|
529 | u_int32_t *q, u_int32_t *r)
|
---|
530 | {
|
---|
531 | u_int64_t n = (u_int64_t)high << 32 | low;
|
---|
532 | u_int64_t d = (u_int64_t)div << 31;
|
---|
533 | u_int32_t q1 = 0;
|
---|
534 | int c = 32;
|
---|
535 | while (n > 0xffffffffU) {
|
---|
536 | q1 <<= 1;
|
---|
537 | if (n >= d) {
|
---|
538 | n -= d;
|
---|
539 | q1 |= 1;
|
---|
540 | }
|
---|
541 | d >>= 1;
|
---|
542 | c--;
|
---|
543 | }
|
---|
544 | q1 <<= c;
|
---|
545 | if (n) {
|
---|
546 | low = n;
|
---|
547 | *q = q1 | (low / div);
|
---|
548 | *r = low % div;
|
---|
549 | } else {
|
---|
550 | *r = 0;
|
---|
551 | *q = q1;
|
---|
552 | }
|
---|
553 | return;
|
---|
554 | }
|
---|
555 |
|
---|
556 | static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem)
|
---|
557 | {
|
---|
558 | u_int32_t low, high;
|
---|
559 | low = *n & 0xffffffff;
|
---|
560 | high = *n >> 32;
|
---|
561 | if (high) {
|
---|
562 | u_int32_t high1 = high % div;
|
---|
563 | u_int32_t low1 = low;
|
---|
564 | high /= div;
|
---|
565 | divl(high1, low1, div, &low, rem);
|
---|
566 | *n = (u_int64_t)high << 32 | low;
|
---|
567 | } else {
|
---|
568 | *n = low / div;
|
---|
569 | *rem = low % div;
|
---|
570 | }
|
---|
571 | }
|
---|
572 | #endif
|
---|
573 |
|
---|
574 | /*
|
---|
575 | * PCM library
|
---|
576 | */
|
---|
577 |
|
---|
578 | static inline int snd_pcm_stream_linked(snd_pcm_substream_t *substream)
|
---|
579 | {
|
---|
580 | return substream->group != &substream->self_group;
|
---|
581 | }
|
---|
582 |
|
---|
583 | static inline void snd_pcm_stream_lock(snd_pcm_substream_t *substream)
|
---|
584 | {
|
---|
585 | read_lock(&snd_pcm_link_rwlock);
|
---|
586 | spin_lock(&substream->self_group.lock);
|
---|
587 | }
|
---|
588 |
|
---|
589 | static inline void snd_pcm_stream_unlock(snd_pcm_substream_t *substream)
|
---|
590 | {
|
---|
591 | spin_unlock(&substream->self_group.lock);
|
---|
592 | read_unlock(&snd_pcm_link_rwlock);
|
---|
593 | }
|
---|
594 |
|
---|
595 | static inline void snd_pcm_stream_lock_irq(snd_pcm_substream_t *substream)
|
---|
596 | {
|
---|
597 | read_lock_irq(&snd_pcm_link_rwlock);
|
---|
598 | spin_lock(&substream->self_group.lock);
|
---|
599 | }
|
---|
600 |
|
---|
601 | static inline void snd_pcm_stream_unlock_irq(snd_pcm_substream_t *substream)
|
---|
602 | {
|
---|
603 | spin_unlock(&substream->self_group.lock);
|
---|
604 | read_unlock_irq(&snd_pcm_link_rwlock);
|
---|
605 | }
|
---|
606 |
|
---|
607 | #define snd_pcm_stream_lock_irqsave(substream, flags) \
|
---|
608 | do { \
|
---|
609 | read_lock_irqsave(&snd_pcm_link_rwlock, (flags)); \
|
---|
610 | spin_lock(&substream->self_group.lock); \
|
---|
611 | } while (0)
|
---|
612 |
|
---|
613 | #define snd_pcm_stream_unlock_irqrestore(substream, flags) \
|
---|
614 | do { \
|
---|
615 | spin_unlock(&substream->self_group.lock); \
|
---|
616 | read_unlock_irqrestore(&snd_pcm_link_rwlock, (flags)); \
|
---|
617 | } while (0)
|
---|
618 |
|
---|
619 | #define snd_pcm_group_for_each(pos, substream) \
|
---|
620 | list_for_each(pos, &substream->group->substreams)
|
---|
621 |
|
---|
622 | #define snd_pcm_group_substream_entry(pos) \
|
---|
623 | list_entry(pos, snd_pcm_substream_t, link_list)
|
---|
624 |
|
---|
625 | static inline int snd_pcm_running(snd_pcm_substream_t *substream)
|
---|
626 | {
|
---|
627 | return (substream->runtime->status->state == SNDRV_PCM_STATE_RUNNING ||
|
---|
628 | (substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
|
---|
629 | substream->stream == SNDRV_PCM_STREAM_PLAYBACK));
|
---|
630 | }
|
---|
631 |
|
---|
632 | static inline ssize_t bytes_to_samples(snd_pcm_runtime_t *runtime, ssize_t size)
|
---|
633 | {
|
---|
634 | return size * 8 / runtime->sample_bits;
|
---|
635 | }
|
---|
636 |
|
---|
637 | static inline snd_pcm_sframes_t bytes_to_frames(snd_pcm_runtime_t *runtime, ssize_t size)
|
---|
638 | {
|
---|
639 | return size * 8 / runtime->frame_bits;
|
---|
640 | }
|
---|
641 |
|
---|
642 | static inline ssize_t samples_to_bytes(snd_pcm_runtime_t *runtime, ssize_t size)
|
---|
643 | {
|
---|
644 | return size * runtime->sample_bits / 8;
|
---|
645 | }
|
---|
646 |
|
---|
647 | static inline ssize_t frames_to_bytes(snd_pcm_runtime_t *runtime, snd_pcm_sframes_t size)
|
---|
648 | {
|
---|
649 | return size * runtime->frame_bits / 8;
|
---|
650 | }
|
---|
651 |
|
---|
652 | static inline int frame_aligned(snd_pcm_runtime_t *runtime, ssize_t bytes)
|
---|
653 | {
|
---|
654 | return bytes % runtime->byte_align == 0;
|
---|
655 | }
|
---|
656 |
|
---|
657 | static inline size_t snd_pcm_lib_buffer_bytes(snd_pcm_substream_t *substream)
|
---|
658 | {
|
---|
659 | snd_pcm_runtime_t *runtime = substream->runtime;
|
---|
660 | return frames_to_bytes(runtime, runtime->buffer_size);
|
---|
661 | }
|
---|
662 |
|
---|
663 | static inline size_t snd_pcm_lib_period_bytes(snd_pcm_substream_t *substream)
|
---|
664 | {
|
---|
665 | snd_pcm_runtime_t *runtime = substream->runtime;
|
---|
666 | return frames_to_bytes(runtime, runtime->period_size);
|
---|
667 | }
|
---|
668 |
|
---|
669 | /*
|
---|
670 | * result is: 0 ... (boundary - 1)
|
---|
671 | */
|
---|
672 | static inline snd_pcm_uframes_t snd_pcm_playback_avail(snd_pcm_runtime_t *runtime)
|
---|
673 | {
|
---|
674 | snd_pcm_sframes_t avail = runtime->status->hw_ptr + runtime->buffer_size - runtime->control->appl_ptr;
|
---|
675 | if (avail < 0)
|
---|
676 | avail += runtime->boundary;
|
---|
677 | else if ((snd_pcm_uframes_t) avail >= runtime->boundary)
|
---|
678 | avail -= runtime->boundary;
|
---|
679 | return avail;
|
---|
680 | }
|
---|
681 |
|
---|
682 | /*
|
---|
683 | * result is: 0 ... (boundary - 1)
|
---|
684 | */
|
---|
685 | static inline snd_pcm_uframes_t snd_pcm_capture_avail(snd_pcm_runtime_t *runtime)
|
---|
686 | {
|
---|
687 | snd_pcm_sframes_t avail = runtime->status->hw_ptr - runtime->control->appl_ptr;
|
---|
688 | if (avail < 0)
|
---|
689 | avail += runtime->boundary;
|
---|
690 | return avail;
|
---|
691 | }
|
---|
692 |
|
---|
693 | static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(snd_pcm_runtime_t *runtime)
|
---|
694 | {
|
---|
695 | return runtime->buffer_size - snd_pcm_playback_avail(runtime);
|
---|
696 | }
|
---|
697 |
|
---|
698 | static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(snd_pcm_runtime_t *runtime)
|
---|
699 | {
|
---|
700 | return runtime->buffer_size - snd_pcm_capture_avail(runtime);
|
---|
701 | }
|
---|
702 |
|
---|
703 | static inline void snd_pcm_trigger_done(snd_pcm_substream_t *substream,
|
---|
704 | snd_pcm_substream_t *master)
|
---|
705 | {
|
---|
706 | substream->runtime->trigger_master = master;
|
---|
707 | }
|
---|
708 |
|
---|
709 | static inline int hw_is_mask(int var)
|
---|
710 | {
|
---|
711 | return var >= SNDRV_PCM_HW_PARAM_FIRST_MASK &&
|
---|
712 | var <= SNDRV_PCM_HW_PARAM_LAST_MASK;
|
---|
713 | }
|
---|
714 |
|
---|
715 | static inline int hw_is_interval(int var)
|
---|
716 | {
|
---|
717 | return var >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL &&
|
---|
718 | var <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL;
|
---|
719 | }
|
---|
720 |
|
---|
721 | static inline snd_mask_t *hw_param_mask(snd_pcm_hw_params_t *params,
|
---|
722 | snd_pcm_hw_param_t var)
|
---|
723 | {
|
---|
724 | return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK];
|
---|
725 | }
|
---|
726 |
|
---|
727 | static inline snd_interval_t *hw_param_interval(snd_pcm_hw_params_t *params,
|
---|
728 | snd_pcm_hw_param_t var)
|
---|
729 | {
|
---|
730 | return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
|
---|
731 | }
|
---|
732 |
|
---|
733 | static inline const snd_mask_t *hw_param_mask_c(const snd_pcm_hw_params_t *params,
|
---|
734 | snd_pcm_hw_param_t var)
|
---|
735 | {
|
---|
736 | return (const snd_mask_t *)hw_param_mask((snd_pcm_hw_params_t*) params, var);
|
---|
737 | }
|
---|
738 |
|
---|
739 | static inline const snd_interval_t *hw_param_interval_c(const snd_pcm_hw_params_t *params,
|
---|
740 | snd_pcm_hw_param_t var)
|
---|
741 | {
|
---|
742 | return (const snd_interval_t *)hw_param_interval((snd_pcm_hw_params_t*) params, var);
|
---|
743 | }
|
---|
744 |
|
---|
745 | #define params_access(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS))
|
---|
746 | #define params_format(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_FORMAT))
|
---|
747 | #define params_subformat(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_SUBFORMAT))
|
---|
748 | #define params_channels(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_CHANNELS)->min
|
---|
749 | #define params_rate(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_RATE)->min
|
---|
750 | #define params_period_size(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min
|
---|
751 | #define params_period_bytes(p) ((params_period_size(p)*snd_pcm_format_physical_width(params_format(p))*params_channels(p))/8)
|
---|
752 | #define params_periods(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_PERIODS)->min
|
---|
753 | #define params_buffer_size(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min
|
---|
754 | #define params_buffer_bytes(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min
|
---|
755 | #define params_tick_time(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_TICK_TIME)->min
|
---|
756 |
|
---|
757 |
|
---|
758 | int snd_interval_refine(snd_interval_t *i, const snd_interval_t *v);
|
---|
759 | void snd_interval_mul(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c);
|
---|
760 | void snd_interval_div(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c);
|
---|
761 | void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b,
|
---|
762 | unsigned int k, snd_interval_t *c);
|
---|
763 | void snd_interval_mulkdiv(const snd_interval_t *a, unsigned int k,
|
---|
764 | const snd_interval_t *b, snd_interval_t *c);
|
---|
765 | int snd_interval_list(snd_interval_t *i, unsigned int count, unsigned int *list, unsigned int mask);
|
---|
766 | int snd_interval_step(snd_interval_t *i, unsigned int min, unsigned int step);
|
---|
767 | int snd_interval_ratnum(snd_interval_t *i,
|
---|
768 | unsigned int rats_count, ratnum_t *rats,
|
---|
769 | unsigned int *nump, unsigned int *denp);
|
---|
770 | int snd_interval_ratden(snd_interval_t *i,
|
---|
771 | unsigned int rats_count, ratden_t *rats,
|
---|
772 | unsigned int *nump, unsigned int *denp);
|
---|
773 |
|
---|
774 | void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params);
|
---|
775 | void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var);
|
---|
776 | int snd_pcm_hw_param_min(snd_pcm_substream_t *substream,
|
---|
777 | snd_pcm_hw_params_t *params,
|
---|
778 | snd_pcm_hw_param_t var,
|
---|
779 | unsigned int val, int *dir);
|
---|
780 | int snd_pcm_hw_param_max(snd_pcm_substream_t *substream,
|
---|
781 | snd_pcm_hw_params_t *params,
|
---|
782 | snd_pcm_hw_param_t var,
|
---|
783 | unsigned int val, int *dir);
|
---|
784 | int snd_pcm_hw_param_setinteger(snd_pcm_substream_t *substream,
|
---|
785 | snd_pcm_hw_params_t *params,
|
---|
786 | snd_pcm_hw_param_t var);
|
---|
787 | int snd_pcm_hw_param_first(snd_pcm_substream_t *substream,
|
---|
788 | snd_pcm_hw_params_t *params,
|
---|
789 | snd_pcm_hw_param_t var, int *dir);
|
---|
790 | int snd_pcm_hw_param_last(snd_pcm_substream_t *substream,
|
---|
791 | snd_pcm_hw_params_t *params,
|
---|
792 | snd_pcm_hw_param_t var, int *dir);
|
---|
793 | int snd_pcm_hw_param_near(snd_pcm_substream_t *substream,
|
---|
794 | snd_pcm_hw_params_t *params,
|
---|
795 | snd_pcm_hw_param_t var,
|
---|
796 | unsigned int val, int *dir);
|
---|
797 | int snd_pcm_hw_param_set(snd_pcm_substream_t *pcm,
|
---|
798 | snd_pcm_hw_params_t *params,
|
---|
799 | snd_pcm_hw_param_t var,
|
---|
800 | unsigned int val, int dir);
|
---|
801 | int snd_pcm_hw_params_choose(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params);
|
---|
802 |
|
---|
803 | int snd_pcm_hw_refine(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params);
|
---|
804 |
|
---|
805 | int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream);
|
---|
806 | int snd_pcm_hw_constraints_complete(snd_pcm_substream_t *substream);
|
---|
807 |
|
---|
808 | int snd_pcm_hw_constraint_mask(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var,
|
---|
809 | u_int32_t mask);
|
---|
810 | int snd_pcm_hw_constraint_mask64(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var,
|
---|
811 | u_int64_t mask);
|
---|
812 | int snd_pcm_hw_constraint_minmax(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var,
|
---|
813 | unsigned int min, unsigned int max);
|
---|
814 | int snd_pcm_hw_constraint_integer(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var);
|
---|
815 | int snd_pcm_hw_constraint_list(snd_pcm_runtime_t *runtime,
|
---|
816 | unsigned int cond,
|
---|
817 | snd_pcm_hw_param_t var,
|
---|
818 | snd_pcm_hw_constraint_list_t *l);
|
---|
819 | int snd_pcm_hw_constraint_ratnums(snd_pcm_runtime_t *runtime,
|
---|
820 | unsigned int cond,
|
---|
821 | snd_pcm_hw_param_t var,
|
---|
822 | snd_pcm_hw_constraint_ratnums_t *r);
|
---|
823 | int snd_pcm_hw_constraint_ratdens(snd_pcm_runtime_t *runtime,
|
---|
824 | unsigned int cond,
|
---|
825 | snd_pcm_hw_param_t var,
|
---|
826 | snd_pcm_hw_constraint_ratdens_t *r);
|
---|
827 | int snd_pcm_hw_constraint_msbits(snd_pcm_runtime_t *runtime,
|
---|
828 | unsigned int cond,
|
---|
829 | unsigned int width,
|
---|
830 | unsigned int msbits);
|
---|
831 | int snd_pcm_hw_constraint_step(snd_pcm_runtime_t *runtime,
|
---|
832 | unsigned int cond,
|
---|
833 | snd_pcm_hw_param_t var,
|
---|
834 | unsigned long step);
|
---|
835 | int snd_pcm_hw_constraint_pow2(snd_pcm_runtime_t *runtime,
|
---|
836 | unsigned int cond,
|
---|
837 | snd_pcm_hw_param_t var);
|
---|
838 | int snd_pcm_hw_rule_add(snd_pcm_runtime_t *runtime,
|
---|
839 | unsigned int cond,
|
---|
840 | int var,
|
---|
841 | snd_pcm_hw_rule_func_t func, void *private,
|
---|
842 | int dep, ...);
|
---|
843 |
|
---|
844 | int snd_pcm_format_signed(snd_pcm_format_t format);
|
---|
845 | int snd_pcm_format_unsigned(snd_pcm_format_t format);
|
---|
846 | int snd_pcm_format_linear(snd_pcm_format_t format);
|
---|
847 | int snd_pcm_format_little_endian(snd_pcm_format_t format);
|
---|
848 | int snd_pcm_format_big_endian(snd_pcm_format_t format);
|
---|
849 | int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */
|
---|
850 | int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */
|
---|
851 | u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format);
|
---|
852 | int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames);
|
---|
853 | snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian);
|
---|
854 | ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
|
---|
855 | const char *snd_pcm_format_name(snd_pcm_format_t format);
|
---|
856 | const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat);
|
---|
857 |
|
---|
858 | void snd_pcm_set_ops(snd_pcm_t * pcm, int direction, snd_pcm_ops_t *ops);
|
---|
859 | void snd_pcm_set_sync(snd_pcm_substream_t * substream);
|
---|
860 | int snd_pcm_lib_interleave_len(snd_pcm_substream_t *substream);
|
---|
861 | int snd_pcm_lib_ioctl(snd_pcm_substream_t *substream,
|
---|
862 | unsigned int cmd, void *arg);
|
---|
863 | int snd_pcm_update_hw_ptr(snd_pcm_substream_t *substream);
|
---|
864 | int snd_pcm_playback_xrun_check(snd_pcm_substream_t *substream);
|
---|
865 | int snd_pcm_capture_xrun_check(snd_pcm_substream_t *substream);
|
---|
866 | int snd_pcm_playback_xrun_asap(snd_pcm_substream_t *substream);
|
---|
867 | int snd_pcm_capture_xrun_asap(snd_pcm_substream_t *substream);
|
---|
868 | void snd_pcm_playback_silence(snd_pcm_substream_t *substream, snd_pcm_uframes_t new_hw_ptr);
|
---|
869 | int snd_pcm_playback_ready(snd_pcm_substream_t *substream);
|
---|
870 | int snd_pcm_capture_ready(snd_pcm_substream_t *substream);
|
---|
871 | long snd_pcm_playback_ready_jiffies(snd_pcm_substream_t *substream);
|
---|
872 | long snd_pcm_capture_ready_jiffies(snd_pcm_substream_t *substream);
|
---|
873 | int snd_pcm_playback_data(snd_pcm_substream_t *substream);
|
---|
874 | int snd_pcm_playback_empty(snd_pcm_substream_t *substream);
|
---|
875 | int snd_pcm_capture_empty(snd_pcm_substream_t *substream);
|
---|
876 | void snd_pcm_tick_prepare(snd_pcm_substream_t *substream);
|
---|
877 | void snd_pcm_tick_set(snd_pcm_substream_t *substream, unsigned long ticks);
|
---|
878 | void snd_pcm_tick_elapsed(snd_pcm_substream_t *substream);
|
---|
879 | void snd_pcm_period_elapsed(snd_pcm_substream_t *substream);
|
---|
880 | snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream,
|
---|
881 | const void *buf, snd_pcm_uframes_t frames);
|
---|
882 | snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream,
|
---|
883 | void *buf, snd_pcm_uframes_t frames);
|
---|
884 | snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream,
|
---|
885 | void **bufs, snd_pcm_uframes_t frames);
|
---|
886 | snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream,
|
---|
887 | void **bufs, snd_pcm_uframes_t frames);
|
---|
888 | int snd_pcm_limit_hw_rates(snd_pcm_runtime_t *runtime);
|
---|
889 |
|
---|
890 | static inline void snd_pcm_set_runtime_buffer(snd_pcm_substream_t *substream,
|
---|
891 | struct snd_dma_buffer *bufp)
|
---|
892 | {
|
---|
893 | snd_pcm_runtime_t *runtime = substream->runtime;
|
---|
894 | if (bufp) {
|
---|
895 | runtime->dma_buffer_p = bufp;
|
---|
896 | runtime->dma_area = bufp->area;
|
---|
897 | runtime->dma_addr = bufp->addr;
|
---|
898 | runtime->dma_bytes = bufp->bytes;
|
---|
899 | } else {
|
---|
900 | runtime->dma_buffer_p = NULL;
|
---|
901 | runtime->dma_area = NULL;
|
---|
902 | runtime->dma_addr = 0;
|
---|
903 | runtime->dma_bytes = 0;
|
---|
904 | }
|
---|
905 | }
|
---|
906 | /*
|
---|
907 | * Timer interface
|
---|
908 | */
|
---|
909 |
|
---|
910 | void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream);
|
---|
911 | void snd_pcm_timer_init(snd_pcm_substream_t * substream);
|
---|
912 | void snd_pcm_timer_done(snd_pcm_substream_t * substream);
|
---|
913 |
|
---|
914 | /*
|
---|
915 | * Memory
|
---|
916 | */
|
---|
917 |
|
---|
918 | int snd_pcm_lib_preallocate_free(snd_pcm_substream_t *substream);
|
---|
919 | int snd_pcm_lib_preallocate_free_for_all(snd_pcm_t *pcm);
|
---|
920 | int snd_pcm_lib_preallocate_pages(snd_pcm_substream_t *substream,
|
---|
921 | int type, struct device *data,
|
---|
922 | size_t size, size_t max);
|
---|
923 | int snd_pcm_lib_preallocate_pages_for_all(snd_pcm_t *pcm,
|
---|
924 | int type, void *data,
|
---|
925 | size_t size, size_t max);
|
---|
926 | int snd_pcm_lib_malloc_pages(snd_pcm_substream_t *substream, size_t size);
|
---|
927 | int snd_pcm_lib_free_pages(snd_pcm_substream_t *substream);
|
---|
928 |
|
---|
929 | #ifdef CONFIG_ISA
|
---|
930 | int snd_pcm_lib_preallocate_isa_pages(snd_pcm_substream_t *substream,
|
---|
931 | size_t size, size_t max);
|
---|
932 | int snd_pcm_lib_preallocate_isa_pages_for_all(snd_pcm_t *pcm,
|
---|
933 | size_t size, size_t max);
|
---|
934 | #endif
|
---|
935 | #ifdef CONFIG_PCI
|
---|
936 | int snd_pcm_lib_preallocate_pci_pages(struct pci_dev *pci,
|
---|
937 | snd_pcm_substream_t *substream,
|
---|
938 | size_t size, size_t max);
|
---|
939 | int snd_pcm_lib_preallocate_pci_pages_for_all(struct pci_dev *pci,
|
---|
940 | snd_pcm_t *pcm,
|
---|
941 | size_t size,
|
---|
942 | size_t max);
|
---|
943 | int snd_pcm_lib_preallocate_sg_pages(struct pci_dev *pci,
|
---|
944 | snd_pcm_substream_t *substream,
|
---|
945 | size_t size, size_t max);
|
---|
946 | int snd_pcm_lib_preallocate_sg_pages_for_all(struct pci_dev *pci,
|
---|
947 | snd_pcm_t *pcm,
|
---|
948 | size_t size, size_t max);
|
---|
949 | #define snd_pcm_substream_sgbuf(substream) ((substream)->runtime->dma_buffer_p->private_data)
|
---|
950 | #define snd_pcm_sgbuf_pages(size) snd_sgbuf_aligned_pages(size)
|
---|
951 | #define snd_pcm_sgbuf_get_addr(sgbuf,ofs) snd_sgbuf_get_addr(sgbuf,ofs)
|
---|
952 | struct page *snd_pcm_sgbuf_ops_page(snd_pcm_substream_t *substream, unsigned long offset);
|
---|
953 | #endif
|
---|
954 |
|
---|
955 | #ifdef CONFIG_SBUS
|
---|
956 | int snd_pcm_lib_preallocate_sbus_pages(struct sbus_dev *sdev,
|
---|
957 | snd_pcm_substream_t *substream,
|
---|
958 | size_t size, size_t max);
|
---|
959 | int snd_pcm_lib_preallocate_sbus_pages_for_all(struct sbus_dev *sdev,
|
---|
960 | snd_pcm_t *pcm,
|
---|
961 | size_t size,
|
---|
962 | size_t max);
|
---|
963 | #endif
|
---|
964 |
|
---|
965 | static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max)
|
---|
966 | {
|
---|
967 | *max = dma < 4 ? 64 * 1024 : 128 * 1024;
|
---|
968 | }
|
---|
969 |
|
---|
970 | /*
|
---|
971 | * Misc
|
---|
972 | */
|
---|
973 |
|
---|
974 | #define SNDRV_PCM_DEFAULT_CON_SPDIF (IEC958_AES0_CON_EMPHASIS_NONE|\
|
---|
975 | (IEC958_AES1_CON_ORIGINAL<<8)|\
|
---|
976 | (IEC958_AES1_CON_PCM_CODER<<8)|\
|
---|
977 | (IEC958_AES3_CON_FS_48000<<24))
|
---|
978 |
|
---|
979 | #define snd_pcm_group_for_each(pos, substream) \
|
---|
980 | list_for_each(pos, &substream->group->substreams)
|
---|
981 |
|
---|
982 | #define snd_pcm_group_substream_entry(pos) \
|
---|
983 | list_entry(pos, snd_pcm_substream_t, link_list)
|
---|
984 |
|
---|
985 |
|
---|
986 |
|
---|
987 | #endif /* __SOUND_PCM_H */
|
---|