| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * atmel-pcm-dma.c -- ALSA PCM DMA support for the Atmel SoC. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 8 | 9 | * Based on atmel-pcm by: |
|---|
| 9 | 10 | * Sedji Gaouaou <sedji.gaouaou@atmel.com> |
|---|
| 10 | 11 | * Copyright 2008 Atmel |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 13 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 14 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 15 | | - * (at your option) any later version. |
|---|
| 16 | | - * |
|---|
| 17 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 18 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | | - * GNU General Public License for more details. |
|---|
| 21 | | - * |
|---|
| 22 | | - * You should have received a copy of the GNU General Public License |
|---|
| 23 | | - * along with this program; if not, write to the Free Software |
|---|
| 24 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 25 | 12 | */ |
|---|
| 26 | 13 | |
|---|
| 27 | 14 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 31 | 18 | #include <linux/dma-mapping.h> |
|---|
| 32 | 19 | #include <linux/dmaengine.h> |
|---|
| 33 | 20 | #include <linux/atmel-ssc.h> |
|---|
| 34 | | -#include <linux/platform_data/dma-atmel.h> |
|---|
| 35 | 21 | |
|---|
| 36 | 22 | #include <sound/core.h> |
|---|
| 37 | 23 | #include <sound/pcm.h> |
|---|
| .. | .. |
|---|
| 57 | 43 | .buffer_bytes_max = 512 * 1024, |
|---|
| 58 | 44 | }; |
|---|
| 59 | 45 | |
|---|
| 60 | | -/** |
|---|
| 46 | +/* |
|---|
| 61 | 47 | * atmel_pcm_dma_irq: SSC interrupt handler for DMAENGINE enabled SSC |
|---|
| 62 | 48 | * |
|---|
| 63 | 49 | * We use DMAENGINE to send/receive data to/from SSC so this ISR is only to |
|---|
| .. | .. |
|---|
| 66 | 52 | static void atmel_pcm_dma_irq(u32 ssc_sr, |
|---|
| 67 | 53 | struct snd_pcm_substream *substream) |
|---|
| 68 | 54 | { |
|---|
| 69 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 55 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 70 | 56 | struct atmel_pcm_dma_params *prtd; |
|---|
| 71 | 57 | |
|---|
| 72 | | - prtd = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); |
|---|
| 58 | + prtd = snd_soc_dai_get_dma_data(asoc_rtd_to_cpu(rtd, 0), substream); |
|---|
| 73 | 59 | |
|---|
| 74 | 60 | if (ssc_sr & prtd->mask->ssc_error) { |
|---|
| 75 | 61 | if (snd_pcm_running(substream)) |
|---|
| .. | .. |
|---|
| 91 | 77 | static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream, |
|---|
| 92 | 78 | struct snd_pcm_hw_params *params, struct dma_slave_config *slave_config) |
|---|
| 93 | 79 | { |
|---|
| 94 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 80 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 95 | 81 | struct atmel_pcm_dma_params *prtd; |
|---|
| 96 | 82 | struct ssc_device *ssc; |
|---|
| 97 | 83 | int ret; |
|---|
| 98 | 84 | |
|---|
| 99 | | - prtd = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); |
|---|
| 85 | + prtd = snd_soc_dai_get_dma_data(asoc_rtd_to_cpu(rtd, 0), substream); |
|---|
| 100 | 86 | ssc = prtd->ssc; |
|---|
| 101 | 87 | |
|---|
| 102 | 88 | ret = snd_hwparams_to_dma_slave_config(substream, params, slave_config); |
|---|
| .. | .. |
|---|
| 124 | 110 | |
|---|
| 125 | 111 | int atmel_pcm_dma_platform_register(struct device *dev) |
|---|
| 126 | 112 | { |
|---|
| 127 | | - return snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config, 0); |
|---|
| 113 | + return devm_snd_dmaengine_pcm_register(dev, |
|---|
| 114 | + &atmel_dmaengine_pcm_config, 0); |
|---|
| 128 | 115 | } |
|---|
| 129 | 116 | EXPORT_SYMBOL(atmel_pcm_dma_platform_register); |
|---|
| 130 | | - |
|---|
| 131 | | -void atmel_pcm_dma_platform_unregister(struct device *dev) |
|---|
| 132 | | -{ |
|---|
| 133 | | - snd_dmaengine_pcm_unregister(dev); |
|---|
| 134 | | -} |
|---|
| 135 | | -EXPORT_SYMBOL(atmel_pcm_dma_platform_unregister); |
|---|
| 136 | 117 | |
|---|
| 137 | 118 | MODULE_AUTHOR("Bo Shen <voice.shen@atmel.com>"); |
|---|
| 138 | 119 | MODULE_DESCRIPTION("Atmel DMA based PCM module"); |
|---|