forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/usb/usx2y/usbusx2yaudio.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * US-X2Y AUDIO
34 * Copyright (c) 2002-2004 by Karsten Wiese
....@@ -13,21 +14,6 @@
1314 * Many codes borrowed from audio.c by
1415 * Alan Cox (alan@lxorguk.ukuu.org.uk)
1516 * Thomas Sailer (sailer@ife.ee.ethz.ch)
16
- *
17
- *
18
- * This program is free software; you can redistribute it and/or modify
19
- * it under the terms of the GNU General Public License as published by
20
- * the Free Software Foundation; either version 2 of the License, or
21
- * (at your option) any later version.
22
- *
23
- * This program is distributed in the hope that it will be useful,
24
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
- * GNU General Public License for more details.
27
- *
28
- * You should have received a copy of the GNU General Public License
29
- * along with this program; if not, write to the Free Software
30
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3117 */
3218
3319
....@@ -68,13 +54,13 @@
6854 #endif
6955
7056
71
-static int usX2Y_urb_capt_retire(struct snd_usX2Y_substream *subs)
57
+static int usx2y_urb_capt_retire(struct snd_usx2y_substream *subs)
7258 {
7359 struct urb *urb = subs->completed_urb;
7460 struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime;
7561 unsigned char *cp;
7662 int i, len, lens = 0, hwptr_done = subs->hwptr_done;
77
- struct usX2Ydev *usX2Y = subs->usX2Y;
63
+ struct usx2ydev *usx2y = subs->usx2y;
7864
7965 for (i = 0; i < nr_of_packs(); i++) {
8066 cp = (unsigned char*)urb->transfer_buffer + urb->iso_frame_desc[i].offset;
....@@ -84,7 +70,7 @@
8470 urb->iso_frame_desc[i].status);
8571 return urb->iso_frame_desc[i].status;
8672 }
87
- len = urb->iso_frame_desc[i].actual_length / usX2Y->stride;
73
+ len = urb->iso_frame_desc[i].actual_length / usx2y->stride;
8874 if (! len) {
8975 snd_printd("0 == len ERROR!\n");
9076 continue;
....@@ -93,12 +79,12 @@
9379 /* copy a data chunk */
9480 if ((hwptr_done + len) > runtime->buffer_size) {
9581 int cnt = runtime->buffer_size - hwptr_done;
96
- int blen = cnt * usX2Y->stride;
97
- memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, blen);
98
- memcpy(runtime->dma_area, cp + blen, len * usX2Y->stride - blen);
82
+ int blen = cnt * usx2y->stride;
83
+ memcpy(runtime->dma_area + hwptr_done * usx2y->stride, cp, blen);
84
+ memcpy(runtime->dma_area, cp + blen, len * usx2y->stride - blen);
9985 } else {
100
- memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp,
101
- len * usX2Y->stride);
86
+ memcpy(runtime->dma_area + hwptr_done * usx2y->stride, cp,
87
+ len * usx2y->stride);
10288 }
10389 lens += len;
10490 if ((hwptr_done += len) >= runtime->buffer_size)
....@@ -124,18 +110,18 @@
124110 * it directly from the buffer. thus the data is once copied to
125111 * a temporary buffer and urb points to that.
126112 */
127
-static int usX2Y_urb_play_prepare(struct snd_usX2Y_substream *subs,
113
+static int usx2y_urb_play_prepare(struct snd_usx2y_substream *subs,
128114 struct urb *cap_urb,
129115 struct urb *urb)
130116 {
131117 int count, counts, pack;
132
- struct usX2Ydev *usX2Y = subs->usX2Y;
118
+ struct usx2ydev *usx2y = subs->usx2y;
133119 struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime;
134120
135121 count = 0;
136122 for (pack = 0; pack < nr_of_packs(); pack++) {
137123 /* calculate the size of a packet */
138
- counts = cap_urb->iso_frame_desc[pack].actual_length / usX2Y->stride;
124
+ counts = cap_urb->iso_frame_desc[pack].actual_length / usx2y->stride;
139125 count += counts;
140126 if (counts < 43 || counts > 50) {
141127 snd_printk(KERN_ERR "should not be here with counts=%i\n", counts);
....@@ -148,7 +134,7 @@
148134 0;
149135 urb->iso_frame_desc[pack].length = cap_urb->iso_frame_desc[pack].actual_length;
150136 }
151
- if (atomic_read(&subs->state) >= state_PRERUNNING)
137
+ if (atomic_read(&subs->state) >= STATE_PRERUNNING)
152138 if (subs->hwptr + count > runtime->buffer_size) {
153139 /* err, the transferred area goes over buffer boundary.
154140 * copy the data to the temp buffer.
....@@ -157,20 +143,20 @@
157143 len = runtime->buffer_size - subs->hwptr;
158144 urb->transfer_buffer = subs->tmpbuf;
159145 memcpy(subs->tmpbuf, runtime->dma_area +
160
- subs->hwptr * usX2Y->stride, len * usX2Y->stride);
161
- memcpy(subs->tmpbuf + len * usX2Y->stride,
162
- runtime->dma_area, (count - len) * usX2Y->stride);
146
+ subs->hwptr * usx2y->stride, len * usx2y->stride);
147
+ memcpy(subs->tmpbuf + len * usx2y->stride,
148
+ runtime->dma_area, (count - len) * usx2y->stride);
163149 subs->hwptr += count;
164150 subs->hwptr -= runtime->buffer_size;
165151 } else {
166152 /* set the buffer pointer */
167
- urb->transfer_buffer = runtime->dma_area + subs->hwptr * usX2Y->stride;
153
+ urb->transfer_buffer = runtime->dma_area + subs->hwptr * usx2y->stride;
168154 if ((subs->hwptr += count) >= runtime->buffer_size)
169155 subs->hwptr -= runtime->buffer_size;
170156 }
171157 else
172158 urb->transfer_buffer = subs->tmpbuf;
173
- urb->transfer_buffer_length = count * usX2Y->stride;
159
+ urb->transfer_buffer_length = count * usx2y->stride;
174160 return 0;
175161 }
176162
....@@ -179,10 +165,10 @@
179165 *
180166 * update the current position and call callback if a period is processed.
181167 */
182
-static void usX2Y_urb_play_retire(struct snd_usX2Y_substream *subs, struct urb *urb)
168
+static void usx2y_urb_play_retire(struct snd_usx2y_substream *subs, struct urb *urb)
183169 {
184170 struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime;
185
- int len = urb->actual_length / subs->usX2Y->stride;
171
+ int len = urb->actual_length / subs->usx2y->stride;
186172
187173 subs->transfer_done += len;
188174 subs->hwptr_done += len;
....@@ -194,14 +180,14 @@
194180 }
195181 }
196182
197
-static int usX2Y_urb_submit(struct snd_usX2Y_substream *subs, struct urb *urb, int frame)
183
+static int usx2y_urb_submit(struct snd_usx2y_substream *subs, struct urb *urb, int frame)
198184 {
199185 int err;
200186 if (!urb)
201187 return -ENODEV;
202188 urb->start_frame = (frame + NRURBS * nr_of_packs()); // let hcd do rollover sanity checks
203189 urb->hcpriv = NULL;
204
- urb->dev = subs->usX2Y->dev; /* we need to set this at each time */
190
+ urb->dev = subs->usx2y->dev; /* we need to set this at each time */
205191 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
206192 snd_printk(KERN_ERR "usb_submit_urb() returned %i\n", err);
207193 return err;
....@@ -209,8 +195,8 @@
209195 return 0;
210196 }
211197
212
-static inline int usX2Y_usbframe_complete(struct snd_usX2Y_substream *capsubs,
213
- struct snd_usX2Y_substream *playbacksubs,
198
+static inline int usx2y_usbframe_complete(struct snd_usx2y_substream *capsubs,
199
+ struct snd_usx2y_substream *playbacksubs,
214200 int frame)
215201 {
216202 int err, state;
....@@ -218,25 +204,25 @@
218204
219205 state = atomic_read(&playbacksubs->state);
220206 if (NULL != urb) {
221
- if (state == state_RUNNING)
222
- usX2Y_urb_play_retire(playbacksubs, urb);
223
- else if (state >= state_PRERUNNING)
207
+ if (state == STATE_RUNNING)
208
+ usx2y_urb_play_retire(playbacksubs, urb);
209
+ else if (state >= STATE_PRERUNNING)
224210 atomic_inc(&playbacksubs->state);
225211 } else {
226212 switch (state) {
227
- case state_STARTING1:
213
+ case STATE_STARTING1:
228214 urb = playbacksubs->urb[0];
229215 atomic_inc(&playbacksubs->state);
230216 break;
231
- case state_STARTING2:
217
+ case STATE_STARTING2:
232218 urb = playbacksubs->urb[1];
233219 atomic_inc(&playbacksubs->state);
234220 break;
235221 }
236222 }
237223 if (urb) {
238
- if ((err = usX2Y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) ||
239
- (err = usX2Y_urb_submit(playbacksubs, urb, frame))) {
224
+ if ((err = usx2y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) ||
225
+ (err = usx2y_urb_submit(playbacksubs, urb, frame))) {
240226 return err;
241227 }
242228 }
....@@ -244,13 +230,13 @@
244230 playbacksubs->completed_urb = NULL;
245231
246232 state = atomic_read(&capsubs->state);
247
- if (state >= state_PREPARED) {
248
- if (state == state_RUNNING) {
249
- if ((err = usX2Y_urb_capt_retire(capsubs)))
233
+ if (state >= STATE_PREPARED) {
234
+ if (state == STATE_RUNNING) {
235
+ if ((err = usx2y_urb_capt_retire(capsubs)))
250236 return err;
251
- } else if (state >= state_PRERUNNING)
237
+ } else if (state >= STATE_PRERUNNING)
252238 atomic_inc(&capsubs->state);
253
- if ((err = usX2Y_urb_submit(capsubs, capsubs->completed_urb, frame)))
239
+ if ((err = usx2y_urb_submit(capsubs, capsubs->completed_urb, frame)))
254240 return err;
255241 }
256242 capsubs->completed_urb = NULL;
....@@ -258,21 +244,21 @@
258244 }
259245
260246
261
-static void usX2Y_clients_stop(struct usX2Ydev *usX2Y)
247
+static void usx2y_clients_stop(struct usx2ydev *usx2y)
262248 {
263249 int s, u;
264250
265251 for (s = 0; s < 4; s++) {
266
- struct snd_usX2Y_substream *subs = usX2Y->subs[s];
252
+ struct snd_usx2y_substream *subs = usx2y->subs[s];
267253 if (subs) {
268254 snd_printdd("%i %p state=%i\n", s, subs, atomic_read(&subs->state));
269
- atomic_set(&subs->state, state_STOPPED);
255
+ atomic_set(&subs->state, STATE_STOPPED);
270256 }
271257 }
272258 for (s = 0; s < 4; s++) {
273
- struct snd_usX2Y_substream *subs = usX2Y->subs[s];
259
+ struct snd_usx2y_substream *subs = usx2y->subs[s];
274260 if (subs) {
275
- if (atomic_read(&subs->state) >= state_PRERUNNING)
261
+ if (atomic_read(&subs->state) >= STATE_PRERUNNING)
276262 snd_pcm_stop_xrun(subs->pcm_substream);
277263 for (u = 0; u < NRURBS; u++) {
278264 struct urb *urb = subs->urb[u];
....@@ -282,60 +268,60 @@
282268 }
283269 }
284270 }
285
- usX2Y->prepare_subs = NULL;
286
- wake_up(&usX2Y->prepare_wait_queue);
271
+ usx2y->prepare_subs = NULL;
272
+ wake_up(&usx2y->prepare_wait_queue);
287273 }
288274
289
-static void usX2Y_error_urb_status(struct usX2Ydev *usX2Y,
290
- struct snd_usX2Y_substream *subs, struct urb *urb)
275
+static void usx2y_error_urb_status(struct usx2ydev *usx2y,
276
+ struct snd_usx2y_substream *subs, struct urb *urb)
291277 {
292278 snd_printk(KERN_ERR "ep=%i stalled with status=%i\n", subs->endpoint, urb->status);
293279 urb->status = 0;
294
- usX2Y_clients_stop(usX2Y);
280
+ usx2y_clients_stop(usx2y);
295281 }
296282
297
-static void i_usX2Y_urb_complete(struct urb *urb)
283
+static void i_usx2y_urb_complete(struct urb *urb)
298284 {
299
- struct snd_usX2Y_substream *subs = urb->context;
300
- struct usX2Ydev *usX2Y = subs->usX2Y;
285
+ struct snd_usx2y_substream *subs = urb->context;
286
+ struct usx2ydev *usx2y = subs->usx2y;
301287
302
- if (unlikely(atomic_read(&subs->state) < state_PREPARED)) {
288
+ if (unlikely(atomic_read(&subs->state) < STATE_PREPARED)) {
303289 snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n",
304
- usb_get_current_frame_number(usX2Y->dev),
290
+ usb_get_current_frame_number(usx2y->dev),
305291 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out",
306292 urb->status, urb->start_frame);
307293 return;
308294 }
309295 if (unlikely(urb->status)) {
310
- usX2Y_error_urb_status(usX2Y, subs, urb);
296
+ usx2y_error_urb_status(usx2y, subs, urb);
311297 return;
312298 }
313299
314300 subs->completed_urb = urb;
315301
316302 {
317
- struct snd_usX2Y_substream *capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE],
318
- *playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK];
303
+ struct snd_usx2y_substream *capsubs = usx2y->subs[SNDRV_PCM_STREAM_CAPTURE],
304
+ *playbacksubs = usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK];
319305 if (capsubs->completed_urb &&
320
- atomic_read(&capsubs->state) >= state_PREPARED &&
306
+ atomic_read(&capsubs->state) >= STATE_PREPARED &&
321307 (playbacksubs->completed_urb ||
322
- atomic_read(&playbacksubs->state) < state_PREPARED)) {
323
- if (!usX2Y_usbframe_complete(capsubs, playbacksubs, urb->start_frame))
324
- usX2Y->wait_iso_frame += nr_of_packs();
308
+ atomic_read(&playbacksubs->state) < STATE_PREPARED)) {
309
+ if (!usx2y_usbframe_complete(capsubs, playbacksubs, urb->start_frame))
310
+ usx2y->wait_iso_frame += nr_of_packs();
325311 else {
326312 snd_printdd("\n");
327
- usX2Y_clients_stop(usX2Y);
313
+ usx2y_clients_stop(usx2y);
328314 }
329315 }
330316 }
331317 }
332318
333
-static void usX2Y_urbs_set_complete(struct usX2Ydev * usX2Y,
319
+static void usx2y_urbs_set_complete(struct usx2ydev * usx2y,
334320 void (*complete)(struct urb *))
335321 {
336322 int s, u;
337323 for (s = 0; s < 4; s++) {
338
- struct snd_usX2Y_substream *subs = usX2Y->subs[s];
324
+ struct snd_usx2y_substream *subs = usx2y->subs[s];
339325 if (NULL != subs)
340326 for (u = 0; u < NRURBS; u++) {
341327 struct urb * urb = subs->urb[u];
....@@ -345,30 +331,30 @@
345331 }
346332 }
347333
348
-static void usX2Y_subs_startup_finish(struct usX2Ydev * usX2Y)
334
+static void usx2y_subs_startup_finish(struct usx2ydev * usx2y)
349335 {
350
- usX2Y_urbs_set_complete(usX2Y, i_usX2Y_urb_complete);
351
- usX2Y->prepare_subs = NULL;
336
+ usx2y_urbs_set_complete(usx2y, i_usx2y_urb_complete);
337
+ usx2y->prepare_subs = NULL;
352338 }
353339
354
-static void i_usX2Y_subs_startup(struct urb *urb)
340
+static void i_usx2y_subs_startup(struct urb *urb)
355341 {
356
- struct snd_usX2Y_substream *subs = urb->context;
357
- struct usX2Ydev *usX2Y = subs->usX2Y;
358
- struct snd_usX2Y_substream *prepare_subs = usX2Y->prepare_subs;
342
+ struct snd_usx2y_substream *subs = urb->context;
343
+ struct usx2ydev *usx2y = subs->usx2y;
344
+ struct snd_usx2y_substream *prepare_subs = usx2y->prepare_subs;
359345 if (NULL != prepare_subs)
360346 if (urb->start_frame == prepare_subs->urb[0]->start_frame) {
361
- usX2Y_subs_startup_finish(usX2Y);
347
+ usx2y_subs_startup_finish(usx2y);
362348 atomic_inc(&prepare_subs->state);
363
- wake_up(&usX2Y->prepare_wait_queue);
349
+ wake_up(&usx2y->prepare_wait_queue);
364350 }
365351
366
- i_usX2Y_urb_complete(urb);
352
+ i_usx2y_urb_complete(urb);
367353 }
368354
369
-static void usX2Y_subs_prepare(struct snd_usX2Y_substream *subs)
355
+static void usx2y_subs_prepare(struct snd_usx2y_substream *subs)
370356 {
371
- snd_printdd("usX2Y_substream_prepare(%p) ep=%i urb0=%p urb1=%p\n",
357
+ snd_printdd("usx2y_substream_prepare(%p) ep=%i urb0=%p urb1=%p\n",
372358 subs, subs->endpoint, subs->urb[0], subs->urb[1]);
373359 /* reset the pointer */
374360 subs->hwptr = 0;
....@@ -377,7 +363,7 @@
377363 }
378364
379365
380
-static void usX2Y_urb_release(struct urb **urb, int free_tb)
366
+static void usx2y_urb_release(struct urb **urb, int free_tb)
381367 {
382368 if (*urb) {
383369 usb_kill_urb(*urb);
....@@ -390,13 +376,13 @@
390376 /*
391377 * release a substreams urbs
392378 */
393
-static void usX2Y_urbs_release(struct snd_usX2Y_substream *subs)
379
+static void usx2y_urbs_release(struct snd_usx2y_substream *subs)
394380 {
395381 int i;
396
- snd_printdd("usX2Y_urbs_release() %i\n", subs->endpoint);
382
+ snd_printdd("usx2y_urbs_release() %i\n", subs->endpoint);
397383 for (i = 0; i < NRURBS; i++)
398
- usX2Y_urb_release(subs->urb + i,
399
- subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]);
384
+ usx2y_urb_release(subs->urb + i,
385
+ subs != subs->usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK]);
400386
401387 kfree(subs->tmpbuf);
402388 subs->tmpbuf = NULL;
....@@ -404,12 +390,12 @@
404390 /*
405391 * initialize a substream's urbs
406392 */
407
-static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs)
393
+static int usx2y_urbs_allocate(struct snd_usx2y_substream *subs)
408394 {
409395 int i;
410396 unsigned int pipe;
411
- int is_playback = subs == subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK];
412
- struct usb_device *dev = subs->usX2Y->dev;
397
+ int is_playback = subs == subs->usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK];
398
+ struct usb_device *dev = subs->usx2y->dev;
413399
414400 pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) :
415401 usb_rcvisocpipe(dev, subs->endpoint);
....@@ -431,7 +417,7 @@
431417 }
432418 *purb = usb_alloc_urb(nr_of_packs(), GFP_KERNEL);
433419 if (NULL == *purb) {
434
- usX2Y_urbs_release(subs);
420
+ usx2y_urbs_release(subs);
435421 return -ENOMEM;
436422 }
437423 if (!is_playback && !(*purb)->transfer_buffer) {
....@@ -440,7 +426,7 @@
440426 kmalloc_array(subs->maxpacksize,
441427 nr_of_packs(), GFP_KERNEL);
442428 if (NULL == (*purb)->transfer_buffer) {
443
- usX2Y_urbs_release(subs);
429
+ usx2y_urbs_release(subs);
444430 return -ENOMEM;
445431 }
446432 }
....@@ -449,43 +435,43 @@
449435 (*purb)->number_of_packets = nr_of_packs();
450436 (*purb)->context = subs;
451437 (*purb)->interval = 1;
452
- (*purb)->complete = i_usX2Y_subs_startup;
438
+ (*purb)->complete = i_usx2y_subs_startup;
453439 }
454440 return 0;
455441 }
456442
457
-static void usX2Y_subs_startup(struct snd_usX2Y_substream *subs)
443
+static void usx2y_subs_startup(struct snd_usx2y_substream *subs)
458444 {
459
- struct usX2Ydev *usX2Y = subs->usX2Y;
460
- usX2Y->prepare_subs = subs;
445
+ struct usx2ydev *usx2y = subs->usx2y;
446
+ usx2y->prepare_subs = subs;
461447 subs->urb[0]->start_frame = -1;
462448 wmb();
463
- usX2Y_urbs_set_complete(usX2Y, i_usX2Y_subs_startup);
449
+ usx2y_urbs_set_complete(usx2y, i_usx2y_subs_startup);
464450 }
465451
466
-static int usX2Y_urbs_start(struct snd_usX2Y_substream *subs)
452
+static int usx2y_urbs_start(struct snd_usx2y_substream *subs)
467453 {
468454 int i, err;
469
- struct usX2Ydev *usX2Y = subs->usX2Y;
455
+ struct usx2ydev *usx2y = subs->usx2y;
470456
471
- if ((err = usX2Y_urbs_allocate(subs)) < 0)
457
+ if ((err = usx2y_urbs_allocate(subs)) < 0)
472458 return err;
473459 subs->completed_urb = NULL;
474460 for (i = 0; i < 4; i++) {
475
- struct snd_usX2Y_substream *subs = usX2Y->subs[i];
476
- if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED)
461
+ struct snd_usx2y_substream *subs = usx2y->subs[i];
462
+ if (subs != NULL && atomic_read(&subs->state) >= STATE_PREPARED)
477463 goto start;
478464 }
479465
480466 start:
481
- usX2Y_subs_startup(subs);
467
+ usx2y_subs_startup(subs);
482468 for (i = 0; i < NRURBS; i++) {
483469 struct urb *urb = subs->urb[i];
484470 if (usb_pipein(urb->pipe)) {
485471 unsigned long pack;
486472 if (0 == i)
487
- atomic_set(&subs->state, state_STARTING3);
488
- urb->dev = usX2Y->dev;
473
+ atomic_set(&subs->state, STATE_STARTING3);
474
+ urb->dev = usx2y->dev;
489475 for (pack = 0; pack < nr_of_packs(); pack++) {
490476 urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack;
491477 urb->iso_frame_desc[pack].length = subs->maxpacksize;
....@@ -497,22 +483,22 @@
497483 goto cleanup;
498484 } else
499485 if (i == 0)
500
- usX2Y->wait_iso_frame = urb->start_frame;
486
+ usx2y->wait_iso_frame = urb->start_frame;
501487 urb->transfer_flags = 0;
502488 } else {
503
- atomic_set(&subs->state, state_STARTING1);
489
+ atomic_set(&subs->state, STATE_STARTING1);
504490 break;
505491 }
506492 }
507493 err = 0;
508
- wait_event(usX2Y->prepare_wait_queue, NULL == usX2Y->prepare_subs);
509
- if (atomic_read(&subs->state) != state_PREPARED)
494
+ wait_event(usx2y->prepare_wait_queue, NULL == usx2y->prepare_subs);
495
+ if (atomic_read(&subs->state) != STATE_PREPARED)
510496 err = -EPIPE;
511497
512498 cleanup:
513499 if (err) {
514
- usX2Y_subs_startup_finish(usX2Y);
515
- usX2Y_clients_stop(usX2Y); // something is completely wroong > stop evrything
500
+ usx2y_subs_startup_finish(usx2y);
501
+ usx2y_clients_stop(usx2y); // something is completely wroong > stop evrything
516502 }
517503 return err;
518504 }
....@@ -520,33 +506,33 @@
520506 /*
521507 * return the current pcm pointer. just return the hwptr_done value.
522508 */
523
-static snd_pcm_uframes_t snd_usX2Y_pcm_pointer(struct snd_pcm_substream *substream)
509
+static snd_pcm_uframes_t snd_usx2y_pcm_pointer(struct snd_pcm_substream *substream)
524510 {
525
- struct snd_usX2Y_substream *subs = substream->runtime->private_data;
511
+ struct snd_usx2y_substream *subs = substream->runtime->private_data;
526512 return subs->hwptr_done;
527513 }
528514 /*
529515 * start/stop substream
530516 */
531
-static int snd_usX2Y_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
517
+static int snd_usx2y_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
532518 {
533
- struct snd_usX2Y_substream *subs = substream->runtime->private_data;
519
+ struct snd_usx2y_substream *subs = substream->runtime->private_data;
534520
535521 switch (cmd) {
536522 case SNDRV_PCM_TRIGGER_START:
537
- snd_printdd("snd_usX2Y_pcm_trigger(START)\n");
538
- if (atomic_read(&subs->state) == state_PREPARED &&
539
- atomic_read(&subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]->state) >= state_PREPARED) {
540
- atomic_set(&subs->state, state_PRERUNNING);
523
+ snd_printdd("snd_usx2y_pcm_trigger(START)\n");
524
+ if (atomic_read(&subs->state) == STATE_PREPARED &&
525
+ atomic_read(&subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE]->state) >= STATE_PREPARED) {
526
+ atomic_set(&subs->state, STATE_PRERUNNING);
541527 } else {
542528 snd_printdd("\n");
543529 return -EPIPE;
544530 }
545531 break;
546532 case SNDRV_PCM_TRIGGER_STOP:
547
- snd_printdd("snd_usX2Y_pcm_trigger(STOP)\n");
548
- if (atomic_read(&subs->state) >= state_PRERUNNING)
549
- atomic_set(&subs->state, state_PREPARED);
533
+ snd_printdd("snd_usx2y_pcm_trigger(STOP)\n");
534
+ if (atomic_read(&subs->state) >= STATE_PRERUNNING)
535
+ atomic_set(&subs->state, STATE_PREPARED);
550536 break;
551537 default:
552538 return -EINVAL;
....@@ -563,11 +549,11 @@
563549 * if sg buffer is supported on the later version of alsa, we'll follow
564550 * that.
565551 */
566
-static struct s_c2
552
+static const struct s_c2
567553 {
568554 char c1, c2;
569555 }
570
- SetRate44100[] =
556
+ setrate_44100[] =
571557 {
572558 { 0x14, 0x08}, // this line sets 44100, well actually a little less
573559 { 0x18, 0x40}, // only tascam / frontier design knows the further lines .......
....@@ -603,7 +589,7 @@
603589 { 0x18, 0x7C},
604590 { 0x18, 0x7E}
605591 };
606
-static struct s_c2 SetRate48000[] =
592
+static const struct s_c2 setrate_48000[] =
607593 {
608594 { 0x14, 0x09}, // this line sets 48000, well actually a little less
609595 { 0x18, 0x40}, // only tascam / frontier design knows the further lines .......
....@@ -639,26 +625,26 @@
639625 { 0x18, 0x7C},
640626 { 0x18, 0x7E}
641627 };
642
-#define NOOF_SETRATE_URBS ARRAY_SIZE(SetRate48000)
628
+#define NOOF_SETRATE_URBS ARRAY_SIZE(setrate_48000)
643629
644
-static void i_usX2Y_04Int(struct urb *urb)
630
+static void i_usx2y_04int(struct urb *urb)
645631 {
646
- struct usX2Ydev *usX2Y = urb->context;
632
+ struct usx2ydev *usx2y = urb->context;
647633
648634 if (urb->status)
649
- snd_printk(KERN_ERR "snd_usX2Y_04Int() urb->status=%i\n", urb->status);
650
- if (0 == --usX2Y->US04->len)
651
- wake_up(&usX2Y->In04WaitQueue);
635
+ snd_printk(KERN_ERR "snd_usx2y_04int() urb->status=%i\n", urb->status);
636
+ if (0 == --usx2y->us04->len)
637
+ wake_up(&usx2y->in04_wait_queue);
652638 }
653639
654
-static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate)
640
+static int usx2y_rate_set(struct usx2ydev *usx2y, int rate)
655641 {
656642 int err = 0, i;
657
- struct snd_usX2Y_urbSeq *us = NULL;
643
+ struct snd_usx2y_urb_seq *us = NULL;
658644 int *usbdata = NULL;
659
- struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100;
645
+ const struct s_c2 *ra = rate == 48000 ? setrate_48000 : setrate_44100;
660646
661
- if (usX2Y->rate != rate) {
647
+ if (usx2y->rate != rate) {
662648 us = kzalloc(sizeof(*us) + sizeof(struct urb*) * NOOF_SETRATE_URBS, GFP_KERNEL);
663649 if (NULL == us) {
664650 err = -ENOMEM;
....@@ -677,17 +663,17 @@
677663 }
678664 ((char*)(usbdata + i))[0] = ra[i].c1;
679665 ((char*)(usbdata + i))[1] = ra[i].c2;
680
- usb_fill_bulk_urb(us->urb[i], usX2Y->dev, usb_sndbulkpipe(usX2Y->dev, 4),
681
- usbdata + i, 2, i_usX2Y_04Int, usX2Y);
666
+ usb_fill_bulk_urb(us->urb[i], usx2y->dev, usb_sndbulkpipe(usx2y->dev, 4),
667
+ usbdata + i, 2, i_usx2y_04int, usx2y);
682668 }
683669 err = usb_urb_ep_type_check(us->urb[0]);
684670 if (err < 0)
685671 goto cleanup;
686672 us->submitted = 0;
687673 us->len = NOOF_SETRATE_URBS;
688
- usX2Y->US04 = us;
689
- wait_event_timeout(usX2Y->In04WaitQueue, 0 == us->len, HZ);
690
- usX2Y->US04 = NULL;
674
+ usx2y->us04 = us;
675
+ wait_event_timeout(usx2y->in04_wait_queue, 0 == us->len, HZ);
676
+ usx2y->us04 = NULL;
691677 if (us->len)
692678 err = -ENODEV;
693679 cleanup:
....@@ -704,11 +690,11 @@
704690 }
705691 usb_free_urb(urb);
706692 }
707
- usX2Y->US04 = NULL;
693
+ usx2y->us04 = NULL;
708694 kfree(usbdata);
709695 kfree(us);
710696 if (!err)
711
- usX2Y->rate = rate;
697
+ usx2y->rate = rate;
712698 }
713699 }
714700
....@@ -716,53 +702,53 @@
716702 }
717703
718704
719
-static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format)
705
+static int usx2y_format_set(struct usx2ydev *usx2y, snd_pcm_format_t format)
720706 {
721707 int alternate, err;
722708 struct list_head* p;
723709 if (format == SNDRV_PCM_FORMAT_S24_3LE) {
724710 alternate = 2;
725
- usX2Y->stride = 6;
711
+ usx2y->stride = 6;
726712 } else {
727713 alternate = 1;
728
- usX2Y->stride = 4;
714
+ usx2y->stride = 4;
729715 }
730
- list_for_each(p, &usX2Y->midi_list) {
716
+ list_for_each(p, &usx2y->midi_list) {
731717 snd_usbmidi_input_stop(p);
732718 }
733
- usb_kill_urb(usX2Y->In04urb);
734
- if ((err = usb_set_interface(usX2Y->dev, 0, alternate))) {
719
+ usb_kill_urb(usx2y->in04_urb);
720
+ if ((err = usb_set_interface(usx2y->dev, 0, alternate))) {
735721 snd_printk(KERN_ERR "usb_set_interface error \n");
736722 return err;
737723 }
738
- usX2Y->In04urb->dev = usX2Y->dev;
739
- err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL);
740
- list_for_each(p, &usX2Y->midi_list) {
724
+ usx2y->in04_urb->dev = usx2y->dev;
725
+ err = usb_submit_urb(usx2y->in04_urb, GFP_KERNEL);
726
+ list_for_each(p, &usx2y->midi_list) {
741727 snd_usbmidi_input_start(p);
742728 }
743
- usX2Y->format = format;
744
- usX2Y->rate = 0;
729
+ usx2y->format = format;
730
+ usx2y->rate = 0;
745731 return err;
746732 }
747733
748734
749
-static int snd_usX2Y_pcm_hw_params(struct snd_pcm_substream *substream,
735
+static int snd_usx2y_pcm_hw_params(struct snd_pcm_substream *substream,
750736 struct snd_pcm_hw_params *hw_params)
751737 {
752738 int err = 0;
753739 unsigned int rate = params_rate(hw_params);
754740 snd_pcm_format_t format = params_format(hw_params);
755741 struct snd_card *card = substream->pstr->pcm->card;
756
- struct usX2Ydev *dev = usX2Y(card);
742
+ struct usx2ydev *dev = usx2y(card);
757743 int i;
758744
759
- mutex_lock(&usX2Y(card)->pcm_mutex);
760
- snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params);
761
- /* all pcm substreams off one usX2Y have to operate at the same
745
+ mutex_lock(&usx2y(card)->pcm_mutex);
746
+ snd_printdd("snd_usx2y_hw_params(%p, %p)\n", substream, hw_params);
747
+ /* all pcm substreams off one usx2y have to operate at the same
762748 * rate & format
763749 */
764750 for (i = 0; i < dev->pcm_devs * 2; i++) {
765
- struct snd_usX2Y_substream *subs = dev->subs[i];
751
+ struct snd_usx2y_substream *subs = dev->subs[i];
766752 struct snd_pcm_substream *test_substream;
767753
768754 if (!subs)
....@@ -780,89 +766,81 @@
780766 }
781767 }
782768
783
- err = snd_pcm_lib_malloc_pages(substream,
784
- params_buffer_bytes(hw_params));
785
- if (err < 0) {
786
- snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n",
787
- substream, params_buffer_bytes(hw_params), err);
788
- goto error;
789
- }
790
-
791769 error:
792
- mutex_unlock(&usX2Y(card)->pcm_mutex);
770
+ mutex_unlock(&usx2y(card)->pcm_mutex);
793771 return err;
794772 }
795773
796774 /*
797775 * free the buffer
798776 */
799
-static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream)
777
+static int snd_usx2y_pcm_hw_free(struct snd_pcm_substream *substream)
800778 {
801779 struct snd_pcm_runtime *runtime = substream->runtime;
802
- struct snd_usX2Y_substream *subs = runtime->private_data;
803
- mutex_lock(&subs->usX2Y->pcm_mutex);
804
- snd_printdd("snd_usX2Y_hw_free(%p)\n", substream);
780
+ struct snd_usx2y_substream *subs = runtime->private_data;
781
+ mutex_lock(&subs->usx2y->pcm_mutex);
782
+ snd_printdd("snd_usx2y_hw_free(%p)\n", substream);
805783
806784 if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
807
- struct snd_usX2Y_substream *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE];
808
- atomic_set(&subs->state, state_STOPPED);
809
- usX2Y_urbs_release(subs);
785
+ struct snd_usx2y_substream *cap_subs = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE];
786
+ atomic_set(&subs->state, STATE_STOPPED);
787
+ usx2y_urbs_release(subs);
810788 if (!cap_subs->pcm_substream ||
811789 !cap_subs->pcm_substream->runtime ||
812790 !cap_subs->pcm_substream->runtime->status ||
813791 cap_subs->pcm_substream->runtime->status->state < SNDRV_PCM_STATE_PREPARED) {
814
- atomic_set(&cap_subs->state, state_STOPPED);
815
- usX2Y_urbs_release(cap_subs);
792
+ atomic_set(&cap_subs->state, STATE_STOPPED);
793
+ usx2y_urbs_release(cap_subs);
816794 }
817795 } else {
818
- struct snd_usX2Y_substream *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK];
819
- if (atomic_read(&playback_subs->state) < state_PREPARED) {
820
- atomic_set(&subs->state, state_STOPPED);
821
- usX2Y_urbs_release(subs);
796
+ struct snd_usx2y_substream *playback_subs = subs->usx2y->subs[SNDRV_PCM_STREAM_PLAYBACK];
797
+ if (atomic_read(&playback_subs->state) < STATE_PREPARED) {
798
+ atomic_set(&subs->state, STATE_STOPPED);
799
+ usx2y_urbs_release(subs);
822800 }
823801 }
824
- mutex_unlock(&subs->usX2Y->pcm_mutex);
825
- return snd_pcm_lib_free_pages(substream);
802
+ mutex_unlock(&subs->usx2y->pcm_mutex);
803
+ return 0;
826804 }
827805 /*
828806 * prepare callback
829807 *
830808 * set format and initialize urbs
831809 */
832
-static int snd_usX2Y_pcm_prepare(struct snd_pcm_substream *substream)
810
+static int snd_usx2y_pcm_prepare(struct snd_pcm_substream *substream)
833811 {
834812 struct snd_pcm_runtime *runtime = substream->runtime;
835
- struct snd_usX2Y_substream *subs = runtime->private_data;
836
- struct usX2Ydev *usX2Y = subs->usX2Y;
837
- struct snd_usX2Y_substream *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE];
813
+ struct snd_usx2y_substream *subs = runtime->private_data;
814
+ struct usx2ydev *usx2y = subs->usx2y;
815
+ struct snd_usx2y_substream *capsubs = subs->usx2y->subs[SNDRV_PCM_STREAM_CAPTURE];
838816 int err = 0;
839
- snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream);
817
+ snd_printdd("snd_usx2y_pcm_prepare(%p)\n", substream);
840818
841
- mutex_lock(&usX2Y->pcm_mutex);
842
- usX2Y_subs_prepare(subs);
819
+ mutex_lock(&usx2y->pcm_mutex);
820
+ usx2y_subs_prepare(subs);
843821 // Start hardware streams
844822 // SyncStream first....
845
- if (atomic_read(&capsubs->state) < state_PREPARED) {
846
- if (usX2Y->format != runtime->format)
847
- if ((err = usX2Y_format_set(usX2Y, runtime->format)) < 0)
823
+ if (atomic_read(&capsubs->state) < STATE_PREPARED) {
824
+ if (usx2y->format != runtime->format)
825
+ if ((err = usx2y_format_set(usx2y, runtime->format)) < 0)
848826 goto up_prepare_mutex;
849
- if (usX2Y->rate != runtime->rate)
850
- if ((err = usX2Y_rate_set(usX2Y, runtime->rate)) < 0)
827
+ if (usx2y->rate != runtime->rate)
828
+ if ((err = usx2y_rate_set(usx2y, runtime->rate)) < 0)
851829 goto up_prepare_mutex;
852830 snd_printdd("starting capture pipe for %s\n", subs == capsubs ? "self" : "playpipe");
853
- if (0 > (err = usX2Y_urbs_start(capsubs)))
831
+ if (0 > (err = usx2y_urbs_start(capsubs)))
854832 goto up_prepare_mutex;
855833 }
856834
857
- if (subs != capsubs && atomic_read(&subs->state) < state_PREPARED)
858
- err = usX2Y_urbs_start(subs);
835
+ if (subs != capsubs && atomic_read(&subs->state) < STATE_PREPARED)
836
+ err = usx2y_urbs_start(subs);
859837
860838 up_prepare_mutex:
861
- mutex_unlock(&usX2Y->pcm_mutex);
839
+ mutex_unlock(&usx2y->pcm_mutex);
862840 return err;
863841 }
864842
865
-static struct snd_pcm_hardware snd_usX2Y_2c =
843
+static const struct snd_pcm_hardware snd_usx2y_2c =
866844 {
867845 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
868846 SNDRV_PCM_INFO_BLOCK_TRANSFER |
....@@ -884,16 +862,16 @@
884862
885863
886864
887
-static int snd_usX2Y_pcm_open(struct snd_pcm_substream *substream)
865
+static int snd_usx2y_pcm_open(struct snd_pcm_substream *substream)
888866 {
889
- struct snd_usX2Y_substream *subs = ((struct snd_usX2Y_substream **)
867
+ struct snd_usx2y_substream *subs = ((struct snd_usx2y_substream **)
890868 snd_pcm_substream_chip(substream))[substream->stream];
891869 struct snd_pcm_runtime *runtime = substream->runtime;
892870
893
- if (subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS)
871
+ if (subs->usx2y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS)
894872 return -EBUSY;
895873
896
- runtime->hw = snd_usX2Y_2c;
874
+ runtime->hw = snd_usx2y_2c;
897875 runtime->private_data = subs;
898876 subs->pcm_substream = substream;
899877 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 1000, 200000);
....@@ -902,10 +880,10 @@
902880
903881
904882
905
-static int snd_usX2Y_pcm_close(struct snd_pcm_substream *substream)
883
+static int snd_usx2y_pcm_close(struct snd_pcm_substream *substream)
906884 {
907885 struct snd_pcm_runtime *runtime = substream->runtime;
908
- struct snd_usX2Y_substream *subs = runtime->private_data;
886
+ struct snd_usx2y_substream *subs = runtime->private_data;
909887
910888 subs->pcm_substream = NULL;
911889
....@@ -913,89 +891,88 @@
913891 }
914892
915893
916
-static const struct snd_pcm_ops snd_usX2Y_pcm_ops =
894
+static const struct snd_pcm_ops snd_usx2y_pcm_ops =
917895 {
918
- .open = snd_usX2Y_pcm_open,
919
- .close = snd_usX2Y_pcm_close,
920
- .ioctl = snd_pcm_lib_ioctl,
921
- .hw_params = snd_usX2Y_pcm_hw_params,
922
- .hw_free = snd_usX2Y_pcm_hw_free,
923
- .prepare = snd_usX2Y_pcm_prepare,
924
- .trigger = snd_usX2Y_pcm_trigger,
925
- .pointer = snd_usX2Y_pcm_pointer,
896
+ .open = snd_usx2y_pcm_open,
897
+ .close = snd_usx2y_pcm_close,
898
+ .hw_params = snd_usx2y_pcm_hw_params,
899
+ .hw_free = snd_usx2y_pcm_hw_free,
900
+ .prepare = snd_usx2y_pcm_prepare,
901
+ .trigger = snd_usx2y_pcm_trigger,
902
+ .pointer = snd_usx2y_pcm_pointer,
926903 };
927904
928905
929906 /*
930907 * free a usb stream instance
931908 */
932
-static void usX2Y_audio_stream_free(struct snd_usX2Y_substream **usX2Y_substream)
909
+static void usx2y_audio_stream_free(struct snd_usx2y_substream **usx2y_substream)
933910 {
934
- kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]);
935
- usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK] = NULL;
911
+ int stream;
936912
937
- kfree(usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE]);
938
- usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL;
913
+ for_each_pcm_streams(stream) {
914
+ kfree(usx2y_substream[stream]);
915
+ usx2y_substream[stream] = NULL;
916
+ }
939917 }
940918
941
-static void snd_usX2Y_pcm_private_free(struct snd_pcm *pcm)
919
+static void snd_usx2y_pcm_private_free(struct snd_pcm *pcm)
942920 {
943
- struct snd_usX2Y_substream **usX2Y_stream = pcm->private_data;
944
- if (usX2Y_stream)
945
- usX2Y_audio_stream_free(usX2Y_stream);
921
+ struct snd_usx2y_substream **usx2y_stream = pcm->private_data;
922
+ if (usx2y_stream)
923
+ usx2y_audio_stream_free(usx2y_stream);
946924 }
947925
948
-static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, int capture_endpoint)
926
+static int usx2y_audio_stream_new(struct snd_card *card, int playback_endpoint, int capture_endpoint)
949927 {
950928 struct snd_pcm *pcm;
951929 int err, i;
952
- struct snd_usX2Y_substream **usX2Y_substream =
953
- usX2Y(card)->subs + 2 * usX2Y(card)->pcm_devs;
930
+ struct snd_usx2y_substream **usx2y_substream =
931
+ usx2y(card)->subs + 2 * usx2y(card)->pcm_devs;
954932
955933 for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
956934 i <= SNDRV_PCM_STREAM_CAPTURE; ++i) {
957
- usX2Y_substream[i] = kzalloc(sizeof(struct snd_usX2Y_substream), GFP_KERNEL);
958
- if (!usX2Y_substream[i])
935
+ usx2y_substream[i] = kzalloc(sizeof(struct snd_usx2y_substream), GFP_KERNEL);
936
+ if (!usx2y_substream[i])
959937 return -ENOMEM;
960938
961
- usX2Y_substream[i]->usX2Y = usX2Y(card);
939
+ usx2y_substream[i]->usx2y = usx2y(card);
962940 }
963941
964942 if (playback_endpoint)
965
- usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]->endpoint = playback_endpoint;
966
- usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE]->endpoint = capture_endpoint;
943
+ usx2y_substream[SNDRV_PCM_STREAM_PLAYBACK]->endpoint = playback_endpoint;
944
+ usx2y_substream[SNDRV_PCM_STREAM_CAPTURE]->endpoint = capture_endpoint;
967945
968
- err = snd_pcm_new(card, NAME_ALLCAPS" Audio", usX2Y(card)->pcm_devs,
946
+ err = snd_pcm_new(card, NAME_ALLCAPS" Audio", usx2y(card)->pcm_devs,
969947 playback_endpoint ? 1 : 0, 1,
970948 &pcm);
971949 if (err < 0) {
972
- usX2Y_audio_stream_free(usX2Y_substream);
950
+ usx2y_audio_stream_free(usx2y_substream);
973951 return err;
974952 }
975953
976954 if (playback_endpoint)
977
- snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_usX2Y_pcm_ops);
978
- snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usX2Y_pcm_ops);
955
+ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_usx2y_pcm_ops);
956
+ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usx2y_pcm_ops);
979957
980
- pcm->private_data = usX2Y_substream;
981
- pcm->private_free = snd_usX2Y_pcm_private_free;
958
+ pcm->private_data = usx2y_substream;
959
+ pcm->private_free = snd_usx2y_pcm_private_free;
982960 pcm->info_flags = 0;
983961
984
- sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs);
962
+ sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usx2y(card)->pcm_devs);
985963
986
- if ((playback_endpoint &&
987
- 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
988
- SNDRV_DMA_TYPE_CONTINUOUS,
989
- snd_dma_continuous_data(GFP_KERNEL),
990
- 64*1024, 128*1024))) ||
991
- 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
992
- SNDRV_DMA_TYPE_CONTINUOUS,
993
- snd_dma_continuous_data(GFP_KERNEL),
994
- 64*1024, 128*1024))) {
995
- snd_usX2Y_pcm_private_free(pcm);
996
- return err;
964
+ if (playback_endpoint) {
965
+ snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
966
+ SNDRV_DMA_TYPE_CONTINUOUS,
967
+ NULL,
968
+ 64*1024, 128*1024);
997969 }
998
- usX2Y(card)->pcm_devs++;
970
+
971
+ snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
972
+ SNDRV_DMA_TYPE_CONTINUOUS,
973
+ NULL,
974
+ 64*1024, 128*1024);
975
+ usx2y(card)->pcm_devs++;
999976
1000977 return 0;
1001978 }
....@@ -1003,18 +980,18 @@
1003980 /*
1004981 * create a chip instance and set its names.
1005982 */
1006
-int usX2Y_audio_create(struct snd_card *card)
983
+int usx2y_audio_create(struct snd_card *card)
1007984 {
1008985 int err = 0;
1009986
1010
- INIT_LIST_HEAD(&usX2Y(card)->pcm_list);
987
+ INIT_LIST_HEAD(&usx2y(card)->pcm_list);
1011988
1012
- if (0 > (err = usX2Y_audio_stream_new(card, 0xA, 0x8)))
989
+ if (0 > (err = usx2y_audio_stream_new(card, 0xA, 0x8)))
1013990 return err;
1014
- if (le16_to_cpu(usX2Y(card)->dev->descriptor.idProduct) == USB_ID_US428)
1015
- if (0 > (err = usX2Y_audio_stream_new(card, 0, 0xA)))
991
+ if (le16_to_cpu(usx2y(card)->dev->descriptor.idProduct) == USB_ID_US428)
992
+ if (0 > (err = usx2y_audio_stream_new(card, 0, 0xA)))
1016993 return err;
1017
- if (le16_to_cpu(usX2Y(card)->dev->descriptor.idProduct) != USB_ID_US122)
1018
- err = usX2Y_rate_set(usX2Y(card), 44100); // Lets us428 recognize output-volume settings, disturbs us122.
994
+ if (le16_to_cpu(usx2y(card)->dev->descriptor.idProduct) != USB_ID_US122)
995
+ err = usx2y_rate_set(usx2y(card), 44100); // Lets us428 recognize output-volume settings, disturbs us122.
1019996 return err;
1020997 }