forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/uniphier/aio-dma.c
....@@ -93,7 +93,8 @@
9393 return ret;
9494 }
9595
96
-static int uniphier_aiodma_open(struct snd_pcm_substream *substream)
96
+static int uniphier_aiodma_open(struct snd_soc_component *component,
97
+ struct snd_pcm_substream *substream)
9798 {
9899 struct snd_pcm_runtime *runtime = substream->runtime;
99100
....@@ -103,28 +104,12 @@
103104 SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256);
104105 }
105106
106
-static int uniphier_aiodma_hw_params(struct snd_pcm_substream *substream,
107
- struct snd_pcm_hw_params *params)
108
-{
109
- snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
110
- substream->runtime->dma_bytes = params_buffer_bytes(params);
111
-
112
- return 0;
113
-}
114
-
115
-static int uniphier_aiodma_hw_free(struct snd_pcm_substream *substream)
116
-{
117
- snd_pcm_set_runtime_buffer(substream, NULL);
118
- substream->runtime->dma_bytes = 0;
119
-
120
- return 0;
121
-}
122
-
123
-static int uniphier_aiodma_prepare(struct snd_pcm_substream *substream)
107
+static int uniphier_aiodma_prepare(struct snd_soc_component *component,
108
+ struct snd_pcm_substream *substream)
124109 {
125110 struct snd_pcm_runtime *runtime = substream->runtime;
126
- struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
127
- struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai);
111
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
112
+ struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
128113 struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
129114 int bytes = runtime->period_size *
130115 runtime->channels * samples_to_bytes(runtime, 1);
....@@ -146,11 +131,12 @@
146131 return 0;
147132 }
148133
149
-static int uniphier_aiodma_trigger(struct snd_pcm_substream *substream, int cmd)
134
+static int uniphier_aiodma_trigger(struct snd_soc_component *component,
135
+ struct snd_pcm_substream *substream, int cmd)
150136 {
151137 struct snd_pcm_runtime *runtime = substream->runtime;
152
- struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
153
- struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai);
138
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
139
+ struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
154140 struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
155141 struct device *dev = &aio->chip->pdev->dev;
156142 int bytes = runtime->period_size *
....@@ -181,11 +167,12 @@
181167 }
182168
183169 static snd_pcm_uframes_t uniphier_aiodma_pointer(
170
+ struct snd_soc_component *component,
184171 struct snd_pcm_substream *substream)
185172 {
186173 struct snd_pcm_runtime *runtime = substream->runtime;
187
- struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
188
- struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai);
174
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
175
+ struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0));
189176 struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
190177 int bytes = runtime->period_size *
191178 runtime->channels * samples_to_bytes(runtime, 1);
....@@ -204,28 +191,19 @@
204191 return pos;
205192 }
206193
207
-static int uniphier_aiodma_mmap(struct snd_pcm_substream *substream,
194
+static int uniphier_aiodma_mmap(struct snd_soc_component *component,
195
+ struct snd_pcm_substream *substream,
208196 struct vm_area_struct *vma)
209197 {
210198 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
211199
212200 return remap_pfn_range(vma, vma->vm_start,
213
- substream->dma_buffer.addr >> PAGE_SHIFT,
201
+ substream->runtime->dma_addr >> PAGE_SHIFT,
214202 vma->vm_end - vma->vm_start, vma->vm_page_prot);
215203 }
216204
217
-static const struct snd_pcm_ops uniphier_aiodma_ops = {
218
- .open = uniphier_aiodma_open,
219
- .ioctl = snd_pcm_lib_ioctl,
220
- .hw_params = uniphier_aiodma_hw_params,
221
- .hw_free = uniphier_aiodma_hw_free,
222
- .prepare = uniphier_aiodma_prepare,
223
- .trigger = uniphier_aiodma_trigger,
224
- .pointer = uniphier_aiodma_pointer,
225
- .mmap = uniphier_aiodma_mmap,
226
-};
227
-
228
-static int uniphier_aiodma_new(struct snd_soc_pcm_runtime *rtd)
205
+static int uniphier_aiodma_new(struct snd_soc_component *component,
206
+ struct snd_soc_pcm_runtime *rtd)
229207 {
230208 struct device *dev = rtd->card->snd_card->dev;
231209 struct snd_pcm *pcm = rtd->pcm;
....@@ -235,22 +213,21 @@
235213 if (ret)
236214 return ret;
237215
238
- return snd_pcm_lib_preallocate_pages_for_all(pcm,
216
+ snd_pcm_set_managed_buffer_all(pcm,
239217 SNDRV_DMA_TYPE_DEV, dev,
240218 uniphier_aiodma_hw.buffer_bytes_max,
241219 uniphier_aiodma_hw.buffer_bytes_max);
242
-}
243
-
244
-static void uniphier_aiodma_free(struct snd_pcm *pcm)
245
-{
246
- snd_pcm_lib_preallocate_free_for_all(pcm);
220
+ return 0;
247221 }
248222
249223 static const struct snd_soc_component_driver uniphier_soc_platform = {
250
- .pcm_new = uniphier_aiodma_new,
251
- .pcm_free = uniphier_aiodma_free,
252
- .ops = &uniphier_aiodma_ops,
253
- .compr_ops = &uniphier_aio_compr_ops,
224
+ .open = uniphier_aiodma_open,
225
+ .prepare = uniphier_aiodma_prepare,
226
+ .trigger = uniphier_aiodma_trigger,
227
+ .pointer = uniphier_aiodma_pointer,
228
+ .mmap = uniphier_aiodma_mmap,
229
+ .pcm_construct = uniphier_aiodma_new,
230
+ .compress_ops = &uniphier_aio_compress_ops,
254231 };
255232
256233 static const struct regmap_config aiodma_regmap_config = {
....@@ -275,12 +252,10 @@
275252 {
276253 struct uniphier_aio_chip *chip = platform_get_drvdata(pdev);
277254 struct device *dev = &pdev->dev;
278
- struct resource *res;
279255 void __iomem *preg;
280256 int irq, ret;
281257
282
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
283
- preg = devm_ioremap_resource(dev, res);
258
+ preg = devm_platform_ioremap_resource(pdev, 0);
284259 if (IS_ERR(preg))
285260 return PTR_ERR(preg);
286261
....@@ -290,10 +265,8 @@
290265 return PTR_ERR(chip->regmap);
291266
292267 irq = platform_get_irq(pdev, 0);
293
- if (irq < 0) {
294
- dev_err(dev, "Could not get irq.\n");
268
+ if (irq < 0)
295269 return irq;
296
- }
297270
298271 ret = devm_request_irq(dev, irq, aiodma_irq,
299272 IRQF_SHARED, dev_name(dev), pdev);