forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/sound/soc/mxs/mxs-sgtl5000.c
....@@ -1,19 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * 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.
174 */
185
196 #include <linux/module.h>
....@@ -32,9 +19,9 @@
3219 static int mxs_sgtl5000_hw_params(struct snd_pcm_substream *substream,
3320 struct snd_pcm_hw_params *params)
3421 {
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);
3825 unsigned int rate = params_rate(params);
3926 u32 mclk;
4027 int ret;
....@@ -75,21 +62,32 @@
7562 #define MXS_SGTL5000_DAI_FMT (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | \
7663 SND_SOC_DAIFMT_CBS_CFS)
7764
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
+
7876 static struct snd_soc_dai_link mxs_sgtl5000_dai[] = {
7977 {
8078 .name = "HiFi Tx",
8179 .stream_name = "HiFi Playback",
82
- .codec_dai_name = "sgtl5000",
8380 .dai_fmt = MXS_SGTL5000_DAI_FMT,
8481 .ops = &mxs_sgtl5000_hifi_ops,
8582 .playback_only = true,
83
+ SND_SOC_DAILINK_REG(hifi_tx),
8684 }, {
8785 .name = "HiFi Rx",
8886 .stream_name = "HiFi Capture",
89
- .codec_dai_name = "sgtl5000",
9087 .dai_fmt = MXS_SGTL5000_DAI_FMT,
9188 .ops = &mxs_sgtl5000_hifi_ops,
9289 .capture_only = true,
90
+ SND_SOC_DAILINK_REG(hifi_rx),
9391 },
9492 };
9593
....@@ -120,16 +118,19 @@
120118 codec_np = of_parse_phandle(np, "audio-codec", 0);
121119 if (!saif_np[0] || !saif_np[1] || !codec_np) {
122120 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]);
123124 return -EINVAL;
124125 }
125126
126127 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];
133134 }
134135
135136 of_node_put(codec_np);