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>
50 #include <sound/intel-dsp-config.h>
53 #include <linux/apple-gmux.h>
62 /* position fix mode */
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).");
155 MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode "
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
188 MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
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()
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()
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()
777 if (request_irq(chip->pci->irq, azx_interrupt, in azx_acquire_irq()
778 chip->msi ? 0 : IRQF_SHARED, in azx_acquire_irq()
779 chip->card->irq_descr, chip)) { in azx_acquire_irq()
780 dev_err(chip->card->dev, in azx_acquire_irq()
782 chip->pci->irq); in azx_acquire_irq()
784 snd_card_disconnect(chip->card); in azx_acquire_irq()
785 return -1; in azx_acquire_irq()
787 bus->irq = chip->pci->irq; in azx_acquire_irq()
788 chip->card->sync_irq = bus->irq; in azx_acquire_irq()
789 pci_intx(chip->pci, !chip->msi); in azx_acquire_irq()
802 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in azx_via_get_position()
811 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); in azx_via_get_position()
812 mod_dma_pos %= azx_dev->core.period_bytes; in azx_via_get_position()
814 fifo_size = azx_stream(azx_dev)->fifo_size; in azx_via_get_position()
816 if (azx_dev->insufficient) { in azx_via_get_position()
821 azx_dev->insufficient = 0; in azx_via_get_position()
825 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; in azx_via_get_position()
827 mini_pos = link_pos - fifo_size; in azx_via_get_position()
830 mod_mini_pos = mini_pos % azx_dev->core.period_bytes; in azx_via_get_position()
831 mod_link_pos = link_pos % azx_dev->core.period_bytes; in azx_via_get_position()
833 bound_pos = link_pos - mod_link_pos; in azx_via_get_position()
835 bound_pos = mini_pos - mod_mini_pos; in azx_via_get_position()
837 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; in azx_via_get_position()
838 if (bound_pos >= azx_dev->core.bufsize) in azx_via_get_position()
851 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_pos_fifo()
852 struct snd_pcm_runtime *runtime = substream->runtime; in azx_get_pos_fifo()
859 runtime->delay = AMD_FIFO_SIZE; in azx_get_pos_fifo()
861 if (azx_dev->insufficient) { in azx_get_pos_fifo()
864 runtime->delay = bytes_to_frames(runtime, pos); in azx_get_pos_fifo()
866 azx_dev->insufficient = 0; in azx_get_pos_fifo()
871 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in azx_get_pos_fifo()
873 pos += azx_dev->core.bufsize; in azx_get_pos_fifo()
874 pos -= delay; in azx_get_pos_fifo()
883 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_fifo()
886 return substream->runtime->delay; in azx_get_delay_from_fifo()
910 list_add(&hda->list, &card_list); in azx_add_card_list()
918 list_del_init(&hda->list); in azx_del_card_list()
922 /* trigger power-save check at writing parameter */
938 chip = &hda->chip; in param_set_xint()
939 if (!hda->probe_continued || chip->disabled || in param_set_xint()
940 hda->runtime_pm_disabled) in param_set_xint()
942 snd_hda_set_power_save(&chip->bus, power_save * 1000); in param_set_xint()
958 chip = card->private_data; in azx_is_pm_ready()
960 if (chip->disabled || hda->init_failed || !chip->running) in azx_is_pm_ready()
973 if (hda->need_i915_power) in __azx_runtime_resume()
983 if (!chip->pm_prepared) { in __azx_runtime_resume()
984 list_for_each_codec(codec, &chip->bus) { in __azx_runtime_resume()
985 if (codec->relaxed_resume) in __azx_runtime_resume()
988 if (codec->forced_resume || (status & (1 << codec->addr))) in __azx_runtime_resume()
993 /* power down again for link-controlled chips */ in __azx_runtime_resume()
994 if (!hda->need_i915_power) in __azx_runtime_resume()
1006 chip = card->private_data; in azx_prepare()
1007 chip->pm_prepared = 1; in azx_prepare()
1010 flush_work(&azx_bus(chip)->unsol_work); in azx_prepare()
1013 * and system suspend, so don't use direct-complete here. in azx_prepare()
1026 chip = card->private_data; in azx_complete()
1028 chip->pm_prepared = 0; in azx_complete()
1040 chip = card->private_data; in azx_suspend()
1043 if (bus->irq >= 0) { in azx_suspend()
1044 free_irq(bus->irq, chip); in azx_suspend()
1045 bus->irq = -1; in azx_suspend()
1046 chip->card->sync_irq = -1; in azx_suspend()
1049 if (chip->msi) in azx_suspend()
1050 pci_disable_msi(chip->pci); in azx_suspend()
1064 chip = card->private_data; in azx_resume()
1065 if (chip->msi) in azx_resume()
1066 if (pci_enable_msi(chip->pci) < 0) in azx_resume()
1067 chip->msi = 0; in azx_resume()
1069 return -EIO; in azx_resume()
1083 struct azx *chip = card->private_data; in azx_freeze_noirq()
1088 if (chip->driver_type == AZX_DRIVER_SKL) in azx_freeze_noirq()
1097 struct azx *chip = card->private_data; in azx_thaw_noirq()
1102 if (chip->driver_type == AZX_DRIVER_SKL) in azx_thaw_noirq()
1115 chip = card->private_data; in azx_runtime_suspend()
1132 chip = card->private_data; in azx_runtime_resume()
1151 chip = card->private_data; in azx_runtime_idle()
1153 if (chip->disabled || hda->init_failed) in azx_runtime_idle()
1157 azx_bus(chip)->codec_powered || !chip->running) in azx_runtime_idle()
1158 return -EBUSY; in azx_runtime_idle()
1160 /* ELD notification gets broken when HD-audio bus is off */ in azx_runtime_idle()
1162 return -EBUSY; in azx_runtime_idle()
1186 struct azx *chip = card->private_data; in azx_vs_set_state()
1191 wait_for_completion(&hda->probe_wait); in azx_vs_set_state()
1192 if (hda->init_failed) in azx_vs_set_state()
1196 if (chip->disabled == disabled) in azx_vs_set_state()
1199 if (!hda->probe_continued) { in azx_vs_set_state()
1200 chip->disabled = disabled; in azx_vs_set_state()
1202 dev_info(chip->card->dev, in azx_vs_set_state()
1205 dev_err(chip->card->dev, "initialization error\n"); in azx_vs_set_state()
1208 dev_info(chip->card->dev, "%s via vga_switcheroo\n", in azx_vs_set_state()
1211 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1215 pm_runtime_suspend(card->dev); in azx_vs_set_state()
1216 pm_runtime_disable(card->dev); in azx_vs_set_state()
1220 pci->current_state = PCI_D3cold; in azx_vs_set_state()
1221 chip->disabled = true; in azx_vs_set_state()
1222 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_set_state()
1223 dev_warn(chip->card->dev, in azx_vs_set_state()
1226 snd_hda_unlock_devices(&chip->bus); in azx_vs_set_state()
1227 chip->disabled = false; in azx_vs_set_state()
1228 pm_runtime_enable(card->dev); in azx_vs_set_state()
1229 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1240 struct azx *chip = card->private_data; in azx_vs_can_switch()
1243 wait_for_completion(&hda->probe_wait); in azx_vs_can_switch()
1244 if (hda->init_failed) in azx_vs_can_switch()
1246 if (chip->disabled || !hda->probe_continued) in azx_vs_can_switch()
1248 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_can_switch()
1250 snd_hda_unlock_devices(&chip->bus); in azx_vs_can_switch()
1263 if (hda->use_vga_switcheroo && !needs_eld_notify_link(chip)) { in setup_vga_switcheroo_runtime_pm()
1264 list_for_each_codec(codec, &chip->bus) in setup_vga_switcheroo_runtime_pm()
1265 codec->auto_runtime_pm = 1; in setup_vga_switcheroo_runtime_pm()
1267 if (chip->running) in setup_vga_switcheroo_runtime_pm()
1276 struct azx *chip = card->private_data; in azx_vs_gpu_bound()
1279 chip->bus.keep_power = 0; in azx_vs_gpu_bound()
1286 struct pci_dev *p = get_bound_vga(chip->pci); in init_vga_switcheroo()
1289 dev_info(chip->card->dev, in init_vga_switcheroo()
1291 hda->use_vga_switcheroo = 1; in init_vga_switcheroo()
1297 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1; in init_vga_switcheroo()
1298 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME; in init_vga_switcheroo()
1315 if (!hda->use_vga_switcheroo) in register_vga_switcheroo()
1318 p = get_bound_vga(chip->pci); in register_vga_switcheroo()
1319 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p); in register_vga_switcheroo()
1324 hda->vga_switcheroo_registered = 1; in register_vga_switcheroo()
1340 struct pci_dev *pci = chip->pci; in azx_free()
1344 if (hda->freed) in azx_free()
1347 if (azx_has_pm_runtime(chip) && chip->running) { in azx_free()
1348 pm_runtime_get_noresume(&pci->dev); in azx_free()
1349 pm_runtime_forbid(&pci->dev); in azx_free()
1350 pm_runtime_dont_use_autosuspend(&pci->dev); in azx_free()
1353 chip->running = 0; in azx_free()
1357 hda->init_failed = 1; /* to be sure */ in azx_free()
1358 complete_all(&hda->probe_wait); in azx_free()
1361 if (chip->disabled && hda->probe_continued) in azx_free()
1362 snd_hda_unlock_devices(&chip->bus); in azx_free()
1363 if (hda->vga_switcheroo_registered) in azx_free()
1364 vga_switcheroo_unregister_client(chip->pci); in azx_free()
1367 if (bus->chip_init) { in azx_free()
1373 if (bus->irq >= 0) in azx_free()
1374 free_irq(bus->irq, (void*)chip); in azx_free()
1381 release_firmware(chip->fw); in azx_free()
1385 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) in azx_free()
1388 hda->freed = 1; in azx_free()
1393 struct azx *chip = device->device_data; in azx_dev_disconnect()
1396 chip->bus.shutdown = 1; in azx_dev_disconnect()
1397 cancel_work_sync(&bus->unsol_work); in azx_dev_disconnect()
1404 azx_free(device->device_data); in azx_dev_free()
1418 if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) && in atpx_present()
1419 (pdev->class != PCI_CLASS_DISPLAY_OTHER << 8)) in atpx_present()
1422 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1448 switch (pci->vendor) { in get_bound_vga()
1451 if (pci->devfn == 1) { in get_bound_vga()
1452 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1453 pci->bus->number, 0); in get_bound_vga()
1460 if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) && in get_bound_vga()
1468 if (pci->devfn == 1) { in get_bound_vga()
1469 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1470 pci->bus->number, 0); in get_bound_vga()
1472 if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) in get_bound_vga()
1497 * allow/deny-listing for position_fix
1509 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1512 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1513 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1532 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); in check_position_fix()
1534 dev_info(chip->card->dev, in check_position_fix()
1536 q->value, q->subvendor, q->subdevice); in check_position_fix()
1537 return q->value; in check_position_fix()
1540 /* Check VIA/ATI HD Audio Controller exist */ in check_position_fix()
1541 if (chip->driver_type == AZX_DRIVER_VIA) { in check_position_fix()
1542 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); in check_position_fix()
1545 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) { in check_position_fix()
1546 dev_dbg(chip->card->dev, "Using FIFO position fix\n"); in check_position_fix()
1549 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { in check_position_fix()
1550 dev_dbg(chip->card->dev, "Using LPIB position fix\n"); in check_position_fix()
1553 if (chip->driver_type == AZX_DRIVER_SKL) { in check_position_fix()
1554 dev_dbg(chip->card->dev, "Using SKL position fix\n"); in check_position_fix()
1572 chip->get_position[0] = chip->get_position[1] = callbacks[fix]; in assign_position_fix()
1574 /* combo mode uses LPIB only for playback */ in assign_position_fix()
1576 chip->get_position[1] = NULL; in assign_position_fix()
1579 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { in assign_position_fix()
1580 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1585 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1590 * deny-lists for probe_mask
1594 * to the non-working (or non-existing) modem codec slot.
1618 chip->codec_probe_mask = probe_mask[dev]; in check_probe_mask()
1619 if (chip->codec_probe_mask == -1) { in check_probe_mask()
1620 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); in check_probe_mask()
1622 dev_info(chip->card->dev, in check_probe_mask()
1624 q->value, q->subvendor, q->subdevice); in check_probe_mask()
1625 chip->codec_probe_mask = q->value; in check_probe_mask()
1630 if (chip->codec_probe_mask != -1 && in check_probe_mask()
1631 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { in check_probe_mask()
1632 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff; in check_probe_mask()
1633 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n", in check_probe_mask()
1634 (int)azx_bus(chip)->codec_mask); in check_probe_mask()
1639 * allow/deny-list for enable_msi
1651 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1660 chip->msi = !!enable_msi; in check_msi()
1663 chip->msi = 1; /* enable MSI as default */ in check_msi()
1664 q = snd_pci_quirk_lookup(chip->pci, msi_deny_list); in check_msi()
1666 dev_info(chip->card->dev, in check_msi()
1668 q->subvendor, q->subdevice, q->value); in check_msi()
1669 chip->msi = q->value; in check_msi()
1674 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { in check_msi()
1675 dev_info(chip->card->dev, "Disabling MSI\n"); in check_msi()
1676 chip->msi = 0; in check_msi()
1680 /* check the snoop mode availability */
1686 dev_info(chip->card->dev, "Force to %s mode by module option\n", in azx_check_snoop_available()
1687 snoop ? "snoop" : "non-snoop"); in azx_check_snoop_available()
1688 chip->snoop = snoop; in azx_check_snoop_available()
1689 chip->uc_buffer = !snoop; in azx_check_snoop_available()
1695 chip->driver_type == AZX_DRIVER_VIA) { in azx_check_snoop_available()
1696 /* force to non-snoop mode for a new VIA controller in azx_check_snoop_available()
1700 pci_read_config_byte(chip->pci, 0x42, &val); in azx_check_snoop_available()
1701 if (!(val & 0x80) && (chip->pci->revision == 0x30 || in azx_check_snoop_available()
1702 chip->pci->revision == 0x20)) in azx_check_snoop_available()
1706 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) in azx_check_snoop_available()
1709 chip->snoop = snoop; in azx_check_snoop_available()
1711 dev_info(chip->card->dev, "Force to non-snoop mode\n"); in azx_check_snoop_available()
1712 /* C-Media requires non-cached pages only for CORB/RIRB */ in azx_check_snoop_available()
1713 if (chip->driver_type != AZX_DRIVER_CMEDIA) in azx_check_snoop_available()
1714 chip->uc_buffer = true; in azx_check_snoop_available()
1721 azx_probe_continue(&hda->chip); in azx_probe_work()
1727 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) { in default_bdl_pos_adj()
1728 switch (chip->pci->device) { in default_bdl_pos_adj()
1737 switch (chip->driver_type) { in default_bdl_pos_adj()
1775 hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL); in azx_create()
1777 return -ENOMEM; in azx_create()
1779 chip = &hda->chip; in azx_create()
1780 mutex_init(&chip->open_mutex); in azx_create()
1781 chip->card = card; in azx_create()
1782 chip->pci = pci; in azx_create()
1783 chip->ops = &pci_hda_ops; in azx_create()
1784 chip->driver_caps = driver_caps; in azx_create()
1785 chip->driver_type = driver_caps & 0xff; in azx_create()
1787 chip->dev_index = dev; in azx_create()
1789 chip->jackpoll_interval = msecs_to_jiffies(jackpoll_ms[dev]); in azx_create()
1790 INIT_LIST_HEAD(&chip->pcm_list); in azx_create()
1791 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); in azx_create()
1792 INIT_LIST_HEAD(&hda->list); in azx_create()
1794 init_completion(&hda->probe_wait); in azx_create()
1799 chip->fallback_to_single_cmd = 1; in azx_create()
1801 chip->single_cmd = single_cmd; in azx_create()
1806 chip->bdl_pos_adj = default_bdl_pos_adj(chip); in azx_create()
1808 chip->bdl_pos_adj = bdl_pos_adj[dev]; in azx_create()
1814 /* use the non-cached pages in non-snoop mode */ in azx_create()
1816 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC; in azx_create()
1818 if (chip->driver_type == AZX_DRIVER_NVIDIA) { in azx_create()
1819 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); in azx_create()
1820 chip->bus.core.needs_damn_long_delay = 1; in azx_create()
1827 dev_err(card->dev, "Error creating device [card]!\n"); in azx_create()
1833 INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work); in azx_create()
1842 int dev = chip->dev_index; in azx_first_init()
1843 struct pci_dev *pci = chip->pci; in azx_first_init()
1844 struct snd_card *card = chip->card; in azx_first_init()
1852 if (chip->driver_type == AZX_DRIVER_ULI) { in azx_first_init()
1863 if (chip->driver_type == AZX_DRIVER_GFHDMI) in azx_first_init()
1864 bus->polling_mode = 1; in azx_first_init()
1866 if (chip->driver_type == AZX_DRIVER_LOONGSON) { in azx_first_init()
1867 bus->polling_mode = 1; in azx_first_init()
1868 bus->not_use_interrupts = 1; in azx_first_init()
1869 bus->access_sdnctl_in_dword = 1; in azx_first_init()
1876 bus->addr = pci_resource_start(pci, 0); in azx_first_init()
1877 bus->remap_addr = pcim_iomap_table(pci)[0]; in azx_first_init()
1879 if (chip->driver_type == AZX_DRIVER_SKL) in azx_first_init()
1888 chip->gts_present = false; in azx_first_init()
1891 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART)) in azx_first_init()
1892 chip->gts_present = true; in azx_first_init()
1895 if (chip->msi) { in azx_first_init()
1896 if (chip->driver_caps & AZX_DCAPS_NO_MSI64) { in azx_first_init()
1897 dev_dbg(card->dev, "Disabling 64bit MSI\n"); in azx_first_init()
1898 pci->no_64bit_msi = true; in azx_first_init()
1901 chip->msi = 0; in azx_first_init()
1907 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); in azx_first_init()
1910 if (chip->pci->vendor == PCI_VENDOR_ID_AMD) in azx_first_init()
1914 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { in azx_first_init()
1921 if (p_smbus->revision < 0x30) in azx_first_init()
1928 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA) in azx_first_init()
1932 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { in azx_first_init()
1933 dev_dbg(card->dev, "Disabling 64bit DMA\n"); in azx_first_init()
1937 /* disable buffer size rounding to 128-byte multiples if supported */ in azx_first_init()
1939 chip->align_buffer_size = !!align_buffer_size; in azx_first_init()
1941 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE) in azx_first_init()
1942 chip->align_buffer_size = 0; in azx_first_init()
1944 chip->align_buffer_size = 1; in azx_first_init()
1950 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits))) in azx_first_init()
1951 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1952 dma_set_max_seg_size(&pci->dev, UINT_MAX); in azx_first_init()
1957 chip->capture_streams = (gcap >> 8) & 0x0f; in azx_first_init()
1958 chip->playback_streams = (gcap >> 12) & 0x0f; in azx_first_init()
1959 if (!chip->playback_streams && !chip->capture_streams) { in azx_first_init()
1962 switch (chip->driver_type) { in azx_first_init()
1964 chip->playback_streams = ULI_NUM_PLAYBACK; in azx_first_init()
1965 chip->capture_streams = ULI_NUM_CAPTURE; in azx_first_init()
1969 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; in azx_first_init()
1970 chip->capture_streams = ATIHDMI_NUM_CAPTURE; in azx_first_init()
1975 chip->playback_streams = ICH6_NUM_PLAYBACK; in azx_first_init()
1976 chip->capture_streams = ICH6_NUM_CAPTURE; in azx_first_init()
1980 chip->capture_index_offset = 0; in azx_first_init()
1981 chip->playback_index_offset = chip->capture_streams; in azx_first_init()
1982 chip->num_streams = chip->playback_streams + chip->capture_streams; in azx_first_init()
1985 if (chip->num_streams > 15 && in azx_first_init()
1986 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) { in azx_first_init()
1987 dev_warn(chip->card->dev, "number of I/O streams is %d, " in azx_first_init()
1988 "forcing separate stream tags", chip->num_streams); in azx_first_init()
1989 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG; in azx_first_init()
2009 if (!azx_bus(chip)->codec_mask) { in azx_first_init()
2010 dev_err(card->dev, "no codecs found!\n"); in azx_first_init()
2015 return -EBUSY; in azx_first_init()
2017 strcpy(card->driver, "HDA-Intel"); in azx_first_init()
2018 strscpy(card->shortname, driver_short_names[chip->driver_type], in azx_first_init()
2019 sizeof(card->shortname)); in azx_first_init()
2020 snprintf(card->longname, sizeof(card->longname), in azx_first_init()
2022 card->shortname, bus->addr, bus->irq); in azx_first_init()
2032 struct azx *chip = card->private_data; in azx_firmware_cb()
2035 chip->fw = fw; in azx_firmware_cb()
2037 dev_err(card->dev, "Cannot load firmware, continue without patching\n"); in azx_firmware_cb()
2038 if (!chip->disabled) { in azx_firmware_cb()
2050 free_irq(bus->irq, chip); in disable_msi_reset_irq()
2051 bus->irq = -1; in disable_msi_reset_irq()
2052 chip->card->sync_irq = -1; in disable_msi_reset_irq()
2053 pci_disable_msi(chip->pci); in disable_msi_reset_irq()
2054 chip->msi = 0; in disable_msi_reset_irq()
2063 * some HD-audio PCI entries are exposed without any codecs, and such devices
2092 dev_info(&pci->dev, "Skipping the device on the denylist\n"); in azx_probe()
2093 return -ENODEV; in azx_probe()
2098 return -ENODEV; in azx_probe()
2101 return -ENOENT; in azx_probe()
2110 dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n"); in azx_probe()
2111 return -ENODEV; in azx_probe()
2114 …dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option i… in azx_probe()
2117 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in azx_probe()
2120 dev_err(&pci->dev, "Error creating card!\n"); in azx_probe()
2124 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); in azx_probe()
2127 card->private_data = chip; in azx_probe()
2134 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) { in azx_probe()
2137 if (err == -EPROBE_DEFER) in azx_probe()
2146 dev_err_probe(card->dev, err, in azx_probe()
2147 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n"); in azx_probe()
2152 chip->driver_caps &= ~AZX_DCAPS_I915_COMPONENT; in azx_probe()
2158 hda->need_i915_power = true; in azx_probe()
2162 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n"); in azx_probe()
2167 dev_err(card->dev, "Error registering vga_switcheroo client\n"); in azx_probe()
2172 dev_info(card->dev, "VGA controller is disabled\n"); in azx_probe()
2173 dev_info(card->dev, "Delaying initialization\n"); in azx_probe()
2174 chip->disabled = true; in azx_probe()
2177 schedule_probe = !chip->disabled; in azx_probe()
2181 dev_info(card->dev, "Applying patch firmware '%s'\n", in azx_probe()
2184 &pci->dev, GFP_KERNEL, card, in azx_probe()
2193 schedule_delayed_work(&hda->probe_work, 0); in azx_probe()
2196 if (chip->disabled) in azx_probe()
2197 complete_all(&hda->probe_wait); in azx_probe()
2207 * popping sounds when ever we enter/leave powersaving mode. Ideally we would
2214 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2216 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2218 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2220 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2224 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2225 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2227 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2256 q = snd_pci_quirk_lookup(chip->pci, power_save_denylist); in set_default_power_save()
2258 …dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0… in set_default_power_save()
2259 q->subvendor, q->subdevice); in set_default_power_save()
2261 hda->runtime_pm_disabled = 1; in set_default_power_save()
2264 dev_info(chip->card->dev, "Forcing power_save to 0 via option\n"); in set_default_power_save()
2267 snd_hda_set_power_save(&chip->bus, val * 1000); in set_default_power_save()
2280 struct pci_dev *pci = chip->pci; in azx_probe_continue()
2281 int dev = chip->dev_index; in azx_probe_continue()
2284 if (chip->disabled || hda->init_failed) in azx_probe_continue()
2285 return -EIO; in azx_probe_continue()
2286 if (hda->probe_retry) in azx_probe_continue()
2289 to_hda_bus(bus)->bus_probing = 1; in azx_probe_continue()
2290 hda->probe_continued = 1; in azx_probe_continue()
2304 chip->beep_mode = beep_mode[dev]; in azx_probe_continue()
2307 chip->ctl_dev_id = ctl_dev_id; in azx_probe_continue()
2310 if (bus->codec_mask) { in azx_probe_continue()
2311 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); in azx_probe_continue()
2317 if (chip->fw) { in azx_probe_continue()
2318 err = snd_hda_load_patch(&chip->bus, chip->fw->size, in azx_probe_continue()
2319 chip->fw->data); in azx_probe_continue()
2326 if (bus->codec_mask && !(probe_only[dev] & 1)) { in azx_probe_continue()
2329 if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) && in azx_probe_continue()
2330 ++hda->probe_retry < 60) { in azx_probe_continue()
2331 schedule_delayed_work(&hda->probe_work, in azx_probe_continue()
2335 dev_err(chip->card->dev, "Cannot probe codecs, giving up\n"); in azx_probe_continue()
2340 err = snd_card_register(chip->card); in azx_probe_continue()
2346 chip->running = 1; in azx_probe_continue()
2352 pm_runtime_use_autosuspend(&pci->dev); in azx_probe_continue()
2353 pm_runtime_allow(&pci->dev); in azx_probe_continue()
2354 pm_runtime_put_autosuspend(&pci->dev); in azx_probe_continue()
2360 snd_card_free(chip->card); in azx_probe_continue()
2364 if (!hda->need_i915_power) in azx_probe_continue()
2366 complete_all(&hda->probe_wait); in azx_probe_continue()
2367 to_hda_bus(bus)->bus_probing = 0; in azx_probe_continue()
2368 hda->probe_retry = 0; in azx_probe_continue()
2380 chip = card->private_data; in azx_remove()
2393 device_unlock(&pci->dev); in azx_remove()
2394 cancel_delayed_work_sync(&hda->probe_work); in azx_remove()
2395 device_lock(&pci->dev); in azx_remove()
2397 clear_bit(chip->dev_index, probed_devs); in azx_remove()
2410 chip = card->private_data; in azx_shutdown()
2411 if (chip && chip->running) in azx_shutdown()
2433 /* Lynx Point-LP */
2435 /* Lynx Point-LP */
2437 /* Wildcat Point-LP */
2441 /* Skylake-LP (Sunrise Point-LP) */
2445 /* Kabylake-LP */
2447 /* Kabylake-H */
2453 /* CometLake-LP */
2455 /* CometLake-H */
2458 /* CometLake-S */
2460 /* CometLake-R */
2464 /* Icelake-H */
2471 /* Tigerlake-H */
2479 /* Alderlake-S */
2481 /* Alderlake-P */
2485 /* Alderlake-M */
2487 /* Alderlake-N */
2501 /* Lunarlake-P */
2503 /* Arrow Lake-S */
2509 /* Apollolake (Broxton-P) */
2511 /* Gemini-Lake */
2552 /* ATI SB 450/600/700/800/900 */
2553 { PCI_VDEVICE(ATI, 0x437b),
2555 { PCI_VDEVICE(ATI, 0x4383),
2573 /* ATI HDMI */
2574 { PCI_VDEVICE(ATI, 0x0002),
2577 { PCI_VDEVICE(ATI, 0x1308),
2579 { PCI_VDEVICE(ATI, 0x157a),
2581 { PCI_VDEVICE(ATI, 0x15b3),
2583 { PCI_VDEVICE(ATI, 0x793b),
2585 { PCI_VDEVICE(ATI, 0x7919),
2587 { PCI_VDEVICE(ATI, 0x960f),
2589 { PCI_VDEVICE(ATI, 0x970f),
2591 { PCI_VDEVICE(ATI, 0x9840),
2593 { PCI_VDEVICE(ATI, 0xaa00),
2595 { PCI_VDEVICE(ATI, 0xaa08),
2597 { PCI_VDEVICE(ATI, 0xaa10),
2599 { PCI_VDEVICE(ATI, 0xaa18),
2601 { PCI_VDEVICE(ATI, 0xaa20),
2603 { PCI_VDEVICE(ATI, 0xaa28),
2605 { PCI_VDEVICE(ATI, 0xaa30),
2607 { PCI_VDEVICE(ATI, 0xaa38),
2609 { PCI_VDEVICE(ATI, 0xaa40),
2611 { PCI_VDEVICE(ATI, 0xaa48),
2613 { PCI_VDEVICE(ATI, 0xaa50),
2615 { PCI_VDEVICE(ATI, 0xaa58),
2617 { PCI_VDEVICE(ATI, 0xaa60),
2619 { PCI_VDEVICE(ATI, 0xaa68),
2621 { PCI_VDEVICE(ATI, 0xaa80),
2623 { PCI_VDEVICE(ATI, 0xaa88),
2625 { PCI_VDEVICE(ATI, 0xaa90),
2627 { PCI_VDEVICE(ATI, 0xaa98),
2629 { PCI_VDEVICE(ATI, 0x9902),
2631 { PCI_VDEVICE(ATI, 0xaaa0),
2633 { PCI_VDEVICE(ATI, 0xaaa8),
2635 { PCI_VDEVICE(ATI, 0xaab0),
2637 { PCI_VDEVICE(ATI, 0xaac0),
2640 { PCI_VDEVICE(ATI, 0xaac8),
2643 { PCI_VDEVICE(ATI, 0xaad8),
2646 { PCI_VDEVICE(ATI, 0xaae0),
2649 { PCI_VDEVICE(ATI, 0xaae8),
2652 { PCI_VDEVICE(ATI, 0xaaf0),
2655 { PCI_VDEVICE(ATI, 0xaaf8),
2658 { PCI_VDEVICE(ATI, 0xab00),
2661 { PCI_VDEVICE(ATI, 0xab08),
2664 { PCI_VDEVICE(ATI, 0xab10),
2667 { PCI_VDEVICE(ATI, 0xab18),
2670 { PCI_VDEVICE(ATI, 0xab20),
2673 { PCI_VDEVICE(ATI, 0xab28),
2676 { PCI_VDEVICE(ATI, 0xab30),
2679 { PCI_VDEVICE(ATI, 0xab38),
2708 /* Creative X-Fi (CA0110-IBG) */
2715 /* the following entry conflicts with snd-ctxfi driver,
2716 * as ctxfi driver mutates from HD-audio to native mode with
2725 /* this entry seems still valid -- i.e. without emu20kx chip */
2738 /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */