Lines Matching +full:noise +full:- +full:sensitive

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>
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 "
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
193 static int align_buffer_size = -1;
199 static int hda_snoop = -1;
246 (((chip)->driver_caps & AZX_DCAPS_SNOOP_MASK) >> 10)
326 #define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo)
327 #define needs_eld_notify_link(chip) ((chip)->bus.keep_power)
350 [AZX_DRIVER_CMEDIA] = "HDA C-Media",
353 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
378 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) in azx_init_pci()
384 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) { in azx_init_pci()
385 dev_dbg(chip->card->dev, "Clearing TCSEL\n"); in azx_init_pci()
386 update_pci_byte(chip->pci, AZX_PCIREG_TCSEL, 0x07, 0); in azx_init_pci()
393 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n", in azx_init_pci()
395 update_pci_byte(chip->pci, in azx_init_pci()
402 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n", in azx_init_pci()
404 update_pci_byte(chip->pci, in azx_init_pci()
407 update_pci_byte(chip->pci, in azx_init_pci()
410 update_pci_byte(chip->pci, in azx_init_pci()
418 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); in azx_init_pci()
424 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop); in azx_init_pci()
425 pci_read_config_word(chip->pci, in azx_init_pci()
428 dev_dbg(chip->card->dev, "SCH snoop: %s\n", in azx_init_pci()
435 * In BXT-P A0, HD-Audio DMA requests is later than expected,
436 * and makes an audio stream sensitive to system latencies when
466 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCAP); in intel_get_lctl_scf()
474 dev_warn(chip->card->dev, "set audio clock frequency to 6MHz"); in intel_get_lctl_scf()
485 * Changes to LCTL.SCF are only needed for the first multi-link dealing in intel_ml_lctl_set_power()
488 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
491 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
495 if (((readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL)) & in intel_ml_lctl_set_power()
498 timeout--; in intel_ml_lctl_set_power()
502 return -1; in intel_ml_lctl_set_power()
512 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
534 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
545 struct pci_dev *pci = chip->pci; in hda_intel_init_chip()
549 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
555 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
563 /* reduce dma latency to avoid noise */ in hda_intel_init_chip()
567 if (bus->mlcap != NULL) in hda_intel_init_chip()
575 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_lpib()
576 int stream = substream->stream; in azx_get_delay_from_lpib()
581 delay = pos - lpib_pos; in azx_get_delay_from_lpib()
583 delay = lpib_pos - pos; in azx_get_delay_from_lpib()
585 if (delay >= azx_dev->core.delay_negative_threshold) in azx_get_delay_from_lpib()
588 delay += azx_dev->core.bufsize; in azx_get_delay_from_lpib()
591 if (delay >= azx_dev->core.period_bytes) { in azx_get_delay_from_lpib()
592 dev_info(chip->card->dev, in azx_get_delay_from_lpib()
594 delay, azx_dev->core.period_bytes); in azx_get_delay_from_lpib()
596 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; in azx_get_delay_from_lpib()
597 chip->get_delay[stream] = NULL; in azx_get_delay_from_lpib()
600 return bytes_to_frames(substream->runtime, delay); in azx_get_delay_from_lpib()
613 azx_dev->irq_pending = 0; in azx_position_check()
617 azx_dev->irq_pending = 1; in azx_position_check()
618 schedule_work(&hda->irq_pending_work); in azx_position_check()
628 * periods. Returns non-zero if it's OK.
630 * Many HD-audio controllers appear pretty inaccurate about
631 * the update-IRQ timing. The IRQ is issued before actually the
635 * Returns 1 if OK to proceed, 0 for delay handling, -1 for skipping update
639 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_position_ok()
640 struct snd_pcm_runtime *runtime = substream->runtime; in azx_position_ok()
641 int stream = substream->stream; in azx_position_ok()
650 if (chip->driver_type == AZX_DRIVER_LOONGSON) in azx_position_ok()
653 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk; in azx_position_ok()
654 if (wallclk < (azx_dev->core.period_wallclk * 2) / 3) in azx_position_ok()
655 return -1; /* bogus (too early) interrupt */ in azx_position_ok()
657 if (chip->get_position[stream]) in azx_position_ok()
658 pos = chip->get_position[stream](chip, azx_dev); in azx_position_ok()
661 if (!pos || pos == (u32)-1) { in azx_position_ok()
662 dev_info(chip->card->dev, in azx_position_ok()
664 chip->get_position[stream] = azx_get_pos_lpib; in azx_position_ok()
665 if (chip->get_position[0] == azx_get_pos_lpib && in azx_position_ok()
666 chip->get_position[1] == azx_get_pos_lpib) in azx_position_ok()
667 azx_bus(chip)->use_posbuf = false; in azx_position_ok()
669 chip->get_delay[stream] = NULL; in azx_position_ok()
671 chip->get_position[stream] = azx_get_pos_posbuf; in azx_position_ok()
672 if (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY) in azx_position_ok()
673 chip->get_delay[stream] = azx_get_delay_from_lpib; in azx_position_ok()
677 if (pos >= azx_dev->core.bufsize) in azx_position_ok()
680 if (WARN_ONCE(!azx_dev->core.period_bytes, in azx_position_ok()
681 "hda-intel: zero azx_dev->period_bytes")) in azx_position_ok()
682 return -1; /* this shouldn't happen! */ in azx_position_ok()
683 if (wallclk < (azx_dev->core.period_wallclk * 5) / 4 && in azx_position_ok()
684 pos % azx_dev->core.period_bytes > azx_dev->core.period_bytes / 2) in azx_position_ok()
685 /* NG - it's below the first next period boundary */ in azx_position_ok()
686 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
687 azx_dev->core.start_wallclk += wallclk; in azx_position_ok()
689 if (azx_dev->core.no_period_wakeup) in azx_position_ok()
692 if (runtime->hw_ptr_base != runtime->hw_ptr_interrupt) in azx_position_ok()
697 hwptr = runtime->hw_ptr_base + pos; in azx_position_ok()
698 if (hwptr < runtime->status->hw_ptr) in azx_position_ok()
699 hwptr += runtime->buffer_size; in azx_position_ok()
700 target = runtime->hw_ptr_interrupt + runtime->period_size; in azx_position_ok()
703 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
715 struct azx *chip = &hda->chip; in azx_irq_pending_work()
720 if (!hda->irq_pending_warned) { in azx_irq_pending_work()
721 dev_info(chip->card->dev, in azx_irq_pending_work()
723 chip->card->number); in azx_irq_pending_work()
724 hda->irq_pending_warned = 1; in azx_irq_pending_work()
729 spin_lock_irq(&bus->reg_lock); in azx_irq_pending_work()
730 list_for_each_entry(s, &bus->stream_list, list) { in azx_irq_pending_work()
732 if (!azx_dev->irq_pending || in azx_irq_pending_work()
733 !s->substream || in azx_irq_pending_work()
734 !s->running) in azx_irq_pending_work()
738 azx_dev->irq_pending = 0; in azx_irq_pending_work()
739 spin_unlock(&bus->reg_lock); in azx_irq_pending_work()
740 snd_pcm_period_elapsed(s->substream); in azx_irq_pending_work()
741 spin_lock(&bus->reg_lock); in azx_irq_pending_work()
747 spin_unlock_irq(&bus->reg_lock); in azx_irq_pending_work()
754 /* clear irq_pending flags and assure no on-going workq */
760 spin_lock_irq(&bus->reg_lock); in azx_clear_irq_pending()
761 list_for_each_entry(s, &bus->stream_list, list) { in azx_clear_irq_pending()
763 azx_dev->irq_pending = 0; in azx_clear_irq_pending()
765 spin_unlock_irq(&bus->reg_lock); in azx_clear_irq_pending()
772 if (request_irq(chip->pci->irq, azx_interrupt, in azx_acquire_irq()
773 chip->msi ? 0 : IRQF_SHARED, in azx_acquire_irq()
774 chip->card->irq_descr, chip)) { in azx_acquire_irq()
775 dev_err(chip->card->dev, in azx_acquire_irq()
777 chip->pci->irq); in azx_acquire_irq()
779 snd_card_disconnect(chip->card); in azx_acquire_irq()
780 return -1; in azx_acquire_irq()
782 bus->irq = chip->pci->irq; in azx_acquire_irq()
783 chip->card->sync_irq = bus->irq; in azx_acquire_irq()
784 pci_intx(chip->pci, !chip->msi); in azx_acquire_irq()
797 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in azx_via_get_position()
806 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); in azx_via_get_position()
807 mod_dma_pos %= azx_dev->core.period_bytes; in azx_via_get_position()
809 fifo_size = azx_stream(azx_dev)->fifo_size - 1; in azx_via_get_position()
811 if (azx_dev->insufficient) { in azx_via_get_position()
816 azx_dev->insufficient = 0; in azx_via_get_position()
820 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; in azx_via_get_position()
822 mini_pos = link_pos - fifo_size; in azx_via_get_position()
825 mod_mini_pos = mini_pos % azx_dev->core.period_bytes; in azx_via_get_position()
826 mod_link_pos = link_pos % azx_dev->core.period_bytes; in azx_via_get_position()
828 bound_pos = link_pos - mod_link_pos; in azx_via_get_position()
830 bound_pos = mini_pos - mod_mini_pos; in azx_via_get_position()
832 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; in azx_via_get_position()
833 if (bound_pos >= azx_dev->core.bufsize) in azx_via_get_position()
846 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_pos_fifo()
847 struct snd_pcm_runtime *runtime = substream->runtime; in azx_get_pos_fifo()
854 runtime->delay = AMD_FIFO_SIZE; in azx_get_pos_fifo()
856 if (azx_dev->insufficient) { in azx_get_pos_fifo()
859 runtime->delay = bytes_to_frames(runtime, pos); in azx_get_pos_fifo()
861 azx_dev->insufficient = 0; in azx_get_pos_fifo()
866 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in azx_get_pos_fifo()
868 pos += azx_dev->core.bufsize; in azx_get_pos_fifo()
869 pos -= delay; in azx_get_pos_fifo()
878 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_fifo()
881 return substream->runtime->delay; in azx_get_delay_from_fifo()
906 list_add(&hda->list, &card_list); in azx_add_card_list()
914 list_del_init(&hda->list); in azx_del_card_list()
918 /* trigger power-save check at writing parameter */
931 chip = &hda->chip; in param_set_xint()
932 if (!hda->probe_continued || chip->disabled) in param_set_xint()
934 snd_hda_set_power_save(&chip->bus, power_save * 1000); in param_set_xint()
950 chip = card->private_data; in azx_is_pm_ready()
952 if (chip->disabled || hda->init_failed || !chip->running) in azx_is_pm_ready()
965 if (hda->need_i915_power) in __azx_runtime_resume()
975 if (!chip->pm_prepared) { in __azx_runtime_resume()
976 list_for_each_codec(codec, &chip->bus) { in __azx_runtime_resume()
977 if (codec->relaxed_resume) in __azx_runtime_resume()
980 if (codec->forced_resume || (status & (1 << codec->addr))) in __azx_runtime_resume()
985 /* power down again for link-controlled chips */ in __azx_runtime_resume()
986 if (!hda->need_i915_power) in __azx_runtime_resume()
999 chip = card->private_data; in azx_prepare()
1000 chip->pm_prepared = 1; in azx_prepare()
1003 flush_work(&azx_bus(chip)->unsol_work); in azx_prepare()
1006 * and system suspend, so don't use direct-complete here. in azx_prepare()
1019 chip = card->private_data; in azx_complete()
1021 chip->pm_prepared = 0; in azx_complete()
1033 chip = card->private_data; in azx_suspend()
1036 if (bus->irq >= 0) { in azx_suspend()
1037 free_irq(bus->irq, chip); in azx_suspend()
1038 bus->irq = -1; in azx_suspend()
1039 chip->card->sync_irq = -1; in azx_suspend()
1042 if (chip->msi) in azx_suspend()
1043 pci_disable_msi(chip->pci); in azx_suspend()
1057 chip = card->private_data; in azx_resume()
1058 if (chip->msi) in azx_resume()
1059 if (pci_enable_msi(chip->pci) < 0) in azx_resume()
1060 chip->msi = 0; in azx_resume()
1062 return -EIO; in azx_resume()
1076 struct azx *chip = card->private_data; in azx_freeze_noirq()
1081 if (chip->driver_type == AZX_DRIVER_SKL) in azx_freeze_noirq()
1090 struct azx *chip = card->private_data; in azx_thaw_noirq()
1095 if (chip->driver_type == AZX_DRIVER_SKL) in azx_thaw_noirq()
1109 chip = card->private_data; in azx_runtime_suspend()
1126 chip = card->private_data; in azx_runtime_resume()
1145 chip = card->private_data; in azx_runtime_idle()
1147 if (chip->disabled || hda->init_failed) in azx_runtime_idle()
1151 azx_bus(chip)->codec_powered || !chip->running) in azx_runtime_idle()
1152 return -EBUSY; in azx_runtime_idle()
1154 /* ELD notification gets broken when HD-audio bus is off */ in azx_runtime_idle()
1156 return -EBUSY; in azx_runtime_idle()
1189 struct azx *chip = card->private_data; in azx_vs_set_state()
1194 wait_for_completion(&hda->probe_wait); in azx_vs_set_state()
1195 if (hda->init_failed) in azx_vs_set_state()
1199 if (chip->disabled == disabled) in azx_vs_set_state()
1202 if (!hda->probe_continued) { in azx_vs_set_state()
1203 chip->disabled = disabled; in azx_vs_set_state()
1205 dev_info(chip->card->dev, in azx_vs_set_state()
1208 dev_err(chip->card->dev, "initialization error\n"); in azx_vs_set_state()
1211 dev_info(chip->card->dev, "%s via vga_switcheroo\n", in azx_vs_set_state()
1214 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1218 pm_runtime_suspend(card->dev); in azx_vs_set_state()
1219 pm_runtime_disable(card->dev); in azx_vs_set_state()
1223 pci->current_state = PCI_D3cold; in azx_vs_set_state()
1224 chip->disabled = true; in azx_vs_set_state()
1225 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_set_state()
1226 dev_warn(chip->card->dev, in azx_vs_set_state()
1229 snd_hda_unlock_devices(&chip->bus); in azx_vs_set_state()
1230 chip->disabled = false; in azx_vs_set_state()
1231 pm_runtime_enable(card->dev); in azx_vs_set_state()
1232 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1243 struct azx *chip = card->private_data; in azx_vs_can_switch()
1246 wait_for_completion(&hda->probe_wait); in azx_vs_can_switch()
1247 if (hda->init_failed) in azx_vs_can_switch()
1249 if (chip->disabled || !hda->probe_continued) in azx_vs_can_switch()
1251 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_can_switch()
1253 snd_hda_unlock_devices(&chip->bus); in azx_vs_can_switch()
1266 if (hda->use_vga_switcheroo && !needs_eld_notify_link(chip)) { in setup_vga_switcheroo_runtime_pm()
1267 list_for_each_codec(codec, &chip->bus) in setup_vga_switcheroo_runtime_pm()
1268 codec->auto_runtime_pm = 1; in setup_vga_switcheroo_runtime_pm()
1270 if (chip->running) in setup_vga_switcheroo_runtime_pm()
1279 struct azx *chip = card->private_data; in azx_vs_gpu_bound()
1282 chip->bus.keep_power = 0; in azx_vs_gpu_bound()
1289 struct pci_dev *p = get_bound_vga(chip->pci); in init_vga_switcheroo()
1292 dev_info(chip->card->dev, in init_vga_switcheroo()
1294 hda->use_vga_switcheroo = 1; in init_vga_switcheroo()
1300 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1; in init_vga_switcheroo()
1301 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME; in init_vga_switcheroo()
1318 if (!hda->use_vga_switcheroo) in register_vga_switcheroo()
1321 p = get_bound_vga(chip->pci); in register_vga_switcheroo()
1322 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p); in register_vga_switcheroo()
1327 hda->vga_switcheroo_registered = 1; in register_vga_switcheroo()
1343 struct pci_dev *pci = chip->pci; in azx_free()
1347 if (hda->freed) in azx_free()
1350 if (azx_has_pm_runtime(chip) && chip->running) { in azx_free()
1351 pm_runtime_get_noresume(&pci->dev); in azx_free()
1352 pm_runtime_forbid(&pci->dev); in azx_free()
1353 pm_runtime_dont_use_autosuspend(&pci->dev); in azx_free()
1356 chip->running = 0; in azx_free()
1360 hda->init_failed = 1; /* to be sure */ in azx_free()
1361 complete_all(&hda->probe_wait); in azx_free()
1364 if (chip->disabled && hda->probe_continued) in azx_free()
1365 snd_hda_unlock_devices(&chip->bus); in azx_free()
1366 if (hda->vga_switcheroo_registered) in azx_free()
1367 vga_switcheroo_unregister_client(chip->pci); in azx_free()
1370 if (bus->chip_init) { in azx_free()
1376 if (bus->irq >= 0) in azx_free()
1377 free_irq(bus->irq, (void*)chip); in azx_free()
1384 release_firmware(chip->fw); in azx_free()
1388 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) in azx_free()
1391 hda->freed = 1; in azx_free()
1396 struct azx *chip = device->device_data; in azx_dev_disconnect()
1399 chip->bus.shutdown = 1; in azx_dev_disconnect()
1400 cancel_work_sync(&bus->unsol_work); in azx_dev_disconnect()
1407 azx_free(device->device_data); in azx_dev_free()
1421 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1431 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1457 switch (pci->vendor) { 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()
1469 if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) && in get_bound_vga()
1477 if (pci->devfn == 1) { in get_bound_vga()
1478 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1479 pci->bus->number, 0); in get_bound_vga()
1481 if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) in get_bound_vga()
1506 * allow/deny-listing for position_fix
1518 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1521 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1522 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1541 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); in check_position_fix()
1543 dev_info(chip->card->dev, in check_position_fix()
1545 q->value, q->subvendor, q->subdevice); in check_position_fix()
1546 return q->value; in check_position_fix()
1550 if (chip->driver_type == AZX_DRIVER_VIA) { in check_position_fix()
1551 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); in check_position_fix()
1554 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) { in check_position_fix()
1555 dev_dbg(chip->card->dev, "Using FIFO position fix\n"); in check_position_fix()
1558 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { in check_position_fix()
1559 dev_dbg(chip->card->dev, "Using LPIB position fix\n"); in check_position_fix()
1562 if (chip->driver_type == AZX_DRIVER_SKL) { in check_position_fix()
1563 dev_dbg(chip->card->dev, "Using SKL position fix\n"); in check_position_fix()
1581 chip->get_position[0] = chip->get_position[1] = callbacks[fix]; in assign_position_fix()
1585 chip->get_position[1] = NULL; in assign_position_fix()
1588 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { in assign_position_fix()
1589 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1594 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1599 * deny-lists for probe_mask
1603 * to the non-working (or non-existing) modem codec slot.
1627 chip->codec_probe_mask = probe_mask[dev]; in check_probe_mask()
1628 if (chip->codec_probe_mask == -1) { in check_probe_mask()
1629 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); in check_probe_mask()
1631 dev_info(chip->card->dev, in check_probe_mask()
1633 q->value, q->subvendor, q->subdevice); in check_probe_mask()
1634 chip->codec_probe_mask = q->value; in check_probe_mask()
1639 if (chip->codec_probe_mask != -1 && in check_probe_mask()
1640 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { in check_probe_mask()
1641 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff; in check_probe_mask()
1642 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n", in check_probe_mask()
1643 (int)azx_bus(chip)->codec_mask); in check_probe_mask()
1648 * allow/deny-list for enable_msi
1660 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1669 chip->msi = !!enable_msi; in check_msi()
1672 chip->msi = 1; /* enable MSI as default */ in check_msi()
1673 q = snd_pci_quirk_lookup(chip->pci, msi_deny_list); in check_msi()
1675 dev_info(chip->card->dev, in check_msi()
1677 q->subvendor, q->subdevice, q->value); in check_msi()
1678 chip->msi = q->value; in check_msi()
1683 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { in check_msi()
1684 dev_info(chip->card->dev, "Disabling MSI\n"); in check_msi()
1685 chip->msi = 0; in check_msi()
1695 dev_info(chip->card->dev, "Force to %s mode by module option\n", in azx_check_snoop_available()
1696 snoop ? "snoop" : "non-snoop"); in azx_check_snoop_available()
1697 chip->snoop = snoop; in azx_check_snoop_available()
1698 chip->uc_buffer = !snoop; in azx_check_snoop_available()
1704 chip->driver_type == AZX_DRIVER_VIA) { in azx_check_snoop_available()
1705 /* force to non-snoop mode for a new VIA controller in azx_check_snoop_available()
1709 pci_read_config_byte(chip->pci, 0x42, &val); in azx_check_snoop_available()
1710 if (!(val & 0x80) && (chip->pci->revision == 0x30 || in azx_check_snoop_available()
1711 chip->pci->revision == 0x20)) in azx_check_snoop_available()
1715 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) in azx_check_snoop_available()
1718 chip->snoop = snoop; in azx_check_snoop_available()
1720 dev_info(chip->card->dev, "Force to non-snoop mode\n"); in azx_check_snoop_available()
1721 /* C-Media requires non-cached pages only for CORB/RIRB */ in azx_check_snoop_available()
1722 if (chip->driver_type != AZX_DRIVER_CMEDIA) in azx_check_snoop_available()
1723 chip->uc_buffer = true; in azx_check_snoop_available()
1730 azx_probe_continue(&hda->chip); in azx_probe_work()
1736 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) { in default_bdl_pos_adj()
1737 switch (chip->pci->device) { in default_bdl_pos_adj()
1746 switch (chip->driver_type) { in default_bdl_pos_adj()
1784 hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL); in azx_create()
1786 return -ENOMEM; in azx_create()
1788 chip = &hda->chip; in azx_create()
1789 mutex_init(&chip->open_mutex); in azx_create()
1790 chip->card = card; in azx_create()
1791 chip->pci = pci; in azx_create()
1792 chip->ops = &pci_hda_ops; in azx_create()
1793 chip->driver_caps = driver_caps; in azx_create()
1794 chip->driver_type = driver_caps & 0xff; in azx_create()
1796 chip->dev_index = dev; in azx_create()
1798 chip->jackpoll_interval = msecs_to_jiffies(jackpoll_ms[dev]); in azx_create()
1799 INIT_LIST_HEAD(&chip->pcm_list); in azx_create()
1800 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); in azx_create()
1801 INIT_LIST_HEAD(&hda->list); in azx_create()
1803 init_completion(&hda->probe_wait); in azx_create()
1808 chip->fallback_to_single_cmd = 1; in azx_create()
1810 chip->single_cmd = single_cmd; in azx_create()
1815 chip->bdl_pos_adj = default_bdl_pos_adj(chip); in azx_create()
1817 chip->bdl_pos_adj = bdl_pos_adj[dev]; in azx_create()
1823 /* use the non-cached pages in non-snoop mode */ in azx_create()
1825 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC_SG; in azx_create()
1827 if (chip->driver_type == AZX_DRIVER_NVIDIA) { in azx_create()
1828 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); in azx_create()
1829 chip->bus.core.needs_damn_long_delay = 1; in azx_create()
1836 dev_err(card->dev, "Error creating device [card]!\n"); in azx_create()
1842 INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work); in azx_create()
1851 int dev = chip->dev_index; in azx_first_init()
1852 struct pci_dev *pci = chip->pci; in azx_first_init()
1853 struct snd_card *card = chip->card; in azx_first_init()
1861 if (chip->driver_type == AZX_DRIVER_ULI) { in azx_first_init()
1872 if (chip->driver_type == AZX_DRIVER_GFHDMI) in azx_first_init()
1873 bus->polling_mode = 1; in azx_first_init()
1875 if (chip->driver_type == AZX_DRIVER_LOONGSON) { in azx_first_init()
1876 bus->polling_mode = 1; in azx_first_init()
1877 bus->not_use_interrupts = 1; in azx_first_init()
1878 bus->access_sdnctl_in_dword = 1; in azx_first_init()
1885 bus->addr = pci_resource_start(pci, 0); in azx_first_init()
1886 bus->remap_addr = pcim_iomap_table(pci)[0]; in azx_first_init()
1888 if (chip->driver_type == AZX_DRIVER_SKL) in azx_first_init()
1897 chip->gts_present = false; in azx_first_init()
1900 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART)) in azx_first_init()
1901 chip->gts_present = true; in azx_first_init()
1904 if (chip->msi) { in azx_first_init()
1905 if (chip->driver_caps & AZX_DCAPS_NO_MSI64) { in azx_first_init()
1906 dev_dbg(card->dev, "Disabling 64bit MSI\n"); in azx_first_init()
1907 pci->no_64bit_msi = true; in azx_first_init()
1910 chip->msi = 0; in azx_first_init()
1916 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); in azx_first_init()
1919 if (chip->pci->vendor == PCI_VENDOR_ID_AMD) in azx_first_init()
1923 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { in azx_first_init()
1930 if (p_smbus->revision < 0x30) in azx_first_init()
1937 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA) in azx_first_init()
1941 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { in azx_first_init()
1942 dev_dbg(card->dev, "Disabling 64bit DMA\n"); in azx_first_init()
1946 /* disable buffer size rounding to 128-byte multiples if supported */ in azx_first_init()
1948 chip->align_buffer_size = !!align_buffer_size; in azx_first_init()
1950 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE) in azx_first_init()
1951 chip->align_buffer_size = 0; in azx_first_init()
1953 chip->align_buffer_size = 1; in azx_first_init()
1959 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits))) in azx_first_init()
1960 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1961 dma_set_max_seg_size(&pci->dev, UINT_MAX); in azx_first_init()
1966 chip->capture_streams = (gcap >> 8) & 0x0f; in azx_first_init()
1967 chip->playback_streams = (gcap >> 12) & 0x0f; in azx_first_init()
1968 if (!chip->playback_streams && !chip->capture_streams) { in azx_first_init()
1971 switch (chip->driver_type) { in azx_first_init()
1973 chip->playback_streams = ULI_NUM_PLAYBACK; in azx_first_init()
1974 chip->capture_streams = ULI_NUM_CAPTURE; in azx_first_init()
1978 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; in azx_first_init()
1979 chip->capture_streams = ATIHDMI_NUM_CAPTURE; in azx_first_init()
1984 chip->playback_streams = ICH6_NUM_PLAYBACK; in azx_first_init()
1985 chip->capture_streams = ICH6_NUM_CAPTURE; in azx_first_init()
1989 chip->capture_index_offset = 0; in azx_first_init()
1990 chip->playback_index_offset = chip->capture_streams; in azx_first_init()
1991 chip->num_streams = chip->playback_streams + chip->capture_streams; in azx_first_init()
1994 if (chip->num_streams > 15 && in azx_first_init()
1995 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) { in azx_first_init()
1996 dev_warn(chip->card->dev, "number of I/O streams is %d, " in azx_first_init()
1997 "forcing separate stream tags", chip->num_streams); in azx_first_init()
1998 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG; in azx_first_init()
2018 if (!azx_bus(chip)->codec_mask) { in azx_first_init()
2019 dev_err(card->dev, "no codecs found!\n"); in azx_first_init()
2024 return -EBUSY; in azx_first_init()
2026 strcpy(card->driver, "HDA-Intel"); in azx_first_init()
2027 strscpy(card->shortname, driver_short_names[chip->driver_type], in azx_first_init()
2028 sizeof(card->shortname)); in azx_first_init()
2029 snprintf(card->longname, sizeof(card->longname), in azx_first_init()
2031 card->shortname, bus->addr, bus->irq); in azx_first_init()
2041 struct azx *chip = card->private_data; in azx_firmware_cb()
2044 chip->fw = fw; in azx_firmware_cb()
2046 dev_err(card->dev, "Cannot load firmware, continue without patching\n"); in azx_firmware_cb()
2047 if (!chip->disabled) { in azx_firmware_cb()
2059 free_irq(bus->irq, chip); in disable_msi_reset_irq()
2060 bus->irq = -1; in disable_msi_reset_irq()
2061 chip->card->sync_irq = -1; in disable_msi_reset_irq()
2062 pci_disable_msi(chip->pci); in disable_msi_reset_irq()
2063 chip->msi = 0; in disable_msi_reset_irq()
2072 * some HD-audio PCI entries are exposed without any codecs, and such devices
2100 dev_info(&pci->dev, "Skipping the device on the denylist\n"); in azx_probe()
2101 return -ENODEV; in azx_probe()
2106 return -ENODEV; in azx_probe()
2109 return -ENOENT; in azx_probe()
2118 dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n"); in azx_probe()
2119 return -ENODEV; in azx_probe()
2122 …dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option i… in azx_probe()
2125 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in azx_probe()
2128 dev_err(&pci->dev, "Error creating card!\n"); in azx_probe()
2132 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); in azx_probe()
2135 card->private_data = chip; in azx_probe()
2142 dev_err(card->dev, "Error registering vga_switcheroo client\n"); in azx_probe()
2147 dev_info(card->dev, "VGA controller is disabled\n"); in azx_probe()
2148 dev_info(card->dev, "Delaying initialization\n"); in azx_probe()
2149 chip->disabled = true; in azx_probe()
2152 schedule_probe = !chip->disabled; in azx_probe()
2156 dev_info(card->dev, "Applying patch firmware '%s'\n", in azx_probe()
2159 &pci->dev, GFP_KERNEL, card, in azx_probe()
2169 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n"); in azx_probe()
2173 schedule_delayed_work(&hda->probe_work, 0); in azx_probe()
2176 if (chip->disabled) in azx_probe()
2177 complete_all(&hda->probe_wait); in azx_probe()
2194 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2196 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2198 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2200 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2204 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2205 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2207 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2237 q = snd_pci_quirk_lookup(chip->pci, power_save_denylist); in set_default_power_save()
2239 …dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0… in set_default_power_save()
2240 q->subvendor, q->subdevice); in set_default_power_save()
2245 snd_hda_set_power_save(&chip->bus, val * 1000); in set_default_power_save()
2258 struct pci_dev *pci = chip->pci; in azx_probe_continue()
2259 int dev = chip->dev_index; in azx_probe_continue()
2262 if (chip->disabled || hda->init_failed) in azx_probe_continue()
2263 return -EIO; in azx_probe_continue()
2264 if (hda->probe_retry) in azx_probe_continue()
2267 to_hda_bus(bus)->bus_probing = 1; in azx_probe_continue()
2268 hda->probe_continued = 1; in azx_probe_continue()
2271 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) { in azx_probe_continue()
2280 dev_err(chip->card->dev, in azx_probe_continue()
2281 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n"); in azx_probe_continue()
2285 chip->driver_caps &= ~AZX_DCAPS_I915_COMPONENT; in azx_probe_continue()
2291 hda->need_i915_power = true; in azx_probe_continue()
2306 chip->beep_mode = beep_mode[dev]; in azx_probe_continue()
2309 chip->ctl_dev_id = ctl_dev_id; in azx_probe_continue()
2312 if (bus->codec_mask) { in azx_probe_continue()
2313 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); in azx_probe_continue()
2319 if (chip->fw) { in azx_probe_continue()
2320 err = snd_hda_load_patch(&chip->bus, chip->fw->size, in azx_probe_continue()
2321 chip->fw->data); in azx_probe_continue()
2325 release_firmware(chip->fw); /* no longer needed */ in azx_probe_continue()
2326 chip->fw = NULL; in azx_probe_continue()
2332 if (bus->codec_mask && !(probe_only[dev] & 1)) { in azx_probe_continue()
2335 if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) && in azx_probe_continue()
2336 ++hda->probe_retry < 60) { in azx_probe_continue()
2337 schedule_delayed_work(&hda->probe_work, in azx_probe_continue()
2341 dev_err(chip->card->dev, "Cannot probe codecs, giving up\n"); in azx_probe_continue()
2346 err = snd_card_register(chip->card); in azx_probe_continue()
2352 chip->running = 1; in azx_probe_continue()
2358 pm_runtime_use_autosuspend(&pci->dev); in azx_probe_continue()
2359 pm_runtime_allow(&pci->dev); in azx_probe_continue()
2360 pm_runtime_put_autosuspend(&pci->dev); in azx_probe_continue()
2366 snd_card_free(chip->card); in azx_probe_continue()
2370 if (!hda->need_i915_power) in azx_probe_continue()
2372 complete_all(&hda->probe_wait); in azx_probe_continue()
2373 to_hda_bus(bus)->bus_probing = 0; in azx_probe_continue()
2374 hda->probe_retry = 0; in azx_probe_continue()
2386 chip = card->private_data; in azx_remove()
2399 device_unlock(&pci->dev); in azx_remove()
2400 cancel_delayed_work_sync(&hda->probe_work); in azx_remove()
2401 device_lock(&pci->dev); in azx_remove()
2403 clear_bit(chip->dev_index, probed_devs); in azx_remove()
2416 chip = card->private_data; in azx_shutdown()
2417 if (chip && chip->running) in azx_shutdown()
2439 /* Lynx Point-LP */
2441 /* Lynx Point-LP */
2443 /* Wildcat Point-LP */
2447 /* Skylake-LP (Sunrise Point-LP) */
2451 /* Kabylake-LP */
2453 /* Kabylake-H */
2459 /* CometLake-LP */
2461 /* CometLake-H */
2464 /* CometLake-S */
2466 /* CometLake-R */
2470 /* Icelake-H */
2477 /* Tigerlake-H */
2485 /* Alderlake-S */
2487 /* Alderlake-P */
2491 /* Alderlake-M */
2493 /* Alderlake-N */
2505 /* Lunarlake-P */
2507 /* Arrow Lake-S */
2511 /* Apollolake (Broxton-P) */
2513 /* Gemini-Lake */
2710 /* Creative X-Fi (CA0110-IBG) */
2717 /* the following entry conflicts with snd-ctxfi driver,
2718 * as ctxfi driver mutates from HD-audio to native mode with
2727 /* this entry seems still valid -- i.e. without emu20kx chip */