| .. | .. |
|---|
| 1 | | -/* sound/soc/samsung/spdif.c |
|---|
| 2 | | - * |
|---|
| 3 | | - * ALSA SoC Audio Layer - Samsung S/PDIF Controller driver |
|---|
| 4 | | - * |
|---|
| 5 | | - * Copyright (c) 2010 Samsung Electronics Co. Ltd |
|---|
| 6 | | - * http://www.samsung.com/ |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 10 | | - * published by the Free Software Foundation. |
|---|
| 11 | | - */ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | +// |
|---|
| 3 | +// ALSA SoC Audio Layer - Samsung S/PDIF Controller driver |
|---|
| 4 | +// |
|---|
| 5 | +// Copyright (c) 2010 Samsung Electronics Co. Ltd |
|---|
| 6 | +// http://www.samsung.com/ |
|---|
| 12 | 7 | |
|---|
| 13 | 8 | #include <linux/clk.h> |
|---|
| 14 | 9 | #include <linux/io.h> |
|---|
| .. | .. |
|---|
| 75 | 70 | * @clk_rate: Current clock rate for calcurate ratio. |
|---|
| 76 | 71 | * @pclk: The peri-clock pointer for spdif master operation. |
|---|
| 77 | 72 | * @sclk: The source clock pointer for making sync signals. |
|---|
| 78 | | - * @save_clkcon: Backup clkcon reg. in suspend. |
|---|
| 79 | | - * @save_con: Backup con reg. in suspend. |
|---|
| 80 | | - * @save_cstas: Backup cstas reg. in suspend. |
|---|
| 73 | + * @saved_clkcon: Backup clkcon reg. in suspend. |
|---|
| 74 | + * @saved_con: Backup con reg. in suspend. |
|---|
| 75 | + * @saved_cstas: Backup cstas reg. in suspend. |
|---|
| 81 | 76 | * @dma_playback: DMA information for playback channel. |
|---|
| 82 | 77 | */ |
|---|
| 83 | 78 | struct samsung_spdif_info { |
|---|
| .. | .. |
|---|
| 95 | 90 | |
|---|
| 96 | 91 | static struct snd_dmaengine_dai_dma_data spdif_stereo_out; |
|---|
| 97 | 92 | static struct samsung_spdif_info spdif_info; |
|---|
| 93 | + |
|---|
| 94 | +static inline struct samsung_spdif_info |
|---|
| 95 | +*component_to_info(struct snd_soc_component *component) |
|---|
| 96 | +{ |
|---|
| 97 | + return snd_soc_component_get_drvdata(component); |
|---|
| 98 | +} |
|---|
| 98 | 99 | |
|---|
| 99 | 100 | static inline struct samsung_spdif_info *to_info(struct snd_soc_dai *cpu_dai) |
|---|
| 100 | 101 | { |
|---|
| .. | .. |
|---|
| 140 | 141 | static int spdif_trigger(struct snd_pcm_substream *substream, int cmd, |
|---|
| 141 | 142 | struct snd_soc_dai *dai) |
|---|
| 142 | 143 | { |
|---|
| 143 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 144 | | - struct samsung_spdif_info *spdif = to_info(rtd->cpu_dai); |
|---|
| 144 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 145 | + struct samsung_spdif_info *spdif = to_info(asoc_rtd_to_cpu(rtd, 0)); |
|---|
| 145 | 146 | unsigned long flags; |
|---|
| 146 | 147 | |
|---|
| 147 | 148 | dev_dbg(spdif->dev, "Entered %s\n", __func__); |
|---|
| .. | .. |
|---|
| 176 | 177 | struct snd_pcm_hw_params *params, |
|---|
| 177 | 178 | struct snd_soc_dai *socdai) |
|---|
| 178 | 179 | { |
|---|
| 179 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 180 | | - struct samsung_spdif_info *spdif = to_info(rtd->cpu_dai); |
|---|
| 180 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 181 | + struct samsung_spdif_info *spdif = to_info(asoc_rtd_to_cpu(rtd, 0)); |
|---|
| 181 | 182 | void __iomem *regs = spdif->regs; |
|---|
| 182 | 183 | struct snd_dmaengine_dai_dma_data *dma_data; |
|---|
| 183 | 184 | u32 con, clkcon, cstas; |
|---|
| .. | .. |
|---|
| 193 | 194 | return -EINVAL; |
|---|
| 194 | 195 | } |
|---|
| 195 | 196 | |
|---|
| 196 | | - snd_soc_dai_set_dma_data(rtd->cpu_dai, substream, dma_data); |
|---|
| 197 | + snd_soc_dai_set_dma_data(asoc_rtd_to_cpu(rtd, 0), substream, dma_data); |
|---|
| 197 | 198 | |
|---|
| 198 | 199 | spin_lock_irqsave(&spdif->lock, flags); |
|---|
| 199 | 200 | |
|---|
| .. | .. |
|---|
| 278 | 279 | static void spdif_shutdown(struct snd_pcm_substream *substream, |
|---|
| 279 | 280 | struct snd_soc_dai *dai) |
|---|
| 280 | 281 | { |
|---|
| 281 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 282 | | - struct samsung_spdif_info *spdif = to_info(rtd->cpu_dai); |
|---|
| 282 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 283 | + struct samsung_spdif_info *spdif = to_info(asoc_rtd_to_cpu(rtd, 0)); |
|---|
| 283 | 284 | void __iomem *regs = spdif->regs; |
|---|
| 284 | 285 | u32 con, clkcon; |
|---|
| 285 | 286 | |
|---|
| .. | .. |
|---|
| 295 | 296 | } |
|---|
| 296 | 297 | |
|---|
| 297 | 298 | #ifdef CONFIG_PM |
|---|
| 298 | | -static int spdif_suspend(struct snd_soc_dai *cpu_dai) |
|---|
| 299 | +static int spdif_suspend(struct snd_soc_component *component) |
|---|
| 299 | 300 | { |
|---|
| 300 | | - struct samsung_spdif_info *spdif = to_info(cpu_dai); |
|---|
| 301 | + struct samsung_spdif_info *spdif = component_to_info(component); |
|---|
| 301 | 302 | u32 con = spdif->saved_con; |
|---|
| 302 | 303 | |
|---|
| 303 | 304 | dev_dbg(spdif->dev, "Entered %s\n", __func__); |
|---|
| .. | .. |
|---|
| 312 | 313 | return 0; |
|---|
| 313 | 314 | } |
|---|
| 314 | 315 | |
|---|
| 315 | | -static int spdif_resume(struct snd_soc_dai *cpu_dai) |
|---|
| 316 | +static int spdif_resume(struct snd_soc_component *component) |
|---|
| 316 | 317 | { |
|---|
| 317 | | - struct samsung_spdif_info *spdif = to_info(cpu_dai); |
|---|
| 318 | + struct samsung_spdif_info *spdif = component_to_info(component); |
|---|
| 318 | 319 | |
|---|
| 319 | 320 | dev_dbg(spdif->dev, "Entered %s\n", __func__); |
|---|
| 320 | 321 | |
|---|
| .. | .. |
|---|
| 348 | 349 | SNDRV_PCM_RATE_96000), |
|---|
| 349 | 350 | .formats = SNDRV_PCM_FMTBIT_S16_LE, }, |
|---|
| 350 | 351 | .ops = &spdif_dai_ops, |
|---|
| 351 | | - .suspend = spdif_suspend, |
|---|
| 352 | | - .resume = spdif_resume, |
|---|
| 353 | 352 | }; |
|---|
| 354 | 353 | |
|---|
| 355 | 354 | static const struct snd_soc_component_driver samsung_spdif_component = { |
|---|
| 356 | 355 | .name = "samsung-spdif", |
|---|
| 356 | + .suspend = spdif_suspend, |
|---|
| 357 | + .resume = spdif_resume, |
|---|
| 357 | 358 | }; |
|---|
| 358 | 359 | |
|---|
| 359 | 360 | static int spdif_probe(struct platform_device *pdev) |
|---|
| .. | .. |
|---|
| 430 | 431 | spdif->dma_playback = &spdif_stereo_out; |
|---|
| 431 | 432 | |
|---|
| 432 | 433 | ret = samsung_asoc_dma_platform_register(&pdev->dev, filter, |
|---|
| 433 | | - NULL, NULL); |
|---|
| 434 | + NULL, NULL, NULL); |
|---|
| 434 | 435 | if (ret) { |
|---|
| 435 | 436 | dev_err(&pdev->dev, "failed to register DMA: %d\n", ret); |
|---|
| 436 | 437 | goto err4; |
|---|