.. | .. |
---|
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 |
---|
19 | 15 | |
---|
20 | 16 | #include <linux/module.h> |
---|
21 | 17 | #include <linux/fsl/guts.h> |
---|
.. | .. |
---|
131 | 127 | */ |
---|
132 | 128 | static int p1022_rdk_startup(struct snd_pcm_substream *substream) |
---|
133 | 129 | { |
---|
134 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
| 130 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
135 | 131 | struct machine_data *mdata = |
---|
136 | 132 | container_of(rtd->card, struct machine_data, card); |
---|
137 | 133 | struct device *dev = rtd->card->dev; |
---|
138 | 134 | int ret = 0; |
---|
139 | 135 | |
---|
140 | 136 | /* 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); |
---|
142 | 138 | if (ret < 0) { |
---|
143 | 139 | dev_err(dev, "could not set codec driver audio format (ret=%i)\n", |
---|
144 | 140 | ret); |
---|
145 | 141 | return ret; |
---|
146 | 142 | } |
---|
147 | 143 | |
---|
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, |
---|
149 | 145 | mdata->clk_frequency); |
---|
150 | 146 | if (ret < 0) { |
---|
151 | 147 | dev_err(dev, "could not set codec PLL frequency (ret=%i)\n", |
---|
.. | .. |
---|
207 | 203 | struct device_node *np = ssi_pdev->dev.of_node; |
---|
208 | 204 | struct device_node *codec_np = NULL; |
---|
209 | 205 | struct machine_data *mdata; |
---|
| 206 | + struct snd_soc_dai_link_component *comp; |
---|
210 | 207 | const u32 *iprop; |
---|
211 | 208 | int ret; |
---|
212 | 209 | |
---|
.. | .. |
---|
223 | 220 | goto error_put; |
---|
224 | 221 | } |
---|
225 | 222 | |
---|
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); |
---|
227 | 246 | mdata->dai[0].ops = &p1022_rdk_ops; |
---|
228 | 247 | |
---|
229 | 248 | /* 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; |
---|
231 | 250 | |
---|
232 | 251 | /* |
---|
233 | 252 | * We register two DAIs per SSI, one for playback and the other for |
---|
.. | .. |
---|
237 | 256 | memcpy(&mdata->dai[1], &mdata->dai[0], sizeof(struct snd_soc_dai_link)); |
---|
238 | 257 | |
---|
239 | 258 | /* 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; |
---|
242 | 261 | |
---|
243 | 262 | /* |
---|
244 | 263 | * Configure the SSI for I2S slave mode. Older device trees have |
---|
.. | .. |
---|
270 | 289 | } |
---|
271 | 290 | |
---|
272 | 291 | /* 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]; |
---|
274 | 293 | ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma", &mdata->dai[0], |
---|
275 | 294 | &mdata->dma_channel_id[0], |
---|
276 | 295 | &mdata->dma_id[0]); |
---|
.. | .. |
---|
281 | 300 | } |
---|
282 | 301 | |
---|
283 | 302 | /* 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]; |
---|
285 | 304 | ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma", &mdata->dai[1], |
---|
286 | 305 | &mdata->dma_channel_id[1], |
---|
287 | 306 | &mdata->dma_id[1]); |
---|