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},"
281 (((chip)->driver_caps & AZX_DCAPS_SNOOP_MASK) >> 10)
327 /* quirks for ATI SB / AMD Hudson */
330 AZX_DCAPS_SNOOP_TYPE(ATI))
332 /* quirks for ATI/AMD HDMI */
337 /* quirks for ATI HDMI with snoop off */
344 AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME |\
361 #define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo)
362 #define needs_eld_notify_link(chip) ((chip)->bus.keep_power)
368 #define CONTROLLER_IN_GPU(pci) (((pci)->device == 0x0a0c) || \
369 ((pci)->device == 0x0c0c) || \
370 ((pci)->device == 0x0d0c) || \
371 ((pci)->device == 0x160c) || \
372 ((pci)->device == 0x490d) || \
373 ((pci)->device == 0x4f90) || \
374 ((pci)->device == 0x4f91) || \
375 ((pci)->device == 0x4f92))
377 #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
385 [AZX_DRIVER_ATI] = "HDA ATI SB",
386 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
387 [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI",
395 [AZX_DRIVER_CMEDIA] = "HDA C-Media",
397 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
422 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) in azx_init_pci()
428 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) { in azx_init_pci()
429 dev_dbg(chip->card->dev, "Clearing TCSEL\n"); in azx_init_pci()
430 update_pci_byte(chip->pci, AZX_PCIREG_TCSEL, 0x07, 0); in azx_init_pci()
433 /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio, in azx_init_pci()
437 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n", in azx_init_pci()
439 update_pci_byte(chip->pci, in azx_init_pci()
446 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n", in azx_init_pci()
448 update_pci_byte(chip->pci, in azx_init_pci()
451 update_pci_byte(chip->pci, in azx_init_pci()
454 update_pci_byte(chip->pci, in azx_init_pci()
462 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); in azx_init_pci()
468 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop); in azx_init_pci()
469 pci_read_config_word(chip->pci, in azx_init_pci()
472 dev_dbg(chip->card->dev, "SCH snoop: %s\n", in azx_init_pci()
479 * In BXT-P A0, HD-Audio DMA requests is later than expected,
510 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCAP); in intel_get_lctl_scf()
518 dev_warn(chip->card->dev, "set audio clock frequency to 6MHz"); in intel_get_lctl_scf()
532 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
535 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
539 if (((readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL)) & in intel_ml_lctl_set_power()
542 timeout--; in intel_ml_lctl_set_power()
546 return -1; in intel_ml_lctl_set_power()
556 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
578 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
589 struct pci_dev *pci = chip->pci; in hda_intel_init_chip()
593 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
599 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
611 if (bus->mlcap != NULL) in hda_intel_init_chip()
619 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_lpib()
620 int stream = substream->stream; in azx_get_delay_from_lpib()
625 delay = pos - lpib_pos; in azx_get_delay_from_lpib()
627 delay = lpib_pos - pos; in azx_get_delay_from_lpib()
629 if (delay >= azx_dev->core.delay_negative_threshold) in azx_get_delay_from_lpib()
632 delay += azx_dev->core.bufsize; in azx_get_delay_from_lpib()
635 if (delay >= azx_dev->core.period_bytes) { in azx_get_delay_from_lpib()
636 dev_info(chip->card->dev, in azx_get_delay_from_lpib()
638 delay, azx_dev->core.period_bytes); in azx_get_delay_from_lpib()
640 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; in azx_get_delay_from_lpib()
641 chip->get_delay[stream] = NULL; in azx_get_delay_from_lpib()
644 return bytes_to_frames(substream->runtime, delay); in azx_get_delay_from_lpib()
657 azx_dev->irq_pending = 0; in azx_position_check()
661 azx_dev->irq_pending = 1; in azx_position_check()
662 schedule_work(&hda->irq_pending_work); in azx_position_check()
672 * periods. Returns non-zero if it's OK.
674 * Many HD-audio controllers appear pretty inaccurate about
675 * the update-IRQ timing. The IRQ is issued before actually the
679 * Returns 1 if OK to proceed, 0 for delay handling, -1 for skipping update
683 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_position_ok()
684 struct snd_pcm_runtime *runtime = substream->runtime; in azx_position_ok()
685 int stream = substream->stream; in azx_position_ok()
690 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk; in azx_position_ok()
691 if (wallclk < (azx_dev->core.period_wallclk * 2) / 3) in azx_position_ok()
692 return -1; /* bogus (too early) interrupt */ in azx_position_ok()
694 if (chip->get_position[stream]) in azx_position_ok()
695 pos = chip->get_position[stream](chip, azx_dev); in azx_position_ok()
698 if (!pos || pos == (u32)-1) { in azx_position_ok()
699 dev_info(chip->card->dev, in azx_position_ok()
701 chip->get_position[stream] = azx_get_pos_lpib; in azx_position_ok()
702 if (chip->get_position[0] == azx_get_pos_lpib && in azx_position_ok()
703 chip->get_position[1] == azx_get_pos_lpib) in azx_position_ok()
704 azx_bus(chip)->use_posbuf = false; in azx_position_ok()
706 chip->get_delay[stream] = NULL; in azx_position_ok()
708 chip->get_position[stream] = azx_get_pos_posbuf; in azx_position_ok()
709 if (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY) in azx_position_ok()
710 chip->get_delay[stream] = azx_get_delay_from_lpib; in azx_position_ok()
714 if (pos >= azx_dev->core.bufsize) in azx_position_ok()
717 if (WARN_ONCE(!azx_dev->core.period_bytes, in azx_position_ok()
718 "hda-intel: zero azx_dev->period_bytes")) in azx_position_ok()
719 return -1; /* this shouldn't happen! */ in azx_position_ok()
720 if (wallclk < (azx_dev->core.period_wallclk * 5) / 4 && in azx_position_ok()
721 pos % azx_dev->core.period_bytes > azx_dev->core.period_bytes / 2) in azx_position_ok()
722 /* NG - it's below the first next period boundary */ in azx_position_ok()
723 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
724 azx_dev->core.start_wallclk += wallclk; in azx_position_ok()
726 if (azx_dev->core.no_period_wakeup) in azx_position_ok()
729 if (runtime->hw_ptr_base != runtime->hw_ptr_interrupt) in azx_position_ok()
734 hwptr = runtime->hw_ptr_base + pos; in azx_position_ok()
735 if (hwptr < runtime->status->hw_ptr) in azx_position_ok()
736 hwptr += runtime->buffer_size; in azx_position_ok()
737 target = runtime->hw_ptr_interrupt + runtime->period_size; in azx_position_ok()
740 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
752 struct azx *chip = &hda->chip; in azx_irq_pending_work()
757 if (!hda->irq_pending_warned) { in azx_irq_pending_work()
758 dev_info(chip->card->dev, in azx_irq_pending_work()
760 chip->card->number); in azx_irq_pending_work()
761 hda->irq_pending_warned = 1; in azx_irq_pending_work()
766 spin_lock_irq(&bus->reg_lock); in azx_irq_pending_work()
767 list_for_each_entry(s, &bus->stream_list, list) { in azx_irq_pending_work()
769 if (!azx_dev->irq_pending || in azx_irq_pending_work()
770 !s->substream || in azx_irq_pending_work()
771 !s->running) in azx_irq_pending_work()
775 azx_dev->irq_pending = 0; in azx_irq_pending_work()
776 spin_unlock(&bus->reg_lock); in azx_irq_pending_work()
777 snd_pcm_period_elapsed(s->substream); in azx_irq_pending_work()
778 spin_lock(&bus->reg_lock); in azx_irq_pending_work()
784 spin_unlock_irq(&bus->reg_lock); in azx_irq_pending_work()
791 /* clear irq_pending flags and assure no on-going workq */
797 spin_lock_irq(&bus->reg_lock); in azx_clear_irq_pending()
798 list_for_each_entry(s, &bus->stream_list, list) { in azx_clear_irq_pending()
800 azx_dev->irq_pending = 0; in azx_clear_irq_pending()
802 spin_unlock_irq(&bus->reg_lock); in azx_clear_irq_pending()
809 if (request_irq(chip->pci->irq, azx_interrupt, in azx_acquire_irq()
810 chip->msi ? 0 : IRQF_SHARED, in azx_acquire_irq()
811 chip->card->irq_descr, chip)) { in azx_acquire_irq()
812 dev_err(chip->card->dev, in azx_acquire_irq()
814 chip->pci->irq); in azx_acquire_irq()
816 snd_card_disconnect(chip->card); in azx_acquire_irq()
817 return -1; in azx_acquire_irq()
819 bus->irq = chip->pci->irq; in azx_acquire_irq()
820 chip->card->sync_irq = bus->irq; in azx_acquire_irq()
821 pci_intx(chip->pci, !chip->msi); in azx_acquire_irq()
834 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in azx_via_get_position()
843 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); in azx_via_get_position()
844 mod_dma_pos %= azx_dev->core.period_bytes; in azx_via_get_position()
846 fifo_size = azx_stream(azx_dev)->fifo_size - 1; in azx_via_get_position()
848 if (azx_dev->insufficient) { in azx_via_get_position()
853 azx_dev->insufficient = 0; in azx_via_get_position()
857 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; in azx_via_get_position()
859 mini_pos = link_pos - fifo_size; in azx_via_get_position()
862 mod_mini_pos = mini_pos % azx_dev->core.period_bytes; in azx_via_get_position()
863 mod_link_pos = link_pos % azx_dev->core.period_bytes; in azx_via_get_position()
865 bound_pos = link_pos - mod_link_pos; in azx_via_get_position()
867 bound_pos = mini_pos - mod_mini_pos; in azx_via_get_position()
869 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; in azx_via_get_position()
870 if (bound_pos >= azx_dev->core.bufsize) in azx_via_get_position()
883 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_pos_fifo()
884 struct snd_pcm_runtime *runtime = substream->runtime; in azx_get_pos_fifo()
891 runtime->delay = AMD_FIFO_SIZE; in azx_get_pos_fifo()
893 if (azx_dev->insufficient) { in azx_get_pos_fifo()
896 runtime->delay = bytes_to_frames(runtime, pos); in azx_get_pos_fifo()
898 azx_dev->insufficient = 0; in azx_get_pos_fifo()
903 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in azx_get_pos_fifo()
905 pos += azx_dev->core.bufsize; in azx_get_pos_fifo()
906 pos -= delay; in azx_get_pos_fifo()
915 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_fifo()
918 return substream->runtime->delay; in azx_get_delay_from_fifo()
943 list_add(&hda->list, &card_list); in azx_add_card_list()
951 list_del_init(&hda->list); in azx_del_card_list()
955 /* trigger power-save check at writing parameter */
968 chip = &hda->chip; in param_set_xint()
969 if (!hda->probe_continued || chip->disabled) in param_set_xint()
971 snd_hda_set_power_save(&chip->bus, power_save * 1000); in param_set_xint()
987 chip = card->private_data; in azx_is_pm_ready()
989 if (chip->disabled || hda->init_failed || !chip->running) in azx_is_pm_ready()
1002 if (hda->need_i915_power) in __azx_runtime_resume()
1012 if (!chip->pm_prepared) { in __azx_runtime_resume()
1013 list_for_each_codec(codec, &chip->bus) { in __azx_runtime_resume()
1014 if (codec->relaxed_resume) in __azx_runtime_resume()
1017 if (codec->forced_resume || (status & (1 << codec->addr))) in __azx_runtime_resume()
1022 /* power down again for link-controlled chips */ in __azx_runtime_resume()
1023 if (!hda->need_i915_power) in __azx_runtime_resume()
1036 chip = card->private_data; in azx_prepare()
1037 chip->pm_prepared = 1; in azx_prepare()
1040 flush_work(&azx_bus(chip)->unsol_work); in azx_prepare()
1043 * and system suspend, so don't use direct-complete here. in azx_prepare()
1056 chip = card->private_data; in azx_complete()
1058 chip->pm_prepared = 0; in azx_complete()
1070 chip = card->private_data; in azx_suspend()
1073 if (bus->irq >= 0) { in azx_suspend()
1074 free_irq(bus->irq, chip); in azx_suspend()
1075 bus->irq = -1; in azx_suspend()
1076 chip->card->sync_irq = -1; in azx_suspend()
1079 if (chip->msi) in azx_suspend()
1080 pci_disable_msi(chip->pci); in azx_suspend()
1094 chip = card->private_data; in azx_resume()
1095 if (chip->msi) in azx_resume()
1096 if (pci_enable_msi(chip->pci) < 0) in azx_resume()
1097 chip->msi = 0; in azx_resume()
1099 return -EIO; in azx_resume()
1113 struct azx *chip = card->private_data; in azx_freeze_noirq()
1118 if (chip->driver_type == AZX_DRIVER_SKL) in azx_freeze_noirq()
1127 struct azx *chip = card->private_data; in azx_thaw_noirq()
1132 if (chip->driver_type == AZX_DRIVER_SKL) in azx_thaw_noirq()
1146 chip = card->private_data; in azx_runtime_suspend()
1163 chip = card->private_data; in azx_runtime_resume()
1182 chip = card->private_data; in azx_runtime_idle()
1184 if (chip->disabled || hda->init_failed) in azx_runtime_idle()
1188 azx_bus(chip)->codec_powered || !chip->running) in azx_runtime_idle()
1189 return -EBUSY; in azx_runtime_idle()
1191 /* ELD notification gets broken when HD-audio bus is off */ in azx_runtime_idle()
1193 return -EBUSY; in azx_runtime_idle()
1226 struct azx *chip = card->private_data; in azx_vs_set_state()
1231 wait_for_completion(&hda->probe_wait); in azx_vs_set_state()
1232 if (hda->init_failed) in azx_vs_set_state()
1236 if (chip->disabled == disabled) in azx_vs_set_state()
1239 if (!hda->probe_continued) { in azx_vs_set_state()
1240 chip->disabled = disabled; in azx_vs_set_state()
1242 dev_info(chip->card->dev, in azx_vs_set_state()
1245 dev_err(chip->card->dev, "initialization error\n"); in azx_vs_set_state()
1248 dev_info(chip->card->dev, "%s via vga_switcheroo\n", in azx_vs_set_state()
1251 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1255 pm_runtime_suspend(card->dev); in azx_vs_set_state()
1256 pm_runtime_disable(card->dev); in azx_vs_set_state()
1260 pci->current_state = PCI_D3cold; in azx_vs_set_state()
1261 chip->disabled = true; in azx_vs_set_state()
1262 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_set_state()
1263 dev_warn(chip->card->dev, in azx_vs_set_state()
1266 snd_hda_unlock_devices(&chip->bus); in azx_vs_set_state()
1267 chip->disabled = false; in azx_vs_set_state()
1268 pm_runtime_enable(card->dev); in azx_vs_set_state()
1269 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1280 struct azx *chip = card->private_data; in azx_vs_can_switch()
1283 wait_for_completion(&hda->probe_wait); in azx_vs_can_switch()
1284 if (hda->init_failed) in azx_vs_can_switch()
1286 if (chip->disabled || !hda->probe_continued) in azx_vs_can_switch()
1288 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_can_switch()
1290 snd_hda_unlock_devices(&chip->bus); in azx_vs_can_switch()
1303 if (hda->use_vga_switcheroo && !needs_eld_notify_link(chip)) { in setup_vga_switcheroo_runtime_pm()
1304 list_for_each_codec(codec, &chip->bus) in setup_vga_switcheroo_runtime_pm()
1305 codec->auto_runtime_pm = 1; in setup_vga_switcheroo_runtime_pm()
1307 if (chip->running) in setup_vga_switcheroo_runtime_pm()
1316 struct azx *chip = card->private_data; in azx_vs_gpu_bound()
1319 chip->bus.keep_power = 0; in azx_vs_gpu_bound()
1326 struct pci_dev *p = get_bound_vga(chip->pci); in init_vga_switcheroo()
1329 dev_info(chip->card->dev, in init_vga_switcheroo()
1331 hda->use_vga_switcheroo = 1; in init_vga_switcheroo()
1337 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1; in init_vga_switcheroo()
1338 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME; in init_vga_switcheroo()
1355 if (!hda->use_vga_switcheroo) in register_vga_switcheroo()
1358 p = get_bound_vga(chip->pci); in register_vga_switcheroo()
1359 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p); in register_vga_switcheroo()
1364 hda->vga_switcheroo_registered = 1; in register_vga_switcheroo()
1380 struct pci_dev *pci = chip->pci; in azx_free()
1384 if (hda->freed) in azx_free()
1387 if (azx_has_pm_runtime(chip) && chip->running) in azx_free()
1388 pm_runtime_get_noresume(&pci->dev); in azx_free()
1389 chip->running = 0; in azx_free()
1393 hda->init_failed = 1; /* to be sure */ in azx_free()
1394 complete_all(&hda->probe_wait); in azx_free()
1397 if (chip->disabled && hda->probe_continued) in azx_free()
1398 snd_hda_unlock_devices(&chip->bus); in azx_free()
1399 if (hda->vga_switcheroo_registered) in azx_free()
1400 vga_switcheroo_unregister_client(chip->pci); in azx_free()
1403 if (bus->chip_init) { in azx_free()
1409 if (bus->irq >= 0) in azx_free()
1410 free_irq(bus->irq, (void*)chip); in azx_free()
1411 if (chip->msi) in azx_free()
1412 pci_disable_msi(chip->pci); in azx_free()
1413 iounmap(bus->remap_addr); in azx_free()
1419 if (chip->region_requested) in azx_free()
1420 pci_release_regions(chip->pci); in azx_free()
1422 pci_disable_device(chip->pci); in azx_free()
1424 release_firmware(chip->fw); in azx_free()
1428 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) in azx_free()
1431 hda->freed = 1; in azx_free()
1436 struct azx *chip = device->device_data; in azx_dev_disconnect()
1439 chip->bus.shutdown = 1; in azx_dev_disconnect()
1440 cancel_work_sync(&bus->unsol_work); in azx_dev_disconnect()
1447 azx_free(device->device_data); in azx_dev_free()
1461 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1471 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1497 switch (pci->vendor) { in get_bound_vga()
1500 if (pci->devfn == 1) { in get_bound_vga()
1501 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1502 pci->bus->number, 0); in get_bound_vga()
1509 if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) && in get_bound_vga()
1517 if (pci->devfn == 1) { in get_bound_vga()
1518 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1519 pci->bus->number, 0); in get_bound_vga()
1521 if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) in get_bound_vga()
1546 * allow/deny-listing for position_fix
1558 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1561 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1562 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1581 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); in check_position_fix()
1583 dev_info(chip->card->dev, in check_position_fix()
1585 q->value, q->subvendor, q->subdevice); in check_position_fix()
1586 return q->value; in check_position_fix()
1589 /* Check VIA/ATI HD Audio Controller exist */ in check_position_fix()
1590 if (chip->driver_type == AZX_DRIVER_VIA) { in check_position_fix()
1591 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); in check_position_fix()
1594 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) { in check_position_fix()
1595 dev_dbg(chip->card->dev, "Using FIFO position fix\n"); in check_position_fix()
1598 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { in check_position_fix()
1599 dev_dbg(chip->card->dev, "Using LPIB position fix\n"); in check_position_fix()
1602 if (chip->driver_type == AZX_DRIVER_SKL) { in check_position_fix()
1603 dev_dbg(chip->card->dev, "Using SKL position fix\n"); in check_position_fix()
1621 chip->get_position[0] = chip->get_position[1] = callbacks[fix]; in assign_position_fix()
1625 chip->get_position[1] = NULL; in assign_position_fix()
1628 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { in assign_position_fix()
1629 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1634 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1639 * deny-lists for probe_mask
1643 * to the non-working (or non-existing) modem codec slot.
1666 chip->codec_probe_mask = probe_mask[dev]; in check_probe_mask()
1667 if (chip->codec_probe_mask == -1) { in check_probe_mask()
1668 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); in check_probe_mask()
1670 dev_info(chip->card->dev, in check_probe_mask()
1672 q->value, q->subvendor, q->subdevice); in check_probe_mask()
1673 chip->codec_probe_mask = q->value; in check_probe_mask()
1678 if (chip->codec_probe_mask != -1 && in check_probe_mask()
1679 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { in check_probe_mask()
1680 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff; in check_probe_mask()
1681 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n", in check_probe_mask()
1682 (int)azx_bus(chip)->codec_mask); in check_probe_mask()
1687 * allow/deny-list for enable_msi
1699 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1708 chip->msi = !!enable_msi; in check_msi()
1711 chip->msi = 1; /* enable MSI as default */ in check_msi()
1712 q = snd_pci_quirk_lookup(chip->pci, msi_deny_list); in check_msi()
1714 dev_info(chip->card->dev, in check_msi()
1716 q->subvendor, q->subdevice, q->value); in check_msi()
1717 chip->msi = q->value; in check_msi()
1722 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { in check_msi()
1723 dev_info(chip->card->dev, "Disabling MSI\n"); in check_msi()
1724 chip->msi = 0; in check_msi()
1734 dev_info(chip->card->dev, "Force to %s mode by module option\n", in azx_check_snoop_available()
1735 snoop ? "snoop" : "non-snoop"); in azx_check_snoop_available()
1736 chip->snoop = snoop; in azx_check_snoop_available()
1737 chip->uc_buffer = !snoop; in azx_check_snoop_available()
1743 chip->driver_type == AZX_DRIVER_VIA) { in azx_check_snoop_available()
1744 /* force to non-snoop mode for a new VIA controller in azx_check_snoop_available()
1748 pci_read_config_byte(chip->pci, 0x42, &val); in azx_check_snoop_available()
1749 if (!(val & 0x80) && (chip->pci->revision == 0x30 || in azx_check_snoop_available()
1750 chip->pci->revision == 0x20)) in azx_check_snoop_available()
1754 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) in azx_check_snoop_available()
1757 chip->snoop = snoop; in azx_check_snoop_available()
1759 dev_info(chip->card->dev, "Force to non-snoop mode\n"); in azx_check_snoop_available()
1760 /* C-Media requires non-cached pages only for CORB/RIRB */ in azx_check_snoop_available()
1761 if (chip->driver_type != AZX_DRIVER_CMEDIA) in azx_check_snoop_available()
1762 chip->uc_buffer = true; in azx_check_snoop_available()
1769 azx_probe_continue(&hda->chip); in azx_probe_work()
1775 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) { in default_bdl_pos_adj()
1776 switch (chip->pci->device) { in default_bdl_pos_adj()
1783 switch (chip->driver_type) { in default_bdl_pos_adj()
1815 hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL); in azx_create()
1818 return -ENOMEM; in azx_create()
1821 chip = &hda->chip; in azx_create()
1822 mutex_init(&chip->open_mutex); in azx_create()
1823 chip->card = card; in azx_create()
1824 chip->pci = pci; in azx_create()
1825 chip->ops = &pci_hda_ops; in azx_create()
1826 chip->driver_caps = driver_caps; in azx_create()
1827 chip->driver_type = driver_caps & 0xff; in azx_create()
1829 chip->dev_index = dev; in azx_create()
1831 chip->jackpoll_interval = msecs_to_jiffies(jackpoll_ms[dev]); in azx_create()
1832 INIT_LIST_HEAD(&chip->pcm_list); in azx_create()
1833 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); in azx_create()
1834 INIT_LIST_HEAD(&hda->list); in azx_create()
1836 init_completion(&hda->probe_wait); in azx_create()
1843 chip->fallback_to_single_cmd = 1; in azx_create()
1845 chip->single_cmd = single_cmd; in azx_create()
1850 chip->bdl_pos_adj = default_bdl_pos_adj(chip); in azx_create()
1852 chip->bdl_pos_adj = bdl_pos_adj[dev]; in azx_create()
1860 /* use the non-cached pages in non-snoop mode */ in azx_create()
1862 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_UC; in azx_create()
1864 if (chip->driver_type == AZX_DRIVER_NVIDIA) { in azx_create()
1865 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); in azx_create()
1866 chip->bus.core.needs_damn_long_delay = 1; in azx_create()
1871 dev_err(card->dev, "Error creating device [card]!\n"); in azx_create()
1877 INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work); in azx_create()
1886 int dev = chip->dev_index; in azx_first_init()
1887 struct pci_dev *pci = chip->pci; in azx_first_init()
1888 struct snd_card *card = chip->card; in azx_first_init()
1895 /* Fix up base address on ULI M5461 */ in azx_first_init()
1896 if (chip->driver_type == AZX_DRIVER_ULI) { in azx_first_init()
1907 chip->region_requested = 1; in azx_first_init()
1909 bus->addr = pci_resource_start(pci, 0); in azx_first_init()
1910 bus->remap_addr = pci_ioremap_bar(pci, 0); in azx_first_init()
1911 if (bus->remap_addr == NULL) { in azx_first_init()
1912 dev_err(card->dev, "ioremap error\n"); in azx_first_init()
1913 return -ENXIO; in azx_first_init()
1916 if (chip->driver_type == AZX_DRIVER_SKL) in azx_first_init()
1925 chip->gts_present = false; in azx_first_init()
1928 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART)) in azx_first_init()
1929 chip->gts_present = true; in azx_first_init()
1932 if (chip->msi) { in azx_first_init()
1933 if (chip->driver_caps & AZX_DCAPS_NO_MSI64) { in azx_first_init()
1934 dev_dbg(card->dev, "Disabling 64bit MSI\n"); in azx_first_init()
1935 pci->no_64bit_msi = true; in azx_first_init()
1938 chip->msi = 0; in azx_first_init()
1944 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); in azx_first_init()
1947 if (chip->pci->vendor == PCI_VENDOR_ID_AMD) in azx_first_init()
1951 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { in azx_first_init()
1958 if (p_smbus->revision < 0x30) in azx_first_init()
1965 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA) in azx_first_init()
1969 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { in azx_first_init()
1970 dev_dbg(card->dev, "Disabling 64bit DMA\n"); in azx_first_init()
1974 /* disable buffer size rounding to 128-byte multiples if supported */ in azx_first_init()
1976 chip->align_buffer_size = !!align_buffer_size; in azx_first_init()
1978 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE) in azx_first_init()
1979 chip->align_buffer_size = 0; in azx_first_init()
1981 chip->align_buffer_size = 1; in azx_first_init()
1987 if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) { in azx_first_init()
1988 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits)); in azx_first_init()
1990 dma_set_mask(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1991 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1997 chip->capture_streams = (gcap >> 8) & 0x0f; in azx_first_init()
1998 chip->playback_streams = (gcap >> 12) & 0x0f; in azx_first_init()
1999 if (!chip->playback_streams && !chip->capture_streams) { in azx_first_init()
2002 switch (chip->driver_type) { in azx_first_init()
2004 chip->playback_streams = ULI_NUM_PLAYBACK; in azx_first_init()
2005 chip->capture_streams = ULI_NUM_CAPTURE; in azx_first_init()
2009 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; in azx_first_init()
2010 chip->capture_streams = ATIHDMI_NUM_CAPTURE; in azx_first_init()
2014 chip->playback_streams = ICH6_NUM_PLAYBACK; in azx_first_init()
2015 chip->capture_streams = ICH6_NUM_CAPTURE; in azx_first_init()
2019 chip->capture_index_offset = 0; in azx_first_init()
2020 chip->playback_index_offset = chip->capture_streams; in azx_first_init()
2021 chip->num_streams = chip->playback_streams + chip->capture_streams; in azx_first_init()
2024 if (chip->num_streams > 15 && in azx_first_init()
2025 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) { in azx_first_init()
2026 dev_warn(chip->card->dev, "number of I/O streams is %d, " in azx_first_init()
2027 "forcing separate stream tags", chip->num_streams); in azx_first_init()
2028 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG; in azx_first_init()
2048 if (!azx_bus(chip)->codec_mask) { in azx_first_init()
2049 dev_err(card->dev, "no codecs found!\n"); in azx_first_init()
2054 return -EBUSY; in azx_first_init()
2056 strcpy(card->driver, "HDA-Intel"); in azx_first_init()
2057 strlcpy(card->shortname, driver_short_names[chip->driver_type], in azx_first_init()
2058 sizeof(card->shortname)); in azx_first_init()
2059 snprintf(card->longname, sizeof(card->longname), in azx_first_init()
2061 card->shortname, bus->addr, bus->irq); in azx_first_init()
2071 struct azx *chip = card->private_data; in azx_firmware_cb()
2074 chip->fw = fw; in azx_firmware_cb()
2076 dev_err(card->dev, "Cannot load firmware, continue without patching\n"); in azx_firmware_cb()
2077 if (!chip->disabled) { in azx_firmware_cb()
2089 free_irq(bus->irq, chip); in disable_msi_reset_irq()
2090 bus->irq = -1; in disable_msi_reset_irq()
2091 chip->card->sync_irq = -1; in disable_msi_reset_irq()
2092 pci_disable_msi(chip->pci); in disable_msi_reset_irq()
2093 chip->msi = 0; in disable_msi_reset_irq()
2106 struct azx *chip = apcm->chip; in pcm_mmap_prepare()
2107 if (chip->uc_buffer) in pcm_mmap_prepare()
2108 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); in pcm_mmap_prepare()
2113 * some HD-audio PCI entries are exposed without any codecs, and such devices
2140 dev_info(&pci->dev, "Skipping the device on the denylist\n"); in azx_probe()
2141 return -ENODEV; in azx_probe()
2145 return -ENODEV; in azx_probe()
2148 return -ENOENT; in azx_probe()
2157 dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n"); in azx_probe()
2158 return -ENODEV; in azx_probe()
2161 …dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option i… in azx_probe()
2164 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in azx_probe()
2167 dev_err(&pci->dev, "Error creating card!\n"); in azx_probe()
2171 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); in azx_probe()
2174 card->private_data = chip; in azx_probe()
2181 dev_err(card->dev, "Error registering vga_switcheroo client\n"); in azx_probe()
2186 dev_info(card->dev, "VGA controller is disabled\n"); in azx_probe()
2187 dev_info(card->dev, "Delaying initialization\n"); in azx_probe()
2188 chip->disabled = true; in azx_probe()
2191 schedule_probe = !chip->disabled; in azx_probe()
2195 dev_info(card->dev, "Applying patch firmware '%s'\n", in azx_probe()
2198 &pci->dev, GFP_KERNEL, card, in azx_probe()
2208 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n"); in azx_probe()
2212 schedule_delayed_work(&hda->probe_work, 0); in azx_probe()
2215 if (chip->disabled) in azx_probe()
2216 complete_all(&hda->probe_wait); in azx_probe()
2233 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2235 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2237 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2239 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2245 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2246 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2248 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2275 q = snd_pci_quirk_lookup(chip->pci, power_save_denylist); in set_default_power_save()
2277 …dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0… in set_default_power_save()
2278 q->subvendor, q->subdevice); in set_default_power_save()
2283 snd_hda_set_power_save(&chip->bus, val * 1000); in set_default_power_save()
2296 struct pci_dev *pci = chip->pci; in azx_probe_continue()
2297 int dev = chip->dev_index; in azx_probe_continue()
2300 if (chip->disabled || hda->init_failed) in azx_probe_continue()
2301 return -EIO; in azx_probe_continue()
2302 if (hda->probe_retry) in azx_probe_continue()
2305 to_hda_bus(bus)->bus_probing = 1; in azx_probe_continue()
2306 hda->probe_continued = 1; in azx_probe_continue()
2309 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) { in azx_probe_continue()
2318 dev_err(chip->card->dev, in azx_probe_continue()
2319 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n"); in azx_probe_continue()
2323 chip->driver_caps &= ~AZX_DCAPS_I915_COMPONENT; in azx_probe_continue()
2329 hda->need_i915_power = 1; in azx_probe_continue()
2344 chip->beep_mode = beep_mode[dev]; in azx_probe_continue()
2348 if (bus->codec_mask) { in azx_probe_continue()
2349 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); in azx_probe_continue()
2355 if (chip->fw) { in azx_probe_continue()
2356 err = snd_hda_load_patch(&chip->bus, chip->fw->size, in azx_probe_continue()
2357 chip->fw->data); in azx_probe_continue()
2361 release_firmware(chip->fw); /* no longer needed */ in azx_probe_continue()
2362 chip->fw = NULL; in azx_probe_continue()
2368 if (bus->codec_mask && !(probe_only[dev] & 1)) { in azx_probe_continue()
2371 if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) && in azx_probe_continue()
2372 ++hda->probe_retry < 60) { in azx_probe_continue()
2373 schedule_delayed_work(&hda->probe_work, in azx_probe_continue()
2377 dev_err(chip->card->dev, "Cannot probe codecs, giving up\n"); in azx_probe_continue()
2382 err = snd_card_register(chip->card); in azx_probe_continue()
2388 chip->running = 1; in azx_probe_continue()
2394 pm_runtime_use_autosuspend(&pci->dev); in azx_probe_continue()
2395 pm_runtime_allow(&pci->dev); in azx_probe_continue()
2396 pm_runtime_put_autosuspend(&pci->dev); in azx_probe_continue()
2402 snd_card_free(chip->card); in azx_probe_continue()
2406 if (!hda->need_i915_power) in azx_probe_continue()
2408 complete_all(&hda->probe_wait); in azx_probe_continue()
2409 to_hda_bus(bus)->bus_probing = 0; in azx_probe_continue()
2410 hda->probe_retry = 0; in azx_probe_continue()
2422 chip = card->private_data; in azx_remove()
2435 device_unlock(&pci->dev); in azx_remove()
2436 cancel_delayed_work_sync(&hda->probe_work); in azx_remove()
2437 device_lock(&pci->dev); in azx_remove()
2450 chip = card->private_data; in azx_shutdown()
2451 if (chip && chip->running) in azx_shutdown()
2482 /* Lynx Point-LP */
2485 /* Lynx Point-LP */
2488 /* Wildcat Point-LP */
2494 /* Sunrise Point-LP */
2500 /* Kabylake-LP */
2503 /* Kabylake-H */
2512 /* CometLake-LP */
2515 /* CometLake-H */
2520 /* CometLake-S */
2523 /* CometLake-R */
2529 /* Icelake-H */
2540 /* Tigerlake-H */
2553 /* Alderlake-S */
2556 /* Alderlake-P */
2564 /* Broxton-P(Apollolake) */
2567 /* Broxton-T */
2570 /* Gemini-Lake */
2627 /* ATI SB 450/600/700/800/900 */
2648 /* ATI HDMI */
2771 /* Creative X-Fi (CA0110-IBG) */
2778 /* the following entry conflicts with snd-ctxfi driver,
2779 * as ctxfi driver mutates from HD-audio to native mode with
2788 /* this entry seems still valid -- i.e. without emu20kx chip */
2801 /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */