| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * tegra_rt5640.c - Tegra machine ASoC driver for boards using RT5640 codec. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 8 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 11 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 12 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 13 | | - * more details. |
|---|
| 14 | | - * |
|---|
| 15 | | - * You should have received a copy of the GNU General Public License |
|---|
| 16 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | 6 | * |
|---|
| 18 | 7 | * Based on code copyright/by: |
|---|
| 19 | 8 | * |
|---|
| .. | .. |
|---|
| 50 | 39 | static int tegra_rt5640_asoc_hw_params(struct snd_pcm_substream *substream, |
|---|
| 51 | 40 | struct snd_pcm_hw_params *params) |
|---|
| 52 | 41 | { |
|---|
| 53 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 54 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
|---|
| 42 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 43 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
|---|
| 55 | 44 | struct snd_soc_card *card = rtd->card; |
|---|
| 56 | 45 | struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); |
|---|
| 57 | 46 | int srate, mclk; |
|---|
| .. | .. |
|---|
| 126 | 115 | return 0; |
|---|
| 127 | 116 | } |
|---|
| 128 | 117 | |
|---|
| 118 | +SND_SOC_DAILINK_DEFS(aif1, |
|---|
| 119 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 120 | + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5640-aif1")), |
|---|
| 121 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
|---|
| 122 | + |
|---|
| 129 | 123 | static struct snd_soc_dai_link tegra_rt5640_dai = { |
|---|
| 130 | 124 | .name = "RT5640", |
|---|
| 131 | 125 | .stream_name = "RT5640 PCM", |
|---|
| 132 | | - .codec_dai_name = "rt5640-aif1", |
|---|
| 133 | 126 | .init = tegra_rt5640_asoc_init, |
|---|
| 134 | 127 | .ops = &tegra_rt5640_ops, |
|---|
| 135 | 128 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
|---|
| 136 | 129 | SND_SOC_DAIFMT_CBS_CFS, |
|---|
| 130 | + SND_SOC_DAILINK_REG(aif1), |
|---|
| 137 | 131 | }; |
|---|
| 138 | 132 | |
|---|
| 139 | 133 | static struct snd_soc_card snd_soc_tegra_rt5640 = { |
|---|
| .. | .. |
|---|
| 171 | 165 | |
|---|
| 172 | 166 | ret = snd_soc_of_parse_card_name(card, "nvidia,model"); |
|---|
| 173 | 167 | if (ret) |
|---|
| 174 | | - goto err; |
|---|
| 168 | + return ret; |
|---|
| 175 | 169 | |
|---|
| 176 | 170 | ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); |
|---|
| 177 | 171 | if (ret) |
|---|
| 178 | | - goto err; |
|---|
| 172 | + return ret; |
|---|
| 179 | 173 | |
|---|
| 180 | | - tegra_rt5640_dai.codec_of_node = of_parse_phandle(np, |
|---|
| 174 | + tegra_rt5640_dai.codecs->of_node = of_parse_phandle(np, |
|---|
| 181 | 175 | "nvidia,audio-codec", 0); |
|---|
| 182 | | - if (!tegra_rt5640_dai.codec_of_node) { |
|---|
| 176 | + if (!tegra_rt5640_dai.codecs->of_node) { |
|---|
| 183 | 177 | dev_err(&pdev->dev, |
|---|
| 184 | 178 | "Property 'nvidia,audio-codec' missing or invalid\n"); |
|---|
| 185 | | - ret = -EINVAL; |
|---|
| 186 | | - goto err; |
|---|
| 179 | + return -EINVAL; |
|---|
| 187 | 180 | } |
|---|
| 188 | 181 | |
|---|
| 189 | | - tegra_rt5640_dai.cpu_of_node = of_parse_phandle(np, |
|---|
| 182 | + tegra_rt5640_dai.cpus->of_node = of_parse_phandle(np, |
|---|
| 190 | 183 | "nvidia,i2s-controller", 0); |
|---|
| 191 | | - if (!tegra_rt5640_dai.cpu_of_node) { |
|---|
| 184 | + if (!tegra_rt5640_dai.cpus->of_node) { |
|---|
| 192 | 185 | dev_err(&pdev->dev, |
|---|
| 193 | 186 | "Property 'nvidia,i2s-controller' missing or invalid\n"); |
|---|
| 194 | | - ret = -EINVAL; |
|---|
| 195 | | - goto err; |
|---|
| 187 | + return -EINVAL; |
|---|
| 196 | 188 | } |
|---|
| 197 | 189 | |
|---|
| 198 | | - tegra_rt5640_dai.platform_of_node = tegra_rt5640_dai.cpu_of_node; |
|---|
| 190 | + tegra_rt5640_dai.platforms->of_node = tegra_rt5640_dai.cpus->of_node; |
|---|
| 199 | 191 | |
|---|
| 200 | 192 | ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); |
|---|
| 201 | 193 | if (ret) |
|---|
| 202 | | - goto err; |
|---|
| 194 | + return ret; |
|---|
| 203 | 195 | |
|---|
| 204 | | - ret = snd_soc_register_card(card); |
|---|
| 196 | + ret = devm_snd_soc_register_card(&pdev->dev, card); |
|---|
| 205 | 197 | if (ret) { |
|---|
| 206 | 198 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", |
|---|
| 207 | 199 | ret); |
|---|
| 208 | | - goto err_fini_utils; |
|---|
| 200 | + return ret; |
|---|
| 209 | 201 | } |
|---|
| 210 | | - |
|---|
| 211 | | - return 0; |
|---|
| 212 | | - |
|---|
| 213 | | -err_fini_utils: |
|---|
| 214 | | - tegra_asoc_utils_fini(&machine->util_data); |
|---|
| 215 | | -err: |
|---|
| 216 | | - return ret; |
|---|
| 217 | | -} |
|---|
| 218 | | - |
|---|
| 219 | | -static int tegra_rt5640_remove(struct platform_device *pdev) |
|---|
| 220 | | -{ |
|---|
| 221 | | - struct snd_soc_card *card = platform_get_drvdata(pdev); |
|---|
| 222 | | - struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); |
|---|
| 223 | | - |
|---|
| 224 | | - snd_soc_unregister_card(card); |
|---|
| 225 | | - |
|---|
| 226 | | - tegra_asoc_utils_fini(&machine->util_data); |
|---|
| 227 | 202 | |
|---|
| 228 | 203 | return 0; |
|---|
| 229 | 204 | } |
|---|
| .. | .. |
|---|
| 240 | 215 | .of_match_table = tegra_rt5640_of_match, |
|---|
| 241 | 216 | }, |
|---|
| 242 | 217 | .probe = tegra_rt5640_probe, |
|---|
| 243 | | - .remove = tegra_rt5640_remove, |
|---|
| 244 | 218 | }; |
|---|
| 245 | 219 | module_platform_driver(tegra_rt5640_driver); |
|---|
| 246 | 220 | |
|---|