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)
360 #define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo)
361 #define needs_eld_notify_link(chip) ((chip)->bus.keep_power)
367 #define CONTROLLER_IN_GPU(pci) (((pci)->device == 0x0a0c) || \
368 ((pci)->device == 0x0c0c) || \
369 ((pci)->device == 0x0d0c) || \
370 ((pci)->device == 0x160c) || \
371 ((pci)->device == 0x490d))
373 #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
381 [AZX_DRIVER_ATI] = "HDA ATI SB",
382 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
383 [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI",
391 [AZX_DRIVER_CMEDIA] = "HDA C-Media",
393 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
418 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) in azx_init_pci()
424 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) { in azx_init_pci()
425 dev_dbg(chip->card->dev, "Clearing TCSEL\n"); in azx_init_pci()
426 update_pci_byte(chip->pci, AZX_PCIREG_TCSEL, 0x07, 0); in azx_init_pci()
429 /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio, in azx_init_pci()
433 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n", in azx_init_pci()
435 update_pci_byte(chip->pci, in azx_init_pci()
442 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n", in azx_init_pci()
444 update_pci_byte(chip->pci, in azx_init_pci()
447 update_pci_byte(chip->pci, in azx_init_pci()
450 update_pci_byte(chip->pci, in azx_init_pci()
458 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); in azx_init_pci()
464 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop); in azx_init_pci()
465 pci_read_config_word(chip->pci, in azx_init_pci()
468 dev_dbg(chip->card->dev, "SCH snoop: %s\n", in azx_init_pci()
475 * In BXT-P A0, HD-Audio DMA requests is later than expected,
506 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCAP); in intel_get_lctl_scf()
514 dev_warn(chip->card->dev, "set audio clock frequency to 6MHz"); in intel_get_lctl_scf()
528 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
531 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
535 if (((readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL)) & in intel_ml_lctl_set_power()
538 timeout--; in intel_ml_lctl_set_power()
542 return -1; in intel_ml_lctl_set_power()
552 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
574 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
585 struct pci_dev *pci = chip->pci; in hda_intel_init_chip()
589 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
595 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
607 if (bus->mlcap != NULL) in hda_intel_init_chip()
615 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_lpib()
616 int stream = substream->stream; in azx_get_delay_from_lpib()
621 delay = pos - lpib_pos; in azx_get_delay_from_lpib()
623 delay = lpib_pos - pos; in azx_get_delay_from_lpib()
625 if (delay >= azx_dev->core.delay_negative_threshold) in azx_get_delay_from_lpib()
628 delay += azx_dev->core.bufsize; in azx_get_delay_from_lpib()
631 if (delay >= azx_dev->core.period_bytes) { in azx_get_delay_from_lpib()
632 dev_info(chip->card->dev, in azx_get_delay_from_lpib()
634 delay, azx_dev->core.period_bytes); in azx_get_delay_from_lpib()
636 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; in azx_get_delay_from_lpib()
637 chip->get_delay[stream] = NULL; in azx_get_delay_from_lpib()
640 return bytes_to_frames(substream->runtime, delay); in azx_get_delay_from_lpib()
653 azx_dev->irq_pending = 0; in azx_position_check()
657 azx_dev->irq_pending = 1; in azx_position_check()
658 schedule_work(&hda->irq_pending_work); in azx_position_check()
668 * periods. Returns non-zero if it's OK.
670 * Many HD-audio controllers appear pretty inaccurate about
671 * the update-IRQ timing. The IRQ is issued before actually the
677 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_position_ok()
678 int stream = substream->stream; in azx_position_ok()
682 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk; in azx_position_ok()
683 if (wallclk < (azx_dev->core.period_wallclk * 2) / 3) in azx_position_ok()
684 return -1; /* bogus (too early) interrupt */ in azx_position_ok()
686 if (chip->get_position[stream]) in azx_position_ok()
687 pos = chip->get_position[stream](chip, azx_dev); in azx_position_ok()
690 if (!pos || pos == (u32)-1) { in azx_position_ok()
691 dev_info(chip->card->dev, in azx_position_ok()
693 chip->get_position[stream] = azx_get_pos_lpib; in azx_position_ok()
694 if (chip->get_position[0] == azx_get_pos_lpib && in azx_position_ok()
695 chip->get_position[1] == azx_get_pos_lpib) in azx_position_ok()
696 azx_bus(chip)->use_posbuf = false; in azx_position_ok()
698 chip->get_delay[stream] = NULL; in azx_position_ok()
700 chip->get_position[stream] = azx_get_pos_posbuf; in azx_position_ok()
701 if (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY) in azx_position_ok()
702 chip->get_delay[stream] = azx_get_delay_from_lpib; in azx_position_ok()
706 if (pos >= azx_dev->core.bufsize) in azx_position_ok()
709 if (WARN_ONCE(!azx_dev->core.period_bytes, in azx_position_ok()
710 "hda-intel: zero azx_dev->period_bytes")) in azx_position_ok()
711 return -1; /* this shouldn't happen! */ in azx_position_ok()
712 if (wallclk < (azx_dev->core.period_wallclk * 5) / 4 && in azx_position_ok()
713 pos % azx_dev->core.period_bytes > azx_dev->core.period_bytes / 2) in azx_position_ok()
714 /* NG - it's below the first next period boundary */ in azx_position_ok()
715 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
716 azx_dev->core.start_wallclk += wallclk; in azx_position_ok()
726 struct azx *chip = &hda->chip; in azx_irq_pending_work()
731 if (!hda->irq_pending_warned) { in azx_irq_pending_work()
732 dev_info(chip->card->dev, in azx_irq_pending_work()
734 chip->card->number); in azx_irq_pending_work()
735 hda->irq_pending_warned = 1; in azx_irq_pending_work()
740 spin_lock_irq(&bus->reg_lock); in azx_irq_pending_work()
741 list_for_each_entry(s, &bus->stream_list, list) { in azx_irq_pending_work()
743 if (!azx_dev->irq_pending || in azx_irq_pending_work()
744 !s->substream || in azx_irq_pending_work()
745 !s->running) in azx_irq_pending_work()
749 azx_dev->irq_pending = 0; in azx_irq_pending_work()
750 spin_unlock(&bus->reg_lock); in azx_irq_pending_work()
751 snd_pcm_period_elapsed(s->substream); in azx_irq_pending_work()
752 spin_lock(&bus->reg_lock); in azx_irq_pending_work()
758 spin_unlock_irq(&bus->reg_lock); in azx_irq_pending_work()
765 /* clear irq_pending flags and assure no on-going workq */
771 spin_lock_irq(&bus->reg_lock); in azx_clear_irq_pending()
772 list_for_each_entry(s, &bus->stream_list, list) { in azx_clear_irq_pending()
774 azx_dev->irq_pending = 0; in azx_clear_irq_pending()
776 spin_unlock_irq(&bus->reg_lock); in azx_clear_irq_pending()
783 if (request_irq(chip->pci->irq, azx_interrupt, in azx_acquire_irq()
784 chip->msi ? 0 : IRQF_SHARED, in azx_acquire_irq()
785 chip->card->irq_descr, chip)) { in azx_acquire_irq()
786 dev_err(chip->card->dev, in azx_acquire_irq()
788 chip->pci->irq); in azx_acquire_irq()
790 snd_card_disconnect(chip->card); in azx_acquire_irq()
791 return -1; in azx_acquire_irq()
793 bus->irq = chip->pci->irq; in azx_acquire_irq()
794 chip->card->sync_irq = bus->irq; in azx_acquire_irq()
795 pci_intx(chip->pci, !chip->msi); in azx_acquire_irq()
808 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in azx_via_get_position()
817 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); in azx_via_get_position()
818 mod_dma_pos %= azx_dev->core.period_bytes; in azx_via_get_position()
820 fifo_size = azx_stream(azx_dev)->fifo_size - 1; in azx_via_get_position()
822 if (azx_dev->insufficient) { in azx_via_get_position()
827 azx_dev->insufficient = 0; in azx_via_get_position()
831 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; in azx_via_get_position()
833 mini_pos = link_pos - fifo_size; in azx_via_get_position()
836 mod_mini_pos = mini_pos % azx_dev->core.period_bytes; in azx_via_get_position()
837 mod_link_pos = link_pos % azx_dev->core.period_bytes; in azx_via_get_position()
839 bound_pos = link_pos - mod_link_pos; in azx_via_get_position()
841 bound_pos = mini_pos - mod_mini_pos; in azx_via_get_position()
843 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; in azx_via_get_position()
844 if (bound_pos >= azx_dev->core.bufsize) in azx_via_get_position()
857 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_pos_fifo()
858 struct snd_pcm_runtime *runtime = substream->runtime; in azx_get_pos_fifo()
865 runtime->delay = AMD_FIFO_SIZE; in azx_get_pos_fifo()
867 if (azx_dev->insufficient) { in azx_get_pos_fifo()
870 runtime->delay = bytes_to_frames(runtime, pos); in azx_get_pos_fifo()
872 azx_dev->insufficient = 0; in azx_get_pos_fifo()
877 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in azx_get_pos_fifo()
879 pos += azx_dev->core.bufsize; in azx_get_pos_fifo()
880 pos -= delay; in azx_get_pos_fifo()
889 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_fifo()
892 return substream->runtime->delay; in azx_get_delay_from_fifo()
901 azx_dev->core.index)); in azx_skl_get_dpib_pos()
908 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in azx_get_pos_skl()
928 list_add(&hda->list, &card_list); in azx_add_card_list()
936 list_del_init(&hda->list); in azx_del_card_list()
940 /* trigger power-save check at writing parameter */
953 chip = &hda->chip; in param_set_xint()
954 if (!hda->probe_continued || chip->disabled) in param_set_xint()
956 snd_hda_set_power_save(&chip->bus, power_save * 1000); in param_set_xint()
972 chip = card->private_data; in azx_is_pm_ready()
974 if (chip->disabled || hda->init_failed || !chip->running) in azx_is_pm_ready()
995 if (hda->need_i915_power) in __azx_runtime_resume()
1005 if (!chip->pm_prepared) { in __azx_runtime_resume()
1006 list_for_each_codec(codec, &chip->bus) { in __azx_runtime_resume()
1007 if (codec->relaxed_resume) in __azx_runtime_resume()
1010 if (codec->forced_resume || (status & (1 << codec->addr))) in __azx_runtime_resume()
1015 /* power down again for link-controlled chips */ in __azx_runtime_resume()
1016 if (!hda->need_i915_power) in __azx_runtime_resume()
1026 chip = card->private_data; in azx_prepare()
1027 chip->pm_prepared = 1; in azx_prepare()
1030 * and system suspend, so don't use direct-complete here. in azx_prepare()
1040 chip = card->private_data; in azx_complete()
1041 chip->pm_prepared = 0; in azx_complete()
1053 chip = card->private_data; in azx_suspend()
1056 if (bus->irq >= 0) { in azx_suspend()
1057 free_irq(bus->irq, chip); in azx_suspend()
1058 bus->irq = -1; in azx_suspend()
1059 chip->card->sync_irq = -1; in azx_suspend()
1062 if (chip->msi) in azx_suspend()
1063 pci_disable_msi(chip->pci); in azx_suspend()
1077 chip = card->private_data; in azx_resume()
1078 if (chip->msi) in azx_resume()
1079 if (pci_enable_msi(chip->pci) < 0) in azx_resume()
1080 chip->msi = 0; in azx_resume()
1082 return -EIO; in azx_resume()
1096 struct azx *chip = card->private_data; in azx_freeze_noirq()
1101 if (chip->driver_type == AZX_DRIVER_SKL) in azx_freeze_noirq()
1110 struct azx *chip = card->private_data; in azx_thaw_noirq()
1115 if (chip->driver_type == AZX_DRIVER_SKL) in azx_thaw_noirq()
1129 chip = card->private_data; in azx_runtime_suspend()
1146 chip = card->private_data; in azx_runtime_resume()
1165 chip = card->private_data; in azx_runtime_idle()
1167 if (chip->disabled || hda->init_failed) in azx_runtime_idle()
1171 azx_bus(chip)->codec_powered || !chip->running) in azx_runtime_idle()
1172 return -EBUSY; in azx_runtime_idle()
1174 /* ELD notification gets broken when HD-audio bus is off */ in azx_runtime_idle()
1176 return -EBUSY; in azx_runtime_idle()
1209 struct azx *chip = card->private_data; in azx_vs_set_state()
1214 wait_for_completion(&hda->probe_wait); in azx_vs_set_state()
1215 if (hda->init_failed) in azx_vs_set_state()
1219 if (chip->disabled == disabled) in azx_vs_set_state()
1222 if (!hda->probe_continued) { in azx_vs_set_state()
1223 chip->disabled = disabled; in azx_vs_set_state()
1225 dev_info(chip->card->dev, in azx_vs_set_state()
1228 dev_err(chip->card->dev, "initialization error\n"); in azx_vs_set_state()
1231 dev_info(chip->card->dev, "%s via vga_switcheroo\n", in azx_vs_set_state()
1234 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1238 pm_runtime_suspend(card->dev); in azx_vs_set_state()
1239 pm_runtime_disable(card->dev); in azx_vs_set_state()
1243 pci->current_state = PCI_D3cold; in azx_vs_set_state()
1244 chip->disabled = true; in azx_vs_set_state()
1245 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_set_state()
1246 dev_warn(chip->card->dev, in azx_vs_set_state()
1249 snd_hda_unlock_devices(&chip->bus); in azx_vs_set_state()
1250 chip->disabled = false; in azx_vs_set_state()
1251 pm_runtime_enable(card->dev); in azx_vs_set_state()
1252 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1263 struct azx *chip = card->private_data; in azx_vs_can_switch()
1266 wait_for_completion(&hda->probe_wait); in azx_vs_can_switch()
1267 if (hda->init_failed) in azx_vs_can_switch()
1269 if (chip->disabled || !hda->probe_continued) in azx_vs_can_switch()
1271 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_can_switch()
1273 snd_hda_unlock_devices(&chip->bus); in azx_vs_can_switch()
1286 if (hda->use_vga_switcheroo && !needs_eld_notify_link(chip)) { in setup_vga_switcheroo_runtime_pm()
1287 list_for_each_codec(codec, &chip->bus) in setup_vga_switcheroo_runtime_pm()
1288 codec->auto_runtime_pm = 1; in setup_vga_switcheroo_runtime_pm()
1290 if (chip->running) in setup_vga_switcheroo_runtime_pm()
1299 struct azx *chip = card->private_data; in azx_vs_gpu_bound()
1302 chip->bus.keep_power = 0; in azx_vs_gpu_bound()
1309 struct pci_dev *p = get_bound_vga(chip->pci); in init_vga_switcheroo()
1312 dev_info(chip->card->dev, in init_vga_switcheroo()
1314 hda->use_vga_switcheroo = 1; in init_vga_switcheroo()
1320 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1; in init_vga_switcheroo()
1321 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME; in init_vga_switcheroo()
1338 if (!hda->use_vga_switcheroo) in register_vga_switcheroo()
1341 p = get_bound_vga(chip->pci); in register_vga_switcheroo()
1342 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p); in register_vga_switcheroo()
1347 hda->vga_switcheroo_registered = 1; in register_vga_switcheroo()
1363 struct pci_dev *pci = chip->pci; in azx_free()
1367 if (hda->freed) in azx_free()
1370 if (azx_has_pm_runtime(chip) && chip->running) in azx_free()
1371 pm_runtime_get_noresume(&pci->dev); in azx_free()
1372 chip->running = 0; in azx_free()
1376 hda->init_failed = 1; /* to be sure */ in azx_free()
1377 complete_all(&hda->probe_wait); in azx_free()
1380 if (chip->disabled && hda->probe_continued) in azx_free()
1381 snd_hda_unlock_devices(&chip->bus); in azx_free()
1382 if (hda->vga_switcheroo_registered) in azx_free()
1383 vga_switcheroo_unregister_client(chip->pci); in azx_free()
1386 if (bus->chip_init) { in azx_free()
1392 if (bus->irq >= 0) in azx_free()
1393 free_irq(bus->irq, (void*)chip); in azx_free()
1394 if (chip->msi) in azx_free()
1395 pci_disable_msi(chip->pci); in azx_free()
1396 iounmap(bus->remap_addr); in azx_free()
1402 if (chip->region_requested) in azx_free()
1403 pci_release_regions(chip->pci); in azx_free()
1405 pci_disable_device(chip->pci); in azx_free()
1407 release_firmware(chip->fw); in azx_free()
1411 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) in azx_free()
1414 hda->freed = 1; in azx_free()
1419 struct azx *chip = device->device_data; in azx_dev_disconnect()
1422 chip->bus.shutdown = 1; in azx_dev_disconnect()
1423 cancel_work_sync(&bus->unsol_work); in azx_dev_disconnect()
1430 azx_free(device->device_data); in azx_dev_free()
1444 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1454 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1480 switch (pci->vendor) { in get_bound_vga()
1483 if (pci->devfn == 1) { in get_bound_vga()
1484 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1485 pci->bus->number, 0); in get_bound_vga()
1492 if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) && 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()
1504 if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) in get_bound_vga()
1529 * allow/deny-listing for position_fix
1541 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1544 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1545 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1564 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); in check_position_fix()
1566 dev_info(chip->card->dev, in check_position_fix()
1568 q->value, q->subvendor, q->subdevice); in check_position_fix()
1569 return q->value; in check_position_fix()
1572 /* Check VIA/ATI HD Audio Controller exist */ in check_position_fix()
1573 if (chip->driver_type == AZX_DRIVER_VIA) { in check_position_fix()
1574 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); in check_position_fix()
1577 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) { in check_position_fix()
1578 dev_dbg(chip->card->dev, "Using FIFO position fix\n"); in check_position_fix()
1581 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { in check_position_fix()
1582 dev_dbg(chip->card->dev, "Using LPIB position fix\n"); in check_position_fix()
1585 if (chip->driver_type == AZX_DRIVER_SKL) { in check_position_fix()
1586 dev_dbg(chip->card->dev, "Using SKL position fix\n"); in check_position_fix()
1604 chip->get_position[0] = chip->get_position[1] = callbacks[fix]; in assign_position_fix()
1608 chip->get_position[1] = NULL; in assign_position_fix()
1611 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { in assign_position_fix()
1612 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1617 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1622 * deny-lists for probe_mask
1626 * to the non-working (or non-existing) modem codec slot.
1649 chip->codec_probe_mask = probe_mask[dev]; in check_probe_mask()
1650 if (chip->codec_probe_mask == -1) { in check_probe_mask()
1651 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); in check_probe_mask()
1653 dev_info(chip->card->dev, in check_probe_mask()
1655 q->value, q->subvendor, q->subdevice); in check_probe_mask()
1656 chip->codec_probe_mask = q->value; in check_probe_mask()
1661 if (chip->codec_probe_mask != -1 && in check_probe_mask()
1662 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { in check_probe_mask()
1663 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff; in check_probe_mask()
1664 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n", in check_probe_mask()
1665 (int)azx_bus(chip)->codec_mask); in check_probe_mask()
1670 * allow/deny-list for enable_msi
1682 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1691 chip->msi = !!enable_msi; in check_msi()
1694 chip->msi = 1; /* enable MSI as default */ in check_msi()
1695 q = snd_pci_quirk_lookup(chip->pci, msi_deny_list); in check_msi()
1697 dev_info(chip->card->dev, in check_msi()
1699 q->subvendor, q->subdevice, q->value); in check_msi()
1700 chip->msi = q->value; in check_msi()
1705 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { in check_msi()
1706 dev_info(chip->card->dev, "Disabling MSI\n"); in check_msi()
1707 chip->msi = 0; in check_msi()
1717 dev_info(chip->card->dev, "Force to %s mode by module option\n", in azx_check_snoop_available()
1718 snoop ? "snoop" : "non-snoop"); in azx_check_snoop_available()
1719 chip->snoop = snoop; in azx_check_snoop_available()
1720 chip->uc_buffer = !snoop; in azx_check_snoop_available()
1726 chip->driver_type == AZX_DRIVER_VIA) { in azx_check_snoop_available()
1727 /* force to non-snoop mode for a new VIA controller in azx_check_snoop_available()
1731 pci_read_config_byte(chip->pci, 0x42, &val); in azx_check_snoop_available()
1732 if (!(val & 0x80) && (chip->pci->revision == 0x30 || in azx_check_snoop_available()
1733 chip->pci->revision == 0x20)) in azx_check_snoop_available()
1737 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) in azx_check_snoop_available()
1740 chip->snoop = snoop; in azx_check_snoop_available()
1742 dev_info(chip->card->dev, "Force to non-snoop mode\n"); in azx_check_snoop_available()
1743 /* C-Media requires non-cached pages only for CORB/RIRB */ in azx_check_snoop_available()
1744 if (chip->driver_type != AZX_DRIVER_CMEDIA) in azx_check_snoop_available()
1745 chip->uc_buffer = true; in azx_check_snoop_available()
1752 azx_probe_continue(&hda->chip); in azx_probe_work()
1758 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) { in default_bdl_pos_adj()
1759 switch (chip->pci->device) { in default_bdl_pos_adj()
1766 switch (chip->driver_type) { in default_bdl_pos_adj()
1798 hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL); in azx_create()
1801 return -ENOMEM; in azx_create()
1804 chip = &hda->chip; in azx_create()
1805 mutex_init(&chip->open_mutex); in azx_create()
1806 chip->card = card; in azx_create()
1807 chip->pci = pci; in azx_create()
1808 chip->ops = &pci_hda_ops; in azx_create()
1809 chip->driver_caps = driver_caps; in azx_create()
1810 chip->driver_type = driver_caps & 0xff; in azx_create()
1812 chip->dev_index = dev; in azx_create()
1814 chip->jackpoll_interval = msecs_to_jiffies(jackpoll_ms[dev]); in azx_create()
1815 INIT_LIST_HEAD(&chip->pcm_list); in azx_create()
1816 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); in azx_create()
1817 INIT_LIST_HEAD(&hda->list); in azx_create()
1819 init_completion(&hda->probe_wait); in azx_create()
1826 chip->fallback_to_single_cmd = 1; in azx_create()
1828 chip->single_cmd = single_cmd; in azx_create()
1833 chip->bdl_pos_adj = default_bdl_pos_adj(chip); in azx_create()
1835 chip->bdl_pos_adj = bdl_pos_adj[dev]; in azx_create()
1843 /* use the non-cached pages in non-snoop mode */ in azx_create()
1845 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_UC; in azx_create()
1847 if (chip->driver_type == AZX_DRIVER_NVIDIA) { in azx_create()
1848 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); in azx_create()
1849 chip->bus.core.needs_damn_long_delay = 1; in azx_create()
1854 dev_err(card->dev, "Error creating device [card]!\n"); in azx_create()
1860 INIT_WORK(&hda->probe_work, azx_probe_work); in azx_create()
1869 int dev = chip->dev_index; in azx_first_init()
1870 struct pci_dev *pci = chip->pci; in azx_first_init()
1871 struct snd_card *card = chip->card; in azx_first_init()
1878 /* Fix up base address on ULI M5461 */ in azx_first_init()
1879 if (chip->driver_type == AZX_DRIVER_ULI) { in azx_first_init()
1890 chip->region_requested = 1; in azx_first_init()
1892 bus->addr = pci_resource_start(pci, 0); in azx_first_init()
1893 bus->remap_addr = pci_ioremap_bar(pci, 0); in azx_first_init()
1894 if (bus->remap_addr == NULL) { in azx_first_init()
1895 dev_err(card->dev, "ioremap error\n"); in azx_first_init()
1896 return -ENXIO; in azx_first_init()
1899 if (chip->driver_type == AZX_DRIVER_SKL) in azx_first_init()
1908 chip->gts_present = false; in azx_first_init()
1911 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART)) in azx_first_init()
1912 chip->gts_present = true; in azx_first_init()
1915 if (chip->msi) { in azx_first_init()
1916 if (chip->driver_caps & AZX_DCAPS_NO_MSI64) { in azx_first_init()
1917 dev_dbg(card->dev, "Disabling 64bit MSI\n"); in azx_first_init()
1918 pci->no_64bit_msi = true; in azx_first_init()
1921 chip->msi = 0; in azx_first_init()
1927 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); in azx_first_init()
1930 if (chip->pci->vendor == PCI_VENDOR_ID_AMD) in azx_first_init()
1934 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { in azx_first_init()
1941 if (p_smbus->revision < 0x30) in azx_first_init()
1948 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA) in azx_first_init()
1952 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { in azx_first_init()
1953 dev_dbg(card->dev, "Disabling 64bit DMA\n"); in azx_first_init()
1957 /* disable buffer size rounding to 128-byte multiples if supported */ in azx_first_init()
1959 chip->align_buffer_size = !!align_buffer_size; in azx_first_init()
1961 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE) in azx_first_init()
1962 chip->align_buffer_size = 0; in azx_first_init()
1964 chip->align_buffer_size = 1; in azx_first_init()
1970 if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) { in azx_first_init()
1971 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits)); in azx_first_init()
1973 dma_set_mask(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1974 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1980 chip->capture_streams = (gcap >> 8) & 0x0f; in azx_first_init()
1981 chip->playback_streams = (gcap >> 12) & 0x0f; in azx_first_init()
1982 if (!chip->playback_streams && !chip->capture_streams) { in azx_first_init()
1985 switch (chip->driver_type) { in azx_first_init()
1987 chip->playback_streams = ULI_NUM_PLAYBACK; in azx_first_init()
1988 chip->capture_streams = ULI_NUM_CAPTURE; in azx_first_init()
1992 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; in azx_first_init()
1993 chip->capture_streams = ATIHDMI_NUM_CAPTURE; in azx_first_init()
1997 chip->playback_streams = ICH6_NUM_PLAYBACK; in azx_first_init()
1998 chip->capture_streams = ICH6_NUM_CAPTURE; in azx_first_init()
2002 chip->capture_index_offset = 0; in azx_first_init()
2003 chip->playback_index_offset = chip->capture_streams; in azx_first_init()
2004 chip->num_streams = chip->playback_streams + chip->capture_streams; in azx_first_init()
2007 if (chip->num_streams > 15 && in azx_first_init()
2008 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) { in azx_first_init()
2009 dev_warn(chip->card->dev, "number of I/O streams is %d, " in azx_first_init()
2010 "forcing separate stream tags", chip->num_streams); in azx_first_init()
2011 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG; in azx_first_init()
2031 if (!azx_bus(chip)->codec_mask) { in azx_first_init()
2032 dev_err(card->dev, "no codecs found!\n"); in azx_first_init()
2037 return -EBUSY; in azx_first_init()
2039 strcpy(card->driver, "HDA-Intel"); in azx_first_init()
2040 strlcpy(card->shortname, driver_short_names[chip->driver_type], in azx_first_init()
2041 sizeof(card->shortname)); in azx_first_init()
2042 snprintf(card->longname, sizeof(card->longname), in azx_first_init()
2044 card->shortname, bus->addr, bus->irq); in azx_first_init()
2054 struct azx *chip = card->private_data; in azx_firmware_cb()
2057 chip->fw = fw; in azx_firmware_cb()
2059 dev_err(card->dev, "Cannot load firmware, continue without patching\n"); in azx_firmware_cb()
2060 if (!chip->disabled) { in azx_firmware_cb()
2072 free_irq(bus->irq, chip); in disable_msi_reset_irq()
2073 bus->irq = -1; in disable_msi_reset_irq()
2074 chip->card->sync_irq = -1; in disable_msi_reset_irq()
2075 pci_disable_msi(chip->pci); in disable_msi_reset_irq()
2076 chip->msi = 0; in disable_msi_reset_irq()
2089 struct azx *chip = apcm->chip; in pcm_mmap_prepare()
2090 if (chip->uc_buffer) in pcm_mmap_prepare()
2091 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); in pcm_mmap_prepare()
2096 * some HD-audio PCI entries are exposed without any codecs, and such devices
2123 dev_info(&pci->dev, "Skipping the device on the denylist\n"); in azx_probe()
2124 return -ENODEV; in azx_probe()
2128 return -ENODEV; in azx_probe()
2131 return -ENOENT; in azx_probe()
2140 dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n"); in azx_probe()
2141 return -ENODEV; in azx_probe()
2144 …dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option i… in azx_probe()
2147 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in azx_probe()
2150 dev_err(&pci->dev, "Error creating card!\n"); in azx_probe()
2154 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); in azx_probe()
2157 card->private_data = chip; in azx_probe()
2164 dev_err(card->dev, "Error registering vga_switcheroo client\n"); in azx_probe()
2169 dev_info(card->dev, "VGA controller is disabled\n"); in azx_probe()
2170 dev_info(card->dev, "Delaying initialization\n"); in azx_probe()
2171 chip->disabled = true; in azx_probe()
2174 schedule_probe = !chip->disabled; in azx_probe()
2178 dev_info(card->dev, "Applying patch firmware '%s'\n", in azx_probe()
2181 &pci->dev, GFP_KERNEL, card, in azx_probe()
2191 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n"); in azx_probe()
2195 schedule_work(&hda->probe_work); in azx_probe()
2198 if (chip->disabled) in azx_probe()
2199 complete_all(&hda->probe_wait); in azx_probe()
2216 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2218 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2220 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2222 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2230 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2231 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2233 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2260 q = snd_pci_quirk_lookup(chip->pci, power_save_denylist); in set_default_power_save()
2262 …dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0… in set_default_power_save()
2263 q->subvendor, q->subdevice); in set_default_power_save()
2268 snd_hda_set_power_save(&chip->bus, val * 1000); in set_default_power_save()
2281 struct pci_dev *pci = chip->pci; in azx_probe_continue()
2282 int dev = chip->dev_index; in azx_probe_continue()
2285 to_hda_bus(bus)->bus_probing = 1; in azx_probe_continue()
2286 hda->probe_continued = 1; in azx_probe_continue()
2289 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) { in azx_probe_continue()
2298 dev_err(chip->card->dev, in azx_probe_continue()
2299 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n"); in azx_probe_continue()
2303 chip->driver_caps &= ~AZX_DCAPS_I915_COMPONENT; in azx_probe_continue()
2309 hda->need_i915_power = 1; in azx_probe_continue()
2324 chip->beep_mode = beep_mode[dev]; in azx_probe_continue()
2328 if (bus->codec_mask) { in azx_probe_continue()
2329 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); in azx_probe_continue()
2335 if (chip->fw) { in azx_probe_continue()
2336 err = snd_hda_load_patch(&chip->bus, chip->fw->size, in azx_probe_continue()
2337 chip->fw->data); in azx_probe_continue()
2341 release_firmware(chip->fw); /* no longer needed */ in azx_probe_continue()
2342 chip->fw = NULL; in azx_probe_continue()
2346 if (bus->codec_mask && !(probe_only[dev] & 1)) { in azx_probe_continue()
2352 err = snd_card_register(chip->card); in azx_probe_continue()
2358 chip->running = 1; in azx_probe_continue()
2364 pm_runtime_use_autosuspend(&pci->dev); in azx_probe_continue()
2365 pm_runtime_allow(&pci->dev); in azx_probe_continue()
2366 pm_runtime_put_autosuspend(&pci->dev); in azx_probe_continue()
2375 if (!hda->need_i915_power) in azx_probe_continue()
2377 complete_all(&hda->probe_wait); in azx_probe_continue()
2378 to_hda_bus(bus)->bus_probing = 0; in azx_probe_continue()
2390 chip = card->private_data; in azx_remove()
2403 device_unlock(&pci->dev); in azx_remove()
2404 cancel_work_sync(&hda->probe_work); in azx_remove()
2405 device_lock(&pci->dev); in azx_remove()
2418 chip = card->private_data; in azx_shutdown()
2419 if (chip && chip->running) in azx_shutdown()
2450 /* Lynx Point-LP */
2453 /* Lynx Point-LP */
2456 /* Wildcat Point-LP */
2462 /* Sunrise Point-LP */
2468 /* Kabylake-LP */
2471 /* Kabylake-H */
2480 /* CometLake-LP */
2483 /* CometLake-H */
2486 /* CometLake-S */
2492 /* Icelake-H */
2503 /* Tigerlake-H */
2509 /* Alderlake-S */
2517 /* Broxton-P(Apollolake) */
2520 /* Broxton-T */
2523 /* Gemini-Lake */
2580 /* ATI SB 450/600/700/800/900 */
2601 /* ATI HDMI */
2724 /* Creative X-Fi (CA0110-IBG) */
2731 /* the following entry conflicts with snd-ctxfi driver,
2732 * as ctxfi driver mutates from HD-audio to native mode with
2741 /* this entry seems still valid -- i.e. without emu20kx chip */
2754 /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */