| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * trimslice.c - TrimSlice machine ASoC driver |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 7 | 8 | * Based on code copyright/by: |
|---|
| 8 | 9 | * Author: Stephen Warren <swarren@nvidia.com> |
|---|
| 9 | 10 | * Copyright (C) 2010-2011 - NVIDIA, Inc. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is free software; you can redistribute it and/or |
|---|
| 12 | | - * modify it under the terms of the GNU General Public License |
|---|
| 13 | | - * version 2 as published by the Free Software Foundation. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 16 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 18 | | - * General Public License for more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public License |
|---|
| 21 | | - * along with this program; if not, write to the Free Software |
|---|
| 22 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
|---|
| 23 | | - * 02110-1301 USA |
|---|
| 24 | | - * |
|---|
| 25 | 11 | */ |
|---|
| 26 | 12 | |
|---|
| 27 | 13 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 48 | 34 | static int trimslice_asoc_hw_params(struct snd_pcm_substream *substream, |
|---|
| 49 | 35 | struct snd_pcm_hw_params *params) |
|---|
| 50 | 36 | { |
|---|
| 51 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 52 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
|---|
| 37 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 38 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
|---|
| 53 | 39 | struct snd_soc_card *card = rtd->card; |
|---|
| 54 | 40 | struct tegra_trimslice *trimslice = snd_soc_card_get_drvdata(card); |
|---|
| 55 | 41 | int srate, mclk; |
|---|
| .. | .. |
|---|
| 91 | 77 | {"RLINEIN", NULL, "Line In"}, |
|---|
| 92 | 78 | }; |
|---|
| 93 | 79 | |
|---|
| 80 | +SND_SOC_DAILINK_DEFS(single_dsp, |
|---|
| 81 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 82 | + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "tlv320aic23-hifi")), |
|---|
| 83 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
|---|
| 84 | + |
|---|
| 94 | 85 | static struct snd_soc_dai_link trimslice_tlv320aic23_dai = { |
|---|
| 95 | 86 | .name = "TLV320AIC23", |
|---|
| 96 | 87 | .stream_name = "AIC23", |
|---|
| 97 | | - .codec_dai_name = "tlv320aic23-hifi", |
|---|
| 98 | 88 | .ops = &trimslice_asoc_ops, |
|---|
| 99 | 89 | .dai_fmt = SND_SOC_DAIFMT_I2S | |
|---|
| 100 | 90 | SND_SOC_DAIFMT_NB_NF | |
|---|
| 101 | 91 | SND_SOC_DAIFMT_CBS_CFS, |
|---|
| 92 | + SND_SOC_DAILINK_REG(single_dsp), |
|---|
| 102 | 93 | }; |
|---|
| 103 | 94 | |
|---|
| 104 | 95 | static struct snd_soc_card snd_soc_trimslice = { |
|---|
| .. | .. |
|---|
| 130 | 121 | card->dev = &pdev->dev; |
|---|
| 131 | 122 | snd_soc_card_set_drvdata(card, trimslice); |
|---|
| 132 | 123 | |
|---|
| 133 | | - trimslice_tlv320aic23_dai.codec_of_node = of_parse_phandle(np, |
|---|
| 124 | + trimslice_tlv320aic23_dai.codecs->of_node = of_parse_phandle(np, |
|---|
| 134 | 125 | "nvidia,audio-codec", 0); |
|---|
| 135 | | - if (!trimslice_tlv320aic23_dai.codec_of_node) { |
|---|
| 126 | + if (!trimslice_tlv320aic23_dai.codecs->of_node) { |
|---|
| 136 | 127 | dev_err(&pdev->dev, |
|---|
| 137 | 128 | "Property 'nvidia,audio-codec' missing or invalid\n"); |
|---|
| 138 | | - ret = -EINVAL; |
|---|
| 139 | | - goto err; |
|---|
| 129 | + return -EINVAL; |
|---|
| 140 | 130 | } |
|---|
| 141 | 131 | |
|---|
| 142 | | - trimslice_tlv320aic23_dai.cpu_of_node = of_parse_phandle(np, |
|---|
| 132 | + trimslice_tlv320aic23_dai.cpus->of_node = of_parse_phandle(np, |
|---|
| 143 | 133 | "nvidia,i2s-controller", 0); |
|---|
| 144 | | - if (!trimslice_tlv320aic23_dai.cpu_of_node) { |
|---|
| 134 | + if (!trimslice_tlv320aic23_dai.cpus->of_node) { |
|---|
| 145 | 135 | dev_err(&pdev->dev, |
|---|
| 146 | 136 | "Property 'nvidia,i2s-controller' missing or invalid\n"); |
|---|
| 147 | | - ret = -EINVAL; |
|---|
| 148 | | - goto err; |
|---|
| 137 | + return -EINVAL; |
|---|
| 149 | 138 | } |
|---|
| 150 | 139 | |
|---|
| 151 | | - trimslice_tlv320aic23_dai.platform_of_node = |
|---|
| 152 | | - trimslice_tlv320aic23_dai.cpu_of_node; |
|---|
| 140 | + trimslice_tlv320aic23_dai.platforms->of_node = |
|---|
| 141 | + trimslice_tlv320aic23_dai.cpus->of_node; |
|---|
| 153 | 142 | |
|---|
| 154 | 143 | ret = tegra_asoc_utils_init(&trimslice->util_data, &pdev->dev); |
|---|
| 155 | 144 | if (ret) |
|---|
| 156 | | - goto err; |
|---|
| 145 | + return ret; |
|---|
| 157 | 146 | |
|---|
| 158 | | - ret = snd_soc_register_card(card); |
|---|
| 147 | + ret = devm_snd_soc_register_card(&pdev->dev, card); |
|---|
| 159 | 148 | if (ret) { |
|---|
| 160 | 149 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", |
|---|
| 161 | 150 | ret); |
|---|
| 162 | | - goto err_fini_utils; |
|---|
| 151 | + return ret; |
|---|
| 163 | 152 | } |
|---|
| 164 | | - |
|---|
| 165 | | - return 0; |
|---|
| 166 | | - |
|---|
| 167 | | -err_fini_utils: |
|---|
| 168 | | - tegra_asoc_utils_fini(&trimslice->util_data); |
|---|
| 169 | | -err: |
|---|
| 170 | | - return ret; |
|---|
| 171 | | -} |
|---|
| 172 | | - |
|---|
| 173 | | -static int tegra_snd_trimslice_remove(struct platform_device *pdev) |
|---|
| 174 | | -{ |
|---|
| 175 | | - struct snd_soc_card *card = platform_get_drvdata(pdev); |
|---|
| 176 | | - struct tegra_trimslice *trimslice = snd_soc_card_get_drvdata(card); |
|---|
| 177 | | - |
|---|
| 178 | | - snd_soc_unregister_card(card); |
|---|
| 179 | | - |
|---|
| 180 | | - tegra_asoc_utils_fini(&trimslice->util_data); |
|---|
| 181 | 153 | |
|---|
| 182 | 154 | return 0; |
|---|
| 183 | 155 | } |
|---|
| .. | .. |
|---|
| 194 | 166 | .of_match_table = trimslice_of_match, |
|---|
| 195 | 167 | }, |
|---|
| 196 | 168 | .probe = tegra_snd_trimslice_probe, |
|---|
| 197 | | - .remove = tegra_snd_trimslice_remove, |
|---|
| 198 | 169 | }; |
|---|
| 199 | 170 | module_platform_driver(tegra_snd_trimslice_driver); |
|---|
| 200 | 171 | |
|---|