.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Au12x0/Au1550 PSC ALSA ASoC audio support. |
---|
3 | 4 | * |
---|
4 | 5 | * (c) 2007-2008 MSC Vertriebsges.m.b.H., |
---|
5 | 6 | * Manuel Lauss <manuel.lauss@gmail.com> |
---|
6 | 7 | * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as |
---|
9 | | - * published by the Free Software Foundation. |
---|
10 | | - * |
---|
11 | 8 | * DMA glue for Au1x-PSC audio. |
---|
12 | | - * |
---|
13 | 9 | */ |
---|
14 | 10 | |
---|
15 | 11 | |
---|
.. | .. |
---|
186 | 182 | return 0; |
---|
187 | 183 | } |
---|
188 | 184 | |
---|
189 | | -static inline struct au1xpsc_audio_dmadata *to_dmadata(struct snd_pcm_substream *ss) |
---|
| 185 | +static inline struct au1xpsc_audio_dmadata *to_dmadata(struct snd_pcm_substream *ss, |
---|
| 186 | + struct snd_soc_component *component) |
---|
190 | 187 | { |
---|
191 | | - struct snd_soc_pcm_runtime *rtd = ss->private_data; |
---|
192 | | - struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); |
---|
193 | 188 | struct au1xpsc_audio_dmadata *pcd = snd_soc_component_get_drvdata(component); |
---|
194 | 189 | return &pcd[ss->stream]; |
---|
195 | 190 | } |
---|
196 | 191 | |
---|
197 | | -static int au1xpsc_pcm_hw_params(struct snd_pcm_substream *substream, |
---|
| 192 | +static int au1xpsc_pcm_hw_params(struct snd_soc_component *component, |
---|
| 193 | + struct snd_pcm_substream *substream, |
---|
198 | 194 | struct snd_pcm_hw_params *params) |
---|
199 | 195 | { |
---|
200 | 196 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
201 | 197 | struct au1xpsc_audio_dmadata *pcd; |
---|
202 | 198 | int stype, ret; |
---|
203 | 199 | |
---|
204 | | - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); |
---|
205 | | - if (ret < 0) |
---|
206 | | - goto out; |
---|
207 | | - |
---|
208 | 200 | stype = substream->stream; |
---|
209 | | - pcd = to_dmadata(substream); |
---|
| 201 | + pcd = to_dmadata(substream, component); |
---|
210 | 202 | |
---|
211 | 203 | DBG("runtime->dma_area = 0x%08lx dma_addr_t = 0x%08lx dma_size = %zu " |
---|
212 | 204 | "runtime->min_align %lu\n", |
---|
.. | .. |
---|
236 | 228 | return ret; |
---|
237 | 229 | } |
---|
238 | 230 | |
---|
239 | | -static int au1xpsc_pcm_hw_free(struct snd_pcm_substream *substream) |
---|
| 231 | +static int au1xpsc_pcm_prepare(struct snd_soc_component *component, |
---|
| 232 | + struct snd_pcm_substream *substream) |
---|
240 | 233 | { |
---|
241 | | - snd_pcm_lib_free_pages(substream); |
---|
242 | | - return 0; |
---|
243 | | -} |
---|
244 | | - |
---|
245 | | -static int au1xpsc_pcm_prepare(struct snd_pcm_substream *substream) |
---|
246 | | -{ |
---|
247 | | - struct au1xpsc_audio_dmadata *pcd = to_dmadata(substream); |
---|
| 234 | + struct au1xpsc_audio_dmadata *pcd = to_dmadata(substream, component); |
---|
248 | 235 | |
---|
249 | 236 | au1xxx_dbdma_reset(pcd->ddma_chan); |
---|
250 | 237 | |
---|
.. | .. |
---|
259 | 246 | return 0; |
---|
260 | 247 | } |
---|
261 | 248 | |
---|
262 | | -static int au1xpsc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
---|
| 249 | +static int au1xpsc_pcm_trigger(struct snd_soc_component *component, |
---|
| 250 | + struct snd_pcm_substream *substream, int cmd) |
---|
263 | 251 | { |
---|
264 | | - u32 c = to_dmadata(substream)->ddma_chan; |
---|
| 252 | + u32 c = to_dmadata(substream, component)->ddma_chan; |
---|
265 | 253 | |
---|
266 | 254 | switch (cmd) { |
---|
267 | 255 | case SNDRV_PCM_TRIGGER_START: |
---|
.. | .. |
---|
279 | 267 | } |
---|
280 | 268 | |
---|
281 | 269 | static snd_pcm_uframes_t |
---|
282 | | -au1xpsc_pcm_pointer(struct snd_pcm_substream *substream) |
---|
| 270 | +au1xpsc_pcm_pointer(struct snd_soc_component *component, |
---|
| 271 | + struct snd_pcm_substream *substream) |
---|
283 | 272 | { |
---|
284 | | - return bytes_to_frames(substream->runtime, to_dmadata(substream)->pos); |
---|
| 273 | + return bytes_to_frames(substream->runtime, |
---|
| 274 | + to_dmadata(substream, component)->pos); |
---|
285 | 275 | } |
---|
286 | 276 | |
---|
287 | | -static int au1xpsc_pcm_open(struct snd_pcm_substream *substream) |
---|
| 277 | +static int au1xpsc_pcm_open(struct snd_soc_component *component, |
---|
| 278 | + struct snd_pcm_substream *substream) |
---|
288 | 279 | { |
---|
289 | | - struct au1xpsc_audio_dmadata *pcd = to_dmadata(substream); |
---|
290 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
| 280 | + struct au1xpsc_audio_dmadata *pcd = to_dmadata(substream, component); |
---|
| 281 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
291 | 282 | int stype = substream->stream, *dmaids; |
---|
292 | 283 | |
---|
293 | | - dmaids = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); |
---|
| 284 | + dmaids = snd_soc_dai_get_dma_data(asoc_rtd_to_cpu(rtd, 0), substream); |
---|
294 | 285 | if (!dmaids) |
---|
295 | 286 | return -ENODEV; /* whoa, has ordering changed? */ |
---|
296 | 287 | |
---|
.. | .. |
---|
300 | 291 | return 0; |
---|
301 | 292 | } |
---|
302 | 293 | |
---|
303 | | -static int au1xpsc_pcm_close(struct snd_pcm_substream *substream) |
---|
| 294 | +static int au1xpsc_pcm_close(struct snd_soc_component *component, |
---|
| 295 | + struct snd_pcm_substream *substream) |
---|
304 | 296 | { |
---|
305 | | - au1x_pcm_dbdma_free(to_dmadata(substream)); |
---|
| 297 | + au1x_pcm_dbdma_free(to_dmadata(substream, component)); |
---|
306 | 298 | return 0; |
---|
307 | 299 | } |
---|
308 | 300 | |
---|
309 | | -static const struct snd_pcm_ops au1xpsc_pcm_ops = { |
---|
310 | | - .open = au1xpsc_pcm_open, |
---|
311 | | - .close = au1xpsc_pcm_close, |
---|
312 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
313 | | - .hw_params = au1xpsc_pcm_hw_params, |
---|
314 | | - .hw_free = au1xpsc_pcm_hw_free, |
---|
315 | | - .prepare = au1xpsc_pcm_prepare, |
---|
316 | | - .trigger = au1xpsc_pcm_trigger, |
---|
317 | | - .pointer = au1xpsc_pcm_pointer, |
---|
318 | | -}; |
---|
319 | | - |
---|
320 | | -static int au1xpsc_pcm_new(struct snd_soc_pcm_runtime *rtd) |
---|
| 301 | +static int au1xpsc_pcm_new(struct snd_soc_component *component, |
---|
| 302 | + struct snd_soc_pcm_runtime *rtd) |
---|
321 | 303 | { |
---|
322 | 304 | struct snd_card *card = rtd->card->snd_card; |
---|
323 | 305 | struct snd_pcm *pcm = rtd->pcm; |
---|
324 | 306 | |
---|
325 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
| 307 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
326 | 308 | card->dev, AU1XPSC_BUFFER_MIN_BYTES, (4096 * 1024) - 1); |
---|
327 | 309 | |
---|
328 | 310 | return 0; |
---|
.. | .. |
---|
331 | 313 | /* au1xpsc audio platform */ |
---|
332 | 314 | static struct snd_soc_component_driver au1xpsc_soc_component = { |
---|
333 | 315 | .name = DRV_NAME, |
---|
334 | | - .ops = &au1xpsc_pcm_ops, |
---|
335 | | - .pcm_new = au1xpsc_pcm_new, |
---|
| 316 | + .open = au1xpsc_pcm_open, |
---|
| 317 | + .close = au1xpsc_pcm_close, |
---|
| 318 | + .hw_params = au1xpsc_pcm_hw_params, |
---|
| 319 | + .prepare = au1xpsc_pcm_prepare, |
---|
| 320 | + .trigger = au1xpsc_pcm_trigger, |
---|
| 321 | + .pointer = au1xpsc_pcm_pointer, |
---|
| 322 | + .pcm_construct = au1xpsc_pcm_new, |
---|
336 | 323 | }; |
---|
337 | 324 | |
---|
338 | 325 | static int au1xpsc_pcm_drvprobe(struct platform_device *pdev) |
---|