forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/fsl/p1022_rdk.c
....@@ -1,21 +1,17 @@
1
-/**
2
- * Freescale P1022RDK ALSA SoC Machine driver
3
- *
4
- * Author: Timur Tabi <timur@freescale.com>
5
- *
6
- * Copyright 2012 Freescale Semiconductor, Inc.
7
- *
8
- * This file is licensed under the terms of the GNU General Public License
9
- * version 2. This program is licensed "as is" without any warranty of any
10
- * kind, whether express or implied.
11
- *
12
- * Note: in order for audio to work correctly, the output controls need
13
- * to be enabled, because they control the clock. So for playback, for
14
- * example:
15
- *
16
- * amixer sset 'Left Output Mixer PCM' on
17
- * amixer sset 'Right Output Mixer PCM' on
18
- */
1
+// SPDX-License-Identifier: GPL-2.0
2
+//
3
+// Freescale P1022RDK ALSA SoC Machine driver
4
+//
5
+// Author: Timur Tabi <timur@freescale.com>
6
+//
7
+// Copyright 2012 Freescale Semiconductor, Inc.
8
+//
9
+// Note: in order for audio to work correctly, the output controls need
10
+// to be enabled, because they control the clock. So for playback, for
11
+// example:
12
+//
13
+// amixer sset 'Left Output Mixer PCM' on
14
+// amixer sset 'Right Output Mixer PCM' on
1915
2016 #include <linux/module.h>
2117 #include <linux/fsl/guts.h>
....@@ -131,21 +127,21 @@
131127 */
132128 static int p1022_rdk_startup(struct snd_pcm_substream *substream)
133129 {
134
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
130
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
135131 struct machine_data *mdata =
136132 container_of(rtd->card, struct machine_data, card);
137133 struct device *dev = rtd->card->dev;
138134 int ret = 0;
139135
140136 /* Tell the codec driver what the serial protocol is. */
141
- ret = snd_soc_dai_set_fmt(rtd->codec_dai, mdata->dai_format);
137
+ ret = snd_soc_dai_set_fmt(asoc_rtd_to_codec(rtd, 0), mdata->dai_format);
142138 if (ret < 0) {
143139 dev_err(dev, "could not set codec driver audio format (ret=%i)\n",
144140 ret);
145141 return ret;
146142 }
147143
148
- ret = snd_soc_dai_set_pll(rtd->codec_dai, 0, 0, mdata->clk_frequency,
144
+ ret = snd_soc_dai_set_pll(asoc_rtd_to_codec(rtd, 0), 0, 0, mdata->clk_frequency,
149145 mdata->clk_frequency);
150146 if (ret < 0) {
151147 dev_err(dev, "could not set codec PLL frequency (ret=%i)\n",
....@@ -207,6 +203,7 @@
207203 struct device_node *np = ssi_pdev->dev.of_node;
208204 struct device_node *codec_np = NULL;
209205 struct machine_data *mdata;
206
+ struct snd_soc_dai_link_component *comp;
210207 const u32 *iprop;
211208 int ret;
212209
....@@ -223,11 +220,33 @@
223220 goto error_put;
224221 }
225222
226
- mdata->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
223
+ comp = devm_kzalloc(&pdev->dev, 6 * sizeof(*comp), GFP_KERNEL);
224
+ if (!comp) {
225
+ ret = -ENOMEM;
226
+ goto error_put;
227
+ }
228
+
229
+ mdata->dai[0].cpus = &comp[0];
230
+ mdata->dai[0].codecs = &comp[1];
231
+ mdata->dai[0].platforms = &comp[2];
232
+
233
+ mdata->dai[0].num_cpus = 1;
234
+ mdata->dai[0].num_codecs = 1;
235
+ mdata->dai[0].num_platforms = 1;
236
+
237
+ mdata->dai[1].cpus = &comp[3];
238
+ mdata->dai[1].codecs = &comp[4];
239
+ mdata->dai[1].platforms = &comp[5];
240
+
241
+ mdata->dai[1].num_cpus = 1;
242
+ mdata->dai[1].num_codecs = 1;
243
+ mdata->dai[1].num_platforms = 1;
244
+
245
+ mdata->dai[0].cpus->dai_name = dev_name(&ssi_pdev->dev);
227246 mdata->dai[0].ops = &p1022_rdk_ops;
228247
229248 /* ASoC core can match codec with device node */
230
- mdata->dai[0].codec_of_node = codec_np;
249
+ mdata->dai[0].codecs->of_node = codec_np;
231250
232251 /*
233252 * We register two DAIs per SSI, one for playback and the other for
....@@ -237,8 +256,8 @@
237256 memcpy(&mdata->dai[1], &mdata->dai[0], sizeof(struct snd_soc_dai_link));
238257
239258 /* The DAI names from the codec (snd_soc_dai_driver.name) */
240
- mdata->dai[0].codec_dai_name = "wm8960-hifi";
241
- mdata->dai[1].codec_dai_name = mdata->dai[0].codec_dai_name;
259
+ mdata->dai[0].codecs->dai_name = "wm8960-hifi";
260
+ mdata->dai[1].codecs->dai_name = mdata->dai[0].codecs->dai_name;
242261
243262 /*
244263 * Configure the SSI for I2S slave mode. Older device trees have
....@@ -270,7 +289,7 @@
270289 }
271290
272291 /* Find the playback DMA channel to use. */
273
- mdata->dai[0].platform_name = mdata->platform_name[0];
292
+ mdata->dai[0].platforms->name = mdata->platform_name[0];
274293 ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma", &mdata->dai[0],
275294 &mdata->dma_channel_id[0],
276295 &mdata->dma_id[0]);
....@@ -281,7 +300,7 @@
281300 }
282301
283302 /* Find the capture DMA channel to use. */
284
- mdata->dai[1].platform_name = mdata->platform_name[1];
303
+ mdata->dai[1].platforms->name = mdata->platform_name[1];
285304 ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma", &mdata->dai[1],
286305 &mdata->dma_channel_id[1],
287306 &mdata->dma_id[1]);