summaryrefslogtreecommitdiffstats
path: root/sound/usb/pcm.c
diff options
context:
space:
mode:
authorRicard Wanderlof <ricard.wanderlof@axis.com>2015-10-19 08:52:49 +0200
committerTakashi Iwai <tiwai@suse.de>2015-10-19 12:38:06 +0200
commit07a40c2fc6f771a4abb2acc7e59434121e9ddf4e (patch)
tree2956668fb810aeaea6ebcb7a85578d2513ee567e /sound/usb/pcm.c
parent759a2f40c9fa3839c021f7cdc4ec19d10fd63b44 (diff)
downloadop-kernel-dev-07a40c2fc6f771a4abb2acc7e59434121e9ddf4e.zip
op-kernel-dev-07a40c2fc6f771a4abb2acc7e59434121e9ddf4e.tar.gz
ALSA: USB-audio: Break out copying to urb from prepare_playback_urb()
Refactoring in preparation for adding Zoom R16/24 quirk. No functional change. Signed-off-by: Ricard Wanderlof <ricardw@axis.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/pcm.c')
-rw-r--r--sound/usb/pcm.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index cdac517..4292bad 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -1385,6 +1385,26 @@ static inline void fill_playback_urb_dsd_dop(struct snd_usb_substream *subs,
}
}
+static void copy_to_urb(struct snd_usb_substream *subs,
+ struct urb *urb, int stride, unsigned int bytes)
+{
+ struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime;
+
+ if (subs->hwptr_done + bytes > runtime->buffer_size * stride) {
+ /* err, the transferred area goes over buffer boundary. */
+ unsigned int bytes1 =
+ runtime->buffer_size * stride - subs->hwptr_done;
+ memcpy(urb->transfer_buffer,
+ runtime->dma_area + subs->hwptr_done, bytes1);
+ memcpy(urb->transfer_buffer + bytes1,
+ runtime->dma_area, bytes - bytes1);
+ } else {
+ memcpy(urb->transfer_buffer,
+ runtime->dma_area + subs->hwptr_done, bytes);
+ }
+ subs->hwptr_done += bytes;
+}
+
static void prepare_playback_urb(struct snd_usb_substream *subs,
struct urb *urb)
{
@@ -1462,20 +1482,7 @@ static void prepare_playback_urb(struct snd_usb_substream *subs,
subs->hwptr_done += bytes;
} else {
/* usual PCM */
- if (subs->hwptr_done + bytes > runtime->buffer_size * stride) {
- /* err, the transferred area goes over buffer boundary. */
- unsigned int bytes1 =
- runtime->buffer_size * stride - subs->hwptr_done;
- memcpy(urb->transfer_buffer,
- runtime->dma_area + subs->hwptr_done, bytes1);
- memcpy(urb->transfer_buffer + bytes1,
- runtime->dma_area, bytes - bytes1);
- } else {
- memcpy(urb->transfer_buffer,
- runtime->dma_area + subs->hwptr_done, bytes);
- }
-
- subs->hwptr_done += bytes;
+ copy_to_urb(subs, urb, stride, bytes);
}
if (subs->hwptr_done >= runtime->buffer_size * stride)
OpenPOWER on IntegriCloud