| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Rockchip machine ASoC driver for boards using a RT5645/RT5650 CODEC. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2015, ROCKCHIP 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 | | - * |
|---|
| 18 | 6 | */ |
|---|
| 19 | 7 | |
|---|
| 20 | 8 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 67 | 55 | struct snd_pcm_hw_params *params) |
|---|
| 68 | 56 | { |
|---|
| 69 | 57 | int ret = 0; |
|---|
| 70 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 71 | | - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
|---|
| 72 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
|---|
| 58 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 59 | + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); |
|---|
| 60 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
|---|
| 73 | 61 | int mclk; |
|---|
| 74 | 62 | |
|---|
| 75 | 63 | switch (params_rate(params)) { |
|---|
| .. | .. |
|---|
| 125 | 113 | return ret; |
|---|
| 126 | 114 | } |
|---|
| 127 | 115 | |
|---|
| 128 | | - return rt5645_set_jack_detect(runtime->codec_dai->component, |
|---|
| 116 | + return rt5645_set_jack_detect(asoc_rtd_to_codec(runtime, 0)->component, |
|---|
| 129 | 117 | &headset_jack, |
|---|
| 130 | 118 | &headset_jack, |
|---|
| 131 | 119 | &headset_jack); |
|---|
| .. | .. |
|---|
| 135 | 123 | .hw_params = rk_aif1_hw_params, |
|---|
| 136 | 124 | }; |
|---|
| 137 | 125 | |
|---|
| 126 | +SND_SOC_DAILINK_DEFS(pcm, |
|---|
| 127 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 128 | + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5645-aif1")), |
|---|
| 129 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
|---|
| 130 | + |
|---|
| 138 | 131 | static struct snd_soc_dai_link rk_dailink = { |
|---|
| 139 | 132 | .name = "rt5645", |
|---|
| 140 | 133 | .stream_name = "rt5645 PCM", |
|---|
| 141 | | - .codec_dai_name = "rt5645-aif1", |
|---|
| 142 | 134 | .init = rk_init, |
|---|
| 143 | 135 | .ops = &rk_aif1_ops, |
|---|
| 144 | 136 | /* set rt5645 as slave */ |
|---|
| 145 | 137 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
|---|
| 146 | 138 | SND_SOC_DAIFMT_CBS_CFS, |
|---|
| 139 | + SND_SOC_DAILINK_REG(pcm), |
|---|
| 147 | 140 | }; |
|---|
| 148 | 141 | |
|---|
| 149 | 142 | static struct snd_soc_card snd_soc_card_rk = { |
|---|
| .. | .. |
|---|
| 168 | 161 | /* register the soc card */ |
|---|
| 169 | 162 | card->dev = &pdev->dev; |
|---|
| 170 | 163 | |
|---|
| 171 | | - rk_dailink.codec_of_node = of_parse_phandle(np, |
|---|
| 164 | + rk_dailink.codecs->of_node = of_parse_phandle(np, |
|---|
| 172 | 165 | "rockchip,audio-codec", 0); |
|---|
| 173 | | - if (!rk_dailink.codec_of_node) { |
|---|
| 166 | + if (!rk_dailink.codecs->of_node) { |
|---|
| 174 | 167 | dev_err(&pdev->dev, |
|---|
| 175 | 168 | "Property 'rockchip,audio-codec' missing or invalid\n"); |
|---|
| 176 | 169 | return -EINVAL; |
|---|
| 177 | 170 | } |
|---|
| 178 | 171 | |
|---|
| 179 | | - rk_dailink.cpu_of_node = of_parse_phandle(np, |
|---|
| 172 | + rk_dailink.cpus->of_node = of_parse_phandle(np, |
|---|
| 180 | 173 | "rockchip,i2s-controller", 0); |
|---|
| 181 | | - if (!rk_dailink.cpu_of_node) { |
|---|
| 174 | + if (!rk_dailink.cpus->of_node) { |
|---|
| 182 | 175 | dev_err(&pdev->dev, |
|---|
| 183 | 176 | "Property 'rockchip,i2s-controller' missing or invalid\n"); |
|---|
| 184 | 177 | ret = -EINVAL; |
|---|
| 185 | 178 | goto put_codec_of_node; |
|---|
| 186 | 179 | } |
|---|
| 187 | 180 | |
|---|
| 188 | | - rk_dailink.platform_of_node = rk_dailink.cpu_of_node; |
|---|
| 181 | + rk_dailink.platforms->of_node = rk_dailink.cpus->of_node; |
|---|
| 189 | 182 | |
|---|
| 190 | 183 | ret = snd_soc_of_parse_card_name(card, "rockchip,model"); |
|---|
| 191 | 184 | if (ret) { |
|---|
| .. | .. |
|---|
| 204 | 197 | return ret; |
|---|
| 205 | 198 | |
|---|
| 206 | 199 | put_cpu_of_node: |
|---|
| 207 | | - of_node_put(rk_dailink.cpu_of_node); |
|---|
| 208 | | - rk_dailink.cpu_of_node = NULL; |
|---|
| 200 | + of_node_put(rk_dailink.cpus->of_node); |
|---|
| 201 | + rk_dailink.cpus->of_node = NULL; |
|---|
| 209 | 202 | put_codec_of_node: |
|---|
| 210 | | - of_node_put(rk_dailink.codec_of_node); |
|---|
| 211 | | - rk_dailink.codec_of_node = NULL; |
|---|
| 203 | + of_node_put(rk_dailink.codecs->of_node); |
|---|
| 204 | + rk_dailink.codecs->of_node = NULL; |
|---|
| 212 | 205 | |
|---|
| 213 | 206 | return ret; |
|---|
| 214 | 207 | } |
|---|
| 215 | 208 | |
|---|
| 216 | 209 | static int snd_rk_mc_remove(struct platform_device *pdev) |
|---|
| 217 | 210 | { |
|---|
| 218 | | - of_node_put(rk_dailink.cpu_of_node); |
|---|
| 219 | | - rk_dailink.cpu_of_node = NULL; |
|---|
| 220 | | - of_node_put(rk_dailink.codec_of_node); |
|---|
| 221 | | - rk_dailink.codec_of_node = NULL; |
|---|
| 211 | + of_node_put(rk_dailink.cpus->of_node); |
|---|
| 212 | + rk_dailink.cpus->of_node = NULL; |
|---|
| 213 | + of_node_put(rk_dailink.codecs->of_node); |
|---|
| 214 | + rk_dailink.codecs->of_node = NULL; |
|---|
| 222 | 215 | |
|---|
| 223 | 216 | return 0; |
|---|
| 224 | 217 | } |
|---|