Lines Matching +full:codec +full:- +full:irq
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
26 #include <sound/intel-dsp-config.h>
27 #include <sound/intel-nhlt.h>
28 #include <sound/soc-acpi-intel-ssp-common.h>
31 #include <sound/hda-mlink.h>
32 #include "../sof-audio.h"
33 #include "../sof-pci-dev.h"
35 #include "../ipc4-topology.h"
41 #include <sound/soc-acpi-intel-match.h>
62 struct snd_soc_dai *d = params_data->dai; in sdw_params_stream()
63 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, params_data->substream->stream); in sdw_params_stream()
66 data.dai_index = (params_data->link_id << 8) | d->id; in sdw_params_stream()
67 data.dai_data = params_data->alh_stream_id; in sdw_params_stream()
75 struct snd_soc_dai *d = free_data->dai; in sdw_params_free()
76 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, free_data->substream->stream); in sdw_params_free()
79 if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { in sdw_params_free()
80 struct snd_sof_widget *swidget = w->dobj.private; in sdw_params_free()
81 struct snd_sof_dai *dai = swidget->private; in sdw_params_free()
85 ipc4_copier = dai->private; in sdw_params_free()
86 ipc4_copier->dai_index = 0; in sdw_params_free()
87 copier_data = &ipc4_copier->data; in sdw_params_free()
90 copier_data->gtw_cfg.node_id &= ~SOF_IPC4_NODE_INDEX_MASK; in sdw_params_free()
104 return sdw_hda_dai_hw_params(params_data->substream, in sdw_ace2x_params_stream()
105 params_data->hw_params, in sdw_ace2x_params_stream()
106 params_data->dai, in sdw_ace2x_params_stream()
107 params_data->link_id, in sdw_ace2x_params_stream()
108 params_data->alh_stream_id); in sdw_ace2x_params_stream()
114 return sdw_hda_dai_hw_free(free_data->substream, in sdw_ace2x_free_stream()
115 free_data->dai, in sdw_ace2x_free_stream()
116 free_data->link_id); in sdw_ace2x_free_stream()
138 return -EINVAL; in hda_sdw_acpi_scan()
140 handle = ACPI_HANDLE(sdev->dev); in hda_sdw_acpi_scan()
143 hdev = sdev->pdata->hw_pdata; in hda_sdw_acpi_scan()
145 ret = sdw_intel_acpi_scan(handle, &hdev->info); in hda_sdw_acpi_scan()
147 return -EINVAL; in hda_sdw_acpi_scan()
159 hdev = sdev->pdata->hw_pdata; in hda_sdw_probe()
163 chip = get_chip_info(sdev->pdata); in hda_sdw_probe()
164 if (chip->hw_ip_version < SOF_INTEL_ACE_2_0) { in hda_sdw_probe()
165 res.mmio_base = sdev->bar[HDA_DSP_BAR]; in hda_sdw_probe()
167 res.shim_base = hdev->desc->sdw_shim_base; in hda_sdw_probe()
168 res.alh_base = hdev->desc->sdw_alh_base; in hda_sdw_probe()
174 * in the HDaudio multi-link areas in hda_sdw_probe()
179 return -ENODEV; in hda_sdw_probe()
181 res.mmio_base = sdev->bar[HDA_DSP_HDA_BAR]; in hda_sdw_probe()
183 * the SHIM and SoundWire register offsets are link-specific in hda_sdw_probe()
191 res.irq = sdev->ipc_irq; in hda_sdw_probe()
192 res.handle = hdev->info.handle; in hda_sdw_probe()
193 res.parent = sdev->dev; in hda_sdw_probe()
195 res.dev = sdev->dev; in hda_sdw_probe()
206 res.count = hdev->info.count; in hda_sdw_probe()
207 res.link_mask = hdev->info.link_mask; in hda_sdw_probe()
211 dev_err(sdev->dev, "error: SoundWire probe failed\n"); in hda_sdw_probe()
212 return -EINVAL; in hda_sdw_probe()
216 hdev->sdw = sdw; in hda_sdw_probe()
224 struct snd_sof_pdata *pdata = sdev->pdata; in hda_sdw_startup()
227 hdev = sdev->pdata->hw_pdata; in hda_sdw_startup()
229 if (!hdev->sdw) in hda_sdw_startup()
232 if (pdata->machine && !pdata->machine->mach_params.link_mask) in hda_sdw_startup()
239 return sdw_intel_startup(hdev->sdw); in hda_sdw_startup()
247 hdev = sdev->pdata->hw_pdata; in hda_sdw_exit()
249 if (hdev->sdw) in hda_sdw_exit()
250 sdw_intel_exit(hdev->sdw); in hda_sdw_exit()
251 hdev->sdw = NULL; in hda_sdw_exit()
264 hdev = sdev->pdata->hw_pdata; in hda_common_check_sdw_irq()
266 if (!hdev->sdw) in hda_common_check_sdw_irq()
293 chip = get_chip_info(sdev->pdata); in hda_dsp_check_sdw_irq()
294 if (chip && chip->check_sdw_irq) in hda_dsp_check_sdw_irq()
295 return chip->check_sdw_irq(sdev); in hda_dsp_check_sdw_irq()
300 static irqreturn_t hda_dsp_sdw_thread(int irq, void *context) in hda_dsp_sdw_thread() argument
302 return sdw_intel_thread(irq, context); in hda_dsp_sdw_thread()
309 hdev = sdev->pdata->hw_pdata; in hda_sdw_check_wakeen_irq_common()
310 if (hdev->sdw && in hda_sdw_check_wakeen_irq_common()
312 hdev->desc->sdw_shim_base + SDW_SHIM_WAKESTS)) in hda_sdw_check_wakeen_irq_common()
327 chip = get_chip_info(sdev->pdata); in hda_sdw_check_wakeen_irq()
328 if (chip && chip->check_sdw_wakeen_irq) in hda_sdw_check_wakeen_irq()
329 return chip->check_sdw_wakeen_irq(sdev); in hda_sdw_check_wakeen_irq()
342 hdev = sdev->pdata->hw_pdata; in hda_sdw_process_wakeen_common()
343 if (!hdev->sdw) in hda_sdw_process_wakeen_common()
346 sdw_intel_process_wakeen_event(hdev->sdw); in hda_sdw_process_wakeen_common()
371 static inline irqreturn_t hda_dsp_sdw_thread(int irq, void *context) in hda_dsp_sdw_thread() argument
395 if (sdev->first_boot) { in hda_dsp_post_fw_run()
396 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_dsp_post_fw_run()
400 dev_err(sdev->dev, in hda_dsp_post_fw_run()
407 (sdev->fw_ready.flags & SOF_IPC_INFO_D3_PERSISTENT || in hda_dsp_post_fw_run()
408 sdev->pdata->ipc_type == SOF_IPC_TYPE_4)) { in hda_dsp_post_fw_run()
409 hdev->imrboot_supported = true; in hda_dsp_post_fw_run()
411 0644, sdev->debugfs_root, in hda_dsp_post_fw_run()
412 &hdev->skip_imr_boot); in hda_dsp_post_fw_run()
418 /* re-enable clock gating and power gating */ in hda_dsp_post_fw_run()
439 static int dmic_num_override = -1;
443 static int mclk_id_override = -1;
455 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_init()
462 sof_hda_bus_init(sdev, &pci->dev); in hda_init()
465 bus->use_posbuf = 0; in hda_init()
467 bus->use_posbuf = 1; in hda_init()
468 bus->bdl_pos_adj = 0; in hda_init()
469 bus->sync_write = 1; in hda_init()
471 mutex_init(&hbus->prepare_mutex); in hda_init()
472 hbus->pci = pci; in hda_init()
473 hbus->mixer_assigned = -1; in hda_init()
474 hbus->modelname = hda_model; in hda_init()
477 bus->addr = pci_resource_start(pci, 0); in hda_init()
478 bus->remap_addr = pci_ioremap_bar(pci, 0); in hda_init()
479 if (!bus->remap_addr) { in hda_init()
480 dev_err(bus->dev, "error: ioremap error\n"); in hda_init()
481 return -ENXIO; in hda_init()
485 sdev->bar[HDA_DSP_HDA_BAR] = bus->remap_addr; in hda_init()
489 if (ret < 0 && ret != -ENODEV) { in hda_init()
490 dev_err_probe(sdev->dev, ret, "init of i915 and HDMI codec failed\n"); in hda_init()
497 dev_err(sdev->dev, "error: get caps error\n"); in hda_init()
503 iounmap(sof_to_bus(sdev)->remap_addr); in hda_init()
510 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in check_dmic_num()
514 nhlt = hdev->nhlt; in check_dmic_num()
516 dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt); in check_dmic_num()
518 dev_info(sdev->dev, "DMICs detected in NHLT tables: %d\n", dmic_num); in check_dmic_num()
521 if (dmic_num_override != -1) { in check_dmic_num()
522 dev_dbg(sdev->dev, in check_dmic_num()
529 dev_dbg(sdev->dev, "invalid dmic_number %d\n", dmic_num); in check_dmic_num()
538 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in check_nhlt_ssp_mask()
542 nhlt = hdev->nhlt; in check_nhlt_ssp_mask()
549 dev_info(sdev->dev, "NHLT device %s(%d) detected, ssp_mask %#x\n", in check_nhlt_ssp_mask()
559 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in check_nhlt_ssp_mclk_mask()
562 nhlt = hdev->nhlt; in check_nhlt_ssp_mclk_mask()
573 struct snd_sof_pdata *pdata = sdev->pdata; in hda_init_caps()
574 struct sof_intel_hda_dev *hdev = pdata->hw_pdata; in hda_init_caps()
579 if (bus->ppcap) in hda_init_caps()
580 dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n"); in hda_init_caps()
585 dev_err(bus->dev, "error: init chip failed with ret: %d\n", in hda_init_caps()
599 dev_dbg(sdev->dev, "skipping SoundWire, not detected with ACPI scan\n"); in hda_init_caps()
603 link_mask = hdev->info.link_mask; in hda_init_caps()
605 dev_dbg(sdev->dev, "skipping SoundWire, no links enabled\n"); in hda_init_caps()
618 dev_err(sdev->dev, "error: SoundWire probe error\n"); in hda_init_caps()
624 /* create codec instances */ in hda_init_caps()
627 if (!HDA_IDISP_CODEC(bus->codec_mask)) in hda_init_caps()
635 static irqreturn_t hda_dsp_interrupt_handler(int irq, void *context) in hda_dsp_interrupt_handler() argument
658 static irqreturn_t hda_dsp_interrupt_thread(int irq, void *context) in hda_dsp_interrupt_thread() argument
661 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_dsp_interrupt_thread()
666 hda_dsp_stream_threaded_handler(irq, sdev); in hda_dsp_interrupt_thread()
671 sof_ops(sdev)->irq_thread(irq, sdev); in hda_dsp_interrupt_thread()
676 hda_dsp_sdw_thread(irq, hdev->sdw); in hda_dsp_interrupt_thread()
697 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_probe_early()
702 if (!sdev->dspless_mode_selected) { in hda_dsp_probe_early()
704 * detect DSP by checking class/subclass/prog-id information in hda_dsp_probe_early()
705 * class=04 subclass 03 prog-if 00: no DSP, legacy driver is required in hda_dsp_probe_early()
706 * class=04 subclass 01 prog-if 00: DSP is present in hda_dsp_probe_early()
708 * class=04 subclass 03 prog-if 80: either of DSP or legacy mode works in hda_dsp_probe_early()
710 if (pci->class == 0x040300) { in hda_dsp_probe_early()
711 dev_err(sdev->dev, "the DSP is not enabled on this platform, aborting probe\n"); in hda_dsp_probe_early()
712 return -ENODEV; in hda_dsp_probe_early()
713 } else if (pci->class != 0x040100 && pci->class != 0x040380) { in hda_dsp_probe_early()
714 dev_err(sdev->dev, "unknown PCI class/subclass/prog-if 0x%06x found, aborting probe\n", in hda_dsp_probe_early()
715 pci->class); in hda_dsp_probe_early()
716 return -ENODEV; in hda_dsp_probe_early()
718 dev_info_once(sdev->dev, "DSP detected with PCI class/subclass/prog-if 0x%06x\n", in hda_dsp_probe_early()
719 pci->class); in hda_dsp_probe_early()
722 chip = get_chip_info(sdev->pdata); in hda_dsp_probe_early()
724 dev_err(sdev->dev, "error: no such device supported, chip id:%x\n", in hda_dsp_probe_early()
725 pci->device); in hda_dsp_probe_early()
726 ret = -EIO; in hda_dsp_probe_early()
730 sdev->num_cores = chip->cores_num; in hda_dsp_probe_early()
732 hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL); in hda_dsp_probe_early()
734 return -ENOMEM; in hda_dsp_probe_early()
735 sdev->pdata->hw_pdata = hdev; in hda_dsp_probe_early()
736 hdev->desc = chip; in hda_dsp_probe_early()
746 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_probe()
747 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_dsp_probe()
751 hdev->dmic_dev = platform_device_register_data(sdev->dev, "dmic-codec", in hda_dsp_probe()
754 if (IS_ERR(hdev->dmic_dev)) { in hda_dsp_probe()
755 dev_err(sdev->dev, "error: failed to create DMIC device\n"); in hda_dsp_probe()
756 return PTR_ERR(hdev->dmic_dev); in hda_dsp_probe()
764 hdev->no_ipc_position = 0; in hda_dsp_probe()
766 hdev->no_ipc_position = sof_ops(sdev)->pcm_pointer ? 1 : 0; in hda_dsp_probe()
769 if (sdev->dspless_mode_selected) in hda_dsp_probe()
770 hdev->no_ipc_position = 1; in hda_dsp_probe()
772 if (sdev->dspless_mode_selected) in hda_dsp_probe()
776 sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR); in hda_dsp_probe()
777 if (!sdev->bar[HDA_DSP_BAR]) { in hda_dsp_probe()
778 dev_err(sdev->dev, "error: ioremap error\n"); in hda_dsp_probe()
779 ret = -ENXIO; in hda_dsp_probe()
783 sdev->mmio_bar = HDA_DSP_BAR; in hda_dsp_probe()
784 sdev->mailbox_bar = HDA_DSP_BAR; in hda_dsp_probe()
788 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64))) { in hda_dsp_probe()
789 dev_dbg(sdev->dev, "DMA mask is 32 bit\n"); in hda_dsp_probe()
790 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32)); in hda_dsp_probe()
792 dma_set_max_seg_size(&pci->dev, UINT_MAX); in hda_dsp_probe()
797 dev_err(sdev->dev, "error: failed to init streams\n"); in hda_dsp_probe()
806 * register our IRQ in hda_dsp_probe()
812 dev_info(sdev->dev, "use msi interrupt mode\n"); in hda_dsp_probe()
813 sdev->ipc_irq = pci_irq_vector(pci, 0); in hda_dsp_probe()
815 sdev->msi_enabled = true; in hda_dsp_probe()
818 if (!sdev->msi_enabled) { in hda_dsp_probe()
819 dev_info(sdev->dev, "use legacy interrupt mode\n"); in hda_dsp_probe()
821 * in IO-APIC mode, hda->irq and ipc_irq are using the same in hda_dsp_probe()
822 * irq number of pci->irq in hda_dsp_probe()
824 sdev->ipc_irq = pci->irq; in hda_dsp_probe()
827 dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq); in hda_dsp_probe()
828 ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler, in hda_dsp_probe()
832 dev_err(sdev->dev, "error: failed to register IPC IRQ %d\n", in hda_dsp_probe()
833 sdev->ipc_irq); in hda_dsp_probe()
838 synchronize_irq(pci->irq); in hda_dsp_probe()
851 if (!sdev->dspless_mode_selected) { in hda_dsp_probe()
857 sdev->dsp_box.offset = HDA_DSP_MBOX_UPLINK_OFFSET; in hda_dsp_probe()
859 INIT_DELAYED_WORK(&hdev->d0i3_work, hda_dsp_d0i3_work); in hda_dsp_probe()
862 chip = get_chip_info(sdev->pdata); in hda_dsp_probe()
863 if (chip && chip->hw_ip_version >= SOF_INTEL_ACE_2_0) { in hda_dsp_probe()
866 dev_err(sdev->dev, "could not startup SoundWire links\n"); in hda_dsp_probe()
871 init_waitqueue_head(&hdev->waitq); in hda_dsp_probe()
873 hdev->nhlt = intel_nhlt_init(sdev->dev); in hda_dsp_probe()
878 if (!sdev->dspless_mode_selected) { in hda_dsp_probe()
883 free_irq(sdev->ipc_irq, sdev); in hda_dsp_probe()
885 if (sdev->msi_enabled) in hda_dsp_probe()
890 if (!sdev->dspless_mode_selected) in hda_dsp_probe()
891 iounmap(sdev->bar[HDA_DSP_BAR]); in hda_dsp_probe()
893 platform_device_unregister(hdev->dmic_dev); in hda_dsp_probe()
901 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_remove()
902 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_dsp_remove()
903 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_dsp_remove()
904 struct nhlt_acpi_table *nhlt = hda->nhlt; in hda_dsp_remove()
909 if (!sdev->dspless_mode_selected) in hda_dsp_remove()
911 cancel_delayed_work_sync(&hda->d0i3_work); in hda_dsp_remove()
917 if (!IS_ERR_OR_NULL(hda->dmic_dev)) in hda_dsp_remove()
918 platform_device_unregister(hda->dmic_dev); in hda_dsp_remove()
920 if (!sdev->dspless_mode_selected) { in hda_dsp_remove()
921 /* disable DSP IRQ */ in hda_dsp_remove()
929 if (sdev->dspless_mode_selected) in hda_dsp_remove()
933 if (chip && chip->power_down_dsp) in hda_dsp_remove()
934 chip->power_down_dsp(sdev); in hda_dsp_remove()
940 if (hda->cl_dmab.area) in hda_dsp_remove()
941 snd_dma_free_pages(&hda->cl_dmab); in hda_dsp_remove()
942 if (hda->iccmax_dmab.area) in hda_dsp_remove()
943 snd_dma_free_pages(&hda->iccmax_dmab); in hda_dsp_remove()
946 free_irq(sdev->ipc_irq, sdev); in hda_dsp_remove()
947 if (sdev->msi_enabled) in hda_dsp_remove()
954 if (!sdev->dspless_mode_selected) in hda_dsp_remove()
955 iounmap(sdev->bar[HDA_DSP_BAR]); in hda_dsp_remove()
961 iounmap(sof_to_bus(sdev)->remap_addr); in hda_dsp_remove_late()
968 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_power_down_dsp()
969 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_power_down_dsp()
971 return hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask); in hda_power_down_dsp()
982 struct snd_sof_pdata *pdata = sdev->pdata; in hda_generic_machine_select()
987 /* codec detection */ in hda_generic_machine_select()
988 if (!bus->codec_mask) { in hda_generic_machine_select()
989 dev_info(bus->dev, "no hda codecs found!\n"); in hda_generic_machine_select()
991 dev_info(bus->dev, "hda codecs found, mask %lx\n", in hda_generic_machine_select()
992 bus->codec_mask); in hda_generic_machine_select()
995 if (bus->codec_mask & (1 << i)) in hda_generic_machine_select()
1003 * - one HDMI codec, and/or in hda_generic_machine_select()
1004 * - one external HDAudio codec in hda_generic_machine_select()
1011 dev_info(bus->dev, "using HDA machine driver %s now\n", in hda_generic_machine_select()
1012 hda_mach->drv_name); in hda_generic_machine_select()
1018 if (!pdata->tplg_filename) in hda_generic_machine_select()
1022 codec_num == 1 && HDA_IDISP_CODEC(bus->codec_mask)) { in hda_generic_machine_select()
1023 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_generic_machine_select()
1024 "%s-idisp", in hda_generic_machine_select()
1025 hda_mach->sof_tplg_filename); in hda_generic_machine_select()
1029 hda_mach->sof_tplg_filename = tplg_filename; in hda_generic_machine_select()
1033 (codec_num == 1 && !HDA_IDISP_CODEC(bus->codec_mask))) { in hda_generic_machine_select()
1036 * HDaudio codec is used in hda_generic_machine_select()
1038 hda_mach->mach_params.link_mask = 0; in hda_generic_machine_select()
1041 * Allow SoundWire links to start when no external HDaudio codec in hda_generic_machine_select()
1043 * will help detect if any SoundWire codec reports as ATTACHED. in hda_generic_machine_select()
1045 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_generic_machine_select()
1047 hda_mach->mach_params.link_mask = hdev->info.link_mask; in hda_generic_machine_select()
1056 mach_params = &(*mach)->mach_params; in hda_generic_machine_select()
1057 mach_params->codec_mask = bus->codec_mask; in hda_generic_machine_select()
1071 struct snd_sof_pdata *pdata = sdev->pdata; in hda_sdw_machine_select()
1079 hdev = pdata->hw_pdata; in hda_sdw_machine_select()
1080 link_mask = hdev->info.link_mask; in hda_sdw_machine_select()
1083 dev_info(sdev->dev, "SoundWire links not enabled\n"); in hda_sdw_machine_select()
1087 if (!hdev->sdw) { in hda_sdw_machine_select()
1088 dev_dbg(sdev->dev, "SoundWire context not allocated\n"); in hda_sdw_machine_select()
1092 if (!hdev->sdw->peripherals || !hdev->sdw->peripherals->num_peripherals) { in hda_sdw_machine_select()
1093 dev_warn(sdev->dev, "No SoundWire peripheral detected in ACPI tables\n"); in hda_sdw_machine_select()
1099 * alternate tables. This case deals with SoundWire-only in hda_sdw_machine_select()
1103 for (mach = pdata->desc->alt_machines; in hda_sdw_machine_select()
1104 mach && mach->link_mask; mach++) { in hda_sdw_machine_select()
1108 * external codec. Instead of exact match of two masks, in hda_sdw_machine_select()
1113 if (~link_mask & mach->link_mask) in hda_sdw_machine_select()
1117 if (!mach->links) in hda_sdw_machine_select()
1120 link = mach->links; in hda_sdw_machine_select()
1121 for (i = 0; i < hdev->info.count && link->num_adr; in hda_sdw_machine_select()
1127 if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link, in hda_sdw_machine_select()
1128 hdev->sdw->peripherals)) in hda_sdw_machine_select()
1132 if (i == hdev->info.count || !link->num_adr) in hda_sdw_machine_select()
1133 if (!mach->machine_check || mach->machine_check(hdev->sdw)) in hda_sdw_machine_select()
1136 if (mach && mach->link_mask) { in hda_sdw_machine_select()
1137 mach->mach_params.links = mach->links; in hda_sdw_machine_select()
1138 mach->mach_params.link_mask = mach->link_mask; in hda_sdw_machine_select()
1139 mach->mach_params.platform = dev_name(sdev->dev); in hda_sdw_machine_select()
1144 dev_info(sdev->dev, "No SoundWire machine driver found for the ACPI-reported configuration:\n"); in hda_sdw_machine_select()
1145 peripherals = hdev->sdw->peripherals; in hda_sdw_machine_select()
1146 for (i = 0; i < peripherals->num_peripherals; i++) in hda_sdw_machine_select()
1147 dev_info(sdev->dev, "link %d mfg_id 0x%04x part_id 0x%04x version %#x\n", in hda_sdw_machine_select()
1148 peripherals->array[i]->bus->link_id, in hda_sdw_machine_select()
1149 peripherals->array[i]->id.mfg_id, in hda_sdw_machine_select()
1150 peripherals->array[i]->id.part_id, in hda_sdw_machine_select()
1151 peripherals->array[i]->id.sdw_version); in hda_sdw_machine_select()
1165 struct snd_sof_pdata *pdata = sdev->pdata; in hda_set_mach_params()
1166 const struct sof_dev_desc *desc = pdata->desc; in hda_set_mach_params()
1169 mach_params = &mach->mach_params; in hda_set_mach_params()
1170 mach_params->platform = dev_name(sdev->dev); in hda_set_mach_params()
1173 mach_params->num_dai_drivers = SOF_SKL_NUM_DAIS_NOCODEC; in hda_set_mach_params()
1175 mach_params->num_dai_drivers = desc->ops->num_drv; in hda_set_mach_params()
1176 mach_params->dai_drivers = desc->ops->drv; in hda_set_mach_params()
1186 * machine driver and could not be mixed with codec name and amp name in check_tplg_quirk_mask()
1189 dmic_ssp_quirk = mach->tplg_quirk_mask & in check_tplg_quirk_mask()
1191 codec_amp_name_quirk = mach->tplg_quirk_mask & in check_tplg_quirk_mask()
1195 return -EINVAL; in check_tplg_quirk_mask()
1216 struct snd_sof_pdata *sof_pdata = sdev->pdata; in hda_machine_select()
1217 const struct sof_dev_desc *desc = sof_pdata->desc; in hda_machine_select()
1229 mach = snd_soc_acpi_find_machine(desc->machines); in hda_machine_select()
1235 * If I2S fails and no external HDaudio codec is detected, in hda_machine_select()
1238 if (!mach && !HDA_EXT_CODEC(bus->codec_mask) && in hda_machine_select()
1251 dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); in hda_machine_select()
1256 mach->mach_params.bt_link_mask = check_nhlt_ssp_mask(sdev, NHLT_DEVICE_BT); in hda_machine_select()
1258 dev_info(sdev->dev, "BT link detected in NHLT tables: %#x\n", in hda_machine_select()
1259 mach->mach_params.bt_link_mask); in hda_machine_select()
1263 dev_dbg(sdev->dev, "overriding BT link detected in NHLT tables %#x by kernel param %#x\n", in hda_machine_select()
1264 mach->mach_params.bt_link_mask, bt_link_mask_override); in hda_machine_select()
1265 mach->mach_params.bt_link_mask = bt_link_mask_override; in hda_machine_select()
1268 if (hweight_long(mach->mach_params.bt_link_mask) > 1) { in hda_machine_select()
1269 dev_warn(sdev->dev, "invalid BT link mask %#x found, reset the mask\n", in hda_machine_select()
1270 mach->mach_params.bt_link_mask); in hda_machine_select()
1271 mach->mach_params.bt_link_mask = 0; in hda_machine_select()
1275 * Fixup tplg file name by appending dmic num, ssp num, codec/amplifier in hda_machine_select()
1286 if (!sof_pdata->tplg_filename) { in hda_machine_select()
1288 tplg_filename = remove_file_ext(mach->sof_tplg_filename); in hda_machine_select()
1292 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1302 dev_err(sdev->dev, "Invalid tplg quirk mask 0x%x\n", in hda_machine_select()
1303 mach->tplg_quirk_mask); in hda_machine_select()
1308 mach->mach_params.dmic_num = check_dmic_num(sdev); in hda_machine_select()
1312 * DMICs use up to 4 pins and are typically pin-muxed with SoundWire in hda_machine_select()
1318 if (hweight_long(mach->link_mask) <= 2) in hda_machine_select()
1321 mach->mach_params.dmic_num = 0; in hda_machine_select()
1323 if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER) in hda_machine_select()
1329 mach->mach_params.dmic_num) { in hda_machine_select()
1330 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1332 sof_pdata->tplg_filename, in hda_machine_select()
1333 i2s_mach_found ? "-dmic" : "-", in hda_machine_select()
1334 mach->mach_params.dmic_num, in hda_machine_select()
1339 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1342 if (mach->link_mask) { in hda_machine_select()
1343 mach->mach_params.links = mach->links; in hda_machine_select()
1344 mach->mach_params.link_mask = mach->link_mask; in hda_machine_select()
1348 mach->mach_params.i2s_link_mask = check_nhlt_ssp_mask(sdev, NHLT_DEVICE_I2S); in hda_machine_select()
1351 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER && in hda_machine_select()
1352 mach->mach_params.i2s_link_mask) { in hda_machine_select()
1353 const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata); in hda_machine_select()
1357 if (hweight_long(mach->mach_params.i2s_link_mask) > 1 && in hda_machine_select()
1358 !(mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_MSB)) in hda_machine_select()
1359 dev_warn(sdev->dev, "More than one SSP exposed by NHLT, choosing MSB\n"); in hda_machine_select()
1361 /* fls returns 1-based results, SSPs indices are 0-based */ in hda_machine_select()
1362 ssp_num = fls(mach->mach_params.i2s_link_mask) - 1; in hda_machine_select()
1364 if (ssp_num >= chip->ssp_count) { in hda_machine_select()
1365 dev_err(sdev->dev, "Invalid SSP %d, max on this platform is %d\n", in hda_machine_select()
1366 ssp_num, chip->ssp_count); in hda_machine_select()
1370 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1372 sof_pdata->tplg_filename, in hda_machine_select()
1373 "-ssp", in hda_machine_select()
1378 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1383 dev_err(sdev->dev, "Invalid MCLK configuration\n"); in hda_machine_select()
1387 dev_dbg(sdev->dev, "MCLK mask %#x found in NHLT\n", mclk_mask); in hda_machine_select()
1390 dev_info(sdev->dev, "Overriding topology with MCLK mask %#x from NHLT\n", mclk_mask); in hda_machine_select()
1391 sdev->mclk_id_override = true; in hda_machine_select()
1392 sdev->mclk_id_quirk = (mclk_mask & BIT(0)) ? 0 : 1; in hda_machine_select()
1396 amp_type = snd_soc_acpi_intel_detect_amp_type(sdev->dev); in hda_machine_select()
1397 codec_type = snd_soc_acpi_intel_detect_codec_type(sdev->dev); in hda_machine_select()
1401 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_AMP_NAME) { in hda_machine_select()
1404 dev_err(sdev->dev, "no tplg suffix found, amp %d\n", in hda_machine_select()
1409 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1410 "%s-%s", in hda_machine_select()
1411 sof_pdata->tplg_filename, in hda_machine_select()
1416 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1421 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME && in hda_machine_select()
1425 dev_err(sdev->dev, "no tplg suffix found, codec %d\n", in hda_machine_select()
1430 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1431 "%s-%s", in hda_machine_select()
1432 sof_pdata->tplg_filename, in hda_machine_select()
1437 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1441 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, in hda_machine_select()
1443 sof_pdata->tplg_filename, in hda_machine_select()
1448 sof_pdata->tplg_filename = tplg_filename; in hda_machine_select()
1453 … dev_info(sdev->dev, "Overriding topology with MCLK %d from kernel_parameter\n", mclk_id_override); in hda_machine_select()
1454 sdev->mclk_id_override = true; in hda_machine_select()
1455 sdev->mclk_id_quirk = mclk_id_override; in hda_machine_select()
1468 dev_dbg(&pci->dev, "SOF PCI driver not selected, aborting probe\n"); in hda_pci_intel_probe()
1469 return -ENODEV; in hda_pci_intel_probe()