| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Rockchip machine ASoC driver for RK3288 boards that have an HDMI and analog |
|---|
| 3 | 4 | * audio output |
|---|
| .. | .. |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * Authors: Sjoerd Simons <sjoerd.simons@collabora.com>, |
|---|
| 8 | 9 | * Romain Perier <romain.perier@collabora.com> |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 11 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 12 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 15 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 16 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 17 | | - * more details. |
|---|
| 18 | | - * |
|---|
| 19 | | - * You should have received a copy of the GNU General Public License |
|---|
| 20 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 21 | | - * |
|---|
| 22 | 10 | */ |
|---|
| 23 | 11 | |
|---|
| 24 | 12 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 78 | 66 | struct snd_pcm_hw_params *params) |
|---|
| 79 | 67 | { |
|---|
| 80 | 68 | int ret = 0; |
|---|
| 81 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 82 | | - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
|---|
| 83 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
|---|
| 69 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 70 | + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); |
|---|
| 71 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
|---|
| 84 | 72 | int mclk; |
|---|
| 85 | 73 | |
|---|
| 86 | 74 | switch (params_rate(params)) { |
|---|
| .. | .. |
|---|
| 151 | 139 | .hw_params = rk_hw_params, |
|---|
| 152 | 140 | }; |
|---|
| 153 | 141 | |
|---|
| 154 | | -static struct snd_soc_dai_link_component rk_codecs[] = { |
|---|
| 155 | | - { }, |
|---|
| 156 | | - { |
|---|
| 157 | | - .name = "hdmi-audio-codec.2.auto", |
|---|
| 158 | | - .dai_name = "i2s-hifi", |
|---|
| 159 | | - }, |
|---|
| 160 | | -}; |
|---|
| 142 | +SND_SOC_DAILINK_DEFS(audio, |
|---|
| 143 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 144 | + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, NULL), |
|---|
| 145 | + COMP_CODEC("hdmi-audio-codec.2.auto", "i2s-hifi")), |
|---|
| 146 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
|---|
| 161 | 147 | |
|---|
| 162 | 148 | static struct snd_soc_dai_link rk_dailink = { |
|---|
| 163 | 149 | .name = "Codecs", |
|---|
| 164 | 150 | .stream_name = "Audio", |
|---|
| 165 | 151 | .init = rk_init, |
|---|
| 166 | 152 | .ops = &rk_ops, |
|---|
| 167 | | - .codecs = rk_codecs, |
|---|
| 168 | | - .num_codecs = ARRAY_SIZE(rk_codecs), |
|---|
| 169 | 153 | /* Set codecs as slave */ |
|---|
| 170 | 154 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
|---|
| 171 | 155 | SND_SOC_DAIFMT_CBS_CFS, |
|---|
| 156 | + SND_SOC_DAILINK_REG(audio), |
|---|
| 172 | 157 | }; |
|---|
| 173 | 158 | |
|---|
| 174 | 159 | static struct snd_soc_card snd_soc_card_rk = { |
|---|
| .. | .. |
|---|
| 244 | 229 | return ret; |
|---|
| 245 | 230 | } |
|---|
| 246 | 231 | |
|---|
| 247 | | - rk_dailink.cpu_of_node = of_parse_phandle(np, "rockchip,i2s-controller", |
|---|
| 232 | + rk_dailink.cpus->of_node = of_parse_phandle(np, "rockchip,i2s-controller", |
|---|
| 248 | 233 | 0); |
|---|
| 249 | | - if (!rk_dailink.cpu_of_node) { |
|---|
| 234 | + if (!rk_dailink.cpus->of_node) { |
|---|
| 250 | 235 | dev_err(&pdev->dev, |
|---|
| 251 | 236 | "Property 'rockchip,i2s-controller' missing or invalid\n"); |
|---|
| 252 | 237 | return -EINVAL; |
|---|
| 253 | 238 | } |
|---|
| 254 | 239 | |
|---|
| 255 | | - rk_dailink.platform_of_node = rk_dailink.cpu_of_node; |
|---|
| 240 | + rk_dailink.platforms->of_node = rk_dailink.cpus->of_node; |
|---|
| 256 | 241 | |
|---|
| 257 | 242 | ret = snd_soc_of_parse_audio_routing(card, "rockchip,routing"); |
|---|
| 258 | 243 | if (ret) { |
|---|
| .. | .. |
|---|
| 286 | 271 | .probe = snd_rk_mc_probe, |
|---|
| 287 | 272 | .driver = { |
|---|
| 288 | 273 | .name = DRV_NAME, |
|---|
| 289 | | - .owner = THIS_MODULE, |
|---|
| 290 | 274 | .pm = &snd_soc_pm_ops, |
|---|
| 291 | 275 | .of_match_table = rockchip_sound_of_match, |
|---|
| 292 | 276 | }, |
|---|