| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2011 Freescale Semiconductor, Inc. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 6 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | | - * (at your option) any later version. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | | - * GNU General Public License for more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * You should have received a copy of the GNU General Public License along |
|---|
| 15 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 16 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|---|
| 17 | 4 | */ |
|---|
| 18 | 5 | |
|---|
| 19 | 6 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 32 | 19 | static int mxs_sgtl5000_hw_params(struct snd_pcm_substream *substream, |
|---|
| 33 | 20 | struct snd_pcm_hw_params *params) |
|---|
| 34 | 21 | { |
|---|
| 35 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 36 | | - struct snd_soc_dai *codec_dai = rtd->codec_dai; |
|---|
| 37 | | - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
|---|
| 22 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 23 | + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); |
|---|
| 24 | + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); |
|---|
| 38 | 25 | unsigned int rate = params_rate(params); |
|---|
| 39 | 26 | u32 mclk; |
|---|
| 40 | 27 | int ret; |
|---|
| .. | .. |
|---|
| 75 | 62 | #define MXS_SGTL5000_DAI_FMT (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | \ |
|---|
| 76 | 63 | SND_SOC_DAIFMT_CBS_CFS) |
|---|
| 77 | 64 | |
|---|
| 65 | + |
|---|
| 66 | +SND_SOC_DAILINK_DEFS(hifi_tx, |
|---|
| 67 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 68 | + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "sgtl5000")), |
|---|
| 69 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
|---|
| 70 | + |
|---|
| 71 | +SND_SOC_DAILINK_DEFS(hifi_rx, |
|---|
| 72 | + DAILINK_COMP_ARRAY(COMP_EMPTY()), |
|---|
| 73 | + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "sgtl5000")), |
|---|
| 74 | + DAILINK_COMP_ARRAY(COMP_EMPTY())); |
|---|
| 75 | + |
|---|
| 78 | 76 | static struct snd_soc_dai_link mxs_sgtl5000_dai[] = { |
|---|
| 79 | 77 | { |
|---|
| 80 | 78 | .name = "HiFi Tx", |
|---|
| 81 | 79 | .stream_name = "HiFi Playback", |
|---|
| 82 | | - .codec_dai_name = "sgtl5000", |
|---|
| 83 | 80 | .dai_fmt = MXS_SGTL5000_DAI_FMT, |
|---|
| 84 | 81 | .ops = &mxs_sgtl5000_hifi_ops, |
|---|
| 85 | 82 | .playback_only = true, |
|---|
| 83 | + SND_SOC_DAILINK_REG(hifi_tx), |
|---|
| 86 | 84 | }, { |
|---|
| 87 | 85 | .name = "HiFi Rx", |
|---|
| 88 | 86 | .stream_name = "HiFi Capture", |
|---|
| 89 | | - .codec_dai_name = "sgtl5000", |
|---|
| 90 | 87 | .dai_fmt = MXS_SGTL5000_DAI_FMT, |
|---|
| 91 | 88 | .ops = &mxs_sgtl5000_hifi_ops, |
|---|
| 92 | 89 | .capture_only = true, |
|---|
| 90 | + SND_SOC_DAILINK_REG(hifi_rx), |
|---|
| 93 | 91 | }, |
|---|
| 94 | 92 | }; |
|---|
| 95 | 93 | |
|---|
| .. | .. |
|---|
| 120 | 118 | codec_np = of_parse_phandle(np, "audio-codec", 0); |
|---|
| 121 | 119 | if (!saif_np[0] || !saif_np[1] || !codec_np) { |
|---|
| 122 | 120 | dev_err(&pdev->dev, "phandle missing or invalid\n"); |
|---|
| 121 | + of_node_put(codec_np); |
|---|
| 122 | + of_node_put(saif_np[0]); |
|---|
| 123 | + of_node_put(saif_np[1]); |
|---|
| 123 | 124 | return -EINVAL; |
|---|
| 124 | 125 | } |
|---|
| 125 | 126 | |
|---|
| 126 | 127 | for (i = 0; i < 2; i++) { |
|---|
| 127 | | - mxs_sgtl5000_dai[i].codec_name = NULL; |
|---|
| 128 | | - mxs_sgtl5000_dai[i].codec_of_node = codec_np; |
|---|
| 129 | | - mxs_sgtl5000_dai[i].cpu_dai_name = NULL; |
|---|
| 130 | | - mxs_sgtl5000_dai[i].cpu_of_node = saif_np[i]; |
|---|
| 131 | | - mxs_sgtl5000_dai[i].platform_name = NULL; |
|---|
| 132 | | - mxs_sgtl5000_dai[i].platform_of_node = saif_np[i]; |
|---|
| 128 | + mxs_sgtl5000_dai[i].codecs->name = NULL; |
|---|
| 129 | + mxs_sgtl5000_dai[i].codecs->of_node = codec_np; |
|---|
| 130 | + mxs_sgtl5000_dai[i].cpus->dai_name = NULL; |
|---|
| 131 | + mxs_sgtl5000_dai[i].cpus->of_node = saif_np[i]; |
|---|
| 132 | + mxs_sgtl5000_dai[i].platforms->name = NULL; |
|---|
| 133 | + mxs_sgtl5000_dai[i].platforms->of_node = saif_np[i]; |
|---|
| 133 | 134 | } |
|---|
| 134 | 135 | |
|---|
| 135 | 136 | of_node_put(codec_np); |
|---|