forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/intel/boards/haswell.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Intel Haswell Lynxpoint SST Audio
34 *
45 * Copyright (C) 2013, Intel Corporation. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License version
8
- * 2 as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
156 */
167
178 #include <linux/module.h>
....@@ -19,10 +10,8 @@
1910 #include <sound/core.h>
2011 #include <sound/pcm.h>
2112 #include <sound/soc.h>
13
+#include <sound/soc-acpi.h>
2214 #include <sound/pcm_params.h>
23
-
24
-#include "../common/sst-dsp.h"
25
-#include "../haswell/sst-haswell-ipc.h"
2615
2716 #include "../../codecs/rt5640.h"
2817
....@@ -63,8 +52,8 @@
6352 static int haswell_rt5640_hw_params(struct snd_pcm_substream *substream,
6453 struct snd_pcm_hw_params *params)
6554 {
66
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
67
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
55
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
56
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
6857 int ret;
6958
7059 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_MCLK, 12288000,
....@@ -85,72 +74,68 @@
8574 .hw_params = haswell_rt5640_hw_params,
8675 };
8776
88
-static int haswell_rtd_init(struct snd_soc_pcm_runtime *rtd)
89
-{
90
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
91
- struct sst_pdata *pdata = dev_get_platdata(component->dev);
92
- struct sst_hsw *haswell = pdata->dsp;
93
- int ret;
77
+SND_SOC_DAILINK_DEF(dummy,
78
+ DAILINK_COMP_ARRAY(COMP_DUMMY()));
9479
95
- /* Set ADSP SSP port settings */
96
- ret = sst_hsw_device_set_config(haswell, SST_HSW_DEVICE_SSP_0,
97
- SST_HSW_DEVICE_MCLK_FREQ_24_MHZ,
98
- SST_HSW_DEVICE_CLOCK_MASTER, 9);
99
- if (ret < 0) {
100
- dev_err(rtd->dev, "failed to set device config\n");
101
- return ret;
102
- }
80
+SND_SOC_DAILINK_DEF(system,
81
+ DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
10382
104
- return 0;
105
-}
83
+SND_SOC_DAILINK_DEF(offload0,
84
+ DAILINK_COMP_ARRAY(COMP_CPU("Offload0 Pin")));
85
+
86
+SND_SOC_DAILINK_DEF(offload1,
87
+ DAILINK_COMP_ARRAY(COMP_CPU("Offload1 Pin")));
88
+
89
+SND_SOC_DAILINK_DEF(loopback,
90
+ DAILINK_COMP_ARRAY(COMP_CPU("Loopback Pin")));
91
+
92
+SND_SOC_DAILINK_DEF(codec,
93
+ DAILINK_COMP_ARRAY(COMP_CODEC("i2c-INT33CA:00", "rt5640-aif1")));
94
+
95
+SND_SOC_DAILINK_DEF(platform,
96
+ DAILINK_COMP_ARRAY(COMP_PLATFORM("haswell-pcm-audio")));
97
+
98
+SND_SOC_DAILINK_DEF(ssp0_port,
99
+ DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port")));
106100
107101 static struct snd_soc_dai_link haswell_rt5640_dais[] = {
108102 /* Front End DAI links */
109103 {
110104 .name = "System",
111105 .stream_name = "System Playback/Capture",
112
- .cpu_dai_name = "System Pin",
113
- .platform_name = "haswell-pcm-audio",
106
+ .nonatomic = 1,
114107 .dynamic = 1,
115
- .codec_name = "snd-soc-dummy",
116
- .codec_dai_name = "snd-soc-dummy-dai",
117
- .init = haswell_rtd_init,
118108 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
119109 .dpcm_playback = 1,
120110 .dpcm_capture = 1,
111
+ SND_SOC_DAILINK_REG(system, dummy, platform),
121112 },
122113 {
123114 .name = "Offload0",
124115 .stream_name = "Offload0 Playback",
125
- .cpu_dai_name = "Offload0 Pin",
126
- .platform_name = "haswell-pcm-audio",
116
+ .nonatomic = 1,
127117 .dynamic = 1,
128
- .codec_name = "snd-soc-dummy",
129
- .codec_dai_name = "snd-soc-dummy-dai",
130118 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
131119 .dpcm_playback = 1,
120
+ SND_SOC_DAILINK_REG(offload0, dummy, platform),
132121 },
133122 {
134123 .name = "Offload1",
135124 .stream_name = "Offload1 Playback",
136
- .cpu_dai_name = "Offload1 Pin",
137
- .platform_name = "haswell-pcm-audio",
125
+ .nonatomic = 1,
138126 .dynamic = 1,
139
- .codec_name = "snd-soc-dummy",
140
- .codec_dai_name = "snd-soc-dummy-dai",
141127 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
142128 .dpcm_playback = 1,
129
+ SND_SOC_DAILINK_REG(offload1, dummy, platform),
143130 },
144131 {
145132 .name = "Loopback",
146133 .stream_name = "Loopback",
147
- .cpu_dai_name = "Loopback Pin",
148
- .platform_name = "haswell-pcm-audio",
134
+ .nonatomic = 1,
149135 .dynamic = 1,
150
- .codec_name = "snd-soc-dummy",
151
- .codec_dai_name = "snd-soc-dummy-dai",
152136 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
153137 .dpcm_capture = 1,
138
+ SND_SOC_DAILINK_REG(loopback, dummy, platform),
154139 },
155140
156141 /* Back End DAI links */
....@@ -158,19 +143,15 @@
158143 /* SSP0 - Codec */
159144 .name = "Codec",
160145 .id = 0,
161
- .cpu_dai_name = "snd-soc-dummy-dai",
162
- .platform_name = "snd-soc-dummy",
163146 .no_pcm = 1,
164
- .codec_name = "i2c-INT33CA:00",
165
- .codec_dai_name = "rt5640-aif1",
166147 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
167148 SND_SOC_DAIFMT_CBS_CFS,
168
- .ignore_suspend = 1,
169149 .ignore_pmdown_time = 1,
170150 .be_hw_params_fixup = haswell_ssp0_fixup,
171151 .ops = &haswell_rt5640_ops,
172152 .dpcm_playback = 1,
173153 .dpcm_capture = 1,
154
+ SND_SOC_DAILINK_REG(ssp0_port, codec, platform),
174155 },
175156 };
176157
....@@ -189,8 +170,18 @@
189170
190171 static int haswell_audio_probe(struct platform_device *pdev)
191172 {
173
+ struct snd_soc_acpi_mach *mach;
174
+ int ret;
175
+
192176 haswell_rt5640.dev = &pdev->dev;
193177
178
+ /* override plaform name, if required */
179
+ mach = pdev->dev.platform_data;
180
+ ret = snd_soc_fixup_dai_links_platform_name(&haswell_rt5640,
181
+ mach->mach_params.platform);
182
+ if (ret)
183
+ return ret;
184
+
194185 return devm_snd_soc_register_card(&pdev->dev, &haswell_rt5640);
195186 }
196187