1 | /* SPDX-License-Identifier: GPL-2.0-or-later */
|
---|
2 | #ifndef __SOUND_PCM_H
|
---|
3 | #define __SOUND_PCM_H
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Digital Audio (PCM) abstract layer
|
---|
7 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
|
---|
8 | * Abramo Bagnara <abramo@alsa-project.org>
|
---|
9 | */
|
---|
10 |
|
---|
11 | #include <sound/asound.h>
|
---|
12 | #include <sound/memalloc.h>
|
---|
13 | #include <sound/minors.h>
|
---|
14 | #include <linux/poll.h>
|
---|
15 | #include <linux/mm.h>
|
---|
16 | #include <linux/bitops.h>
|
---|
17 | #include <linux/pm_qos.h>
|
---|
18 | #include <linux/refcount.h>
|
---|
19 | #include <linux/uio.h>
|
---|
20 |
|
---|
21 | #define snd_pcm_substream_chip(substream) ((substream)->private_data)
|
---|
22 | #define snd_pcm_chip(pcm) ((pcm)->private_data)
|
---|
23 |
|
---|
24 | #if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
|
---|
25 | #include <sound/pcm_oss.h>
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | /*
|
---|
29 | * Hardware (lowlevel) section
|
---|
30 | */
|
---|
31 |
|
---|
32 | struct snd_pcm_hardware {
|
---|
33 | unsigned int info; /* SNDRV_PCM_INFO_* */
|
---|
34 | u64 formats; /* SNDRV_PCM_FMTBIT_* */
|
---|
35 | u32 subformats; /* for S32_LE, SNDRV_PCM_SUBFMTBIT_* */
|
---|
36 | unsigned int rates; /* SNDRV_PCM_RATE_* */
|
---|
37 | unsigned int rate_min; /* min rate */
|
---|
38 | unsigned int rate_max; /* max rate */
|
---|
39 | unsigned int channels_min; /* min channels */
|
---|
40 | unsigned int channels_max; /* max channels */
|
---|
41 | size_t buffer_bytes_max; /* max buffer size */
|
---|
42 | size_t period_bytes_min; /* min period size */
|
---|
43 | size_t period_bytes_max; /* max period size */
|
---|
44 | unsigned int periods_min; /* min # of periods */
|
---|
45 | unsigned int periods_max; /* max # of periods */
|
---|
46 | size_t fifo_size; /* fifo size in bytes */
|
---|
47 | };
|
---|
48 |
|
---|
49 | struct snd_pcm_status64;
|
---|
50 | struct snd_pcm_substream;
|
---|
51 | struct snd_pcm_audio_tstamp_config; /* definitions further down */
|
---|
52 | struct snd_pcm_audio_tstamp_report;
|
---|
53 |
|
---|
54 | struct snd_pcm_ops {
|
---|
55 | int (*open)(struct snd_pcm_substream *substream);
|
---|
56 | int (*close)(struct snd_pcm_substream *substream);
|
---|
57 | int (*ioctl)(struct snd_pcm_substream * substream,
|
---|
58 | unsigned int cmd, void *arg);
|
---|
59 | int (*hw_params)(struct snd_pcm_substream *substream,
|
---|
60 | struct snd_pcm_hw_params *params);
|
---|
61 | int (*hw_free)(struct snd_pcm_substream *substream);
|
---|
62 | int (*prepare)(struct snd_pcm_substream *substream);
|
---|
63 | int (*trigger)(struct snd_pcm_substream *substream, int cmd);
|
---|
64 | int (*sync_stop)(struct snd_pcm_substream *substream);
|
---|
65 | snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream);
|
---|
66 | int (*get_time_info)(struct snd_pcm_substream *substream,
|
---|
67 | struct timespec64 *system_ts, struct timespec64 *audio_ts,
|
---|
68 | struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
|
---|
69 | struct snd_pcm_audio_tstamp_report *audio_tstamp_report);
|
---|
70 | int (*fill_silence)(struct snd_pcm_substream *substream, int channel,
|
---|
71 | unsigned long pos, unsigned long bytes);
|
---|
72 | #ifndef TARGET_OS2
|
---|
73 | int (*copy)(struct snd_pcm_substream *substream, int channel,
|
---|
74 | unsigned long pos, struct iov_iter *iter, unsigned long bytes);
|
---|
75 | #else
|
---|
76 | int (*copy)(struct snd_pcm_substream *substream, int channel,
|
---|
77 | unsigned long pos, void *iter, unsigned long bytes);
|
---|
78 | #endif
|
---|
79 | struct page *(*page)(struct snd_pcm_substream *substream,
|
---|
80 | unsigned long offset);
|
---|
81 | int (*mmap)(struct snd_pcm_substream *substream, struct vm_area_struct *vma);
|
---|
82 | int (*ack)(struct snd_pcm_substream *substream);
|
---|
83 | };
|
---|
84 |
|
---|
85 | /*
|
---|
86 | *
|
---|
87 | */
|
---|
88 |
|
---|
89 | #if defined(CONFIG_SND_DYNAMIC_MINORS)
|
---|
90 | #define SNDRV_PCM_DEVICES (SNDRV_OS_MINORS-2)
|
---|
91 | #else
|
---|
92 | #define SNDRV_PCM_DEVICES 8
|
---|
93 | #endif
|
---|
94 |
|
---|
95 | #define SNDRV_PCM_IOCTL1_RESET 0
|
---|
96 | /* 1 is absent slot. */
|
---|
97 | #define SNDRV_PCM_IOCTL1_CHANNEL_INFO 2
|
---|
98 | /* 3 is absent slot. */
|
---|
99 | #define SNDRV_PCM_IOCTL1_FIFO_SIZE 4
|
---|
100 | #define SNDRV_PCM_IOCTL1_SYNC_ID 5
|
---|
101 |
|
---|
102 | #define SNDRV_PCM_TRIGGER_STOP 0
|
---|
103 | #define SNDRV_PCM_TRIGGER_START 1
|
---|
104 | #define SNDRV_PCM_TRIGGER_PAUSE_PUSH 3
|
---|
105 | #define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4
|
---|
106 | #define SNDRV_PCM_TRIGGER_SUSPEND 5
|
---|
107 | #define SNDRV_PCM_TRIGGER_RESUME 6
|
---|
108 | #define SNDRV_PCM_TRIGGER_DRAIN 7
|
---|
109 |
|
---|
110 | #define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
|
---|
111 |
|
---|
112 | /* If you change this don't forget to change rates[] table in pcm_native.c */
|
---|
113 | #define SNDRV_PCM_RATE_5512 (1U<<0) /* 5512Hz */
|
---|
114 | #define SNDRV_PCM_RATE_8000 (1U<<1) /* 8000Hz */
|
---|
115 | #define SNDRV_PCM_RATE_11025 (1U<<2) /* 11025Hz */
|
---|
116 | #define SNDRV_PCM_RATE_16000 (1U<<3) /* 16000Hz */
|
---|
117 | #define SNDRV_PCM_RATE_22050 (1U<<4) /* 22050Hz */
|
---|
118 | #define SNDRV_PCM_RATE_32000 (1U<<5) /* 32000Hz */
|
---|
119 | #define SNDRV_PCM_RATE_44100 (1U<<6) /* 44100Hz */
|
---|
120 | #define SNDRV_PCM_RATE_48000 (1U<<7) /* 48000Hz */
|
---|
121 | #define SNDRV_PCM_RATE_64000 (1U<<8) /* 64000Hz */
|
---|
122 | #define SNDRV_PCM_RATE_88200 (1U<<9) /* 88200Hz */
|
---|
123 | #define SNDRV_PCM_RATE_96000 (1U<<10) /* 96000Hz */
|
---|
124 | #define SNDRV_PCM_RATE_176400 (1U<<11) /* 176400Hz */
|
---|
125 | #define SNDRV_PCM_RATE_192000 (1U<<12) /* 192000Hz */
|
---|
126 | #define SNDRV_PCM_RATE_352800 (1U<<13) /* 352800Hz */
|
---|
127 | #define SNDRV_PCM_RATE_384000 (1U<<14) /* 384000Hz */
|
---|
128 | #define SNDRV_PCM_RATE_705600 (1U<<15) /* 705600Hz */
|
---|
129 | #define SNDRV_PCM_RATE_768000 (1U<<16) /* 768000Hz */
|
---|
130 | /* extended rates since 6.12 */
|
---|
131 | #define SNDRV_PCM_RATE_12000 (1U<<17) /* 12000Hz */
|
---|
132 | #define SNDRV_PCM_RATE_24000 (1U<<18) /* 24000Hz */
|
---|
133 | #define SNDRV_PCM_RATE_128000 (1U<<19) /* 128000Hz */
|
---|
134 |
|
---|
135 | #define SNDRV_PCM_RATE_CONTINUOUS (1U<<30) /* continuous range */
|
---|
136 | #define SNDRV_PCM_RATE_KNOT (1U<<31) /* supports more non-continuous rates */
|
---|
137 |
|
---|
138 | #define SNDRV_PCM_RATE_8000_44100 (SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_11025|\
|
---|
139 | SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_22050|\
|
---|
140 | SNDRV_PCM_RATE_32000|SNDRV_PCM_RATE_44100)
|
---|
141 | #define SNDRV_PCM_RATE_8000_48000 (SNDRV_PCM_RATE_8000_44100|SNDRV_PCM_RATE_48000)
|
---|
142 | #define SNDRV_PCM_RATE_8000_96000 (SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_64000|\
|
---|
143 | SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000)
|
---|
144 | #define SNDRV_PCM_RATE_8000_192000 (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\
|
---|
145 | SNDRV_PCM_RATE_192000)
|
---|
146 | #define SNDRV_PCM_RATE_8000_384000 (SNDRV_PCM_RATE_8000_192000|\
|
---|
147 | SNDRV_PCM_RATE_352800|\
|
---|
148 | SNDRV_PCM_RATE_384000)
|
---|
149 | #define SNDRV_PCM_RATE_8000_768000 (SNDRV_PCM_RATE_8000_384000|\
|
---|
150 | SNDRV_PCM_RATE_705600|\
|
---|
151 | SNDRV_PCM_RATE_768000)
|
---|
152 | #define _SNDRV_PCM_FMTBIT(fmt) (1ULL << (__force int)SNDRV_PCM_FORMAT_##fmt)
|
---|
153 | #define SNDRV_PCM_FMTBIT_S8 _SNDRV_PCM_FMTBIT(S8)
|
---|
154 | #define SNDRV_PCM_FMTBIT_U8 _SNDRV_PCM_FMTBIT(U8)
|
---|
155 | #define SNDRV_PCM_FMTBIT_S16_LE _SNDRV_PCM_FMTBIT(S16_LE)
|
---|
156 | #define SNDRV_PCM_FMTBIT_S16_BE _SNDRV_PCM_FMTBIT(S16_BE)
|
---|
157 | #define SNDRV_PCM_FMTBIT_U16_LE _SNDRV_PCM_FMTBIT(U16_LE)
|
---|
158 | #define SNDRV_PCM_FMTBIT_U16_BE _SNDRV_PCM_FMTBIT(U16_BE)
|
---|
159 | #define SNDRV_PCM_FMTBIT_S24_LE _SNDRV_PCM_FMTBIT(S24_LE)
|
---|
160 | #define SNDRV_PCM_FMTBIT_S24_BE _SNDRV_PCM_FMTBIT(S24_BE)
|
---|
161 | #define SNDRV_PCM_FMTBIT_U24_LE _SNDRV_PCM_FMTBIT(U24_LE)
|
---|
162 | #define SNDRV_PCM_FMTBIT_U24_BE _SNDRV_PCM_FMTBIT(U24_BE)
|
---|
163 | // For S32/U32 formats, 'msbits' hardware parameter is often used to deliver information about the
|
---|
164 | // available bit count in most significant bit. It's for the case of so-called 'left-justified' or
|
---|
165 | // `right-padding` sample which has less width than 32 bit.
|
---|
166 | #define SNDRV_PCM_FMTBIT_S32_LE _SNDRV_PCM_FMTBIT(S32_LE)
|
---|
167 | #define SNDRV_PCM_FMTBIT_S32_BE _SNDRV_PCM_FMTBIT(S32_BE)
|
---|
168 | #define SNDRV_PCM_FMTBIT_U32_LE _SNDRV_PCM_FMTBIT(U32_LE)
|
---|
169 | #define SNDRV_PCM_FMTBIT_U32_BE _SNDRV_PCM_FMTBIT(U32_BE)
|
---|
170 | #define SNDRV_PCM_FMTBIT_FLOAT_LE _SNDRV_PCM_FMTBIT(FLOAT_LE)
|
---|
171 | #define SNDRV_PCM_FMTBIT_FLOAT_BE _SNDRV_PCM_FMTBIT(FLOAT_BE)
|
---|
172 | #define SNDRV_PCM_FMTBIT_FLOAT64_LE _SNDRV_PCM_FMTBIT(FLOAT64_LE)
|
---|
173 | #define SNDRV_PCM_FMTBIT_FLOAT64_BE _SNDRV_PCM_FMTBIT(FLOAT64_BE)
|
---|
174 | #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_LE)
|
---|
175 | #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_BE)
|
---|
176 | #define SNDRV_PCM_FMTBIT_MU_LAW _SNDRV_PCM_FMTBIT(MU_LAW)
|
---|
177 | #define SNDRV_PCM_FMTBIT_A_LAW _SNDRV_PCM_FMTBIT(A_LAW)
|
---|
178 | #define SNDRV_PCM_FMTBIT_IMA_ADPCM _SNDRV_PCM_FMTBIT(IMA_ADPCM)
|
---|
179 | #define SNDRV_PCM_FMTBIT_MPEG _SNDRV_PCM_FMTBIT(MPEG)
|
---|
180 | #define SNDRV_PCM_FMTBIT_GSM _SNDRV_PCM_FMTBIT(GSM)
|
---|
181 | #define SNDRV_PCM_FMTBIT_S20_LE _SNDRV_PCM_FMTBIT(S20_LE)
|
---|
182 | #define SNDRV_PCM_FMTBIT_U20_LE _SNDRV_PCM_FMTBIT(U20_LE)
|
---|
183 | #define SNDRV_PCM_FMTBIT_S20_BE _SNDRV_PCM_FMTBIT(S20_BE)
|
---|
184 | #define SNDRV_PCM_FMTBIT_U20_BE _SNDRV_PCM_FMTBIT(U20_BE)
|
---|
185 | #define SNDRV_PCM_FMTBIT_SPECIAL _SNDRV_PCM_FMTBIT(SPECIAL)
|
---|
186 | #define SNDRV_PCM_FMTBIT_S24_3LE _SNDRV_PCM_FMTBIT(S24_3LE)
|
---|
187 | #define SNDRV_PCM_FMTBIT_U24_3LE _SNDRV_PCM_FMTBIT(U24_3LE)
|
---|
188 | #define SNDRV_PCM_FMTBIT_S24_3BE _SNDRV_PCM_FMTBIT(S24_3BE)
|
---|
189 | #define SNDRV_PCM_FMTBIT_U24_3BE _SNDRV_PCM_FMTBIT(U24_3BE)
|
---|
190 | #define SNDRV_PCM_FMTBIT_S20_3LE _SNDRV_PCM_FMTBIT(S20_3LE)
|
---|
191 | #define SNDRV_PCM_FMTBIT_U20_3LE _SNDRV_PCM_FMTBIT(U20_3LE)
|
---|
192 | #define SNDRV_PCM_FMTBIT_S20_3BE _SNDRV_PCM_FMTBIT(S20_3BE)
|
---|
193 | #define SNDRV_PCM_FMTBIT_U20_3BE _SNDRV_PCM_FMTBIT(U20_3BE)
|
---|
194 | #define SNDRV_PCM_FMTBIT_S18_3LE _SNDRV_PCM_FMTBIT(S18_3LE)
|
---|
195 | #define SNDRV_PCM_FMTBIT_U18_3LE _SNDRV_PCM_FMTBIT(U18_3LE)
|
---|
196 | #define SNDRV_PCM_FMTBIT_S18_3BE _SNDRV_PCM_FMTBIT(S18_3BE)
|
---|
197 | #define SNDRV_PCM_FMTBIT_U18_3BE _SNDRV_PCM_FMTBIT(U18_3BE)
|
---|
198 | #define SNDRV_PCM_FMTBIT_G723_24 _SNDRV_PCM_FMTBIT(G723_24)
|
---|
199 | #define SNDRV_PCM_FMTBIT_G723_24_1B _SNDRV_PCM_FMTBIT(G723_24_1B)
|
---|
200 | #define SNDRV_PCM_FMTBIT_G723_40 _SNDRV_PCM_FMTBIT(G723_40)
|
---|
201 | #define SNDRV_PCM_FMTBIT_G723_40_1B _SNDRV_PCM_FMTBIT(G723_40_1B)
|
---|
202 | #define SNDRV_PCM_FMTBIT_DSD_U8 _SNDRV_PCM_FMTBIT(DSD_U8)
|
---|
203 | #define SNDRV_PCM_FMTBIT_DSD_U16_LE _SNDRV_PCM_FMTBIT(DSD_U16_LE)
|
---|
204 | #define SNDRV_PCM_FMTBIT_DSD_U32_LE _SNDRV_PCM_FMTBIT(DSD_U32_LE)
|
---|
205 | #define SNDRV_PCM_FMTBIT_DSD_U16_BE _SNDRV_PCM_FMTBIT(DSD_U16_BE)
|
---|
206 | #define SNDRV_PCM_FMTBIT_DSD_U32_BE _SNDRV_PCM_FMTBIT(DSD_U32_BE)
|
---|
207 |
|
---|
208 | #ifdef SNDRV_LITTLE_ENDIAN
|
---|
209 | #define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE
|
---|
210 | #define SNDRV_PCM_FMTBIT_U16 SNDRV_PCM_FMTBIT_U16_LE
|
---|
211 | #define SNDRV_PCM_FMTBIT_S24 SNDRV_PCM_FMTBIT_S24_LE
|
---|
212 | #define SNDRV_PCM_FMTBIT_U24 SNDRV_PCM_FMTBIT_U24_LE
|
---|
213 | #define SNDRV_PCM_FMTBIT_S32 SNDRV_PCM_FMTBIT_S32_LE
|
---|
214 | #define SNDRV_PCM_FMTBIT_U32 SNDRV_PCM_FMTBIT_U32_LE
|
---|
215 | #define SNDRV_PCM_FMTBIT_FLOAT SNDRV_PCM_FMTBIT_FLOAT_LE
|
---|
216 | #define SNDRV_PCM_FMTBIT_FLOAT64 SNDRV_PCM_FMTBIT_FLOAT64_LE
|
---|
217 | #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE
|
---|
218 | #define SNDRV_PCM_FMTBIT_S20 SNDRV_PCM_FMTBIT_S20_LE
|
---|
219 | #define SNDRV_PCM_FMTBIT_U20 SNDRV_PCM_FMTBIT_U20_LE
|
---|
220 | #endif
|
---|
221 | #ifdef SNDRV_BIG_ENDIAN
|
---|
222 | #define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_BE
|
---|
223 | #define SNDRV_PCM_FMTBIT_U16 SNDRV_PCM_FMTBIT_U16_BE
|
---|
224 | #define SNDRV_PCM_FMTBIT_S24 SNDRV_PCM_FMTBIT_S24_BE
|
---|
225 | #define SNDRV_PCM_FMTBIT_U24 SNDRV_PCM_FMTBIT_U24_BE
|
---|
226 | #define SNDRV_PCM_FMTBIT_S32 SNDRV_PCM_FMTBIT_S32_BE
|
---|
227 | #define SNDRV_PCM_FMTBIT_U32 SNDRV_PCM_FMTBIT_U32_BE
|
---|
228 | #define SNDRV_PCM_FMTBIT_FLOAT SNDRV_PCM_FMTBIT_FLOAT_BE
|
---|
229 | #define SNDRV_PCM_FMTBIT_FLOAT64 SNDRV_PCM_FMTBIT_FLOAT64_BE
|
---|
230 | #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE
|
---|
231 | #define SNDRV_PCM_FMTBIT_S20 SNDRV_PCM_FMTBIT_S20_BE
|
---|
232 | #define SNDRV_PCM_FMTBIT_U20 SNDRV_PCM_FMTBIT_U20_BE
|
---|
233 | #endif
|
---|
234 |
|
---|
235 | #define _SNDRV_PCM_SUBFMTBIT(fmt) BIT((__force int)SNDRV_PCM_SUBFORMAT_##fmt)
|
---|
236 | #define SNDRV_PCM_SUBFMTBIT_STD _SNDRV_PCM_SUBFMTBIT(STD)
|
---|
237 | #define SNDRV_PCM_SUBFMTBIT_MSBITS_MAX _SNDRV_PCM_SUBFMTBIT(MSBITS_MAX)
|
---|
238 | #define SNDRV_PCM_SUBFMTBIT_MSBITS_20 _SNDRV_PCM_SUBFMTBIT(MSBITS_20)
|
---|
239 | #define SNDRV_PCM_SUBFMTBIT_MSBITS_24 _SNDRV_PCM_SUBFMTBIT(MSBITS_24)
|
---|
240 |
|
---|
241 | struct snd_pcm_file {
|
---|
242 | struct snd_pcm_substream *substream;
|
---|
243 | int no_compat_mmap;
|
---|
244 | unsigned int user_pversion; /* supported protocol version */
|
---|
245 | };
|
---|
246 |
|
---|
247 | struct snd_pcm_hw_rule;
|
---|
248 | typedef int (*snd_pcm_hw_rule_func_t)(struct snd_pcm_hw_params *params,
|
---|
249 | struct snd_pcm_hw_rule *rule);
|
---|
250 |
|
---|
251 | struct snd_pcm_hw_rule {
|
---|
252 | unsigned int cond;
|
---|
253 | int var;
|
---|
254 | int deps[5];
|
---|
255 |
|
---|
256 | snd_pcm_hw_rule_func_t func;
|
---|
257 | void *private;
|
---|
258 | };
|
---|
259 |
|
---|
260 | struct snd_pcm_hw_constraints {
|
---|
261 | struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
|
---|
262 | SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];
|
---|
263 | struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
|
---|
264 | SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
|
---|
265 | unsigned int rules_num;
|
---|
266 | unsigned int rules_all;
|
---|
267 | struct snd_pcm_hw_rule *rules;
|
---|
268 | };
|
---|
269 |
|
---|
270 | static inline struct snd_mask *constrs_mask(struct snd_pcm_hw_constraints *constrs,
|
---|
271 | snd_pcm_hw_param_t var)
|
---|
272 | {
|
---|
273 | return &constrs->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK];
|
---|
274 | }
|
---|
275 |
|
---|
276 | static inline struct snd_interval *constrs_interval(struct snd_pcm_hw_constraints *constrs,
|
---|
277 | snd_pcm_hw_param_t var)
|
---|
278 | {
|
---|
279 | return &constrs->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
|
---|
280 | }
|
---|
281 |
|
---|
282 | struct snd_ratnum {
|
---|
283 | unsigned int num;
|
---|
284 | unsigned int den_min, den_max, den_step;
|
---|
285 | };
|
---|
286 |
|
---|
287 | struct snd_ratden {
|
---|
288 | unsigned int num_min, num_max, num_step;
|
---|
289 | unsigned int den;
|
---|
290 | };
|
---|
291 |
|
---|
292 | struct snd_pcm_hw_constraint_ratnums {
|
---|
293 | int nrats;
|
---|
294 | const struct snd_ratnum *rats;
|
---|
295 | };
|
---|
296 |
|
---|
297 | struct snd_pcm_hw_constraint_ratdens {
|
---|
298 | int nrats;
|
---|
299 | const struct snd_ratden *rats;
|
---|
300 | };
|
---|
301 |
|
---|
302 | struct snd_pcm_hw_constraint_list {
|
---|
303 | const unsigned int *list;
|
---|
304 | unsigned int count;
|
---|
305 | unsigned int mask;
|
---|
306 | };
|
---|
307 |
|
---|
308 | struct snd_pcm_hw_constraint_ranges {
|
---|
309 | unsigned int count;
|
---|
310 | const struct snd_interval *ranges;
|
---|
311 | unsigned int mask;
|
---|
312 | };
|
---|
313 |
|
---|
314 | /*
|
---|
315 | * userspace-provided audio timestamp config to kernel,
|
---|
316 | * structure is for internal use only and filled with dedicated unpack routine
|
---|
317 | */
|
---|
318 | struct snd_pcm_audio_tstamp_config {
|
---|
319 | /* 5 of max 16 bits used */
|
---|
320 | u32 type_requested:4;
|
---|
321 | u32 report_delay:1; /* add total delay to A/D or D/A */
|
---|
322 | };
|
---|
323 |
|
---|
324 | static inline void snd_pcm_unpack_audio_tstamp_config(__u32 data,
|
---|
325 | struct snd_pcm_audio_tstamp_config *config)
|
---|
326 | {
|
---|
327 | config->type_requested = data & 0xF;
|
---|
328 | config->report_delay = (data >> 4) & 1;
|
---|
329 | }
|
---|
330 |
|
---|
331 | /*
|
---|
332 | * kernel-provided audio timestamp report to user-space
|
---|
333 | * structure is for internal use only and read by dedicated pack routine
|
---|
334 | */
|
---|
335 | struct snd_pcm_audio_tstamp_report {
|
---|
336 | /* 6 of max 16 bits used for bit-fields */
|
---|
337 |
|
---|
338 | /* for backwards compatibility */
|
---|
339 | u32 valid:1;
|
---|
340 |
|
---|
341 | /* actual type if hardware could not support requested timestamp */
|
---|
342 | u32 actual_type:4;
|
---|
343 |
|
---|
344 | /* accuracy represented in ns units */
|
---|
345 | u32 accuracy_report:1; /* 0 if accuracy unknown, 1 if accuracy field is valid */
|
---|
346 | u32 accuracy; /* up to 4.29s, will be packed in separate field */
|
---|
347 | };
|
---|
348 |
|
---|
349 | static inline void snd_pcm_pack_audio_tstamp_report(__u32 *data, __u32 *accuracy,
|
---|
350 | const struct snd_pcm_audio_tstamp_report *report)
|
---|
351 | {
|
---|
352 | u32 tmp;
|
---|
353 |
|
---|
354 | tmp = report->accuracy_report;
|
---|
355 | tmp <<= 4;
|
---|
356 | tmp |= report->actual_type;
|
---|
357 | tmp <<= 1;
|
---|
358 | tmp |= report->valid;
|
---|
359 |
|
---|
360 | *data &= 0xffff; /* zero-clear MSBs */
|
---|
361 | *data |= (tmp << 16);
|
---|
362 | *accuracy = report->accuracy;
|
---|
363 | }
|
---|
364 |
|
---|
365 |
|
---|
366 | struct snd_pcm_runtime {
|
---|
367 | /* -- Status -- */
|
---|
368 | snd_pcm_state_t state; /* stream state */
|
---|
369 | snd_pcm_state_t suspended_state; /* suspended stream state */
|
---|
370 | struct snd_pcm_substream *trigger_master;
|
---|
371 | struct timespec64 trigger_tstamp; /* trigger timestamp */
|
---|
372 | bool trigger_tstamp_latched; /* trigger timestamp latched in low-level driver/hardware */
|
---|
373 | int overrange;
|
---|
374 | snd_pcm_uframes_t avail_max;
|
---|
375 | snd_pcm_uframes_t hw_ptr_base; /* Position at buffer restart */
|
---|
376 | snd_pcm_uframes_t hw_ptr_interrupt; /* Position at interrupt time */
|
---|
377 | unsigned long hw_ptr_jiffies; /* Time when hw_ptr is updated */
|
---|
378 | unsigned long hw_ptr_buffer_jiffies; /* buffer time in jiffies */
|
---|
379 | snd_pcm_sframes_t delay; /* extra delay; typically FIFO size */
|
---|
380 | u64 hw_ptr_wrap; /* offset for hw_ptr due to boundary wrap-around */
|
---|
381 |
|
---|
382 | /* -- HW params -- */
|
---|
383 | snd_pcm_access_t access; /* access mode */
|
---|
384 | snd_pcm_format_t format; /* SNDRV_PCM_FORMAT_* */
|
---|
385 | snd_pcm_subformat_t subformat; /* subformat */
|
---|
386 | unsigned int rate; /* rate in Hz */
|
---|
387 | unsigned int channels; /* channels */
|
---|
388 | snd_pcm_uframes_t period_size; /* period size */
|
---|
389 | unsigned int periods; /* periods */
|
---|
390 | snd_pcm_uframes_t buffer_size; /* buffer size */
|
---|
391 | snd_pcm_uframes_t min_align; /* Min alignment for the format */
|
---|
392 | size_t byte_align;
|
---|
393 | unsigned int frame_bits;
|
---|
394 | unsigned int sample_bits;
|
---|
395 | unsigned int info;
|
---|
396 | unsigned int rate_num;
|
---|
397 | unsigned int rate_den;
|
---|
398 | unsigned int no_period_wakeup: 1;
|
---|
399 |
|
---|
400 | /* -- SW params; see struct snd_pcm_sw_params for comments -- */
|
---|
401 | int tstamp_mode;
|
---|
402 | unsigned int period_step;
|
---|
403 | snd_pcm_uframes_t start_threshold;
|
---|
404 | snd_pcm_uframes_t stop_threshold;
|
---|
405 | snd_pcm_uframes_t silence_threshold;
|
---|
406 | snd_pcm_uframes_t silence_size;
|
---|
407 | snd_pcm_uframes_t boundary;
|
---|
408 |
|
---|
409 | /* internal data of auto-silencer */
|
---|
410 | snd_pcm_uframes_t silence_start; /* starting pointer to silence area */
|
---|
411 | snd_pcm_uframes_t silence_filled; /* already filled part of silence area */
|
---|
412 |
|
---|
413 | bool std_sync_id; /* hardware synchronization - standard per card ID */
|
---|
414 |
|
---|
415 | /* -- mmap -- */
|
---|
416 | struct snd_pcm_mmap_status *status;
|
---|
417 | struct snd_pcm_mmap_control *control;
|
---|
418 |
|
---|
419 | /* -- locking / scheduling -- */
|
---|
420 | snd_pcm_uframes_t twake; /* do transfer (!poll) wakeup if non-zero */
|
---|
421 | wait_queue_head_t sleep; /* poll sleep */
|
---|
422 | wait_queue_head_t tsleep; /* transfer sleep */
|
---|
423 | struct snd_fasync *fasync;
|
---|
424 | bool stop_operating; /* sync_stop will be called */
|
---|
425 | struct mutex buffer_mutex; /* protect for buffer changes */
|
---|
426 | atomic_t buffer_accessing; /* >0: in r/w operation, <0: blocked */
|
---|
427 |
|
---|
428 | /* -- private section -- */
|
---|
429 | void *private_data;
|
---|
430 | void (*private_free)(struct snd_pcm_runtime *runtime);
|
---|
431 |
|
---|
432 | /* -- hardware description -- */
|
---|
433 | struct snd_pcm_hardware hw;
|
---|
434 | struct snd_pcm_hw_constraints hw_constraints;
|
---|
435 |
|
---|
436 | /* -- timer -- */
|
---|
437 | unsigned int timer_resolution; /* timer resolution */
|
---|
438 | int tstamp_type; /* timestamp type */
|
---|
439 |
|
---|
440 | /* -- DMA -- */
|
---|
441 | unsigned char *dma_area; /* DMA area */
|
---|
442 | dma_addr_t dma_addr; /* physical bus address (not accessible from main CPU) */
|
---|
443 | size_t dma_bytes; /* size of DMA area */
|
---|
444 |
|
---|
445 | struct snd_dma_buffer *dma_buffer_p; /* allocated buffer */
|
---|
446 | unsigned int buffer_changed:1; /* buffer allocation changed; set only in managed mode */
|
---|
447 |
|
---|
448 | /* -- audio timestamp config -- */
|
---|
449 | struct snd_pcm_audio_tstamp_config audio_tstamp_config;
|
---|
450 | struct snd_pcm_audio_tstamp_report audio_tstamp_report;
|
---|
451 | struct timespec64 driver_tstamp;
|
---|
452 |
|
---|
453 | #if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
|
---|
454 | /* -- OSS things -- */
|
---|
455 | struct snd_pcm_oss_runtime oss;
|
---|
456 | #endif
|
---|
457 | };
|
---|
458 |
|
---|
459 | struct snd_pcm_group { /* keep linked substreams */
|
---|
460 | spinlock_t lock;
|
---|
461 | struct mutex mutex;
|
---|
462 | struct list_head substreams;
|
---|
463 | refcount_t refs;
|
---|
464 | };
|
---|
465 |
|
---|
466 | struct pid;
|
---|
467 |
|
---|
468 | struct snd_pcm_substream {
|
---|
469 | struct snd_pcm *pcm;
|
---|
470 | struct snd_pcm_str *pstr;
|
---|
471 | void *private_data; /* copied from pcm->private_data */
|
---|
472 | int number;
|
---|
473 | char name[32]; /* substream name */
|
---|
474 | int stream; /* stream (direction) */
|
---|
475 | struct pm_qos_request latency_pm_qos_req; /* pm_qos request */
|
---|
476 | size_t buffer_bytes_max; /* limit ring buffer size */
|
---|
477 | struct snd_dma_buffer dma_buffer;
|
---|
478 | size_t dma_max;
|
---|
479 | /* -- hardware operations -- */
|
---|
480 | const struct snd_pcm_ops *ops;
|
---|
481 | /* -- runtime information -- */
|
---|
482 | struct snd_pcm_runtime *runtime;
|
---|
483 | /* -- timer section -- */
|
---|
484 | struct snd_timer *timer; /* timer */
|
---|
485 | unsigned timer_running: 1; /* time is running */
|
---|
486 | long wait_time; /* time in ms for R/W to wait for avail */
|
---|
487 | /* -- next substream -- */
|
---|
488 | struct snd_pcm_substream *next;
|
---|
489 | /* -- linked substreams -- */
|
---|
490 | struct list_head link_list; /* linked list member */
|
---|
491 | struct snd_pcm_group self_group; /* fake group for non linked substream (with substream lock inside) */
|
---|
492 | struct snd_pcm_group *group; /* pointer to current group */
|
---|
493 | /* -- assigned files -- */
|
---|
494 | int ref_count;
|
---|
495 | atomic_t mmap_count;
|
---|
496 | unsigned int f_flags;
|
---|
497 | void (*pcm_release)(struct snd_pcm_substream *);
|
---|
498 | struct pid *pid;
|
---|
499 | #if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
|
---|
500 | /* -- OSS things -- */
|
---|
501 | struct snd_pcm_oss_substream oss;
|
---|
502 | #endif
|
---|
503 | #ifdef CONFIG_SND_VERBOSE_PROCFS
|
---|
504 | struct snd_info_entry *proc_root;
|
---|
505 | #endif /* CONFIG_SND_VERBOSE_PROCFS */
|
---|
506 | /* misc flags */
|
---|
507 | unsigned int hw_opened: 1;
|
---|
508 | unsigned int managed_buffer_alloc:1;
|
---|
509 | #ifdef CONFIG_SND_PCM_XRUN_DEBUG
|
---|
510 | unsigned int xrun_counter; /* number of times xrun happens */
|
---|
511 | #endif /* CONFIG_SND_PCM_XRUN_DEBUG */
|
---|
512 | };
|
---|
513 |
|
---|
514 | #define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0)
|
---|
515 |
|
---|
516 |
|
---|
517 | struct snd_pcm_str {
|
---|
518 | int stream; /* stream (direction) */
|
---|
519 | struct snd_pcm *pcm;
|
---|
520 | /* -- substreams -- */
|
---|
521 | unsigned int substream_count;
|
---|
522 | unsigned int substream_opened;
|
---|
523 | struct snd_pcm_substream *substream;
|
---|
524 | #if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
|
---|
525 | /* -- OSS things -- */
|
---|
526 | struct snd_pcm_oss_stream oss;
|
---|
527 | #endif
|
---|
528 | #ifdef CONFIG_SND_VERBOSE_PROCFS
|
---|
529 | struct snd_info_entry *proc_root;
|
---|
530 | #ifdef CONFIG_SND_PCM_XRUN_DEBUG
|
---|
531 | unsigned int xrun_debug; /* 0 = disabled, 1 = verbose, 2 = stacktrace */
|
---|
532 | #endif
|
---|
533 | #endif
|
---|
534 | struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */
|
---|
535 | struct device *dev;
|
---|
536 | };
|
---|
537 |
|
---|
538 | struct snd_pcm {
|
---|
539 | struct snd_card *card;
|
---|
540 | struct list_head list;
|
---|
541 | int device; /* device number */
|
---|
542 | unsigned int info_flags;
|
---|
543 | unsigned short dev_class;
|
---|
544 | unsigned short dev_subclass;
|
---|
545 | char id[64];
|
---|
546 | char name[80];
|
---|
547 | struct snd_pcm_str streams[2];
|
---|
548 | struct mutex open_mutex;
|
---|
549 | wait_queue_head_t open_wait;
|
---|
550 | void *private_data;
|
---|
551 | void (*private_free) (struct snd_pcm *pcm);
|
---|
552 | bool internal; /* pcm is for internal use only */
|
---|
553 | bool nonatomic; /* whole PCM operations are in non-atomic context */
|
---|
554 | bool no_device_suspend; /* don't invoke device PM suspend */
|
---|
555 | #if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
|
---|
556 | struct snd_pcm_oss oss;
|
---|
557 | #endif
|
---|
558 | };
|
---|
559 |
|
---|
560 | /*
|
---|
561 | * Registering
|
---|
562 | */
|
---|
563 |
|
---|
564 | extern const struct file_operations snd_pcm_f_ops[2];
|
---|
565 |
|
---|
566 | int snd_pcm_new(struct snd_card *card, const char *id, int device,
|
---|
567 | int playback_count, int capture_count,
|
---|
568 | struct snd_pcm **rpcm);
|
---|
569 | int snd_pcm_new_internal(struct snd_card *card, const char *id, int device,
|
---|
570 | int playback_count, int capture_count,
|
---|
571 | struct snd_pcm **rpcm);
|
---|
572 | int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count);
|
---|
573 |
|
---|
574 | #if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS)
|
---|
575 | struct snd_pcm_notify {
|
---|
576 | int (*n_register) (struct snd_pcm * pcm);
|
---|
577 | int (*n_disconnect) (struct snd_pcm * pcm);
|
---|
578 | int (*n_unregister) (struct snd_pcm * pcm);
|
---|
579 | struct list_head list;
|
---|
580 | };
|
---|
581 | int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree);
|
---|
582 | #endif
|
---|
583 |
|
---|
584 | /*
|
---|
585 | * Native I/O
|
---|
586 | */
|
---|
587 |
|
---|
588 | int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info);
|
---|
589 | int snd_pcm_info_user(struct snd_pcm_substream *substream,
|
---|
590 | struct snd_pcm_info __user *info);
|
---|
591 | int snd_pcm_status64(struct snd_pcm_substream *substream,
|
---|
592 | struct snd_pcm_status64 *status);
|
---|
593 | int snd_pcm_start(struct snd_pcm_substream *substream);
|
---|
594 | int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
|
---|
595 | int snd_pcm_drain_done(struct snd_pcm_substream *substream);
|
---|
596 | int snd_pcm_stop_xrun(struct snd_pcm_substream *substream);
|
---|
597 | #ifdef CONFIG_PM
|
---|
598 | int snd_pcm_suspend_all(struct snd_pcm *pcm);
|
---|
599 | #else
|
---|
600 | static inline int snd_pcm_suspend_all(struct snd_pcm *pcm)
|
---|
601 | {
|
---|
602 | return 0;
|
---|
603 | }
|
---|
604 | #endif
|
---|
605 | int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg);
|
---|
606 | int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, struct file *file,
|
---|
607 | struct snd_pcm_substream **rsubstream);
|
---|
608 | void snd_pcm_release_substream(struct snd_pcm_substream *substream);
|
---|
609 | int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, struct file *file,
|
---|
610 | struct snd_pcm_substream **rsubstream);
|
---|
611 | void snd_pcm_detach_substream(struct snd_pcm_substream *substream);
|
---|
612 | int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area);
|
---|
613 |
|
---|
614 |
|
---|
615 | #ifdef CONFIG_SND_DEBUG
|
---|
616 | void snd_pcm_debug_name(struct snd_pcm_substream *substream,
|
---|
617 | char *name, size_t len);
|
---|
618 | #else
|
---|
619 | static inline void
|
---|
620 | snd_pcm_debug_name(struct snd_pcm_substream *substream, char *buf, size_t size)
|
---|
621 | {
|
---|
622 | *buf = 0;
|
---|
623 | }
|
---|
624 | #endif
|
---|
625 |
|
---|
626 | /*
|
---|
627 | * PCM library
|
---|
628 | */
|
---|
629 |
|
---|
630 | /**
|
---|
631 | * snd_pcm_stream_linked - Check whether the substream is linked with others
|
---|
632 | * @substream: substream to check
|
---|
633 | *
|
---|
634 | * Return: true if the given substream is being linked with others
|
---|
635 | */
|
---|
636 | static inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream)
|
---|
637 | {
|
---|
638 | return substream->group != &substream->self_group;
|
---|
639 | }
|
---|
640 |
|
---|
641 | void snd_pcm_stream_lock(struct snd_pcm_substream *substream);
|
---|
642 | void snd_pcm_stream_unlock(struct snd_pcm_substream *substream);
|
---|
643 | void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream);
|
---|
644 | void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream);
|
---|
645 | unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream);
|
---|
646 | unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream);
|
---|
647 |
|
---|
648 | /**
|
---|
649 | * snd_pcm_stream_lock_irqsave - Lock the PCM stream
|
---|
650 | * @substream: PCM substream
|
---|
651 | * @flags: irq flags
|
---|
652 | *
|
---|
653 | * This locks the PCM stream like snd_pcm_stream_lock() but with the local
|
---|
654 | * IRQ (only when nonatomic is false). In nonatomic case, this is identical
|
---|
655 | * as snd_pcm_stream_lock().
|
---|
656 | */
|
---|
657 | #ifndef TARGET_OS2
|
---|
658 | #define snd_pcm_stream_lock_irqsave(substream, flags) \
|
---|
659 | do { \
|
---|
660 | typecheck(unsigned long, flags); \
|
---|
661 | flags = _snd_pcm_stream_lock_irqsave(substream); \
|
---|
662 | } while (0)
|
---|
663 | #else
|
---|
664 | #define snd_pcm_stream_lock_irqsave(substream, flags) \
|
---|
665 | do { \
|
---|
666 | flags = _snd_pcm_stream_lock_irqsave(substream); \
|
---|
667 | } while (0)
|
---|
668 | #endif
|
---|
669 | void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
|
---|
670 | unsigned long flags);
|
---|
671 |
|
---|
672 | /**
|
---|
673 | * snd_pcm_stream_lock_irqsave_nested - Single-nested PCM stream locking
|
---|
674 | * @substream: PCM substream
|
---|
675 | * @flags: irq flags
|
---|
676 | *
|
---|
677 | * This locks the PCM stream like snd_pcm_stream_lock_irqsave() but with
|
---|
678 | * the single-depth lockdep subclass.
|
---|
679 | */
|
---|
680 | #define snd_pcm_stream_lock_irqsave_nested(substream, flags) \
|
---|
681 | do { \
|
---|
682 | typecheck(unsigned long, flags); \
|
---|
683 | flags = _snd_pcm_stream_lock_irqsave_nested(substream); \
|
---|
684 | } while (0)
|
---|
685 |
|
---|
686 | #ifndef TARGET_OS2
|
---|
687 | /* definitions for guard(); use like guard(pcm_stream_lock) */
|
---|
688 | DEFINE_LOCK_GUARD_1(pcm_stream_lock, struct snd_pcm_substream,
|
---|
689 | snd_pcm_stream_lock(_T->lock),
|
---|
690 | snd_pcm_stream_unlock(_T->lock))
|
---|
691 | DEFINE_LOCK_GUARD_1(pcm_stream_lock_irq, struct snd_pcm_substream,
|
---|
692 | snd_pcm_stream_lock_irq(_T->lock),
|
---|
693 | snd_pcm_stream_unlock_irq(_T->lock))
|
---|
694 | DEFINE_LOCK_GUARD_1(pcm_stream_lock_irqsave, struct snd_pcm_substream,
|
---|
695 | snd_pcm_stream_lock_irqsave(_T->lock, _T->flags),
|
---|
696 | snd_pcm_stream_unlock_irqrestore(_T->lock, _T->flags),
|
---|
697 | unsigned long flags)
|
---|
698 | #endif
|
---|
699 |
|
---|
700 | /**
|
---|
701 | * snd_pcm_group_for_each_entry - iterate over the linked substreams
|
---|
702 | * @s: the iterator
|
---|
703 | * @substream: the substream
|
---|
704 | *
|
---|
705 | * Iterate over the all linked substreams to the given @substream.
|
---|
706 | * When @substream isn't linked with any others, this gives returns @substream
|
---|
707 | * itself once.
|
---|
708 | */
|
---|
709 | #define snd_pcm_group_for_each_entry(s, substream) \
|
---|
710 | list_for_each_entry(s, &substream->group->substreams, link_list, struct snd_pcm_substream)
|
---|
711 |
|
---|
712 | #define for_each_pcm_streams(stream) \
|
---|
713 | for (stream = SNDRV_PCM_STREAM_PLAYBACK; \
|
---|
714 | stream <= SNDRV_PCM_STREAM_LAST; \
|
---|
715 | stream++)
|
---|
716 |
|
---|
717 | /**
|
---|
718 | * snd_pcm_running - Check whether the substream is in a running state
|
---|
719 | * @substream: substream to check
|
---|
720 | *
|
---|
721 | * Return: true if the given substream is in the state RUNNING, or in the
|
---|
722 | * state DRAINING for playback.
|
---|
723 | */
|
---|
724 | static inline int snd_pcm_running(struct snd_pcm_substream *substream)
|
---|
725 | {
|
---|
726 | return (substream->runtime->state == SNDRV_PCM_STATE_RUNNING ||
|
---|
727 | (substream->runtime->state == SNDRV_PCM_STATE_DRAINING &&
|
---|
728 | substream->stream == SNDRV_PCM_STREAM_PLAYBACK));
|
---|
729 | }
|
---|
730 |
|
---|
731 | /**
|
---|
732 | * __snd_pcm_set_state - Change the current PCM state
|
---|
733 | * @runtime: PCM runtime to set
|
---|
734 | * @state: the current state to set
|
---|
735 | *
|
---|
736 | * Call within the stream lock
|
---|
737 | */
|
---|
738 | static inline void __snd_pcm_set_state(struct snd_pcm_runtime *runtime,
|
---|
739 | snd_pcm_state_t state)
|
---|
740 | {
|
---|
741 | runtime->state = state;
|
---|
742 | runtime->status->state = state; /* copy for mmap */
|
---|
743 | }
|
---|
744 |
|
---|
745 | /**
|
---|
746 | * bytes_to_samples - Unit conversion of the size from bytes to samples
|
---|
747 | * @runtime: PCM runtime instance
|
---|
748 | * @size: size in bytes
|
---|
749 | *
|
---|
750 | * Return: the size in samples
|
---|
751 | */
|
---|
752 | static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size)
|
---|
753 | {
|
---|
754 | return size * 8 / runtime->sample_bits;
|
---|
755 | }
|
---|
756 |
|
---|
757 | /**
|
---|
758 | * bytes_to_frames - Unit conversion of the size from bytes to frames
|
---|
759 | * @runtime: PCM runtime instance
|
---|
760 | * @size: size in bytes
|
---|
761 | *
|
---|
762 | * Return: the size in frames
|
---|
763 | */
|
---|
764 | static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size)
|
---|
765 | {
|
---|
766 | return size * 8 / runtime->frame_bits;
|
---|
767 | }
|
---|
768 |
|
---|
769 | /**
|
---|
770 | * samples_to_bytes - Unit conversion of the size from samples to bytes
|
---|
771 | * @runtime: PCM runtime instance
|
---|
772 | * @size: size in samples
|
---|
773 | *
|
---|
774 | * Return: the byte size
|
---|
775 | */
|
---|
776 | static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size)
|
---|
777 | {
|
---|
778 | return size * runtime->sample_bits / 8;
|
---|
779 | }
|
---|
780 |
|
---|
781 | /**
|
---|
782 | * frames_to_bytes - Unit conversion of the size from frames to bytes
|
---|
783 | * @runtime: PCM runtime instance
|
---|
784 | * @size: size in frames
|
---|
785 | *
|
---|
786 | * Return: the byte size
|
---|
787 | */
|
---|
788 | static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size)
|
---|
789 | {
|
---|
790 | return size * runtime->frame_bits / 8;
|
---|
791 | }
|
---|
792 |
|
---|
793 | /**
|
---|
794 | * frame_aligned - Check whether the byte size is aligned to frames
|
---|
795 | * @runtime: PCM runtime instance
|
---|
796 | * @bytes: size in bytes
|
---|
797 | *
|
---|
798 | * Return: true if aligned, or false if not
|
---|
799 | */
|
---|
800 | static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes)
|
---|
801 | {
|
---|
802 | return bytes % runtime->byte_align == 0;
|
---|
803 | }
|
---|
804 |
|
---|
805 | /**
|
---|
806 | * snd_pcm_lib_buffer_bytes - Get the buffer size of the current PCM in bytes
|
---|
807 | * @substream: PCM substream
|
---|
808 | *
|
---|
809 | * Return: buffer byte size
|
---|
810 | */
|
---|
811 | static inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream)
|
---|
812 | {
|
---|
813 | struct snd_pcm_runtime *runtime = substream->runtime;
|
---|
814 | return frames_to_bytes(runtime, runtime->buffer_size);
|
---|
815 | }
|
---|
816 |
|
---|
817 | /**
|
---|
818 | * snd_pcm_lib_period_bytes - Get the period size of the current PCM in bytes
|
---|
819 | * @substream: PCM substream
|
---|
820 | *
|
---|
821 | * Return: period byte size
|
---|
822 | */
|
---|
823 | static inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream)
|
---|
824 | {
|
---|
825 | struct snd_pcm_runtime *runtime = substream->runtime;
|
---|
826 | return frames_to_bytes(runtime, runtime->period_size);
|
---|
827 | }
|
---|
828 |
|
---|
829 | /**
|
---|
830 | * snd_pcm_playback_avail - Get the available (writable) space for playback
|
---|
831 | * @runtime: PCM runtime instance
|
---|
832 | *
|
---|
833 | * Result is between 0 ... (boundary - 1)
|
---|
834 | *
|
---|
835 | * Return: available frame size
|
---|
836 | */
|
---|
837 | static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime)
|
---|
838 | {
|
---|
839 | snd_pcm_sframes_t avail = runtime->status->hw_ptr + runtime->buffer_size - runtime->control->appl_ptr;
|
---|
840 | #if defined TARGET_OS2
|
---|
841 | if ( runtime->buffer_size > runtime->control->appl_ptr)
|
---|
842 | avail = runtime->status->hw_ptr + runtime->buffer_size - runtime->control->appl_ptr;
|
---|
843 | else
|
---|
844 | {
|
---|
845 |
|
---|
846 | avail = runtime->control->appl_ptr - runtime->status->hw_ptr;
|
---|
847 | if ( avail > runtime->buffer_size )
|
---|
848 | avail = 0;
|
---|
849 | else
|
---|
850 | avail = runtime->buffer_size - avail;
|
---|
851 | }
|
---|
852 | #endif /* TARGET_OS2 */
|
---|
853 | if (avail < 0)
|
---|
854 | avail += runtime->boundary;
|
---|
855 | else if ((snd_pcm_uframes_t) avail >= runtime->boundary)
|
---|
856 | avail -= runtime->boundary;
|
---|
857 | return avail;
|
---|
858 | }
|
---|
859 |
|
---|
860 | /**
|
---|
861 | * snd_pcm_capture_avail - Get the available (readable) space for capture
|
---|
862 | * @runtime: PCM runtime instance
|
---|
863 | *
|
---|
864 | * Result is between 0 ... (boundary - 1)
|
---|
865 | *
|
---|
866 | * Return: available frame size
|
---|
867 | */
|
---|
868 | static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime)
|
---|
869 | {
|
---|
870 | snd_pcm_sframes_t avail = runtime->status->hw_ptr - runtime->control->appl_ptr;
|
---|
871 | if (avail < 0)
|
---|
872 | avail += runtime->boundary;
|
---|
873 | return avail;
|
---|
874 | }
|
---|
875 |
|
---|
876 | /**
|
---|
877 | * snd_pcm_playback_hw_avail - Get the queued space for playback
|
---|
878 | * @runtime: PCM runtime instance
|
---|
879 | *
|
---|
880 | * Return: available frame size
|
---|
881 | */
|
---|
882 | static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(struct snd_pcm_runtime *runtime)
|
---|
883 | {
|
---|
884 | return runtime->buffer_size - snd_pcm_playback_avail(runtime);
|
---|
885 | }
|
---|
886 |
|
---|
887 | /**
|
---|
888 | * snd_pcm_capture_hw_avail - Get the free space for capture
|
---|
889 | * @runtime: PCM runtime instance
|
---|
890 | *
|
---|
891 | * Return: available frame size
|
---|
892 | */
|
---|
893 | static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime *runtime)
|
---|
894 | {
|
---|
895 | return runtime->buffer_size - snd_pcm_capture_avail(runtime);
|
---|
896 | }
|
---|
897 |
|
---|
898 | /**
|
---|
899 | * snd_pcm_playback_ready - check whether the playback buffer is available
|
---|
900 | * @substream: the pcm substream instance
|
---|
901 | *
|
---|
902 | * Checks whether enough free space is available on the playback buffer.
|
---|
903 | *
|
---|
904 | * Return: Non-zero if available, or zero if not.
|
---|
905 | */
|
---|
906 | static inline int snd_pcm_playback_ready(struct snd_pcm_substream *substream)
|
---|
907 | {
|
---|
908 | struct snd_pcm_runtime *runtime = substream->runtime;
|
---|
909 | return snd_pcm_playback_avail(runtime) >= runtime->control->avail_min;
|
---|
910 | }
|
---|
911 |
|
---|
912 | /**
|
---|
913 | * snd_pcm_capture_ready - check whether the capture buffer is available
|
---|
914 | * @substream: the pcm substream instance
|
---|
915 | *
|
---|
916 | * Checks whether enough capture data is available on the capture buffer.
|
---|
917 | *
|
---|
918 | * Return: Non-zero if available, or zero if not.
|
---|
919 | */
|
---|
920 | static inline int snd_pcm_capture_ready(struct snd_pcm_substream *substream)
|
---|
921 | {
|
---|
922 | struct snd_pcm_runtime *runtime = substream->runtime;
|
---|
923 | return snd_pcm_capture_avail(runtime) >= runtime->control->avail_min;
|
---|
924 | }
|
---|
925 |
|
---|
926 | /**
|
---|
927 | * snd_pcm_playback_data - check whether any data exists on the playback buffer
|
---|
928 | * @substream: the pcm substream instance
|
---|
929 | *
|
---|
930 | * Checks whether any data exists on the playback buffer.
|
---|
931 | *
|
---|
932 | * Return: Non-zero if any data exists, or zero if not. If stop_threshold
|
---|
933 | * is bigger or equal to boundary, then this function returns always non-zero.
|
---|
934 | */
|
---|
935 | static inline int snd_pcm_playback_data(struct snd_pcm_substream *substream)
|
---|
936 | {
|
---|
937 | struct snd_pcm_runtime *runtime = substream->runtime;
|
---|
938 |
|
---|
939 | if (runtime->stop_threshold >= runtime->boundary)
|
---|
940 | return 1;
|
---|
941 | return snd_pcm_playback_avail(runtime) < runtime->buffer_size;
|
---|
942 | }
|
---|
943 |
|
---|
944 | /**
|
---|
945 | * snd_pcm_playback_empty - check whether the playback buffer is empty
|
---|
946 | * @substream: the pcm substream instance
|
---|
947 | *
|
---|
948 | * Checks whether the playback buffer is empty.
|
---|
949 | *
|
---|
950 | * Return: Non-zero if empty, or zero if not.
|
---|
951 | */
|
---|
952 | static inline int snd_pcm_playback_empty(struct snd_pcm_substream *substream)
|
---|
953 | {
|
---|
954 | struct snd_pcm_runtime *runtime = substream->runtime;
|
---|
955 | return snd_pcm_playback_avail(runtime) >= runtime->buffer_size;
|
---|
956 | }
|
---|
957 |
|
---|
958 | /**
|
---|
959 | * snd_pcm_capture_empty - check whether the capture buffer is empty
|
---|
960 | * @substream: the pcm substream instance
|
---|
961 | *
|
---|
962 | * Checks whether the capture buffer is empty.
|
---|
963 | *
|
---|
964 | * Return: Non-zero if empty, or zero if not.
|
---|
965 | */
|
---|
966 | static inline int snd_pcm_capture_empty(struct snd_pcm_substream *substream)
|
---|
967 | {
|
---|
968 | struct snd_pcm_runtime *runtime = substream->runtime;
|
---|
969 | return snd_pcm_capture_avail(runtime) == 0;
|
---|
970 | }
|
---|
971 |
|
---|
972 | /**
|
---|
973 | * snd_pcm_trigger_done - Mark the master substream
|
---|
974 | * @substream: the pcm substream instance
|
---|
975 | * @master: the linked master substream
|
---|
976 | *
|
---|
977 | * When multiple substreams of the same card are linked and the hardware
|
---|
978 | * supports the single-shot operation, the driver calls this in the loop
|
---|
979 | * in snd_pcm_group_for_each_entry() for marking the substream as "done".
|
---|
980 | * Then most of trigger operations are performed only to the given master
|
---|
981 | * substream.
|
---|
982 | *
|
---|
983 | * The trigger_master mark is cleared at timestamp updates at the end
|
---|
984 | * of trigger operations.
|
---|
985 | */
|
---|
986 | static inline void snd_pcm_trigger_done(struct snd_pcm_substream *substream,
|
---|
987 | struct snd_pcm_substream *master)
|
---|
988 | {
|
---|
989 | substream->runtime->trigger_master = master;
|
---|
990 | }
|
---|
991 |
|
---|
992 | static inline int hw_is_mask(int var)
|
---|
993 | {
|
---|
994 | return var >= SNDRV_PCM_HW_PARAM_FIRST_MASK &&
|
---|
995 | var <= SNDRV_PCM_HW_PARAM_LAST_MASK;
|
---|
996 | }
|
---|
997 |
|
---|
998 | static inline int hw_is_interval(int var)
|
---|
999 | {
|
---|
1000 | return var >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL &&
|
---|
1001 | var <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL;
|
---|
1002 | }
|
---|
1003 |
|
---|
1004 | static inline struct snd_mask *hw_param_mask(struct snd_pcm_hw_params *params,
|
---|
1005 | snd_pcm_hw_param_t var)
|
---|
1006 | {
|
---|
1007 | return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK];
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | static inline struct snd_interval *hw_param_interval(struct snd_pcm_hw_params *params,
|
---|
1011 | snd_pcm_hw_param_t var)
|
---|
1012 | {
|
---|
1013 | return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 | static inline const struct snd_mask *hw_param_mask_c(const struct snd_pcm_hw_params *params,
|
---|
1017 | snd_pcm_hw_param_t var)
|
---|
1018 | {
|
---|
1019 | return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK];
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 | static inline const struct snd_interval *hw_param_interval_c(const struct snd_pcm_hw_params *params,
|
---|
1023 | snd_pcm_hw_param_t var)
|
---|
1024 | {
|
---|
1025 | return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 | /**
|
---|
1029 | * params_channels - Get the number of channels from the hw params
|
---|
1030 | * @p: hw params
|
---|
1031 | *
|
---|
1032 | * Return: the number of channels
|
---|
1033 | */
|
---|
1034 | static inline unsigned int params_channels(const struct snd_pcm_hw_params *p)
|
---|
1035 | {
|
---|
1036 | return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_CHANNELS)->min;
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 | /**
|
---|
1040 | * params_rate - Get the sample rate from the hw params
|
---|
1041 | * @p: hw params
|
---|
1042 | *
|
---|
1043 | * Return: the sample rate
|
---|
1044 | */
|
---|
1045 | static inline unsigned int params_rate(const struct snd_pcm_hw_params *p)
|
---|
1046 | {
|
---|
1047 | return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_RATE)->min;
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 | /**
|
---|
1051 | * params_period_size - Get the period size (in frames) from the hw params
|
---|
1052 | * @p: hw params
|
---|
1053 | *
|
---|
1054 | * Return: the period size in frames
|
---|
1055 | */
|
---|
1056 | static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p)
|
---|
1057 | {
|
---|
1058 | return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min;
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | /**
|
---|
1062 | * params_periods - Get the number of periods from the hw params
|
---|
1063 | * @p: hw params
|
---|
1064 | *
|
---|
1065 | * Return: the number of periods
|
---|
1066 | */
|
---|
1067 | static inline unsigned int params_periods(const struct snd_pcm_hw_params *p)
|
---|
1068 | {
|
---|
1069 | return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIODS)->min;
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | /**
|
---|
1073 | * params_buffer_size - Get the buffer size (in frames) from the hw params
|
---|
1074 | * @p: hw params
|
---|
1075 | *
|
---|
1076 | * Return: the buffer size in frames
|
---|
1077 | */
|
---|
1078 | static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p)
|
---|
1079 | {
|
---|
1080 | return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min;
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 | /**
|
---|
1084 | * params_buffer_bytes - Get the buffer size (in bytes) from the hw params
|
---|
1085 | * @p: hw params
|
---|
1086 | *
|
---|
1087 | * Return: the buffer size in bytes
|
---|
1088 | */
|
---|
1089 | static inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p)
|
---|
1090 | {
|
---|
1091 | return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min;
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 | int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v);
|
---|
1095 | int snd_interval_list(struct snd_interval *i, unsigned int count,
|
---|
1096 | const unsigned int *list, unsigned int mask);
|
---|
1097 | int snd_interval_ranges(struct snd_interval *i, unsigned int count,
|
---|
1098 | const struct snd_interval *list, unsigned int mask);
|
---|
1099 | int snd_interval_ratnum(struct snd_interval *i,
|
---|
1100 | unsigned int rats_count, const struct snd_ratnum *rats,
|
---|
1101 | unsigned int *nump, unsigned int *denp);
|
---|
1102 |
|
---|
1103 | void _snd_pcm_hw_params_any(struct snd_pcm_hw_params *params);
|
---|
1104 | void _snd_pcm_hw_param_setempty(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var);
|
---|
1105 |
|
---|
1106 | int snd_pcm_hw_refine(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params);
|
---|
1107 |
|
---|
1108 | int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
|
---|
1109 | u_int64_t mask);
|
---|
1110 | int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
|
---|
1111 | unsigned int min, unsigned int max);
|
---|
1112 | int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var);
|
---|
1113 | int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime,
|
---|
1114 | unsigned int cond,
|
---|
1115 | snd_pcm_hw_param_t var,
|
---|
1116 | const struct snd_pcm_hw_constraint_list *l);
|
---|
1117 | int snd_pcm_hw_constraint_ranges(struct snd_pcm_runtime *runtime,
|
---|
1118 | unsigned int cond,
|
---|
1119 | snd_pcm_hw_param_t var,
|
---|
1120 | const struct snd_pcm_hw_constraint_ranges *r);
|
---|
1121 | int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime,
|
---|
1122 | unsigned int cond,
|
---|
1123 | snd_pcm_hw_param_t var,
|
---|
1124 | const struct snd_pcm_hw_constraint_ratnums *r);
|
---|
1125 | int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime,
|
---|
1126 | unsigned int cond,
|
---|
1127 | snd_pcm_hw_param_t var,
|
---|
1128 | const struct snd_pcm_hw_constraint_ratdens *r);
|
---|
1129 | int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime,
|
---|
1130 | unsigned int cond,
|
---|
1131 | unsigned int width,
|
---|
1132 | unsigned int msbits);
|
---|
1133 | int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime,
|
---|
1134 | unsigned int cond,
|
---|
1135 | snd_pcm_hw_param_t var,
|
---|
1136 | unsigned long step);
|
---|
1137 | int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime,
|
---|
1138 | unsigned int cond,
|
---|
1139 | snd_pcm_hw_param_t var);
|
---|
1140 | int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime,
|
---|
1141 | unsigned int base_rate);
|
---|
1142 | int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime,
|
---|
1143 | unsigned int cond,
|
---|
1144 | int var,
|
---|
1145 | snd_pcm_hw_rule_func_t func, void *private,
|
---|
1146 | int dep, ...);
|
---|
1147 |
|
---|
1148 | /**
|
---|
1149 | * snd_pcm_hw_constraint_single() - Constrain parameter to a single value
|
---|
1150 | * @runtime: PCM runtime instance
|
---|
1151 | * @var: The hw_params variable to constrain
|
---|
1152 | * @val: The value to constrain to
|
---|
1153 | *
|
---|
1154 | * Return: Positive if the value is changed, zero if it's not changed, or a
|
---|
1155 | * negative error code.
|
---|
1156 | */
|
---|
1157 | static inline int snd_pcm_hw_constraint_single(
|
---|
1158 | struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
|
---|
1159 | unsigned int val)
|
---|
1160 | {
|
---|
1161 | return snd_pcm_hw_constraint_minmax(runtime, var, val, val);
|
---|
1162 | }
|
---|
1163 |
|
---|
1164 | int snd_pcm_format_signed(snd_pcm_format_t format);
|
---|
1165 | int snd_pcm_format_unsigned(snd_pcm_format_t format);
|
---|
1166 | int snd_pcm_format_linear(snd_pcm_format_t format);
|
---|
1167 | int snd_pcm_format_little_endian(snd_pcm_format_t format);
|
---|
1168 | int snd_pcm_format_big_endian(snd_pcm_format_t format);
|
---|
1169 | #if 0 /* just for kernel-doc */
|
---|
1170 | /**
|
---|
1171 | * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian
|
---|
1172 | * @format: the format to check
|
---|
1173 | *
|
---|
1174 | * Return: 1 if the given PCM format is CPU-endian, 0 if
|
---|
1175 | * opposite, or a negative error code if endian not specified.
|
---|
1176 | */
|
---|
1177 | int snd_pcm_format_cpu_endian(snd_pcm_format_t format);
|
---|
1178 | #endif /* DocBook */
|
---|
1179 | #ifdef SNDRV_LITTLE_ENDIAN
|
---|
1180 | #define snd_pcm_format_cpu_endian(format) snd_pcm_format_little_endian(format)
|
---|
1181 | #else
|
---|
1182 | #define snd_pcm_format_cpu_endian(format) snd_pcm_format_big_endian(format)
|
---|
1183 | #endif
|
---|
1184 | int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */
|
---|
1185 | int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */
|
---|
1186 | ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
|
---|
1187 | const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format);
|
---|
1188 | int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames);
|
---|
1189 |
|
---|
1190 | void snd_pcm_set_ops(struct snd_pcm * pcm, int direction,
|
---|
1191 | const struct snd_pcm_ops *ops);
|
---|
1192 | void snd_pcm_set_sync_per_card(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params,
|
---|
1193 | const unsigned char *id, unsigned int len);
|
---|
1194 | /**
|
---|
1195 | * snd_pcm_set_sync - set the PCM sync id
|
---|
1196 | * @substream: the pcm substream
|
---|
1197 | *
|
---|
1198 | * Use the default PCM sync identifier for the specific card.
|
---|
1199 | */
|
---|
1200 | static inline void snd_pcm_set_sync(struct snd_pcm_substream *substream)
|
---|
1201 | {
|
---|
1202 | substream->runtime->std_sync_id = true;
|
---|
1203 | }
|
---|
1204 | int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream,
|
---|
1205 | unsigned int cmd, void *arg);
|
---|
1206 | void snd_pcm_period_elapsed_under_stream_lock(struct snd_pcm_substream *substream);
|
---|
1207 | void snd_pcm_period_elapsed(struct snd_pcm_substream *substream);
|
---|
1208 | snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream,
|
---|
1209 | void *buf, bool interleaved,
|
---|
1210 | snd_pcm_uframes_t frames, bool in_kernel);
|
---|
1211 |
|
---|
1212 | static inline snd_pcm_sframes_t
|
---|
1213 | snd_pcm_lib_write(struct snd_pcm_substream *substream,
|
---|
1214 | const void __user *buf, snd_pcm_uframes_t frames)
|
---|
1215 | {
|
---|
1216 | return __snd_pcm_lib_xfer(substream, (void __force *)buf, true, frames, false);
|
---|
1217 | }
|
---|
1218 |
|
---|
1219 | static inline snd_pcm_sframes_t
|
---|
1220 | snd_pcm_lib_read(struct snd_pcm_substream *substream,
|
---|
1221 | void __user *buf, snd_pcm_uframes_t frames)
|
---|
1222 | {
|
---|
1223 | return __snd_pcm_lib_xfer(substream, (void __force *)buf, true, frames, false);
|
---|
1224 | }
|
---|
1225 |
|
---|
1226 | static inline snd_pcm_sframes_t
|
---|
1227 | snd_pcm_lib_writev(struct snd_pcm_substream *substream,
|
---|
1228 | void __user **bufs, snd_pcm_uframes_t frames)
|
---|
1229 | {
|
---|
1230 | return __snd_pcm_lib_xfer(substream, (void *)bufs, false, frames, false);
|
---|
1231 | }
|
---|
1232 |
|
---|
1233 | static inline snd_pcm_sframes_t
|
---|
1234 | snd_pcm_lib_readv(struct snd_pcm_substream *substream,
|
---|
1235 | void __user **bufs, snd_pcm_uframes_t frames)
|
---|
1236 | {
|
---|
1237 | return __snd_pcm_lib_xfer(substream, (void *)bufs, false, frames, false);
|
---|
1238 | }
|
---|
1239 |
|
---|
1240 | static inline snd_pcm_sframes_t
|
---|
1241 | snd_pcm_kernel_write(struct snd_pcm_substream *substream,
|
---|
1242 | const void *buf, snd_pcm_uframes_t frames)
|
---|
1243 | {
|
---|
1244 | return __snd_pcm_lib_xfer(substream, (void *)buf, true, frames, true);
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 | static inline snd_pcm_sframes_t
|
---|
1248 | snd_pcm_kernel_read(struct snd_pcm_substream *substream,
|
---|
1249 | void *buf, snd_pcm_uframes_t frames)
|
---|
1250 | {
|
---|
1251 | return __snd_pcm_lib_xfer(substream, buf, true, frames, true);
|
---|
1252 | }
|
---|
1253 |
|
---|
1254 | static inline snd_pcm_sframes_t
|
---|
1255 | snd_pcm_kernel_writev(struct snd_pcm_substream *substream,
|
---|
1256 | void **bufs, snd_pcm_uframes_t frames)
|
---|
1257 | {
|
---|
1258 | return __snd_pcm_lib_xfer(substream, bufs, false, frames, true);
|
---|
1259 | }
|
---|
1260 |
|
---|
1261 | static inline snd_pcm_sframes_t
|
---|
1262 | snd_pcm_kernel_readv(struct snd_pcm_substream *substream,
|
---|
1263 | void **bufs, snd_pcm_uframes_t frames)
|
---|
1264 | {
|
---|
1265 | return __snd_pcm_lib_xfer(substream, bufs, false, frames, true);
|
---|
1266 | }
|
---|
1267 |
|
---|
1268 | int snd_pcm_hw_limit_rates(struct snd_pcm_hardware *hw);
|
---|
1269 |
|
---|
1270 | static inline int
|
---|
1271 | snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime)
|
---|
1272 | {
|
---|
1273 | return snd_pcm_hw_limit_rates(&runtime->hw);
|
---|
1274 | }
|
---|
1275 |
|
---|
1276 | unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate);
|
---|
1277 | unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit);
|
---|
1278 | unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
|
---|
1279 | unsigned int rates_b);
|
---|
1280 | unsigned int snd_pcm_rate_range_to_bits(unsigned int rate_min,
|
---|
1281 | unsigned int rate_max);
|
---|
1282 |
|
---|
1283 | /**
|
---|
1284 | * snd_pcm_set_runtime_buffer - Set the PCM runtime buffer
|
---|
1285 | * @substream: PCM substream to set
|
---|
1286 | * @bufp: the buffer information, NULL to clear
|
---|
1287 | *
|
---|
1288 | * Copy the buffer information to runtime->dma_buffer when @bufp is non-NULL.
|
---|
1289 | * Otherwise it clears the current buffer information.
|
---|
1290 | */
|
---|
1291 | static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream,
|
---|
1292 | struct snd_dma_buffer *bufp)
|
---|
1293 | {
|
---|
1294 | struct snd_pcm_runtime *runtime = substream->runtime;
|
---|
1295 | if (bufp) {
|
---|
1296 | runtime->dma_buffer_p = bufp;
|
---|
1297 | runtime->dma_area = bufp->area;
|
---|
1298 | runtime->dma_addr = bufp->addr;
|
---|
1299 | runtime->dma_bytes = bufp->bytes;
|
---|
1300 | } else {
|
---|
1301 | runtime->dma_buffer_p = NULL;
|
---|
1302 | runtime->dma_area = NULL;
|
---|
1303 | runtime->dma_addr = 0;
|
---|
1304 | runtime->dma_bytes = 0;
|
---|
1305 | }
|
---|
1306 | }
|
---|
1307 |
|
---|
1308 | /**
|
---|
1309 | * snd_pcm_gettime - Fill the timespec64 depending on the timestamp mode
|
---|
1310 | * @runtime: PCM runtime instance
|
---|
1311 | * @tv: timespec64 to fill
|
---|
1312 | */
|
---|
1313 | static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime,
|
---|
1314 | struct timespec64 *tv)
|
---|
1315 | {
|
---|
1316 | switch (runtime->tstamp_type) {
|
---|
1317 | case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC:
|
---|
1318 | ktime_get_ts64(tv);
|
---|
1319 | break;
|
---|
1320 | case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW:
|
---|
1321 | ktime_get_raw_ts64(tv);
|
---|
1322 | break;
|
---|
1323 | default:
|
---|
1324 | ktime_get_real_ts64(tv);
|
---|
1325 | break;
|
---|
1326 | }
|
---|
1327 | }
|
---|
1328 |
|
---|
1329 | /*
|
---|
1330 | * Memory
|
---|
1331 | */
|
---|
1332 |
|
---|
1333 | void snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream);
|
---|
1334 | void snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm);
|
---|
1335 | void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
|
---|
1336 | int type, struct device *data,
|
---|
1337 | size_t size, size_t max);
|
---|
1338 | void snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm,
|
---|
1339 | int type, void *data,
|
---|
1340 | size_t size, size_t max);
|
---|
1341 | int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size);
|
---|
1342 | int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream);
|
---|
1343 |
|
---|
1344 | int snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type,
|
---|
1345 | struct device *data, size_t size, size_t max);
|
---|
1346 | int snd_pcm_set_managed_buffer_all(struct snd_pcm *pcm, int type,
|
---|
1347 | struct device *data,
|
---|
1348 | size_t size, size_t max);
|
---|
1349 |
|
---|
1350 | /**
|
---|
1351 | * snd_pcm_set_fixed_buffer - Preallocate and set up the fixed size PCM buffer
|
---|
1352 | * @substream: the pcm substream instance
|
---|
1353 | * @type: DMA type (SNDRV_DMA_TYPE_*)
|
---|
1354 | * @data: DMA type dependent data
|
---|
1355 | * @size: the requested pre-allocation size in bytes
|
---|
1356 | *
|
---|
1357 | * This is a variant of snd_pcm_set_managed_buffer(), but this pre-allocates
|
---|
1358 | * only the given sized buffer and doesn't allow re-allocation nor dynamic
|
---|
1359 | * allocation of a larger buffer unlike the standard one.
|
---|
1360 | * The function may return -ENOMEM error, hence the caller must check it.
|
---|
1361 | *
|
---|
1362 | * Return: zero if successful, or a negative error code
|
---|
1363 | */
|
---|
1364 | static inline int __must_check
|
---|
1365 | snd_pcm_set_fixed_buffer(struct snd_pcm_substream *substream, int type,
|
---|
1366 | struct device *data, size_t size)
|
---|
1367 | {
|
---|
1368 | return snd_pcm_set_managed_buffer(substream, type, data, size, 0);
|
---|
1369 | }
|
---|
1370 |
|
---|
1371 | /**
|
---|
1372 | * snd_pcm_set_fixed_buffer_all - Preallocate and set up the fixed size PCM buffer
|
---|
1373 | * @pcm: the pcm instance
|
---|
1374 | * @type: DMA type (SNDRV_DMA_TYPE_*)
|
---|
1375 | * @data: DMA type dependent data
|
---|
1376 | * @size: the requested pre-allocation size in bytes
|
---|
1377 | *
|
---|
1378 | * Apply the set up of the fixed buffer via snd_pcm_set_fixed_buffer() for
|
---|
1379 | * all substream. If any of allocation fails, it returns -ENOMEM, hence the
|
---|
1380 | * caller must check the return value.
|
---|
1381 | *
|
---|
1382 | * Return: zero if successful, or a negative error code
|
---|
1383 | */
|
---|
1384 | static inline int __must_check
|
---|
1385 | snd_pcm_set_fixed_buffer_all(struct snd_pcm *pcm, int type,
|
---|
1386 | struct device *data, size_t size)
|
---|
1387 | {
|
---|
1388 | return snd_pcm_set_managed_buffer_all(pcm, type, data, size, 0);
|
---|
1389 | }
|
---|
1390 |
|
---|
1391 | #define snd_pcm_get_dma_buf(substream) ((substream)->runtime->dma_buffer_p)
|
---|
1392 |
|
---|
1393 | /**
|
---|
1394 | * snd_pcm_sgbuf_get_addr - Get the DMA address at the corresponding offset
|
---|
1395 | * @substream: PCM substream
|
---|
1396 | * @ofs: byte offset
|
---|
1397 | *
|
---|
1398 | * Return: DMA address
|
---|
1399 | */
|
---|
1400 | static inline dma_addr_t
|
---|
1401 | snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs)
|
---|
1402 | {
|
---|
1403 | return snd_sgbuf_get_addr(snd_pcm_get_dma_buf(substream), ofs);
|
---|
1404 | }
|
---|
1405 |
|
---|
1406 | /**
|
---|
1407 | * snd_pcm_sgbuf_get_chunk_size - Compute the max size that fits within the
|
---|
1408 | * contig. page from the given size
|
---|
1409 | * @substream: PCM substream
|
---|
1410 | * @ofs: byte offset
|
---|
1411 | * @size: byte size to examine
|
---|
1412 | *
|
---|
1413 | * Return: chunk size
|
---|
1414 | */
|
---|
1415 | static inline unsigned int
|
---|
1416 | snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream,
|
---|
1417 | unsigned int ofs, unsigned int size)
|
---|
1418 | {
|
---|
1419 | return snd_sgbuf_get_chunk_size(snd_pcm_get_dma_buf(substream), ofs, size);
|
---|
1420 | }
|
---|
1421 |
|
---|
1422 | /**
|
---|
1423 | * snd_pcm_mmap_data_open - increase the mmap counter
|
---|
1424 | * @area: VMA
|
---|
1425 | *
|
---|
1426 | * PCM mmap callback should handle this counter properly
|
---|
1427 | */
|
---|
1428 | static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area)
|
---|
1429 | {
|
---|
1430 | struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data;
|
---|
1431 | atomic_inc(&substream->mmap_count);
|
---|
1432 | }
|
---|
1433 |
|
---|
1434 | /**
|
---|
1435 | * snd_pcm_mmap_data_close - decrease the mmap counter
|
---|
1436 | * @area: VMA
|
---|
1437 | *
|
---|
1438 | * PCM mmap callback should handle this counter properly
|
---|
1439 | */
|
---|
1440 | static inline void snd_pcm_mmap_data_close(struct vm_area_struct *area)
|
---|
1441 | {
|
---|
1442 | struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data;
|
---|
1443 | atomic_dec(&substream->mmap_count);
|
---|
1444 | }
|
---|
1445 |
|
---|
1446 | int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream,
|
---|
1447 | struct vm_area_struct *area);
|
---|
1448 | /* mmap for io-memory area */
|
---|
1449 | #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA)
|
---|
1450 | #define SNDRV_PCM_INFO_MMAP_IOMEM SNDRV_PCM_INFO_MMAP
|
---|
1451 | int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_struct *area);
|
---|
1452 | #else
|
---|
1453 | #define SNDRV_PCM_INFO_MMAP_IOMEM 0
|
---|
1454 | #define snd_pcm_lib_mmap_iomem NULL
|
---|
1455 | #endif
|
---|
1456 |
|
---|
1457 | /**
|
---|
1458 | * snd_pcm_limit_isa_dma_size - Get the max size fitting with ISA DMA transfer
|
---|
1459 | * @dma: DMA number
|
---|
1460 | * @max: pointer to store the max size
|
---|
1461 | */
|
---|
1462 | static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max)
|
---|
1463 | {
|
---|
1464 | *max = dma < 4 ? 64 * 1024 : 128 * 1024;
|
---|
1465 | }
|
---|
1466 |
|
---|
1467 | /*
|
---|
1468 | * Misc
|
---|
1469 | */
|
---|
1470 |
|
---|
1471 | #define SNDRV_PCM_DEFAULT_CON_SPDIF (IEC958_AES0_CON_EMPHASIS_NONE|\
|
---|
1472 | (IEC958_AES1_CON_ORIGINAL<<8)|\
|
---|
1473 | (IEC958_AES1_CON_PCM_CODER<<8)|\
|
---|
1474 | (IEC958_AES3_CON_FS_48000<<24))
|
---|
1475 |
|
---|
1476 | const char *snd_pcm_format_name(snd_pcm_format_t format);
|
---|
1477 |
|
---|
1478 | /**
|
---|
1479 | * snd_pcm_direction_name - Get a string naming the direction of a stream
|
---|
1480 | * @direction: Stream's direction, one of SNDRV_PCM_STREAM_XXX
|
---|
1481 | *
|
---|
1482 | * Returns a string naming the direction of the stream.
|
---|
1483 | */
|
---|
1484 | static inline const char *snd_pcm_direction_name(int direction)
|
---|
1485 | {
|
---|
1486 | if (direction == SNDRV_PCM_STREAM_PLAYBACK)
|
---|
1487 | return "Playback";
|
---|
1488 | else
|
---|
1489 | return "Capture";
|
---|
1490 | }
|
---|
1491 |
|
---|
1492 | /**
|
---|
1493 | * snd_pcm_stream_str - Get a string naming the direction of a stream
|
---|
1494 | * @substream: the pcm substream instance
|
---|
1495 | *
|
---|
1496 | * Return: A string naming the direction of the stream.
|
---|
1497 | */
|
---|
1498 | static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream)
|
---|
1499 | {
|
---|
1500 | return snd_pcm_direction_name(substream->stream);
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | /*
|
---|
1504 | * PCM channel-mapping control API
|
---|
1505 | */
|
---|
1506 | /* array element of channel maps */
|
---|
1507 | struct snd_pcm_chmap_elem {
|
---|
1508 | unsigned char channels;
|
---|
1509 | unsigned char map[15];
|
---|
1510 | };
|
---|
1511 |
|
---|
1512 | /* channel map information; retrieved via snd_kcontrol_chip() */
|
---|
1513 | struct snd_pcm_chmap {
|
---|
1514 | struct snd_pcm *pcm; /* assigned PCM instance */
|
---|
1515 | int stream; /* PLAYBACK or CAPTURE */
|
---|
1516 | struct snd_kcontrol *kctl;
|
---|
1517 | const struct snd_pcm_chmap_elem *chmap;
|
---|
1518 | unsigned int max_channels;
|
---|
1519 | unsigned int channel_mask; /* optional: active channels bitmask */
|
---|
1520 | void *private_data; /* optional: private data pointer */
|
---|
1521 | };
|
---|
1522 |
|
---|
1523 | /**
|
---|
1524 | * snd_pcm_chmap_substream - get the PCM substream assigned to the given chmap info
|
---|
1525 | * @info: chmap information
|
---|
1526 | * @idx: the substream number index
|
---|
1527 | *
|
---|
1528 | * Return: the matched PCM substream, or NULL if not found
|
---|
1529 | */
|
---|
1530 | static inline struct snd_pcm_substream *
|
---|
1531 | snd_pcm_chmap_substream(struct snd_pcm_chmap *info, unsigned int idx)
|
---|
1532 | {
|
---|
1533 | struct snd_pcm_substream *s;
|
---|
1534 | for (s = info->pcm->streams[info->stream].substream; s; s = s->next)
|
---|
1535 | if (s->number == idx)
|
---|
1536 | return s;
|
---|
1537 | return NULL;
|
---|
1538 | }
|
---|
1539 |
|
---|
1540 | /* ALSA-standard channel maps (RL/RR prior to C/LFE) */
|
---|
1541 | extern const struct snd_pcm_chmap_elem snd_pcm_std_chmaps[];
|
---|
1542 | /* Other world's standard channel maps (C/LFE prior to RL/RR) */
|
---|
1543 | extern const struct snd_pcm_chmap_elem snd_pcm_alt_chmaps[];
|
---|
1544 |
|
---|
1545 | /* bit masks to be passed to snd_pcm_chmap.channel_mask field */
|
---|
1546 | #define SND_PCM_CHMAP_MASK_24 ((1U << 2) | (1U << 4))
|
---|
1547 | #define SND_PCM_CHMAP_MASK_246 (SND_PCM_CHMAP_MASK_24 | (1U << 6))
|
---|
1548 | #define SND_PCM_CHMAP_MASK_2468 (SND_PCM_CHMAP_MASK_246 | (1U << 8))
|
---|
1549 |
|
---|
1550 | int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream,
|
---|
1551 | const struct snd_pcm_chmap_elem *chmap,
|
---|
1552 | int max_channels,
|
---|
1553 | unsigned long private_value,
|
---|
1554 | struct snd_pcm_chmap **info_ret);
|
---|
1555 |
|
---|
1556 | /**
|
---|
1557 | * pcm_format_to_bits - Strong-typed conversion of pcm_format to bitwise
|
---|
1558 | * @pcm_format: PCM format
|
---|
1559 | *
|
---|
1560 | * Return: 64bit mask corresponding to the given PCM format
|
---|
1561 | */
|
---|
1562 | static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
|
---|
1563 | {
|
---|
1564 | return 1ULL << (__force int) pcm_format;
|
---|
1565 | }
|
---|
1566 |
|
---|
1567 | /**
|
---|
1568 | * pcm_for_each_format - helper to iterate for each format type
|
---|
1569 | * @f: the iterator variable in snd_pcm_format_t type
|
---|
1570 | */
|
---|
1571 | #define pcm_for_each_format(f) \
|
---|
1572 | for ((f) = SNDRV_PCM_FORMAT_FIRST; \
|
---|
1573 | (__force int)(f) <= (__force int)SNDRV_PCM_FORMAT_LAST; \
|
---|
1574 | (f) = (__force snd_pcm_format_t)((__force int)(f) + 1))
|
---|
1575 |
|
---|
1576 | /* printk helpers */
|
---|
1577 | #ifndef TARGET_OS2
|
---|
1578 | #define pcm_err(pcm, fmt, args...) \
|
---|
1579 | dev_err((pcm)->card->dev, fmt, ##args)
|
---|
1580 | #define pcm_warn(pcm, fmt, args...) \
|
---|
1581 | dev_warn((pcm)->card->dev, fmt, ##args)
|
---|
1582 | #define pcm_dbg(pcm, fmt, args...) \
|
---|
1583 | dev_dbg((pcm)->card->dev, fmt, ##args)
|
---|
1584 | #else
|
---|
1585 | #define pcm_err pcm_dbg
|
---|
1586 | #define pcm_warn pcm_dbg
|
---|
1587 | int pcm_dbg(struct snd_pcm *dev, const char *fmt, ...);
|
---|
1588 | #endif
|
---|
1589 |
|
---|
1590 | /* helpers for copying between iov_iter and iomem */
|
---|
1591 | int copy_to_iter_fromio(struct iov_iter *itert, const void __iomem *src,
|
---|
1592 | size_t count);
|
---|
1593 | int copy_from_iter_toio(void __iomem *dst, struct iov_iter *iter, size_t count);
|
---|
1594 |
|
---|
1595 | struct snd_pcm_status64 {
|
---|
1596 | snd_pcm_state_t state; /* stream state */
|
---|
1597 | u8 rsvd[4];
|
---|
1598 | s64 trigger_tstamp_sec; /* time when stream was started/stopped/paused */
|
---|
1599 | s64 trigger_tstamp_nsec;
|
---|
1600 | s64 tstamp_sec; /* reference timestamp */
|
---|
1601 | s64 tstamp_nsec;
|
---|
1602 | snd_pcm_uframes_t appl_ptr; /* appl ptr */
|
---|
1603 | snd_pcm_uframes_t hw_ptr; /* hw ptr */
|
---|
1604 | snd_pcm_sframes_t delay; /* current delay in frames */
|
---|
1605 | snd_pcm_uframes_t avail; /* number of frames available */
|
---|
1606 | snd_pcm_uframes_t avail_max; /* max frames available on hw since last status */
|
---|
1607 | snd_pcm_uframes_t overrange; /* count of ADC (capture) overrange detections from last status */
|
---|
1608 | snd_pcm_state_t suspended_state; /* suspended stream state */
|
---|
1609 | __u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */
|
---|
1610 | s64 audio_tstamp_sec; /* sample counter, wall clock, PHC or on-demand sync'ed */
|
---|
1611 | s64 audio_tstamp_nsec;
|
---|
1612 | s64 driver_tstamp_sec; /* useful in case reference system tstamp is reported with delay */
|
---|
1613 | s64 driver_tstamp_nsec;
|
---|
1614 | __u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */
|
---|
1615 | unsigned char reserved[52-4*sizeof(s64)]; /* must be filled with zero */
|
---|
1616 | };
|
---|
1617 |
|
---|
1618 | #define SNDRV_PCM_IOCTL_STATUS64 _IOR('A', 0x20, struct snd_pcm_status64)
|
---|
1619 | #define SNDRV_PCM_IOCTL_STATUS_EXT64 _IOWR('A', 0x24, struct snd_pcm_status64)
|
---|
1620 |
|
---|
1621 | struct snd_pcm_status32 {
|
---|
1622 | snd_pcm_state_t state; /* stream state */
|
---|
1623 | s32 trigger_tstamp_sec; /* time when stream was started/stopped/paused */
|
---|
1624 | s32 trigger_tstamp_nsec;
|
---|
1625 | s32 tstamp_sec; /* reference timestamp */
|
---|
1626 | s32 tstamp_nsec;
|
---|
1627 | u32 appl_ptr; /* appl ptr */
|
---|
1628 | u32 hw_ptr; /* hw ptr */
|
---|
1629 | s32 delay; /* current delay in frames */
|
---|
1630 | u32 avail; /* number of frames available */
|
---|
1631 | u32 avail_max; /* max frames available on hw since last status */
|
---|
1632 | u32 overrange; /* count of ADC (capture) overrange detections from last status */
|
---|
1633 | snd_pcm_state_t suspended_state; /* suspended stream state */
|
---|
1634 | u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */
|
---|
1635 | s32 audio_tstamp_sec; /* sample counter, wall clock, PHC or on-demand sync'ed */
|
---|
1636 | s32 audio_tstamp_nsec;
|
---|
1637 | s32 driver_tstamp_sec; /* useful in case reference system tstamp is reported with delay */
|
---|
1638 | s32 driver_tstamp_nsec;
|
---|
1639 | u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */
|
---|
1640 | unsigned char reserved[52-4*sizeof(s32)]; /* must be filled with zero */
|
---|
1641 | };
|
---|
1642 |
|
---|
1643 | #define SNDRV_PCM_IOCTL_STATUS32 _IOR('A', 0x20, struct snd_pcm_status32)
|
---|
1644 | #define SNDRV_PCM_IOCTL_STATUS_EXT32 _IOWR('A', 0x24, struct snd_pcm_status32)
|
---|
1645 |
|
---|
1646 | #endif /* __SOUND_PCM_H */
|
---|