forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/fsl/fsl_dma.c
....@@ -1,18 +1,14 @@
1
-/*
2
- * Freescale DMA ALSA SoC PCM driver
3
- *
4
- * Author: Timur Tabi <timur@freescale.com>
5
- *
6
- * Copyright 2007-2010 Freescale Semiconductor, Inc.
7
- *
8
- * This file is licensed under the terms of the GNU General Public License
9
- * version 2. This program is licensed "as is" without any warranty of any
10
- * kind, whether express or implied.
11
- *
12
- * This driver implements ASoC support for the Elo DMA controller, which is
13
- * the DMA controller on Freescale 83xx, 85xx, and 86xx SOCs. In ALSA terms,
14
- * the PCM driver is what handles the DMA buffer.
15
- */
1
+// SPDX-License-Identifier: GPL-2.0
2
+//
3
+// Freescale DMA ALSA SoC PCM driver
4
+//
5
+// Author: Timur Tabi <timur@freescale.com>
6
+//
7
+// Copyright 2007-2010 Freescale Semiconductor, Inc.
8
+//
9
+// This driver implements ASoC support for the Elo DMA controller, which is
10
+// the DMA controller on Freescale 83xx, 85xx, and 86xx SOCs. In ALSA terms,
11
+// the PCM driver is what handles the DMA buffer.
1612
1713 #include <linux/module.h>
1814 #include <linux/init.h>
....@@ -158,7 +154,7 @@
158154 /**
159155 * fsl_dma_update_pointers - update LD pointers to point to the next period
160156 *
161
- * As each period is completed, this function changes the the link
157
+ * As each period is completed, this function changes the link
162158 * descriptor pointers for that period to point to the next period.
163159 */
164160 static void fsl_dma_update_pointers(struct fsl_dma_private *dma_private)
....@@ -204,9 +200,8 @@
204200 {
205201 struct fsl_dma_private *dma_private = dev_id;
206202 struct snd_pcm_substream *substream = dma_private->substream;
207
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
208
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
209
- struct device *dev = component->dev;
203
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
204
+ struct device *dev = rtd->dev;
210205 struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel;
211206 irqreturn_t ret = IRQ_NONE;
212207 u32 sr, sr2 = 0;
....@@ -284,7 +279,8 @@
284279 * Regardless of where the memory is actually allocated, since the device can
285280 * technically DMA to any 36-bit address, we do need to set the DMA mask to 36.
286281 */
287
-static int fsl_dma_new(struct snd_soc_pcm_runtime *rtd)
282
+static int fsl_dma_new(struct snd_soc_component *component,
283
+ struct snd_soc_pcm_runtime *rtd)
288284 {
289285 struct snd_card *card = rtd->card->snd_card;
290286 struct snd_pcm *pcm = rtd->pcm;
....@@ -384,11 +380,10 @@
384380 * buffer, which is what ALSA expects. We're just dividing it into
385381 * contiguous parts, and creating a link descriptor for each one.
386382 */
387
-static int fsl_dma_open(struct snd_pcm_substream *substream)
383
+static int fsl_dma_open(struct snd_soc_component *component,
384
+ struct snd_pcm_substream *substream)
388385 {
389386 struct snd_pcm_runtime *runtime = substream->runtime;
390
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
391
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
392387 struct device *dev = component->dev;
393388 struct dma_object *dma =
394389 container_of(component->driver, struct dma_object, dai);
....@@ -537,13 +532,12 @@
537532 * and 8 bytes at a time). So we do not support packed 24-bit samples.
538533 * 24-bit data must be padded to 32 bits.
539534 */
540
-static int fsl_dma_hw_params(struct snd_pcm_substream *substream,
541
- struct snd_pcm_hw_params *hw_params)
535
+static int fsl_dma_hw_params(struct snd_soc_component *component,
536
+ struct snd_pcm_substream *substream,
537
+ struct snd_pcm_hw_params *hw_params)
542538 {
543539 struct snd_pcm_runtime *runtime = substream->runtime;
544540 struct fsl_dma_private *dma_private = runtime->private_data;
545
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
546
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
547541 struct device *dev = component->dev;
548542
549543 /* Number of bits per sample */
....@@ -702,12 +696,11 @@
702696 * The base address of the buffer is stored in the source_addr field of the
703697 * first link descriptor.
704698 */
705
-static snd_pcm_uframes_t fsl_dma_pointer(struct snd_pcm_substream *substream)
699
+static snd_pcm_uframes_t fsl_dma_pointer(struct snd_soc_component *component,
700
+ struct snd_pcm_substream *substream)
706701 {
707702 struct snd_pcm_runtime *runtime = substream->runtime;
708703 struct fsl_dma_private *dma_private = runtime->private_data;
709
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
710
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
711704 struct device *dev = component->dev;
712705 struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel;
713706 dma_addr_t position;
....@@ -767,7 +760,8 @@
767760 *
768761 * This function can be called multiple times.
769762 */
770
-static int fsl_dma_hw_free(struct snd_pcm_substream *substream)
763
+static int fsl_dma_hw_free(struct snd_soc_component *component,
764
+ struct snd_pcm_substream *substream)
771765 {
772766 struct snd_pcm_runtime *runtime = substream->runtime;
773767 struct fsl_dma_private *dma_private = runtime->private_data;
....@@ -800,12 +794,11 @@
800794 /**
801795 * fsl_dma_close: close the stream.
802796 */
803
-static int fsl_dma_close(struct snd_pcm_substream *substream)
797
+static int fsl_dma_close(struct snd_soc_component *component,
798
+ struct snd_pcm_substream *substream)
804799 {
805800 struct snd_pcm_runtime *runtime = substream->runtime;
806801 struct fsl_dma_private *dma_private = runtime->private_data;
807
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
808
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
809802 struct device *dev = component->dev;
810803 struct dma_object *dma =
811804 container_of(component->driver, struct dma_object, dai);
....@@ -828,7 +821,8 @@
828821 /*
829822 * Remove this PCM driver.
830823 */
831
-static void fsl_dma_free_dma_buffers(struct snd_pcm *pcm)
824
+static void fsl_dma_free_dma_buffers(struct snd_soc_component *component,
825
+ struct snd_pcm *pcm)
832826 {
833827 struct snd_pcm_substream *substream;
834828 unsigned int i;
....@@ -876,15 +870,6 @@
876870 return NULL;
877871 }
878872
879
-static const struct snd_pcm_ops fsl_dma_ops = {
880
- .open = fsl_dma_open,
881
- .close = fsl_dma_close,
882
- .ioctl = snd_pcm_lib_ioctl,
883
- .hw_params = fsl_dma_hw_params,
884
- .hw_free = fsl_dma_hw_free,
885
- .pointer = fsl_dma_pointer,
886
-};
887
-
888873 static int fsl_soc_dma_probe(struct platform_device *pdev)
889874 {
890875 struct dma_object *dma;
....@@ -916,9 +901,13 @@
916901 }
917902
918903 dma->dai.name = DRV_NAME;
919
- dma->dai.ops = &fsl_dma_ops;
920
- dma->dai.pcm_new = fsl_dma_new;
921
- dma->dai.pcm_free = fsl_dma_free_dma_buffers;
904
+ dma->dai.open = fsl_dma_open;
905
+ dma->dai.close = fsl_dma_close;
906
+ dma->dai.hw_params = fsl_dma_hw_params;
907
+ dma->dai.hw_free = fsl_dma_hw_free;
908
+ dma->dai.pointer = fsl_dma_pointer;
909
+ dma->dai.pcm_construct = fsl_dma_new;
910
+ dma->dai.pcm_destruct = fsl_dma_free_dma_buffers;
922911
923912 /* Store the SSI-specific information that we need */
924913 dma->ssi_stx_phys = res.start + REG_SSI_STX0;