.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Intel Haswell Lynxpoint SST Audio |
---|
3 | 4 | * |
---|
4 | 5 | * 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 | | - * |
---|
15 | 6 | */ |
---|
16 | 7 | |
---|
17 | 8 | #include <linux/module.h> |
---|
.. | .. |
---|
19 | 10 | #include <sound/core.h> |
---|
20 | 11 | #include <sound/pcm.h> |
---|
21 | 12 | #include <sound/soc.h> |
---|
| 13 | +#include <sound/soc-acpi.h> |
---|
22 | 14 | #include <sound/pcm_params.h> |
---|
23 | | - |
---|
24 | | -#include "../common/sst-dsp.h" |
---|
25 | | -#include "../haswell/sst-haswell-ipc.h" |
---|
26 | 15 | |
---|
27 | 16 | #include "../../codecs/rt5640.h" |
---|
28 | 17 | |
---|
.. | .. |
---|
63 | 52 | static int haswell_rt5640_hw_params(struct snd_pcm_substream *substream, |
---|
64 | 53 | struct snd_pcm_hw_params *params) |
---|
65 | 54 | { |
---|
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); |
---|
68 | 57 | int ret; |
---|
69 | 58 | |
---|
70 | 59 | ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_MCLK, 12288000, |
---|
.. | .. |
---|
85 | 74 | .hw_params = haswell_rt5640_hw_params, |
---|
86 | 75 | }; |
---|
87 | 76 | |
---|
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())); |
---|
94 | 79 | |
---|
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"))); |
---|
103 | 82 | |
---|
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"))); |
---|
106 | 100 | |
---|
107 | 101 | static struct snd_soc_dai_link haswell_rt5640_dais[] = { |
---|
108 | 102 | /* Front End DAI links */ |
---|
109 | 103 | { |
---|
110 | 104 | .name = "System", |
---|
111 | 105 | .stream_name = "System Playback/Capture", |
---|
112 | | - .cpu_dai_name = "System Pin", |
---|
113 | | - .platform_name = "haswell-pcm-audio", |
---|
| 106 | + .nonatomic = 1, |
---|
114 | 107 | .dynamic = 1, |
---|
115 | | - .codec_name = "snd-soc-dummy", |
---|
116 | | - .codec_dai_name = "snd-soc-dummy-dai", |
---|
117 | | - .init = haswell_rtd_init, |
---|
118 | 108 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
---|
119 | 109 | .dpcm_playback = 1, |
---|
120 | 110 | .dpcm_capture = 1, |
---|
| 111 | + SND_SOC_DAILINK_REG(system, dummy, platform), |
---|
121 | 112 | }, |
---|
122 | 113 | { |
---|
123 | 114 | .name = "Offload0", |
---|
124 | 115 | .stream_name = "Offload0 Playback", |
---|
125 | | - .cpu_dai_name = "Offload0 Pin", |
---|
126 | | - .platform_name = "haswell-pcm-audio", |
---|
| 116 | + .nonatomic = 1, |
---|
127 | 117 | .dynamic = 1, |
---|
128 | | - .codec_name = "snd-soc-dummy", |
---|
129 | | - .codec_dai_name = "snd-soc-dummy-dai", |
---|
130 | 118 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
---|
131 | 119 | .dpcm_playback = 1, |
---|
| 120 | + SND_SOC_DAILINK_REG(offload0, dummy, platform), |
---|
132 | 121 | }, |
---|
133 | 122 | { |
---|
134 | 123 | .name = "Offload1", |
---|
135 | 124 | .stream_name = "Offload1 Playback", |
---|
136 | | - .cpu_dai_name = "Offload1 Pin", |
---|
137 | | - .platform_name = "haswell-pcm-audio", |
---|
| 125 | + .nonatomic = 1, |
---|
138 | 126 | .dynamic = 1, |
---|
139 | | - .codec_name = "snd-soc-dummy", |
---|
140 | | - .codec_dai_name = "snd-soc-dummy-dai", |
---|
141 | 127 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
---|
142 | 128 | .dpcm_playback = 1, |
---|
| 129 | + SND_SOC_DAILINK_REG(offload1, dummy, platform), |
---|
143 | 130 | }, |
---|
144 | 131 | { |
---|
145 | 132 | .name = "Loopback", |
---|
146 | 133 | .stream_name = "Loopback", |
---|
147 | | - .cpu_dai_name = "Loopback Pin", |
---|
148 | | - .platform_name = "haswell-pcm-audio", |
---|
| 134 | + .nonatomic = 1, |
---|
149 | 135 | .dynamic = 1, |
---|
150 | | - .codec_name = "snd-soc-dummy", |
---|
151 | | - .codec_dai_name = "snd-soc-dummy-dai", |
---|
152 | 136 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
---|
153 | 137 | .dpcm_capture = 1, |
---|
| 138 | + SND_SOC_DAILINK_REG(loopback, dummy, platform), |
---|
154 | 139 | }, |
---|
155 | 140 | |
---|
156 | 141 | /* Back End DAI links */ |
---|
.. | .. |
---|
158 | 143 | /* SSP0 - Codec */ |
---|
159 | 144 | .name = "Codec", |
---|
160 | 145 | .id = 0, |
---|
161 | | - .cpu_dai_name = "snd-soc-dummy-dai", |
---|
162 | | - .platform_name = "snd-soc-dummy", |
---|
163 | 146 | .no_pcm = 1, |
---|
164 | | - .codec_name = "i2c-INT33CA:00", |
---|
165 | | - .codec_dai_name = "rt5640-aif1", |
---|
166 | 147 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
---|
167 | 148 | SND_SOC_DAIFMT_CBS_CFS, |
---|
168 | | - .ignore_suspend = 1, |
---|
169 | 149 | .ignore_pmdown_time = 1, |
---|
170 | 150 | .be_hw_params_fixup = haswell_ssp0_fixup, |
---|
171 | 151 | .ops = &haswell_rt5640_ops, |
---|
172 | 152 | .dpcm_playback = 1, |
---|
173 | 153 | .dpcm_capture = 1, |
---|
| 154 | + SND_SOC_DAILINK_REG(ssp0_port, codec, platform), |
---|
174 | 155 | }, |
---|
175 | 156 | }; |
---|
176 | 157 | |
---|
.. | .. |
---|
189 | 170 | |
---|
190 | 171 | static int haswell_audio_probe(struct platform_device *pdev) |
---|
191 | 172 | { |
---|
| 173 | + struct snd_soc_acpi_mach *mach; |
---|
| 174 | + int ret; |
---|
| 175 | + |
---|
192 | 176 | haswell_rt5640.dev = &pdev->dev; |
---|
193 | 177 | |
---|
| 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 | + |
---|
194 | 185 | return devm_snd_soc_register_card(&pdev->dev, &haswell_rt5640); |
---|
195 | 186 | } |
---|
196 | 187 | |
---|