diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-06-01 18:24:56 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-06-02 09:01:55 +0200 |
commit | 4f083917994fdde40a86e51c4ee0af5a61182117 (patch) | |
tree | dbb2467219623a19fa4548f80749dd2b94e364f9 /sound/usb | |
parent | e8a8f09cb0b3b82dfacd6a7fce5c99bdf239c5dc (diff) |
ALSA: usb-audio: Factor out DSD bitrev copy function
Just minor code refactoring. Like DOP DSD code, it can be better in a
separate function for code readability.
Link: https://lore.kernel.org/r/20210601162457.4877-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/pcm.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 8ee45f2e8dce..e26d37365f02 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -1250,6 +1250,24 @@ static inline void fill_playback_urb_dsd_dop(struct snd_usb_substream *subs, urb_ctx_queue_advance(subs, urb, queued); } +/* copy bit-reversed bytes onto transfer buffer */ +static void fill_playback_urb_dsd_bitrev(struct snd_usb_substream *subs, + struct urb *urb, unsigned int bytes) +{ + struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; + const u8 *src = runtime->dma_area; + u8 *buf = urb->transfer_buffer; + int i, ofs = subs->hwptr_done; + + for (i = 0; i < bytes; i++) { + *buf++ = bitrev8(src[ofs]); + if (++ofs >= subs->buffer_bytes) + ofs = 0; + } + + urb_ctx_queue_advance(subs, urb, bytes); +} + static void copy_to_urb(struct snd_usb_substream *subs, struct urb *urb, int offset, int stride, unsigned int bytes) { @@ -1360,15 +1378,7 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, fill_playback_urb_dsd_dop(subs, urb, bytes); } else if (unlikely(ep->cur_format == SNDRV_PCM_FORMAT_DSD_U8 && subs->cur_audiofmt->dsd_bitrev)) { - /* bit-reverse the bytes */ - u8 *buf = urb->transfer_buffer; - for (i = 0; i < bytes; i++) { - int idx = (subs->hwptr_done + i) % subs->buffer_bytes; - - buf[i] = bitrev8(runtime->dma_area[idx]); - } - - urb_ctx_queue_advance(subs, urb, bytes); + fill_playback_urb_dsd_bitrev(subs, urb, bytes); } else { /* usual PCM */ if (!subs->tx_length_quirk) |