diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-01-23 10:10:57 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-01-28 01:21:18 -0500 |
commit | ad0119abe29fe3d506486a789de4c4619fa7602c (patch) | |
tree | ebbb5c893a11998437fba5bbfd0b22a63f70fe71 /sound/usb/line6/playback.c | |
parent | ab5cdcbab2efb833b4c199d0b0a6603af080eaa2 (diff) |
ALSA: line6: Rearrange PCM structure
Introduce a new line6_pcm_stream structure and group individual
fields of snd_line6_pcm struct to playback and capture groups.
This patch itself just does rename and nothing else. More
meaningful cleanups based on these fields shuffling will follow.
Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/line6/playback.c')
-rw-r--r-- | sound/usb/line6/playback.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 7e031b1761aa..d619c1718306 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c | |||
@@ -145,17 +145,17 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) | |||
145 | (USB_INTERVALS_PER_SECOND / LINE6_ISO_INTERVAL); | 145 | (USB_INTERVALS_PER_SECOND / LINE6_ISO_INTERVAL); |
146 | struct urb *urb_out; | 146 | struct urb *urb_out; |
147 | 147 | ||
148 | spin_lock_irqsave(&line6pcm->lock_audio_out, flags); | 148 | spin_lock_irqsave(&line6pcm->out.lock, flags); |
149 | index = | 149 | index = |
150 | find_first_zero_bit(&line6pcm->active_urb_out, LINE6_ISO_BUFFERS); | 150 | find_first_zero_bit(&line6pcm->out.active_urbs, LINE6_ISO_BUFFERS); |
151 | 151 | ||
152 | if (index < 0 || index >= LINE6_ISO_BUFFERS) { | 152 | if (index < 0 || index >= LINE6_ISO_BUFFERS) { |
153 | spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); | 153 | spin_unlock_irqrestore(&line6pcm->out.lock, flags); |
154 | dev_err(line6pcm->line6->ifcdev, "no free URB found\n"); | 154 | dev_err(line6pcm->line6->ifcdev, "no free URB found\n"); |
155 | return -EINVAL; | 155 | return -EINVAL; |
156 | } | 156 | } |
157 | 157 | ||
158 | urb_out = line6pcm->urb_audio_out[index]; | 158 | urb_out = line6pcm->out.urbs[index]; |
159 | urb_size = 0; | 159 | urb_size = 0; |
160 | 160 | ||
161 | for (i = 0; i < LINE6_ISO_PACKETS; ++i) { | 161 | for (i = 0; i < LINE6_ISO_PACKETS; ++i) { |
@@ -170,9 +170,9 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) | |||
170 | if (fsize == 0) { | 170 | if (fsize == 0) { |
171 | int n; | 171 | int n; |
172 | 172 | ||
173 | line6pcm->count_out += frame_increment; | 173 | line6pcm->out.count += frame_increment; |
174 | n = line6pcm->count_out / frame_factor; | 174 | n = line6pcm->out.count / frame_factor; |
175 | line6pcm->count_out -= n * frame_factor; | 175 | line6pcm->out.count -= n * frame_factor; |
176 | fsize = n * bytes_per_frame; | 176 | fsize = n * bytes_per_frame; |
177 | } | 177 | } |
178 | 178 | ||
@@ -183,14 +183,14 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) | |||
183 | 183 | ||
184 | if (urb_size == 0) { | 184 | if (urb_size == 0) { |
185 | /* can't determine URB size */ | 185 | /* can't determine URB size */ |
186 | spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); | 186 | spin_unlock_irqrestore(&line6pcm->out.lock, flags); |
187 | dev_err(line6pcm->line6->ifcdev, "driver bug: urb_size = 0\n"); | 187 | dev_err(line6pcm->line6->ifcdev, "driver bug: urb_size = 0\n"); |
188 | return -EINVAL; | 188 | return -EINVAL; |
189 | } | 189 | } |
190 | 190 | ||
191 | urb_frames = urb_size / bytes_per_frame; | 191 | urb_frames = urb_size / bytes_per_frame; |
192 | urb_out->transfer_buffer = | 192 | urb_out->transfer_buffer = |
193 | line6pcm->buffer_out + | 193 | line6pcm->out.buffer + |
194 | index * LINE6_ISO_PACKETS * line6pcm->max_packet_size; | 194 | index * LINE6_ISO_PACKETS * line6pcm->max_packet_size; |
195 | urb_out->transfer_buffer_length = urb_size; | 195 | urb_out->transfer_buffer_length = urb_size; |
196 | urb_out->context = line6pcm; | 196 | urb_out->context = line6pcm; |
@@ -200,19 +200,19 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) | |||
200 | struct snd_pcm_runtime *runtime = | 200 | struct snd_pcm_runtime *runtime = |
201 | get_substream(line6pcm, SNDRV_PCM_STREAM_PLAYBACK)->runtime; | 201 | get_substream(line6pcm, SNDRV_PCM_STREAM_PLAYBACK)->runtime; |
202 | 202 | ||
203 | if (line6pcm->pos_out + urb_frames > runtime->buffer_size) { | 203 | if (line6pcm->out.pos + urb_frames > runtime->buffer_size) { |
204 | /* | 204 | /* |
205 | The transferred area goes over buffer boundary, | 205 | The transferred area goes over buffer boundary, |
206 | copy the data to the temp buffer. | 206 | copy the data to the temp buffer. |
207 | */ | 207 | */ |
208 | int len; | 208 | int len; |
209 | 209 | ||
210 | len = runtime->buffer_size - line6pcm->pos_out; | 210 | len = runtime->buffer_size - line6pcm->out.pos; |
211 | 211 | ||
212 | if (len > 0) { | 212 | if (len > 0) { |
213 | memcpy(urb_out->transfer_buffer, | 213 | memcpy(urb_out->transfer_buffer, |
214 | runtime->dma_area + | 214 | runtime->dma_area + |
215 | line6pcm->pos_out * bytes_per_frame, | 215 | line6pcm->out.pos * bytes_per_frame, |
216 | len * bytes_per_frame); | 216 | len * bytes_per_frame); |
217 | memcpy(urb_out->transfer_buffer + | 217 | memcpy(urb_out->transfer_buffer + |
218 | len * bytes_per_frame, runtime->dma_area, | 218 | len * bytes_per_frame, runtime->dma_area, |
@@ -223,13 +223,13 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) | |||
223 | } else { | 223 | } else { |
224 | memcpy(urb_out->transfer_buffer, | 224 | memcpy(urb_out->transfer_buffer, |
225 | runtime->dma_area + | 225 | runtime->dma_area + |
226 | line6pcm->pos_out * bytes_per_frame, | 226 | line6pcm->out.pos * bytes_per_frame, |
227 | urb_out->transfer_buffer_length); | 227 | urb_out->transfer_buffer_length); |
228 | } | 228 | } |
229 | 229 | ||
230 | line6pcm->pos_out += urb_frames; | 230 | line6pcm->out.pos += urb_frames; |
231 | if (line6pcm->pos_out >= runtime->buffer_size) | 231 | if (line6pcm->out.pos >= runtime->buffer_size) |
232 | line6pcm->pos_out -= runtime->buffer_size; | 232 | line6pcm->out.pos -= runtime->buffer_size; |
233 | } else { | 233 | } else { |
234 | memset(urb_out->transfer_buffer, 0, | 234 | memset(urb_out->transfer_buffer, 0, |
235 | urb_out->transfer_buffer_length); | 235 | urb_out->transfer_buffer_length); |
@@ -265,12 +265,12 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) | |||
265 | ret = usb_submit_urb(urb_out, GFP_ATOMIC); | 265 | ret = usb_submit_urb(urb_out, GFP_ATOMIC); |
266 | 266 | ||
267 | if (ret == 0) | 267 | if (ret == 0) |
268 | set_bit(index, &line6pcm->active_urb_out); | 268 | set_bit(index, &line6pcm->out.active_urbs); |
269 | else | 269 | else |
270 | dev_err(line6pcm->line6->ifcdev, | 270 | dev_err(line6pcm->line6->ifcdev, |
271 | "URB out #%d submission failed (%d)\n", index, ret); | 271 | "URB out #%d submission failed (%d)\n", index, ret); |
272 | 272 | ||
273 | spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); | 273 | spin_unlock_irqrestore(&line6pcm->out.lock, flags); |
274 | return 0; | 274 | return 0; |
275 | } | 275 | } |
276 | 276 | ||
@@ -298,9 +298,9 @@ void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm) | |||
298 | unsigned int i; | 298 | unsigned int i; |
299 | 299 | ||
300 | for (i = 0; i < LINE6_ISO_BUFFERS; i++) { | 300 | for (i = 0; i < LINE6_ISO_BUFFERS; i++) { |
301 | if (test_bit(i, &line6pcm->active_urb_out)) { | 301 | if (test_bit(i, &line6pcm->out.active_urbs)) { |
302 | if (!test_and_set_bit(i, &line6pcm->unlink_urb_out)) { | 302 | if (!test_and_set_bit(i, &line6pcm->out.unlink_urbs)) { |
303 | struct urb *u = line6pcm->urb_audio_out[i]; | 303 | struct urb *u = line6pcm->out.urbs[i]; |
304 | 304 | ||
305 | usb_unlink_urb(u); | 305 | usb_unlink_urb(u); |
306 | } | 306 | } |
@@ -321,7 +321,7 @@ void line6_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) | |||
321 | do { | 321 | do { |
322 | alive = 0; | 322 | alive = 0; |
323 | for (i = 0; i < LINE6_ISO_BUFFERS; i++) { | 323 | for (i = 0; i < LINE6_ISO_BUFFERS; i++) { |
324 | if (test_bit(i, &line6pcm->active_urb_out)) | 324 | if (test_bit(i, &line6pcm->out.active_urbs)) |
325 | alive++; | 325 | alive++; |
326 | } | 326 | } |
327 | if (!alive) | 327 | if (!alive) |
@@ -344,8 +344,8 @@ void line6_unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) | |||
344 | 344 | ||
345 | void line6_free_playback_buffer(struct snd_line6_pcm *line6pcm) | 345 | void line6_free_playback_buffer(struct snd_line6_pcm *line6pcm) |
346 | { | 346 | { |
347 | kfree(line6pcm->buffer_out); | 347 | kfree(line6pcm->out.buffer); |
348 | line6pcm->buffer_out = NULL; | 348 | line6pcm->out.buffer = NULL; |
349 | } | 349 | } |
350 | 350 | ||
351 | /* | 351 | /* |
@@ -363,11 +363,11 @@ static void audio_out_callback(struct urb *urb) | |||
363 | memset(urb->transfer_buffer, 0, urb->transfer_buffer_length); | 363 | memset(urb->transfer_buffer, 0, urb->transfer_buffer_length); |
364 | #endif | 364 | #endif |
365 | 365 | ||
366 | line6pcm->last_frame_out = urb->start_frame; | 366 | line6pcm->out.last_frame = urb->start_frame; |
367 | 367 | ||
368 | /* find index of URB */ | 368 | /* find index of URB */ |
369 | for (index = 0; index < LINE6_ISO_BUFFERS; index++) | 369 | for (index = 0; index < LINE6_ISO_BUFFERS; index++) |
370 | if (urb == line6pcm->urb_audio_out[index]) | 370 | if (urb == line6pcm->out.urbs[index]) |
371 | break; | 371 | break; |
372 | 372 | ||
373 | if (index >= LINE6_ISO_BUFFERS) | 373 | if (index >= LINE6_ISO_BUFFERS) |
@@ -376,19 +376,19 @@ static void audio_out_callback(struct urb *urb) | |||
376 | for (i = 0; i < LINE6_ISO_PACKETS; i++) | 376 | for (i = 0; i < LINE6_ISO_PACKETS; i++) |
377 | length += urb->iso_frame_desc[i].length; | 377 | length += urb->iso_frame_desc[i].length; |
378 | 378 | ||
379 | spin_lock_irqsave(&line6pcm->lock_audio_out, flags); | 379 | spin_lock_irqsave(&line6pcm->out.lock, flags); |
380 | 380 | ||
381 | if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, &line6pcm->flags)) { | 381 | if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, &line6pcm->flags)) { |
382 | struct snd_pcm_runtime *runtime = substream->runtime; | 382 | struct snd_pcm_runtime *runtime = substream->runtime; |
383 | 383 | ||
384 | line6pcm->pos_out_done += | 384 | line6pcm->out.pos_done += |
385 | length / line6pcm->properties->bytes_per_frame; | 385 | length / line6pcm->properties->bytes_per_frame; |
386 | 386 | ||
387 | if (line6pcm->pos_out_done >= runtime->buffer_size) | 387 | if (line6pcm->out.pos_done >= runtime->buffer_size) |
388 | line6pcm->pos_out_done -= runtime->buffer_size; | 388 | line6pcm->out.pos_done -= runtime->buffer_size; |
389 | } | 389 | } |
390 | 390 | ||
391 | clear_bit(index, &line6pcm->active_urb_out); | 391 | clear_bit(index, &line6pcm->out.active_urbs); |
392 | 392 | ||
393 | for (i = 0; i < LINE6_ISO_PACKETS; i++) | 393 | for (i = 0; i < LINE6_ISO_PACKETS; i++) |
394 | if (urb->iso_frame_desc[i].status == -EXDEV) { | 394 | if (urb->iso_frame_desc[i].status == -EXDEV) { |
@@ -396,19 +396,19 @@ static void audio_out_callback(struct urb *urb) | |||
396 | break; | 396 | break; |
397 | } | 397 | } |
398 | 398 | ||
399 | if (test_and_clear_bit(index, &line6pcm->unlink_urb_out)) | 399 | if (test_and_clear_bit(index, &line6pcm->out.unlink_urbs)) |
400 | shutdown = 1; | 400 | shutdown = 1; |
401 | 401 | ||
402 | spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); | 402 | spin_unlock_irqrestore(&line6pcm->out.lock, flags); |
403 | 403 | ||
404 | if (!shutdown) { | 404 | if (!shutdown) { |
405 | submit_audio_out_urb(line6pcm); | 405 | submit_audio_out_urb(line6pcm); |
406 | 406 | ||
407 | if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, | 407 | if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, |
408 | &line6pcm->flags)) { | 408 | &line6pcm->flags)) { |
409 | line6pcm->bytes_out += length; | 409 | line6pcm->out.bytes += length; |
410 | if (line6pcm->bytes_out >= line6pcm->period_out) { | 410 | if (line6pcm->out.bytes >= line6pcm->out.period) { |
411 | line6pcm->bytes_out %= line6pcm->period_out; | 411 | line6pcm->out.bytes %= line6pcm->out.period; |
412 | snd_pcm_period_elapsed(substream); | 412 | snd_pcm_period_elapsed(substream); |
413 | } | 413 | } |
414 | } | 414 | } |
@@ -457,7 +457,7 @@ static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream, | |||
457 | return ret; | 457 | return ret; |
458 | } | 458 | } |
459 | 459 | ||
460 | line6pcm->period_out = params_period_bytes(hw_params); | 460 | line6pcm->out.period = params_period_bytes(hw_params); |
461 | return 0; | 461 | return 0; |
462 | } | 462 | } |
463 | 463 | ||
@@ -517,7 +517,7 @@ snd_line6_playback_pointer(struct snd_pcm_substream *substream) | |||
517 | { | 517 | { |
518 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); | 518 | struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); |
519 | 519 | ||
520 | return line6pcm->pos_out_done; | 520 | return line6pcm->out.pos_done; |
521 | } | 521 | } |
522 | 522 | ||
523 | /* playback operators */ | 523 | /* playback operators */ |
@@ -542,7 +542,7 @@ int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm) | |||
542 | struct urb *urb; | 542 | struct urb *urb; |
543 | 543 | ||
544 | /* URB for audio out: */ | 544 | /* URB for audio out: */ |
545 | urb = line6pcm->urb_audio_out[i] = | 545 | urb = line6pcm->out.urbs[i] = |
546 | usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); | 546 | usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); |
547 | 547 | ||
548 | if (urb == NULL) | 548 | if (urb == NULL) |