.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * atmel-pcm.c -- ALSA PCM interface for the Atmel atmel SoC. |
---|
3 | 4 | * |
---|
.. | .. |
---|
15 | 16 | * Author: Nicolas Pitre |
---|
16 | 17 | * Created: Nov 30, 2004 |
---|
17 | 18 | * 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 |
---|
32 | 19 | */ |
---|
33 | 20 | |
---|
34 | 21 | #include <linux/module.h> |
---|
.. | .. |
---|
69 | 56 | return 0; |
---|
70 | 57 | } |
---|
71 | 58 | |
---|
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) |
---|
74 | 62 | { |
---|
75 | 63 | return remap_pfn_range(vma, vma->vm_start, |
---|
76 | 64 | substream->dma_buffer.addr >> PAGE_SHIFT, |
---|
77 | 65 | vma->vm_end - vma->vm_start, vma->vm_page_prot); |
---|
78 | 66 | } |
---|
79 | 67 | |
---|
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) |
---|
81 | 70 | { |
---|
82 | 71 | struct snd_card *card = rtd->card->snd_card; |
---|
83 | 72 | struct snd_pcm *pcm = rtd->pcm; |
---|
.. | .. |
---|
106 | 95 | return ret; |
---|
107 | 96 | } |
---|
108 | 97 | |
---|
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) |
---|
110 | 100 | { |
---|
111 | 101 | struct snd_pcm_substream *substream; |
---|
112 | 102 | struct snd_dma_buffer *buf; |
---|
.. | .. |
---|
209 | 199 | /*--------------------------------------------------------------------------*\ |
---|
210 | 200 | * PCM operations |
---|
211 | 201 | \*--------------------------------------------------------------------------*/ |
---|
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) |
---|
214 | 205 | { |
---|
215 | 206 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
216 | 207 | 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); |
---|
218 | 209 | |
---|
219 | 210 | /* this may get called several times by oss emulation |
---|
220 | 211 | * with different params */ |
---|
.. | .. |
---|
222 | 213 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); |
---|
223 | 214 | runtime->dma_bytes = params_buffer_bytes(params); |
---|
224 | 215 | |
---|
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); |
---|
226 | 217 | prtd->params->dma_intr_handler = atmel_pcm_dma_irq; |
---|
227 | 218 | |
---|
228 | 219 | prtd->dma_buffer = runtime->dma_addr; |
---|
.. | .. |
---|
238 | 229 | return 0; |
---|
239 | 230 | } |
---|
240 | 231 | |
---|
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) |
---|
242 | 234 | { |
---|
243 | 235 | struct atmel_runtime_data *prtd = substream->runtime->private_data; |
---|
244 | 236 | struct atmel_pcm_dma_params *params = prtd->params; |
---|
.. | .. |
---|
252 | 244 | return 0; |
---|
253 | 245 | } |
---|
254 | 246 | |
---|
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) |
---|
256 | 249 | { |
---|
257 | 250 | struct atmel_runtime_data *prtd = substream->runtime->private_data; |
---|
258 | 251 | struct atmel_pcm_dma_params *params = prtd->params; |
---|
.. | .. |
---|
264 | 257 | return 0; |
---|
265 | 258 | } |
---|
266 | 259 | |
---|
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) |
---|
269 | 262 | { |
---|
270 | 263 | struct snd_pcm_runtime *rtd = substream->runtime; |
---|
271 | 264 | struct atmel_runtime_data *prtd = rtd->private_data; |
---|
.. | .. |
---|
330 | 323 | return ret; |
---|
331 | 324 | } |
---|
332 | 325 | |
---|
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) |
---|
335 | 328 | { |
---|
336 | 329 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
337 | 330 | struct atmel_runtime_data *prtd = runtime->private_data; |
---|
.. | .. |
---|
348 | 341 | return x; |
---|
349 | 342 | } |
---|
350 | 343 | |
---|
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) |
---|
352 | 346 | { |
---|
353 | 347 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
354 | 348 | struct atmel_runtime_data *prtd; |
---|
.. | .. |
---|
373 | 367 | return ret; |
---|
374 | 368 | } |
---|
375 | 369 | |
---|
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) |
---|
377 | 372 | { |
---|
378 | 373 | struct atmel_runtime_data *prtd = substream->runtime->private_data; |
---|
379 | 374 | |
---|
.. | .. |
---|
381 | 376 | return 0; |
---|
382 | 377 | } |
---|
383 | 378 | |
---|
384 | | -static const struct snd_pcm_ops atmel_pcm_ops = { |
---|
| 379 | +static const struct snd_soc_component_driver atmel_soc_platform = { |
---|
385 | 380 | .open = atmel_pcm_open, |
---|
386 | 381 | .close = atmel_pcm_close, |
---|
387 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
388 | 382 | .hw_params = atmel_pcm_hw_params, |
---|
389 | 383 | .hw_free = atmel_pcm_hw_free, |
---|
390 | 384 | .prepare = atmel_pcm_prepare, |
---|
391 | 385 | .trigger = atmel_pcm_trigger, |
---|
392 | 386 | .pointer = atmel_pcm_pointer, |
---|
393 | 387 | .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, |
---|
400 | 390 | }; |
---|
401 | 391 | |
---|
402 | 392 | int atmel_pcm_pdc_platform_register(struct device *dev) |
---|
.. | .. |
---|
405 | 395 | NULL, 0); |
---|
406 | 396 | } |
---|
407 | 397 | 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); |
---|
413 | 398 | |
---|
414 | 399 | MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>"); |
---|
415 | 400 | MODULE_DESCRIPTION("Atmel PCM module"); |
---|