forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/atmel/atmel-pcm-pdc.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * atmel-pcm.c -- ALSA PCM interface for the Atmel atmel SoC.
34 *
....@@ -15,20 +16,6 @@
1516 * Author: Nicolas Pitre
1617 * Created: Nov 30, 2004
1718 * Copyright: (C) 2004 MontaVista Software, Inc.
18
- *
19
- * This program is free software; you can redistribute it and/or modify
20
- * it under the terms of the GNU General Public License as published by
21
- * the Free Software Foundation; either version 2 of the License, or
22
- * (at your option) any later version.
23
- *
24
- * This program is distributed in the hope that it will be useful,
25
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- * GNU General Public License for more details.
28
- *
29
- * You should have received a copy of the GNU General Public License
30
- * along with this program; if not, write to the Free Software
31
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3219 */
3320
3421 #include <linux/module.h>
....@@ -69,15 +56,17 @@
6956 return 0;
7057 }
7158
72
-static int atmel_pcm_mmap(struct snd_pcm_substream *substream,
73
- struct vm_area_struct *vma)
59
+static int atmel_pcm_mmap(struct snd_soc_component *component,
60
+ struct snd_pcm_substream *substream,
61
+ struct vm_area_struct *vma)
7462 {
7563 return remap_pfn_range(vma, vma->vm_start,
7664 substream->dma_buffer.addr >> PAGE_SHIFT,
7765 vma->vm_end - vma->vm_start, vma->vm_page_prot);
7866 }
7967
80
-static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
68
+static int atmel_pcm_new(struct snd_soc_component *component,
69
+ struct snd_soc_pcm_runtime *rtd)
8170 {
8271 struct snd_card *card = rtd->card->snd_card;
8372 struct snd_pcm *pcm = rtd->pcm;
....@@ -106,7 +95,8 @@
10695 return ret;
10796 }
10897
109
-static void atmel_pcm_free(struct snd_pcm *pcm)
98
+static void atmel_pcm_free(struct snd_soc_component *component,
99
+ struct snd_pcm *pcm)
110100 {
111101 struct snd_pcm_substream *substream;
112102 struct snd_dma_buffer *buf;
....@@ -209,12 +199,13 @@
209199 /*--------------------------------------------------------------------------*\
210200 * PCM operations
211201 \*--------------------------------------------------------------------------*/
212
-static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
213
- struct snd_pcm_hw_params *params)
202
+static int atmel_pcm_hw_params(struct snd_soc_component *component,
203
+ struct snd_pcm_substream *substream,
204
+ struct snd_pcm_hw_params *params)
214205 {
215206 struct snd_pcm_runtime *runtime = substream->runtime;
216207 struct atmel_runtime_data *prtd = runtime->private_data;
217
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
208
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
218209
219210 /* this may get called several times by oss emulation
220211 * with different params */
....@@ -222,7 +213,7 @@
222213 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
223214 runtime->dma_bytes = params_buffer_bytes(params);
224215
225
- prtd->params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
216
+ prtd->params = snd_soc_dai_get_dma_data(asoc_rtd_to_cpu(rtd, 0), substream);
226217 prtd->params->dma_intr_handler = atmel_pcm_dma_irq;
227218
228219 prtd->dma_buffer = runtime->dma_addr;
....@@ -238,7 +229,8 @@
238229 return 0;
239230 }
240231
241
-static int atmel_pcm_hw_free(struct snd_pcm_substream *substream)
232
+static int atmel_pcm_hw_free(struct snd_soc_component *component,
233
+ struct snd_pcm_substream *substream)
242234 {
243235 struct atmel_runtime_data *prtd = substream->runtime->private_data;
244236 struct atmel_pcm_dma_params *params = prtd->params;
....@@ -252,7 +244,8 @@
252244 return 0;
253245 }
254246
255
-static int atmel_pcm_prepare(struct snd_pcm_substream *substream)
247
+static int atmel_pcm_prepare(struct snd_soc_component *component,
248
+ struct snd_pcm_substream *substream)
256249 {
257250 struct atmel_runtime_data *prtd = substream->runtime->private_data;
258251 struct atmel_pcm_dma_params *params = prtd->params;
....@@ -264,8 +257,8 @@
264257 return 0;
265258 }
266259
267
-static int atmel_pcm_trigger(struct snd_pcm_substream *substream,
268
- int cmd)
260
+static int atmel_pcm_trigger(struct snd_soc_component *component,
261
+ struct snd_pcm_substream *substream, int cmd)
269262 {
270263 struct snd_pcm_runtime *rtd = substream->runtime;
271264 struct atmel_runtime_data *prtd = rtd->private_data;
....@@ -330,8 +323,8 @@
330323 return ret;
331324 }
332325
333
-static snd_pcm_uframes_t atmel_pcm_pointer(
334
- struct snd_pcm_substream *substream)
326
+static snd_pcm_uframes_t atmel_pcm_pointer(struct snd_soc_component *component,
327
+ struct snd_pcm_substream *substream)
335328 {
336329 struct snd_pcm_runtime *runtime = substream->runtime;
337330 struct atmel_runtime_data *prtd = runtime->private_data;
....@@ -348,7 +341,8 @@
348341 return x;
349342 }
350343
351
-static int atmel_pcm_open(struct snd_pcm_substream *substream)
344
+static int atmel_pcm_open(struct snd_soc_component *component,
345
+ struct snd_pcm_substream *substream)
352346 {
353347 struct snd_pcm_runtime *runtime = substream->runtime;
354348 struct atmel_runtime_data *prtd;
....@@ -373,7 +367,8 @@
373367 return ret;
374368 }
375369
376
-static int atmel_pcm_close(struct snd_pcm_substream *substream)
370
+static int atmel_pcm_close(struct snd_soc_component *component,
371
+ struct snd_pcm_substream *substream)
377372 {
378373 struct atmel_runtime_data *prtd = substream->runtime->private_data;
379374
....@@ -381,22 +376,17 @@
381376 return 0;
382377 }
383378
384
-static const struct snd_pcm_ops atmel_pcm_ops = {
379
+static const struct snd_soc_component_driver atmel_soc_platform = {
385380 .open = atmel_pcm_open,
386381 .close = atmel_pcm_close,
387
- .ioctl = snd_pcm_lib_ioctl,
388382 .hw_params = atmel_pcm_hw_params,
389383 .hw_free = atmel_pcm_hw_free,
390384 .prepare = atmel_pcm_prepare,
391385 .trigger = atmel_pcm_trigger,
392386 .pointer = atmel_pcm_pointer,
393387 .mmap = atmel_pcm_mmap,
394
-};
395
-
396
-static struct snd_soc_component_driver atmel_soc_platform = {
397
- .ops = &atmel_pcm_ops,
398
- .pcm_new = atmel_pcm_new,
399
- .pcm_free = atmel_pcm_free,
388
+ .pcm_construct = atmel_pcm_new,
389
+ .pcm_destruct = atmel_pcm_free,
400390 };
401391
402392 int atmel_pcm_pdc_platform_register(struct device *dev)
....@@ -405,11 +395,6 @@
405395 NULL, 0);
406396 }
407397 EXPORT_SYMBOL(atmel_pcm_pdc_platform_register);
408
-
409
-void atmel_pcm_pdc_platform_unregister(struct device *dev)
410
-{
411
-}
412
-EXPORT_SYMBOL(atmel_pcm_pdc_platform_unregister);
413398
414399 MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>");
415400 MODULE_DESCRIPTION("Atmel PCM module");