forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/fsl/mpc5200_dma.c
....@@ -1,10 +1,10 @@
1
-/*
2
- * Freescale MPC5200 PSC DMA
3
- * ALSA SoC Platform driver
4
- *
5
- * Copyright (C) 2008 Secret Lab Technologies Ltd.
6
- * Copyright (C) 2009 Jon Smirl, Digispeaker
7
- */
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
88
99 #include <linux/module.h>
1010 #include <linux/of_device.h>
....@@ -98,7 +98,8 @@
9898 return IRQ_HANDLED;
9999 }
100100
101
-static int psc_dma_hw_free(struct snd_pcm_substream *substream)
101
+static int psc_dma_hw_free(struct snd_soc_component *component,
102
+ struct snd_pcm_substream *substream)
102103 {
103104 snd_pcm_set_runtime_buffer(substream, NULL);
104105 return 0;
....@@ -110,10 +111,11 @@
110111 * This function is called by ALSA to start, stop, pause, and resume the DMA
111112 * transfer of data.
112113 */
113
-static int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd)
114
+static int psc_dma_trigger(struct snd_soc_component *component,
115
+ struct snd_pcm_substream *substream, int cmd)
114116 {
115
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
116
- struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai);
117
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
118
+ struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
117119 struct snd_pcm_runtime *runtime = substream->runtime;
118120 struct psc_dma_stream *s = to_psc_dma_stream(substream, psc_dma);
119121 struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs;
....@@ -210,11 +212,12 @@
210212 .fifo_size = 512,
211213 };
212214
213
-static int psc_dma_open(struct snd_pcm_substream *substream)
215
+static int psc_dma_open(struct snd_soc_component *component,
216
+ struct snd_pcm_substream *substream)
214217 {
215218 struct snd_pcm_runtime *runtime = substream->runtime;
216
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
217
- struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai);
219
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
220
+ struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
218221 struct psc_dma_stream *s;
219222 int rc;
220223
....@@ -238,10 +241,11 @@
238241 return 0;
239242 }
240243
241
-static int psc_dma_close(struct snd_pcm_substream *substream)
244
+static int psc_dma_close(struct snd_soc_component *component,
245
+ struct snd_pcm_substream *substream)
242246 {
243
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
244
- struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai);
247
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
248
+ struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
245249 struct psc_dma_stream *s;
246250
247251 dev_dbg(psc_dma->dev, "psc_dma_close(substream=%p)\n", substream);
....@@ -263,10 +267,11 @@
263267 }
264268
265269 static snd_pcm_uframes_t
266
-psc_dma_pointer(struct snd_pcm_substream *substream)
270
+psc_dma_pointer(struct snd_soc_component *component,
271
+ struct snd_pcm_substream *substream)
267272 {
268
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
269
- struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai);
273
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
274
+ struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
270275 struct psc_dma_stream *s;
271276 dma_addr_t count;
272277
....@@ -280,30 +285,20 @@
280285 return bytes_to_frames(substream->runtime, count);
281286 }
282287
283
-static int
284
-psc_dma_hw_params(struct snd_pcm_substream *substream,
285
- struct snd_pcm_hw_params *params)
288
+static int psc_dma_hw_params(struct snd_soc_component *component,
289
+ struct snd_pcm_substream *substream,
290
+ struct snd_pcm_hw_params *params)
286291 {
287292 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
288293
289294 return 0;
290295 }
291296
292
-static const struct snd_pcm_ops psc_dma_ops = {
293
- .open = psc_dma_open,
294
- .close = psc_dma_close,
295
- .hw_free = psc_dma_hw_free,
296
- .ioctl = snd_pcm_lib_ioctl,
297
- .pointer = psc_dma_pointer,
298
- .trigger = psc_dma_trigger,
299
- .hw_params = psc_dma_hw_params,
300
-};
301
-
302
-static int psc_dma_new(struct snd_soc_pcm_runtime *rtd)
297
+static int psc_dma_new(struct snd_soc_component *component,
298
+ struct snd_soc_pcm_runtime *rtd)
303299 {
304300 struct snd_card *card = rtd->card->snd_card;
305
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
306
- struct snd_soc_dai *dai = rtd->cpu_dai;
301
+ struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0);
307302 struct snd_pcm *pcm = rtd->pcm;
308303 size_t size = psc_dma_hardware.buffer_bytes_max;
309304 int rc;
....@@ -341,10 +336,9 @@
341336 return -ENOMEM;
342337 }
343338
344
-static void psc_dma_free(struct snd_pcm *pcm)
339
+static void psc_dma_free(struct snd_soc_component *component,
340
+ struct snd_pcm *pcm)
345341 {
346
- struct snd_soc_pcm_runtime *rtd = pcm->private_data;
347
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
348342 struct snd_pcm_substream *substream;
349343 int stream;
350344
....@@ -362,9 +356,14 @@
362356
363357 static const struct snd_soc_component_driver mpc5200_audio_dma_component = {
364358 .name = DRV_NAME,
365
- .ops = &psc_dma_ops,
366
- .pcm_new = &psc_dma_new,
367
- .pcm_free = &psc_dma_free,
359
+ .open = psc_dma_open,
360
+ .close = psc_dma_close,
361
+ .hw_free = psc_dma_hw_free,
362
+ .pointer = psc_dma_pointer,
363
+ .trigger = psc_dma_trigger,
364
+ .hw_params = psc_dma_hw_params,
365
+ .pcm_construct = psc_dma_new,
366
+ .pcm_destruct = psc_dma_free,
368367 };
369368
370369 int mpc5200_audio_dma_create(struct platform_device *op)