.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | | - * This program is free software; you can redistribute it and/or modify |
---|
3 | | - * it under the terms of the GNU General Public License as published by |
---|
4 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
5 | | - * (at your option) any later version. |
---|
6 | | - * |
---|
7 | | - * This program is distributed in the hope that it will be useful, |
---|
8 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | | - * GNU General Public License for more details. |
---|
11 | | - * |
---|
12 | | - * You should have received a copy of the GNU General Public License |
---|
13 | | - * along with this program; if not, write to the Free Software |
---|
14 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
15 | 3 | */ |
---|
16 | 4 | |
---|
17 | 5 | /* USX2Y "rawusb" aka hwdep_pcm implementation |
---|
.. | .. |
---|
59 | 47 | #include <sound/hwdep.h> |
---|
60 | 48 | |
---|
61 | 49 | |
---|
62 | | -static int usX2Y_usbpcm_urb_capt_retire(struct snd_usX2Y_substream *subs) |
---|
| 50 | +static int usx2y_usbpcm_urb_capt_retire(struct snd_usx2y_substream *subs) |
---|
63 | 51 | { |
---|
64 | 52 | struct urb *urb = subs->completed_urb; |
---|
65 | 53 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
---|
66 | 54 | int i, lens = 0, hwptr_done = subs->hwptr_done; |
---|
67 | | - struct usX2Ydev *usX2Y = subs->usX2Y; |
---|
68 | | - if (0 > usX2Y->hwdep_pcm_shm->capture_iso_start) { //FIXME |
---|
69 | | - int head = usX2Y->hwdep_pcm_shm->captured_iso_head + 1; |
---|
70 | | - if (head >= ARRAY_SIZE(usX2Y->hwdep_pcm_shm->captured_iso)) |
---|
| 55 | + struct usx2ydev *usx2y = subs->usx2y; |
---|
| 56 | + if (0 > usx2y->hwdep_pcm_shm->capture_iso_start) { //FIXME |
---|
| 57 | + int head = usx2y->hwdep_pcm_shm->captured_iso_head + 1; |
---|
| 58 | + if (head >= ARRAY_SIZE(usx2y->hwdep_pcm_shm->captured_iso)) |
---|
71 | 59 | head = 0; |
---|
72 | | - usX2Y->hwdep_pcm_shm->capture_iso_start = head; |
---|
| 60 | + usx2y->hwdep_pcm_shm->capture_iso_start = head; |
---|
73 | 61 | snd_printdd("cap start %i\n", head); |
---|
74 | 62 | } |
---|
75 | 63 | for (i = 0; i < nr_of_packs(); i++) { |
---|
.. | .. |
---|
77 | 65 | snd_printk(KERN_ERR "active frame status %i. Most probably some hardware problem.\n", urb->iso_frame_desc[i].status); |
---|
78 | 66 | return urb->iso_frame_desc[i].status; |
---|
79 | 67 | } |
---|
80 | | - lens += urb->iso_frame_desc[i].actual_length / usX2Y->stride; |
---|
| 68 | + lens += urb->iso_frame_desc[i].actual_length / usx2y->stride; |
---|
81 | 69 | } |
---|
82 | 70 | if ((hwptr_done += lens) >= runtime->buffer_size) |
---|
83 | 71 | hwptr_done -= runtime->buffer_size; |
---|
.. | .. |
---|
91 | 79 | return 0; |
---|
92 | 80 | } |
---|
93 | 81 | |
---|
94 | | -static inline int usX2Y_iso_frames_per_buffer(struct snd_pcm_runtime *runtime, |
---|
95 | | - struct usX2Ydev * usX2Y) |
---|
| 82 | +static inline int usx2y_iso_frames_per_buffer(struct snd_pcm_runtime *runtime, |
---|
| 83 | + struct usx2ydev * usx2y) |
---|
96 | 84 | { |
---|
97 | | - return (runtime->buffer_size * 1000) / usX2Y->rate + 1; //FIXME: so far only correct period_size == 2^x ? |
---|
| 85 | + return (runtime->buffer_size * 1000) / usx2y->rate + 1; //FIXME: so far only correct period_size == 2^x ? |
---|
98 | 86 | } |
---|
99 | 87 | |
---|
100 | 88 | /* |
---|
.. | .. |
---|
107 | 95 | * it directly from the buffer. thus the data is once copied to |
---|
108 | 96 | * a temporary buffer and urb points to that. |
---|
109 | 97 | */ |
---|
110 | | -static int usX2Y_hwdep_urb_play_prepare(struct snd_usX2Y_substream *subs, |
---|
| 98 | +static int usx2y_hwdep_urb_play_prepare(struct snd_usx2y_substream *subs, |
---|
111 | 99 | struct urb *urb) |
---|
112 | 100 | { |
---|
113 | 101 | int count, counts, pack; |
---|
114 | | - struct usX2Ydev *usX2Y = subs->usX2Y; |
---|
115 | | - struct snd_usX2Y_hwdep_pcm_shm *shm = usX2Y->hwdep_pcm_shm; |
---|
| 102 | + struct usx2ydev *usx2y = subs->usx2y; |
---|
| 103 | + struct snd_usx2y_hwdep_pcm_shm *shm = usx2y->hwdep_pcm_shm; |
---|
116 | 104 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
---|
117 | 105 | |
---|
118 | 106 | if (0 > shm->playback_iso_start) { |
---|
119 | 107 | shm->playback_iso_start = shm->captured_iso_head - |
---|
120 | | - usX2Y_iso_frames_per_buffer(runtime, usX2Y); |
---|
| 108 | + usx2y_iso_frames_per_buffer(runtime, usx2y); |
---|
121 | 109 | if (0 > shm->playback_iso_start) |
---|
122 | 110 | shm->playback_iso_start += ARRAY_SIZE(shm->captured_iso); |
---|
123 | 111 | shm->playback_iso_head = shm->playback_iso_start; |
---|
.. | .. |
---|
126 | 114 | count = 0; |
---|
127 | 115 | for (pack = 0; pack < nr_of_packs(); pack++) { |
---|
128 | 116 | /* calculate the size of a packet */ |
---|
129 | | - counts = shm->captured_iso[shm->playback_iso_head].length / usX2Y->stride; |
---|
| 117 | + counts = shm->captured_iso[shm->playback_iso_head].length / usx2y->stride; |
---|
130 | 118 | if (counts < 43 || counts > 50) { |
---|
131 | 119 | snd_printk(KERN_ERR "should not be here with counts=%i\n", counts); |
---|
132 | 120 | return -EPIPE; |
---|
.. | .. |
---|
134 | 122 | /* set up descriptor */ |
---|
135 | 123 | urb->iso_frame_desc[pack].offset = shm->captured_iso[shm->playback_iso_head].offset; |
---|
136 | 124 | urb->iso_frame_desc[pack].length = shm->captured_iso[shm->playback_iso_head].length; |
---|
137 | | - if (atomic_read(&subs->state) != state_RUNNING) |
---|
| 125 | + if (atomic_read(&subs->state) != STATE_RUNNING) |
---|
138 | 126 | memset((char *)urb->transfer_buffer + urb->iso_frame_desc[pack].offset, 0, |
---|
139 | 127 | urb->iso_frame_desc[pack].length); |
---|
140 | 128 | if (++shm->playback_iso_head >= ARRAY_SIZE(shm->captured_iso)) |
---|
141 | 129 | shm->playback_iso_head = 0; |
---|
142 | 130 | count += counts; |
---|
143 | 131 | } |
---|
144 | | - urb->transfer_buffer_length = count * usX2Y->stride; |
---|
| 132 | + urb->transfer_buffer_length = count * usx2y->stride; |
---|
145 | 133 | return 0; |
---|
146 | 134 | } |
---|
147 | 135 | |
---|
148 | 136 | |
---|
149 | | -static inline void usX2Y_usbpcm_urb_capt_iso_advance(struct snd_usX2Y_substream *subs, |
---|
| 137 | +static inline void usx2y_usbpcm_urb_capt_iso_advance(struct snd_usx2y_substream *subs, |
---|
150 | 138 | struct urb *urb) |
---|
151 | 139 | { |
---|
152 | 140 | int pack; |
---|
153 | 141 | for (pack = 0; pack < nr_of_packs(); ++pack) { |
---|
154 | 142 | struct usb_iso_packet_descriptor *desc = urb->iso_frame_desc + pack; |
---|
155 | 143 | if (NULL != subs) { |
---|
156 | | - struct snd_usX2Y_hwdep_pcm_shm *shm = subs->usX2Y->hwdep_pcm_shm; |
---|
| 144 | + struct snd_usx2y_hwdep_pcm_shm *shm = subs->usx2y->hwdep_pcm_shm; |
---|
157 | 145 | int head = shm->captured_iso_head + 1; |
---|
158 | 146 | if (head >= ARRAY_SIZE(shm->captured_iso)) |
---|
159 | 147 | head = 0; |
---|
.. | .. |
---|
169 | 157 | } |
---|
170 | 158 | } |
---|
171 | 159 | |
---|
172 | | -static inline int usX2Y_usbpcm_usbframe_complete(struct snd_usX2Y_substream *capsubs, |
---|
173 | | - struct snd_usX2Y_substream *capsubs2, |
---|
174 | | - struct snd_usX2Y_substream *playbacksubs, |
---|
| 160 | +static inline int usx2y_usbpcm_usbframe_complete(struct snd_usx2y_substream *capsubs, |
---|
| 161 | + struct snd_usx2y_substream *capsubs2, |
---|
| 162 | + struct snd_usx2y_substream *playbacksubs, |
---|
175 | 163 | int frame) |
---|
176 | 164 | { |
---|
177 | 165 | int err, state; |
---|
.. | .. |
---|
179 | 167 | |
---|
180 | 168 | state = atomic_read(&playbacksubs->state); |
---|
181 | 169 | if (NULL != urb) { |
---|
182 | | - if (state == state_RUNNING) |
---|
183 | | - usX2Y_urb_play_retire(playbacksubs, urb); |
---|
184 | | - else if (state >= state_PRERUNNING) |
---|
| 170 | + if (state == STATE_RUNNING) |
---|
| 171 | + usx2y_urb_play_retire(playbacksubs, urb); |
---|
| 172 | + else if (state >= STATE_PRERUNNING) |
---|
185 | 173 | atomic_inc(&playbacksubs->state); |
---|
186 | 174 | } else { |
---|
187 | 175 | switch (state) { |
---|
188 | | - case state_STARTING1: |
---|
| 176 | + case STATE_STARTING1: |
---|
189 | 177 | urb = playbacksubs->urb[0]; |
---|
190 | 178 | atomic_inc(&playbacksubs->state); |
---|
191 | 179 | break; |
---|
192 | | - case state_STARTING2: |
---|
| 180 | + case STATE_STARTING2: |
---|
193 | 181 | urb = playbacksubs->urb[1]; |
---|
194 | 182 | atomic_inc(&playbacksubs->state); |
---|
195 | 183 | break; |
---|
196 | 184 | } |
---|
197 | 185 | } |
---|
198 | 186 | if (urb) { |
---|
199 | | - if ((err = usX2Y_hwdep_urb_play_prepare(playbacksubs, urb)) || |
---|
200 | | - (err = usX2Y_urb_submit(playbacksubs, urb, frame))) { |
---|
| 187 | + if ((err = usx2y_hwdep_urb_play_prepare(playbacksubs, urb)) || |
---|
| 188 | + (err = usx2y_urb_submit(playbacksubs, urb, frame))) { |
---|
201 | 189 | return err; |
---|
202 | 190 | } |
---|
203 | 191 | } |
---|
.. | .. |
---|
205 | 193 | playbacksubs->completed_urb = NULL; |
---|
206 | 194 | |
---|
207 | 195 | state = atomic_read(&capsubs->state); |
---|
208 | | - if (state >= state_PREPARED) { |
---|
209 | | - if (state == state_RUNNING) { |
---|
210 | | - if ((err = usX2Y_usbpcm_urb_capt_retire(capsubs))) |
---|
| 196 | + if (state >= STATE_PREPARED) { |
---|
| 197 | + if (state == STATE_RUNNING) { |
---|
| 198 | + if ((err = usx2y_usbpcm_urb_capt_retire(capsubs))) |
---|
211 | 199 | return err; |
---|
212 | | - } else if (state >= state_PRERUNNING) |
---|
| 200 | + } else if (state >= STATE_PRERUNNING) |
---|
213 | 201 | atomic_inc(&capsubs->state); |
---|
214 | | - usX2Y_usbpcm_urb_capt_iso_advance(capsubs, capsubs->completed_urb); |
---|
| 202 | + usx2y_usbpcm_urb_capt_iso_advance(capsubs, capsubs->completed_urb); |
---|
215 | 203 | if (NULL != capsubs2) |
---|
216 | | - usX2Y_usbpcm_urb_capt_iso_advance(NULL, capsubs2->completed_urb); |
---|
217 | | - if ((err = usX2Y_urb_submit(capsubs, capsubs->completed_urb, frame))) |
---|
| 204 | + usx2y_usbpcm_urb_capt_iso_advance(NULL, capsubs2->completed_urb); |
---|
| 205 | + if ((err = usx2y_urb_submit(capsubs, capsubs->completed_urb, frame))) |
---|
218 | 206 | return err; |
---|
219 | 207 | if (NULL != capsubs2) |
---|
220 | | - if ((err = usX2Y_urb_submit(capsubs2, capsubs2->completed_urb, frame))) |
---|
| 208 | + if ((err = usx2y_urb_submit(capsubs2, capsubs2->completed_urb, frame))) |
---|
221 | 209 | return err; |
---|
222 | 210 | } |
---|
223 | 211 | capsubs->completed_urb = NULL; |
---|
.. | .. |
---|
227 | 215 | } |
---|
228 | 216 | |
---|
229 | 217 | |
---|
230 | | -static void i_usX2Y_usbpcm_urb_complete(struct urb *urb) |
---|
| 218 | +static void i_usx2y_usbpcm_urb_complete(struct urb *urb) |
---|
231 | 219 | { |
---|
232 | | - struct snd_usX2Y_substream *subs = urb->context; |
---|
233 | | - struct usX2Ydev *usX2Y = subs->usX2Y; |
---|
234 | | - struct snd_usX2Y_substream *capsubs, *capsubs2, *playbacksubs; |
---|
| 220 | + struct snd_usx2y_substream *subs = urb->context; |
---|
| 221 | + struct usx2ydev *usx2y = subs->usx2y; |
---|
| 222 | + struct snd_usx2y_substream *capsubs, *capsubs2, *playbacksubs; |
---|
235 | 223 | |
---|
236 | | - if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { |
---|
| 224 | + if (unlikely(atomic_read(&subs->state) < STATE_PREPARED)) { |
---|
237 | 225 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", |
---|
238 | | - usb_get_current_frame_number(usX2Y->dev), |
---|
| 226 | + usb_get_current_frame_number(usx2y->dev), |
---|
239 | 227 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", |
---|
240 | 228 | urb->status, urb->start_frame); |
---|
241 | 229 | return; |
---|
242 | 230 | } |
---|
243 | 231 | if (unlikely(urb->status)) { |
---|
244 | | - usX2Y_error_urb_status(usX2Y, subs, urb); |
---|
| 232 | + usx2y_error_urb_status(usx2y, subs, urb); |
---|
245 | 233 | return; |
---|
246 | 234 | } |
---|
247 | 235 | |
---|
248 | 236 | subs->completed_urb = urb; |
---|
249 | | - capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
---|
250 | | - capsubs2 = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; |
---|
251 | | - playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
---|
252 | | - if (capsubs->completed_urb && atomic_read(&capsubs->state) >= state_PREPARED && |
---|
| 237 | + capsubs = usx2y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
---|
| 238 | + capsubs2 = usx2y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; |
---|
| 239 | + playbacksubs = usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
---|
| 240 | + if (capsubs->completed_urb && atomic_read(&capsubs->state) >= STATE_PREPARED && |
---|
253 | 241 | (NULL == capsubs2 || capsubs2->completed_urb) && |
---|
254 | | - (playbacksubs->completed_urb || atomic_read(&playbacksubs->state) < state_PREPARED)) { |
---|
255 | | - if (!usX2Y_usbpcm_usbframe_complete(capsubs, capsubs2, playbacksubs, urb->start_frame)) |
---|
256 | | - usX2Y->wait_iso_frame += nr_of_packs(); |
---|
| 242 | + (playbacksubs->completed_urb || atomic_read(&playbacksubs->state) < STATE_PREPARED)) { |
---|
| 243 | + if (!usx2y_usbpcm_usbframe_complete(capsubs, capsubs2, playbacksubs, urb->start_frame)) |
---|
| 244 | + usx2y->wait_iso_frame += nr_of_packs(); |
---|
257 | 245 | else { |
---|
258 | 246 | snd_printdd("\n"); |
---|
259 | | - usX2Y_clients_stop(usX2Y); |
---|
| 247 | + usx2y_clients_stop(usx2y); |
---|
260 | 248 | } |
---|
261 | 249 | } |
---|
262 | 250 | } |
---|
263 | 251 | |
---|
264 | 252 | |
---|
265 | | -static void usX2Y_hwdep_urb_release(struct urb **urb) |
---|
| 253 | +static void usx2y_hwdep_urb_release(struct urb **urb) |
---|
266 | 254 | { |
---|
267 | 255 | usb_kill_urb(*urb); |
---|
268 | 256 | usb_free_urb(*urb); |
---|
.. | .. |
---|
272 | 260 | /* |
---|
273 | 261 | * release a substream |
---|
274 | 262 | */ |
---|
275 | | -static void usX2Y_usbpcm_urbs_release(struct snd_usX2Y_substream *subs) |
---|
| 263 | +static void usx2y_usbpcm_urbs_release(struct snd_usx2y_substream *subs) |
---|
276 | 264 | { |
---|
277 | 265 | int i; |
---|
278 | | - snd_printdd("snd_usX2Y_urbs_release() %i\n", subs->endpoint); |
---|
| 266 | + snd_printdd("snd_usx2y_urbs_release() %i\n", subs->endpoint); |
---|
279 | 267 | for (i = 0; i < NRURBS; i++) |
---|
280 | | - usX2Y_hwdep_urb_release(subs->urb + i); |
---|
| 268 | + usx2y_hwdep_urb_release(subs->urb + i); |
---|
281 | 269 | } |
---|
282 | 270 | |
---|
283 | | -static void usX2Y_usbpcm_subs_startup_finish(struct usX2Ydev * usX2Y) |
---|
| 271 | +static void usx2y_usbpcm_subs_startup_finish(struct usx2ydev * usx2y) |
---|
284 | 272 | { |
---|
285 | | - usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_urb_complete); |
---|
286 | | - usX2Y->prepare_subs = NULL; |
---|
| 273 | + usx2y_urbs_set_complete(usx2y, i_usx2y_usbpcm_urb_complete); |
---|
| 274 | + usx2y->prepare_subs = NULL; |
---|
287 | 275 | } |
---|
288 | 276 | |
---|
289 | | -static void i_usX2Y_usbpcm_subs_startup(struct urb *urb) |
---|
| 277 | +static void i_usx2y_usbpcm_subs_startup(struct urb *urb) |
---|
290 | 278 | { |
---|
291 | | - struct snd_usX2Y_substream *subs = urb->context; |
---|
292 | | - struct usX2Ydev *usX2Y = subs->usX2Y; |
---|
293 | | - struct snd_usX2Y_substream *prepare_subs = usX2Y->prepare_subs; |
---|
| 279 | + struct snd_usx2y_substream *subs = urb->context; |
---|
| 280 | + struct usx2ydev *usx2y = subs->usx2y; |
---|
| 281 | + struct snd_usx2y_substream *prepare_subs = usx2y->prepare_subs; |
---|
294 | 282 | if (NULL != prepare_subs && |
---|
295 | 283 | urb->start_frame == prepare_subs->urb[0]->start_frame) { |
---|
296 | 284 | atomic_inc(&prepare_subs->state); |
---|
297 | | - if (prepare_subs == usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]) { |
---|
298 | | - struct snd_usX2Y_substream *cap_subs2 = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; |
---|
| 285 | + if (prepare_subs == usx2y->subs[SNDRV_PCM_STREAM_CAPTURE]) { |
---|
| 286 | + struct snd_usx2y_substream *cap_subs2 = usx2y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; |
---|
299 | 287 | if (cap_subs2 != NULL) |
---|
300 | 288 | atomic_inc(&cap_subs2->state); |
---|
301 | 289 | } |
---|
302 | | - usX2Y_usbpcm_subs_startup_finish(usX2Y); |
---|
303 | | - wake_up(&usX2Y->prepare_wait_queue); |
---|
| 290 | + usx2y_usbpcm_subs_startup_finish(usx2y); |
---|
| 291 | + wake_up(&usx2y->prepare_wait_queue); |
---|
304 | 292 | } |
---|
305 | 293 | |
---|
306 | | - i_usX2Y_usbpcm_urb_complete(urb); |
---|
| 294 | + i_usx2y_usbpcm_urb_complete(urb); |
---|
307 | 295 | } |
---|
308 | 296 | |
---|
309 | 297 | /* |
---|
310 | 298 | * initialize a substream's urbs |
---|
311 | 299 | */ |
---|
312 | | -static int usX2Y_usbpcm_urbs_allocate(struct snd_usX2Y_substream *subs) |
---|
| 300 | +static int usx2y_usbpcm_urbs_allocate(struct snd_usx2y_substream *subs) |
---|
313 | 301 | { |
---|
314 | 302 | int i; |
---|
315 | 303 | unsigned int pipe; |
---|
316 | | - int is_playback = subs == subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
---|
317 | | - struct usb_device *dev = subs->usX2Y->dev; |
---|
| 304 | + int is_playback = subs == subs->usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
---|
| 305 | + struct usb_device *dev = subs->usx2y->dev; |
---|
318 | 306 | |
---|
319 | 307 | pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) : |
---|
320 | 308 | usb_rcvisocpipe(dev, subs->endpoint); |
---|
.. | .. |
---|
331 | 319 | } |
---|
332 | 320 | *purb = usb_alloc_urb(nr_of_packs(), GFP_KERNEL); |
---|
333 | 321 | if (NULL == *purb) { |
---|
334 | | - usX2Y_usbpcm_urbs_release(subs); |
---|
| 322 | + usx2y_usbpcm_urbs_release(subs); |
---|
335 | 323 | return -ENOMEM; |
---|
336 | 324 | } |
---|
337 | 325 | (*purb)->transfer_buffer = is_playback ? |
---|
338 | | - subs->usX2Y->hwdep_pcm_shm->playback : ( |
---|
| 326 | + subs->usx2y->hwdep_pcm_shm->playback : ( |
---|
339 | 327 | subs->endpoint == 0x8 ? |
---|
340 | | - subs->usX2Y->hwdep_pcm_shm->capture0x8 : |
---|
341 | | - subs->usX2Y->hwdep_pcm_shm->capture0xA); |
---|
| 328 | + subs->usx2y->hwdep_pcm_shm->capture0x8 : |
---|
| 329 | + subs->usx2y->hwdep_pcm_shm->capture0xA); |
---|
342 | 330 | |
---|
343 | 331 | (*purb)->dev = dev; |
---|
344 | 332 | (*purb)->pipe = pipe; |
---|
345 | 333 | (*purb)->number_of_packets = nr_of_packs(); |
---|
346 | 334 | (*purb)->context = subs; |
---|
347 | 335 | (*purb)->interval = 1; |
---|
348 | | - (*purb)->complete = i_usX2Y_usbpcm_subs_startup; |
---|
| 336 | + (*purb)->complete = i_usx2y_usbpcm_subs_startup; |
---|
349 | 337 | } |
---|
350 | 338 | return 0; |
---|
351 | 339 | } |
---|
.. | .. |
---|
353 | 341 | /* |
---|
354 | 342 | * free the buffer |
---|
355 | 343 | */ |
---|
356 | | -static int snd_usX2Y_usbpcm_hw_free(struct snd_pcm_substream *substream) |
---|
| 344 | +static int snd_usx2y_usbpcm_hw_free(struct snd_pcm_substream *substream) |
---|
357 | 345 | { |
---|
358 | 346 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
359 | | - struct snd_usX2Y_substream *subs = runtime->private_data, |
---|
360 | | - *cap_subs2 = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; |
---|
361 | | - mutex_lock(&subs->usX2Y->pcm_mutex); |
---|
362 | | - snd_printdd("snd_usX2Y_usbpcm_hw_free(%p)\n", substream); |
---|
| 347 | + struct snd_usx2y_substream *subs = runtime->private_data, |
---|
| 348 | + *cap_subs2 = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; |
---|
| 349 | + mutex_lock(&subs->usx2y->pcm_mutex); |
---|
| 350 | + snd_printdd("snd_usx2y_usbpcm_hw_free(%p)\n", substream); |
---|
363 | 351 | |
---|
364 | 352 | if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { |
---|
365 | | - struct snd_usX2Y_substream *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
---|
366 | | - atomic_set(&subs->state, state_STOPPED); |
---|
367 | | - usX2Y_usbpcm_urbs_release(subs); |
---|
| 353 | + struct snd_usx2y_substream *cap_subs = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
---|
| 354 | + atomic_set(&subs->state, STATE_STOPPED); |
---|
| 355 | + usx2y_usbpcm_urbs_release(subs); |
---|
368 | 356 | if (!cap_subs->pcm_substream || |
---|
369 | 357 | !cap_subs->pcm_substream->runtime || |
---|
370 | 358 | !cap_subs->pcm_substream->runtime->status || |
---|
371 | 359 | cap_subs->pcm_substream->runtime->status->state < SNDRV_PCM_STATE_PREPARED) { |
---|
372 | | - atomic_set(&cap_subs->state, state_STOPPED); |
---|
| 360 | + atomic_set(&cap_subs->state, STATE_STOPPED); |
---|
373 | 361 | if (NULL != cap_subs2) |
---|
374 | | - atomic_set(&cap_subs2->state, state_STOPPED); |
---|
375 | | - usX2Y_usbpcm_urbs_release(cap_subs); |
---|
| 362 | + atomic_set(&cap_subs2->state, STATE_STOPPED); |
---|
| 363 | + usx2y_usbpcm_urbs_release(cap_subs); |
---|
376 | 364 | if (NULL != cap_subs2) |
---|
377 | | - usX2Y_usbpcm_urbs_release(cap_subs2); |
---|
| 365 | + usx2y_usbpcm_urbs_release(cap_subs2); |
---|
378 | 366 | } |
---|
379 | 367 | } else { |
---|
380 | | - struct snd_usX2Y_substream *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
---|
381 | | - if (atomic_read(&playback_subs->state) < state_PREPARED) { |
---|
382 | | - atomic_set(&subs->state, state_STOPPED); |
---|
| 368 | + struct snd_usx2y_substream *playback_subs = subs->usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
---|
| 369 | + if (atomic_read(&playback_subs->state) < STATE_PREPARED) { |
---|
| 370 | + atomic_set(&subs->state, STATE_STOPPED); |
---|
383 | 371 | if (NULL != cap_subs2) |
---|
384 | | - atomic_set(&cap_subs2->state, state_STOPPED); |
---|
385 | | - usX2Y_usbpcm_urbs_release(subs); |
---|
| 372 | + atomic_set(&cap_subs2->state, STATE_STOPPED); |
---|
| 373 | + usx2y_usbpcm_urbs_release(subs); |
---|
386 | 374 | if (NULL != cap_subs2) |
---|
387 | | - usX2Y_usbpcm_urbs_release(cap_subs2); |
---|
| 375 | + usx2y_usbpcm_urbs_release(cap_subs2); |
---|
388 | 376 | } |
---|
389 | 377 | } |
---|
390 | | - mutex_unlock(&subs->usX2Y->pcm_mutex); |
---|
391 | | - return snd_pcm_lib_free_pages(substream); |
---|
| 378 | + mutex_unlock(&subs->usx2y->pcm_mutex); |
---|
| 379 | + return 0; |
---|
392 | 380 | } |
---|
393 | 381 | |
---|
394 | | -static void usX2Y_usbpcm_subs_startup(struct snd_usX2Y_substream *subs) |
---|
| 382 | +static void usx2y_usbpcm_subs_startup(struct snd_usx2y_substream *subs) |
---|
395 | 383 | { |
---|
396 | | - struct usX2Ydev * usX2Y = subs->usX2Y; |
---|
397 | | - usX2Y->prepare_subs = subs; |
---|
| 384 | + struct usx2ydev * usx2y = subs->usx2y; |
---|
| 385 | + usx2y->prepare_subs = subs; |
---|
398 | 386 | subs->urb[0]->start_frame = -1; |
---|
399 | | - smp_wmb(); // Make sure above modifications are seen by i_usX2Y_subs_startup() |
---|
400 | | - usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_subs_startup); |
---|
| 387 | + smp_wmb(); // Make sure above modifications are seen by i_usx2y_subs_startup() |
---|
| 388 | + usx2y_urbs_set_complete(usx2y, i_usx2y_usbpcm_subs_startup); |
---|
401 | 389 | } |
---|
402 | 390 | |
---|
403 | | -static int usX2Y_usbpcm_urbs_start(struct snd_usX2Y_substream *subs) |
---|
| 391 | +static int usx2y_usbpcm_urbs_start(struct snd_usx2y_substream *subs) |
---|
404 | 392 | { |
---|
405 | 393 | int p, u, err, |
---|
406 | 394 | stream = subs->pcm_substream->stream; |
---|
407 | | - struct usX2Ydev *usX2Y = subs->usX2Y; |
---|
| 395 | + struct usx2ydev *usx2y = subs->usx2y; |
---|
408 | 396 | |
---|
409 | 397 | if (SNDRV_PCM_STREAM_CAPTURE == stream) { |
---|
410 | | - usX2Y->hwdep_pcm_shm->captured_iso_head = -1; |
---|
411 | | - usX2Y->hwdep_pcm_shm->captured_iso_frames = 0; |
---|
| 398 | + usx2y->hwdep_pcm_shm->captured_iso_head = -1; |
---|
| 399 | + usx2y->hwdep_pcm_shm->captured_iso_frames = 0; |
---|
412 | 400 | } |
---|
413 | 401 | |
---|
414 | 402 | for (p = 0; 3 >= (stream + p); p += 2) { |
---|
415 | | - struct snd_usX2Y_substream *subs = usX2Y->subs[stream + p]; |
---|
| 403 | + struct snd_usx2y_substream *subs = usx2y->subs[stream + p]; |
---|
416 | 404 | if (subs != NULL) { |
---|
417 | | - if ((err = usX2Y_usbpcm_urbs_allocate(subs)) < 0) |
---|
| 405 | + if ((err = usx2y_usbpcm_urbs_allocate(subs)) < 0) |
---|
418 | 406 | return err; |
---|
419 | 407 | subs->completed_urb = NULL; |
---|
420 | 408 | } |
---|
421 | 409 | } |
---|
422 | 410 | |
---|
423 | 411 | for (p = 0; p < 4; p++) { |
---|
424 | | - struct snd_usX2Y_substream *subs = usX2Y->subs[p]; |
---|
425 | | - if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) |
---|
| 412 | + struct snd_usx2y_substream *subs = usx2y->subs[p]; |
---|
| 413 | + if (subs != NULL && atomic_read(&subs->state) >= STATE_PREPARED) |
---|
426 | 414 | goto start; |
---|
427 | 415 | } |
---|
428 | 416 | |
---|
429 | 417 | start: |
---|
430 | | - usX2Y_usbpcm_subs_startup(subs); |
---|
| 418 | + usx2y_usbpcm_subs_startup(subs); |
---|
431 | 419 | for (u = 0; u < NRURBS; u++) { |
---|
432 | 420 | for (p = 0; 3 >= (stream + p); p += 2) { |
---|
433 | | - struct snd_usX2Y_substream *subs = usX2Y->subs[stream + p]; |
---|
| 421 | + struct snd_usx2y_substream *subs = usx2y->subs[stream + p]; |
---|
434 | 422 | if (subs != NULL) { |
---|
435 | 423 | struct urb *urb = subs->urb[u]; |
---|
436 | 424 | if (usb_pipein(urb->pipe)) { |
---|
437 | 425 | unsigned long pack; |
---|
438 | 426 | if (0 == u) |
---|
439 | | - atomic_set(&subs->state, state_STARTING3); |
---|
440 | | - urb->dev = usX2Y->dev; |
---|
| 427 | + atomic_set(&subs->state, STATE_STARTING3); |
---|
| 428 | + urb->dev = usx2y->dev; |
---|
441 | 429 | for (pack = 0; pack < nr_of_packs(); pack++) { |
---|
442 | 430 | urb->iso_frame_desc[pack].offset = subs->maxpacksize * (pack + u * nr_of_packs()); |
---|
443 | 431 | urb->iso_frame_desc[pack].length = subs->maxpacksize; |
---|
.. | .. |
---|
450 | 438 | } else { |
---|
451 | 439 | snd_printdd("%i\n", urb->start_frame); |
---|
452 | 440 | if (u == 0) |
---|
453 | | - usX2Y->wait_iso_frame = urb->start_frame; |
---|
| 441 | + usx2y->wait_iso_frame = urb->start_frame; |
---|
454 | 442 | } |
---|
455 | 443 | urb->transfer_flags = 0; |
---|
456 | 444 | } else { |
---|
457 | | - atomic_set(&subs->state, state_STARTING1); |
---|
| 445 | + atomic_set(&subs->state, STATE_STARTING1); |
---|
458 | 446 | break; |
---|
459 | 447 | } |
---|
460 | 448 | } |
---|
461 | 449 | } |
---|
462 | 450 | } |
---|
463 | 451 | err = 0; |
---|
464 | | - wait_event(usX2Y->prepare_wait_queue, NULL == usX2Y->prepare_subs); |
---|
465 | | - if (atomic_read(&subs->state) != state_PREPARED) |
---|
| 452 | + wait_event(usx2y->prepare_wait_queue, NULL == usx2y->prepare_subs); |
---|
| 453 | + if (atomic_read(&subs->state) != STATE_PREPARED) |
---|
466 | 454 | err = -EPIPE; |
---|
467 | 455 | |
---|
468 | 456 | cleanup: |
---|
469 | 457 | if (err) { |
---|
470 | | - usX2Y_subs_startup_finish(usX2Y); // Call it now |
---|
471 | | - usX2Y_clients_stop(usX2Y); // something is completely wroong > stop evrything |
---|
| 458 | + usx2y_subs_startup_finish(usx2y); // Call it now |
---|
| 459 | + usx2y_clients_stop(usx2y); // something is completely wroong > stop evrything |
---|
472 | 460 | } |
---|
473 | 461 | return err; |
---|
474 | 462 | } |
---|
.. | .. |
---|
478 | 466 | * |
---|
479 | 467 | * set format and initialize urbs |
---|
480 | 468 | */ |
---|
481 | | -static int snd_usX2Y_usbpcm_prepare(struct snd_pcm_substream *substream) |
---|
| 469 | +static int snd_usx2y_usbpcm_prepare(struct snd_pcm_substream *substream) |
---|
482 | 470 | { |
---|
483 | 471 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
484 | | - struct snd_usX2Y_substream *subs = runtime->private_data; |
---|
485 | | - struct usX2Ydev *usX2Y = subs->usX2Y; |
---|
486 | | - struct snd_usX2Y_substream *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
---|
| 472 | + struct snd_usx2y_substream *subs = runtime->private_data; |
---|
| 473 | + struct usx2ydev *usx2y = subs->usx2y; |
---|
| 474 | + struct snd_usx2y_substream *capsubs = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
---|
487 | 475 | int err = 0; |
---|
488 | | - snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); |
---|
| 476 | + snd_printdd("snd_usx2y_pcm_prepare(%p)\n", substream); |
---|
489 | 477 | |
---|
490 | | - if (NULL == usX2Y->hwdep_pcm_shm) { |
---|
491 | | - if (NULL == (usX2Y->hwdep_pcm_shm = snd_malloc_pages(sizeof(struct snd_usX2Y_hwdep_pcm_shm), GFP_KERNEL))) |
---|
| 478 | + if (NULL == usx2y->hwdep_pcm_shm) { |
---|
| 479 | + usx2y->hwdep_pcm_shm = alloc_pages_exact(sizeof(struct snd_usx2y_hwdep_pcm_shm), |
---|
| 480 | + GFP_KERNEL); |
---|
| 481 | + if (!usx2y->hwdep_pcm_shm) |
---|
492 | 482 | return -ENOMEM; |
---|
493 | | - memset(usX2Y->hwdep_pcm_shm, 0, sizeof(struct snd_usX2Y_hwdep_pcm_shm)); |
---|
| 483 | + memset(usx2y->hwdep_pcm_shm, 0, sizeof(struct snd_usx2y_hwdep_pcm_shm)); |
---|
494 | 484 | } |
---|
495 | 485 | |
---|
496 | | - mutex_lock(&usX2Y->pcm_mutex); |
---|
497 | | - usX2Y_subs_prepare(subs); |
---|
| 486 | + mutex_lock(&usx2y->pcm_mutex); |
---|
| 487 | + usx2y_subs_prepare(subs); |
---|
498 | 488 | // Start hardware streams |
---|
499 | 489 | // SyncStream first.... |
---|
500 | | - if (atomic_read(&capsubs->state) < state_PREPARED) { |
---|
501 | | - if (usX2Y->format != runtime->format) |
---|
502 | | - if ((err = usX2Y_format_set(usX2Y, runtime->format)) < 0) |
---|
| 490 | + if (atomic_read(&capsubs->state) < STATE_PREPARED) { |
---|
| 491 | + if (usx2y->format != runtime->format) |
---|
| 492 | + if ((err = usx2y_format_set(usx2y, runtime->format)) < 0) |
---|
503 | 493 | goto up_prepare_mutex; |
---|
504 | | - if (usX2Y->rate != runtime->rate) |
---|
505 | | - if ((err = usX2Y_rate_set(usX2Y, runtime->rate)) < 0) |
---|
| 494 | + if (usx2y->rate != runtime->rate) |
---|
| 495 | + if ((err = usx2y_rate_set(usx2y, runtime->rate)) < 0) |
---|
506 | 496 | goto up_prepare_mutex; |
---|
507 | 497 | snd_printdd("starting capture pipe for %s\n", subs == capsubs ? |
---|
508 | 498 | "self" : "playpipe"); |
---|
509 | | - if (0 > (err = usX2Y_usbpcm_urbs_start(capsubs))) |
---|
| 499 | + if (0 > (err = usx2y_usbpcm_urbs_start(capsubs))) |
---|
510 | 500 | goto up_prepare_mutex; |
---|
511 | 501 | } |
---|
512 | 502 | |
---|
513 | 503 | if (subs != capsubs) { |
---|
514 | | - usX2Y->hwdep_pcm_shm->playback_iso_start = -1; |
---|
515 | | - if (atomic_read(&subs->state) < state_PREPARED) { |
---|
516 | | - while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > |
---|
517 | | - usX2Y->hwdep_pcm_shm->captured_iso_frames) { |
---|
| 504 | + usx2y->hwdep_pcm_shm->playback_iso_start = -1; |
---|
| 505 | + if (atomic_read(&subs->state) < STATE_PREPARED) { |
---|
| 506 | + while (usx2y_iso_frames_per_buffer(runtime, usx2y) > |
---|
| 507 | + usx2y->hwdep_pcm_shm->captured_iso_frames) { |
---|
518 | 508 | snd_printdd("Wait: iso_frames_per_buffer=%i," |
---|
519 | 509 | "captured_iso_frames=%i\n", |
---|
520 | | - usX2Y_iso_frames_per_buffer(runtime, usX2Y), |
---|
521 | | - usX2Y->hwdep_pcm_shm->captured_iso_frames); |
---|
| 510 | + usx2y_iso_frames_per_buffer(runtime, usx2y), |
---|
| 511 | + usx2y->hwdep_pcm_shm->captured_iso_frames); |
---|
522 | 512 | if (msleep_interruptible(10)) { |
---|
523 | 513 | err = -ERESTARTSYS; |
---|
524 | 514 | goto up_prepare_mutex; |
---|
525 | 515 | } |
---|
526 | 516 | } |
---|
527 | | - if (0 > (err = usX2Y_usbpcm_urbs_start(subs))) |
---|
| 517 | + if (0 > (err = usx2y_usbpcm_urbs_start(subs))) |
---|
528 | 518 | goto up_prepare_mutex; |
---|
529 | 519 | } |
---|
530 | 520 | snd_printdd("Ready: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", |
---|
531 | | - usX2Y_iso_frames_per_buffer(runtime, usX2Y), |
---|
532 | | - usX2Y->hwdep_pcm_shm->captured_iso_frames); |
---|
| 521 | + usx2y_iso_frames_per_buffer(runtime, usx2y), |
---|
| 522 | + usx2y->hwdep_pcm_shm->captured_iso_frames); |
---|
533 | 523 | } else |
---|
534 | | - usX2Y->hwdep_pcm_shm->capture_iso_start = -1; |
---|
| 524 | + usx2y->hwdep_pcm_shm->capture_iso_start = -1; |
---|
535 | 525 | |
---|
536 | 526 | up_prepare_mutex: |
---|
537 | | - mutex_unlock(&usX2Y->pcm_mutex); |
---|
| 527 | + mutex_unlock(&usx2y->pcm_mutex); |
---|
538 | 528 | return err; |
---|
539 | 529 | } |
---|
540 | 530 | |
---|
541 | | -static struct snd_pcm_hardware snd_usX2Y_4c = |
---|
| 531 | +static const struct snd_pcm_hardware snd_usx2y_4c = |
---|
542 | 532 | { |
---|
543 | 533 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
---|
544 | 534 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
---|
.. | .. |
---|
559 | 549 | |
---|
560 | 550 | |
---|
561 | 551 | |
---|
562 | | -static int snd_usX2Y_usbpcm_open(struct snd_pcm_substream *substream) |
---|
| 552 | +static int snd_usx2y_usbpcm_open(struct snd_pcm_substream *substream) |
---|
563 | 553 | { |
---|
564 | | - struct snd_usX2Y_substream *subs = ((struct snd_usX2Y_substream **) |
---|
| 554 | + struct snd_usx2y_substream *subs = ((struct snd_usx2y_substream **) |
---|
565 | 555 | snd_pcm_substream_chip(substream))[substream->stream]; |
---|
566 | 556 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
567 | 557 | |
---|
568 | | - if (!(subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS)) |
---|
| 558 | + if (!(subs->usx2y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS)) |
---|
569 | 559 | return -EBUSY; |
---|
570 | 560 | |
---|
571 | | - runtime->hw = SNDRV_PCM_STREAM_PLAYBACK == substream->stream ? snd_usX2Y_2c : |
---|
572 | | - (subs->usX2Y->subs[3] ? snd_usX2Y_4c : snd_usX2Y_2c); |
---|
| 561 | + runtime->hw = SNDRV_PCM_STREAM_PLAYBACK == substream->stream ? snd_usx2y_2c : |
---|
| 562 | + (subs->usx2y->subs[3] ? snd_usx2y_4c : snd_usx2y_2c); |
---|
573 | 563 | runtime->private_data = subs; |
---|
574 | 564 | subs->pcm_substream = substream; |
---|
575 | 565 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 1000, 200000); |
---|
.. | .. |
---|
577 | 567 | } |
---|
578 | 568 | |
---|
579 | 569 | |
---|
580 | | -static int snd_usX2Y_usbpcm_close(struct snd_pcm_substream *substream) |
---|
| 570 | +static int snd_usx2y_usbpcm_close(struct snd_pcm_substream *substream) |
---|
581 | 571 | { |
---|
582 | 572 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
583 | | - struct snd_usX2Y_substream *subs = runtime->private_data; |
---|
| 573 | + struct snd_usx2y_substream *subs = runtime->private_data; |
---|
584 | 574 | |
---|
585 | 575 | subs->pcm_substream = NULL; |
---|
586 | 576 | return 0; |
---|
587 | 577 | } |
---|
588 | 578 | |
---|
589 | 579 | |
---|
590 | | -static const struct snd_pcm_ops snd_usX2Y_usbpcm_ops = |
---|
| 580 | +static const struct snd_pcm_ops snd_usx2y_usbpcm_ops = |
---|
591 | 581 | { |
---|
592 | | - .open = snd_usX2Y_usbpcm_open, |
---|
593 | | - .close = snd_usX2Y_usbpcm_close, |
---|
594 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
595 | | - .hw_params = snd_usX2Y_pcm_hw_params, |
---|
596 | | - .hw_free = snd_usX2Y_usbpcm_hw_free, |
---|
597 | | - .prepare = snd_usX2Y_usbpcm_prepare, |
---|
598 | | - .trigger = snd_usX2Y_pcm_trigger, |
---|
599 | | - .pointer = snd_usX2Y_pcm_pointer, |
---|
| 582 | + .open = snd_usx2y_usbpcm_open, |
---|
| 583 | + .close = snd_usx2y_usbpcm_close, |
---|
| 584 | + .hw_params = snd_usx2y_pcm_hw_params, |
---|
| 585 | + .hw_free = snd_usx2y_usbpcm_hw_free, |
---|
| 586 | + .prepare = snd_usx2y_usbpcm_prepare, |
---|
| 587 | + .trigger = snd_usx2y_pcm_trigger, |
---|
| 588 | + .pointer = snd_usx2y_pcm_pointer, |
---|
600 | 589 | }; |
---|
601 | 590 | |
---|
602 | 591 | |
---|
603 | | -static int usX2Y_pcms_busy_check(struct snd_card *card) |
---|
| 592 | +static int usx2y_pcms_busy_check(struct snd_card *card) |
---|
604 | 593 | { |
---|
605 | | - struct usX2Ydev *dev = usX2Y(card); |
---|
| 594 | + struct usx2ydev *dev = usx2y(card); |
---|
606 | 595 | int i; |
---|
607 | 596 | |
---|
608 | 597 | for (i = 0; i < dev->pcm_devs * 2; i++) { |
---|
609 | | - struct snd_usX2Y_substream *subs = dev->subs[i]; |
---|
| 598 | + struct snd_usx2y_substream *subs = dev->subs[i]; |
---|
610 | 599 | if (subs && subs->pcm_substream && |
---|
611 | 600 | SUBSTREAM_BUSY(subs->pcm_substream)) |
---|
612 | 601 | return -EBUSY; |
---|
.. | .. |
---|
614 | 603 | return 0; |
---|
615 | 604 | } |
---|
616 | 605 | |
---|
617 | | -static int snd_usX2Y_hwdep_pcm_open(struct snd_hwdep *hw, struct file *file) |
---|
| 606 | +static int snd_usx2y_hwdep_pcm_open(struct snd_hwdep *hw, struct file *file) |
---|
618 | 607 | { |
---|
619 | 608 | struct snd_card *card = hw->card; |
---|
620 | 609 | int err; |
---|
621 | 610 | |
---|
622 | | - mutex_lock(&usX2Y(card)->pcm_mutex); |
---|
623 | | - err = usX2Y_pcms_busy_check(card); |
---|
| 611 | + mutex_lock(&usx2y(card)->pcm_mutex); |
---|
| 612 | + err = usx2y_pcms_busy_check(card); |
---|
624 | 613 | if (!err) |
---|
625 | | - usX2Y(card)->chip_status |= USX2Y_STAT_CHIP_MMAP_PCM_URBS; |
---|
626 | | - mutex_unlock(&usX2Y(card)->pcm_mutex); |
---|
| 614 | + usx2y(card)->chip_status |= USX2Y_STAT_CHIP_MMAP_PCM_URBS; |
---|
| 615 | + mutex_unlock(&usx2y(card)->pcm_mutex); |
---|
627 | 616 | return err; |
---|
628 | 617 | } |
---|
629 | 618 | |
---|
630 | 619 | |
---|
631 | | -static int snd_usX2Y_hwdep_pcm_release(struct snd_hwdep *hw, struct file *file) |
---|
| 620 | +static int snd_usx2y_hwdep_pcm_release(struct snd_hwdep *hw, struct file *file) |
---|
632 | 621 | { |
---|
633 | 622 | struct snd_card *card = hw->card; |
---|
634 | 623 | int err; |
---|
635 | 624 | |
---|
636 | | - mutex_lock(&usX2Y(card)->pcm_mutex); |
---|
637 | | - err = usX2Y_pcms_busy_check(card); |
---|
| 625 | + mutex_lock(&usx2y(card)->pcm_mutex); |
---|
| 626 | + err = usx2y_pcms_busy_check(card); |
---|
638 | 627 | if (!err) |
---|
639 | | - usX2Y(hw->card)->chip_status &= ~USX2Y_STAT_CHIP_MMAP_PCM_URBS; |
---|
640 | | - mutex_unlock(&usX2Y(card)->pcm_mutex); |
---|
| 628 | + usx2y(hw->card)->chip_status &= ~USX2Y_STAT_CHIP_MMAP_PCM_URBS; |
---|
| 629 | + mutex_unlock(&usx2y(card)->pcm_mutex); |
---|
641 | 630 | return err; |
---|
642 | 631 | } |
---|
643 | 632 | |
---|
644 | 633 | |
---|
645 | | -static void snd_usX2Y_hwdep_pcm_vm_open(struct vm_area_struct *area) |
---|
| 634 | +static void snd_usx2y_hwdep_pcm_vm_open(struct vm_area_struct *area) |
---|
646 | 635 | { |
---|
647 | 636 | } |
---|
648 | 637 | |
---|
649 | 638 | |
---|
650 | | -static void snd_usX2Y_hwdep_pcm_vm_close(struct vm_area_struct *area) |
---|
| 639 | +static void snd_usx2y_hwdep_pcm_vm_close(struct vm_area_struct *area) |
---|
651 | 640 | { |
---|
652 | 641 | } |
---|
653 | 642 | |
---|
654 | 643 | |
---|
655 | | -static vm_fault_t snd_usX2Y_hwdep_pcm_vm_fault(struct vm_fault *vmf) |
---|
| 644 | +static vm_fault_t snd_usx2y_hwdep_pcm_vm_fault(struct vm_fault *vmf) |
---|
656 | 645 | { |
---|
657 | 646 | unsigned long offset; |
---|
658 | 647 | void *vaddr; |
---|
659 | 648 | |
---|
660 | 649 | offset = vmf->pgoff << PAGE_SHIFT; |
---|
661 | | - vaddr = (char *)((struct usX2Ydev *)vmf->vma->vm_private_data)->hwdep_pcm_shm + offset; |
---|
| 650 | + vaddr = (char *)((struct usx2ydev *)vmf->vma->vm_private_data)->hwdep_pcm_shm + offset; |
---|
662 | 651 | vmf->page = virt_to_page(vaddr); |
---|
663 | 652 | get_page(vmf->page); |
---|
664 | 653 | return 0; |
---|
665 | 654 | } |
---|
666 | 655 | |
---|
667 | 656 | |
---|
668 | | -static const struct vm_operations_struct snd_usX2Y_hwdep_pcm_vm_ops = { |
---|
669 | | - .open = snd_usX2Y_hwdep_pcm_vm_open, |
---|
670 | | - .close = snd_usX2Y_hwdep_pcm_vm_close, |
---|
671 | | - .fault = snd_usX2Y_hwdep_pcm_vm_fault, |
---|
| 657 | +static const struct vm_operations_struct snd_usx2y_hwdep_pcm_vm_ops = { |
---|
| 658 | + .open = snd_usx2y_hwdep_pcm_vm_open, |
---|
| 659 | + .close = snd_usx2y_hwdep_pcm_vm_close, |
---|
| 660 | + .fault = snd_usx2y_hwdep_pcm_vm_fault, |
---|
672 | 661 | }; |
---|
673 | 662 | |
---|
674 | 663 | |
---|
675 | | -static int snd_usX2Y_hwdep_pcm_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area) |
---|
| 664 | +static int snd_usx2y_hwdep_pcm_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area) |
---|
676 | 665 | { |
---|
677 | 666 | unsigned long size = (unsigned long)(area->vm_end - area->vm_start); |
---|
678 | | - struct usX2Ydev *usX2Y = hw->private_data; |
---|
| 667 | + struct usx2ydev *usx2y = hw->private_data; |
---|
679 | 668 | |
---|
680 | | - if (!(usX2Y->chip_status & USX2Y_STAT_CHIP_INIT)) |
---|
| 669 | + if (!(usx2y->chip_status & USX2Y_STAT_CHIP_INIT)) |
---|
681 | 670 | return -EBUSY; |
---|
682 | 671 | |
---|
683 | 672 | /* if userspace tries to mmap beyond end of our buffer, fail */ |
---|
684 | | - if (size > PAGE_ALIGN(sizeof(struct snd_usX2Y_hwdep_pcm_shm))) { |
---|
685 | | - snd_printd("%lu > %lu\n", size, (unsigned long)sizeof(struct snd_usX2Y_hwdep_pcm_shm)); |
---|
| 673 | + if (size > PAGE_ALIGN(sizeof(struct snd_usx2y_hwdep_pcm_shm))) { |
---|
| 674 | + snd_printd("%lu > %lu\n", size, (unsigned long)sizeof(struct snd_usx2y_hwdep_pcm_shm)); |
---|
686 | 675 | return -EINVAL; |
---|
687 | 676 | } |
---|
688 | 677 | |
---|
689 | | - if (!usX2Y->hwdep_pcm_shm) { |
---|
| 678 | + if (!usx2y->hwdep_pcm_shm) { |
---|
690 | 679 | return -ENODEV; |
---|
691 | 680 | } |
---|
692 | | - area->vm_ops = &snd_usX2Y_hwdep_pcm_vm_ops; |
---|
| 681 | + area->vm_ops = &snd_usx2y_hwdep_pcm_vm_ops; |
---|
693 | 682 | area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; |
---|
694 | 683 | area->vm_private_data = hw->private_data; |
---|
695 | 684 | return 0; |
---|
696 | 685 | } |
---|
697 | 686 | |
---|
698 | 687 | |
---|
699 | | -static void snd_usX2Y_hwdep_pcm_private_free(struct snd_hwdep *hwdep) |
---|
| 688 | +static void snd_usx2y_hwdep_pcm_private_free(struct snd_hwdep *hwdep) |
---|
700 | 689 | { |
---|
701 | | - struct usX2Ydev *usX2Y = hwdep->private_data; |
---|
702 | | - if (NULL != usX2Y->hwdep_pcm_shm) |
---|
703 | | - snd_free_pages(usX2Y->hwdep_pcm_shm, sizeof(struct snd_usX2Y_hwdep_pcm_shm)); |
---|
| 690 | + struct usx2ydev *usx2y = hwdep->private_data; |
---|
| 691 | + if (NULL != usx2y->hwdep_pcm_shm) |
---|
| 692 | + free_pages_exact(usx2y->hwdep_pcm_shm, sizeof(struct snd_usx2y_hwdep_pcm_shm)); |
---|
704 | 693 | } |
---|
705 | 694 | |
---|
706 | 695 | |
---|
707 | | -int usX2Y_hwdep_pcm_new(struct snd_card *card) |
---|
| 696 | +int usx2y_hwdep_pcm_new(struct snd_card *card) |
---|
708 | 697 | { |
---|
709 | 698 | int err; |
---|
710 | 699 | struct snd_hwdep *hw; |
---|
711 | 700 | struct snd_pcm *pcm; |
---|
712 | | - struct usb_device *dev = usX2Y(card)->dev; |
---|
| 701 | + struct usb_device *dev = usx2y(card)->dev; |
---|
713 | 702 | if (1 != nr_of_packs()) |
---|
714 | 703 | return 0; |
---|
715 | 704 | |
---|
.. | .. |
---|
717 | 706 | return err; |
---|
718 | 707 | |
---|
719 | 708 | hw->iface = SNDRV_HWDEP_IFACE_USX2Y_PCM; |
---|
720 | | - hw->private_data = usX2Y(card); |
---|
721 | | - hw->private_free = snd_usX2Y_hwdep_pcm_private_free; |
---|
722 | | - hw->ops.open = snd_usX2Y_hwdep_pcm_open; |
---|
723 | | - hw->ops.release = snd_usX2Y_hwdep_pcm_release; |
---|
724 | | - hw->ops.mmap = snd_usX2Y_hwdep_pcm_mmap; |
---|
| 709 | + hw->private_data = usx2y(card); |
---|
| 710 | + hw->private_free = snd_usx2y_hwdep_pcm_private_free; |
---|
| 711 | + hw->ops.open = snd_usx2y_hwdep_pcm_open; |
---|
| 712 | + hw->ops.release = snd_usx2y_hwdep_pcm_release; |
---|
| 713 | + hw->ops.mmap = snd_usx2y_hwdep_pcm_mmap; |
---|
725 | 714 | hw->exclusive = 1; |
---|
726 | 715 | sprintf(hw->name, "/dev/bus/usb/%03d/%03d/hwdeppcm", dev->bus->busnum, dev->devnum); |
---|
727 | 716 | |
---|
.. | .. |
---|
729 | 718 | if (err < 0) { |
---|
730 | 719 | return err; |
---|
731 | 720 | } |
---|
732 | | - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_usX2Y_usbpcm_ops); |
---|
733 | | - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usX2Y_usbpcm_ops); |
---|
| 721 | + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_usx2y_usbpcm_ops); |
---|
| 722 | + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usx2y_usbpcm_ops); |
---|
734 | 723 | |
---|
735 | | - pcm->private_data = usX2Y(card)->subs; |
---|
| 724 | + pcm->private_data = usx2y(card)->subs; |
---|
736 | 725 | pcm->info_flags = 0; |
---|
737 | 726 | |
---|
738 | 727 | sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio"); |
---|
739 | | - if (0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, |
---|
740 | | - SNDRV_DMA_TYPE_CONTINUOUS, |
---|
741 | | - snd_dma_continuous_data(GFP_KERNEL), |
---|
742 | | - 64*1024, 128*1024)) || |
---|
743 | | - 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, |
---|
744 | | - SNDRV_DMA_TYPE_CONTINUOUS, |
---|
745 | | - snd_dma_continuous_data(GFP_KERNEL), |
---|
746 | | - 64*1024, 128*1024))) { |
---|
747 | | - return err; |
---|
748 | | - } |
---|
749 | | - |
---|
| 728 | + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, |
---|
| 729 | + SNDRV_DMA_TYPE_CONTINUOUS, |
---|
| 730 | + NULL, |
---|
| 731 | + 64*1024, 128*1024); |
---|
| 732 | + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, |
---|
| 733 | + SNDRV_DMA_TYPE_CONTINUOUS, |
---|
| 734 | + NULL, |
---|
| 735 | + 64*1024, 128*1024); |
---|
750 | 736 | |
---|
751 | 737 | return 0; |
---|
752 | 738 | } |
---|
753 | 739 | |
---|
754 | 740 | #else |
---|
755 | 741 | |
---|
756 | | -int usX2Y_hwdep_pcm_new(struct snd_card *card) |
---|
| 742 | +int usx2y_hwdep_pcm_new(struct snd_card *card) |
---|
757 | 743 | { |
---|
758 | 744 | return 0; |
---|
759 | 745 | } |
---|