1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2 //
3 // This file is provided under a dual BSD/GPLv2 license. When using or
4 // redistributing this file, you may do so under either license.
5 //
6 // Copyright(c) 2018 Intel Corporation
7 //
8 // Authors: Liam Girdwood <liam.r.girdwood@linux.intel.com>
9 // Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
10 // Rander Wang <rander.wang@intel.com>
11 // Keyon Jie <yang.jie@linux.intel.com>
12 //
13
14 /*
15 * Hardware interface for generic Intel audio DSP HDA IP
16 */
17
18 #include <sound/hdaudio_ext.h>
19 #include <sound/hda_register.h>
20
21 #include <linux/acpi.h>
22 #include <linux/debugfs.h>
23 #include <linux/module.h>
24 #include <linux/soundwire/sdw.h>
25 #include <linux/soundwire/sdw_intel.h>
26 #include <sound/intel-dsp-config.h>
27 #include <sound/intel-nhlt.h>
28 #include <sound/soc-acpi-intel-ssp-common.h>
29 #include <sound/soc_sdw_utils.h>
30 #include <sound/sof.h>
31 #include <sound/sof/xtensa.h>
32 #include <sound/hda-mlink.h>
33 #include "../sof-audio.h"
34 #include "../sof-pci-dev.h"
35 #include "../ops.h"
36 #include "../ipc4-topology.h"
37 #include "../../intel/common/sof-function-topology-lib.h"
38 #include "hda.h"
39
40 #include <trace/events/sof_intel.h>
41
42 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
43 #include <sound/soc-acpi-intel-match.h>
44 #endif
45
46 /* platform specific devices */
47 #include "shim.h"
48
49 #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
50
51 /*
52 * The default for SoundWire clock stop quirks is to power gate the IP
53 * and do a Bus Reset, this will need to be modified when the DSP
54 * needs to remain in D0i3 so that the Master does not lose context
55 * and enumeration is not required on clock restart
56 */
57 static int sdw_clock_stop_quirks = SDW_INTEL_CLK_STOP_BUS_RESET;
58 module_param(sdw_clock_stop_quirks, int, 0444);
59 MODULE_PARM_DESC(sdw_clock_stop_quirks, "SOF SoundWire clock stop quirks");
60
sdw_params_stream(struct device * dev,struct sdw_intel_stream_params_data * params_data)61 static int sdw_params_stream(struct device *dev,
62 struct sdw_intel_stream_params_data *params_data)
63 {
64 struct snd_soc_dai *d = params_data->dai;
65 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, params_data->substream->stream);
66 struct snd_sof_dai_config_data data = { 0 };
67
68 if (!w) {
69 dev_err(dev, "%s widget not found, check amp link num in the topology\n",
70 d->name);
71 return -EINVAL;
72 }
73 data.dai_index = (params_data->link_id << 8) | d->id;
74 data.dai_data = params_data->alh_stream_id;
75 data.dai_node_id = data.dai_data;
76
77 return hda_dai_config(w, SOF_DAI_CONFIG_FLAGS_HW_PARAMS, &data);
78 }
79
sdw_params_free(struct device * dev,struct sdw_intel_stream_free_data * free_data)80 static int sdw_params_free(struct device *dev, struct sdw_intel_stream_free_data *free_data)
81 {
82 struct snd_soc_dai *d = free_data->dai;
83 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, free_data->substream->stream);
84 struct snd_sof_dev *sdev = widget_to_sdev(w);
85
86 if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) {
87 struct snd_sof_widget *swidget = w->dobj.private;
88 struct snd_sof_dai *dai = swidget->private;
89 struct sof_ipc4_copier_data *copier_data;
90 struct sof_ipc4_copier *ipc4_copier;
91
92 ipc4_copier = dai->private;
93 ipc4_copier->dai_index = 0;
94 copier_data = &ipc4_copier->data;
95
96 /* clear the node ID */
97 copier_data->gtw_cfg.node_id &= ~SOF_IPC4_NODE_INDEX_MASK;
98 }
99
100 return 0;
101 }
102
103 struct sdw_intel_ops sdw_callback = {
104 .params_stream = sdw_params_stream,
105 .free_stream = sdw_params_free,
106 };
107
sdw_ace2x_params_stream(struct device * dev,struct sdw_intel_stream_params_data * params_data)108 static int sdw_ace2x_params_stream(struct device *dev,
109 struct sdw_intel_stream_params_data *params_data)
110 {
111 return sdw_hda_dai_hw_params(params_data->substream,
112 params_data->hw_params,
113 params_data->dai,
114 params_data->link_id,
115 params_data->alh_stream_id);
116 }
117
sdw_ace2x_free_stream(struct device * dev,struct sdw_intel_stream_free_data * free_data)118 static int sdw_ace2x_free_stream(struct device *dev,
119 struct sdw_intel_stream_free_data *free_data)
120 {
121 return sdw_hda_dai_hw_free(free_data->substream,
122 free_data->dai,
123 free_data->link_id);
124 }
125
sdw_ace2x_trigger(struct snd_pcm_substream * substream,int cmd,struct snd_soc_dai * dai)126 static int sdw_ace2x_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai)
127 {
128 return sdw_hda_dai_trigger(substream, cmd, dai);
129 }
130
131 static struct sdw_intel_ops sdw_ace2x_callback = {
132 .params_stream = sdw_ace2x_params_stream,
133 .free_stream = sdw_ace2x_free_stream,
134 .trigger = sdw_ace2x_trigger,
135 };
136
hda_sdw_acpi_scan(struct snd_sof_dev * sdev)137 static int hda_sdw_acpi_scan(struct snd_sof_dev *sdev)
138 {
139 u32 interface_mask = hda_get_interface_mask(sdev);
140 struct sof_intel_hda_dev *hdev;
141 acpi_handle handle;
142 int ret;
143
144 if (!(interface_mask & BIT(SOF_DAI_INTEL_ALH)))
145 return -EINVAL;
146
147 handle = ACPI_HANDLE(sdev->dev);
148
149 /* save ACPI info for the probe step */
150 hdev = sdev->pdata->hw_pdata;
151
152 ret = sdw_intel_acpi_scan(handle, &hdev->info);
153 if (ret < 0)
154 return -EINVAL;
155
156 return 0;
157 }
158
hda_sdw_probe(struct snd_sof_dev * sdev)159 static int hda_sdw_probe(struct snd_sof_dev *sdev)
160 {
161 const struct sof_intel_dsp_desc *chip;
162 struct sof_intel_hda_dev *hdev;
163 struct sdw_intel_res res;
164 void *sdw;
165
166 hdev = sdev->pdata->hw_pdata;
167
168 memset(&res, 0, sizeof(res));
169
170 chip = get_chip_info(sdev->pdata);
171 if (chip->hw_ip_version < SOF_INTEL_ACE_2_0) {
172 res.mmio_base = sdev->bar[HDA_DSP_BAR];
173 res.hw_ops = &sdw_intel_cnl_hw_ops;
174 res.shim_base = hdev->desc->sdw_shim_base;
175 res.alh_base = hdev->desc->sdw_alh_base;
176 res.ext = false;
177 res.ops = &sdw_callback;
178 } else {
179 /*
180 * retrieve eml_lock needed to protect shared registers
181 * in the HDaudio multi-link areas
182 */
183 res.eml_lock = hdac_bus_eml_get_mutex(sof_to_bus(sdev), true,
184 AZX_REG_ML_LEPTR_ID_SDW);
185 if (!res.eml_lock)
186 return -ENODEV;
187
188 res.mmio_base = sdev->bar[HDA_DSP_HDA_BAR];
189 /*
190 * the SHIM and SoundWire register offsets are link-specific
191 * and will be determined when adding auxiliary devices
192 */
193 res.hw_ops = &sdw_intel_lnl_hw_ops;
194 res.ext = true;
195 res.ops = &sdw_ace2x_callback;
196
197 /* ACE3+ supports microphone privacy */
198 if (chip->hw_ip_version >= SOF_INTEL_ACE_3_0)
199 res.mic_privacy = true;
200 }
201 res.irq = sdev->ipc_irq;
202 res.handle = hdev->info.handle;
203 res.parent = sdev->dev;
204
205 res.dev = sdev->dev;
206 res.clock_stop_quirks = sdw_clock_stop_quirks;
207 res.hbus = sof_to_bus(sdev);
208
209 /*
210 * ops and arg fields are not populated for now,
211 * they will be needed when the DAI callbacks are
212 * provided
213 */
214
215 /* we could filter links here if needed, e.g for quirks */
216 res.count = hdev->info.count;
217 res.link_mask = hdev->info.link_mask;
218
219 sdw = sdw_intel_probe(&res);
220 if (!sdw) {
221 dev_err(sdev->dev, "error: SoundWire probe failed\n");
222 return -EINVAL;
223 }
224
225 /* save context */
226 hdev->sdw = sdw;
227
228 return 0;
229 }
230
hda_sdw_startup(struct snd_sof_dev * sdev)231 int hda_sdw_startup(struct snd_sof_dev *sdev)
232 {
233 struct sof_intel_hda_dev *hdev;
234 struct snd_sof_pdata *pdata = sdev->pdata;
235 int ret;
236
237 hdev = sdev->pdata->hw_pdata;
238
239 if (!hdev->sdw)
240 return 0;
241
242 if (pdata->machine && !pdata->machine->mach_params.link_mask)
243 return 0;
244
245 ret = hda_sdw_check_lcount(sdev);
246 if (ret < 0)
247 return ret;
248
249 return sdw_intel_startup(hdev->sdw);
250 }
251 EXPORT_SYMBOL_NS(hda_sdw_startup, "SND_SOC_SOF_INTEL_HDA_GENERIC");
252
hda_sdw_exit(struct snd_sof_dev * sdev)253 static int hda_sdw_exit(struct snd_sof_dev *sdev)
254 {
255 struct sof_intel_hda_dev *hdev;
256
257 hdev = sdev->pdata->hw_pdata;
258
259 if (hdev->sdw)
260 sdw_intel_exit(hdev->sdw);
261 hdev->sdw = NULL;
262
263 hda_sdw_int_enable(sdev, false);
264
265 return 0;
266 }
267
hda_common_check_sdw_irq(struct snd_sof_dev * sdev)268 bool hda_common_check_sdw_irq(struct snd_sof_dev *sdev)
269 {
270 struct sof_intel_hda_dev *hdev;
271 bool ret = false;
272 u32 irq_status;
273
274 hdev = sdev->pdata->hw_pdata;
275
276 if (!hdev->sdw)
277 return ret;
278
279 /* store status */
280 irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIS2);
281
282 /* invalid message ? */
283 if (irq_status == 0xffffffff)
284 goto out;
285
286 /* SDW message ? */
287 if (irq_status & HDA_DSP_REG_ADSPIS2_SNDW)
288 ret = true;
289
290 out:
291 return ret;
292 }
293 EXPORT_SYMBOL_NS(hda_common_check_sdw_irq, "SND_SOC_SOF_INTEL_HDA_GENERIC");
294
hda_dsp_check_sdw_irq(struct snd_sof_dev * sdev)295 static bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
296 {
297 u32 interface_mask = hda_get_interface_mask(sdev);
298 const struct sof_intel_dsp_desc *chip;
299
300 if (!(interface_mask & BIT(SOF_DAI_INTEL_ALH)))
301 return false;
302
303 chip = get_chip_info(sdev->pdata);
304 if (chip && chip->check_sdw_irq)
305 return chip->check_sdw_irq(sdev);
306
307 return false;
308 }
309
hda_dsp_sdw_thread(int irq,void * context)310 static irqreturn_t hda_dsp_sdw_thread(int irq, void *context)
311 {
312 return sdw_intel_thread(irq, context);
313 }
314
hda_sdw_check_wakeen_irq_common(struct snd_sof_dev * sdev)315 bool hda_sdw_check_wakeen_irq_common(struct snd_sof_dev *sdev)
316 {
317 struct sof_intel_hda_dev *hdev;
318
319 hdev = sdev->pdata->hw_pdata;
320 if (hdev->sdw &&
321 snd_sof_dsp_read(sdev, HDA_DSP_BAR,
322 hdev->desc->sdw_shim_base + SDW_SHIM_WAKESTS))
323 return true;
324
325 return false;
326 }
327 EXPORT_SYMBOL_NS(hda_sdw_check_wakeen_irq_common, "SND_SOC_SOF_INTEL_HDA_GENERIC");
328
hda_sdw_check_wakeen_irq(struct snd_sof_dev * sdev)329 static bool hda_sdw_check_wakeen_irq(struct snd_sof_dev *sdev)
330 {
331 u32 interface_mask = hda_get_interface_mask(sdev);
332 const struct sof_intel_dsp_desc *chip;
333
334 if (!(interface_mask & BIT(SOF_DAI_INTEL_ALH)))
335 return false;
336
337 chip = get_chip_info(sdev->pdata);
338 if (chip && chip->check_sdw_wakeen_irq)
339 return chip->check_sdw_wakeen_irq(sdev);
340
341 return false;
342 }
343
hda_sdw_process_wakeen_common(struct snd_sof_dev * sdev)344 void hda_sdw_process_wakeen_common(struct snd_sof_dev *sdev)
345 {
346 u32 interface_mask = hda_get_interface_mask(sdev);
347 struct sof_intel_hda_dev *hdev;
348
349 if (!(interface_mask & BIT(SOF_DAI_INTEL_ALH)))
350 return;
351
352 hdev = sdev->pdata->hw_pdata;
353 if (!hdev->sdw)
354 return;
355
356 sdw_intel_process_wakeen_event(hdev->sdw);
357 }
358 EXPORT_SYMBOL_NS(hda_sdw_process_wakeen_common, "SND_SOC_SOF_INTEL_HDA_GENERIC");
359
hda_dsp_sdw_check_mic_privacy_irq(struct snd_sof_dev * sdev)360 static bool hda_dsp_sdw_check_mic_privacy_irq(struct snd_sof_dev *sdev)
361 {
362 const struct sof_intel_dsp_desc *chip;
363
364 chip = get_chip_info(sdev->pdata);
365 if (chip && chip->check_mic_privacy_irq)
366 return chip->check_mic_privacy_irq(sdev, true,
367 AZX_REG_ML_LEPTR_ID_SDW);
368
369 return false;
370 }
371
hda_dsp_sdw_process_mic_privacy(struct snd_sof_dev * sdev)372 static void hda_dsp_sdw_process_mic_privacy(struct snd_sof_dev *sdev)
373 {
374 const struct sof_intel_dsp_desc *chip;
375
376 chip = get_chip_info(sdev->pdata);
377 if (chip && chip->process_mic_privacy)
378 chip->process_mic_privacy(sdev, true, AZX_REG_ML_LEPTR_ID_SDW);
379 }
380
381 #else /* IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) */
hda_sdw_acpi_scan(struct snd_sof_dev * sdev)382 static inline int hda_sdw_acpi_scan(struct snd_sof_dev *sdev)
383 {
384 return 0;
385 }
386
hda_sdw_probe(struct snd_sof_dev * sdev)387 static inline int hda_sdw_probe(struct snd_sof_dev *sdev)
388 {
389 return 0;
390 }
391
hda_sdw_exit(struct snd_sof_dev * sdev)392 static inline int hda_sdw_exit(struct snd_sof_dev *sdev)
393 {
394 return 0;
395 }
396
hda_dsp_check_sdw_irq(struct snd_sof_dev * sdev)397 static inline bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
398 {
399 return false;
400 }
401
hda_dsp_sdw_thread(int irq,void * context)402 static inline irqreturn_t hda_dsp_sdw_thread(int irq, void *context)
403 {
404 return IRQ_HANDLED;
405 }
406
hda_sdw_check_wakeen_irq(struct snd_sof_dev * sdev)407 static inline bool hda_sdw_check_wakeen_irq(struct snd_sof_dev *sdev)
408 {
409 return false;
410 }
411
hda_dsp_sdw_check_mic_privacy_irq(struct snd_sof_dev * sdev)412 static inline bool hda_dsp_sdw_check_mic_privacy_irq(struct snd_sof_dev *sdev)
413 {
414 return false;
415 }
416
hda_dsp_sdw_process_mic_privacy(struct snd_sof_dev * sdev)417 static inline void hda_dsp_sdw_process_mic_privacy(struct snd_sof_dev *sdev) { }
418
419 #endif /* IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) */
420
421 /* pre fw run operations */
hda_dsp_pre_fw_run(struct snd_sof_dev * sdev)422 int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev)
423 {
424 /* disable clock gating and power gating */
425 return hda_dsp_ctrl_clock_power_gating(sdev, false);
426 }
427
428 /* post fw run operations */
hda_dsp_post_fw_run(struct snd_sof_dev * sdev)429 int hda_dsp_post_fw_run(struct snd_sof_dev *sdev)
430 {
431 int ret;
432
433 if (sdev->first_boot) {
434 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
435
436 ret = hda_sdw_startup(sdev);
437 if (ret < 0) {
438 dev_err(sdev->dev,
439 "error: could not startup SoundWire links\n");
440 return ret;
441 }
442
443 /* Check if IMR boot is usable */
444 if (!sof_debug_check_flag(SOF_DBG_IGNORE_D3_PERSISTENT) &&
445 (sdev->fw_ready.flags & SOF_IPC_INFO_D3_PERSISTENT ||
446 sdev->pdata->ipc_type == SOF_IPC_TYPE_4)) {
447 hdev->imrboot_supported = true;
448 debugfs_create_bool("skip_imr_boot",
449 0644, sdev->debugfs_root,
450 &hdev->skip_imr_boot);
451 }
452 }
453
454 hda_sdw_int_enable(sdev, true);
455
456 /* re-enable clock gating and power gating */
457 return hda_dsp_ctrl_clock_power_gating(sdev, true);
458 }
459 EXPORT_SYMBOL_NS(hda_dsp_post_fw_run, "SND_SOC_SOF_INTEL_HDA_GENERIC");
460
461 /*
462 * Debug
463 */
464
465 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG)
466 static bool hda_use_msi = true;
467 module_param_named(use_msi, hda_use_msi, bool, 0444);
468 MODULE_PARM_DESC(use_msi, "SOF HDA use PCI MSI mode");
469 #else
470 #define hda_use_msi (1)
471 #endif
472
473 static char *hda_model;
474 module_param(hda_model, charp, 0444);
475 MODULE_PARM_DESC(hda_model, "Use the given HDA board model.");
476
477 static int dmic_num_override = -1;
478 module_param_named(dmic_num, dmic_num_override, int, 0444);
479 MODULE_PARM_DESC(dmic_num, "SOF HDA DMIC number");
480
481 static int mclk_id_override = -1;
482 module_param_named(mclk_id, mclk_id_override, int, 0444);
483 MODULE_PARM_DESC(mclk_id, "SOF SSP mclk_id");
484
485 static int bt_link_mask_override = -1;
486 module_param_named(bt_link_mask, bt_link_mask_override, int, 0444);
487 MODULE_PARM_DESC(bt_link_mask, "SOF BT offload link mask");
488
hda_init(struct snd_sof_dev * sdev)489 static int hda_init(struct snd_sof_dev *sdev)
490 {
491 struct hda_bus *hbus;
492 struct hdac_bus *bus;
493 struct pci_dev *pci = to_pci_dev(sdev->dev);
494 int ret;
495
496 hbus = sof_to_hbus(sdev);
497 bus = sof_to_bus(sdev);
498
499 /* HDA bus init */
500 sof_hda_bus_init(sdev, &pci->dev);
501
502 if (sof_hda_position_quirk == SOF_HDA_POSITION_QUIRK_USE_DPIB_REGISTERS)
503 bus->use_posbuf = 0;
504 else
505 bus->use_posbuf = 1;
506 bus->bdl_pos_adj = 0;
507 bus->sync_write = 1;
508
509 mutex_init(&hbus->prepare_mutex);
510 hbus->pci = pci;
511 hbus->mixer_assigned = -1;
512 hbus->modelname = hda_model;
513
514 /* initialise hdac bus */
515 bus->addr = pci_resource_start(pci, 0);
516 bus->remap_addr = pci_ioremap_bar(pci, 0);
517 if (!bus->remap_addr) {
518 dev_err(bus->dev, "error: ioremap error\n");
519 return -ENXIO;
520 }
521
522 /* HDA base */
523 sdev->bar[HDA_DSP_HDA_BAR] = bus->remap_addr;
524
525 /* init i915 and HDMI codecs */
526 ret = hda_codec_i915_init(sdev);
527 if (ret < 0 && ret != -ENODEV) {
528 dev_err_probe(sdev->dev, ret, "init of i915 and HDMI codec failed\n");
529 goto out;
530 }
531
532 /* get controller capabilities */
533 ret = hda_dsp_ctrl_get_caps(sdev);
534 if (ret < 0) {
535 dev_err(sdev->dev, "error: get caps error\n");
536 hda_codec_i915_exit(sdev);
537 }
538
539 out:
540 if (ret < 0)
541 iounmap(sof_to_bus(sdev)->remap_addr);
542
543 return ret;
544 }
545
check_dmic_num(struct snd_sof_dev * sdev)546 static int check_dmic_num(struct snd_sof_dev *sdev)
547 {
548 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
549 struct nhlt_acpi_table *nhlt;
550 int dmic_num = 0;
551
552 nhlt = hdev->nhlt;
553 if (nhlt)
554 dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt);
555
556 dev_info(sdev->dev, "DMICs detected in NHLT tables: %d\n", dmic_num);
557
558 /* allow for module parameter override */
559 if (dmic_num_override != -1) {
560 dev_dbg(sdev->dev,
561 "overriding DMICs detected in NHLT tables %d by kernel param %d\n",
562 dmic_num, dmic_num_override);
563 dmic_num = dmic_num_override;
564 }
565
566 if (dmic_num < 0 || dmic_num > 4) {
567 dev_dbg(sdev->dev, "invalid dmic_number %d\n", dmic_num);
568 dmic_num = 0;
569 }
570
571 return dmic_num;
572 }
573
check_nhlt_ssp_mask(struct snd_sof_dev * sdev,u8 device_type)574 static int check_nhlt_ssp_mask(struct snd_sof_dev *sdev, u8 device_type)
575 {
576 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
577 struct nhlt_acpi_table *nhlt;
578 int ssp_mask = 0;
579
580 nhlt = hdev->nhlt;
581 if (!nhlt)
582 return ssp_mask;
583
584 if (intel_nhlt_has_endpoint_type(nhlt, NHLT_LINK_SSP)) {
585 ssp_mask = intel_nhlt_ssp_endpoint_mask(nhlt, device_type);
586 if (ssp_mask)
587 dev_info(sdev->dev, "NHLT device %s(%d) detected, ssp_mask %#x\n",
588 device_type == NHLT_DEVICE_BT ? "BT" : "I2S",
589 device_type, ssp_mask);
590 }
591
592 return ssp_mask;
593 }
594
check_nhlt_ssp_mclk_mask(struct snd_sof_dev * sdev,int ssp_num)595 static int check_nhlt_ssp_mclk_mask(struct snd_sof_dev *sdev, int ssp_num)
596 {
597 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
598 struct nhlt_acpi_table *nhlt;
599
600 nhlt = hdev->nhlt;
601 if (!nhlt)
602 return 0;
603
604 return intel_nhlt_ssp_mclk_mask(nhlt, ssp_num);
605 }
606
hda_init_caps(struct snd_sof_dev * sdev)607 static int hda_init_caps(struct snd_sof_dev *sdev)
608 {
609 u32 interface_mask = hda_get_interface_mask(sdev);
610 struct hdac_bus *bus = sof_to_bus(sdev);
611 struct snd_sof_pdata *pdata = sdev->pdata;
612 struct sof_intel_hda_dev *hdev = pdata->hw_pdata;
613 u32 link_mask;
614 int ret = 0;
615
616 /* check if dsp is there */
617 if (bus->ppcap)
618 dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n");
619
620 /* Init HDA controller after i915 init */
621 ret = hda_dsp_ctrl_init_chip(sdev, true);
622 if (ret < 0) {
623 dev_err(bus->dev, "error: init chip failed with ret: %d\n",
624 ret);
625 return ret;
626 }
627
628 hda_bus_ml_init(bus);
629
630 /* Skip SoundWire if it is not supported */
631 if (!(interface_mask & BIT(SOF_DAI_INTEL_ALH)))
632 goto skip_soundwire;
633
634 /* Skip SoundWire in nocodec mode */
635 if (IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT) &&
636 sof_debug_check_flag(SOF_DBG_FORCE_NOCODEC))
637 goto skip_soundwire;
638
639 /* scan SoundWire capabilities exposed by DSDT */
640 ret = hda_sdw_acpi_scan(sdev);
641 if (ret < 0) {
642 dev_dbg(sdev->dev, "skipping SoundWire, not detected with ACPI scan\n");
643 goto skip_soundwire;
644 }
645
646 link_mask = hdev->info.link_mask;
647 if (!link_mask) {
648 dev_dbg(sdev->dev, "skipping SoundWire, no links enabled\n");
649 goto skip_soundwire;
650 }
651
652 /*
653 * probe/allocate SoundWire resources.
654 * The hardware configuration takes place in hda_sdw_startup
655 * after power rails are enabled.
656 * It's entirely possible to have a mix of I2S/DMIC/SoundWire
657 * devices, so we allocate the resources in all cases.
658 */
659 ret = hda_sdw_probe(sdev);
660 if (ret < 0) {
661 dev_err(sdev->dev, "error: SoundWire probe error\n");
662 return ret;
663 }
664
665 skip_soundwire:
666
667 /* create codec instances */
668 hda_codec_probe_bus(sdev);
669
670 if (!HDA_IDISP_CODEC(bus->codec_mask))
671 hda_codec_i915_display_power(sdev, false);
672
673 hda_bus_ml_put_all(bus);
674
675 return 0;
676 }
677
hda_dsp_interrupt_handler(int irq,void * context)678 static irqreturn_t hda_dsp_interrupt_handler(int irq, void *context)
679 {
680 struct snd_sof_dev *sdev = context;
681
682 /*
683 * Get global interrupt status. It includes all hardware interrupt
684 * sources in the Intel HD Audio controller.
685 */
686 if (snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS) &
687 SOF_HDA_INTSTS_GIS) {
688
689 /* disable GIE interrupt */
690 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
691 SOF_HDA_INTCTL,
692 SOF_HDA_INT_GLOBAL_EN,
693 0);
694
695 return IRQ_WAKE_THREAD;
696 }
697
698 return IRQ_NONE;
699 }
700
hda_dsp_interrupt_thread(int irq,void * context)701 static irqreturn_t hda_dsp_interrupt_thread(int irq, void *context)
702 {
703 struct snd_sof_dev *sdev = context;
704 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
705
706 /* deal with streams and controller first */
707 if (hda_dsp_check_stream_irq(sdev)) {
708 trace_sof_intel_hda_irq(sdev, "stream");
709 hda_dsp_stream_threaded_handler(irq, sdev);
710 }
711
712 if (hda_check_ipc_irq(sdev)) {
713 trace_sof_intel_hda_irq(sdev, "ipc");
714 sof_ops(sdev)->irq_thread(irq, sdev);
715 }
716
717 if (hda_dsp_check_sdw_irq(sdev)) {
718 trace_sof_intel_hda_irq(sdev, "sdw");
719
720 hda_dsp_sdw_thread(irq, hdev->sdw);
721
722 if (hda_dsp_sdw_check_mic_privacy_irq(sdev)) {
723 trace_sof_intel_hda_irq(sdev, "mic privacy");
724 hda_dsp_sdw_process_mic_privacy(sdev);
725 }
726 }
727
728 if (hda_sdw_check_wakeen_irq(sdev)) {
729 trace_sof_intel_hda_irq(sdev, "wakeen");
730 hda_sdw_process_wakeen(sdev);
731 }
732
733 hda_codec_check_for_state_change(sdev);
734
735 /* enable GIE interrupt */
736 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
737 SOF_HDA_INTCTL,
738 SOF_HDA_INT_GLOBAL_EN,
739 SOF_HDA_INT_GLOBAL_EN);
740
741 return IRQ_HANDLED;
742 }
743
hda_dsp_probe_early(struct snd_sof_dev * sdev)744 int hda_dsp_probe_early(struct snd_sof_dev *sdev)
745 {
746 struct pci_dev *pci = to_pci_dev(sdev->dev);
747 struct sof_intel_hda_dev *hdev;
748 const struct sof_intel_dsp_desc *chip;
749 int ret = 0;
750
751 if (!sdev->dspless_mode_selected) {
752 /*
753 * detect DSP by checking class/subclass/prog-id information
754 * class=04 subclass 03 prog-if 00: no DSP, legacy driver is required
755 * class=04 subclass 01 prog-if 00: DSP is present
756 * (and may be required e.g. for DMIC or SSP support)
757 * class=04 subclass 03 prog-if 80: either of DSP or legacy mode works
758 */
759 if (pci->class == 0x040300) {
760 dev_err(sdev->dev, "the DSP is not enabled on this platform, aborting probe\n");
761 return -ENODEV;
762 } else if (pci->class != 0x040100 && pci->class != 0x040380) {
763 dev_err(sdev->dev, "unknown PCI class/subclass/prog-if 0x%06x found, aborting probe\n",
764 pci->class);
765 return -ENODEV;
766 }
767 dev_info_once(sdev->dev, "DSP detected with PCI class/subclass/prog-if 0x%06x\n",
768 pci->class);
769 }
770
771 chip = get_chip_info(sdev->pdata);
772 if (!chip) {
773 dev_err(sdev->dev, "error: no such device supported, chip id:%x\n",
774 pci->device);
775 ret = -EIO;
776 goto err;
777 }
778
779 sdev->num_cores = chip->cores_num;
780
781 hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL);
782 if (!hdev)
783 return -ENOMEM;
784 sdev->pdata->hw_pdata = hdev;
785 hdev->desc = chip;
786 ret = hda_init(sdev);
787
788 err:
789 return ret;
790 }
791 EXPORT_SYMBOL_NS(hda_dsp_probe_early, "SND_SOC_SOF_INTEL_HDA_GENERIC");
792
hda_dsp_probe(struct snd_sof_dev * sdev)793 int hda_dsp_probe(struct snd_sof_dev *sdev)
794 {
795 struct pci_dev *pci = to_pci_dev(sdev->dev);
796 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
797 const struct sof_intel_dsp_desc *chip;
798 int ret = 0;
799
800 hdev->dmic_dev = platform_device_register_data(sdev->dev, "dmic-codec",
801 PLATFORM_DEVID_NONE,
802 NULL, 0);
803 if (IS_ERR(hdev->dmic_dev)) {
804 dev_err(sdev->dev, "error: failed to create DMIC device\n");
805 return PTR_ERR(hdev->dmic_dev);
806 }
807
808 /*
809 * use position update IPC if either it is forced
810 * or we don't have other choice
811 */
812 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_FORCE_IPC_POSITION)
813 hdev->no_ipc_position = 0;
814 #else
815 hdev->no_ipc_position = sof_ops(sdev)->pcm_pointer ? 1 : 0;
816 #endif
817
818 if (sdev->dspless_mode_selected)
819 hdev->no_ipc_position = 1;
820
821 if (sdev->dspless_mode_selected)
822 goto skip_dsp_setup;
823
824 /* DSP base */
825 sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR);
826 if (!sdev->bar[HDA_DSP_BAR]) {
827 dev_err(sdev->dev, "error: ioremap error\n");
828 ret = -ENXIO;
829 goto hdac_bus_unmap;
830 }
831
832 sdev->mmio_bar = HDA_DSP_BAR;
833 sdev->mailbox_bar = HDA_DSP_BAR;
834 skip_dsp_setup:
835
836 /* allow 64bit DMA address if supported by H/W */
837 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64))) {
838 dev_dbg(sdev->dev, "DMA mask is 32 bit\n");
839 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
840 }
841 dma_set_max_seg_size(&pci->dev, UINT_MAX);
842
843 /* init streams */
844 ret = hda_dsp_stream_init(sdev);
845 if (ret < 0) {
846 dev_err(sdev->dev, "error: failed to init streams\n");
847 /*
848 * not all errors are due to memory issues, but trying
849 * to free everything does not harm
850 */
851 goto free_streams;
852 }
853
854 /*
855 * register our IRQ
856 * let's try to enable msi firstly
857 * if it fails, use legacy interrupt mode
858 * TODO: support msi multiple vectors
859 */
860 if (hda_use_msi && pci_alloc_irq_vectors(pci, 1, 1, PCI_IRQ_MSI) > 0) {
861 dev_info(sdev->dev, "use msi interrupt mode\n");
862 sdev->ipc_irq = pci_irq_vector(pci, 0);
863 /* initialised to "false" by kzalloc() */
864 sdev->msi_enabled = true;
865 }
866
867 if (!sdev->msi_enabled) {
868 dev_info(sdev->dev, "use legacy interrupt mode\n");
869 /*
870 * in IO-APIC mode, hda->irq and ipc_irq are using the same
871 * irq number of pci->irq
872 */
873 sdev->ipc_irq = pci->irq;
874 }
875
876 dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq);
877 ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler,
878 hda_dsp_interrupt_thread,
879 IRQF_SHARED, "AudioDSP", sdev);
880 if (ret < 0) {
881 dev_err(sdev->dev, "error: failed to register IPC IRQ %d\n",
882 sdev->ipc_irq);
883 goto free_irq_vector;
884 }
885
886 pci_set_master(pci);
887 synchronize_irq(pci->irq);
888
889 /*
890 * clear TCSEL to clear playback on some HD Audio
891 * codecs. PCI TCSEL is defined in the Intel manuals.
892 */
893 snd_sof_pci_update_bits(sdev, PCI_TCSEL, 0x07, 0);
894
895 /* init HDA capabilities */
896 ret = hda_init_caps(sdev);
897 if (ret < 0)
898 goto free_ipc_irq;
899
900 if (!sdev->dspless_mode_selected) {
901 /* enable ppcap interrupt */
902 hda_dsp_ctrl_ppcap_enable(sdev, true);
903 hda_dsp_ctrl_ppcap_int_enable(sdev, true);
904
905 /* set default mailbox offset for FW ready message */
906 sdev->dsp_box.offset = HDA_DSP_MBOX_UPLINK_OFFSET;
907
908 INIT_DELAYED_WORK(&hdev->d0i3_work, hda_dsp_d0i3_work);
909 }
910
911 chip = get_chip_info(sdev->pdata);
912 if (chip && chip->hw_ip_version >= SOF_INTEL_ACE_2_0) {
913 ret = hda_sdw_startup(sdev);
914 if (ret < 0) {
915 dev_err(sdev->dev, "could not startup SoundWire links\n");
916 goto disable_pp_cap;
917 }
918 }
919
920 init_waitqueue_head(&hdev->waitq);
921
922 hdev->nhlt = intel_nhlt_init(sdev->dev);
923
924 return 0;
925
926 disable_pp_cap:
927 if (!sdev->dspless_mode_selected) {
928 hda_dsp_ctrl_ppcap_int_enable(sdev, false);
929 hda_dsp_ctrl_ppcap_enable(sdev, false);
930 }
931 free_ipc_irq:
932 free_irq(sdev->ipc_irq, sdev);
933 free_irq_vector:
934 if (sdev->msi_enabled)
935 pci_free_irq_vectors(pci);
936 free_streams:
937 hda_dsp_stream_free(sdev);
938 /* dsp_unmap: not currently used */
939 if (!sdev->dspless_mode_selected)
940 iounmap(sdev->bar[HDA_DSP_BAR]);
941 hdac_bus_unmap:
942 platform_device_unregister(hdev->dmic_dev);
943
944 return ret;
945 }
946 EXPORT_SYMBOL_NS(hda_dsp_probe, "SND_SOC_SOF_INTEL_HDA_GENERIC");
947
hda_dsp_remove(struct snd_sof_dev * sdev)948 void hda_dsp_remove(struct snd_sof_dev *sdev)
949 {
950 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
951 const struct sof_intel_dsp_desc *chip = hda->desc;
952 struct pci_dev *pci = to_pci_dev(sdev->dev);
953 struct nhlt_acpi_table *nhlt = hda->nhlt;
954
955 if (nhlt)
956 intel_nhlt_free(nhlt);
957
958 if (!sdev->dspless_mode_selected)
959 /* cancel any attempt for DSP D0I3 */
960 cancel_delayed_work_sync(&hda->d0i3_work);
961
962 hda_codec_device_remove(sdev);
963
964 hda_sdw_exit(sdev);
965
966 if (!IS_ERR_OR_NULL(hda->dmic_dev))
967 platform_device_unregister(hda->dmic_dev);
968
969 if (!sdev->dspless_mode_selected) {
970 /* disable DSP IRQ */
971 hda_dsp_ctrl_ppcap_int_enable(sdev, false);
972 }
973
974 /* disable CIE and GIE interrupts */
975 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL,
976 SOF_HDA_INT_CTRL_EN | SOF_HDA_INT_GLOBAL_EN, 0);
977
978 if (sdev->dspless_mode_selected)
979 goto skip_disable_dsp;
980
981 /* Cancel the microphone privacy work if mic privacy is active */
982 if (hda->mic_privacy.active)
983 cancel_work_sync(&hda->mic_privacy.work);
984
985 /* no need to check for error as the DSP will be disabled anyway */
986 if (chip && chip->power_down_dsp)
987 chip->power_down_dsp(sdev);
988
989 /* disable DSP */
990 hda_dsp_ctrl_ppcap_enable(sdev, false);
991
992 /* Free the persistent DMA buffers used for base firmware download */
993 if (hda->cl_dmab.area)
994 snd_dma_free_pages(&hda->cl_dmab);
995 if (hda->iccmax_dmab.area)
996 snd_dma_free_pages(&hda->iccmax_dmab);
997
998 skip_disable_dsp:
999 free_irq(sdev->ipc_irq, sdev);
1000 if (sdev->msi_enabled)
1001 pci_free_irq_vectors(pci);
1002
1003 hda_dsp_stream_free(sdev);
1004
1005 hda_bus_ml_free(sof_to_bus(sdev));
1006
1007 if (!sdev->dspless_mode_selected)
1008 iounmap(sdev->bar[HDA_DSP_BAR]);
1009 }
1010 EXPORT_SYMBOL_NS(hda_dsp_remove, "SND_SOC_SOF_INTEL_HDA_GENERIC");
1011
hda_dsp_remove_late(struct snd_sof_dev * sdev)1012 void hda_dsp_remove_late(struct snd_sof_dev *sdev)
1013 {
1014 iounmap(sof_to_bus(sdev)->remap_addr);
1015 sof_hda_bus_exit(sdev);
1016 hda_codec_i915_exit(sdev);
1017 }
1018
hda_power_down_dsp(struct snd_sof_dev * sdev)1019 int hda_power_down_dsp(struct snd_sof_dev *sdev)
1020 {
1021 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
1022 const struct sof_intel_dsp_desc *chip = hda->desc;
1023
1024 return hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask);
1025 }
1026 EXPORT_SYMBOL_NS(hda_power_down_dsp, "SND_SOC_SOF_INTEL_HDA_GENERIC");
1027
1028 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
hda_generic_machine_select(struct snd_sof_dev * sdev,struct snd_soc_acpi_mach ** mach)1029 static void hda_generic_machine_select(struct snd_sof_dev *sdev,
1030 struct snd_soc_acpi_mach **mach)
1031 {
1032 struct hdac_bus *bus = sof_to_bus(sdev);
1033 struct snd_soc_acpi_mach_params *mach_params;
1034 struct snd_soc_acpi_mach *hda_mach;
1035 struct snd_sof_pdata *pdata = sdev->pdata;
1036 const char *tplg_filename;
1037 int codec_num = 0;
1038 int i;
1039
1040 /* codec detection */
1041 if (!bus->codec_mask) {
1042 dev_info(bus->dev, "no hda codecs found!\n");
1043 } else {
1044 dev_info(bus->dev, "hda codecs found, mask %lx\n",
1045 bus->codec_mask);
1046
1047 for (i = 0; i < HDA_MAX_CODECS; i++) {
1048 if (bus->codec_mask & (1 << i))
1049 codec_num++;
1050 }
1051
1052 /*
1053 * If no machine driver is found, then:
1054 *
1055 * generic hda machine driver can handle:
1056 * - one HDMI codec, and/or
1057 * - one external HDAudio codec
1058 */
1059 if (!*mach && codec_num <= 2) {
1060 bool tplg_fixup = false;
1061
1062 /*
1063 * make a local copy of the match array since we might
1064 * be modifying it
1065 */
1066 hda_mach = devm_kmemdup_array(sdev->dev,
1067 snd_soc_acpi_intel_hda_machines,
1068 2, /* we have one entry + sentinel in the array */
1069 sizeof(snd_soc_acpi_intel_hda_machines[0]),
1070 GFP_KERNEL);
1071 if (!hda_mach) {
1072 dev_err(bus->dev,
1073 "%s: failed to duplicate the HDA match table\n",
1074 __func__);
1075 return;
1076 }
1077
1078 dev_info(bus->dev, "using HDA machine driver %s now\n",
1079 hda_mach->drv_name);
1080
1081 /*
1082 * topology: use the info from hda_machines since tplg file name
1083 * is not overwritten
1084 */
1085 if (!pdata->tplg_filename)
1086 tplg_fixup = true;
1087
1088 if (tplg_fixup &&
1089 codec_num == 1 && HDA_IDISP_CODEC(bus->codec_mask)) {
1090 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1091 "%s-idisp",
1092 hda_mach->sof_tplg_filename);
1093 if (!tplg_filename)
1094 return;
1095
1096 hda_mach->sof_tplg_filename = tplg_filename;
1097 }
1098
1099 if (codec_num == 2 ||
1100 (codec_num == 1 && !HDA_IDISP_CODEC(bus->codec_mask))) {
1101 /*
1102 * Prevent SoundWire links from starting when an external
1103 * HDaudio codec is used
1104 */
1105 hda_mach->mach_params.link_mask = 0;
1106 } else {
1107 /*
1108 * Allow SoundWire links to start when no external HDaudio codec
1109 * was detected. This will not create a SoundWire card but
1110 * will help detect if any SoundWire codec reports as ATTACHED.
1111 */
1112 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
1113
1114 hda_mach->mach_params.link_mask = hdev->info.link_mask;
1115 }
1116
1117 *mach = hda_mach;
1118 }
1119 }
1120
1121 /* used by hda machine driver to create dai links */
1122 if (*mach) {
1123 mach_params = &(*mach)->mach_params;
1124 mach_params->codec_mask = bus->codec_mask;
1125 }
1126 }
1127 #else
hda_generic_machine_select(struct snd_sof_dev * sdev,struct snd_soc_acpi_mach ** mach)1128 static void hda_generic_machine_select(struct snd_sof_dev *sdev,
1129 struct snd_soc_acpi_mach **mach)
1130 {
1131 }
1132 #endif
1133
1134 #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
1135
is_endpoint_present(struct sdw_slave * sdw_device,struct asoc_sdw_codec_info * dai_info,int dai_type)1136 static bool is_endpoint_present(struct sdw_slave *sdw_device,
1137 struct asoc_sdw_codec_info *dai_info, int dai_type)
1138 {
1139 int i;
1140
1141 /* If SDCA is not present, assume the endpoint is present */
1142 if (!sdw_device->sdca_data.interface_revision) {
1143 dev_warn(&sdw_device->dev, "SDCA properties not found in BIOS\n");
1144 return true;
1145 }
1146
1147 for (i = 0; i < sdw_device->sdca_data.num_functions; i++) {
1148 if (dai_type == dai_info->dais[i].dai_type)
1149 return true;
1150 }
1151 dev_dbg(&sdw_device->dev, "Endpoint DAI type %d not found\n", dai_type);
1152 return false;
1153 }
1154
find_acpi_adr_device(struct device * dev,struct sdw_slave * sdw_device,struct snd_soc_acpi_link_adr * link,int * amp_index)1155 static struct snd_soc_acpi_adr_device *find_acpi_adr_device(struct device *dev,
1156 struct sdw_slave *sdw_device,
1157 struct snd_soc_acpi_link_adr *link,
1158 int *amp_index)
1159 {
1160 struct snd_soc_acpi_adr_device *adr_dev;
1161 const char *name_prefix = "";
1162 int index = link->num_adr;
1163 bool is_amp = true; /* Set it to false if the codec wiah any NON-AMP DAI type */
1164 int ep_index = 0;
1165 int i, j;
1166
1167 link->mask = BIT(sdw_device->bus->link_id);
1168 /* index is 0 based, we need allocate index + 1 for the array size */
1169 if (!index)
1170 adr_dev = devm_kzalloc(dev, sizeof(*adr_dev), GFP_KERNEL);
1171 else
1172 adr_dev = devm_krealloc(dev, (struct snd_soc_acpi_adr_device *)link->adr_d,
1173 (index + 1) * sizeof(*adr_dev), GFP_KERNEL);
1174
1175 if (!adr_dev)
1176 return NULL;
1177
1178 for (i = 0; i < asoc_sdw_get_codec_info_list_count(); i++) {
1179 struct snd_soc_acpi_endpoint *endpoints;
1180 int amp_group_id = 1;
1181
1182 if (sdw_device->id.part_id != codec_info_list[i].part_id)
1183 continue;
1184
1185 endpoints = devm_kcalloc(dev, codec_info_list[i].dai_num,
1186 sizeof(struct snd_soc_acpi_endpoint), GFP_KERNEL);
1187 if (!endpoints)
1188 return NULL;
1189
1190 name_prefix = codec_info_list[i].name_prefix;
1191 /*
1192 * This should not happen, but add a paranoid check to avoid NULL pointer
1193 * dereference
1194 */
1195 if (!name_prefix) {
1196 dev_err(dev, "codec_info_list name_prefix of part id %#x is missing\n",
1197 codec_info_list[i].part_id);
1198 return NULL;
1199 }
1200 for (j = 0; j < codec_info_list[i].dai_num; j++) {
1201 /* Check if the endpoint is present by the SDCA DisCo table */
1202 if (!is_endpoint_present(sdw_device, &codec_info_list[i],
1203 codec_info_list[i].dais[j].dai_type))
1204 continue;
1205
1206 endpoints[ep_index].num = ep_index;
1207 if (codec_info_list[i].dais[j].dai_type == SOC_SDW_DAI_TYPE_AMP) {
1208 /* Assume all amp are aggregated */
1209 endpoints[ep_index].aggregated = 1;
1210 endpoints[ep_index].group_id = amp_group_id;
1211 endpoints[ep_index].group_position = *amp_index;
1212 /* Set group id = 2 for feedback capture endpoint */
1213 amp_group_id++;
1214 } else {
1215 endpoints[ep_index].aggregated = 0;
1216 endpoints[ep_index].group_id = 0;
1217 endpoints[ep_index].group_position = 0;
1218 is_amp = false;
1219 }
1220 ep_index++;
1221 }
1222 adr_dev[index].endpoints = endpoints;
1223 adr_dev[index].num_endpoints = ep_index;
1224 break;
1225 }
1226
1227 if (i == asoc_sdw_get_codec_info_list_count()) {
1228 dev_err(dev, "part id %#x is not supported\n", sdw_device->id.part_id);
1229 return NULL;
1230 }
1231
1232 adr_dev[index].adr = ((u64)sdw_device->id.class_id & 0xFF) |
1233 ((u64)sdw_device->id.part_id & 0xFFFF) << 8 |
1234 ((u64)sdw_device->id.mfg_id & 0xFFFF) << 24 |
1235 ((u64)(sdw_device->id.unique_id & 0xF) << 40) |
1236 ((u64)(sdw_device->id.sdw_version & 0xF) << 44) |
1237 ((u64)(sdw_device->bus->link_id & 0xF) << 48);
1238
1239 if (!is_amp) {
1240 /* For non-amp codecs, get name_prefix from codec_info_list[] */
1241 adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s", name_prefix);
1242 goto done_name_prefix;
1243 }
1244
1245 /*
1246 * The name_prefix comes from codec_info_list which has a name_prefix per codec.
1247 * And we need to give a unique name_prefix for each amp and should be backwards
1248 * compatible to the existing acpi match tables to not break existing UCMs.
1249 * For the common name_prefix, we append the amp index to it. However, for the
1250 * "Left" name_prefix, we convert the second amp name_prefix to "Right" and
1251 * for the third and further amps, we set the name_prefix to "AMP<amp_index>".
1252 */
1253 if (!strcmp(name_prefix, "Left")) {
1254 switch (*amp_index) {
1255 case 1:
1256 adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL,
1257 "%s", "Left");
1258 break;
1259 case 2:
1260 adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL,
1261 "%s", "Right");
1262 break;
1263 default:
1264 /* Set the name_fix to AMP<amp_index> if there are more than 2 amps */
1265 adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
1266 "AMP", *amp_index);
1267 break;
1268 }
1269 } else if (!strcmp(name_prefix, "AMP")) {
1270 adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
1271 name_prefix,
1272 *amp_index);
1273 } else {
1274 /*
1275 * The name_prefix will be the amp name if it is not "Left" or "AMP", set it to
1276 * <name_prefix>-<amp_index> format. Like rt1320-1
1277 */
1278 adr_dev[index].name_prefix = devm_kasprintf(dev, GFP_KERNEL, "%s-%d",
1279 name_prefix,
1280 *amp_index);
1281 }
1282 (*amp_index)++;
1283
1284 done_name_prefix:
1285 if (!adr_dev[index].name_prefix) {
1286 dev_err(dev, "failed to allocate memory for name_prefix\n");
1287 return NULL;
1288 }
1289
1290 dev_dbg(dev, "adr[%d] 0x%llx link id %d name_prefix \"%s\" is found\n",
1291 index, adr_dev[index].adr, sdw_device->bus->link_id, adr_dev[index].name_prefix);
1292
1293 link->num_adr++;
1294
1295 return adr_dev;
1296 }
1297
hda_sdw_machine_select(struct snd_sof_dev * sdev)1298 static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev)
1299 {
1300 struct snd_sof_pdata *pdata = sdev->pdata;
1301 const struct snd_soc_acpi_link_adr *link;
1302 const struct sof_intel_dsp_desc *chip;
1303 struct snd_soc_acpi_link_adr *links;
1304 struct sdw_peripherals *peripherals;
1305 struct snd_soc_acpi_mach *mach;
1306 struct sof_intel_hda_dev *hdev;
1307 int link_index, link_num;
1308 int amp_index = 1;
1309 u32 link_mask = 0;
1310 int i;
1311
1312 hdev = pdata->hw_pdata;
1313
1314 if (!hdev->info.link_mask) {
1315 dev_info(sdev->dev, "SoundWire links not enabled\n");
1316 return NULL;
1317 }
1318
1319 if (!hdev->sdw) {
1320 dev_dbg(sdev->dev, "SoundWire context not allocated\n");
1321 return NULL;
1322 }
1323
1324 if (!hdev->sdw->peripherals || !hdev->sdw->peripherals->num_peripherals) {
1325 dev_warn(sdev->dev, "No SoundWire peripheral detected in ACPI tables\n");
1326 return NULL;
1327 }
1328
1329 /*
1330 * Select SoundWire machine driver if needed using the
1331 * alternate tables. This case deals with SoundWire-only
1332 * machines, for mixed cases with I2C/I2S the detection relies
1333 * on the HID list.
1334 */
1335 for (mach = pdata->desc->alt_machines;
1336 mach && mach->link_mask; mach++) {
1337 /*
1338 * On some platforms such as Up Extreme all links
1339 * are enabled but only one link can be used by
1340 * external codec. Instead of exact match of two masks,
1341 * first check whether link_mask of mach is subset of
1342 * link_mask supported by hw and then go on searching
1343 * link_adr
1344 */
1345 if (~hdev->info.link_mask & mach->link_mask)
1346 continue;
1347
1348 /* No need to match adr if there is no links defined */
1349 if (!mach->links)
1350 break;
1351
1352 link = mach->links;
1353 for (i = 0; i < hdev->info.count && link->num_adr;
1354 i++, link++) {
1355 /*
1356 * Try next machine if any expected Slaves
1357 * are not found on this link.
1358 */
1359 if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link,
1360 hdev->sdw->peripherals))
1361 break;
1362 }
1363 /* Found if all Slaves are checked */
1364 if (i == hdev->info.count || !link->num_adr)
1365 if (!mach->machine_check || mach->machine_check(hdev->sdw))
1366 break;
1367 }
1368 if (mach && mach->link_mask) {
1369 mach->mach_params.links = mach->links;
1370 mach->mach_params.link_mask = mach->link_mask;
1371 mach->mach_params.platform = dev_name(sdev->dev);
1372
1373 return mach;
1374 }
1375
1376 dev_info(sdev->dev, "No SoundWire machine driver found for the ACPI-reported configuration:\n");
1377 peripherals = hdev->sdw->peripherals;
1378 for (i = 0; i < peripherals->num_peripherals; i++)
1379 dev_info(sdev->dev, "link %d mfg_id 0x%04x part_id 0x%04x version %#x\n",
1380 peripherals->array[i]->bus->link_id,
1381 peripherals->array[i]->id.mfg_id,
1382 peripherals->array[i]->id.part_id,
1383 peripherals->array[i]->id.sdw_version);
1384
1385 chip = get_chip_info(sdev->pdata);
1386
1387 /* SDCA was not well supported in the BIOS before ACE2.0 */
1388 if (chip->hw_ip_version < SOF_INTEL_ACE_2_0)
1389 return NULL;
1390
1391 if (!peripherals->num_peripherals)
1392 return NULL;
1393
1394 /* Create default SDW mach */
1395 mach = devm_kzalloc(sdev->dev, sizeof(*mach), GFP_KERNEL);
1396 if (!mach)
1397 return NULL;
1398
1399 /* Get link mask and link number */
1400 for (i = 0; i < peripherals->num_peripherals; i++)
1401 link_mask |= BIT(peripherals->array[i]->bus->link_id);
1402
1403 link_num = hweight32(link_mask);
1404 links = devm_kcalloc(sdev->dev, link_num, sizeof(*links), GFP_KERNEL);
1405 if (!links)
1406 return NULL;
1407
1408 /* Generate snd_soc_acpi_link_adr struct for each peripheral reported by the ACPI table */
1409 for (i = 0; i < peripherals->num_peripherals; i++) {
1410 /* link_index = the number of used links below the current link */
1411 link_index = hweight32(link_mask & (BIT(peripherals->array[i]->bus->link_id) - 1));
1412 links[link_index].adr_d = find_acpi_adr_device(sdev->dev, peripherals->array[i],
1413 &links[link_index], &_index);
1414 if (!links[link_index].adr_d)
1415 return NULL;
1416 }
1417
1418 mach->drv_name = "sof_sdw";
1419 mach->mach_params.links = links;
1420 mach->mach_params.link_mask = link_mask;
1421 mach->mach_params.platform = dev_name(sdev->dev);
1422 mach->get_function_tplg_files = sof_sdw_get_tplg_files;
1423 /*
1424 * Set mach->sof_tplg_filename as a dummy topology to avoid tplg file checking
1425 * and being used.
1426 */
1427 mach->sof_tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1428 "sof-%s-dummy.tplg", chip->platform);
1429
1430 dev_info(sdev->dev, "Use SoundWire default machine driver with function topologies\n");
1431 return mach;
1432 }
1433 #else
hda_sdw_machine_select(struct snd_sof_dev * sdev)1434 static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev)
1435 {
1436 return NULL;
1437 }
1438 #endif
1439
hda_set_mach_params(struct snd_soc_acpi_mach * mach,struct snd_sof_dev * sdev)1440 void hda_set_mach_params(struct snd_soc_acpi_mach *mach,
1441 struct snd_sof_dev *sdev)
1442 {
1443 struct snd_sof_pdata *pdata = sdev->pdata;
1444 const struct sof_dev_desc *desc = pdata->desc;
1445 struct snd_soc_acpi_mach_params *mach_params;
1446
1447 mach_params = &mach->mach_params;
1448 mach_params->platform = dev_name(sdev->dev);
1449 if (IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT) &&
1450 sof_debug_check_flag(SOF_DBG_FORCE_NOCODEC))
1451 mach_params->num_dai_drivers = SOF_SKL_NUM_DAIS_NOCODEC;
1452 else
1453 mach_params->num_dai_drivers = desc->ops->num_drv;
1454 mach_params->dai_drivers = desc->ops->drv;
1455 }
1456
check_tplg_quirk_mask(struct snd_soc_acpi_mach * mach)1457 static int check_tplg_quirk_mask(struct snd_soc_acpi_mach *mach)
1458 {
1459 u32 dmic_ssp_quirk;
1460 u32 codec_amp_name_quirk;
1461
1462 /*
1463 * In current implementation dmic and ssp quirks are designed for es8336
1464 * machine driver and could not be mixed with codec name and amp name
1465 * quirks.
1466 */
1467 dmic_ssp_quirk = mach->tplg_quirk_mask &
1468 (SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER | SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER);
1469 codec_amp_name_quirk = mach->tplg_quirk_mask &
1470 (SND_SOC_ACPI_TPLG_INTEL_AMP_NAME | SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME);
1471
1472 if (dmic_ssp_quirk && codec_amp_name_quirk)
1473 return -EINVAL;
1474
1475 return 0;
1476 }
1477
remove_file_ext(struct device * dev,const char * tplg_filename)1478 static char *remove_file_ext(struct device *dev, const char *tplg_filename)
1479 {
1480 char *filename, *tmp;
1481
1482 filename = devm_kstrdup(dev, tplg_filename, GFP_KERNEL);
1483 if (!filename)
1484 return NULL;
1485
1486 /* remove file extension if exist */
1487 tmp = filename;
1488 return strsep(&tmp, ".");
1489 }
1490
hda_machine_select(struct snd_sof_dev * sdev)1491 struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
1492 {
1493 u32 interface_mask = hda_get_interface_mask(sdev);
1494 struct snd_sof_pdata *sof_pdata = sdev->pdata;
1495 const struct sof_dev_desc *desc = sof_pdata->desc;
1496 struct hdac_bus *bus = sof_to_bus(sdev);
1497 struct snd_soc_acpi_mach *mach = NULL;
1498 enum snd_soc_acpi_intel_codec codec_type, amp_type;
1499 const char *tplg_filename;
1500 const char *tplg_suffix;
1501 bool amp_name_valid;
1502 bool i2s_mach_found = false;
1503 bool sdw_mach_found = false;
1504
1505 /* Try I2S or DMIC if it is supported */
1506 if (interface_mask & (BIT(SOF_DAI_INTEL_SSP) | BIT(SOF_DAI_INTEL_DMIC))) {
1507 mach = snd_soc_acpi_find_machine(desc->machines);
1508 if (mach)
1509 i2s_mach_found = true;
1510 }
1511
1512 /*
1513 * If I2S fails and no external HDaudio codec is detected,
1514 * try SoundWire if it is supported
1515 */
1516 if (!mach && !HDA_EXT_CODEC(bus->codec_mask) &&
1517 (interface_mask & BIT(SOF_DAI_INTEL_ALH))) {
1518 mach = hda_sdw_machine_select(sdev);
1519 if (mach)
1520 sdw_mach_found = true;
1521 }
1522
1523 /*
1524 * Choose HDA generic machine driver if mach is NULL.
1525 * Otherwise, set certain mach params.
1526 */
1527 hda_generic_machine_select(sdev, &mach);
1528 if (!mach) {
1529 dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n");
1530 return NULL;
1531 }
1532
1533 /* report BT offload link mask to machine driver */
1534 mach->mach_params.bt_link_mask = check_nhlt_ssp_mask(sdev, NHLT_DEVICE_BT);
1535
1536 dev_info(sdev->dev, "BT link detected in NHLT tables: %#x\n",
1537 mach->mach_params.bt_link_mask);
1538
1539 /* allow for module parameter override */
1540 if (bt_link_mask_override != -1) {
1541 dev_dbg(sdev->dev, "overriding BT link detected in NHLT tables %#x by kernel param %#x\n",
1542 mach->mach_params.bt_link_mask, bt_link_mask_override);
1543 mach->mach_params.bt_link_mask = bt_link_mask_override;
1544 }
1545
1546 if (hweight_long(mach->mach_params.bt_link_mask) > 1) {
1547 dev_warn(sdev->dev, "invalid BT link mask %#x found, reset the mask\n",
1548 mach->mach_params.bt_link_mask);
1549 mach->mach_params.bt_link_mask = 0;
1550 }
1551
1552 /*
1553 * Fixup tplg file name by appending dmic num, ssp num, codec/amplifier
1554 * name string if quirk flag is set.
1555 */
1556 if (mach) {
1557 const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata);
1558 bool tplg_fixup = false;
1559 bool dmic_fixup = false;
1560
1561 /*
1562 * If tplg file name is overridden, use it instead of
1563 * the one set in mach table
1564 */
1565 if (!sof_pdata->tplg_filename) {
1566 /* remove file extension if it exists */
1567 tplg_filename = remove_file_ext(sdev->dev, mach->sof_tplg_filename);
1568 if (!tplg_filename)
1569 return NULL;
1570
1571 sof_pdata->tplg_filename = tplg_filename;
1572 tplg_fixup = true;
1573 }
1574
1575 /*
1576 * Checking quirk mask integrity; some quirk flags could not be
1577 * set concurrently.
1578 */
1579 if (tplg_fixup &&
1580 check_tplg_quirk_mask(mach)) {
1581 dev_err(sdev->dev, "Invalid tplg quirk mask 0x%x\n",
1582 mach->tplg_quirk_mask);
1583 return NULL;
1584 }
1585
1586 /* report to machine driver if any DMICs are found */
1587 mach->mach_params.dmic_num = check_dmic_num(sdev);
1588
1589 if (sdw_mach_found || mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER)
1590 dmic_fixup = true;
1591
1592 if (tplg_fixup &&
1593 dmic_fixup &&
1594 mach->mach_params.dmic_num) {
1595 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1596 "%s%s%d%s",
1597 sof_pdata->tplg_filename,
1598 i2s_mach_found ? "-dmic" : "-",
1599 mach->mach_params.dmic_num,
1600 "ch");
1601 if (!tplg_filename)
1602 return NULL;
1603
1604 sof_pdata->tplg_filename = tplg_filename;
1605 }
1606
1607 if (tplg_fixup && mach->mach_params.bt_link_mask &&
1608 chip->hw_ip_version >= SOF_INTEL_ACE_4_0) {
1609 int bt_port = fls(mach->mach_params.bt_link_mask) - 1;
1610
1611 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, "%s-ssp%d-bt",
1612 sof_pdata->tplg_filename, bt_port);
1613 if (!tplg_filename)
1614 return NULL;
1615
1616 sof_pdata->tplg_filename = tplg_filename;
1617 }
1618
1619 if (mach->link_mask) {
1620 mach->mach_params.links = mach->links;
1621 mach->mach_params.link_mask = mach->link_mask;
1622 }
1623
1624 /* report SSP link mask to machine driver */
1625 mach->mach_params.i2s_link_mask = check_nhlt_ssp_mask(sdev, NHLT_DEVICE_I2S);
1626
1627 if (tplg_fixup &&
1628 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER &&
1629 mach->mach_params.i2s_link_mask) {
1630 int ssp_num;
1631
1632 if (hweight_long(mach->mach_params.i2s_link_mask) > 1 &&
1633 !(mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_MSB))
1634 dev_warn(sdev->dev, "More than one SSP exposed by NHLT, choosing MSB\n");
1635
1636 /* fls returns 1-based results, SSPs indices are 0-based */
1637 ssp_num = fls(mach->mach_params.i2s_link_mask) - 1;
1638
1639 if (ssp_num >= chip->ssp_count) {
1640 dev_err(sdev->dev, "Invalid SSP %d, max on this platform is %d\n",
1641 ssp_num, chip->ssp_count);
1642 return NULL;
1643 }
1644
1645 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1646 "%s%s%d",
1647 sof_pdata->tplg_filename,
1648 "-ssp",
1649 ssp_num);
1650 if (!tplg_filename)
1651 return NULL;
1652
1653 sof_pdata->tplg_filename = tplg_filename;
1654
1655 if (sof_pdata->ipc_type == SOF_IPC_TYPE_3) {
1656 int mclk_mask = check_nhlt_ssp_mclk_mask(sdev,
1657 ssp_num);
1658
1659 if (mclk_mask < 0) {
1660 dev_err(sdev->dev,
1661 "Invalid MCLK configuration for SSP%d\n",
1662 ssp_num);
1663 return NULL;
1664 }
1665
1666 if (mclk_mask) {
1667 sdev->mclk_id_override = true;
1668 sdev->mclk_id_quirk = (mclk_mask & BIT(0)) ? 0 : 1;
1669 dev_info(sdev->dev,
1670 "SSP%d to use MCLK id %d (mask: %#x)\n",
1671 ssp_num, sdev->mclk_id_quirk, mclk_mask);
1672 } else {
1673 dev_dbg(sdev->dev,
1674 "MCLK mask is empty for SSP%d in NHLT\n",
1675 ssp_num);
1676 }
1677 }
1678 }
1679
1680 amp_type = snd_soc_acpi_intel_detect_amp_type(sdev->dev);
1681 codec_type = snd_soc_acpi_intel_detect_codec_type(sdev->dev);
1682 amp_name_valid = amp_type != CODEC_NONE && amp_type != codec_type;
1683
1684 if (tplg_fixup && amp_name_valid &&
1685 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_AMP_NAME) {
1686 tplg_suffix = snd_soc_acpi_intel_get_amp_tplg_suffix(amp_type);
1687 if (!tplg_suffix) {
1688 dev_err(sdev->dev, "no tplg suffix found, amp %d\n",
1689 amp_type);
1690 return NULL;
1691 }
1692
1693 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1694 "%s-%s",
1695 sof_pdata->tplg_filename,
1696 tplg_suffix);
1697 if (!tplg_filename)
1698 return NULL;
1699
1700 sof_pdata->tplg_filename = tplg_filename;
1701 }
1702
1703
1704 if (tplg_fixup &&
1705 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME &&
1706 codec_type != CODEC_NONE) {
1707 tplg_suffix = snd_soc_acpi_intel_get_codec_tplg_suffix(codec_type);
1708 if (!tplg_suffix) {
1709 dev_err(sdev->dev, "no tplg suffix found, codec %d\n",
1710 codec_type);
1711 return NULL;
1712 }
1713
1714 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1715 "%s-%s",
1716 sof_pdata->tplg_filename,
1717 tplg_suffix);
1718 if (!tplg_filename)
1719 return NULL;
1720
1721 sof_pdata->tplg_filename = tplg_filename;
1722 }
1723
1724 if (tplg_fixup) {
1725 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
1726 "%s%s",
1727 sof_pdata->tplg_filename,
1728 ".tplg");
1729 if (!tplg_filename)
1730 return NULL;
1731
1732 sof_pdata->tplg_filename = tplg_filename;
1733 }
1734
1735 /* check if mclk_id should be modified from topology defaults */
1736 if (mclk_id_override >= 0) {
1737 dev_info(sdev->dev, "Overriding topology with MCLK %d from kernel_parameter\n", mclk_id_override);
1738 sdev->mclk_id_override = true;
1739 sdev->mclk_id_quirk = mclk_id_override;
1740 }
1741 }
1742
1743 return mach;
1744 }
1745
hda_pci_intel_probe(struct pci_dev * pci,const struct pci_device_id * pci_id)1746 int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
1747 {
1748 int ret;
1749
1750 ret = snd_intel_dsp_driver_probe(pci);
1751 if (ret != SND_INTEL_DSP_DRIVER_ANY && ret != SND_INTEL_DSP_DRIVER_SOF) {
1752 dev_dbg(&pci->dev, "SOF PCI driver not selected, aborting probe\n");
1753 return -ENODEV;
1754 }
1755
1756 return sof_pci_probe(pci, pci_id);
1757 }
1758 EXPORT_SYMBOL_NS(hda_pci_intel_probe, "SND_SOC_SOF_INTEL_HDA_GENERIC");
1759
hda_register_clients(struct snd_sof_dev * sdev)1760 int hda_register_clients(struct snd_sof_dev *sdev)
1761 {
1762 return hda_probes_register(sdev);
1763 }
1764
hda_unregister_clients(struct snd_sof_dev * sdev)1765 void hda_unregister_clients(struct snd_sof_dev *sdev)
1766 {
1767 hda_probes_unregister(sdev);
1768 }
1769
1770 MODULE_LICENSE("Dual BSD/GPL");
1771 MODULE_DESCRIPTION("SOF support for HDaudio platforms");
1772 MODULE_IMPORT_NS("SND_SOC_SOF_PCI_DEV");
1773 MODULE_IMPORT_NS("SND_SOC_SOF_HDA_AUDIO_CODEC");
1774 MODULE_IMPORT_NS("SND_SOC_SOF_HDA_AUDIO_CODEC_I915");
1775 MODULE_IMPORT_NS("SND_SOC_SOF_XTENSA");
1776 MODULE_IMPORT_NS("SND_INTEL_SOUNDWIRE_ACPI");
1777 MODULE_IMPORT_NS("SOUNDWIRE_INTEL_INIT");
1778 MODULE_IMPORT_NS("SOUNDWIRE_INTEL");
1779 MODULE_IMPORT_NS("SND_SOC_SDW_UTILS");
1780 MODULE_IMPORT_NS("SND_SOC_SOF_HDA_MLINK");
1781 MODULE_IMPORT_NS("SND_SOC_SOF_INTEL_HDA_COMMON");
1782 MODULE_IMPORT_NS("SND_SOC_ACPI_INTEL_MATCH");
1783