Lines Matching +full:ati +full:- +full:base
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>
72 /* Defines for ATI HD Audio support in SB450 south bridge */
93 /* ICH, ATI and VIA have 4 playback and 4 capture */
101 /* ATI HDMI may have up to 8 playbacks and 0 capture */
114 static int position_fix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
115 static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
116 static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
119 static int single_cmd = -1;
120 static int enable_msi = -1;
125 static bool beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] =
140 …"(-1 = system default, 0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO, 4 = COMBO, 5 = SKL+, 6 = FIFO…
144 MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
166 "deprecated, use snd-intel-dspcfg.dsp_driver option instead");
178 MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
183 MODULE_PARM_DESC(pm_blacklist, "Enable power-management denylist");
185 /* reset the HD-audio controller in power save mode.
186 * this may give more power-saving, but will take longer time to
196 static int align_buffer_size = -1;
202 static int hda_snoop = -1;
229 "{ATI, SB450},"
230 "{ATI, SB600},"
231 "{ATI, RS600},"
232 "{ATI, RS690},"
233 "{ATI, RS780},"
234 "{ATI, R600},"
235 "{ATI, RV630},"
236 "{ATI, RV610},"
237 "{ATI, RV670},"
238 "{ATI, RV635},"
239 "{ATI, RV620},"
240 "{ATI, RV770},"
282 (((chip)->driver_caps & AZX_DCAPS_SNOOP_MASK) >> 10)
328 /* quirks for ATI SB / AMD Hudson */
331 AZX_DCAPS_SNOOP_TYPE(ATI))
333 /* quirks for ATI/AMD HDMI */
338 /* quirks for ATI HDMI with snoop off */
345 AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME |\
362 #define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo)
363 #define needs_eld_notify_link(chip) ((chip)->bus.keep_power)
369 #define CONTROLLER_IN_GPU(pci) (((pci)->vendor == 0x8086) && \
370 (((pci)->device == 0x0a0c) || \
371 ((pci)->device == 0x0c0c) || \
372 ((pci)->device == 0x0d0c) || \
373 ((pci)->device == 0x160c) || \
374 ((pci)->device == 0x490d) || \
375 ((pci)->device == 0x4f90) || \
376 ((pci)->device == 0x4f91) || \
377 ((pci)->device == 0x4f92)))
379 #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
387 [AZX_DRIVER_ATI] = "HDA ATI SB",
388 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
389 [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI",
398 [AZX_DRIVER_CMEDIA] = "HDA C-Media",
400 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
425 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) in azx_init_pci()
431 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) { in azx_init_pci()
432 dev_dbg(chip->card->dev, "Clearing TCSEL\n"); in azx_init_pci()
433 update_pci_byte(chip->pci, AZX_PCIREG_TCSEL, 0x07, 0); in azx_init_pci()
436 /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio, in azx_init_pci()
440 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n", in azx_init_pci()
442 update_pci_byte(chip->pci, in azx_init_pci()
449 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n", in azx_init_pci()
451 update_pci_byte(chip->pci, in azx_init_pci()
454 update_pci_byte(chip->pci, in azx_init_pci()
457 update_pci_byte(chip->pci, in azx_init_pci()
465 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); in azx_init_pci()
471 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop); in azx_init_pci()
472 pci_read_config_word(chip->pci, in azx_init_pci()
475 dev_dbg(chip->card->dev, "SCH snoop: %s\n", in azx_init_pci()
482 * In BXT-P A0, HD-Audio DMA requests is later than expected,
513 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCAP); in intel_get_lctl_scf()
521 dev_warn(chip->card->dev, "set audio clock frequency to 6MHz"); in intel_get_lctl_scf()
535 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
538 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
542 if (((readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL)) & in intel_ml_lctl_set_power()
545 timeout--; in intel_ml_lctl_set_power()
549 return -1; in intel_ml_lctl_set_power()
559 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
581 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
592 struct pci_dev *pci = chip->pci; in hda_intel_init_chip()
596 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
602 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
614 if (bus->mlcap != NULL) in hda_intel_init_chip()
622 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_lpib()
623 int stream = substream->stream; in azx_get_delay_from_lpib()
628 delay = pos - lpib_pos; in azx_get_delay_from_lpib()
630 delay = lpib_pos - pos; in azx_get_delay_from_lpib()
632 if (delay >= azx_dev->core.delay_negative_threshold) in azx_get_delay_from_lpib()
635 delay += azx_dev->core.bufsize; in azx_get_delay_from_lpib()
638 if (delay >= azx_dev->core.period_bytes) { in azx_get_delay_from_lpib()
639 dev_info(chip->card->dev, in azx_get_delay_from_lpib()
641 delay, azx_dev->core.period_bytes); in azx_get_delay_from_lpib()
643 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; in azx_get_delay_from_lpib()
644 chip->get_delay[stream] = NULL; in azx_get_delay_from_lpib()
647 return bytes_to_frames(substream->runtime, delay); in azx_get_delay_from_lpib()
660 azx_dev->irq_pending = 0; in azx_position_check()
664 azx_dev->irq_pending = 1; in azx_position_check()
665 schedule_work(&hda->irq_pending_work); in azx_position_check()
675 * periods. Returns non-zero if it's OK.
677 * Many HD-audio controllers appear pretty inaccurate about
678 * the update-IRQ timing. The IRQ is issued before actually the
682 * Returns 1 if OK to proceed, 0 for delay handling, -1 for skipping update
686 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_position_ok()
687 struct snd_pcm_runtime *runtime = substream->runtime; in azx_position_ok()
688 int stream = substream->stream; in azx_position_ok()
693 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk; in azx_position_ok()
694 if (wallclk < (azx_dev->core.period_wallclk * 2) / 3) in azx_position_ok()
695 return -1; /* bogus (too early) interrupt */ in azx_position_ok()
697 if (chip->get_position[stream]) in azx_position_ok()
698 pos = chip->get_position[stream](chip, azx_dev); in azx_position_ok()
701 if (!pos || pos == (u32)-1) { in azx_position_ok()
702 dev_info(chip->card->dev, in azx_position_ok()
704 chip->get_position[stream] = azx_get_pos_lpib; in azx_position_ok()
705 if (chip->get_position[0] == azx_get_pos_lpib && in azx_position_ok()
706 chip->get_position[1] == azx_get_pos_lpib) in azx_position_ok()
707 azx_bus(chip)->use_posbuf = false; in azx_position_ok()
709 chip->get_delay[stream] = NULL; in azx_position_ok()
711 chip->get_position[stream] = azx_get_pos_posbuf; in azx_position_ok()
712 if (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY) in azx_position_ok()
713 chip->get_delay[stream] = azx_get_delay_from_lpib; in azx_position_ok()
717 if (pos >= azx_dev->core.bufsize) in azx_position_ok()
720 if (WARN_ONCE(!azx_dev->core.period_bytes, in azx_position_ok()
721 "hda-intel: zero azx_dev->period_bytes")) in azx_position_ok()
722 return -1; /* this shouldn't happen! */ in azx_position_ok()
723 if (wallclk < (azx_dev->core.period_wallclk * 5) / 4 && in azx_position_ok()
724 pos % azx_dev->core.period_bytes > azx_dev->core.period_bytes / 2) in azx_position_ok()
725 /* NG - it's below the first next period boundary */ in azx_position_ok()
726 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
727 azx_dev->core.start_wallclk += wallclk; in azx_position_ok()
729 if (azx_dev->core.no_period_wakeup) in azx_position_ok()
732 if (runtime->hw_ptr_base != runtime->hw_ptr_interrupt) in azx_position_ok()
737 hwptr = runtime->hw_ptr_base + pos; in azx_position_ok()
738 if (hwptr < runtime->status->hw_ptr) in azx_position_ok()
739 hwptr += runtime->buffer_size; in azx_position_ok()
740 target = runtime->hw_ptr_interrupt + runtime->period_size; in azx_position_ok()
743 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
755 struct azx *chip = &hda->chip; in azx_irq_pending_work()
760 if (!hda->irq_pending_warned) { in azx_irq_pending_work()
761 dev_info(chip->card->dev, in azx_irq_pending_work()
763 chip->card->number); in azx_irq_pending_work()
764 hda->irq_pending_warned = 1; in azx_irq_pending_work()
769 spin_lock_irq(&bus->reg_lock); in azx_irq_pending_work()
770 list_for_each_entry(s, &bus->stream_list, list) { in azx_irq_pending_work()
772 if (!azx_dev->irq_pending || in azx_irq_pending_work()
773 !s->substream || in azx_irq_pending_work()
774 !s->running) in azx_irq_pending_work()
778 azx_dev->irq_pending = 0; in azx_irq_pending_work()
779 spin_unlock(&bus->reg_lock); in azx_irq_pending_work()
780 snd_pcm_period_elapsed(s->substream); in azx_irq_pending_work()
781 spin_lock(&bus->reg_lock); in azx_irq_pending_work()
787 spin_unlock_irq(&bus->reg_lock); in azx_irq_pending_work()
794 /* clear irq_pending flags and assure no on-going workq */
800 spin_lock_irq(&bus->reg_lock); in azx_clear_irq_pending()
801 list_for_each_entry(s, &bus->stream_list, list) { in azx_clear_irq_pending()
803 azx_dev->irq_pending = 0; in azx_clear_irq_pending()
805 spin_unlock_irq(&bus->reg_lock); in azx_clear_irq_pending()
812 if (request_irq(chip->pci->irq, azx_interrupt, in azx_acquire_irq()
813 chip->msi ? 0 : IRQF_SHARED, in azx_acquire_irq()
814 chip->card->irq_descr, chip)) { in azx_acquire_irq()
815 dev_err(chip->card->dev, in azx_acquire_irq()
817 chip->pci->irq); in azx_acquire_irq()
819 snd_card_disconnect(chip->card); in azx_acquire_irq()
820 return -1; in azx_acquire_irq()
822 bus->irq = chip->pci->irq; in azx_acquire_irq()
823 chip->card->sync_irq = bus->irq; in azx_acquire_irq()
824 pci_intx(chip->pci, !chip->msi); in azx_acquire_irq()
837 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in azx_via_get_position()
846 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); in azx_via_get_position()
847 mod_dma_pos %= azx_dev->core.period_bytes; in azx_via_get_position()
849 fifo_size = azx_stream(azx_dev)->fifo_size - 1; in azx_via_get_position()
851 if (azx_dev->insufficient) { in azx_via_get_position()
856 azx_dev->insufficient = 0; in azx_via_get_position()
860 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; in azx_via_get_position()
862 mini_pos = link_pos - fifo_size; in azx_via_get_position()
865 mod_mini_pos = mini_pos % azx_dev->core.period_bytes; in azx_via_get_position()
866 mod_link_pos = link_pos % azx_dev->core.period_bytes; in azx_via_get_position()
868 bound_pos = link_pos - mod_link_pos; in azx_via_get_position()
870 bound_pos = mini_pos - mod_mini_pos; in azx_via_get_position()
872 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; in azx_via_get_position()
873 if (bound_pos >= azx_dev->core.bufsize) in azx_via_get_position()
886 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_pos_fifo()
887 struct snd_pcm_runtime *runtime = substream->runtime; in azx_get_pos_fifo()
894 runtime->delay = AMD_FIFO_SIZE; in azx_get_pos_fifo()
896 if (azx_dev->insufficient) { in azx_get_pos_fifo()
899 runtime->delay = bytes_to_frames(runtime, pos); in azx_get_pos_fifo()
901 azx_dev->insufficient = 0; in azx_get_pos_fifo()
906 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in azx_get_pos_fifo()
908 pos += azx_dev->core.bufsize; in azx_get_pos_fifo()
909 pos -= delay; in azx_get_pos_fifo()
918 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_fifo()
921 return substream->runtime->delay; in azx_get_delay_from_fifo()
946 list_add(&hda->list, &card_list); in azx_add_card_list()
954 list_del_init(&hda->list); in azx_del_card_list()
958 /* trigger power-save check at writing parameter */
971 chip = &hda->chip; in param_set_xint()
972 if (!hda->probe_continued || chip->disabled) in param_set_xint()
974 snd_hda_set_power_save(&chip->bus, power_save * 1000); in param_set_xint()
990 chip = card->private_data; in azx_is_pm_ready()
992 if (chip->disabled || hda->init_failed || !chip->running) in azx_is_pm_ready()
1005 if (hda->need_i915_power) in __azx_runtime_resume()
1015 if (!chip->pm_prepared) { in __azx_runtime_resume()
1016 list_for_each_codec(codec, &chip->bus) { in __azx_runtime_resume()
1017 if (codec->relaxed_resume) in __azx_runtime_resume()
1020 if (codec->forced_resume || (status & (1 << codec->addr))) in __azx_runtime_resume()
1025 /* power down again for link-controlled chips */ in __azx_runtime_resume()
1026 if (!hda->need_i915_power) in __azx_runtime_resume()
1039 chip = card->private_data; in azx_prepare()
1040 chip->pm_prepared = 1; in azx_prepare()
1043 flush_work(&azx_bus(chip)->unsol_work); in azx_prepare()
1046 * and system suspend, so don't use direct-complete here. in azx_prepare()
1059 chip = card->private_data; in azx_complete()
1061 chip->pm_prepared = 0; in azx_complete()
1073 chip = card->private_data; in azx_suspend()
1076 if (bus->irq >= 0) { in azx_suspend()
1077 free_irq(bus->irq, chip); in azx_suspend()
1078 bus->irq = -1; in azx_suspend()
1079 chip->card->sync_irq = -1; in azx_suspend()
1082 if (chip->msi) in azx_suspend()
1083 pci_disable_msi(chip->pci); in azx_suspend()
1097 chip = card->private_data; in azx_resume()
1098 if (chip->msi) in azx_resume()
1099 if (pci_enable_msi(chip->pci) < 0) in azx_resume()
1100 chip->msi = 0; in azx_resume()
1102 return -EIO; in azx_resume()
1116 struct azx *chip = card->private_data; in azx_freeze_noirq()
1121 if (chip->driver_type == AZX_DRIVER_SKL) in azx_freeze_noirq()
1130 struct azx *chip = card->private_data; in azx_thaw_noirq()
1135 if (chip->driver_type == AZX_DRIVER_SKL) in azx_thaw_noirq()
1149 chip = card->private_data; in azx_runtime_suspend()
1166 chip = card->private_data; in azx_runtime_resume()
1185 chip = card->private_data; in azx_runtime_idle()
1187 if (chip->disabled || hda->init_failed) in azx_runtime_idle()
1191 azx_bus(chip)->codec_powered || !chip->running) in azx_runtime_idle()
1192 return -EBUSY; in azx_runtime_idle()
1194 /* ELD notification gets broken when HD-audio bus is off */ in azx_runtime_idle()
1196 return -EBUSY; in azx_runtime_idle()
1229 struct azx *chip = card->private_data; in azx_vs_set_state()
1234 wait_for_completion(&hda->probe_wait); in azx_vs_set_state()
1235 if (hda->init_failed) in azx_vs_set_state()
1239 if (chip->disabled == disabled) in azx_vs_set_state()
1242 if (!hda->probe_continued) { in azx_vs_set_state()
1243 chip->disabled = disabled; in azx_vs_set_state()
1245 dev_info(chip->card->dev, in azx_vs_set_state()
1248 dev_err(chip->card->dev, "initialization error\n"); in azx_vs_set_state()
1251 dev_info(chip->card->dev, "%s via vga_switcheroo\n", in azx_vs_set_state()
1254 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1258 pm_runtime_suspend(card->dev); in azx_vs_set_state()
1259 pm_runtime_disable(card->dev); in azx_vs_set_state()
1263 pci->current_state = PCI_D3cold; in azx_vs_set_state()
1264 chip->disabled = true; in azx_vs_set_state()
1265 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_set_state()
1266 dev_warn(chip->card->dev, in azx_vs_set_state()
1269 snd_hda_unlock_devices(&chip->bus); in azx_vs_set_state()
1270 chip->disabled = false; in azx_vs_set_state()
1271 pm_runtime_enable(card->dev); in azx_vs_set_state()
1272 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1283 struct azx *chip = card->private_data; in azx_vs_can_switch()
1286 wait_for_completion(&hda->probe_wait); in azx_vs_can_switch()
1287 if (hda->init_failed) in azx_vs_can_switch()
1289 if (chip->disabled || !hda->probe_continued) in azx_vs_can_switch()
1291 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_can_switch()
1293 snd_hda_unlock_devices(&chip->bus); in azx_vs_can_switch()
1306 if (hda->use_vga_switcheroo && !needs_eld_notify_link(chip)) { in setup_vga_switcheroo_runtime_pm()
1307 list_for_each_codec(codec, &chip->bus) in setup_vga_switcheroo_runtime_pm()
1308 codec->auto_runtime_pm = 1; in setup_vga_switcheroo_runtime_pm()
1310 if (chip->running) in setup_vga_switcheroo_runtime_pm()
1319 struct azx *chip = card->private_data; in azx_vs_gpu_bound()
1322 chip->bus.keep_power = 0; in azx_vs_gpu_bound()
1329 struct pci_dev *p = get_bound_vga(chip->pci); in init_vga_switcheroo()
1332 dev_info(chip->card->dev, in init_vga_switcheroo()
1334 hda->use_vga_switcheroo = 1; in init_vga_switcheroo()
1340 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1; in init_vga_switcheroo()
1341 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME; in init_vga_switcheroo()
1358 if (!hda->use_vga_switcheroo) in register_vga_switcheroo()
1361 p = get_bound_vga(chip->pci); in register_vga_switcheroo()
1362 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p); in register_vga_switcheroo()
1367 hda->vga_switcheroo_registered = 1; in register_vga_switcheroo()
1383 struct pci_dev *pci = chip->pci; in azx_free()
1387 if (hda->freed) in azx_free()
1390 if (azx_has_pm_runtime(chip) && chip->running) in azx_free()
1391 pm_runtime_get_noresume(&pci->dev); in azx_free()
1392 chip->running = 0; in azx_free()
1396 hda->init_failed = 1; /* to be sure */ in azx_free()
1397 complete_all(&hda->probe_wait); in azx_free()
1400 if (chip->disabled && hda->probe_continued) in azx_free()
1401 snd_hda_unlock_devices(&chip->bus); in azx_free()
1402 if (hda->vga_switcheroo_registered) in azx_free()
1403 vga_switcheroo_unregister_client(chip->pci); in azx_free()
1406 if (bus->chip_init) { in azx_free()
1412 if (bus->irq >= 0) in azx_free()
1413 free_irq(bus->irq, (void*)chip); in azx_free()
1414 if (chip->msi) in azx_free()
1415 pci_disable_msi(chip->pci); in azx_free()
1416 iounmap(bus->remap_addr); in azx_free()
1422 if (chip->region_requested) in azx_free()
1423 pci_release_regions(chip->pci); in azx_free()
1425 pci_disable_device(chip->pci); in azx_free()
1427 release_firmware(chip->fw); in azx_free()
1431 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) in azx_free()
1434 hda->freed = 1; in azx_free()
1439 struct azx *chip = device->device_data; in azx_dev_disconnect()
1442 chip->bus.shutdown = 1; in azx_dev_disconnect()
1443 cancel_work_sync(&bus->unsol_work); in azx_dev_disconnect()
1450 azx_free(device->device_data); in azx_dev_free()
1464 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1474 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1500 switch (pci->vendor) { in get_bound_vga()
1503 if (pci->devfn == 1) { in get_bound_vga()
1504 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1505 pci->bus->number, 0); in get_bound_vga()
1512 if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) && in get_bound_vga()
1520 if (pci->devfn == 1) { in get_bound_vga()
1521 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1522 pci->bus->number, 0); in get_bound_vga()
1524 if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) in get_bound_vga()
1549 * allow/deny-listing for position_fix
1561 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1564 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1565 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1584 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); in check_position_fix()
1586 dev_info(chip->card->dev, in check_position_fix()
1588 q->value, q->subvendor, q->subdevice); in check_position_fix()
1589 return q->value; in check_position_fix()
1592 /* Check VIA/ATI HD Audio Controller exist */ in check_position_fix()
1593 if (chip->driver_type == AZX_DRIVER_VIA) { in check_position_fix()
1594 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); in check_position_fix()
1597 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) { in check_position_fix()
1598 dev_dbg(chip->card->dev, "Using FIFO position fix\n"); in check_position_fix()
1601 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { in check_position_fix()
1602 dev_dbg(chip->card->dev, "Using LPIB position fix\n"); in check_position_fix()
1605 if (chip->driver_type == AZX_DRIVER_SKL) { in check_position_fix()
1606 dev_dbg(chip->card->dev, "Using SKL position fix\n"); in check_position_fix()
1624 chip->get_position[0] = chip->get_position[1] = callbacks[fix]; in assign_position_fix()
1628 chip->get_position[1] = NULL; in assign_position_fix()
1631 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { in assign_position_fix()
1632 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1637 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1642 * deny-lists for probe_mask
1646 * to the non-working (or non-existing) modem codec slot.
1670 chip->codec_probe_mask = probe_mask[dev]; in check_probe_mask()
1671 if (chip->codec_probe_mask == -1) { in check_probe_mask()
1672 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); in check_probe_mask()
1674 dev_info(chip->card->dev, in check_probe_mask()
1676 q->value, q->subvendor, q->subdevice); in check_probe_mask()
1677 chip->codec_probe_mask = q->value; in check_probe_mask()
1682 if (chip->codec_probe_mask != -1 && in check_probe_mask()
1683 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { in check_probe_mask()
1684 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff; in check_probe_mask()
1685 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n", in check_probe_mask()
1686 (int)azx_bus(chip)->codec_mask); in check_probe_mask()
1691 * allow/deny-list for enable_msi
1703 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1712 chip->msi = !!enable_msi; in check_msi()
1715 chip->msi = 1; /* enable MSI as default */ in check_msi()
1716 q = snd_pci_quirk_lookup(chip->pci, msi_deny_list); in check_msi()
1718 dev_info(chip->card->dev, in check_msi()
1720 q->subvendor, q->subdevice, q->value); in check_msi()
1721 chip->msi = q->value; in check_msi()
1726 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { in check_msi()
1727 dev_info(chip->card->dev, "Disabling MSI\n"); in check_msi()
1728 chip->msi = 0; in check_msi()
1738 dev_info(chip->card->dev, "Force to %s mode by module option\n", in azx_check_snoop_available()
1739 snoop ? "snoop" : "non-snoop"); in azx_check_snoop_available()
1740 chip->snoop = snoop; in azx_check_snoop_available()
1741 chip->uc_buffer = !snoop; in azx_check_snoop_available()
1747 chip->driver_type == AZX_DRIVER_VIA) { in azx_check_snoop_available()
1748 /* force to non-snoop mode for a new VIA controller in azx_check_snoop_available()
1752 pci_read_config_byte(chip->pci, 0x42, &val); in azx_check_snoop_available()
1753 if (!(val & 0x80) && (chip->pci->revision == 0x30 || in azx_check_snoop_available()
1754 chip->pci->revision == 0x20)) in azx_check_snoop_available()
1758 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) in azx_check_snoop_available()
1761 chip->snoop = snoop; in azx_check_snoop_available()
1763 dev_info(chip->card->dev, "Force to non-snoop mode\n"); in azx_check_snoop_available()
1764 /* C-Media requires non-cached pages only for CORB/RIRB */ in azx_check_snoop_available()
1765 if (chip->driver_type != AZX_DRIVER_CMEDIA) in azx_check_snoop_available()
1766 chip->uc_buffer = true; in azx_check_snoop_available()
1773 azx_probe_continue(&hda->chip); in azx_probe_work()
1779 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) { in default_bdl_pos_adj()
1780 switch (chip->pci->device) { in default_bdl_pos_adj()
1787 switch (chip->driver_type) { in default_bdl_pos_adj()
1825 hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL); in azx_create()
1828 return -ENOMEM; in azx_create()
1831 chip = &hda->chip; in azx_create()
1832 mutex_init(&chip->open_mutex); in azx_create()
1833 chip->card = card; in azx_create()
1834 chip->pci = pci; in azx_create()
1835 chip->ops = &pci_hda_ops; in azx_create()
1836 chip->driver_caps = driver_caps; in azx_create()
1837 chip->driver_type = driver_caps & 0xff; in azx_create()
1839 chip->dev_index = dev; in azx_create()
1841 chip->jackpoll_interval = msecs_to_jiffies(jackpoll_ms[dev]); in azx_create()
1842 INIT_LIST_HEAD(&chip->pcm_list); in azx_create()
1843 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); in azx_create()
1844 INIT_LIST_HEAD(&hda->list); in azx_create()
1846 init_completion(&hda->probe_wait); in azx_create()
1851 chip->fallback_to_single_cmd = 1; in azx_create()
1853 chip->single_cmd = single_cmd; in azx_create()
1858 chip->bdl_pos_adj = default_bdl_pos_adj(chip); in azx_create()
1860 chip->bdl_pos_adj = bdl_pos_adj[dev]; in azx_create()
1868 /* use the non-cached pages in non-snoop mode */ in azx_create()
1870 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_UC; in azx_create()
1872 if (chip->driver_type == AZX_DRIVER_NVIDIA) { in azx_create()
1873 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); in azx_create()
1874 chip->bus.core.needs_damn_long_delay = 1; in azx_create()
1881 dev_err(card->dev, "Error creating device [card]!\n"); in azx_create()
1887 INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work); in azx_create()
1896 int dev = chip->dev_index; in azx_first_init()
1897 struct pci_dev *pci = chip->pci; in azx_first_init()
1898 struct snd_card *card = chip->card; in azx_first_init()
1905 /* Fix up base address on ULI M5461 */ in azx_first_init()
1906 if (chip->driver_type == AZX_DRIVER_ULI) { in azx_first_init()
1917 if (chip->driver_type == AZX_DRIVER_GFHDMI) in azx_first_init()
1918 bus->polling_mode = 1; in azx_first_init()
1923 chip->region_requested = 1; in azx_first_init()
1925 bus->addr = pci_resource_start(pci, 0); in azx_first_init()
1926 bus->remap_addr = pci_ioremap_bar(pci, 0); in azx_first_init()
1927 if (bus->remap_addr == NULL) { in azx_first_init()
1928 dev_err(card->dev, "ioremap error\n"); in azx_first_init()
1929 return -ENXIO; in azx_first_init()
1932 if (chip->driver_type == AZX_DRIVER_SKL) in azx_first_init()
1941 chip->gts_present = false; in azx_first_init()
1944 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART)) in azx_first_init()
1945 chip->gts_present = true; in azx_first_init()
1948 if (chip->msi) { in azx_first_init()
1949 if (chip->driver_caps & AZX_DCAPS_NO_MSI64) { in azx_first_init()
1950 dev_dbg(card->dev, "Disabling 64bit MSI\n"); in azx_first_init()
1951 pci->no_64bit_msi = true; in azx_first_init()
1954 chip->msi = 0; in azx_first_init()
1960 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); in azx_first_init()
1963 if (chip->pci->vendor == PCI_VENDOR_ID_AMD) in azx_first_init()
1967 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { in azx_first_init()
1974 if (p_smbus->revision < 0x30) in azx_first_init()
1981 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA) in azx_first_init()
1985 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { in azx_first_init()
1986 dev_dbg(card->dev, "Disabling 64bit DMA\n"); in azx_first_init()
1990 /* disable buffer size rounding to 128-byte multiples if supported */ in azx_first_init()
1992 chip->align_buffer_size = !!align_buffer_size; in azx_first_init()
1994 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE) in azx_first_init()
1995 chip->align_buffer_size = 0; in azx_first_init()
1997 chip->align_buffer_size = 1; in azx_first_init()
2003 if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) { in azx_first_init()
2004 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits)); in azx_first_init()
2006 dma_set_mask(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
2007 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
2013 chip->capture_streams = (gcap >> 8) & 0x0f; in azx_first_init()
2014 chip->playback_streams = (gcap >> 12) & 0x0f; in azx_first_init()
2015 if (!chip->playback_streams && !chip->capture_streams) { in azx_first_init()
2018 switch (chip->driver_type) { in azx_first_init()
2020 chip->playback_streams = ULI_NUM_PLAYBACK; in azx_first_init()
2021 chip->capture_streams = ULI_NUM_CAPTURE; in azx_first_init()
2025 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; in azx_first_init()
2026 chip->capture_streams = ATIHDMI_NUM_CAPTURE; in azx_first_init()
2031 chip->playback_streams = ICH6_NUM_PLAYBACK; in azx_first_init()
2032 chip->capture_streams = ICH6_NUM_CAPTURE; in azx_first_init()
2036 chip->capture_index_offset = 0; in azx_first_init()
2037 chip->playback_index_offset = chip->capture_streams; in azx_first_init()
2038 chip->num_streams = chip->playback_streams + chip->capture_streams; in azx_first_init()
2041 if (chip->num_streams > 15 && in azx_first_init()
2042 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) { in azx_first_init()
2043 dev_warn(chip->card->dev, "number of I/O streams is %d, " in azx_first_init()
2044 "forcing separate stream tags", chip->num_streams); in azx_first_init()
2045 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG; in azx_first_init()
2065 if (!azx_bus(chip)->codec_mask) { in azx_first_init()
2066 dev_err(card->dev, "no codecs found!\n"); in azx_first_init()
2071 return -EBUSY; in azx_first_init()
2073 strcpy(card->driver, "HDA-Intel"); in azx_first_init()
2074 strlcpy(card->shortname, driver_short_names[chip->driver_type], in azx_first_init()
2075 sizeof(card->shortname)); in azx_first_init()
2076 snprintf(card->longname, sizeof(card->longname), in azx_first_init()
2078 card->shortname, bus->addr, bus->irq); in azx_first_init()
2088 struct azx *chip = card->private_data; in azx_firmware_cb()
2091 chip->fw = fw; in azx_firmware_cb()
2093 dev_err(card->dev, "Cannot load firmware, continue without patching\n"); in azx_firmware_cb()
2094 if (!chip->disabled) { in azx_firmware_cb()
2106 free_irq(bus->irq, chip); in disable_msi_reset_irq()
2107 bus->irq = -1; in disable_msi_reset_irq()
2108 chip->card->sync_irq = -1; in disable_msi_reset_irq()
2109 pci_disable_msi(chip->pci); in disable_msi_reset_irq()
2110 chip->msi = 0; in disable_msi_reset_irq()
2123 struct azx *chip = apcm->chip; in pcm_mmap_prepare()
2124 if (chip->uc_buffer) in pcm_mmap_prepare()
2125 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); in pcm_mmap_prepare()
2130 * some HD-audio PCI entries are exposed without any codecs, and such devices
2157 dev_info(&pci->dev, "Skipping the device on the denylist\n"); in azx_probe()
2158 return -ENODEV; in azx_probe()
2162 return -ENODEV; in azx_probe()
2165 return -ENOENT; in azx_probe()
2174 dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n"); in azx_probe()
2175 return -ENODEV; in azx_probe()
2178 …dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option i… in azx_probe()
2181 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in azx_probe()
2184 dev_err(&pci->dev, "Error creating card!\n"); in azx_probe()
2188 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); in azx_probe()
2191 card->private_data = chip; in azx_probe()
2198 dev_err(card->dev, "Error registering vga_switcheroo client\n"); in azx_probe()
2203 dev_info(card->dev, "VGA controller is disabled\n"); in azx_probe()
2204 dev_info(card->dev, "Delaying initialization\n"); in azx_probe()
2205 chip->disabled = true; in azx_probe()
2208 schedule_probe = !chip->disabled; in azx_probe()
2212 dev_info(card->dev, "Applying patch firmware '%s'\n", in azx_probe()
2215 &pci->dev, GFP_KERNEL, card, in azx_probe()
2225 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n"); in azx_probe()
2229 schedule_delayed_work(&hda->probe_work, 0); in azx_probe()
2232 if (chip->disabled) in azx_probe()
2233 complete_all(&hda->probe_wait); in azx_probe()
2250 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2252 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2254 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2256 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2262 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2263 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2265 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2295 q = snd_pci_quirk_lookup(chip->pci, power_save_denylist); in set_default_power_save()
2297 …dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0… in set_default_power_save()
2298 q->subvendor, q->subdevice); in set_default_power_save()
2303 snd_hda_set_power_save(&chip->bus, val * 1000); in set_default_power_save()
2316 struct pci_dev *pci = chip->pci; in azx_probe_continue()
2317 int dev = chip->dev_index; in azx_probe_continue()
2320 if (chip->disabled || hda->init_failed) in azx_probe_continue()
2321 return -EIO; in azx_probe_continue()
2322 if (hda->probe_retry) in azx_probe_continue()
2325 to_hda_bus(bus)->bus_probing = 1; in azx_probe_continue()
2326 hda->probe_continued = 1; in azx_probe_continue()
2329 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) { in azx_probe_continue()
2338 dev_err(chip->card->dev, in azx_probe_continue()
2339 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n"); in azx_probe_continue()
2343 chip->driver_caps &= ~AZX_DCAPS_I915_COMPONENT; in azx_probe_continue()
2349 hda->need_i915_power = 1; in azx_probe_continue()
2364 chip->beep_mode = beep_mode[dev]; in azx_probe_continue()
2368 if (bus->codec_mask) { in azx_probe_continue()
2369 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); in azx_probe_continue()
2375 if (chip->fw) { in azx_probe_continue()
2376 err = snd_hda_load_patch(&chip->bus, chip->fw->size, in azx_probe_continue()
2377 chip->fw->data); in azx_probe_continue()
2381 release_firmware(chip->fw); /* no longer needed */ in azx_probe_continue()
2382 chip->fw = NULL; in azx_probe_continue()
2388 if (bus->codec_mask && !(probe_only[dev] & 1)) { in azx_probe_continue()
2391 if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) && in azx_probe_continue()
2392 ++hda->probe_retry < 60) { in azx_probe_continue()
2393 schedule_delayed_work(&hda->probe_work, in azx_probe_continue()
2397 dev_err(chip->card->dev, "Cannot probe codecs, giving up\n"); in azx_probe_continue()
2402 err = snd_card_register(chip->card); in azx_probe_continue()
2408 chip->running = 1; in azx_probe_continue()
2414 pm_runtime_use_autosuspend(&pci->dev); in azx_probe_continue()
2415 pm_runtime_allow(&pci->dev); in azx_probe_continue()
2416 pm_runtime_put_autosuspend(&pci->dev); in azx_probe_continue()
2422 snd_card_free(chip->card); in azx_probe_continue()
2426 if (!hda->need_i915_power) in azx_probe_continue()
2428 complete_all(&hda->probe_wait); in azx_probe_continue()
2429 to_hda_bus(bus)->bus_probing = 0; in azx_probe_continue()
2430 hda->probe_retry = 0; in azx_probe_continue()
2442 chip = card->private_data; in azx_remove()
2455 device_unlock(&pci->dev); in azx_remove()
2456 cancel_delayed_work_sync(&hda->probe_work); in azx_remove()
2457 device_lock(&pci->dev); in azx_remove()
2470 chip = card->private_data; in azx_shutdown()
2471 if (chip && chip->running) in azx_shutdown()
2502 /* Lynx Point-LP */
2505 /* Lynx Point-LP */
2508 /* Wildcat Point-LP */
2514 /* Sunrise Point-LP */
2520 /* Kabylake-LP */
2523 /* Kabylake-H */
2532 /* CometLake-LP */
2535 /* CometLake-H */
2540 /* CometLake-S */
2543 /* CometLake-R */
2549 /* Icelake-H */
2560 /* Tigerlake-H */
2573 /* Alderlake-S */
2576 /* Alderlake-P */
2586 /* Broxton-P(Apollolake) */
2589 /* Broxton-T */
2592 /* Gemini-Lake */
2652 /* ATI SB 450/600/700/800/900 */
2673 /* ATI HDMI */
2805 /* Creative X-Fi (CA0110-IBG) */
2812 /* the following entry conflicts with snd-ctxfi driver,
2813 * as ctxfi driver mutates from HD-audio to native mode with
2822 /* this entry seems still valid -- i.e. without emu20kx chip */
2835 /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */