hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/fsl/p1022_ds.c
....@@ -1,14 +1,10 @@
1
-/**
2
- * Freescale P1022DS ALSA SoC Machine driver
3
- *
4
- * Author: Timur Tabi <timur@freescale.com>
5
- *
6
- * Copyright 2010 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
- */
1
+// SPDX-License-Identifier: GPL-2.0
2
+//
3
+// Freescale P1022DS ALSA SoC Machine driver
4
+//
5
+// Author: Timur Tabi <timur@freescale.com>
6
+//
7
+// Copyright 2010 Freescale Semiconductor, Inc.
128
139 #include <linux/module.h>
1410 #include <linux/fsl/guts.h>
....@@ -125,14 +121,14 @@
125121 */
126122 static int p1022_ds_startup(struct snd_pcm_substream *substream)
127123 {
128
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
124
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
129125 struct machine_data *mdata =
130126 container_of(rtd->card, struct machine_data, card);
131127 struct device *dev = rtd->card->dev;
132128 int ret = 0;
133129
134130 /* Tell the codec driver what the serial protocol is. */
135
- ret = snd_soc_dai_set_fmt(rtd->codec_dai, mdata->dai_format);
131
+ ret = snd_soc_dai_set_fmt(asoc_rtd_to_codec(rtd, 0), mdata->dai_format);
136132 if (ret < 0) {
137133 dev_err(dev, "could not set codec driver audio format\n");
138134 return ret;
....@@ -142,7 +138,7 @@
142138 * Tell the codec driver what the MCLK frequency is, and whether it's
143139 * a slave or master.
144140 */
145
- ret = snd_soc_dai_set_sysclk(rtd->codec_dai, 0, mdata->clk_frequency,
141
+ ret = snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0), 0, mdata->clk_frequency,
146142 mdata->codec_clk_direction);
147143 if (ret < 0) {
148144 dev_err(dev, "could not set codec driver clock params\n");
....@@ -203,6 +199,7 @@
203199 struct device_node *np = ssi_pdev->dev.of_node;
204200 struct device_node *codec_np = NULL;
205201 struct machine_data *mdata;
202
+ struct snd_soc_dai_link_component *comp;
206203 int ret = -ENODEV;
207204 const char *sprop;
208205 const u32 *iprop;
....@@ -220,11 +217,34 @@
220217 goto error_put;
221218 }
222219
223
- mdata->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
220
+ comp = devm_kzalloc(&pdev->dev, 6 * sizeof(*comp), GFP_KERNEL);
221
+ if (!comp) {
222
+ ret = -ENOMEM;
223
+ goto error_put;
224
+ }
225
+
226
+ mdata->dai[0].cpus = &comp[0];
227
+ mdata->dai[0].codecs = &comp[1];
228
+ mdata->dai[0].platforms = &comp[2];
229
+
230
+ mdata->dai[0].num_cpus = 1;
231
+ mdata->dai[0].num_codecs = 1;
232
+ mdata->dai[0].num_platforms = 1;
233
+
234
+ mdata->dai[1].cpus = &comp[3];
235
+ mdata->dai[1].codecs = &comp[4];
236
+ mdata->dai[1].platforms = &comp[5];
237
+
238
+ mdata->dai[1].num_cpus = 1;
239
+ mdata->dai[1].num_codecs = 1;
240
+ mdata->dai[1].num_platforms = 1;
241
+
242
+
243
+ mdata->dai[0].cpus->dai_name = dev_name(&ssi_pdev->dev);
224244 mdata->dai[0].ops = &p1022_ds_ops;
225245
226246 /* ASoC core can match codec with device node */
227
- mdata->dai[0].codec_of_node = codec_np;
247
+ mdata->dai[0].codecs->of_node = codec_np;
228248
229249 /* We register two DAIs per SSI, one for playback and the other for
230250 * capture. We support codecs that have separate DAIs for both playback
....@@ -233,8 +253,8 @@
233253 memcpy(&mdata->dai[1], &mdata->dai[0], sizeof(struct snd_soc_dai_link));
234254
235255 /* The DAI names from the codec (snd_soc_dai_driver.name) */
236
- mdata->dai[0].codec_dai_name = "wm8776-hifi-playback";
237
- mdata->dai[1].codec_dai_name = "wm8776-hifi-capture";
256
+ mdata->dai[0].codecs->dai_name = "wm8776-hifi-playback";
257
+ mdata->dai[1].codecs->dai_name = "wm8776-hifi-capture";
238258
239259 /* Get the device ID */
240260 iprop = of_get_property(np, "cell-index", NULL);
....@@ -320,7 +340,7 @@
320340 }
321341
322342 /* Find the playback DMA channel to use. */
323
- mdata->dai[0].platform_name = mdata->platform_name[0];
343
+ mdata->dai[0].platforms->name = mdata->platform_name[0];
324344 ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma", &mdata->dai[0],
325345 &mdata->dma_channel_id[0],
326346 &mdata->dma_id[0]);
....@@ -330,7 +350,7 @@
330350 }
331351
332352 /* Find the capture DMA channel to use. */
333
- mdata->dai[1].platform_name = mdata->platform_name[1];
353
+ mdata->dai[1].platforms->name = mdata->platform_name[1];
334354 ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma", &mdata->dai[1],
335355 &mdata->dma_channel_id[1],
336356 &mdata->dma_id[1]);