aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/fsl
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r--sound/soc/fsl/mpc5200_dma.c28
-rw-r--r--sound/soc/fsl/mpc5200_dma.h8
2 files changed, 11 insertions, 25 deletions
diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
index 6096d22283e6..986d3c8ab6e1 100644
--- a/sound/soc/fsl/mpc5200_dma.c
+++ b/sound/soc/fsl/mpc5200_dma.c
@@ -58,13 +58,11 @@ static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s)
58 /* Prepare and enqueue the next buffer descriptor */ 58 /* Prepare and enqueue the next buffer descriptor */
59 bd = bcom_prepare_next_buffer(s->bcom_task); 59 bd = bcom_prepare_next_buffer(s->bcom_task);
60 bd->status = s->period_bytes; 60 bd->status = s->period_bytes;
61 bd->data[0] = s->period_next_pt; 61 bd->data[0] = s->runtime->dma_addr + (s->period_next * s->period_bytes);
62 bcom_submit_next_buffer(s->bcom_task, NULL); 62 bcom_submit_next_buffer(s->bcom_task, NULL);
63 63
64 /* Update for next period */ 64 /* Update for next period */
65 s->period_next_pt += s->period_bytes; 65 s->period_next = (s->period_next + 1) % s->runtime->periods;
66 if (s->period_next_pt >= s->period_end)
67 s->period_next_pt = s->period_start;
68} 66}
69 67
70static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s) 68static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s)
@@ -79,7 +77,7 @@ static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s)
79 if (bcom_queue_full(s->bcom_task)) 77 if (bcom_queue_full(s->bcom_task))
80 return; 78 return;
81 79
82 s->appl_ptr += s->period_size; 80 s->appl_ptr += s->runtime->period_size;
83 81
84 psc_dma_bcom_enqueue_next_buffer(s); 82 psc_dma_bcom_enqueue_next_buffer(s);
85 } 83 }
@@ -91,7 +89,7 @@ static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s)
91 if (bcom_queue_full(s->bcom_task)) 89 if (bcom_queue_full(s->bcom_task))
92 return; 90 return;
93 91
94 s->appl_ptr += s->period_size; 92 s->appl_ptr += s->runtime->period_size;
95 93
96 psc_dma_bcom_enqueue_next_buffer(s); 94 psc_dma_bcom_enqueue_next_buffer(s);
97 } 95 }
@@ -108,9 +106,7 @@ static irqreturn_t psc_dma_bcom_irq_tx(int irq, void *_psc_dma_stream)
108 while (bcom_buffer_done(s->bcom_task)) { 106 while (bcom_buffer_done(s->bcom_task)) {
109 bcom_retrieve_buffer(s->bcom_task, NULL, NULL); 107 bcom_retrieve_buffer(s->bcom_task, NULL, NULL);
110 108
111 s->period_current_pt += s->period_bytes; 109 s->period_current = (s->period_current+1) % s->runtime->periods;
112 if (s->period_current_pt >= s->period_end)
113 s->period_current_pt = s->period_start;
114 } 110 }
115 psc_dma_bcom_enqueue_tx(s); 111 psc_dma_bcom_enqueue_tx(s);
116 spin_unlock(&s->psc_dma->lock); 112 spin_unlock(&s->psc_dma->lock);
@@ -133,9 +129,7 @@ static irqreturn_t psc_dma_bcom_irq_rx(int irq, void *_psc_dma_stream)
133 while (bcom_buffer_done(s->bcom_task)) { 129 while (bcom_buffer_done(s->bcom_task)) {
134 bcom_retrieve_buffer(s->bcom_task, NULL, NULL); 130 bcom_retrieve_buffer(s->bcom_task, NULL, NULL);
135 131
136 s->period_current_pt += s->period_bytes; 132 s->period_current = (s->period_current+1) % s->runtime->periods;
137 if (s->period_current_pt >= s->period_end)
138 s->period_current_pt = s->period_start;
139 133
140 psc_dma_bcom_enqueue_next_buffer(s); 134 psc_dma_bcom_enqueue_next_buffer(s);
141 } 135 }
@@ -185,12 +179,8 @@ static int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd)
185 case SNDRV_PCM_TRIGGER_START: 179 case SNDRV_PCM_TRIGGER_START:
186 s->period_bytes = frames_to_bytes(runtime, 180 s->period_bytes = frames_to_bytes(runtime,
187 runtime->period_size); 181 runtime->period_size);
188 s->period_start = virt_to_phys(runtime->dma_area); 182 s->period_next = 0;
189 s->period_end = s->period_start + 183 s->period_current = 0;
190 (s->period_bytes * runtime->periods);
191 s->period_next_pt = s->period_start;
192 s->period_current_pt = s->period_start;
193 s->period_size = runtime->period_size;
194 s->active = 1; 184 s->active = 1;
195 185
196 /* track appl_ptr so that we have a better chance of detecting 186 /* track appl_ptr so that we have a better chance of detecting
@@ -343,7 +333,7 @@ psc_dma_pointer(struct snd_pcm_substream *substream)
343 else 333 else
344 s = &psc_dma->playback; 334 s = &psc_dma->playback;
345 335
346 count = s->period_current_pt - s->period_start; 336 count = s->period_current * s->period_bytes;
347 337
348 return bytes_to_frames(substream->runtime, count); 338 return bytes_to_frames(substream->runtime, count);
349} 339}
diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h
index 8d396bb9d9fe..529f7a094479 100644
--- a/sound/soc/fsl/mpc5200_dma.h
+++ b/sound/soc/fsl/mpc5200_dma.h
@@ -13,7 +13,6 @@
13 * @psc_dma: pointer back to parent psc_dma data structure 13 * @psc_dma: pointer back to parent psc_dma data structure
14 * @bcom_task: bestcomm task structure 14 * @bcom_task: bestcomm task structure
15 * @irq: irq number for bestcomm task 15 * @irq: irq number for bestcomm task
16 * @period_start: physical address of start of DMA region
17 * @period_end: physical address of end of DMA region 16 * @period_end: physical address of end of DMA region
18 * @period_next_pt: physical address of next DMA buffer to enqueue 17 * @period_next_pt: physical address of next DMA buffer to enqueue
19 * @period_bytes: size of DMA period in bytes 18 * @period_bytes: size of DMA period in bytes
@@ -27,12 +26,9 @@ struct psc_dma_stream {
27 struct bcom_task *bcom_task; 26 struct bcom_task *bcom_task;
28 int irq; 27 int irq;
29 struct snd_pcm_substream *stream; 28 struct snd_pcm_substream *stream;
30 dma_addr_t period_start; 29 int period_next;
31 dma_addr_t period_end; 30 int period_current;
32 dma_addr_t period_next_pt;
33 dma_addr_t period_current_pt;
34 int period_bytes; 31 int period_bytes;
35 int period_size;
36}; 32};
37 33
38/** 34/**