Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 1 | /* |
Chris Rorvick | c078a4a | 2015-01-20 02:20:50 -0600 | [diff] [blame] | 2 | * Line 6 Linux USB driver |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 3 | * |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 4 | * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation, version 2. |
| 9 | * |
| 10 | */ |
| 11 | |
Stefan Hajnoczi | 140e28b | 2011-11-23 08:20:45 +0000 | [diff] [blame] | 12 | #include <linux/slab.h> |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 13 | #include <sound/core.h> |
| 14 | #include <sound/pcm.h> |
| 15 | #include <sound/pcm_params.h> |
| 16 | |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 17 | #include "capture.h" |
| 18 | #include "driver.h" |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 19 | #include "pcm.h" |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 20 | |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 21 | /* |
| 22 | Find a free URB and submit it. |
Takashi Iwai | 3d3ae44 | 2015-01-27 12:50:44 +0100 | [diff] [blame] | 23 | must be called in line6pcm->in.lock context |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 24 | */ |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 25 | static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 26 | { |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 27 | int index; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 28 | int i, urb_size; |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 29 | int ret; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 30 | struct urb *urb_in; |
| 31 | |
Shawn Bohrer | e0645d6 | 2009-11-15 22:17:52 -0600 | [diff] [blame] | 32 | index = |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 33 | find_first_zero_bit(&line6pcm->in.active_urbs, LINE6_ISO_BUFFERS); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 34 | |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 35 | if (index < 0 || index >= LINE6_ISO_BUFFERS) { |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 36 | dev_err(line6pcm->line6->ifcdev, "no free URB found\n"); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 37 | return -EINVAL; |
| 38 | } |
| 39 | |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 40 | urb_in = line6pcm->in.urbs[index]; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 41 | urb_size = 0; |
| 42 | |
Greg Kroah-Hartman | 6efc566 | 2009-02-27 22:39:22 -0800 | [diff] [blame] | 43 | for (i = 0; i < LINE6_ISO_PACKETS; ++i) { |
Shawn Bohrer | e0645d6 | 2009-11-15 22:17:52 -0600 | [diff] [blame] | 44 | struct usb_iso_packet_descriptor *fin = |
| 45 | &urb_in->iso_frame_desc[i]; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 46 | fin->offset = urb_size; |
| 47 | fin->length = line6pcm->max_packet_size; |
| 48 | urb_size += line6pcm->max_packet_size; |
| 49 | } |
| 50 | |
Shawn Bohrer | e0645d6 | 2009-11-15 22:17:52 -0600 | [diff] [blame] | 51 | urb_in->transfer_buffer = |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 52 | line6pcm->in.buffer + |
Shawn Bohrer | e0645d6 | 2009-11-15 22:17:52 -0600 | [diff] [blame] | 53 | index * LINE6_ISO_PACKETS * line6pcm->max_packet_size; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 54 | urb_in->transfer_buffer_length = urb_size; |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 55 | urb_in->context = line6pcm; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 56 | |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 57 | ret = usb_submit_urb(urb_in, GFP_ATOMIC); |
| 58 | |
| 59 | if (ret == 0) |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 60 | set_bit(index, &line6pcm->in.active_urbs); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 61 | else |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 62 | dev_err(line6pcm->line6->ifcdev, |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 63 | "URB in #%d submission failed (%d)\n", index, ret); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 64 | |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | /* |
| 69 | Submit all currently available capture URBs. |
Takashi Iwai | 63e20df | 2015-01-27 15:24:09 +0100 | [diff] [blame] | 70 | must be called in line6pcm->in.lock context |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 71 | */ |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 72 | int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 73 | { |
Takashi Iwai | 3d3ae44 | 2015-01-27 12:50:44 +0100 | [diff] [blame] | 74 | int ret = 0, i; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 75 | |
Greg Kroah-Hartman | 6efc566 | 2009-02-27 22:39:22 -0800 | [diff] [blame] | 76 | for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 77 | ret = submit_audio_in_urb(line6pcm); |
Greg Kroah-Hartman | 6efc566 | 2009-02-27 22:39:22 -0800 | [diff] [blame] | 78 | if (ret < 0) |
Takashi Iwai | 3d3ae44 | 2015-01-27 12:50:44 +0100 | [diff] [blame] | 79 | break; |
Greg Kroah-Hartman | 6efc566 | 2009-02-27 22:39:22 -0800 | [diff] [blame] | 80 | } |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 81 | |
Takashi Iwai | 3d3ae44 | 2015-01-27 12:50:44 +0100 | [diff] [blame] | 82 | return ret; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /* |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 86 | Copy data into ALSA capture buffer. |
| 87 | */ |
| 88 | void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) |
| 89 | { |
| 90 | struct snd_pcm_substream *substream = |
| 91 | get_substream(line6pcm, SNDRV_PCM_STREAM_CAPTURE); |
| 92 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 93 | const int bytes_per_frame = line6pcm->properties->bytes_per_frame; |
| 94 | int frames = fsize / bytes_per_frame; |
| 95 | |
Peter Huewe | 597a1e7 | 2010-12-07 23:38:02 +0100 | [diff] [blame] | 96 | if (runtime == NULL) |
Markus Grabner | c7fcf25 | 2010-09-17 23:33:25 +0200 | [diff] [blame] | 97 | return; |
| 98 | |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 99 | if (line6pcm->in.pos_done + frames > runtime->buffer_size) { |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 100 | /* |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 101 | The transferred area goes over buffer boundary, |
| 102 | copy two separate chunks. |
| 103 | */ |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 104 | int len; |
Mikhail Boiko | b5f87cf | 2014-03-18 23:59:46 +0200 | [diff] [blame] | 105 | |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 106 | len = runtime->buffer_size - line6pcm->in.pos_done; |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 107 | |
| 108 | if (len > 0) { |
| 109 | memcpy(runtime->dma_area + |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 110 | line6pcm->in.pos_done * bytes_per_frame, fbuf, |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 111 | len * bytes_per_frame); |
| 112 | memcpy(runtime->dma_area, fbuf + len * bytes_per_frame, |
| 113 | (frames - len) * bytes_per_frame); |
Greg Kroah-Hartman | 027360c | 2010-09-21 16:58:00 -0700 | [diff] [blame] | 114 | } else { |
| 115 | /* this is somewhat paranoid */ |
| 116 | dev_err(line6pcm->line6->ifcdev, |
| 117 | "driver bug: len = %d\n", len); |
| 118 | } |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 119 | } else { |
| 120 | /* copy single chunk */ |
| 121 | memcpy(runtime->dma_area + |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 122 | line6pcm->in.pos_done * bytes_per_frame, fbuf, fsize); |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 123 | } |
| 124 | |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 125 | line6pcm->in.pos_done += frames; |
| 126 | if (line6pcm->in.pos_done >= runtime->buffer_size) |
| 127 | line6pcm->in.pos_done -= runtime->buffer_size; |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length) |
| 131 | { |
| 132 | struct snd_pcm_substream *substream = |
| 133 | get_substream(line6pcm, SNDRV_PCM_STREAM_CAPTURE); |
| 134 | |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 135 | line6pcm->in.bytes += length; |
| 136 | if (line6pcm->in.bytes >= line6pcm->in.period) { |
| 137 | line6pcm->in.bytes %= line6pcm->in.period; |
Takashi Iwai | 3d3ae44 | 2015-01-27 12:50:44 +0100 | [diff] [blame] | 138 | spin_unlock(&line6pcm->in.lock); |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 139 | snd_pcm_period_elapsed(substream); |
Takashi Iwai | 3d3ae44 | 2015-01-27 12:50:44 +0100 | [diff] [blame] | 140 | spin_lock(&line6pcm->in.lock); |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | |
| 144 | /* |
Greg Kroah-Hartman | 027360c | 2010-09-21 16:58:00 -0700 | [diff] [blame] | 145 | * Callback for completed capture URB. |
| 146 | */ |
Greg Kroah-Hartman | 0c7ab15 | 2009-02-27 20:28:04 -0800 | [diff] [blame] | 147 | static void audio_in_callback(struct urb *urb) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 148 | { |
| 149 | int i, index, length = 0, shutdown = 0; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 150 | unsigned long flags; |
| 151 | |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 152 | struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context; |
| 153 | |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 154 | line6pcm->in.last_frame = urb->start_frame; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 155 | |
| 156 | /* find index of URB */ |
Greg Kroah-Hartman | 6efc566 | 2009-02-27 22:39:22 -0800 | [diff] [blame] | 157 | for (index = 0; index < LINE6_ISO_BUFFERS; ++index) |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 158 | if (urb == line6pcm->in.urbs[index]) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 159 | break; |
| 160 | |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 161 | spin_lock_irqsave(&line6pcm->in.lock, flags); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 162 | |
Greg Kroah-Hartman | 6efc566 | 2009-02-27 22:39:22 -0800 | [diff] [blame] | 163 | for (i = 0; i < LINE6_ISO_PACKETS; ++i) { |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 164 | char *fbuf; |
| 165 | int fsize; |
| 166 | struct usb_iso_packet_descriptor *fin = &urb->iso_frame_desc[i]; |
| 167 | |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 168 | if (fin->status == -EXDEV) { |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 169 | shutdown = 1; |
| 170 | break; |
| 171 | } |
| 172 | |
| 173 | fbuf = urb->transfer_buffer + fin->offset; |
| 174 | fsize = fin->actual_length; |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 175 | |
| 176 | if (fsize > line6pcm->max_packet_size) { |
| 177 | dev_err(line6pcm->line6->ifcdev, |
| 178 | "driver and/or device bug: packet too large (%d > %d)\n", |
| 179 | fsize, line6pcm->max_packet_size); |
| 180 | } |
| 181 | |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 182 | length += fsize; |
| 183 | |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 184 | /* the following assumes LINE6_ISO_PACKETS == 1: */ |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 185 | line6pcm->prev_fbuf = fbuf; |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 186 | line6pcm->prev_fsize = fsize; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 187 | |
Takashi Iwai | 63e20df | 2015-01-27 15:24:09 +0100 | [diff] [blame] | 188 | if (!test_bit(LINE6_STREAM_IMPULSE, &line6pcm->in.running) && |
| 189 | test_bit(LINE6_STREAM_PCM, &line6pcm->in.running) && |
| 190 | fsize > 0) |
| 191 | line6_capture_copy(line6pcm, fbuf, fsize); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 192 | } |
| 193 | |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 194 | clear_bit(index, &line6pcm->in.active_urbs); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 195 | |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 196 | if (test_and_clear_bit(index, &line6pcm->in.unlink_urbs)) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 197 | shutdown = 1; |
| 198 | |
Greg Kroah-Hartman | 6efc566 | 2009-02-27 22:39:22 -0800 | [diff] [blame] | 199 | if (!shutdown) { |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 200 | submit_audio_in_urb(line6pcm); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 201 | |
Takashi Iwai | 63e20df | 2015-01-27 15:24:09 +0100 | [diff] [blame] | 202 | if (!test_bit(LINE6_STREAM_IMPULSE, &line6pcm->in.running) && |
| 203 | test_bit(LINE6_STREAM_PCM, &line6pcm->in.running)) |
| 204 | line6_capture_check_period(line6pcm, length); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 205 | } |
Takashi Iwai | 3d3ae44 | 2015-01-27 12:50:44 +0100 | [diff] [blame] | 206 | |
| 207 | spin_unlock_irqrestore(&line6pcm->in.lock, flags); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | /* open capture callback */ |
| 211 | static int snd_line6_capture_open(struct snd_pcm_substream *substream) |
| 212 | { |
| 213 | int err; |
| 214 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 215 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); |
| 216 | |
Greg Kroah-Hartman | 6efc566 | 2009-02-27 22:39:22 -0800 | [diff] [blame] | 217 | err = snd_pcm_hw_constraint_ratdens(runtime, 0, |
| 218 | SNDRV_PCM_HW_PARAM_RATE, |
Takashi Iwai | 1263f61 | 2015-01-28 15:08:59 +0100 | [diff] [blame] | 219 | &line6pcm->properties->rates); |
Greg Kroah-Hartman | 6efc566 | 2009-02-27 22:39:22 -0800 | [diff] [blame] | 220 | if (err < 0) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 221 | return err; |
| 222 | |
Takashi Iwai | 1263f61 | 2015-01-28 15:08:59 +0100 | [diff] [blame] | 223 | runtime->hw = line6pcm->properties->capture_hw; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 224 | return 0; |
| 225 | } |
| 226 | |
| 227 | /* close capture callback */ |
| 228 | static int snd_line6_capture_close(struct snd_pcm_substream *substream) |
| 229 | { |
| 230 | return 0; |
| 231 | } |
| 232 | |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 233 | /* capture operators */ |
| 234 | struct snd_pcm_ops snd_line6_capture_ops = { |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 235 | .open = snd_line6_capture_open, |
| 236 | .close = snd_line6_capture_close, |
| 237 | .ioctl = snd_pcm_lib_ioctl, |
Takashi Iwai | 63e20df | 2015-01-27 15:24:09 +0100 | [diff] [blame] | 238 | .hw_params = snd_line6_hw_params, |
| 239 | .hw_free = snd_line6_hw_free, |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 240 | .prepare = snd_line6_prepare, |
| 241 | .trigger = snd_line6_trigger, |
Takashi Iwai | 2954f91 | 2015-01-27 15:41:27 +0100 | [diff] [blame] | 242 | .pointer = snd_line6_pointer, |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 243 | }; |
| 244 | |
Markus Grabner | 1027f47 | 2010-08-12 01:35:30 +0200 | [diff] [blame] | 245 | int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 246 | { |
Chris Rorvick | 16d603d | 2015-01-12 12:42:55 -0800 | [diff] [blame] | 247 | struct usb_line6 *line6 = line6pcm->line6; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 248 | int i; |
| 249 | |
| 250 | /* create audio URBs and fill in constant values: */ |
Greg Kroah-Hartman | 6efc566 | 2009-02-27 22:39:22 -0800 | [diff] [blame] | 251 | for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 252 | struct urb *urb; |
| 253 | |
| 254 | /* URB for audio in: */ |
Takashi Iwai | ad0119a | 2015-01-23 16:10:57 +0100 | [diff] [blame] | 255 | urb = line6pcm->in.urbs[i] = |
Shawn Bohrer | e0645d6 | 2009-11-15 22:17:52 -0600 | [diff] [blame] | 256 | usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 257 | |
Takashi Iwai | a019f5e | 2015-01-19 15:05:10 +0100 | [diff] [blame] | 258 | if (urb == NULL) |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 259 | return -ENOMEM; |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 260 | |
Chris Rorvick | 16d603d | 2015-01-12 12:42:55 -0800 | [diff] [blame] | 261 | urb->dev = line6->usbdev; |
Shawn Bohrer | e0645d6 | 2009-11-15 22:17:52 -0600 | [diff] [blame] | 262 | urb->pipe = |
Chris Rorvick | 16d603d | 2015-01-12 12:42:55 -0800 | [diff] [blame] | 263 | usb_rcvisocpipe(line6->usbdev, |
| 264 | line6->properties->ep_audio_r & |
Markus Grabner | e1a164d | 2010-08-23 01:08:25 +0200 | [diff] [blame] | 265 | USB_ENDPOINT_NUMBER_MASK); |
Markus Grabner | 705ecec | 2009-02-27 19:43:04 -0800 | [diff] [blame] | 266 | urb->transfer_flags = URB_ISO_ASAP; |
| 267 | urb->start_frame = -1; |
| 268 | urb->number_of_packets = LINE6_ISO_PACKETS; |
| 269 | urb->interval = LINE6_ISO_INTERVAL; |
| 270 | urb->error_count = 0; |
| 271 | urb->complete = audio_in_callback; |
| 272 | } |
| 273 | |
| 274 | return 0; |
| 275 | } |