-static int snd_cs46xx_capture_transfer(snd_pcm_substream_t *substream)
-{
- cs46xx_t *chip = snd_pcm_substream_chip(substream);
- snd_pcm_runtime_t *runtime = substream->runtime;
- snd_pcm_uframes_t appl_ptr = runtime->control->appl_ptr;
- snd_pcm_sframes_t diff = appl_ptr - chip->capt.appl_ptr;
- int buffer_size = runtime->period_size * CS46XX_FRAGS << chip->capt.shift;
-
- if (diff) {
- if (diff < -(snd_pcm_sframes_t) (runtime->boundary / 2))
- diff += runtime->boundary;
- chip->capt.sw_ready -= diff * (1 << chip->capt.shift);
- chip->capt.appl_ptr = appl_ptr;
- }
- while (chip->capt.hw_ready > 0 &&
- chip->capt.sw_ready < (int)chip->capt.sw_bufsize) {
- size_t hw_to_end = buffer_size - chip->capt.hw_data;
- size_t sw_to_end = chip->capt.sw_bufsize - chip->capt.sw_data;
- size_t bytes = chip->capt.sw_bufsize - chip->capt.sw_ready;
- if (chip->capt.hw_ready < (int)bytes)
- bytes = chip->capt.hw_ready;
- if (hw_to_end < bytes)
- bytes = hw_to_end;
- if (sw_to_end < bytes)
- bytes = sw_to_end;
- memcpy(runtime->dma_area + chip->capt.sw_data,
- chip->capt.hw_buf.area + chip->capt.hw_data,
- bytes);
- chip->capt.hw_data += bytes;
- if ((int)chip->capt.hw_data == buffer_size)
- chip->capt.hw_data = 0;
- chip->capt.sw_data += bytes;
- if (chip->capt.sw_data == chip->capt.sw_bufsize)
- chip->capt.sw_data = 0;
- chip->capt.hw_ready -= bytes;
- chip->capt.sw_ready += bytes;
- }
+static void snd_cs46xx_cp_trans_copy(struct snd_pcm_substream *substream,
+ struct snd_pcm_indirect *rec, size_t bytes)
+{
+ struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
+ struct snd_pcm_runtime *runtime = substream->runtime;
+ memcpy(runtime->dma_area + rec->sw_data,
+ chip->capt.hw_buf.area + rec->hw_data, bytes);
+}
+
+static int snd_cs46xx_capture_transfer(struct snd_pcm_substream *substream)
+{
+ struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
+ snd_pcm_indirect_capture_transfer(substream, &chip->capt.pcm_rec, snd_cs46xx_cp_trans_copy);