Lines Matching +full:south +full:- +full:field

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * hda_intel.c - Implementation of primary alsa driver code base
27 #include <linux/dma-mapping.h>
51 #include <sound/intel-dsp-config.h>
54 #include <linux/apple-gmux.h>
73 /* Defines for ATI HD Audio support in SB450 south bridge */
108 static int position_fix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
109 static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
110 static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
113 static int single_cmd = -1;
114 static int enable_msi = -1;
119 static bool beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] =
135 "(-1 = system default, 0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO, 4 = COMBO, 5 = SKL+, 6 = FIFO).");
139 MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
161 "deprecated, use snd-intel-dspcfg.dsp_driver option instead");
175 MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
178 static int pm_blacklist = -1;
180 MODULE_PARM_DESC(pm_blacklist, "Enable power-management denylist");
182 /* reset the HD-audio controller in power save mode.
183 * this may give more power-saving, but will take longer time to
195 static int align_buffer_size = -1;
201 static int hda_snoop = -1;
249 (((chip)->driver_caps & AZX_DCAPS_SNOOP_MASK) >> 10)
332 #define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo)
333 #define needs_eld_notify_link(chip) ((chip)->bus.keep_power)
356 [AZX_DRIVER_CMEDIA] = "HDA C-Media",
360 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
385 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
391 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) {
392 dev_dbg(chip->card->dev, "Clearing TCSEL\n");
393 update_pci_byte(chip->pci, AZX_PCIREG_TCSEL, 0x07, 0);
400 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n",
402 update_pci_byte(chip->pci,
409 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n",
411 update_pci_byte(chip->pci,
414 update_pci_byte(chip->pci,
417 update_pci_byte(chip->pci,
425 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop);
431 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop);
432 pci_read_config_word(chip->pci,
435 dev_dbg(chip->card->dev, "SCH snoop: %s\n",
442 * In BXT-P A0, HD-Audio DMA requests is later than expected,
473 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCAP);
481 dev_warn(chip->card->dev, "set audio clock frequency to 6MHz");
492 * Changes to LCTL.SCF are only needed for the first multi-link dealing
495 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL);
498 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL);
502 if (((readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL)) &
505 timeout--;
509 return -1;
519 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL);
541 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL);
552 struct pci_dev *pci = chip->pci;
556 if (chip->driver_type == AZX_DRIVER_SKL) {
562 if (chip->driver_type == AZX_DRIVER_SKL) {
574 if (bus->mlcap != NULL)
582 struct snd_pcm_substream *substream = azx_dev->core.substream;
583 int stream = substream->stream;
588 delay = pos - lpib_pos;
590 delay = lpib_pos - pos;
592 if (delay >= azx_dev->core.delay_negative_threshold)
595 delay += azx_dev->core.bufsize;
598 if (delay >= azx_dev->core.period_bytes) {
599 dev_info(chip->card->dev,
601 delay, azx_dev->core.period_bytes);
603 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY;
604 chip->get_delay[stream] = NULL;
607 return bytes_to_frames(substream->runtime, delay);
620 azx_dev->irq_pending = 0;
624 azx_dev->irq_pending = 1;
625 schedule_work(&hda->irq_pending_work);
635 * periods. Returns non-zero if it's OK.
637 * Many HD-audio controllers appear pretty inaccurate about
638 * the update-IRQ timing. The IRQ is issued before actually the
642 * Returns 1 if OK to proceed, 0 for delay handling, -1 for skipping update
646 struct snd_pcm_substream *substream = azx_dev->core.substream;
647 struct snd_pcm_runtime *runtime = substream->runtime;
648 int stream = substream->stream;
657 if (chip->driver_type == AZX_DRIVER_LOONGSON)
660 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk;
661 if (wallclk < (azx_dev->core.period_wallclk * 2) / 3)
662 return -1; /* bogus (too early) interrupt */
664 if (chip->get_position[stream])
665 pos = chip->get_position[stream](chip, azx_dev);
668 if (!pos || pos == (u32)-1) {
669 dev_info(chip->card->dev,
671 chip->get_position[stream] = azx_get_pos_lpib;
672 if (chip->get_position[0] == azx_get_pos_lpib &&
673 chip->get_position[1] == azx_get_pos_lpib)
674 azx_bus(chip)->use_posbuf = false;
676 chip->get_delay[stream] = NULL;
678 chip->get_position[stream] = azx_get_pos_posbuf;
679 if (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)
680 chip->get_delay[stream] = azx_get_delay_from_lpib;
684 if (pos >= azx_dev->core.bufsize)
687 if (WARN_ONCE(!azx_dev->core.period_bytes,
688 "hda-intel: zero azx_dev->period_bytes"))
689 return -1; /* this shouldn't happen! */
690 if (wallclk < (azx_dev->core.period_wallclk * 5) / 4 &&
691 pos % azx_dev->core.period_bytes > azx_dev->core.period_bytes / 2)
692 /* NG - it's below the first next period boundary */
693 return chip->bdl_pos_adj ? 0 : -1;
694 azx_dev->core.start_wallclk += wallclk;
696 if (azx_dev->core.no_period_wakeup)
699 if (runtime->hw_ptr_base != runtime->hw_ptr_interrupt)
704 hwptr = runtime->hw_ptr_base + pos;
705 if (hwptr < runtime->status->hw_ptr)
706 hwptr += runtime->buffer_size;
707 target = runtime->hw_ptr_interrupt + runtime->period_size;
710 return chip->bdl_pos_adj ? 0 : -1;
722 struct azx *chip = &hda->chip;
727 if (!hda->irq_pending_warned) {
728 dev_info(chip->card->dev,
730 chip->card->number);
731 hda->irq_pending_warned = 1;
736 spin_lock_irq(&bus->reg_lock);
737 list_for_each_entry(s, &bus->stream_list, list) {
739 if (!azx_dev->irq_pending ||
740 !s->substream ||
741 !s->running)
745 azx_dev->irq_pending = 0;
746 spin_unlock(&bus->reg_lock);
747 snd_pcm_period_elapsed(s->substream);
748 spin_lock(&bus->reg_lock);
754 spin_unlock_irq(&bus->reg_lock);
761 /* clear irq_pending flags and assure no on-going workq */
767 guard(spinlock_irq)(&bus->reg_lock);
768 list_for_each_entry(s, &bus->stream_list, list) {
770 azx_dev->irq_pending = 0;
779 if (!chip->msi || pci_alloc_irq_vectors(chip->pci, 1, 1, PCI_IRQ_MSI) < 0) {
780 ret = pci_alloc_irq_vectors(chip->pci, 1, 1, PCI_IRQ_INTX);
783 chip->msi = 0;
786 if (request_irq(chip->pci->irq, azx_interrupt,
787 chip->msi ? 0 : IRQF_SHARED,
788 chip->card->irq_descr, chip)) {
789 dev_err(chip->card->dev,
791 chip->pci->irq);
793 snd_card_disconnect(chip->card);
794 return -1;
796 bus->irq = chip->pci->irq;
797 chip->card->sync_irq = bus->irq;
810 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
819 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf);
820 mod_dma_pos %= azx_dev->core.period_bytes;
822 fifo_size = azx_stream(azx_dev)->fifo_size;
824 if (azx_dev->insufficient) {
829 azx_dev->insufficient = 0;
833 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size;
835 mini_pos = link_pos - fifo_size;
838 mod_mini_pos = mini_pos % azx_dev->core.period_bytes;
839 mod_link_pos = link_pos % azx_dev->core.period_bytes;
841 bound_pos = link_pos - mod_link_pos;
843 bound_pos = mini_pos - mod_mini_pos;
845 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes;
846 if (bound_pos >= azx_dev->core.bufsize)
859 struct snd_pcm_substream *substream = azx_dev->core.substream;
860 struct snd_pcm_runtime *runtime = substream->runtime;
867 runtime->delay = AMD_FIFO_SIZE;
869 if (azx_dev->insufficient) {
872 runtime->delay = bytes_to_frames(runtime, pos);
874 azx_dev->insufficient = 0;
879 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
881 pos += azx_dev->core.bufsize;
882 pos -= delay;
891 struct snd_pcm_substream *substream = azx_dev->core.substream;
894 return substream->runtime->delay;
919 list_add(&hda->list, &card_list);
927 list_del_init(&hda->list);
930 /* trigger power-save check at writing parameter */
946 chip = &hda->chip;
947 if (!hda->probe_continued || chip->disabled ||
948 hda->runtime_pm_disabled)
950 snd_hda_set_power_save(&chip->bus, power_save * 1000);
965 chip = card->private_data;
967 if (chip->disabled || hda->init_failed || !chip->running)
980 if (hda->need_i915_power)
990 if (!chip->pm_prepared) {
991 list_for_each_codec(codec, &chip->bus) {
992 if (codec->relaxed_resume)
995 if (codec->forced_resume || (status & (1 << codec->addr)))
1000 /* power down again for link-controlled chips */
1001 if (!hda->need_i915_power)
1013 chip = card->private_data;
1014 chip->pm_prepared = 1;
1017 flush_work(&azx_bus(chip)->unsol_work);
1020 * and system suspend, so don't use direct-complete here.
1033 chip = card->private_data;
1035 chip->pm_prepared = 0;
1046 chip = card->private_data;
1061 chip = card->private_data;
1075 struct azx *chip = card->private_data;
1080 if (chip->driver_type == AZX_DRIVER_SKL)
1089 struct azx *chip = card->private_data;
1094 if (chip->driver_type == AZX_DRIVER_SKL)
1107 chip = card->private_data;
1124 chip = card->private_data;
1143 chip = card->private_data;
1145 if (chip->disabled || hda->init_failed)
1149 azx_bus(chip)->codec_powered || !chip->running)
1150 return -EBUSY;
1152 /* ELD notification gets broken when HD-audio bus is off */
1154 return -EBUSY;
1178 struct azx *chip = card->private_data;
1183 wait_for_completion(&hda->probe_wait);
1184 if (hda->init_failed)
1188 if (chip->disabled == disabled)
1191 if (!hda->probe_continued) {
1192 chip->disabled = disabled;
1194 dev_info(chip->card->dev,
1197 dev_err(chip->card->dev, "initialization error\n");
1200 dev_info(chip->card->dev, "%s via vga_switcheroo\n",
1203 list_for_each_codec(codec, &chip->bus) {
1207 pm_runtime_suspend(card->dev);
1208 pm_runtime_disable(card->dev);
1212 pci->current_state = PCI_D3cold;
1213 chip->disabled = true;
1214 if (snd_hda_lock_devices(&chip->bus))
1215 dev_warn(chip->card->dev,
1218 snd_hda_unlock_devices(&chip->bus);
1219 chip->disabled = false;
1220 pm_runtime_enable(card->dev);
1221 list_for_each_codec(codec, &chip->bus) {
1232 struct azx *chip = card->private_data;
1235 wait_for_completion(&hda->probe_wait);
1236 if (hda->init_failed)
1238 if (chip->disabled || !hda->probe_continued)
1240 if (snd_hda_lock_devices(&chip->bus))
1242 snd_hda_unlock_devices(&chip->bus);
1255 if (hda->use_vga_switcheroo && !needs_eld_notify_link(chip)) {
1256 list_for_each_codec(codec, &chip->bus)
1257 codec->auto_runtime_pm = 1;
1259 if (chip->running)
1268 struct azx *chip = card->private_data;
1271 chip->bus.keep_power = 0;
1278 struct pci_dev *p = get_bound_vga(chip->pci);
1281 dev_info(chip->card->dev,
1283 hda->use_vga_switcheroo = 1;
1289 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1;
1290 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME;
1307 if (!hda->use_vga_switcheroo)
1310 p = get_bound_vga(chip->pci);
1311 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p);
1316 hda->vga_switcheroo_registered = 1;
1332 struct pci_dev *pci = chip->pci;
1336 if (hda->freed)
1339 if (azx_has_pm_runtime(chip) && chip->running) {
1340 pm_runtime_get_noresume(&pci->dev);
1341 pm_runtime_forbid(&pci->dev);
1342 pm_runtime_dont_use_autosuspend(&pci->dev);
1345 chip->running = 0;
1349 hda->init_failed = 1; /* to be sure */
1350 complete_all(&hda->probe_wait);
1353 if (chip->disabled && hda->probe_continued)
1354 snd_hda_unlock_devices(&chip->bus);
1355 if (hda->vga_switcheroo_registered) {
1356 vga_switcheroo_unregister_client(chip->pci);
1359 * leaving the device probed but non-functional. As long
1365 dev_warn(&pci->dev, "GPU sound probed, but not operational: please add a quirk to driver_denylist\n");
1366 pm_runtime_disable(&pci->dev);
1367 pm_runtime_set_suspended(&pci->dev);
1368 pm_runtime_enable(&pci->dev);
1372 if (bus->chip_init) {
1378 if (bus->irq >= 0)
1379 free_irq(bus->irq, (void*)chip);
1386 release_firmware(chip->fw);
1390 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT)
1393 hda->freed = 1;
1398 struct azx *chip = device->device_data;
1401 chip->bus.shutdown = 1;
1402 cancel_work_sync(&bus->unsol_work);
1409 azx_free(device->device_data);
1423 if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) &&
1424 (pdev->class != PCI_CLASS_DISPLAY_OTHER << 8))
1427 dhandle = ACPI_HANDLE(&pdev->dev);
1453 switch (pci->vendor) {
1456 if (pci->devfn == 1) {
1457 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
1458 pci->bus->number, 0);
1473 if (pci->devfn == 1) {
1474 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus),
1475 pci->bus->number, 0);
1502 * allow/deny-listing for position_fix
1514 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1517 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1518 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1537 q = snd_pci_quirk_lookup(chip->pci, position_fix_list);
1539 dev_info(chip->card->dev,
1541 q->value, q->subvendor, q->subdevice);
1542 return q->value;
1546 if (chip->driver_type == AZX_DRIVER_VIA) {
1547 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n");
1550 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) {
1551 dev_dbg(chip->card->dev, "Using FIFO position fix\n");
1554 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) {
1555 dev_dbg(chip->card->dev, "Using LPIB position fix\n");
1558 if (chip->driver_type == AZX_DRIVER_SKL) {
1559 dev_dbg(chip->card->dev, "Using SKL position fix\n");
1577 chip->get_position[0] = chip->get_position[1] = callbacks[fix];
1581 chip->get_position[1] = NULL;
1584 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) {
1585 chip->get_delay[0] = chip->get_delay[1] =
1590 chip->get_delay[0] = chip->get_delay[1] =
1595 * deny-lists for probe_mask
1599 * to the non-working (or non-existing) modem codec slot.
1623 chip->codec_probe_mask = probe_mask[dev];
1624 if (chip->codec_probe_mask == -1) {
1625 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list);
1627 dev_info(chip->card->dev,
1629 q->value, q->subvendor, q->subdevice);
1630 chip->codec_probe_mask = q->value;
1635 if (chip->codec_probe_mask != -1 &&
1636 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) {
1637 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff;
1638 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n",
1639 (int)azx_bus(chip)->codec_mask);
1644 * allow/deny-list for enable_msi
1656 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1665 chip->msi = !!enable_msi;
1668 chip->msi = 1; /* enable MSI as default */
1669 q = snd_pci_quirk_lookup(chip->pci, msi_deny_list);
1671 dev_info(chip->card->dev,
1673 q->subvendor, q->subdevice, q->value);
1674 chip->msi = q->value;
1679 if (chip->driver_caps & AZX_DCAPS_NO_MSI) {
1680 dev_info(chip->card->dev, "Disabling MSI\n");
1681 chip->msi = 0;
1691 dev_info(chip->card->dev, "Force to %s mode by module option\n",
1692 snoop ? "snoop" : "non-snoop");
1693 chip->snoop = snoop;
1694 chip->uc_buffer = !snoop;
1700 chip->driver_type == AZX_DRIVER_VIA) {
1701 /* force to non-snoop mode for a new VIA controller
1705 pci_read_config_byte(chip->pci, 0x42, &val);
1706 if (!(val & 0x80) && (chip->pci->revision == 0x30 ||
1707 chip->pci->revision == 0x20))
1711 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF)
1714 chip->snoop = snoop;
1716 dev_info(chip->card->dev, "Force to non-snoop mode\n");
1717 /* C-Media requires non-cached pages only for CORB/RIRB */
1718 if (chip->driver_type != AZX_DRIVER_CMEDIA)
1719 chip->uc_buffer = true;
1726 azx_probe_continue(&hda->chip);
1732 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) {
1733 switch (chip->pci->device) {
1742 switch (chip->driver_type) {
1782 hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL);
1784 return -ENOMEM;
1786 chip = &hda->chip;
1787 mutex_init(&chip->open_mutex);
1788 chip->card = card;
1789 chip->pci = pci;
1790 chip->ops = &pci_hda_ops;
1791 chip->driver_caps = driver_caps;
1792 chip->driver_type = driver_caps & 0xff;
1794 chip->dev_index = dev;
1796 chip->jackpoll_interval = msecs_to_jiffies(jackpoll_ms[dev]);
1797 INIT_LIST_HEAD(&chip->pcm_list);
1798 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work);
1799 INIT_LIST_HEAD(&hda->list);
1801 init_completion(&hda->probe_wait);
1806 chip->fallback_to_single_cmd = 1;
1808 chip->single_cmd = single_cmd;
1813 chip->bdl_pos_adj = default_bdl_pos_adj(chip);
1815 chip->bdl_pos_adj = bdl_pos_adj[dev];
1821 /* use the non-cached pages in non-snoop mode */
1823 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC;
1825 if (chip->driver_type == AZX_DRIVER_NVIDIA) {
1826 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");
1827 chip->bus.core.needs_damn_long_delay = 1;
1834 dev_err(card->dev, "Error creating device [card]!\n");
1840 INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work);
1849 int dev = chip->dev_index;
1850 struct pci_dev *pci = chip->pci;
1851 struct snd_card *card = chip->card;
1859 if (chip->driver_type == AZX_DRIVER_ULI) {
1870 if (chip->driver_type == AZX_DRIVER_GFHDMI)
1871 bus->polling_mode = 1;
1873 if (chip->driver_type == AZX_DRIVER_LOONGSON) {
1874 bus->polling_mode = 1;
1875 bus->not_use_interrupts = 1;
1876 bus->access_sdnctl_in_dword = 1;
1877 if (!chip->jackpoll_interval)
1878 chip->jackpoll_interval = msecs_to_jiffies(1500);
1881 if (chip->driver_type == AZX_DRIVER_ZHAOXINHDMI)
1882 bus->polling_mode = 1;
1884 bus->remap_addr = pcim_iomap_region(pci, 0, "ICH HD audio");
1885 if (IS_ERR(bus->remap_addr))
1886 return PTR_ERR(bus->remap_addr);
1888 bus->addr = pci_resource_start(pci, 0);
1890 if (chip->driver_type == AZX_DRIVER_SKL)
1899 chip->gts_present = false;
1902 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART))
1903 chip->gts_present = true;
1906 if (chip->msi && chip->driver_caps & AZX_DCAPS_NO_MSI64) {
1907 dev_dbg(card->dev, "Disabling 64bit MSI\n");
1908 pci->no_64bit_msi = true;
1914 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap);
1917 if (chip->pci->vendor == PCI_VENDOR_ID_AMD)
1921 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) {
1928 if (p_smbus->revision < 0x30)
1935 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA)
1939 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) {
1940 dev_dbg(card->dev, "Disabling 64bit DMA\n");
1944 /* disable buffer size rounding to 128-byte multiples if supported */
1946 chip->align_buffer_size = !!align_buffer_size;
1948 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE)
1949 chip->align_buffer_size = 0;
1951 chip->align_buffer_size = 1;
1957 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
1958 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
1959 dma_set_max_seg_size(&pci->dev, UINT_MAX);
1964 chip->capture_streams = (gcap >> 8) & 0x0f;
1965 chip->playback_streams = (gcap >> 12) & 0x0f;
1966 if (!chip->playback_streams && !chip->capture_streams) {
1969 switch (chip->driver_type) {
1971 chip->playback_streams = ULI_NUM_PLAYBACK;
1972 chip->capture_streams = ULI_NUM_CAPTURE;
1976 chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
1977 chip->capture_streams = ATIHDMI_NUM_CAPTURE;
1983 chip->playback_streams = ICH6_NUM_PLAYBACK;
1984 chip->capture_streams = ICH6_NUM_CAPTURE;
1988 chip->capture_index_offset = 0;
1989 chip->playback_index_offset = chip->capture_streams;
1990 chip->num_streams = chip->playback_streams + chip->capture_streams;
1992 /* sanity check for the SDxCTL.STRM field overflow */
1993 if (chip->num_streams > 15 &&
1994 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) {
1995 dev_warn(chip->card->dev, "number of I/O streams is %d, "
1996 "forcing separate stream tags", chip->num_streams);
1997 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG;
2017 if (!azx_bus(chip)->codec_mask) {
2018 dev_err(card->dev, "no codecs found!\n");
2023 return -EBUSY;
2025 strscpy(card->driver, "HDA-Intel");
2026 strscpy(card->shortname, driver_short_names[chip->driver_type],
2027 sizeof(card->shortname));
2028 snprintf(card->longname, sizeof(card->longname),
2030 card->shortname, bus->addr, bus->irq);
2040 struct azx *chip = card->private_data;
2043 chip->fw = fw;
2045 dev_err(card->dev, "Cannot load firmware, continue without patching\n");
2046 if (!chip->disabled) {
2058 free_irq(bus->irq, chip);
2059 bus->irq = -1;
2060 chip->card->sync_irq = -1;
2061 pci_free_irq_vectors(chip->pci);
2062 chip->msi = 0;
2071 * some HD-audio PCI entries are exposed without any codecs, and such devices
2087 /* DMI-based denylist, to be used when:
2088 * - PCI subsystem IDs are zero, impossible to distinguish from valid sound cards.
2089 * - Different modifications of the same laptop use different GPU models.
2122 dev_info(&pci->dev, "Skipping the device on the denylist\n");
2123 return -ENODEV;
2127 if (dmi && pci_match_id(dmi->driver_data, pci)) {
2128 dev_info(&pci->dev, "Skipping the device on the DMI denylist\n");
2129 return -ENODEV;
2134 return -ENODEV;
2137 return -ENOENT;
2146 dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n");
2147 return -ENODEV;
2150 dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option instead\n");
2153 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2156 dev_err(&pci->dev, "Error creating card!\n");
2160 err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
2163 card->private_data = chip;
2170 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) {
2173 if (err == -EPROBE_DEFER)
2182 dev_err_probe(card->dev, err,
2183 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n");
2188 chip->driver_caps &= ~AZX_DCAPS_I915_COMPONENT;
2194 hda->need_i915_power = true;
2198 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n");
2203 dev_err(card->dev, "Error registering vga_switcheroo client\n");
2208 dev_info(card->dev, "VGA controller is disabled\n");
2209 dev_info(card->dev, "Delaying initialization\n");
2210 chip->disabled = true;
2213 schedule_probe = !chip->disabled;
2217 dev_info(card->dev, "Applying patch firmware '%s'\n",
2220 &pci->dev, GFP_KERNEL, card,
2229 schedule_delayed_work(&hda->probe_work, 0);
2232 if (chip->disabled)
2233 complete_all(&hda->probe_wait);
2250 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2252 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2254 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2256 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2260 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2261 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2263 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2296 q = snd_pci_quirk_lookup(chip->pci, power_save_denylist);
2298 dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0\n",
2299 q->subvendor, q->subdevice);
2301 hda->runtime_pm_disabled = 1;
2304 dev_info(chip->card->dev, "Forcing power_save to 0 via option\n");
2307 snd_hda_set_power_save(&chip->bus, val * 1000);
2320 struct pci_dev *pci = chip->pci;
2321 int dev = chip->dev_index;
2324 if (chip->disabled || hda->init_failed)
2325 return -EIO;
2326 if (hda->probe_retry)
2329 to_hda_bus(bus)->bus_probing = 1;
2330 hda->probe_continued = 1;
2344 chip->beep_mode = beep_mode[dev];
2347 chip->ctl_dev_id = ctl_dev_id;
2350 if (bus->codec_mask) {
2351 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]);
2357 if (chip->fw) {
2358 err = snd_hda_load_patch(&chip->bus, chip->fw->size,
2359 chip->fw->data);
2366 if (bus->codec_mask && !(probe_only[dev] & 1)) {
2369 if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) &&
2370 ++hda->probe_retry < 60) {
2371 schedule_delayed_work(&hda->probe_work,
2375 dev_err(chip->card->dev, "Cannot probe codecs, giving up\n");
2380 err = snd_card_register(chip->card);
2386 chip->running = 1;
2392 pm_runtime_use_autosuspend(&pci->dev);
2393 pm_runtime_allow(&pci->dev);
2394 pm_runtime_put_autosuspend(&pci->dev);
2400 snd_card_free(chip->card);
2404 if (!hda->need_i915_power)
2406 complete_all(&hda->probe_wait);
2407 to_hda_bus(bus)->bus_probing = 0;
2408 hda->probe_retry = 0;
2420 chip = card->private_data;
2433 device_unlock(&pci->dev);
2434 cancel_delayed_work_sync(&hda->probe_work);
2435 device_lock(&pci->dev);
2437 clear_bit(chip->dev_index, probed_devs);
2450 chip = card->private_data;
2451 if (chip && chip->running)
2473 /* Lynx Point-LP */
2475 /* Lynx Point-LP */
2477 /* Wildcat Point-LP */
2481 /* Skylake-LP (Sunrise Point-LP) */
2485 /* Kabylake-LP */
2487 /* Kabylake-H */
2493 /* CometLake-LP */
2495 /* CometLake-H */
2498 /* CometLake-S */
2500 /* CometLake-R */
2504 /* Icelake-H */
2511 /* Tigerlake-H */
2519 /* Alderlake-S */
2521 /* Alderlake-P */
2525 /* Alderlake-M */
2527 /* Alderlake-N */
2541 /* Lunarlake-P */
2543 /* Arrow Lake-S */
2549 /* Panther Lake-H */
2553 /* Apollolake (Broxton-P) */
2555 /* Gemini-Lake */
2755 /* Creative X-Fi (CA0110-IBG) */
2762 /* the following entry conflicts with snd-ctxfi driver,
2763 * as ctxfi driver mutates from HD-audio to native mode with
2772 /* this entry seems still valid -- i.e. without emu20kx chip */