diff options
Diffstat (limited to 'sound/usb/usx2y/usbusx2yaudio.c')
-rw-r--r-- | sound/usb/usx2y/usbusx2yaudio.c | 209 |
1 files changed, 115 insertions, 94 deletions
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index e1dbfbba8fa9..a6bbc7a6348f 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c | |||
@@ -67,18 +67,20 @@ | |||
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | 69 | ||
70 | static int usX2Y_urb_capt_retire(snd_usX2Y_substream_t *subs) | 70 | static int usX2Y_urb_capt_retire(struct snd_usX2Y_substream *subs) |
71 | { | 71 | { |
72 | struct urb *urb = subs->completed_urb; | 72 | struct urb *urb = subs->completed_urb; |
73 | snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; | 73 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
74 | unsigned char *cp; | 74 | unsigned char *cp; |
75 | int i, len, lens = 0, hwptr_done = subs->hwptr_done; | 75 | int i, len, lens = 0, hwptr_done = subs->hwptr_done; |
76 | usX2Ydev_t *usX2Y = subs->usX2Y; | 76 | struct usX2Ydev *usX2Y = subs->usX2Y; |
77 | 77 | ||
78 | for (i = 0; i < nr_of_packs(); i++) { | 78 | for (i = 0; i < nr_of_packs(); i++) { |
79 | cp = (unsigned char*)urb->transfer_buffer + urb->iso_frame_desc[i].offset; | 79 | cp = (unsigned char*)urb->transfer_buffer + urb->iso_frame_desc[i].offset; |
80 | if (urb->iso_frame_desc[i].status) { /* active? hmm, skip this */ | 80 | if (urb->iso_frame_desc[i].status) { /* active? hmm, skip this */ |
81 | snd_printk(KERN_ERR "activ frame status %i. Most propably some hardware problem.\n", urb->iso_frame_desc[i].status); | 81 | snd_printk(KERN_ERR "active frame status %i. " |
82 | "Most propably some hardware problem.\n", | ||
83 | urb->iso_frame_desc[i].status); | ||
82 | return urb->iso_frame_desc[i].status; | 84 | return urb->iso_frame_desc[i].status; |
83 | } | 85 | } |
84 | len = urb->iso_frame_desc[i].actual_length / usX2Y->stride; | 86 | len = urb->iso_frame_desc[i].actual_length / usX2Y->stride; |
@@ -94,7 +96,8 @@ static int usX2Y_urb_capt_retire(snd_usX2Y_substream_t *subs) | |||
94 | memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, blen); | 96 | memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, blen); |
95 | memcpy(runtime->dma_area, cp + blen, len * usX2Y->stride - blen); | 97 | memcpy(runtime->dma_area, cp + blen, len * usX2Y->stride - blen); |
96 | } else { | 98 | } else { |
97 | memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, len * usX2Y->stride); | 99 | memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, |
100 | len * usX2Y->stride); | ||
98 | } | 101 | } |
99 | lens += len; | 102 | lens += len; |
100 | if ((hwptr_done += len) >= runtime->buffer_size) | 103 | if ((hwptr_done += len) >= runtime->buffer_size) |
@@ -120,13 +123,13 @@ static int usX2Y_urb_capt_retire(snd_usX2Y_substream_t *subs) | |||
120 | * it directly from the buffer. thus the data is once copied to | 123 | * it directly from the buffer. thus the data is once copied to |
121 | * a temporary buffer and urb points to that. | 124 | * a temporary buffer and urb points to that. |
122 | */ | 125 | */ |
123 | static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, | 126 | static int usX2Y_urb_play_prepare(struct snd_usX2Y_substream *subs, |
124 | struct urb *cap_urb, | 127 | struct urb *cap_urb, |
125 | struct urb *urb) | 128 | struct urb *urb) |
126 | { | 129 | { |
127 | int count, counts, pack; | 130 | int count, counts, pack; |
128 | usX2Ydev_t* usX2Y = subs->usX2Y; | 131 | struct usX2Ydev *usX2Y = subs->usX2Y; |
129 | snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; | 132 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
130 | 133 | ||
131 | count = 0; | 134 | count = 0; |
132 | for (pack = 0; pack < nr_of_packs(); pack++) { | 135 | for (pack = 0; pack < nr_of_packs(); pack++) { |
@@ -139,7 +142,8 @@ static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, | |||
139 | } | 142 | } |
140 | /* set up descriptor */ | 143 | /* set up descriptor */ |
141 | urb->iso_frame_desc[pack].offset = pack ? | 144 | urb->iso_frame_desc[pack].offset = pack ? |
142 | urb->iso_frame_desc[pack - 1].offset + urb->iso_frame_desc[pack - 1].length : | 145 | urb->iso_frame_desc[pack - 1].offset + |
146 | urb->iso_frame_desc[pack - 1].length : | ||
143 | 0; | 147 | 0; |
144 | urb->iso_frame_desc[pack].length = cap_urb->iso_frame_desc[pack].actual_length; | 148 | urb->iso_frame_desc[pack].length = cap_urb->iso_frame_desc[pack].actual_length; |
145 | } | 149 | } |
@@ -151,8 +155,10 @@ static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, | |||
151 | int len; | 155 | int len; |
152 | len = runtime->buffer_size - subs->hwptr; | 156 | len = runtime->buffer_size - subs->hwptr; |
153 | urb->transfer_buffer = subs->tmpbuf; | 157 | urb->transfer_buffer = subs->tmpbuf; |
154 | memcpy(subs->tmpbuf, runtime->dma_area + subs->hwptr * usX2Y->stride, len * usX2Y->stride); | 158 | memcpy(subs->tmpbuf, runtime->dma_area + |
155 | memcpy(subs->tmpbuf + len * usX2Y->stride, runtime->dma_area, (count - len) * usX2Y->stride); | 159 | subs->hwptr * usX2Y->stride, len * usX2Y->stride); |
160 | memcpy(subs->tmpbuf + len * usX2Y->stride, | ||
161 | runtime->dma_area, (count - len) * usX2Y->stride); | ||
156 | subs->hwptr += count; | 162 | subs->hwptr += count; |
157 | subs->hwptr -= runtime->buffer_size; | 163 | subs->hwptr -= runtime->buffer_size; |
158 | } else { | 164 | } else { |
@@ -172,9 +178,9 @@ static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, | |||
172 | * | 178 | * |
173 | * update the current position and call callback if a period is processed. | 179 | * update the current position and call callback if a period is processed. |
174 | */ | 180 | */ |
175 | static void usX2Y_urb_play_retire(snd_usX2Y_substream_t *subs, struct urb *urb) | 181 | static void usX2Y_urb_play_retire(struct snd_usX2Y_substream *subs, struct urb *urb) |
176 | { | 182 | { |
177 | snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; | 183 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
178 | int len = urb->actual_length / subs->usX2Y->stride; | 184 | int len = urb->actual_length / subs->usX2Y->stride; |
179 | 185 | ||
180 | subs->transfer_done += len; | 186 | subs->transfer_done += len; |
@@ -187,7 +193,7 @@ static void usX2Y_urb_play_retire(snd_usX2Y_substream_t *subs, struct urb *urb) | |||
187 | } | 193 | } |
188 | } | 194 | } |
189 | 195 | ||
190 | static int usX2Y_urb_submit(snd_usX2Y_substream_t *subs, struct urb *urb, int frame) | 196 | static int usX2Y_urb_submit(struct snd_usX2Y_substream *subs, struct urb *urb, int frame) |
191 | { | 197 | { |
192 | int err; | 198 | int err; |
193 | if (!urb) | 199 | if (!urb) |
@@ -202,7 +208,9 @@ static int usX2Y_urb_submit(snd_usX2Y_substream_t *subs, struct urb *urb, int fr | |||
202 | return 0; | 208 | return 0; |
203 | } | 209 | } |
204 | 210 | ||
205 | static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_usX2Y_substream_t *playbacksubs, int frame) | 211 | static inline int usX2Y_usbframe_complete(struct snd_usX2Y_substream *capsubs, |
212 | struct snd_usX2Y_substream *playbacksubs, | ||
213 | int frame) | ||
206 | { | 214 | { |
207 | int err, state; | 215 | int err, state; |
208 | struct urb *urb = playbacksubs->completed_urb; | 216 | struct urb *urb = playbacksubs->completed_urb; |
@@ -211,9 +219,8 @@ static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_us | |||
211 | if (NULL != urb) { | 219 | if (NULL != urb) { |
212 | if (state == state_RUNNING) | 220 | if (state == state_RUNNING) |
213 | usX2Y_urb_play_retire(playbacksubs, urb); | 221 | usX2Y_urb_play_retire(playbacksubs, urb); |
214 | else | 222 | else if (state >= state_PRERUNNING) |
215 | if (state >= state_PRERUNNING) | 223 | atomic_inc(&playbacksubs->state); |
216 | atomic_inc(&playbacksubs->state); | ||
217 | } else { | 224 | } else { |
218 | switch (state) { | 225 | switch (state) { |
219 | case state_STARTING1: | 226 | case state_STARTING1: |
@@ -228,8 +235,9 @@ static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_us | |||
228 | } | 235 | } |
229 | if (urb) { | 236 | if (urb) { |
230 | if ((err = usX2Y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) || | 237 | if ((err = usX2Y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) || |
231 | (err = usX2Y_urb_submit(playbacksubs, urb, frame))) | 238 | (err = usX2Y_urb_submit(playbacksubs, urb, frame))) { |
232 | return err; | 239 | return err; |
240 | } | ||
233 | } | 241 | } |
234 | 242 | ||
235 | playbacksubs->completed_urb = NULL; | 243 | playbacksubs->completed_urb = NULL; |
@@ -249,18 +257,19 @@ static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_us | |||
249 | } | 257 | } |
250 | 258 | ||
251 | 259 | ||
252 | static void usX2Y_clients_stop(usX2Ydev_t *usX2Y) | 260 | static void usX2Y_clients_stop(struct usX2Ydev *usX2Y) |
253 | { | 261 | { |
254 | int s, u; | 262 | int s, u; |
263 | |||
255 | for (s = 0; s < 4; s++) { | 264 | for (s = 0; s < 4; s++) { |
256 | snd_usX2Y_substream_t *subs = usX2Y->subs[s]; | 265 | struct snd_usX2Y_substream *subs = usX2Y->subs[s]; |
257 | if (subs) { | 266 | if (subs) { |
258 | snd_printdd("%i %p state=%i\n", s, subs, atomic_read(&subs->state)); | 267 | snd_printdd("%i %p state=%i\n", s, subs, atomic_read(&subs->state)); |
259 | atomic_set(&subs->state, state_STOPPED); | 268 | atomic_set(&subs->state, state_STOPPED); |
260 | } | 269 | } |
261 | } | 270 | } |
262 | for (s = 0; s < 4; s++) { | 271 | for (s = 0; s < 4; s++) { |
263 | snd_usX2Y_substream_t *subs = usX2Y->subs[s]; | 272 | struct snd_usX2Y_substream *subs = usX2Y->subs[s]; |
264 | if (subs) { | 273 | if (subs) { |
265 | if (atomic_read(&subs->state) >= state_PRERUNNING) { | 274 | if (atomic_read(&subs->state) >= state_PRERUNNING) { |
266 | snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN); | 275 | snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN); |
@@ -268,7 +277,8 @@ static void usX2Y_clients_stop(usX2Ydev_t *usX2Y) | |||
268 | for (u = 0; u < NRURBS; u++) { | 277 | for (u = 0; u < NRURBS; u++) { |
269 | struct urb *urb = subs->urb[u]; | 278 | struct urb *urb = subs->urb[u]; |
270 | if (NULL != urb) | 279 | if (NULL != urb) |
271 | snd_printdd("%i status=%i start_frame=%i\n", u, urb->status, urb->start_frame); | 280 | snd_printdd("%i status=%i start_frame=%i\n", |
281 | u, urb->status, urb->start_frame); | ||
272 | } | 282 | } |
273 | } | 283 | } |
274 | } | 284 | } |
@@ -276,30 +286,36 @@ static void usX2Y_clients_stop(usX2Ydev_t *usX2Y) | |||
276 | wake_up(&usX2Y->prepare_wait_queue); | 286 | wake_up(&usX2Y->prepare_wait_queue); |
277 | } | 287 | } |
278 | 288 | ||
279 | static void usX2Y_error_urb_status(usX2Ydev_t *usX2Y, snd_usX2Y_substream_t *subs, struct urb *urb) | 289 | static void usX2Y_error_urb_status(struct usX2Ydev *usX2Y, |
290 | struct snd_usX2Y_substream *subs, struct urb *urb) | ||
280 | { | 291 | { |
281 | snd_printk(KERN_ERR "ep=%i stalled with status=%i\n", subs->endpoint, urb->status); | 292 | snd_printk(KERN_ERR "ep=%i stalled with status=%i\n", subs->endpoint, urb->status); |
282 | urb->status = 0; | 293 | urb->status = 0; |
283 | usX2Y_clients_stop(usX2Y); | 294 | usX2Y_clients_stop(usX2Y); |
284 | } | 295 | } |
285 | 296 | ||
286 | static void usX2Y_error_sequence(usX2Ydev_t *usX2Y, snd_usX2Y_substream_t *subs, struct urb *urb) | 297 | static void usX2Y_error_sequence(struct usX2Ydev *usX2Y, |
298 | struct snd_usX2Y_substream *subs, struct urb *urb) | ||
287 | { | 299 | { |
288 | snd_printk(KERN_ERR "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" | 300 | snd_printk(KERN_ERR "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" |
289 | KERN_ERR "Most propably some urb of usb-frame %i is still missing.\n" | 301 | KERN_ERR "Most propably some urb of usb-frame %i is still missing.\n" |
290 | KERN_ERR "Cause could be too long delays in usb-hcd interrupt handling.\n", | 302 | KERN_ERR "Cause could be too long delays in usb-hcd interrupt handling.\n", |
291 | usb_get_current_frame_number(usX2Y->chip.dev), | 303 | usb_get_current_frame_number(usX2Y->chip.dev), |
292 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); | 304 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", |
305 | usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); | ||
293 | usX2Y_clients_stop(usX2Y); | 306 | usX2Y_clients_stop(usX2Y); |
294 | } | 307 | } |
295 | 308 | ||
296 | static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) | 309 | static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) |
297 | { | 310 | { |
298 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; | 311 | struct snd_usX2Y_substream *subs = urb->context; |
299 | usX2Ydev_t *usX2Y = subs->usX2Y; | 312 | struct usX2Ydev *usX2Y = subs->usX2Y; |
300 | 313 | ||
301 | if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { | 314 | if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { |
302 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", usb_get_current_frame_number(usX2Y->chip.dev), subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", urb->status, urb->start_frame); | 315 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", |
316 | usb_get_current_frame_number(usX2Y->chip.dev), | ||
317 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", | ||
318 | urb->status, urb->start_frame); | ||
303 | return; | 319 | return; |
304 | } | 320 | } |
305 | if (unlikely(urb->status)) { | 321 | if (unlikely(urb->status)) { |
@@ -313,10 +329,12 @@ static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) | |||
313 | return; | 329 | return; |
314 | } | 330 | } |
315 | { | 331 | { |
316 | snd_usX2Y_substream_t *capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE], | 332 | struct snd_usX2Y_substream *capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE], |
317 | *playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; | 333 | *playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
318 | if (capsubs->completed_urb && atomic_read(&capsubs->state) >= state_PREPARED && | 334 | if (capsubs->completed_urb && |
319 | (playbacksubs->completed_urb || atomic_read(&playbacksubs->state) < state_PREPARED)) { | 335 | atomic_read(&capsubs->state) >= state_PREPARED && |
336 | (playbacksubs->completed_urb || | ||
337 | atomic_read(&playbacksubs->state) < state_PREPARED)) { | ||
320 | if (!usX2Y_usbframe_complete(capsubs, playbacksubs, urb->start_frame)) { | 338 | if (!usX2Y_usbframe_complete(capsubs, playbacksubs, urb->start_frame)) { |
321 | if (nr_of_packs() <= urb->start_frame && | 339 | if (nr_of_packs() <= urb->start_frame && |
322 | urb->start_frame <= (2 * nr_of_packs() - 1)) // uhci and ohci | 340 | urb->start_frame <= (2 * nr_of_packs() - 1)) // uhci and ohci |
@@ -331,11 +349,12 @@ static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) | |||
331 | } | 349 | } |
332 | } | 350 | } |
333 | 351 | ||
334 | static void usX2Y_urbs_set_complete(usX2Ydev_t * usX2Y, void (*complete)(struct urb *, struct pt_regs *)) | 352 | static void usX2Y_urbs_set_complete(struct usX2Ydev * usX2Y, |
353 | void (*complete)(struct urb *, struct pt_regs *)) | ||
335 | { | 354 | { |
336 | int s, u; | 355 | int s, u; |
337 | for (s = 0; s < 4; s++) { | 356 | for (s = 0; s < 4; s++) { |
338 | snd_usX2Y_substream_t *subs = usX2Y->subs[s]; | 357 | struct snd_usX2Y_substream *subs = usX2Y->subs[s]; |
339 | if (NULL != subs) | 358 | if (NULL != subs) |
340 | for (u = 0; u < NRURBS; u++) { | 359 | for (u = 0; u < NRURBS; u++) { |
341 | struct urb * urb = subs->urb[u]; | 360 | struct urb * urb = subs->urb[u]; |
@@ -345,7 +364,7 @@ static void usX2Y_urbs_set_complete(usX2Ydev_t * usX2Y, void (*complete)(struct | |||
345 | } | 364 | } |
346 | } | 365 | } |
347 | 366 | ||
348 | static void usX2Y_subs_startup_finish(usX2Ydev_t * usX2Y) | 367 | static void usX2Y_subs_startup_finish(struct usX2Ydev * usX2Y) |
349 | { | 368 | { |
350 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_urb_complete); | 369 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_urb_complete); |
351 | usX2Y->prepare_subs = NULL; | 370 | usX2Y->prepare_subs = NULL; |
@@ -353,9 +372,9 @@ static void usX2Y_subs_startup_finish(usX2Ydev_t * usX2Y) | |||
353 | 372 | ||
354 | static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs) | 373 | static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs) |
355 | { | 374 | { |
356 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; | 375 | struct snd_usX2Y_substream *subs = urb->context; |
357 | usX2Ydev_t *usX2Y = subs->usX2Y; | 376 | struct usX2Ydev *usX2Y = subs->usX2Y; |
358 | snd_usX2Y_substream_t *prepare_subs = usX2Y->prepare_subs; | 377 | struct snd_usX2Y_substream *prepare_subs = usX2Y->prepare_subs; |
359 | if (NULL != prepare_subs) | 378 | if (NULL != prepare_subs) |
360 | if (urb->start_frame == prepare_subs->urb[0]->start_frame) { | 379 | if (urb->start_frame == prepare_subs->urb[0]->start_frame) { |
361 | usX2Y_subs_startup_finish(usX2Y); | 380 | usX2Y_subs_startup_finish(usX2Y); |
@@ -366,9 +385,10 @@ static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs) | |||
366 | i_usX2Y_urb_complete(urb, regs); | 385 | i_usX2Y_urb_complete(urb, regs); |
367 | } | 386 | } |
368 | 387 | ||
369 | static void usX2Y_subs_prepare(snd_usX2Y_substream_t *subs) | 388 | static void usX2Y_subs_prepare(struct snd_usX2Y_substream *subs) |
370 | { | 389 | { |
371 | snd_printdd("usX2Y_substream_prepare(%p) ep=%i urb0=%p urb1=%p\n", subs, subs->endpoint, subs->urb[0], subs->urb[1]); | 390 | snd_printdd("usX2Y_substream_prepare(%p) ep=%i urb0=%p urb1=%p\n", |
391 | subs, subs->endpoint, subs->urb[0], subs->urb[1]); | ||
372 | /* reset the pointer */ | 392 | /* reset the pointer */ |
373 | subs->hwptr = 0; | 393 | subs->hwptr = 0; |
374 | subs->hwptr_done = 0; | 394 | subs->hwptr_done = 0; |
@@ -376,7 +396,7 @@ static void usX2Y_subs_prepare(snd_usX2Y_substream_t *subs) | |||
376 | } | 396 | } |
377 | 397 | ||
378 | 398 | ||
379 | static void usX2Y_urb_release(struct urb** urb, int free_tb) | 399 | static void usX2Y_urb_release(struct urb **urb, int free_tb) |
380 | { | 400 | { |
381 | if (*urb) { | 401 | if (*urb) { |
382 | usb_kill_urb(*urb); | 402 | usb_kill_urb(*urb); |
@@ -389,12 +409,13 @@ static void usX2Y_urb_release(struct urb** urb, int free_tb) | |||
389 | /* | 409 | /* |
390 | * release a substreams urbs | 410 | * release a substreams urbs |
391 | */ | 411 | */ |
392 | static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs) | 412 | static void usX2Y_urbs_release(struct snd_usX2Y_substream *subs) |
393 | { | 413 | { |
394 | int i; | 414 | int i; |
395 | snd_printdd("usX2Y_urbs_release() %i\n", subs->endpoint); | 415 | snd_printdd("usX2Y_urbs_release() %i\n", subs->endpoint); |
396 | for (i = 0; i < NRURBS; i++) | 416 | for (i = 0; i < NRURBS; i++) |
397 | usX2Y_urb_release(subs->urb + i, subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]); | 417 | usX2Y_urb_release(subs->urb + i, |
418 | subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]); | ||
398 | 419 | ||
399 | kfree(subs->tmpbuf); | 420 | kfree(subs->tmpbuf); |
400 | subs->tmpbuf = NULL; | 421 | subs->tmpbuf = NULL; |
@@ -402,7 +423,7 @@ static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs) | |||
402 | /* | 423 | /* |
403 | * initialize a substream's urbs | 424 | * initialize a substream's urbs |
404 | */ | 425 | */ |
405 | static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) | 426 | static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs) |
406 | { | 427 | { |
407 | int i; | 428 | int i; |
408 | unsigned int pipe; | 429 | unsigned int pipe; |
@@ -452,25 +473,25 @@ static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) | |||
452 | return 0; | 473 | return 0; |
453 | } | 474 | } |
454 | 475 | ||
455 | static void usX2Y_subs_startup(snd_usX2Y_substream_t *subs) | 476 | static void usX2Y_subs_startup(struct snd_usX2Y_substream *subs) |
456 | { | 477 | { |
457 | usX2Ydev_t *usX2Y = subs->usX2Y; | 478 | struct usX2Ydev *usX2Y = subs->usX2Y; |
458 | usX2Y->prepare_subs = subs; | 479 | usX2Y->prepare_subs = subs; |
459 | subs->urb[0]->start_frame = -1; | 480 | subs->urb[0]->start_frame = -1; |
460 | wmb(); | 481 | wmb(); |
461 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_subs_startup); | 482 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_subs_startup); |
462 | } | 483 | } |
463 | 484 | ||
464 | static int usX2Y_urbs_start(snd_usX2Y_substream_t *subs) | 485 | static int usX2Y_urbs_start(struct snd_usX2Y_substream *subs) |
465 | { | 486 | { |
466 | int i, err; | 487 | int i, err; |
467 | usX2Ydev_t *usX2Y = subs->usX2Y; | 488 | struct usX2Ydev *usX2Y = subs->usX2Y; |
468 | 489 | ||
469 | if ((err = usX2Y_urbs_allocate(subs)) < 0) | 490 | if ((err = usX2Y_urbs_allocate(subs)) < 0) |
470 | return err; | 491 | return err; |
471 | subs->completed_urb = NULL; | 492 | subs->completed_urb = NULL; |
472 | for (i = 0; i < 4; i++) { | 493 | for (i = 0; i < 4; i++) { |
473 | snd_usX2Y_substream_t *subs = usX2Y->subs[i]; | 494 | struct snd_usX2Y_substream *subs = usX2Y->subs[i]; |
474 | if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) | 495 | if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) |
475 | goto start; | 496 | goto start; |
476 | } | 497 | } |
@@ -521,17 +542,17 @@ static int usX2Y_urbs_start(snd_usX2Y_substream_t *subs) | |||
521 | /* | 542 | /* |
522 | * return the current pcm pointer. just return the hwptr_done value. | 543 | * return the current pcm pointer. just return the hwptr_done value. |
523 | */ | 544 | */ |
524 | static snd_pcm_uframes_t snd_usX2Y_pcm_pointer(snd_pcm_substream_t *substream) | 545 | static snd_pcm_uframes_t snd_usX2Y_pcm_pointer(struct snd_pcm_substream *substream) |
525 | { | 546 | { |
526 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)substream->runtime->private_data; | 547 | struct snd_usX2Y_substream *subs = substream->runtime->private_data; |
527 | return subs->hwptr_done; | 548 | return subs->hwptr_done; |
528 | } | 549 | } |
529 | /* | 550 | /* |
530 | * start/stop substream | 551 | * start/stop substream |
531 | */ | 552 | */ |
532 | static int snd_usX2Y_pcm_trigger(snd_pcm_substream_t *substream, int cmd) | 553 | static int snd_usX2Y_pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
533 | { | 554 | { |
534 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)substream->runtime->private_data; | 555 | struct snd_usX2Y_substream *subs = substream->runtime->private_data; |
535 | 556 | ||
536 | switch (cmd) { | 557 | switch (cmd) { |
537 | case SNDRV_PCM_TRIGGER_START: | 558 | case SNDRV_PCM_TRIGGER_START: |
@@ -642,9 +663,9 @@ static struct s_c2 SetRate48000[] = | |||
642 | }; | 663 | }; |
643 | #define NOOF_SETRATE_URBS ARRAY_SIZE(SetRate48000) | 664 | #define NOOF_SETRATE_URBS ARRAY_SIZE(SetRate48000) |
644 | 665 | ||
645 | static void i_usX2Y_04Int(struct urb* urb, struct pt_regs *regs) | 666 | static void i_usX2Y_04Int(struct urb *urb, struct pt_regs *regs) |
646 | { | 667 | { |
647 | usX2Ydev_t* usX2Y = urb->context; | 668 | struct usX2Ydev *usX2Y = urb->context; |
648 | 669 | ||
649 | if (urb->status) | 670 | if (urb->status) |
650 | snd_printk(KERN_ERR "snd_usX2Y_04Int() urb->status=%i\n", urb->status); | 671 | snd_printk(KERN_ERR "snd_usX2Y_04Int() urb->status=%i\n", urb->status); |
@@ -652,10 +673,10 @@ static void i_usX2Y_04Int(struct urb* urb, struct pt_regs *regs) | |||
652 | wake_up(&usX2Y->In04WaitQueue); | 673 | wake_up(&usX2Y->In04WaitQueue); |
653 | } | 674 | } |
654 | 675 | ||
655 | static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate) | 676 | static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate) |
656 | { | 677 | { |
657 | int err = 0, i; | 678 | int err = 0, i; |
658 | snd_usX2Y_urbSeq_t *us = NULL; | 679 | struct snd_usX2Y_urbSeq *us = NULL; |
659 | int *usbdata = NULL; | 680 | int *usbdata = NULL; |
660 | struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100; | 681 | struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100; |
661 | 682 | ||
@@ -714,7 +735,7 @@ static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate) | |||
714 | } | 735 | } |
715 | 736 | ||
716 | 737 | ||
717 | static int usX2Y_format_set(usX2Ydev_t *usX2Y, snd_pcm_format_t format) | 738 | static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format) |
718 | { | 739 | { |
719 | int alternate, err; | 740 | int alternate, err; |
720 | struct list_head* p; | 741 | struct list_head* p; |
@@ -744,27 +765,27 @@ static int usX2Y_format_set(usX2Ydev_t *usX2Y, snd_pcm_format_t format) | |||
744 | } | 765 | } |
745 | 766 | ||
746 | 767 | ||
747 | static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream, | 768 | static int snd_usX2Y_pcm_hw_params(struct snd_pcm_substream *substream, |
748 | snd_pcm_hw_params_t *hw_params) | 769 | struct snd_pcm_hw_params *hw_params) |
749 | { | 770 | { |
750 | int err = 0; | 771 | int err = 0; |
751 | unsigned int rate = params_rate(hw_params); | 772 | unsigned int rate = params_rate(hw_params); |
752 | snd_pcm_format_t format = params_format(hw_params); | 773 | snd_pcm_format_t format = params_format(hw_params); |
753 | snd_card_t *card = substream->pstr->pcm->card; | 774 | struct snd_card *card = substream->pstr->pcm->card; |
754 | struct list_head *list; | 775 | struct list_head *list; |
755 | 776 | ||
756 | snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params); | 777 | snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params); |
757 | // all pcm substreams off one usX2Y have to operate at the same rate & format | 778 | // all pcm substreams off one usX2Y have to operate at the same rate & format |
758 | list_for_each(list, &card->devices) { | 779 | list_for_each(list, &card->devices) { |
759 | snd_device_t *dev; | 780 | struct snd_device *dev; |
760 | snd_pcm_t *pcm; | 781 | struct snd_pcm *pcm; |
761 | int s; | 782 | int s; |
762 | dev = snd_device(list); | 783 | dev = snd_device(list); |
763 | if (dev->type != SNDRV_DEV_PCM) | 784 | if (dev->type != SNDRV_DEV_PCM) |
764 | continue; | 785 | continue; |
765 | pcm = dev->device_data; | 786 | pcm = dev->device_data; |
766 | for (s = 0; s < 2; ++s) { | 787 | for (s = 0; s < 2; ++s) { |
767 | snd_pcm_substream_t *test_substream; | 788 | struct snd_pcm_substream *test_substream; |
768 | test_substream = pcm->streams[s].substream; | 789 | test_substream = pcm->streams[s].substream; |
769 | if (test_substream && test_substream != substream && | 790 | if (test_substream && test_substream != substream && |
770 | test_substream->runtime && | 791 | test_substream->runtime && |
@@ -776,7 +797,8 @@ static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream, | |||
776 | } | 797 | } |
777 | } | 798 | } |
778 | if (0 > (err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)))) { | 799 | if (0 > (err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)))) { |
779 | snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n", substream, params_buffer_bytes(hw_params), err); | 800 | snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n", |
801 | substream, params_buffer_bytes(hw_params), err); | ||
780 | return err; | 802 | return err; |
781 | } | 803 | } |
782 | return 0; | 804 | return 0; |
@@ -785,15 +807,15 @@ static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream, | |||
785 | /* | 807 | /* |
786 | * free the buffer | 808 | * free the buffer |
787 | */ | 809 | */ |
788 | static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream) | 810 | static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream) |
789 | { | 811 | { |
790 | snd_pcm_runtime_t *runtime = substream->runtime; | 812 | struct snd_pcm_runtime *runtime = substream->runtime; |
791 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; | 813 | struct snd_usX2Y_substream *subs = runtime->private_data; |
792 | down(&subs->usX2Y->prepare_mutex); | 814 | down(&subs->usX2Y->prepare_mutex); |
793 | snd_printdd("snd_usX2Y_hw_free(%p)\n", substream); | 815 | snd_printdd("snd_usX2Y_hw_free(%p)\n", substream); |
794 | 816 | ||
795 | if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { | 817 | if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { |
796 | snd_usX2Y_substream_t *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; | 818 | struct snd_usX2Y_substream *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
797 | atomic_set(&subs->state, state_STOPPED); | 819 | atomic_set(&subs->state, state_STOPPED); |
798 | usX2Y_urbs_release(subs); | 820 | usX2Y_urbs_release(subs); |
799 | if (!cap_subs->pcm_substream || | 821 | if (!cap_subs->pcm_substream || |
@@ -804,7 +826,7 @@ static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream) | |||
804 | usX2Y_urbs_release(cap_subs); | 826 | usX2Y_urbs_release(cap_subs); |
805 | } | 827 | } |
806 | } else { | 828 | } else { |
807 | snd_usX2Y_substream_t *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; | 829 | struct snd_usX2Y_substream *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
808 | if (atomic_read(&playback_subs->state) < state_PREPARED) { | 830 | if (atomic_read(&playback_subs->state) < state_PREPARED) { |
809 | atomic_set(&subs->state, state_STOPPED); | 831 | atomic_set(&subs->state, state_STOPPED); |
810 | usX2Y_urbs_release(subs); | 832 | usX2Y_urbs_release(subs); |
@@ -818,12 +840,12 @@ static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream) | |||
818 | * | 840 | * |
819 | * set format and initialize urbs | 841 | * set format and initialize urbs |
820 | */ | 842 | */ |
821 | static int snd_usX2Y_pcm_prepare(snd_pcm_substream_t *substream) | 843 | static int snd_usX2Y_pcm_prepare(struct snd_pcm_substream *substream) |
822 | { | 844 | { |
823 | snd_pcm_runtime_t *runtime = substream->runtime; | 845 | struct snd_pcm_runtime *runtime = substream->runtime; |
824 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; | 846 | struct snd_usX2Y_substream *subs = runtime->private_data; |
825 | usX2Ydev_t *usX2Y = subs->usX2Y; | 847 | struct usX2Ydev *usX2Y = subs->usX2Y; |
826 | snd_usX2Y_substream_t *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; | 848 | struct snd_usX2Y_substream *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
827 | int err = 0; | 849 | int err = 0; |
828 | snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); | 850 | snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); |
829 | 851 | ||
@@ -851,7 +873,7 @@ static int snd_usX2Y_pcm_prepare(snd_pcm_substream_t *substream) | |||
851 | return err; | 873 | return err; |
852 | } | 874 | } |
853 | 875 | ||
854 | static snd_pcm_hardware_t snd_usX2Y_2c = | 876 | static struct snd_pcm_hardware snd_usX2Y_2c = |
855 | { | 877 | { |
856 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 878 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
857 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 879 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
@@ -872,11 +894,11 @@ static snd_pcm_hardware_t snd_usX2Y_2c = | |||
872 | 894 | ||
873 | 895 | ||
874 | 896 | ||
875 | static int snd_usX2Y_pcm_open(snd_pcm_substream_t *substream) | 897 | static int snd_usX2Y_pcm_open(struct snd_pcm_substream *substream) |
876 | { | 898 | { |
877 | snd_usX2Y_substream_t *subs = ((snd_usX2Y_substream_t **) | 899 | struct snd_usX2Y_substream *subs = ((struct snd_usX2Y_substream **) |
878 | snd_pcm_substream_chip(substream))[substream->stream]; | 900 | snd_pcm_substream_chip(substream))[substream->stream]; |
879 | snd_pcm_runtime_t *runtime = substream->runtime; | 901 | struct snd_pcm_runtime *runtime = substream->runtime; |
880 | 902 | ||
881 | if (subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS) | 903 | if (subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS) |
882 | return -EBUSY; | 904 | return -EBUSY; |
@@ -890,19 +912,18 @@ static int snd_usX2Y_pcm_open(snd_pcm_substream_t *substream) | |||
890 | 912 | ||
891 | 913 | ||
892 | 914 | ||
893 | static int snd_usX2Y_pcm_close(snd_pcm_substream_t *substream) | 915 | static int snd_usX2Y_pcm_close(struct snd_pcm_substream *substream) |
894 | { | 916 | { |
895 | snd_pcm_runtime_t *runtime = substream->runtime; | 917 | struct snd_pcm_runtime *runtime = substream->runtime; |
896 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; | 918 | struct snd_usX2Y_substream *subs = runtime->private_data; |
897 | int err = 0; | ||
898 | 919 | ||
899 | subs->pcm_substream = NULL; | 920 | subs->pcm_substream = NULL; |
900 | 921 | ||
901 | return err; | 922 | return 0; |
902 | } | 923 | } |
903 | 924 | ||
904 | 925 | ||
905 | static snd_pcm_ops_t snd_usX2Y_pcm_ops = | 926 | static struct snd_pcm_ops snd_usX2Y_pcm_ops = |
906 | { | 927 | { |
907 | .open = snd_usX2Y_pcm_open, | 928 | .open = snd_usX2Y_pcm_open, |
908 | .close = snd_usX2Y_pcm_close, | 929 | .close = snd_usX2Y_pcm_close, |
@@ -918,7 +939,7 @@ static snd_pcm_ops_t snd_usX2Y_pcm_ops = | |||
918 | /* | 939 | /* |
919 | * free a usb stream instance | 940 | * free a usb stream instance |
920 | */ | 941 | */ |
921 | static void usX2Y_audio_stream_free(snd_usX2Y_substream_t **usX2Y_substream) | 942 | static void usX2Y_audio_stream_free(struct snd_usX2Y_substream **usX2Y_substream) |
922 | { | 943 | { |
923 | if (NULL != usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]) { | 944 | if (NULL != usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]) { |
924 | kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]); | 945 | kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]); |
@@ -928,23 +949,23 @@ static void usX2Y_audio_stream_free(snd_usX2Y_substream_t **usX2Y_substream) | |||
928 | usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL; | 949 | usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL; |
929 | } | 950 | } |
930 | 951 | ||
931 | static void snd_usX2Y_pcm_private_free(snd_pcm_t *pcm) | 952 | static void snd_usX2Y_pcm_private_free(struct snd_pcm *pcm) |
932 | { | 953 | { |
933 | snd_usX2Y_substream_t **usX2Y_stream = pcm->private_data; | 954 | struct snd_usX2Y_substream **usX2Y_stream = pcm->private_data; |
934 | if (usX2Y_stream) | 955 | if (usX2Y_stream) |
935 | usX2Y_audio_stream_free(usX2Y_stream); | 956 | usX2Y_audio_stream_free(usX2Y_stream); |
936 | } | 957 | } |
937 | 958 | ||
938 | static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int capture_endpoint) | 959 | static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, int capture_endpoint) |
939 | { | 960 | { |
940 | snd_pcm_t *pcm; | 961 | struct snd_pcm *pcm; |
941 | int err, i; | 962 | int err, i; |
942 | snd_usX2Y_substream_t **usX2Y_substream = | 963 | struct snd_usX2Y_substream **usX2Y_substream = |
943 | usX2Y(card)->subs + 2 * usX2Y(card)->chip.pcm_devs; | 964 | usX2Y(card)->subs + 2 * usX2Y(card)->chip.pcm_devs; |
944 | 965 | ||
945 | for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; | 966 | for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; |
946 | i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { | 967 | i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { |
947 | usX2Y_substream[i] = kzalloc(sizeof(snd_usX2Y_substream_t), GFP_KERNEL); | 968 | usX2Y_substream[i] = kzalloc(sizeof(struct snd_usX2Y_substream), GFP_KERNEL); |
948 | if (NULL == usX2Y_substream[i]) { | 969 | if (NULL == usX2Y_substream[i]) { |
949 | snd_printk(KERN_ERR "cannot malloc\n"); | 970 | snd_printk(KERN_ERR "cannot malloc\n"); |
950 | return -ENOMEM; | 971 | return -ENOMEM; |
@@ -994,7 +1015,7 @@ static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int c | |||
994 | /* | 1015 | /* |
995 | * create a chip instance and set its names. | 1016 | * create a chip instance and set its names. |
996 | */ | 1017 | */ |
997 | int usX2Y_audio_create(snd_card_t* card) | 1018 | int usX2Y_audio_create(struct snd_card *card) |
998 | { | 1019 | { |
999 | int err = 0; | 1020 | int err = 0; |
1000 | 1021 | ||