Lines Matching +full:ati +full:- +full:mode
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>
63 /* position fix mode */
74 /* Defines for ATI HD Audio support in SB450 south bridge */
92 /* ICH, ATI and VIA have 4 playback and 4 capture */
100 /* ATI HDMI may have up to 8 playbacks and 0 capture */
109 static int position_fix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
110 static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
111 static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
114 static int single_cmd = -1;
115 static int enable_msi = -1;
120 static bool beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] =
136 …"(-1 = system default, 0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO, 4 = COMBO, 5 = SKL+, 6 = FIFO…
140 MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
156 MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode "
162 "deprecated, use snd-intel-dspcfg.dsp_driver option instead");
176 MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
181 MODULE_PARM_DESC(pm_blacklist, "Enable power-management denylist");
183 /* reset the HD-audio controller in power save mode.
184 * this may give more power-saving, but will take longer time to
189 MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
194 static int align_buffer_size = -1;
200 static int hda_snoop = -1;
247 (((chip)->driver_caps & AZX_DCAPS_SNOOP_MASK) >> 10)
293 /* quirks for ATI SB / AMD Hudson */
296 AZX_DCAPS_SNOOP_TYPE(ATI))
298 /* quirks for ATI/AMD HDMI */
303 /* quirks for ATI HDMI with snoop off */
310 AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME |\
327 #define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo)
328 #define needs_eld_notify_link(chip) ((chip)->bus.keep_power)
340 [AZX_DRIVER_ATI] = "HDA ATI SB",
341 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
342 [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI",
351 [AZX_DRIVER_CMEDIA] = "HDA C-Media",
354 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
379 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) in azx_init_pci()
385 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) { in azx_init_pci()
386 dev_dbg(chip->card->dev, "Clearing TCSEL\n"); in azx_init_pci()
387 update_pci_byte(chip->pci, AZX_PCIREG_TCSEL, 0x07, 0); in azx_init_pci()
390 /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio, in azx_init_pci()
394 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n", in azx_init_pci()
396 update_pci_byte(chip->pci, in azx_init_pci()
403 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n", in azx_init_pci()
405 update_pci_byte(chip->pci, in azx_init_pci()
408 update_pci_byte(chip->pci, in azx_init_pci()
411 update_pci_byte(chip->pci, in azx_init_pci()
419 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); in azx_init_pci()
425 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop); in azx_init_pci()
426 pci_read_config_word(chip->pci, in azx_init_pci()
429 dev_dbg(chip->card->dev, "SCH snoop: %s\n", in azx_init_pci()
436 * In BXT-P A0, HD-Audio DMA requests is later than expected,
467 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCAP); in intel_get_lctl_scf()
475 dev_warn(chip->card->dev, "set audio clock frequency to 6MHz"); in intel_get_lctl_scf()
486 * Changes to LCTL.SCF are only needed for the first multi-link dealing in intel_ml_lctl_set_power()
489 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
492 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
496 if (((readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL)) & in intel_ml_lctl_set_power()
499 timeout--; in intel_ml_lctl_set_power()
503 return -1; in intel_ml_lctl_set_power()
513 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
535 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
546 struct pci_dev *pci = chip->pci; in hda_intel_init_chip()
550 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
556 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
568 if (bus->mlcap != NULL) in hda_intel_init_chip()
576 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_lpib()
577 int stream = substream->stream; in azx_get_delay_from_lpib()
582 delay = pos - lpib_pos; in azx_get_delay_from_lpib()
584 delay = lpib_pos - pos; in azx_get_delay_from_lpib()
586 if (delay >= azx_dev->core.delay_negative_threshold) in azx_get_delay_from_lpib()
589 delay += azx_dev->core.bufsize; in azx_get_delay_from_lpib()
592 if (delay >= azx_dev->core.period_bytes) { in azx_get_delay_from_lpib()
593 dev_info(chip->card->dev, in azx_get_delay_from_lpib()
595 delay, azx_dev->core.period_bytes); in azx_get_delay_from_lpib()
597 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; in azx_get_delay_from_lpib()
598 chip->get_delay[stream] = NULL; in azx_get_delay_from_lpib()
601 return bytes_to_frames(substream->runtime, delay); in azx_get_delay_from_lpib()
614 azx_dev->irq_pending = 0; in azx_position_check()
618 azx_dev->irq_pending = 1; in azx_position_check()
619 schedule_work(&hda->irq_pending_work); in azx_position_check()
629 * periods. Returns non-zero if it's OK.
631 * Many HD-audio controllers appear pretty inaccurate about
632 * the update-IRQ timing. The IRQ is issued before actually the
636 * Returns 1 if OK to proceed, 0 for delay handling, -1 for skipping update
640 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_position_ok()
641 struct snd_pcm_runtime *runtime = substream->runtime; in azx_position_ok()
642 int stream = substream->stream; in azx_position_ok()
651 if (chip->driver_type == AZX_DRIVER_LOONGSON) in azx_position_ok()
654 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk; in azx_position_ok()
655 if (wallclk < (azx_dev->core.period_wallclk * 2) / 3) in azx_position_ok()
656 return -1; /* bogus (too early) interrupt */ in azx_position_ok()
658 if (chip->get_position[stream]) in azx_position_ok()
659 pos = chip->get_position[stream](chip, azx_dev); in azx_position_ok()
662 if (!pos || pos == (u32)-1) { in azx_position_ok()
663 dev_info(chip->card->dev, in azx_position_ok()
665 chip->get_position[stream] = azx_get_pos_lpib; in azx_position_ok()
666 if (chip->get_position[0] == azx_get_pos_lpib && in azx_position_ok()
667 chip->get_position[1] == azx_get_pos_lpib) in azx_position_ok()
668 azx_bus(chip)->use_posbuf = false; in azx_position_ok()
670 chip->get_delay[stream] = NULL; in azx_position_ok()
672 chip->get_position[stream] = azx_get_pos_posbuf; in azx_position_ok()
673 if (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY) in azx_position_ok()
674 chip->get_delay[stream] = azx_get_delay_from_lpib; in azx_position_ok()
678 if (pos >= azx_dev->core.bufsize) in azx_position_ok()
681 if (WARN_ONCE(!azx_dev->core.period_bytes, in azx_position_ok()
682 "hda-intel: zero azx_dev->period_bytes")) in azx_position_ok()
683 return -1; /* this shouldn't happen! */ in azx_position_ok()
684 if (wallclk < (azx_dev->core.period_wallclk * 5) / 4 && in azx_position_ok()
685 pos % azx_dev->core.period_bytes > azx_dev->core.period_bytes / 2) in azx_position_ok()
686 /* NG - it's below the first next period boundary */ in azx_position_ok()
687 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
688 azx_dev->core.start_wallclk += wallclk; in azx_position_ok()
690 if (azx_dev->core.no_period_wakeup) in azx_position_ok()
693 if (runtime->hw_ptr_base != runtime->hw_ptr_interrupt) in azx_position_ok()
698 hwptr = runtime->hw_ptr_base + pos; in azx_position_ok()
699 if (hwptr < runtime->status->hw_ptr) in azx_position_ok()
700 hwptr += runtime->buffer_size; in azx_position_ok()
701 target = runtime->hw_ptr_interrupt + runtime->period_size; in azx_position_ok()
704 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
716 struct azx *chip = &hda->chip; in azx_irq_pending_work()
721 if (!hda->irq_pending_warned) { in azx_irq_pending_work()
722 dev_info(chip->card->dev, in azx_irq_pending_work()
724 chip->card->number); in azx_irq_pending_work()
725 hda->irq_pending_warned = 1; in azx_irq_pending_work()
730 spin_lock_irq(&bus->reg_lock); in azx_irq_pending_work()
731 list_for_each_entry(s, &bus->stream_list, list) { in azx_irq_pending_work()
733 if (!azx_dev->irq_pending || in azx_irq_pending_work()
734 !s->substream || in azx_irq_pending_work()
735 !s->running) in azx_irq_pending_work()
739 azx_dev->irq_pending = 0; in azx_irq_pending_work()
740 spin_unlock(&bus->reg_lock); in azx_irq_pending_work()
741 snd_pcm_period_elapsed(s->substream); in azx_irq_pending_work()
742 spin_lock(&bus->reg_lock); in azx_irq_pending_work()
748 spin_unlock_irq(&bus->reg_lock); in azx_irq_pending_work()
755 /* clear irq_pending flags and assure no on-going workq */
761 spin_lock_irq(&bus->reg_lock); in azx_clear_irq_pending()
762 list_for_each_entry(s, &bus->stream_list, list) { in azx_clear_irq_pending()
764 azx_dev->irq_pending = 0; in azx_clear_irq_pending()
766 spin_unlock_irq(&bus->reg_lock); in azx_clear_irq_pending()
773 if (request_irq(chip->pci->irq, azx_interrupt, in azx_acquire_irq()
774 chip->msi ? 0 : IRQF_SHARED, in azx_acquire_irq()
775 chip->card->irq_descr, chip)) { in azx_acquire_irq()
776 dev_err(chip->card->dev, in azx_acquire_irq()
778 chip->pci->irq); in azx_acquire_irq()
780 snd_card_disconnect(chip->card); in azx_acquire_irq()
781 return -1; in azx_acquire_irq()
783 bus->irq = chip->pci->irq; in azx_acquire_irq()
784 chip->card->sync_irq = bus->irq; in azx_acquire_irq()
785 pci_intx(chip->pci, !chip->msi); in azx_acquire_irq()
798 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in azx_via_get_position()
807 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); in azx_via_get_position()
808 mod_dma_pos %= azx_dev->core.period_bytes; in azx_via_get_position()
810 fifo_size = azx_stream(azx_dev)->fifo_size - 1; in azx_via_get_position()
812 if (azx_dev->insufficient) { in azx_via_get_position()
817 azx_dev->insufficient = 0; in azx_via_get_position()
821 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; in azx_via_get_position()
823 mini_pos = link_pos - fifo_size; in azx_via_get_position()
826 mod_mini_pos = mini_pos % azx_dev->core.period_bytes; in azx_via_get_position()
827 mod_link_pos = link_pos % azx_dev->core.period_bytes; in azx_via_get_position()
829 bound_pos = link_pos - mod_link_pos; in azx_via_get_position()
831 bound_pos = mini_pos - mod_mini_pos; in azx_via_get_position()
833 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; in azx_via_get_position()
834 if (bound_pos >= azx_dev->core.bufsize) in azx_via_get_position()
847 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_pos_fifo()
848 struct snd_pcm_runtime *runtime = substream->runtime; in azx_get_pos_fifo()
855 runtime->delay = AMD_FIFO_SIZE; in azx_get_pos_fifo()
857 if (azx_dev->insufficient) { in azx_get_pos_fifo()
860 runtime->delay = bytes_to_frames(runtime, pos); in azx_get_pos_fifo()
862 azx_dev->insufficient = 0; in azx_get_pos_fifo()
867 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in azx_get_pos_fifo()
869 pos += azx_dev->core.bufsize; in azx_get_pos_fifo()
870 pos -= delay; in azx_get_pos_fifo()
879 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_fifo()
882 return substream->runtime->delay; in azx_get_delay_from_fifo()
907 list_add(&hda->list, &card_list); in azx_add_card_list()
915 list_del_init(&hda->list); in azx_del_card_list()
919 /* trigger power-save check at writing parameter */
932 chip = &hda->chip; in param_set_xint()
933 if (!hda->probe_continued || chip->disabled) in param_set_xint()
935 snd_hda_set_power_save(&chip->bus, power_save * 1000); in param_set_xint()
951 chip = card->private_data; in azx_is_pm_ready()
953 if (chip->disabled || hda->init_failed || !chip->running) in azx_is_pm_ready()
966 if (hda->need_i915_power) in __azx_runtime_resume()
976 if (!chip->pm_prepared) { in __azx_runtime_resume()
977 list_for_each_codec(codec, &chip->bus) { in __azx_runtime_resume()
978 if (codec->relaxed_resume) in __azx_runtime_resume()
981 if (codec->forced_resume || (status & (1 << codec->addr))) in __azx_runtime_resume()
986 /* power down again for link-controlled chips */ in __azx_runtime_resume()
987 if (!hda->need_i915_power) in __azx_runtime_resume()
1000 chip = card->private_data; in azx_prepare()
1001 chip->pm_prepared = 1; in azx_prepare()
1004 flush_work(&azx_bus(chip)->unsol_work); in azx_prepare()
1007 * and system suspend, so don't use direct-complete here. in azx_prepare()
1020 chip = card->private_data; in azx_complete()
1022 chip->pm_prepared = 0; in azx_complete()
1034 chip = card->private_data; in azx_suspend()
1037 if (bus->irq >= 0) { in azx_suspend()
1038 free_irq(bus->irq, chip); in azx_suspend()
1039 bus->irq = -1; in azx_suspend()
1040 chip->card->sync_irq = -1; in azx_suspend()
1043 if (chip->msi) in azx_suspend()
1044 pci_disable_msi(chip->pci); in azx_suspend()
1058 chip = card->private_data; in azx_resume()
1059 if (chip->msi) in azx_resume()
1060 if (pci_enable_msi(chip->pci) < 0) in azx_resume()
1061 chip->msi = 0; in azx_resume()
1063 return -EIO; in azx_resume()
1077 struct azx *chip = card->private_data; in azx_freeze_noirq()
1082 if (chip->driver_type == AZX_DRIVER_SKL) in azx_freeze_noirq()
1091 struct azx *chip = card->private_data; in azx_thaw_noirq()
1096 if (chip->driver_type == AZX_DRIVER_SKL) in azx_thaw_noirq()
1110 chip = card->private_data; in azx_runtime_suspend()
1127 chip = card->private_data; in azx_runtime_resume()
1146 chip = card->private_data; in azx_runtime_idle()
1148 if (chip->disabled || hda->init_failed) in azx_runtime_idle()
1152 azx_bus(chip)->codec_powered || !chip->running) in azx_runtime_idle()
1153 return -EBUSY; in azx_runtime_idle()
1155 /* ELD notification gets broken when HD-audio bus is off */ in azx_runtime_idle()
1157 return -EBUSY; in azx_runtime_idle()
1190 struct azx *chip = card->private_data; in azx_vs_set_state()
1195 wait_for_completion(&hda->probe_wait); in azx_vs_set_state()
1196 if (hda->init_failed) in azx_vs_set_state()
1200 if (chip->disabled == disabled) in azx_vs_set_state()
1203 if (!hda->probe_continued) { in azx_vs_set_state()
1204 chip->disabled = disabled; in azx_vs_set_state()
1206 dev_info(chip->card->dev, in azx_vs_set_state()
1209 dev_err(chip->card->dev, "initialization error\n"); in azx_vs_set_state()
1212 dev_info(chip->card->dev, "%s via vga_switcheroo\n", in azx_vs_set_state()
1215 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1219 pm_runtime_suspend(card->dev); in azx_vs_set_state()
1220 pm_runtime_disable(card->dev); in azx_vs_set_state()
1224 pci->current_state = PCI_D3cold; in azx_vs_set_state()
1225 chip->disabled = true; in azx_vs_set_state()
1226 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_set_state()
1227 dev_warn(chip->card->dev, in azx_vs_set_state()
1230 snd_hda_unlock_devices(&chip->bus); in azx_vs_set_state()
1231 chip->disabled = false; in azx_vs_set_state()
1232 pm_runtime_enable(card->dev); in azx_vs_set_state()
1233 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1244 struct azx *chip = card->private_data; in azx_vs_can_switch()
1247 wait_for_completion(&hda->probe_wait); in azx_vs_can_switch()
1248 if (hda->init_failed) in azx_vs_can_switch()
1250 if (chip->disabled || !hda->probe_continued) in azx_vs_can_switch()
1252 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_can_switch()
1254 snd_hda_unlock_devices(&chip->bus); in azx_vs_can_switch()
1267 if (hda->use_vga_switcheroo && !needs_eld_notify_link(chip)) { in setup_vga_switcheroo_runtime_pm()
1268 list_for_each_codec(codec, &chip->bus) in setup_vga_switcheroo_runtime_pm()
1269 codec->auto_runtime_pm = 1; in setup_vga_switcheroo_runtime_pm()
1271 if (chip->running) in setup_vga_switcheroo_runtime_pm()
1280 struct azx *chip = card->private_data; in azx_vs_gpu_bound()
1283 chip->bus.keep_power = 0; in azx_vs_gpu_bound()
1290 struct pci_dev *p = get_bound_vga(chip->pci); in init_vga_switcheroo()
1293 dev_info(chip->card->dev, in init_vga_switcheroo()
1295 hda->use_vga_switcheroo = 1; in init_vga_switcheroo()
1301 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1; in init_vga_switcheroo()
1302 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME; in init_vga_switcheroo()
1319 if (!hda->use_vga_switcheroo) in register_vga_switcheroo()
1322 p = get_bound_vga(chip->pci); in register_vga_switcheroo()
1323 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p); in register_vga_switcheroo()
1328 hda->vga_switcheroo_registered = 1; in register_vga_switcheroo()
1344 struct pci_dev *pci = chip->pci; in azx_free()
1348 if (hda->freed) in azx_free()
1351 if (azx_has_pm_runtime(chip) && chip->running) { in azx_free()
1352 pm_runtime_get_noresume(&pci->dev); in azx_free()
1353 pm_runtime_forbid(&pci->dev); in azx_free()
1354 pm_runtime_dont_use_autosuspend(&pci->dev); in azx_free()
1357 chip->running = 0; in azx_free()
1361 hda->init_failed = 1; /* to be sure */ in azx_free()
1362 complete_all(&hda->probe_wait); in azx_free()
1365 if (chip->disabled && hda->probe_continued) in azx_free()
1366 snd_hda_unlock_devices(&chip->bus); in azx_free()
1367 if (hda->vga_switcheroo_registered) { in azx_free()
1368 vga_switcheroo_unregister_client(chip->pci); in azx_free()
1371 * leaving the device probed but non-functional. As long in azx_free()
1377 …dev_warn(&pci->dev, "GPU sound probed, but not operational: please add a quirk to driver_denylist\… in azx_free()
1378 pm_runtime_disable(&pci->dev); in azx_free()
1379 pm_runtime_set_suspended(&pci->dev); in azx_free()
1380 pm_runtime_enable(&pci->dev); in azx_free()
1384 if (bus->chip_init) { in azx_free()
1390 if (bus->irq >= 0) in azx_free()
1391 free_irq(bus->irq, (void*)chip); in azx_free()
1398 release_firmware(chip->fw); in azx_free()
1402 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) in azx_free()
1405 hda->freed = 1; in azx_free()
1410 struct azx *chip = device->device_data; in azx_dev_disconnect()
1413 chip->bus.shutdown = 1; in azx_dev_disconnect()
1414 cancel_work_sync(&bus->unsol_work); in azx_dev_disconnect()
1421 azx_free(device->device_data); in azx_dev_free()
1435 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1445 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1471 switch (pci->vendor) { in get_bound_vga()
1474 if (pci->devfn == 1) { in get_bound_vga()
1475 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1476 pci->bus->number, 0); in get_bound_vga()
1483 if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) && in get_bound_vga()
1491 if (pci->devfn == 1) { in get_bound_vga()
1492 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1493 pci->bus->number, 0); in get_bound_vga()
1495 if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) in get_bound_vga()
1520 * allow/deny-listing for position_fix
1532 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1535 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1536 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1555 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); in check_position_fix()
1557 dev_info(chip->card->dev, in check_position_fix()
1559 q->value, q->subvendor, q->subdevice); in check_position_fix()
1560 return q->value; in check_position_fix()
1563 /* Check VIA/ATI HD Audio Controller exist */ in check_position_fix()
1564 if (chip->driver_type == AZX_DRIVER_VIA) { in check_position_fix()
1565 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); in check_position_fix()
1568 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) { in check_position_fix()
1569 dev_dbg(chip->card->dev, "Using FIFO position fix\n"); in check_position_fix()
1572 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { in check_position_fix()
1573 dev_dbg(chip->card->dev, "Using LPIB position fix\n"); in check_position_fix()
1576 if (chip->driver_type == AZX_DRIVER_SKL) { in check_position_fix()
1577 dev_dbg(chip->card->dev, "Using SKL position fix\n"); in check_position_fix()
1595 chip->get_position[0] = chip->get_position[1] = callbacks[fix]; in assign_position_fix()
1597 /* combo mode uses LPIB only for playback */ in assign_position_fix()
1599 chip->get_position[1] = NULL; in assign_position_fix()
1602 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { in assign_position_fix()
1603 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1608 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1613 * deny-lists for probe_mask
1617 * to the non-working (or non-existing) modem codec slot.
1641 chip->codec_probe_mask = probe_mask[dev]; in check_probe_mask()
1642 if (chip->codec_probe_mask == -1) { in check_probe_mask()
1643 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); in check_probe_mask()
1645 dev_info(chip->card->dev, in check_probe_mask()
1647 q->value, q->subvendor, q->subdevice); in check_probe_mask()
1648 chip->codec_probe_mask = q->value; in check_probe_mask()
1653 if (chip->codec_probe_mask != -1 && in check_probe_mask()
1654 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { in check_probe_mask()
1655 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff; in check_probe_mask()
1656 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n", in check_probe_mask()
1657 (int)azx_bus(chip)->codec_mask); in check_probe_mask()
1662 * allow/deny-list for enable_msi
1674 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1683 chip->msi = !!enable_msi; in check_msi()
1686 chip->msi = 1; /* enable MSI as default */ in check_msi()
1687 q = snd_pci_quirk_lookup(chip->pci, msi_deny_list); in check_msi()
1689 dev_info(chip->card->dev, in check_msi()
1691 q->subvendor, q->subdevice, q->value); in check_msi()
1692 chip->msi = q->value; in check_msi()
1697 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { in check_msi()
1698 dev_info(chip->card->dev, "Disabling MSI\n"); in check_msi()
1699 chip->msi = 0; in check_msi()
1703 /* check the snoop mode availability */
1709 dev_info(chip->card->dev, "Force to %s mode by module option\n", in azx_check_snoop_available()
1710 snoop ? "snoop" : "non-snoop"); in azx_check_snoop_available()
1711 chip->snoop = snoop; in azx_check_snoop_available()
1712 chip->uc_buffer = !snoop; in azx_check_snoop_available()
1718 chip->driver_type == AZX_DRIVER_VIA) { in azx_check_snoop_available()
1719 /* force to non-snoop mode for a new VIA controller in azx_check_snoop_available()
1723 pci_read_config_byte(chip->pci, 0x42, &val); in azx_check_snoop_available()
1724 if (!(val & 0x80) && (chip->pci->revision == 0x30 || in azx_check_snoop_available()
1725 chip->pci->revision == 0x20)) in azx_check_snoop_available()
1729 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) in azx_check_snoop_available()
1732 chip->snoop = snoop; in azx_check_snoop_available()
1734 dev_info(chip->card->dev, "Force to non-snoop mode\n"); in azx_check_snoop_available()
1735 /* C-Media requires non-cached pages only for CORB/RIRB */ in azx_check_snoop_available()
1736 if (chip->driver_type != AZX_DRIVER_CMEDIA) in azx_check_snoop_available()
1737 chip->uc_buffer = true; in azx_check_snoop_available()
1744 azx_probe_continue(&hda->chip); in azx_probe_work()
1750 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) { in default_bdl_pos_adj()
1751 switch (chip->pci->device) { in default_bdl_pos_adj()
1760 switch (chip->driver_type) { in default_bdl_pos_adj()
1798 hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL); in azx_create()
1800 return -ENOMEM; in azx_create()
1802 chip = &hda->chip; in azx_create()
1803 mutex_init(&chip->open_mutex); in azx_create()
1804 chip->card = card; in azx_create()
1805 chip->pci = pci; in azx_create()
1806 chip->ops = &pci_hda_ops; in azx_create()
1807 chip->driver_caps = driver_caps; in azx_create()
1808 chip->driver_type = driver_caps & 0xff; in azx_create()
1810 chip->dev_index = dev; in azx_create()
1812 chip->jackpoll_interval = msecs_to_jiffies(jackpoll_ms[dev]); in azx_create()
1813 INIT_LIST_HEAD(&chip->pcm_list); in azx_create()
1814 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); in azx_create()
1815 INIT_LIST_HEAD(&hda->list); in azx_create()
1817 init_completion(&hda->probe_wait); in azx_create()
1822 chip->fallback_to_single_cmd = 1; in azx_create()
1824 chip->single_cmd = single_cmd; in azx_create()
1829 chip->bdl_pos_adj = default_bdl_pos_adj(chip); in azx_create()
1831 chip->bdl_pos_adj = bdl_pos_adj[dev]; in azx_create()
1837 /* use the non-cached pages in non-snoop mode */ in azx_create()
1839 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC_SG; in azx_create()
1841 if (chip->driver_type == AZX_DRIVER_NVIDIA) { in azx_create()
1842 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); in azx_create()
1843 chip->bus.core.needs_damn_long_delay = 1; in azx_create()
1850 dev_err(card->dev, "Error creating device [card]!\n"); in azx_create()
1856 INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work); in azx_create()
1865 int dev = chip->dev_index; in azx_first_init()
1866 struct pci_dev *pci = chip->pci; in azx_first_init()
1867 struct snd_card *card = chip->card; in azx_first_init()
1875 if (chip->driver_type == AZX_DRIVER_ULI) { in azx_first_init()
1886 if (chip->driver_type == AZX_DRIVER_GFHDMI) in azx_first_init()
1887 bus->polling_mode = 1; in azx_first_init()
1889 if (chip->driver_type == AZX_DRIVER_LOONGSON) { in azx_first_init()
1890 bus->polling_mode = 1; in azx_first_init()
1891 bus->not_use_interrupts = 1; in azx_first_init()
1892 bus->access_sdnctl_in_dword = 1; in azx_first_init()
1899 bus->addr = pci_resource_start(pci, 0); in azx_first_init()
1900 bus->remap_addr = pcim_iomap_table(pci)[0]; in azx_first_init()
1902 if (chip->driver_type == AZX_DRIVER_SKL) in azx_first_init()
1911 chip->gts_present = false; in azx_first_init()
1914 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART)) in azx_first_init()
1915 chip->gts_present = true; in azx_first_init()
1918 if (chip->msi) { in azx_first_init()
1919 if (chip->driver_caps & AZX_DCAPS_NO_MSI64) { in azx_first_init()
1920 dev_dbg(card->dev, "Disabling 64bit MSI\n"); in azx_first_init()
1921 pci->no_64bit_msi = true; in azx_first_init()
1924 chip->msi = 0; in azx_first_init()
1930 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); in azx_first_init()
1933 if (chip->pci->vendor == PCI_VENDOR_ID_AMD) in azx_first_init()
1937 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { in azx_first_init()
1944 if (p_smbus->revision < 0x30) in azx_first_init()
1951 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA) in azx_first_init()
1955 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { in azx_first_init()
1956 dev_dbg(card->dev, "Disabling 64bit DMA\n"); in azx_first_init()
1960 /* disable buffer size rounding to 128-byte multiples if supported */ in azx_first_init()
1962 chip->align_buffer_size = !!align_buffer_size; in azx_first_init()
1964 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE) in azx_first_init()
1965 chip->align_buffer_size = 0; in azx_first_init()
1967 chip->align_buffer_size = 1; in azx_first_init()
1973 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits))) in azx_first_init()
1974 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1975 dma_set_max_seg_size(&pci->dev, UINT_MAX); in azx_first_init()
1980 chip->capture_streams = (gcap >> 8) & 0x0f; in azx_first_init()
1981 chip->playback_streams = (gcap >> 12) & 0x0f; in azx_first_init()
1982 if (!chip->playback_streams && !chip->capture_streams) { in azx_first_init()
1985 switch (chip->driver_type) { in azx_first_init()
1987 chip->playback_streams = ULI_NUM_PLAYBACK; in azx_first_init()
1988 chip->capture_streams = ULI_NUM_CAPTURE; in azx_first_init()
1992 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; in azx_first_init()
1993 chip->capture_streams = ATIHDMI_NUM_CAPTURE; in azx_first_init()
1998 chip->playback_streams = ICH6_NUM_PLAYBACK; in azx_first_init()
1999 chip->capture_streams = ICH6_NUM_CAPTURE; in azx_first_init()
2003 chip->capture_index_offset = 0; in azx_first_init()
2004 chip->playback_index_offset = chip->capture_streams; in azx_first_init()
2005 chip->num_streams = chip->playback_streams + chip->capture_streams; in azx_first_init()
2008 if (chip->num_streams > 15 && in azx_first_init()
2009 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) { in azx_first_init()
2010 dev_warn(chip->card->dev, "number of I/O streams is %d, " in azx_first_init()
2011 "forcing separate stream tags", chip->num_streams); in azx_first_init()
2012 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG; in azx_first_init()
2032 if (!azx_bus(chip)->codec_mask) { in azx_first_init()
2033 dev_err(card->dev, "no codecs found!\n"); in azx_first_init()
2038 return -EBUSY; in azx_first_init()
2040 strcpy(card->driver, "HDA-Intel"); in azx_first_init()
2041 strscpy(card->shortname, driver_short_names[chip->driver_type], in azx_first_init()
2042 sizeof(card->shortname)); in azx_first_init()
2043 snprintf(card->longname, sizeof(card->longname), in azx_first_init()
2045 card->shortname, bus->addr, bus->irq); in azx_first_init()
2055 struct azx *chip = card->private_data; in azx_firmware_cb()
2058 chip->fw = fw; in azx_firmware_cb()
2060 dev_err(card->dev, "Cannot load firmware, continue without patching\n"); in azx_firmware_cb()
2061 if (!chip->disabled) { in azx_firmware_cb()
2073 free_irq(bus->irq, chip); in disable_msi_reset_irq()
2074 bus->irq = -1; in disable_msi_reset_irq()
2075 chip->card->sync_irq = -1; in disable_msi_reset_irq()
2076 pci_disable_msi(chip->pci); in disable_msi_reset_irq()
2077 chip->msi = 0; in disable_msi_reset_irq()
2086 * some HD-audio PCI entries are exposed without any codecs, and such devices
2101 /* DMI-based denylist, to be used when:
2102 * - PCI subsystem IDs are zero, impossible to distinguish from valid sound cards.
2103 * - Different modifications of the same laptop use different GPU models.
2136 dev_info(&pci->dev, "Skipping the device on the denylist\n"); in azx_probe()
2137 return -ENODEV; in azx_probe()
2141 if (dmi && pci_match_id(dmi->driver_data, pci)) { in azx_probe()
2142 dev_info(&pci->dev, "Skipping the device on the DMI denylist\n"); in azx_probe()
2143 return -ENODEV; in azx_probe()
2148 return -ENODEV; in azx_probe()
2151 return -ENOENT; in azx_probe()
2160 dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n"); in azx_probe()
2161 return -ENODEV; in azx_probe()
2164 …dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option i… in azx_probe()
2167 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in azx_probe()
2170 dev_err(&pci->dev, "Error creating card!\n"); in azx_probe()
2174 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); in azx_probe()
2177 card->private_data = chip; in azx_probe()
2184 dev_err(card->dev, "Error registering vga_switcheroo client\n"); in azx_probe()
2189 dev_info(card->dev, "VGA controller is disabled\n"); in azx_probe()
2190 dev_info(card->dev, "Delaying initialization\n"); in azx_probe()
2191 chip->disabled = true; in azx_probe()
2194 schedule_probe = !chip->disabled; in azx_probe()
2198 dev_info(card->dev, "Applying patch firmware '%s'\n", in azx_probe()
2201 &pci->dev, GFP_KERNEL, card, in azx_probe()
2211 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n"); in azx_probe()
2215 schedule_delayed_work(&hda->probe_work, 0); in azx_probe()
2218 if (chip->disabled) in azx_probe()
2219 complete_all(&hda->probe_wait); in azx_probe()
2229 * popping sounds when ever we enter/leave powersaving mode. Ideally we would
2236 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2238 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2240 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2242 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2246 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2247 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2249 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2283 q = snd_pci_quirk_lookup(chip->pci, power_save_denylist); in set_default_power_save()
2285 …dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0… in set_default_power_save()
2286 q->subvendor, q->subdevice); in set_default_power_save()
2291 snd_hda_set_power_save(&chip->bus, val * 1000); in set_default_power_save()
2304 struct pci_dev *pci = chip->pci; in azx_probe_continue()
2305 int dev = chip->dev_index; in azx_probe_continue()
2308 if (chip->disabled || hda->init_failed) in azx_probe_continue()
2309 return -EIO; in azx_probe_continue()
2310 if (hda->probe_retry) in azx_probe_continue()
2313 to_hda_bus(bus)->bus_probing = 1; in azx_probe_continue()
2314 hda->probe_continued = 1; in azx_probe_continue()
2317 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) { in azx_probe_continue()
2326 dev_err(chip->card->dev, in azx_probe_continue()
2327 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n"); in azx_probe_continue()
2331 chip->driver_caps &= ~AZX_DCAPS_I915_COMPONENT; in azx_probe_continue()
2337 hda->need_i915_power = true; in azx_probe_continue()
2352 chip->beep_mode = beep_mode[dev]; in azx_probe_continue()
2355 chip->ctl_dev_id = ctl_dev_id; in azx_probe_continue()
2358 if (bus->codec_mask) { in azx_probe_continue()
2359 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); in azx_probe_continue()
2365 if (chip->fw) { in azx_probe_continue()
2366 err = snd_hda_load_patch(&chip->bus, chip->fw->size, in azx_probe_continue()
2367 chip->fw->data); in azx_probe_continue()
2371 release_firmware(chip->fw); /* no longer needed */ in azx_probe_continue()
2372 chip->fw = NULL; in azx_probe_continue()
2378 if (bus->codec_mask && !(probe_only[dev] & 1)) { in azx_probe_continue()
2381 if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) && in azx_probe_continue()
2382 ++hda->probe_retry < 60) { in azx_probe_continue()
2383 schedule_delayed_work(&hda->probe_work, in azx_probe_continue()
2387 dev_err(chip->card->dev, "Cannot probe codecs, giving up\n"); in azx_probe_continue()
2392 err = snd_card_register(chip->card); in azx_probe_continue()
2398 chip->running = 1; in azx_probe_continue()
2404 pm_runtime_use_autosuspend(&pci->dev); in azx_probe_continue()
2405 pm_runtime_allow(&pci->dev); in azx_probe_continue()
2406 pm_runtime_put_autosuspend(&pci->dev); in azx_probe_continue()
2412 snd_card_free(chip->card); in azx_probe_continue()
2416 if (!hda->need_i915_power) in azx_probe_continue()
2418 complete_all(&hda->probe_wait); in azx_probe_continue()
2419 to_hda_bus(bus)->bus_probing = 0; in azx_probe_continue()
2420 hda->probe_retry = 0; in azx_probe_continue()
2432 chip = card->private_data; in azx_remove()
2445 device_unlock(&pci->dev); in azx_remove()
2446 cancel_delayed_work_sync(&hda->probe_work); in azx_remove()
2447 device_lock(&pci->dev); in azx_remove()
2449 clear_bit(chip->dev_index, probed_devs); in azx_remove()
2462 chip = card->private_data; in azx_shutdown()
2463 if (chip && chip->running) in azx_shutdown()
2485 /* Lynx Point-LP */
2487 /* Lynx Point-LP */
2489 /* Wildcat Point-LP */
2493 /* Skylake-LP (Sunrise Point-LP) */
2497 /* Kabylake-LP */
2499 /* Kabylake-H */
2505 /* CometLake-LP */
2507 /* CometLake-H */
2510 /* CometLake-S */
2512 /* CometLake-R */
2516 /* Icelake-H */
2523 /* Tigerlake-H */
2531 /* Alderlake-S */
2533 /* Alderlake-P */
2537 /* Alderlake-M */
2539 /* Alderlake-N */
2551 /* Lunarlake-P */
2553 /* Arrow Lake-S */
2557 /* Apollolake (Broxton-P) */
2559 /* Gemini-Lake */
2600 /* ATI SB 450/600/700/800/900 */
2601 { PCI_VDEVICE(ATI, 0x437b),
2603 { PCI_VDEVICE(ATI, 0x4383),
2621 /* ATI HDMI */
2622 { PCI_VDEVICE(ATI, 0x0002),
2625 { PCI_VDEVICE(ATI, 0x1308),
2627 { PCI_VDEVICE(ATI, 0x157a),
2629 { PCI_VDEVICE(ATI, 0x15b3),
2631 { PCI_VDEVICE(ATI, 0x793b),
2633 { PCI_VDEVICE(ATI, 0x7919),
2635 { PCI_VDEVICE(ATI, 0x960f),
2637 { PCI_VDEVICE(ATI, 0x970f),
2639 { PCI_VDEVICE(ATI, 0x9840),
2641 { PCI_VDEVICE(ATI, 0xaa00),
2643 { PCI_VDEVICE(ATI, 0xaa08),
2645 { PCI_VDEVICE(ATI, 0xaa10),
2647 { PCI_VDEVICE(ATI, 0xaa18),
2649 { PCI_VDEVICE(ATI, 0xaa20),
2651 { PCI_VDEVICE(ATI, 0xaa28),
2653 { PCI_VDEVICE(ATI, 0xaa30),
2655 { PCI_VDEVICE(ATI, 0xaa38),
2657 { PCI_VDEVICE(ATI, 0xaa40),
2659 { PCI_VDEVICE(ATI, 0xaa48),
2661 { PCI_VDEVICE(ATI, 0xaa50),
2663 { PCI_VDEVICE(ATI, 0xaa58),
2665 { PCI_VDEVICE(ATI, 0xaa60),
2667 { PCI_VDEVICE(ATI, 0xaa68),
2669 { PCI_VDEVICE(ATI, 0xaa80),
2671 { PCI_VDEVICE(ATI, 0xaa88),
2673 { PCI_VDEVICE(ATI, 0xaa90),
2675 { PCI_VDEVICE(ATI, 0xaa98),
2677 { PCI_VDEVICE(ATI, 0x9902),
2679 { PCI_VDEVICE(ATI, 0xaaa0),
2681 { PCI_VDEVICE(ATI, 0xaaa8),
2683 { PCI_VDEVICE(ATI, 0xaab0),
2685 { PCI_VDEVICE(ATI, 0xaac0),
2688 { PCI_VDEVICE(ATI, 0xaac8),
2691 { PCI_VDEVICE(ATI, 0xaad8),
2694 { PCI_VDEVICE(ATI, 0xaae0),
2697 { PCI_VDEVICE(ATI, 0xaae8),
2700 { PCI_VDEVICE(ATI, 0xaaf0),
2703 { PCI_VDEVICE(ATI, 0xaaf8),
2706 { PCI_VDEVICE(ATI, 0xab00),
2709 { PCI_VDEVICE(ATI, 0xab08),
2712 { PCI_VDEVICE(ATI, 0xab10),
2715 { PCI_VDEVICE(ATI, 0xab18),
2718 { PCI_VDEVICE(ATI, 0xab20),
2721 { PCI_VDEVICE(ATI, 0xab28),
2724 { PCI_VDEVICE(ATI, 0xab30),
2727 { PCI_VDEVICE(ATI, 0xab38),
2730 { PCI_VDEVICE(ATI, 0xab40),
2759 /* Creative X-Fi (CA0110-IBG) */
2766 /* the following entry conflicts with snd-ctxfi driver,
2767 * as ctxfi driver mutates from HD-audio to native mode with
2776 /* this entry seems still valid -- i.e. without emu20kx chip */
2789 /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */