Lines Matching +full:timeout +full:- +full:ati +full:- +full:ms
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>
50 #include <sound/intel-dsp-config.h>
53 #include <linux/apple-gmux.h>
73 /* Defines for ATI HD Audio support in SB450 south bridge */
91 /* ICH, ATI and VIA have 4 playback and 4 capture */
99 /* ATI HDMI may have up to 8 playbacks and 0 capture */
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).");
143 MODULE_PARM_DESC(jackpoll_ms, "Ms between polling for jack events (default = 0, using unsol events …
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;
248 (((chip)->driver_caps & AZX_DCAPS_SNOOP_MASK) >> 10)
297 /* quirks for ATI SB / AMD Hudson */
300 AZX_DCAPS_SNOOP_TYPE(ATI))
302 /* quirks for ATI/AMD HDMI */
307 /* quirks for ATI HDMI with snoop off */
314 AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME |\
331 #define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo)
332 #define needs_eld_notify_link(chip) ((chip)->bus.keep_power)
344 [AZX_DRIVER_ATI] = "HDA ATI SB",
345 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
346 [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI",
355 [AZX_DRIVER_CMEDIA] = "HDA C-Media",
358 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
383 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) in azx_init_pci()
389 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) { in azx_init_pci()
390 dev_dbg(chip->card->dev, "Clearing TCSEL\n"); in azx_init_pci()
391 update_pci_byte(chip->pci, AZX_PCIREG_TCSEL, 0x07, 0); in azx_init_pci()
394 /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio, in azx_init_pci()
398 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n", in azx_init_pci()
400 update_pci_byte(chip->pci, in azx_init_pci()
407 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n", in azx_init_pci()
409 update_pci_byte(chip->pci, in azx_init_pci()
412 update_pci_byte(chip->pci, in azx_init_pci()
415 update_pci_byte(chip->pci, in azx_init_pci()
423 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); in azx_init_pci()
429 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop); in azx_init_pci()
430 pci_read_config_word(chip->pci, in azx_init_pci()
433 dev_dbg(chip->card->dev, "SCH snoop: %s\n", in azx_init_pci()
440 * In BXT-P A0, HD-Audio DMA requests is later than expected,
471 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCAP); in intel_get_lctl_scf()
479 dev_warn(chip->card->dev, "set audio clock frequency to 6MHz"); in intel_get_lctl_scf()
487 int timeout; in intel_ml_lctl_set_power() local
490 * Changes to LCTL.SCF are only needed for the first multi-link dealing in intel_ml_lctl_set_power()
493 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
496 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
498 timeout = 50; in intel_ml_lctl_set_power()
499 while (timeout) { in intel_ml_lctl_set_power()
500 if (((readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL)) & in intel_ml_lctl_set_power()
503 timeout--; in intel_ml_lctl_set_power()
507 return -1; in intel_ml_lctl_set_power()
517 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
539 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
550 struct pci_dev *pci = chip->pci; in hda_intel_init_chip()
554 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
560 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
572 if (bus->mlcap != NULL) in hda_intel_init_chip()
580 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_lpib()
581 int stream = substream->stream; in azx_get_delay_from_lpib()
586 delay = pos - lpib_pos; in azx_get_delay_from_lpib()
588 delay = lpib_pos - pos; in azx_get_delay_from_lpib()
590 if (delay >= azx_dev->core.delay_negative_threshold) in azx_get_delay_from_lpib()
593 delay += azx_dev->core.bufsize; in azx_get_delay_from_lpib()
596 if (delay >= azx_dev->core.period_bytes) { in azx_get_delay_from_lpib()
597 dev_info(chip->card->dev, in azx_get_delay_from_lpib()
599 delay, azx_dev->core.period_bytes); in azx_get_delay_from_lpib()
601 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; in azx_get_delay_from_lpib()
602 chip->get_delay[stream] = NULL; in azx_get_delay_from_lpib()
605 return bytes_to_frames(substream->runtime, delay); in azx_get_delay_from_lpib()
618 azx_dev->irq_pending = 0; in azx_position_check()
622 azx_dev->irq_pending = 1; in azx_position_check()
623 schedule_work(&hda->irq_pending_work); in azx_position_check()
633 * periods. Returns non-zero if it's OK.
635 * Many HD-audio controllers appear pretty inaccurate about
636 * the update-IRQ timing. The IRQ is issued before actually the
640 * Returns 1 if OK to proceed, 0 for delay handling, -1 for skipping update
644 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_position_ok()
645 struct snd_pcm_runtime *runtime = substream->runtime; in azx_position_ok()
646 int stream = substream->stream; in azx_position_ok()
655 if (chip->driver_type == AZX_DRIVER_LOONGSON) in azx_position_ok()
658 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk; in azx_position_ok()
659 if (wallclk < (azx_dev->core.period_wallclk * 2) / 3) in azx_position_ok()
660 return -1; /* bogus (too early) interrupt */ in azx_position_ok()
662 if (chip->get_position[stream]) in azx_position_ok()
663 pos = chip->get_position[stream](chip, azx_dev); in azx_position_ok()
666 if (!pos || pos == (u32)-1) { in azx_position_ok()
667 dev_info(chip->card->dev, in azx_position_ok()
669 chip->get_position[stream] = azx_get_pos_lpib; in azx_position_ok()
670 if (chip->get_position[0] == azx_get_pos_lpib && in azx_position_ok()
671 chip->get_position[1] == azx_get_pos_lpib) in azx_position_ok()
672 azx_bus(chip)->use_posbuf = false; in azx_position_ok()
674 chip->get_delay[stream] = NULL; in azx_position_ok()
676 chip->get_position[stream] = azx_get_pos_posbuf; in azx_position_ok()
677 if (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY) in azx_position_ok()
678 chip->get_delay[stream] = azx_get_delay_from_lpib; in azx_position_ok()
682 if (pos >= azx_dev->core.bufsize) in azx_position_ok()
685 if (WARN_ONCE(!azx_dev->core.period_bytes, in azx_position_ok()
686 "hda-intel: zero azx_dev->period_bytes")) in azx_position_ok()
687 return -1; /* this shouldn't happen! */ in azx_position_ok()
688 if (wallclk < (azx_dev->core.period_wallclk * 5) / 4 && in azx_position_ok()
689 pos % azx_dev->core.period_bytes > azx_dev->core.period_bytes / 2) in azx_position_ok()
690 /* NG - it's below the first next period boundary */ in azx_position_ok()
691 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
692 azx_dev->core.start_wallclk += wallclk; in azx_position_ok()
694 if (azx_dev->core.no_period_wakeup) in azx_position_ok()
697 if (runtime->hw_ptr_base != runtime->hw_ptr_interrupt) in azx_position_ok()
702 hwptr = runtime->hw_ptr_base + pos; in azx_position_ok()
703 if (hwptr < runtime->status->hw_ptr) in azx_position_ok()
704 hwptr += runtime->buffer_size; in azx_position_ok()
705 target = runtime->hw_ptr_interrupt + runtime->period_size; in azx_position_ok()
708 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
720 struct azx *chip = &hda->chip; in azx_irq_pending_work()
725 if (!hda->irq_pending_warned) { in azx_irq_pending_work()
726 dev_info(chip->card->dev, in azx_irq_pending_work()
728 chip->card->number); in azx_irq_pending_work()
729 hda->irq_pending_warned = 1; in azx_irq_pending_work()
734 spin_lock_irq(&bus->reg_lock); in azx_irq_pending_work()
735 list_for_each_entry(s, &bus->stream_list, list) { in azx_irq_pending_work()
737 if (!azx_dev->irq_pending || in azx_irq_pending_work()
738 !s->substream || in azx_irq_pending_work()
739 !s->running) in azx_irq_pending_work()
743 azx_dev->irq_pending = 0; in azx_irq_pending_work()
744 spin_unlock(&bus->reg_lock); in azx_irq_pending_work()
745 snd_pcm_period_elapsed(s->substream); in azx_irq_pending_work()
746 spin_lock(&bus->reg_lock); in azx_irq_pending_work()
752 spin_unlock_irq(&bus->reg_lock); in azx_irq_pending_work()
759 /* clear irq_pending flags and assure no on-going workq */
765 spin_lock_irq(&bus->reg_lock); in azx_clear_irq_pending()
766 list_for_each_entry(s, &bus->stream_list, list) { in azx_clear_irq_pending()
768 azx_dev->irq_pending = 0; in azx_clear_irq_pending()
770 spin_unlock_irq(&bus->reg_lock); in azx_clear_irq_pending()
778 if (!chip->msi || pci_alloc_irq_vectors(chip->pci, 1, 1, PCI_IRQ_MSI) < 0) { in azx_acquire_irq()
779 ret = pci_alloc_irq_vectors(chip->pci, 1, 1, PCI_IRQ_INTX); in azx_acquire_irq()
782 chip->msi = 0; in azx_acquire_irq()
785 if (request_irq(chip->pci->irq, azx_interrupt, in azx_acquire_irq()
786 chip->msi ? 0 : IRQF_SHARED, in azx_acquire_irq()
787 chip->card->irq_descr, chip)) { in azx_acquire_irq()
788 dev_err(chip->card->dev, in azx_acquire_irq()
790 chip->pci->irq); in azx_acquire_irq()
792 snd_card_disconnect(chip->card); in azx_acquire_irq()
793 return -1; in azx_acquire_irq()
795 bus->irq = chip->pci->irq; in azx_acquire_irq()
796 chip->card->sync_irq = bus->irq; in azx_acquire_irq()
809 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in azx_via_get_position()
818 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); in azx_via_get_position()
819 mod_dma_pos %= azx_dev->core.period_bytes; in azx_via_get_position()
821 fifo_size = azx_stream(azx_dev)->fifo_size; in azx_via_get_position()
823 if (azx_dev->insufficient) { in azx_via_get_position()
828 azx_dev->insufficient = 0; in azx_via_get_position()
832 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; in azx_via_get_position()
834 mini_pos = link_pos - fifo_size; in azx_via_get_position()
837 mod_mini_pos = mini_pos % azx_dev->core.period_bytes; in azx_via_get_position()
838 mod_link_pos = link_pos % azx_dev->core.period_bytes; in azx_via_get_position()
840 bound_pos = link_pos - mod_link_pos; in azx_via_get_position()
842 bound_pos = mini_pos - mod_mini_pos; in azx_via_get_position()
844 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; in azx_via_get_position()
845 if (bound_pos >= azx_dev->core.bufsize) in azx_via_get_position()
858 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_pos_fifo()
859 struct snd_pcm_runtime *runtime = substream->runtime; in azx_get_pos_fifo()
866 runtime->delay = AMD_FIFO_SIZE; in azx_get_pos_fifo()
868 if (azx_dev->insufficient) { in azx_get_pos_fifo()
871 runtime->delay = bytes_to_frames(runtime, pos); in azx_get_pos_fifo()
873 azx_dev->insufficient = 0; in azx_get_pos_fifo()
878 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in azx_get_pos_fifo()
880 pos += azx_dev->core.bufsize; in azx_get_pos_fifo()
881 pos -= delay; in azx_get_pos_fifo()
890 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_fifo()
893 return substream->runtime->delay; in azx_get_delay_from_fifo()
917 list_add(&hda->list, &card_list); in azx_add_card_list()
925 list_del_init(&hda->list); in azx_del_card_list()
929 /* trigger power-save check at writing parameter */
945 chip = &hda->chip; in param_set_xint()
946 if (!hda->probe_continued || chip->disabled || in param_set_xint()
947 hda->runtime_pm_disabled) in param_set_xint()
949 snd_hda_set_power_save(&chip->bus, power_save * 1000); in param_set_xint()
965 chip = card->private_data; in azx_is_pm_ready()
967 if (chip->disabled || hda->init_failed || !chip->running) in azx_is_pm_ready()
980 if (hda->need_i915_power) in __azx_runtime_resume()
990 if (!chip->pm_prepared) { in __azx_runtime_resume()
991 list_for_each_codec(codec, &chip->bus) { in __azx_runtime_resume()
992 if (codec->relaxed_resume) in __azx_runtime_resume()
995 if (codec->forced_resume || (status & (1 << codec->addr))) in __azx_runtime_resume()
1000 /* power down again for link-controlled chips */ in __azx_runtime_resume()
1001 if (!hda->need_i915_power) in __azx_runtime_resume()
1013 chip = card->private_data; in azx_prepare()
1014 chip->pm_prepared = 1; in azx_prepare()
1017 flush_work(&azx_bus(chip)->unsol_work); in azx_prepare()
1020 * and system suspend, so don't use direct-complete here. in azx_prepare()
1033 chip = card->private_data; in azx_complete()
1035 chip->pm_prepared = 0; in azx_complete()
1046 chip = card->private_data; in azx_suspend()
1061 chip = card->private_data; in azx_resume()
1075 struct azx *chip = card->private_data; in azx_freeze_noirq()
1080 if (chip->driver_type == AZX_DRIVER_SKL) in azx_freeze_noirq()
1089 struct azx *chip = card->private_data; in azx_thaw_noirq()
1094 if (chip->driver_type == AZX_DRIVER_SKL) in azx_thaw_noirq()
1107 chip = card->private_data; in azx_runtime_suspend()
1124 chip = card->private_data; in azx_runtime_resume()
1143 chip = card->private_data; in azx_runtime_idle()
1145 if (chip->disabled || hda->init_failed) in azx_runtime_idle()
1149 azx_bus(chip)->codec_powered || !chip->running) in azx_runtime_idle()
1150 return -EBUSY; in azx_runtime_idle()
1152 /* ELD notification gets broken when HD-audio bus is off */ in azx_runtime_idle()
1154 return -EBUSY; in azx_runtime_idle()
1178 struct azx *chip = card->private_data; in azx_vs_set_state()
1183 wait_for_completion(&hda->probe_wait); in azx_vs_set_state()
1184 if (hda->init_failed) in azx_vs_set_state()
1188 if (chip->disabled == disabled) in azx_vs_set_state()
1191 if (!hda->probe_continued) { in azx_vs_set_state()
1192 chip->disabled = disabled; in azx_vs_set_state()
1194 dev_info(chip->card->dev, in azx_vs_set_state()
1197 dev_err(chip->card->dev, "initialization error\n"); in azx_vs_set_state()
1200 dev_info(chip->card->dev, "%s via vga_switcheroo\n", in azx_vs_set_state()
1203 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1207 pm_runtime_suspend(card->dev); in azx_vs_set_state()
1208 pm_runtime_disable(card->dev); in azx_vs_set_state()
1212 pci->current_state = PCI_D3cold; in azx_vs_set_state()
1213 chip->disabled = true; in azx_vs_set_state()
1214 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_set_state()
1215 dev_warn(chip->card->dev, in azx_vs_set_state()
1218 snd_hda_unlock_devices(&chip->bus); in azx_vs_set_state()
1219 chip->disabled = false; in azx_vs_set_state()
1220 pm_runtime_enable(card->dev); in azx_vs_set_state()
1221 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1232 struct azx *chip = card->private_data; in azx_vs_can_switch()
1235 wait_for_completion(&hda->probe_wait); in azx_vs_can_switch()
1236 if (hda->init_failed) in azx_vs_can_switch()
1238 if (chip->disabled || !hda->probe_continued) in azx_vs_can_switch()
1240 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_can_switch()
1242 snd_hda_unlock_devices(&chip->bus); in azx_vs_can_switch()
1255 if (hda->use_vga_switcheroo && !needs_eld_notify_link(chip)) { in setup_vga_switcheroo_runtime_pm()
1256 list_for_each_codec(codec, &chip->bus) in setup_vga_switcheroo_runtime_pm()
1257 codec->auto_runtime_pm = 1; in setup_vga_switcheroo_runtime_pm()
1259 if (chip->running) in setup_vga_switcheroo_runtime_pm()
1268 struct azx *chip = card->private_data; in azx_vs_gpu_bound()
1271 chip->bus.keep_power = 0; in azx_vs_gpu_bound()
1278 struct pci_dev *p = get_bound_vga(chip->pci); in init_vga_switcheroo()
1281 dev_info(chip->card->dev, in init_vga_switcheroo()
1283 hda->use_vga_switcheroo = 1; in init_vga_switcheroo()
1289 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1; in init_vga_switcheroo()
1290 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME; in init_vga_switcheroo()
1307 if (!hda->use_vga_switcheroo) in register_vga_switcheroo()
1310 p = get_bound_vga(chip->pci); in register_vga_switcheroo()
1311 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p); in register_vga_switcheroo()
1316 hda->vga_switcheroo_registered = 1; in register_vga_switcheroo()
1332 struct pci_dev *pci = chip->pci; in azx_free()
1336 if (hda->freed) in azx_free()
1339 if (azx_has_pm_runtime(chip) && chip->running) { in azx_free()
1340 pm_runtime_get_noresume(&pci->dev); in azx_free()
1341 pm_runtime_forbid(&pci->dev); in azx_free()
1342 pm_runtime_dont_use_autosuspend(&pci->dev); in azx_free()
1345 chip->running = 0; in azx_free()
1349 hda->init_failed = 1; /* to be sure */ in azx_free()
1350 complete_all(&hda->probe_wait); in azx_free()
1353 if (chip->disabled && hda->probe_continued) in azx_free()
1354 snd_hda_unlock_devices(&chip->bus); in azx_free()
1355 if (hda->vga_switcheroo_registered) in azx_free()
1356 vga_switcheroo_unregister_client(chip->pci); in azx_free()
1359 if (bus->chip_init) { in azx_free()
1365 if (bus->irq >= 0) in azx_free()
1366 free_irq(bus->irq, (void*)chip); in azx_free()
1373 release_firmware(chip->fw); in azx_free()
1377 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) in azx_free()
1380 hda->freed = 1; in azx_free()
1385 struct azx *chip = device->device_data; in azx_dev_disconnect()
1388 chip->bus.shutdown = 1; in azx_dev_disconnect()
1389 cancel_work_sync(&bus->unsol_work); in azx_dev_disconnect()
1396 azx_free(device->device_data); in azx_dev_free()
1410 if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) && in atpx_present()
1411 (pdev->class != PCI_CLASS_DISPLAY_OTHER << 8)) in atpx_present()
1414 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1440 switch (pci->vendor) { in get_bound_vga()
1443 if (pci->devfn == 1) { in get_bound_vga()
1444 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1445 pci->bus->number, 0); in get_bound_vga()
1452 if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) && in get_bound_vga()
1460 if (pci->devfn == 1) { in get_bound_vga()
1461 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1462 pci->bus->number, 0); in get_bound_vga()
1464 if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) in get_bound_vga()
1489 * allow/deny-listing for position_fix
1501 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1504 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1505 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1524 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); in check_position_fix()
1526 dev_info(chip->card->dev, in check_position_fix()
1528 q->value, q->subvendor, q->subdevice); in check_position_fix()
1529 return q->value; in check_position_fix()
1532 /* Check VIA/ATI HD Audio Controller exist */ in check_position_fix()
1533 if (chip->driver_type == AZX_DRIVER_VIA) { in check_position_fix()
1534 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); in check_position_fix()
1537 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) { in check_position_fix()
1538 dev_dbg(chip->card->dev, "Using FIFO position fix\n"); in check_position_fix()
1541 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { in check_position_fix()
1542 dev_dbg(chip->card->dev, "Using LPIB position fix\n"); in check_position_fix()
1545 if (chip->driver_type == AZX_DRIVER_SKL) { in check_position_fix()
1546 dev_dbg(chip->card->dev, "Using SKL position fix\n"); in check_position_fix()
1564 chip->get_position[0] = chip->get_position[1] = callbacks[fix]; in assign_position_fix()
1568 chip->get_position[1] = NULL; in assign_position_fix()
1571 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { in assign_position_fix()
1572 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1577 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1582 * deny-lists for probe_mask
1586 * to the non-working (or non-existing) modem codec slot.
1610 chip->codec_probe_mask = probe_mask[dev]; in check_probe_mask()
1611 if (chip->codec_probe_mask == -1) { in check_probe_mask()
1612 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); in check_probe_mask()
1614 dev_info(chip->card->dev, in check_probe_mask()
1616 q->value, q->subvendor, q->subdevice); in check_probe_mask()
1617 chip->codec_probe_mask = q->value; in check_probe_mask()
1622 if (chip->codec_probe_mask != -1 && in check_probe_mask()
1623 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { in check_probe_mask()
1624 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff; in check_probe_mask()
1625 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n", in check_probe_mask()
1626 (int)azx_bus(chip)->codec_mask); in check_probe_mask()
1631 * allow/deny-list for enable_msi
1643 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1652 chip->msi = !!enable_msi; in check_msi()
1655 chip->msi = 1; /* enable MSI as default */ in check_msi()
1656 q = snd_pci_quirk_lookup(chip->pci, msi_deny_list); in check_msi()
1658 dev_info(chip->card->dev, in check_msi()
1660 q->subvendor, q->subdevice, q->value); in check_msi()
1661 chip->msi = q->value; in check_msi()
1666 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { in check_msi()
1667 dev_info(chip->card->dev, "Disabling MSI\n"); in check_msi()
1668 chip->msi = 0; in check_msi()
1678 dev_info(chip->card->dev, "Force to %s mode by module option\n", in azx_check_snoop_available()
1679 snoop ? "snoop" : "non-snoop"); in azx_check_snoop_available()
1680 chip->snoop = snoop; in azx_check_snoop_available()
1681 chip->uc_buffer = !snoop; in azx_check_snoop_available()
1687 chip->driver_type == AZX_DRIVER_VIA) { in azx_check_snoop_available()
1688 /* force to non-snoop mode for a new VIA controller in azx_check_snoop_available()
1692 pci_read_config_byte(chip->pci, 0x42, &val); in azx_check_snoop_available()
1693 if (!(val & 0x80) && (chip->pci->revision == 0x30 || in azx_check_snoop_available()
1694 chip->pci->revision == 0x20)) in azx_check_snoop_available()
1698 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) in azx_check_snoop_available()
1701 chip->snoop = snoop; in azx_check_snoop_available()
1703 dev_info(chip->card->dev, "Force to non-snoop mode\n"); in azx_check_snoop_available()
1704 /* C-Media requires non-cached pages only for CORB/RIRB */ in azx_check_snoop_available()
1705 if (chip->driver_type != AZX_DRIVER_CMEDIA) in azx_check_snoop_available()
1706 chip->uc_buffer = true; in azx_check_snoop_available()
1713 azx_probe_continue(&hda->chip); in azx_probe_work()
1719 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) { in default_bdl_pos_adj()
1720 switch (chip->pci->device) { in default_bdl_pos_adj()
1729 switch (chip->driver_type) { in default_bdl_pos_adj()
1767 hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL); in azx_create()
1769 return -ENOMEM; in azx_create()
1771 chip = &hda->chip; in azx_create()
1772 mutex_init(&chip->open_mutex); in azx_create()
1773 chip->card = card; in azx_create()
1774 chip->pci = pci; in azx_create()
1775 chip->ops = &pci_hda_ops; in azx_create()
1776 chip->driver_caps = driver_caps; in azx_create()
1777 chip->driver_type = driver_caps & 0xff; in azx_create()
1779 chip->dev_index = dev; in azx_create()
1781 chip->jackpoll_interval = msecs_to_jiffies(jackpoll_ms[dev]); in azx_create()
1782 INIT_LIST_HEAD(&chip->pcm_list); in azx_create()
1783 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); in azx_create()
1784 INIT_LIST_HEAD(&hda->list); in azx_create()
1786 init_completion(&hda->probe_wait); in azx_create()
1791 chip->fallback_to_single_cmd = 1; in azx_create()
1793 chip->single_cmd = single_cmd; in azx_create()
1798 chip->bdl_pos_adj = default_bdl_pos_adj(chip); in azx_create()
1800 chip->bdl_pos_adj = bdl_pos_adj[dev]; in azx_create()
1806 /* use the non-cached pages in non-snoop mode */ in azx_create()
1808 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC; in azx_create()
1810 if (chip->driver_type == AZX_DRIVER_NVIDIA) { in azx_create()
1811 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); in azx_create()
1812 chip->bus.core.needs_damn_long_delay = 1; in azx_create()
1819 dev_err(card->dev, "Error creating device [card]!\n"); in azx_create()
1825 INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work); in azx_create()
1834 int dev = chip->dev_index; in azx_first_init()
1835 struct pci_dev *pci = chip->pci; in azx_first_init()
1836 struct snd_card *card = chip->card; in azx_first_init()
1844 if (chip->driver_type == AZX_DRIVER_ULI) { in azx_first_init()
1855 if (chip->driver_type == AZX_DRIVER_GFHDMI) in azx_first_init()
1856 bus->polling_mode = 1; in azx_first_init()
1858 if (chip->driver_type == AZX_DRIVER_LOONGSON) { in azx_first_init()
1859 bus->polling_mode = 1; in azx_first_init()
1860 bus->not_use_interrupts = 1; in azx_first_init()
1861 bus->access_sdnctl_in_dword = 1; in azx_first_init()
1862 if (!chip->jackpoll_interval) in azx_first_init()
1863 chip->jackpoll_interval = msecs_to_jiffies(1500); in azx_first_init()
1870 bus->addr = pci_resource_start(pci, 0); in azx_first_init()
1871 bus->remap_addr = pcim_iomap_table(pci)[0]; in azx_first_init()
1873 if (chip->driver_type == AZX_DRIVER_SKL) in azx_first_init()
1882 chip->gts_present = false; in azx_first_init()
1885 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART)) in azx_first_init()
1886 chip->gts_present = true; in azx_first_init()
1889 if (chip->msi && chip->driver_caps & AZX_DCAPS_NO_MSI64) { in azx_first_init()
1890 dev_dbg(card->dev, "Disabling 64bit MSI\n"); in azx_first_init()
1891 pci->no_64bit_msi = true; in azx_first_init()
1897 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); in azx_first_init()
1900 if (chip->pci->vendor == PCI_VENDOR_ID_AMD) in azx_first_init()
1904 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { in azx_first_init()
1911 if (p_smbus->revision < 0x30) in azx_first_init()
1918 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA) in azx_first_init()
1922 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { in azx_first_init()
1923 dev_dbg(card->dev, "Disabling 64bit DMA\n"); in azx_first_init()
1927 /* disable buffer size rounding to 128-byte multiples if supported */ in azx_first_init()
1929 chip->align_buffer_size = !!align_buffer_size; in azx_first_init()
1931 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE) in azx_first_init()
1932 chip->align_buffer_size = 0; in azx_first_init()
1934 chip->align_buffer_size = 1; in azx_first_init()
1940 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits))) in azx_first_init()
1941 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1942 dma_set_max_seg_size(&pci->dev, UINT_MAX); in azx_first_init()
1947 chip->capture_streams = (gcap >> 8) & 0x0f; in azx_first_init()
1948 chip->playback_streams = (gcap >> 12) & 0x0f; in azx_first_init()
1949 if (!chip->playback_streams && !chip->capture_streams) { in azx_first_init()
1952 switch (chip->driver_type) { in azx_first_init()
1954 chip->playback_streams = ULI_NUM_PLAYBACK; in azx_first_init()
1955 chip->capture_streams = ULI_NUM_CAPTURE; in azx_first_init()
1959 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; in azx_first_init()
1960 chip->capture_streams = ATIHDMI_NUM_CAPTURE; in azx_first_init()
1965 chip->playback_streams = ICH6_NUM_PLAYBACK; in azx_first_init()
1966 chip->capture_streams = ICH6_NUM_CAPTURE; in azx_first_init()
1970 chip->capture_index_offset = 0; in azx_first_init()
1971 chip->playback_index_offset = chip->capture_streams; in azx_first_init()
1972 chip->num_streams = chip->playback_streams + chip->capture_streams; in azx_first_init()
1975 if (chip->num_streams > 15 && in azx_first_init()
1976 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) { in azx_first_init()
1977 dev_warn(chip->card->dev, "number of I/O streams is %d, " in azx_first_init()
1978 "forcing separate stream tags", chip->num_streams); in azx_first_init()
1979 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG; in azx_first_init()
1999 if (!azx_bus(chip)->codec_mask) { in azx_first_init()
2000 dev_err(card->dev, "no codecs found!\n"); in azx_first_init()
2005 return -EBUSY; in azx_first_init()
2007 strcpy(card->driver, "HDA-Intel"); in azx_first_init()
2008 strscpy(card->shortname, driver_short_names[chip->driver_type], in azx_first_init()
2009 sizeof(card->shortname)); in azx_first_init()
2010 snprintf(card->longname, sizeof(card->longname), in azx_first_init()
2012 card->shortname, bus->addr, bus->irq); in azx_first_init()
2022 struct azx *chip = card->private_data; in azx_firmware_cb()
2025 chip->fw = fw; in azx_firmware_cb()
2027 dev_err(card->dev, "Cannot load firmware, continue without patching\n"); in azx_firmware_cb()
2028 if (!chip->disabled) { in azx_firmware_cb()
2040 free_irq(bus->irq, chip); in disable_msi_reset_irq()
2041 bus->irq = -1; in disable_msi_reset_irq()
2042 chip->card->sync_irq = -1; in disable_msi_reset_irq()
2043 pci_free_irq_vectors(chip->pci); in disable_msi_reset_irq()
2044 chip->msi = 0; in disable_msi_reset_irq()
2053 * some HD-audio PCI entries are exposed without any codecs, and such devices
2082 dev_info(&pci->dev, "Skipping the device on the denylist\n"); in azx_probe()
2083 return -ENODEV; in azx_probe()
2088 return -ENODEV; in azx_probe()
2091 return -ENOENT; in azx_probe()
2100 dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n"); in azx_probe()
2101 return -ENODEV; in azx_probe()
2104 …dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option i… in azx_probe()
2107 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in azx_probe()
2110 dev_err(&pci->dev, "Error creating card!\n"); in azx_probe()
2114 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); in azx_probe()
2117 card->private_data = chip; in azx_probe()
2124 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) { in azx_probe()
2127 if (err == -EPROBE_DEFER) in azx_probe()
2136 dev_err_probe(card->dev, err, in azx_probe()
2137 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n"); in azx_probe()
2142 chip->driver_caps &= ~AZX_DCAPS_I915_COMPONENT; in azx_probe()
2148 hda->need_i915_power = true; in azx_probe()
2152 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n"); in azx_probe()
2157 dev_err(card->dev, "Error registering vga_switcheroo client\n"); in azx_probe()
2162 dev_info(card->dev, "VGA controller is disabled\n"); in azx_probe()
2163 dev_info(card->dev, "Delaying initialization\n"); in azx_probe()
2164 chip->disabled = true; in azx_probe()
2167 schedule_probe = !chip->disabled; in azx_probe()
2171 dev_info(card->dev, "Applying patch firmware '%s'\n", in azx_probe()
2174 &pci->dev, GFP_KERNEL, card, in azx_probe()
2183 schedule_delayed_work(&hda->probe_work, 0); in azx_probe()
2186 if (chip->disabled) in azx_probe()
2187 complete_all(&hda->probe_wait); in azx_probe()
2204 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2206 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2208 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2210 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2214 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2215 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2217 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2246 q = snd_pci_quirk_lookup(chip->pci, power_save_denylist); in set_default_power_save()
2248 …dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0… in set_default_power_save()
2249 q->subvendor, q->subdevice); in set_default_power_save()
2251 hda->runtime_pm_disabled = 1; in set_default_power_save()
2254 dev_info(chip->card->dev, "Forcing power_save to 0 via option\n"); in set_default_power_save()
2257 snd_hda_set_power_save(&chip->bus, val * 1000); in set_default_power_save()
2270 struct pci_dev *pci = chip->pci; in azx_probe_continue()
2271 int dev = chip->dev_index; in azx_probe_continue()
2274 if (chip->disabled || hda->init_failed) in azx_probe_continue()
2275 return -EIO; in azx_probe_continue()
2276 if (hda->probe_retry) in azx_probe_continue()
2279 to_hda_bus(bus)->bus_probing = 1; in azx_probe_continue()
2280 hda->probe_continued = 1; in azx_probe_continue()
2294 chip->beep_mode = beep_mode[dev]; in azx_probe_continue()
2297 chip->ctl_dev_id = ctl_dev_id; in azx_probe_continue()
2300 if (bus->codec_mask) { in azx_probe_continue()
2301 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); in azx_probe_continue()
2307 if (chip->fw) { in azx_probe_continue()
2308 err = snd_hda_load_patch(&chip->bus, chip->fw->size, in azx_probe_continue()
2309 chip->fw->data); in azx_probe_continue()
2316 if (bus->codec_mask && !(probe_only[dev] & 1)) { in azx_probe_continue()
2319 if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) && in azx_probe_continue()
2320 ++hda->probe_retry < 60) { in azx_probe_continue()
2321 schedule_delayed_work(&hda->probe_work, in azx_probe_continue()
2325 dev_err(chip->card->dev, "Cannot probe codecs, giving up\n"); in azx_probe_continue()
2330 err = snd_card_register(chip->card); in azx_probe_continue()
2336 chip->running = 1; in azx_probe_continue()
2342 pm_runtime_use_autosuspend(&pci->dev); in azx_probe_continue()
2343 pm_runtime_allow(&pci->dev); in azx_probe_continue()
2344 pm_runtime_put_autosuspend(&pci->dev); in azx_probe_continue()
2350 snd_card_free(chip->card); in azx_probe_continue()
2354 if (!hda->need_i915_power) in azx_probe_continue()
2356 complete_all(&hda->probe_wait); in azx_probe_continue()
2357 to_hda_bus(bus)->bus_probing = 0; in azx_probe_continue()
2358 hda->probe_retry = 0; in azx_probe_continue()
2370 chip = card->private_data; in azx_remove()
2383 device_unlock(&pci->dev); in azx_remove()
2384 cancel_delayed_work_sync(&hda->probe_work); in azx_remove()
2385 device_lock(&pci->dev); in azx_remove()
2387 clear_bit(chip->dev_index, probed_devs); in azx_remove()
2400 chip = card->private_data; in azx_shutdown()
2401 if (chip && chip->running) in azx_shutdown()
2423 /* Lynx Point-LP */
2425 /* Lynx Point-LP */
2427 /* Wildcat Point-LP */
2431 /* Skylake-LP (Sunrise Point-LP) */
2435 /* Kabylake-LP */
2437 /* Kabylake-H */
2443 /* CometLake-LP */
2445 /* CometLake-H */
2448 /* CometLake-S */
2450 /* CometLake-R */
2454 /* Icelake-H */
2461 /* Tigerlake-H */
2469 /* Alderlake-S */
2471 /* Alderlake-P */
2475 /* Alderlake-M */
2477 /* Alderlake-N */
2491 /* Lunarlake-P */
2493 /* Arrow Lake-S */
2499 /* Apollolake (Broxton-P) */
2501 /* Gemini-Lake */
2542 /* ATI SB 450/600/700/800/900 */
2543 { PCI_VDEVICE(ATI, 0x437b),
2545 { PCI_VDEVICE(ATI, 0x4383),
2563 /* ATI HDMI */
2564 { PCI_VDEVICE(ATI, 0x0002),
2567 { PCI_VDEVICE(ATI, 0x1308),
2569 { PCI_VDEVICE(ATI, 0x157a),
2571 { PCI_VDEVICE(ATI, 0x15b3),
2573 { PCI_VDEVICE(ATI, 0x793b),
2575 { PCI_VDEVICE(ATI, 0x7919),
2577 { PCI_VDEVICE(ATI, 0x960f),
2579 { PCI_VDEVICE(ATI, 0x970f),
2581 { PCI_VDEVICE(ATI, 0x9840),
2583 { PCI_VDEVICE(ATI, 0xaa00),
2585 { PCI_VDEVICE(ATI, 0xaa08),
2587 { PCI_VDEVICE(ATI, 0xaa10),
2589 { PCI_VDEVICE(ATI, 0xaa18),
2591 { PCI_VDEVICE(ATI, 0xaa20),
2593 { PCI_VDEVICE(ATI, 0xaa28),
2595 { PCI_VDEVICE(ATI, 0xaa30),
2597 { PCI_VDEVICE(ATI, 0xaa38),
2599 { PCI_VDEVICE(ATI, 0xaa40),
2601 { PCI_VDEVICE(ATI, 0xaa48),
2603 { PCI_VDEVICE(ATI, 0xaa50),
2605 { PCI_VDEVICE(ATI, 0xaa58),
2607 { PCI_VDEVICE(ATI, 0xaa60),
2609 { PCI_VDEVICE(ATI, 0xaa68),
2611 { PCI_VDEVICE(ATI, 0xaa80),
2613 { PCI_VDEVICE(ATI, 0xaa88),
2615 { PCI_VDEVICE(ATI, 0xaa90),
2617 { PCI_VDEVICE(ATI, 0xaa98),
2619 { PCI_VDEVICE(ATI, 0x9902),
2621 { PCI_VDEVICE(ATI, 0xaaa0),
2623 { PCI_VDEVICE(ATI, 0xaaa8),
2625 { PCI_VDEVICE(ATI, 0xaab0),
2627 { PCI_VDEVICE(ATI, 0xaac0),
2630 { PCI_VDEVICE(ATI, 0xaac8),
2633 { PCI_VDEVICE(ATI, 0xaad8),
2636 { PCI_VDEVICE(ATI, 0xaae0),
2639 { PCI_VDEVICE(ATI, 0xaae8),
2642 { PCI_VDEVICE(ATI, 0xaaf0),
2645 { PCI_VDEVICE(ATI, 0xaaf8),
2648 { PCI_VDEVICE(ATI, 0xab00),
2651 { PCI_VDEVICE(ATI, 0xab08),
2654 { PCI_VDEVICE(ATI, 0xab10),
2657 { PCI_VDEVICE(ATI, 0xab18),
2660 { PCI_VDEVICE(ATI, 0xab20),
2663 { PCI_VDEVICE(ATI, 0xab28),
2666 { PCI_VDEVICE(ATI, 0xab30),
2669 { PCI_VDEVICE(ATI, 0xab38),
2698 /* Creative X-Fi (CA0110-IBG) */
2705 /* the following entry conflicts with snd-ctxfi driver,
2706 * as ctxfi driver mutates from HD-audio to native mode with
2715 /* this entry seems still valid -- i.e. without emu20kx chip */
2728 /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */