| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * tegra_sgtl5000.c - Tegra machine ASoC driver for boards using SGTL5000 codec |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Author: Marcel Ziswiler <marcel@ziswiler.com> |
|---|
| 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 | * |
|---|
| .. | .. |
|---|
| 46 | 35 | static int tegra_sgtl5000_hw_params(struct snd_pcm_substream *substream, |
|---|
| 47 | 36 | struct snd_pcm_hw_params *params) |
|---|
| 48 | 37 | { |
|---|
| 49 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 50 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
|---|
| 38 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 39 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
|---|
| 51 | 40 | struct snd_soc_card *card = rtd->card; |
|---|
| 52 | 41 | struct tegra_sgtl5000 *machine = snd_soc_card_get_drvdata(card); |
|---|
| 53 | 42 | int srate, mclk; |
|---|
| .. | .. |
|---|
| 92 | 81 | SND_SOC_DAPM_MIC("Mic Jack", NULL), |
|---|
| 93 | 82 | }; |
|---|
| 94 | 83 | |
|---|
| 84 | +SND_SOC_DAILINK_DEFS(hifi, |
|---|
| 85 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 86 | + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "sgtl5000")), |
|---|
| 87 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
|---|
| 88 | + |
|---|
| 95 | 89 | static struct snd_soc_dai_link tegra_sgtl5000_dai = { |
|---|
| 96 | 90 | .name = "sgtl5000", |
|---|
| 97 | 91 | .stream_name = "HiFi", |
|---|
| 98 | | - .codec_dai_name = "sgtl5000", |
|---|
| 99 | 92 | .ops = &tegra_sgtl5000_ops, |
|---|
| 100 | 93 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
|---|
| 101 | 94 | SND_SOC_DAIFMT_CBS_CFS, |
|---|
| 95 | + SND_SOC_DAILINK_REG(hifi), |
|---|
| 102 | 96 | }; |
|---|
| 103 | 97 | |
|---|
| 104 | 98 | static struct snd_soc_card snd_soc_tegra_sgtl5000 = { |
|---|
| .. | .. |
|---|
| 135 | 129 | if (ret) |
|---|
| 136 | 130 | goto err; |
|---|
| 137 | 131 | |
|---|
| 138 | | - tegra_sgtl5000_dai.codec_of_node = of_parse_phandle(np, |
|---|
| 132 | + tegra_sgtl5000_dai.codecs->of_node = of_parse_phandle(np, |
|---|
| 139 | 133 | "nvidia,audio-codec", 0); |
|---|
| 140 | | - if (!tegra_sgtl5000_dai.codec_of_node) { |
|---|
| 134 | + if (!tegra_sgtl5000_dai.codecs->of_node) { |
|---|
| 141 | 135 | dev_err(&pdev->dev, |
|---|
| 142 | 136 | "Property 'nvidia,audio-codec' missing or invalid\n"); |
|---|
| 143 | 137 | ret = -EINVAL; |
|---|
| 144 | 138 | goto err; |
|---|
| 145 | 139 | } |
|---|
| 146 | 140 | |
|---|
| 147 | | - tegra_sgtl5000_dai.cpu_of_node = of_parse_phandle(np, |
|---|
| 141 | + tegra_sgtl5000_dai.cpus->of_node = of_parse_phandle(np, |
|---|
| 148 | 142 | "nvidia,i2s-controller", 0); |
|---|
| 149 | | - if (!tegra_sgtl5000_dai.cpu_of_node) { |
|---|
| 143 | + if (!tegra_sgtl5000_dai.cpus->of_node) { |
|---|
| 150 | 144 | dev_err(&pdev->dev, |
|---|
| 151 | 145 | "Property 'nvidia,i2s-controller' missing/invalid\n"); |
|---|
| 152 | 146 | ret = -EINVAL; |
|---|
| 153 | 147 | goto err_put_codec_of_node; |
|---|
| 154 | 148 | } |
|---|
| 155 | 149 | |
|---|
| 156 | | - tegra_sgtl5000_dai.platform_of_node = tegra_sgtl5000_dai.cpu_of_node; |
|---|
| 150 | + tegra_sgtl5000_dai.platforms->of_node = tegra_sgtl5000_dai.cpus->of_node; |
|---|
| 157 | 151 | |
|---|
| 158 | 152 | ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); |
|---|
| 159 | 153 | if (ret) |
|---|
| .. | .. |
|---|
| 163 | 157 | if (ret) { |
|---|
| 164 | 158 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", |
|---|
| 165 | 159 | ret); |
|---|
| 166 | | - goto err_fini_utils; |
|---|
| 160 | + goto err_put_cpu_of_node; |
|---|
| 167 | 161 | } |
|---|
| 168 | 162 | |
|---|
| 169 | 163 | return 0; |
|---|
| 170 | 164 | |
|---|
| 171 | | -err_fini_utils: |
|---|
| 172 | | - tegra_asoc_utils_fini(&machine->util_data); |
|---|
| 173 | 165 | err_put_cpu_of_node: |
|---|
| 174 | | - of_node_put(tegra_sgtl5000_dai.cpu_of_node); |
|---|
| 175 | | - tegra_sgtl5000_dai.cpu_of_node = NULL; |
|---|
| 176 | | - tegra_sgtl5000_dai.platform_of_node = NULL; |
|---|
| 166 | + of_node_put(tegra_sgtl5000_dai.cpus->of_node); |
|---|
| 167 | + tegra_sgtl5000_dai.cpus->of_node = NULL; |
|---|
| 168 | + tegra_sgtl5000_dai.platforms->of_node = NULL; |
|---|
| 177 | 169 | err_put_codec_of_node: |
|---|
| 178 | | - of_node_put(tegra_sgtl5000_dai.codec_of_node); |
|---|
| 179 | | - tegra_sgtl5000_dai.codec_of_node = NULL; |
|---|
| 170 | + of_node_put(tegra_sgtl5000_dai.codecs->of_node); |
|---|
| 171 | + tegra_sgtl5000_dai.codecs->of_node = NULL; |
|---|
| 180 | 172 | err: |
|---|
| 181 | 173 | return ret; |
|---|
| 182 | 174 | } |
|---|
| .. | .. |
|---|
| 184 | 176 | static int tegra_sgtl5000_driver_remove(struct platform_device *pdev) |
|---|
| 185 | 177 | { |
|---|
| 186 | 178 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
|---|
| 187 | | - struct tegra_sgtl5000 *machine = snd_soc_card_get_drvdata(card); |
|---|
| 188 | 179 | int ret; |
|---|
| 189 | 180 | |
|---|
| 190 | 181 | ret = snd_soc_unregister_card(card); |
|---|
| 191 | 182 | |
|---|
| 192 | | - tegra_asoc_utils_fini(&machine->util_data); |
|---|
| 193 | | - |
|---|
| 194 | | - of_node_put(tegra_sgtl5000_dai.cpu_of_node); |
|---|
| 195 | | - tegra_sgtl5000_dai.cpu_of_node = NULL; |
|---|
| 196 | | - tegra_sgtl5000_dai.platform_of_node = NULL; |
|---|
| 197 | | - of_node_put(tegra_sgtl5000_dai.codec_of_node); |
|---|
| 198 | | - tegra_sgtl5000_dai.codec_of_node = NULL; |
|---|
| 183 | + of_node_put(tegra_sgtl5000_dai.cpus->of_node); |
|---|
| 184 | + tegra_sgtl5000_dai.cpus->of_node = NULL; |
|---|
| 185 | + tegra_sgtl5000_dai.platforms->of_node = NULL; |
|---|
| 186 | + of_node_put(tegra_sgtl5000_dai.codecs->of_node); |
|---|
| 187 | + tegra_sgtl5000_dai.codecs->of_node = NULL; |
|---|
| 199 | 188 | |
|---|
| 200 | 189 | return ret; |
|---|
| 201 | 190 | } |
|---|