forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/sound/soc/fsl/eukrea-tlv320.c
....@@ -1,19 +1,13 @@
1
-/*
2
- * eukrea-tlv320.c -- SoC audio for eukrea_cpuimxXX in I2S mode
3
- *
4
- * Copyright 2010 Eric Bénard, Eukréa Electromatique <eric@eukrea.com>
5
- *
6
- * based on sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c
7
- * which is Copyright 2009 Simtec Electronics
8
- * and on sound/soc/imx/phycore-ac97.c which is
9
- * Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
10
- *
11
- * This program is free software; you can redistribute it and/or modify it
12
- * under the terms of the GNU General Public License as published by the
13
- * Free Software Foundation; either version 2 of the License, or (at your
14
- * option) any later version.
15
- *
16
- */
1
+// SPDX-License-Identifier: GPL-2.0+
2
+//
3
+// eukrea-tlv320.c -- SoC audio for eukrea_cpuimxXX in I2S mode
4
+//
5
+// Copyright 2010 Eric Bénard, Eukréa Electromatique <eric@eukrea.com>
6
+//
7
+// based on sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c
8
+// which is Copyright 2009 Simtec Electronics
9
+// and on sound/soc/imx/phycore-ac97.c which is
10
+// Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
1711
1812 #include <linux/errno.h>
1913 #include <linux/module.h>
....@@ -36,9 +30,9 @@
3630 static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream,
3731 struct snd_pcm_hw_params *params)
3832 {
39
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
40
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
41
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
33
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
34
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
35
+ struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
4236 int ret;
4337
4438 ret = snd_soc_dai_set_sysclk(codec_dai, 0,
....@@ -67,13 +61,18 @@
6761 .hw_params = eukrea_tlv320_hw_params,
6862 };
6963
64
+SND_SOC_DAILINK_DEFS(hifi,
65
+ DAILINK_COMP_ARRAY(COMP_EMPTY()),
66
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "tlv320aic23-hifi")),
67
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
68
+
7069 static struct snd_soc_dai_link eukrea_tlv320_dai = {
7170 .name = "tlv320aic23",
7271 .stream_name = "TLV320AIC23",
73
- .codec_dai_name = "tlv320aic23-hifi",
7472 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
7573 SND_SOC_DAIFMT_CBM_CFM,
7674 .ops = &eukrea_tlv320_snd_ops,
75
+ SND_SOC_DAILINK_REG(hifi),
7776 };
7877
7978 static struct snd_soc_card eukrea_tlv320 = {
....@@ -87,7 +86,7 @@
8786 int ret;
8887 int int_port = 0, ext_port;
8988 struct device_node *np = pdev->dev.of_node;
90
- struct device_node *ssi_np = NULL, *codec_np = NULL;
89
+ struct device_node *ssi_np = NULL, *codec_np = NULL, *tmp_np = NULL;
9190
9291 eukrea_tlv320.dev = &pdev->dev;
9392 if (np) {
....@@ -110,7 +109,7 @@
110109
111110 codec_np = of_parse_phandle(ssi_np, "codec-handle", 0);
112111 if (codec_np)
113
- eukrea_tlv320_dai.codec_of_node = codec_np;
112
+ eukrea_tlv320_dai.codecs->of_node = codec_np;
114113 else
115114 dev_err(&pdev->dev, "codec-handle node missing or invalid.\n");
116115
....@@ -134,17 +133,17 @@
134133 int_port--;
135134 ext_port--;
136135
137
- eukrea_tlv320_dai.cpu_of_node = ssi_np;
138
- eukrea_tlv320_dai.platform_of_node = ssi_np;
136
+ eukrea_tlv320_dai.cpus->of_node = ssi_np;
137
+ eukrea_tlv320_dai.platforms->of_node = ssi_np;
139138 } else {
140
- eukrea_tlv320_dai.cpu_dai_name = "imx-ssi.0";
141
- eukrea_tlv320_dai.platform_name = "imx-ssi.0";
142
- eukrea_tlv320_dai.codec_name = "tlv320aic23-codec.0-001a";
139
+ eukrea_tlv320_dai.cpus->dai_name = "imx-ssi.0";
140
+ eukrea_tlv320_dai.platforms->name = "imx-ssi.0";
141
+ eukrea_tlv320_dai.codecs->name = "tlv320aic23-codec.0-001a";
143142 eukrea_tlv320.name = "cpuimx-audio";
144143 }
145144
146145 if (machine_is_eukrea_cpuimx27() ||
147
- of_find_compatible_node(NULL, NULL, "fsl,imx21-audmux")) {
146
+ (tmp_np = of_find_compatible_node(NULL, NULL, "fsl,imx21-audmux"))) {
148147 imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
149148 IMX_AUDMUX_V1_PCR_SYN |
150149 IMX_AUDMUX_V1_PCR_TFSDIR |
....@@ -159,10 +158,11 @@
159158 IMX_AUDMUX_V1_PCR_SYN |
160159 IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0)
161160 );
161
+ of_node_put(tmp_np);
162162 } else if (machine_is_eukrea_cpuimx25sd() ||
163163 machine_is_eukrea_cpuimx35sd() ||
164164 machine_is_eukrea_cpuimx51sd() ||
165
- of_find_compatible_node(NULL, NULL, "fsl,imx31-audmux")) {
165
+ (tmp_np = of_find_compatible_node(NULL, NULL, "fsl,imx31-audmux"))) {
166166 if (!np)
167167 ext_port = machine_is_eukrea_cpuimx25sd() ?
168168 4 : 3;
....@@ -179,6 +179,7 @@
179179 IMX_AUDMUX_V2_PTCR_SYN,
180180 IMX_AUDMUX_V2_PDCR_RXDSEL(int_port)
181181 );
182
+ of_node_put(tmp_np);
182183 } else {
183184 if (np) {
184185 /* The eukrea,asoc-tlv320 driver was explicitly