| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/sound/soc/pxa/mmp-pcm.c |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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 | | - * |
|---|
| 11 | 6 | */ |
|---|
| 12 | 7 | #include <linux/module.h> |
|---|
| 13 | 8 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 60 | 55 | }, |
|---|
| 61 | 56 | }; |
|---|
| 62 | 57 | |
|---|
| 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) |
|---|
| 65 | 61 | { |
|---|
| 66 | 62 | struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); |
|---|
| 67 | 63 | struct dma_slave_config slave_config; |
|---|
| .. | .. |
|---|
| 82 | 78 | return 0; |
|---|
| 83 | 79 | } |
|---|
| 84 | 80 | |
|---|
| 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 | + |
|---|
| 85 | 93 | static bool filter(struct dma_chan *chan, void *param) |
|---|
| 86 | 94 | { |
|---|
| 87 | 95 | struct mmp_dma_data *dma_data = param; |
|---|
| .. | .. |
|---|
| 99 | 107 | return found; |
|---|
| 100 | 108 | } |
|---|
| 101 | 109 | |
|---|
| 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) |
|---|
| 103 | 112 | { |
|---|
| 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); |
|---|
| 106 | 114 | 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); |
|---|
| 108 | 116 | struct mmp_dma_data dma_data; |
|---|
| 109 | 117 | struct resource *r; |
|---|
| 110 | 118 | |
|---|
| .. | .. |
|---|
| 122 | 130 | &dma_data); |
|---|
| 123 | 131 | } |
|---|
| 124 | 132 | |
|---|
| 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) |
|---|
| 127 | 142 | { |
|---|
| 128 | 143 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 129 | 144 | unsigned long off = vma->vm_pgoff; |
|---|
| .. | .. |
|---|
| 134 | 149 | vma->vm_end - vma->vm_start, vma->vm_page_prot); |
|---|
| 135 | 150 | } |
|---|
| 136 | 151 | |
|---|
| 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) |
|---|
| 148 | 154 | { |
|---|
| 149 | 155 | struct snd_pcm_substream *substream; |
|---|
| 150 | 156 | struct snd_dma_buffer *buf; |
|---|
| .. | .. |
|---|
| 193 | 199 | return 0; |
|---|
| 194 | 200 | } |
|---|
| 195 | 201 | |
|---|
| 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) |
|---|
| 197 | 204 | { |
|---|
| 198 | 205 | struct snd_pcm_substream *substream; |
|---|
| 199 | 206 | struct snd_pcm *pcm = rtd->pcm; |
|---|
| .. | .. |
|---|
| 210 | 217 | return 0; |
|---|
| 211 | 218 | |
|---|
| 212 | 219 | err: |
|---|
| 213 | | - mmp_pcm_free_dma_buffers(pcm); |
|---|
| 220 | + mmp_pcm_free_dma_buffers(component, pcm); |
|---|
| 214 | 221 | return ret; |
|---|
| 215 | 222 | } |
|---|
| 216 | 223 | |
|---|
| 217 | 224 | static const struct snd_soc_component_driver mmp_soc_component = { |
|---|
| 218 | 225 | .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, |
|---|
| 222 | 234 | }; |
|---|
| 223 | 235 | |
|---|
| 224 | 236 | static int mmp_pcm_probe(struct platform_device *pdev) |
|---|