forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/samsung/spdif.c
....@@ -1,14 +1,9 @@
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/
127
138 #include <linux/clk.h>
149 #include <linux/io.h>
....@@ -75,9 +70,9 @@
7570 * @clk_rate: Current clock rate for calcurate ratio.
7671 * @pclk: The peri-clock pointer for spdif master operation.
7772 * @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.
8176 * @dma_playback: DMA information for playback channel.
8277 */
8378 struct samsung_spdif_info {
....@@ -95,6 +90,12 @@
9590
9691 static struct snd_dmaengine_dai_dma_data spdif_stereo_out;
9792 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
+}
9899
99100 static inline struct samsung_spdif_info *to_info(struct snd_soc_dai *cpu_dai)
100101 {
....@@ -140,8 +141,8 @@
140141 static int spdif_trigger(struct snd_pcm_substream *substream, int cmd,
141142 struct snd_soc_dai *dai)
142143 {
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));
145146 unsigned long flags;
146147
147148 dev_dbg(spdif->dev, "Entered %s\n", __func__);
....@@ -176,8 +177,8 @@
176177 struct snd_pcm_hw_params *params,
177178 struct snd_soc_dai *socdai)
178179 {
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));
181182 void __iomem *regs = spdif->regs;
182183 struct snd_dmaengine_dai_dma_data *dma_data;
183184 u32 con, clkcon, cstas;
....@@ -193,7 +194,7 @@
193194 return -EINVAL;
194195 }
195196
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);
197198
198199 spin_lock_irqsave(&spdif->lock, flags);
199200
....@@ -278,8 +279,8 @@
278279 static void spdif_shutdown(struct snd_pcm_substream *substream,
279280 struct snd_soc_dai *dai)
280281 {
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));
283284 void __iomem *regs = spdif->regs;
284285 u32 con, clkcon;
285286
....@@ -295,9 +296,9 @@
295296 }
296297
297298 #ifdef CONFIG_PM
298
-static int spdif_suspend(struct snd_soc_dai *cpu_dai)
299
+static int spdif_suspend(struct snd_soc_component *component)
299300 {
300
- struct samsung_spdif_info *spdif = to_info(cpu_dai);
301
+ struct samsung_spdif_info *spdif = component_to_info(component);
301302 u32 con = spdif->saved_con;
302303
303304 dev_dbg(spdif->dev, "Entered %s\n", __func__);
....@@ -312,9 +313,9 @@
312313 return 0;
313314 }
314315
315
-static int spdif_resume(struct snd_soc_dai *cpu_dai)
316
+static int spdif_resume(struct snd_soc_component *component)
316317 {
317
- struct samsung_spdif_info *spdif = to_info(cpu_dai);
318
+ struct samsung_spdif_info *spdif = component_to_info(component);
318319
319320 dev_dbg(spdif->dev, "Entered %s\n", __func__);
320321
....@@ -348,12 +349,12 @@
348349 SNDRV_PCM_RATE_96000),
349350 .formats = SNDRV_PCM_FMTBIT_S16_LE, },
350351 .ops = &spdif_dai_ops,
351
- .suspend = spdif_suspend,
352
- .resume = spdif_resume,
353352 };
354353
355354 static const struct snd_soc_component_driver samsung_spdif_component = {
356355 .name = "samsung-spdif",
356
+ .suspend = spdif_suspend,
357
+ .resume = spdif_resume,
357358 };
358359
359360 static int spdif_probe(struct platform_device *pdev)
....@@ -430,7 +431,7 @@
430431 spdif->dma_playback = &spdif_stereo_out;
431432
432433 ret = samsung_asoc_dma_platform_register(&pdev->dev, filter,
433
- NULL, NULL);
434
+ NULL, NULL, NULL);
434435 if (ret) {
435436 dev_err(&pdev->dev, "failed to register DMA: %d\n", ret);
436437 goto err4;