| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * tegra_alc5632.c -- Toshiba AC100(PAZ00) machine ASoC driver |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 7 | 8 | * Authors: Leon Romanovsky <leon@leon.nu> |
|---|
| 8 | 9 | * Andrey Danin <danindrey@mail.ru> |
|---|
| 9 | 10 | * Marc Dietrich <marvin24@gmx.de> |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 12 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 13 | | - * published by the Free Software Foundation. |
|---|
| 14 | 11 | */ |
|---|
| 15 | 12 | |
|---|
| 16 | 13 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 39 | 36 | static int tegra_alc5632_asoc_hw_params(struct snd_pcm_substream *substream, |
|---|
| 40 | 37 | struct snd_pcm_hw_params *params) |
|---|
| 41 | 38 | { |
|---|
| 42 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 43 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
|---|
| 39 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 40 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
|---|
| 44 | 41 | struct snd_soc_card *card = rtd->card; |
|---|
| 45 | 42 | struct tegra_alc5632 *alc5632 = snd_soc_card_get_drvdata(card); |
|---|
| 46 | 43 | int srate, mclk; |
|---|
| .. | .. |
|---|
| 124 | 121 | return 0; |
|---|
| 125 | 122 | } |
|---|
| 126 | 123 | |
|---|
| 124 | +SND_SOC_DAILINK_DEFS(pcm, |
|---|
| 125 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 126 | + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "alc5632-hifi")), |
|---|
| 127 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
|---|
| 128 | + |
|---|
| 127 | 129 | static struct snd_soc_dai_link tegra_alc5632_dai = { |
|---|
| 128 | 130 | .name = "ALC5632", |
|---|
| 129 | 131 | .stream_name = "ALC5632 PCM", |
|---|
| 130 | | - .codec_dai_name = "alc5632-hifi", |
|---|
| 131 | 132 | .init = tegra_alc5632_asoc_init, |
|---|
| 132 | 133 | .ops = &tegra_alc5632_asoc_ops, |
|---|
| 133 | 134 | .dai_fmt = SND_SOC_DAIFMT_I2S |
|---|
| 134 | 135 | | SND_SOC_DAIFMT_NB_NF |
|---|
| 135 | 136 | | SND_SOC_DAIFMT_CBS_CFS, |
|---|
| 137 | + SND_SOC_DAILINK_REG(pcm), |
|---|
| 136 | 138 | }; |
|---|
| 137 | 139 | |
|---|
| 138 | 140 | static struct snd_soc_card snd_soc_tegra_alc5632 = { |
|---|
| .. | .. |
|---|
| 175 | 177 | if (ret) |
|---|
| 176 | 178 | goto err; |
|---|
| 177 | 179 | |
|---|
| 178 | | - tegra_alc5632_dai.codec_of_node = of_parse_phandle( |
|---|
| 180 | + tegra_alc5632_dai.codecs->of_node = of_parse_phandle( |
|---|
| 179 | 181 | pdev->dev.of_node, "nvidia,audio-codec", 0); |
|---|
| 180 | 182 | |
|---|
| 181 | | - if (!tegra_alc5632_dai.codec_of_node) { |
|---|
| 183 | + if (!tegra_alc5632_dai.codecs->of_node) { |
|---|
| 182 | 184 | dev_err(&pdev->dev, |
|---|
| 183 | 185 | "Property 'nvidia,audio-codec' missing or invalid\n"); |
|---|
| 184 | 186 | ret = -EINVAL; |
|---|
| 185 | 187 | goto err; |
|---|
| 186 | 188 | } |
|---|
| 187 | 189 | |
|---|
| 188 | | - tegra_alc5632_dai.cpu_of_node = of_parse_phandle(np, |
|---|
| 190 | + tegra_alc5632_dai.cpus->of_node = of_parse_phandle(np, |
|---|
| 189 | 191 | "nvidia,i2s-controller", 0); |
|---|
| 190 | | - if (!tegra_alc5632_dai.cpu_of_node) { |
|---|
| 192 | + if (!tegra_alc5632_dai.cpus->of_node) { |
|---|
| 191 | 193 | dev_err(&pdev->dev, |
|---|
| 192 | 194 | "Property 'nvidia,i2s-controller' missing or invalid\n"); |
|---|
| 193 | 195 | ret = -EINVAL; |
|---|
| 194 | 196 | goto err_put_codec_of_node; |
|---|
| 195 | 197 | } |
|---|
| 196 | 198 | |
|---|
| 197 | | - tegra_alc5632_dai.platform_of_node = tegra_alc5632_dai.cpu_of_node; |
|---|
| 199 | + tegra_alc5632_dai.platforms->of_node = tegra_alc5632_dai.cpus->of_node; |
|---|
| 198 | 200 | |
|---|
| 199 | 201 | ret = tegra_asoc_utils_init(&alc5632->util_data, &pdev->dev); |
|---|
| 200 | 202 | if (ret) |
|---|
| .. | .. |
|---|
| 204 | 206 | if (ret) { |
|---|
| 205 | 207 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", |
|---|
| 206 | 208 | ret); |
|---|
| 207 | | - goto err_fini_utils; |
|---|
| 209 | + goto err_put_cpu_of_node; |
|---|
| 208 | 210 | } |
|---|
| 209 | 211 | |
|---|
| 210 | 212 | return 0; |
|---|
| 211 | 213 | |
|---|
| 212 | | -err_fini_utils: |
|---|
| 213 | | - tegra_asoc_utils_fini(&alc5632->util_data); |
|---|
| 214 | 214 | err_put_cpu_of_node: |
|---|
| 215 | | - of_node_put(tegra_alc5632_dai.cpu_of_node); |
|---|
| 216 | | - tegra_alc5632_dai.cpu_of_node = NULL; |
|---|
| 217 | | - tegra_alc5632_dai.platform_of_node = NULL; |
|---|
| 215 | + of_node_put(tegra_alc5632_dai.cpus->of_node); |
|---|
| 216 | + tegra_alc5632_dai.cpus->of_node = NULL; |
|---|
| 217 | + tegra_alc5632_dai.platforms->of_node = NULL; |
|---|
| 218 | 218 | err_put_codec_of_node: |
|---|
| 219 | | - of_node_put(tegra_alc5632_dai.codec_of_node); |
|---|
| 220 | | - tegra_alc5632_dai.codec_of_node = NULL; |
|---|
| 219 | + of_node_put(tegra_alc5632_dai.codecs->of_node); |
|---|
| 220 | + tegra_alc5632_dai.codecs->of_node = NULL; |
|---|
| 221 | 221 | err: |
|---|
| 222 | 222 | return ret; |
|---|
| 223 | 223 | } |
|---|
| .. | .. |
|---|
| 225 | 225 | static int tegra_alc5632_remove(struct platform_device *pdev) |
|---|
| 226 | 226 | { |
|---|
| 227 | 227 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
|---|
| 228 | | - struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card); |
|---|
| 229 | 228 | |
|---|
| 230 | 229 | snd_soc_unregister_card(card); |
|---|
| 231 | 230 | |
|---|
| 232 | | - tegra_asoc_utils_fini(&machine->util_data); |
|---|
| 233 | | - |
|---|
| 234 | | - of_node_put(tegra_alc5632_dai.cpu_of_node); |
|---|
| 235 | | - tegra_alc5632_dai.cpu_of_node = NULL; |
|---|
| 236 | | - tegra_alc5632_dai.platform_of_node = NULL; |
|---|
| 237 | | - of_node_put(tegra_alc5632_dai.codec_of_node); |
|---|
| 238 | | - tegra_alc5632_dai.codec_of_node = NULL; |
|---|
| 231 | + of_node_put(tegra_alc5632_dai.cpus->of_node); |
|---|
| 232 | + tegra_alc5632_dai.cpus->of_node = NULL; |
|---|
| 233 | + tegra_alc5632_dai.platforms->of_node = NULL; |
|---|
| 234 | + of_node_put(tegra_alc5632_dai.codecs->of_node); |
|---|
| 235 | + tegra_alc5632_dai.codecs->of_node = NULL; |
|---|
| 239 | 236 | |
|---|
| 240 | 237 | return 0; |
|---|
| 241 | 238 | } |
|---|