mpc5200_dma.c (762f99f4f3cb41a775b5157dd761217beba65873) mpc5200_dma.c (14ec63f678e8beaaa1005ccae6c112bf672ba2b3)
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Freescale MPC5200 PSC DMA
4// ALSA SoC Platform driver
5//
6// Copyright (C) 2008 Secret Lab Technologies Ltd.
7// Copyright (C) 2009 Jon Smirl, Digispeaker
8

--- 93 unchanged lines hidden (view full) ---

102 * psc_dma_trigger: start and stop the DMA transfer.
103 *
104 * This function is called by ALSA to start, stop, pause, and resume the DMA
105 * transfer of data.
106 */
107static int psc_dma_trigger(struct snd_soc_component *component,
108 struct snd_pcm_substream *substream, int cmd)
109{
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Freescale MPC5200 PSC DMA
4// ALSA SoC Platform driver
5//
6// Copyright (C) 2008 Secret Lab Technologies Ltd.
7// Copyright (C) 2009 Jon Smirl, Digispeaker
8

--- 93 unchanged lines hidden (view full) ---

102 * psc_dma_trigger: start and stop the DMA transfer.
103 *
104 * This function is called by ALSA to start, stop, pause, and resume the DMA
105 * transfer of data.
106 */
107static int psc_dma_trigger(struct snd_soc_component *component,
108 struct snd_pcm_substream *substream, int cmd)
109{
110 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
111 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
110 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
111 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(snd_soc_rtd_to_cpu(rtd, 0));
112 struct snd_pcm_runtime *runtime = substream->runtime;
113 struct psc_dma_stream *s = to_psc_dma_stream(substream, psc_dma);
114 struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs;
115 u16 imr;
116 unsigned long flags;
117 int i;
118
119 switch (cmd) {

--- 84 unchanged lines hidden (view full) ---

204 .buffer_bytes_max = 2 * 1024 * 1024,
205 .fifo_size = 512,
206};
207
208static int psc_dma_open(struct snd_soc_component *component,
209 struct snd_pcm_substream *substream)
210{
211 struct snd_pcm_runtime *runtime = substream->runtime;
112 struct snd_pcm_runtime *runtime = substream->runtime;
113 struct psc_dma_stream *s = to_psc_dma_stream(substream, psc_dma);
114 struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs;
115 u16 imr;
116 unsigned long flags;
117 int i;
118
119 switch (cmd) {

--- 84 unchanged lines hidden (view full) ---

204 .buffer_bytes_max = 2 * 1024 * 1024,
205 .fifo_size = 512,
206};
207
208static int psc_dma_open(struct snd_soc_component *component,
209 struct snd_pcm_substream *substream)
210{
211 struct snd_pcm_runtime *runtime = substream->runtime;
212 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
213 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
212 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
213 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(snd_soc_rtd_to_cpu(rtd, 0));
214 struct psc_dma_stream *s;
215 int rc;
216
217 dev_dbg(psc_dma->dev, "psc_dma_open(substream=%p)\n", substream);
218
219 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
220 s = &psc_dma->capture;
221 else

--- 10 unchanged lines hidden (view full) ---

232
233 s->stream = substream;
234 return 0;
235}
236
237static int psc_dma_close(struct snd_soc_component *component,
238 struct snd_pcm_substream *substream)
239{
214 struct psc_dma_stream *s;
215 int rc;
216
217 dev_dbg(psc_dma->dev, "psc_dma_open(substream=%p)\n", substream);
218
219 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
220 s = &psc_dma->capture;
221 else

--- 10 unchanged lines hidden (view full) ---

232
233 s->stream = substream;
234 return 0;
235}
236
237static int psc_dma_close(struct snd_soc_component *component,
238 struct snd_pcm_substream *substream)
239{
240 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
241 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
240 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
241 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(snd_soc_rtd_to_cpu(rtd, 0));
242 struct psc_dma_stream *s;
243
244 dev_dbg(psc_dma->dev, "psc_dma_close(substream=%p)\n", substream);
245
246 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
247 s = &psc_dma->capture;
248 else
249 s = &psc_dma->playback;

--- 8 unchanged lines hidden (view full) ---

258 s->stream = NULL;
259 return 0;
260}
261
262static snd_pcm_uframes_t
263psc_dma_pointer(struct snd_soc_component *component,
264 struct snd_pcm_substream *substream)
265{
242 struct psc_dma_stream *s;
243
244 dev_dbg(psc_dma->dev, "psc_dma_close(substream=%p)\n", substream);
245
246 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
247 s = &psc_dma->capture;
248 else
249 s = &psc_dma->playback;

--- 8 unchanged lines hidden (view full) ---

258 s->stream = NULL;
259 return 0;
260}
261
262static snd_pcm_uframes_t
263psc_dma_pointer(struct snd_soc_component *component,
264 struct snd_pcm_substream *substream)
265{
266 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
267 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
266 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
267 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(snd_soc_rtd_to_cpu(rtd, 0));
268 struct psc_dma_stream *s;
269 dma_addr_t count;
270
271 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
272 s = &psc_dma->capture;
273 else
274 s = &psc_dma->playback;
275
276 count = s->period_current * s->period_bytes;
277
278 return bytes_to_frames(substream->runtime, count);
279}
280
281static int psc_dma_new(struct snd_soc_component *component,
282 struct snd_soc_pcm_runtime *rtd)
283{
284 struct snd_card *card = rtd->card->snd_card;
268 struct psc_dma_stream *s;
269 dma_addr_t count;
270
271 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
272 s = &psc_dma->capture;
273 else
274 s = &psc_dma->playback;
275
276 count = s->period_current * s->period_bytes;
277
278 return bytes_to_frames(substream->runtime, count);
279}
280
281static int psc_dma_new(struct snd_soc_component *component,
282 struct snd_soc_pcm_runtime *rtd)
283{
284 struct snd_card *card = rtd->card->snd_card;
285 struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0);
285 struct snd_soc_dai *dai = snd_soc_rtd_to_cpu(rtd, 0);
286 struct snd_pcm *pcm = rtd->pcm;
287 size_t size = psc_dma_hardware.buffer_bytes_max;
288 int rc;
289
290 dev_dbg(component->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n",
291 card, dai, pcm);
292
293 rc = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));

--- 161 unchanged lines hidden ---
286 struct snd_pcm *pcm = rtd->pcm;
287 size_t size = psc_dma_hardware.buffer_bytes_max;
288 int rc;
289
290 dev_dbg(component->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n",
291 card, dai, pcm);
292
293 rc = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));

--- 161 unchanged lines hidden ---