hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/sound/soc/pxa/mmp-pcm.c
....@@ -1,13 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * linux/sound/soc/pxa/mmp-pcm.c
34 *
45 * Copyright (C) 2011 Marvell International Ltd.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
116 */
127 #include <linux/module.h>
138 #include <linux/init.h>
....@@ -60,8 +55,9 @@
6055 },
6156 };
6257
63
-static int mmp_pcm_hw_params(struct snd_pcm_substream *substream,
64
- struct snd_pcm_hw_params *params)
58
+static int mmp_pcm_hw_params(struct snd_soc_component *component,
59
+ struct snd_pcm_substream *substream,
60
+ struct snd_pcm_hw_params *params)
6561 {
6662 struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream);
6763 struct dma_slave_config slave_config;
....@@ -82,6 +78,18 @@
8278 return 0;
8379 }
8480
81
+static int mmp_pcm_trigger(struct snd_soc_component *component,
82
+ struct snd_pcm_substream *substream, int cmd)
83
+{
84
+ return snd_dmaengine_pcm_trigger(substream, cmd);
85
+}
86
+
87
+static snd_pcm_uframes_t mmp_pcm_pointer(struct snd_soc_component *component,
88
+ struct snd_pcm_substream *substream)
89
+{
90
+ return snd_dmaengine_pcm_pointer(substream);
91
+}
92
+
8593 static bool filter(struct dma_chan *chan, void *param)
8694 {
8795 struct mmp_dma_data *dma_data = param;
....@@ -99,12 +107,12 @@
99107 return found;
100108 }
101109
102
-static int mmp_pcm_open(struct snd_pcm_substream *substream)
110
+static int mmp_pcm_open(struct snd_soc_component *component,
111
+ struct snd_pcm_substream *substream)
103112 {
104
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
105
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
113
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
106114 struct platform_device *pdev = to_platform_device(component->dev);
107
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
115
+ struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
108116 struct mmp_dma_data dma_data;
109117 struct resource *r;
110118
....@@ -122,8 +130,15 @@
122130 &dma_data);
123131 }
124132
125
-static int mmp_pcm_mmap(struct snd_pcm_substream *substream,
126
- struct vm_area_struct *vma)
133
+static int mmp_pcm_close(struct snd_soc_component *component,
134
+ struct snd_pcm_substream *substream)
135
+{
136
+ return snd_dmaengine_pcm_close_release_chan(substream);
137
+}
138
+
139
+static int mmp_pcm_mmap(struct snd_soc_component *component,
140
+ struct snd_pcm_substream *substream,
141
+ struct vm_area_struct *vma)
127142 {
128143 struct snd_pcm_runtime *runtime = substream->runtime;
129144 unsigned long off = vma->vm_pgoff;
....@@ -134,17 +149,8 @@
134149 vma->vm_end - vma->vm_start, vma->vm_page_prot);
135150 }
136151
137
-static const struct snd_pcm_ops mmp_pcm_ops = {
138
- .open = mmp_pcm_open,
139
- .close = snd_dmaengine_pcm_close_release_chan,
140
- .ioctl = snd_pcm_lib_ioctl,
141
- .hw_params = mmp_pcm_hw_params,
142
- .trigger = snd_dmaengine_pcm_trigger,
143
- .pointer = snd_dmaengine_pcm_pointer,
144
- .mmap = mmp_pcm_mmap,
145
-};
146
-
147
-static void mmp_pcm_free_dma_buffers(struct snd_pcm *pcm)
152
+static void mmp_pcm_free_dma_buffers(struct snd_soc_component *component,
153
+ struct snd_pcm *pcm)
148154 {
149155 struct snd_pcm_substream *substream;
150156 struct snd_dma_buffer *buf;
....@@ -193,7 +199,8 @@
193199 return 0;
194200 }
195201
196
-static int mmp_pcm_new(struct snd_soc_pcm_runtime *rtd)
202
+static int mmp_pcm_new(struct snd_soc_component *component,
203
+ struct snd_soc_pcm_runtime *rtd)
197204 {
198205 struct snd_pcm_substream *substream;
199206 struct snd_pcm *pcm = rtd->pcm;
....@@ -210,15 +217,20 @@
210217 return 0;
211218
212219 err:
213
- mmp_pcm_free_dma_buffers(pcm);
220
+ mmp_pcm_free_dma_buffers(component, pcm);
214221 return ret;
215222 }
216223
217224 static const struct snd_soc_component_driver mmp_soc_component = {
218225 .name = DRV_NAME,
219
- .ops = &mmp_pcm_ops,
220
- .pcm_new = mmp_pcm_new,
221
- .pcm_free = mmp_pcm_free_dma_buffers,
226
+ .open = mmp_pcm_open,
227
+ .close = mmp_pcm_close,
228
+ .hw_params = mmp_pcm_hw_params,
229
+ .trigger = mmp_pcm_trigger,
230
+ .pointer = mmp_pcm_pointer,
231
+ .mmap = mmp_pcm_mmap,
232
+ .pcm_construct = mmp_pcm_new,
233
+ .pcm_destruct = mmp_pcm_free_dma_buffers,
222234 };
223235
224236 static int mmp_pcm_probe(struct platform_device *pdev)