Lines Matching +full:ati +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * hda_intel.c - Implementation of primary alsa driver code base
27 #include <linux/dma-mapping.h>
50 #include <sound/intel-dsp-config.h>
61 /* position fix mode */
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).");
160 MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode "
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
191 MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
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))
374 #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
382 [AZX_DRIVER_ATI] = "HDA ATI SB",
383 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
384 [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI",
392 [AZX_DRIVER_CMEDIA] = "HDA C-Media",
394 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
419 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) in azx_init_pci()
425 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) { in azx_init_pci()
426 dev_dbg(chip->card->dev, "Clearing TCSEL\n"); in azx_init_pci()
427 update_pci_byte(chip->pci, AZX_PCIREG_TCSEL, 0x07, 0); in azx_init_pci()
430 /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio, in azx_init_pci()
434 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n", in azx_init_pci()
436 update_pci_byte(chip->pci, in azx_init_pci()
443 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n", in azx_init_pci()
445 update_pci_byte(chip->pci, in azx_init_pci()
448 update_pci_byte(chip->pci, in azx_init_pci()
451 update_pci_byte(chip->pci, in azx_init_pci()
459 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); in azx_init_pci()
465 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop); in azx_init_pci()
466 pci_read_config_word(chip->pci, in azx_init_pci()
469 dev_dbg(chip->card->dev, "SCH snoop: %s\n", in azx_init_pci()
476 * In BXT-P A0, HD-Audio DMA requests is later than expected,
507 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCAP); in intel_get_lctl_scf()
515 dev_warn(chip->card->dev, "set audio clock frequency to 6MHz"); in intel_get_lctl_scf()
529 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
532 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
536 if (((readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL)) & in intel_ml_lctl_set_power()
539 timeout--; in intel_ml_lctl_set_power()
543 return -1; in intel_ml_lctl_set_power()
553 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
575 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
586 struct pci_dev *pci = chip->pci; in hda_intel_init_chip()
590 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
596 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
608 if (bus->mlcap != NULL) in hda_intel_init_chip()
616 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_lpib()
617 int stream = substream->stream; in azx_get_delay_from_lpib()
622 delay = pos - lpib_pos; in azx_get_delay_from_lpib()
624 delay = lpib_pos - pos; in azx_get_delay_from_lpib()
626 if (delay >= azx_dev->core.delay_negative_threshold) in azx_get_delay_from_lpib()
629 delay += azx_dev->core.bufsize; in azx_get_delay_from_lpib()
632 if (delay >= azx_dev->core.period_bytes) { in azx_get_delay_from_lpib()
633 dev_info(chip->card->dev, in azx_get_delay_from_lpib()
635 delay, azx_dev->core.period_bytes); in azx_get_delay_from_lpib()
637 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; in azx_get_delay_from_lpib()
638 chip->get_delay[stream] = NULL; in azx_get_delay_from_lpib()
641 return bytes_to_frames(substream->runtime, delay); in azx_get_delay_from_lpib()
654 azx_dev->irq_pending = 0; in azx_position_check()
658 azx_dev->irq_pending = 1; in azx_position_check()
659 schedule_work(&hda->irq_pending_work); in azx_position_check()
669 * periods. Returns non-zero if it's OK.
671 * Many HD-audio controllers appear pretty inaccurate about
672 * the update-IRQ timing. The IRQ is issued before actually the
678 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_position_ok()
679 int stream = substream->stream; in azx_position_ok()
683 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk; in azx_position_ok()
684 if (wallclk < (azx_dev->core.period_wallclk * 2) / 3) in azx_position_ok()
685 return -1; /* bogus (too early) interrupt */ in azx_position_ok()
687 if (chip->get_position[stream]) in azx_position_ok()
688 pos = chip->get_position[stream](chip, azx_dev); in azx_position_ok()
691 if (!pos || pos == (u32)-1) { in azx_position_ok()
692 dev_info(chip->card->dev, in azx_position_ok()
694 chip->get_position[stream] = azx_get_pos_lpib; in azx_position_ok()
695 if (chip->get_position[0] == azx_get_pos_lpib && in azx_position_ok()
696 chip->get_position[1] == azx_get_pos_lpib) in azx_position_ok()
697 azx_bus(chip)->use_posbuf = false; in azx_position_ok()
699 chip->get_delay[stream] = NULL; in azx_position_ok()
701 chip->get_position[stream] = azx_get_pos_posbuf; in azx_position_ok()
702 if (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY) in azx_position_ok()
703 chip->get_delay[stream] = azx_get_delay_from_lpib; in azx_position_ok()
707 if (pos >= azx_dev->core.bufsize) in azx_position_ok()
710 if (WARN_ONCE(!azx_dev->core.period_bytes, in azx_position_ok()
711 "hda-intel: zero azx_dev->period_bytes")) in azx_position_ok()
712 return -1; /* this shouldn't happen! */ in azx_position_ok()
713 if (wallclk < (azx_dev->core.period_wallclk * 5) / 4 && in azx_position_ok()
714 pos % azx_dev->core.period_bytes > azx_dev->core.period_bytes / 2) in azx_position_ok()
715 /* NG - it's below the first next period boundary */ in azx_position_ok()
716 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
717 azx_dev->core.start_wallclk += wallclk; in azx_position_ok()
727 struct azx *chip = &hda->chip; in azx_irq_pending_work()
732 if (!hda->irq_pending_warned) { in azx_irq_pending_work()
733 dev_info(chip->card->dev, in azx_irq_pending_work()
735 chip->card->number); in azx_irq_pending_work()
736 hda->irq_pending_warned = 1; in azx_irq_pending_work()
741 spin_lock_irq(&bus->reg_lock); in azx_irq_pending_work()
742 list_for_each_entry(s, &bus->stream_list, list) { in azx_irq_pending_work()
744 if (!azx_dev->irq_pending || in azx_irq_pending_work()
745 !s->substream || in azx_irq_pending_work()
746 !s->running) in azx_irq_pending_work()
750 azx_dev->irq_pending = 0; in azx_irq_pending_work()
751 spin_unlock(&bus->reg_lock); in azx_irq_pending_work()
752 snd_pcm_period_elapsed(s->substream); in azx_irq_pending_work()
753 spin_lock(&bus->reg_lock); in azx_irq_pending_work()
759 spin_unlock_irq(&bus->reg_lock); in azx_irq_pending_work()
766 /* clear irq_pending flags and assure no on-going workq */
772 spin_lock_irq(&bus->reg_lock); in azx_clear_irq_pending()
773 list_for_each_entry(s, &bus->stream_list, list) { in azx_clear_irq_pending()
775 azx_dev->irq_pending = 0; in azx_clear_irq_pending()
777 spin_unlock_irq(&bus->reg_lock); in azx_clear_irq_pending()
784 if (request_irq(chip->pci->irq, azx_interrupt, in azx_acquire_irq()
785 chip->msi ? 0 : IRQF_SHARED, in azx_acquire_irq()
786 chip->card->irq_descr, chip)) { in azx_acquire_irq()
787 dev_err(chip->card->dev, in azx_acquire_irq()
789 chip->pci->irq); in azx_acquire_irq()
791 snd_card_disconnect(chip->card); in azx_acquire_irq()
792 return -1; in azx_acquire_irq()
794 bus->irq = chip->pci->irq; in azx_acquire_irq()
795 chip->card->sync_irq = bus->irq; in azx_acquire_irq()
796 pci_intx(chip->pci, !chip->msi); in azx_acquire_irq()
809 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in azx_via_get_position()
818 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); in azx_via_get_position()
819 mod_dma_pos %= azx_dev->core.period_bytes; in azx_via_get_position()
821 fifo_size = azx_stream(azx_dev)->fifo_size - 1; in azx_via_get_position()
823 if (azx_dev->insufficient) { in azx_via_get_position()
828 azx_dev->insufficient = 0; in azx_via_get_position()
832 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; in azx_via_get_position()
834 mini_pos = link_pos - fifo_size; in azx_via_get_position()
837 mod_mini_pos = mini_pos % azx_dev->core.period_bytes; in azx_via_get_position()
838 mod_link_pos = link_pos % azx_dev->core.period_bytes; in azx_via_get_position()
840 bound_pos = link_pos - mod_link_pos; in azx_via_get_position()
842 bound_pos = mini_pos - mod_mini_pos; in azx_via_get_position()
844 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; in azx_via_get_position()
845 if (bound_pos >= azx_dev->core.bufsize) in azx_via_get_position()
858 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_pos_fifo()
859 struct snd_pcm_runtime *runtime = substream->runtime; in azx_get_pos_fifo()
866 runtime->delay = AMD_FIFO_SIZE; in azx_get_pos_fifo()
868 if (azx_dev->insufficient) { in azx_get_pos_fifo()
871 runtime->delay = bytes_to_frames(runtime, pos); in azx_get_pos_fifo()
873 azx_dev->insufficient = 0; in azx_get_pos_fifo()
878 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in azx_get_pos_fifo()
880 pos += azx_dev->core.bufsize; in azx_get_pos_fifo()
881 pos -= delay; in azx_get_pos_fifo()
890 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_fifo()
893 return substream->runtime->delay; in azx_get_delay_from_fifo()
902 azx_dev->core.index)); in azx_skl_get_dpib_pos()
909 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in azx_get_pos_skl()
929 list_add(&hda->list, &card_list); in azx_add_card_list()
937 list_del_init(&hda->list); in azx_del_card_list()
941 /* trigger power-save check at writing parameter */
954 chip = &hda->chip; in param_set_xint()
955 if (!hda->probe_continued || chip->disabled) in param_set_xint()
957 snd_hda_set_power_save(&chip->bus, power_save * 1000); in param_set_xint()
973 chip = card->private_data; in azx_is_pm_ready()
975 if (chip->disabled || hda->init_failed || !chip->running) in azx_is_pm_ready()
996 if (hda->need_i915_power) in __azx_runtime_resume()
1006 if (!chip->pm_prepared) { in __azx_runtime_resume()
1007 list_for_each_codec(codec, &chip->bus) { in __azx_runtime_resume()
1008 if (codec->relaxed_resume) in __azx_runtime_resume()
1011 if (codec->forced_resume || (status & (1 << codec->addr))) in __azx_runtime_resume()
1016 /* power down again for link-controlled chips */ in __azx_runtime_resume()
1017 if (!hda->need_i915_power) in __azx_runtime_resume()
1030 chip = card->private_data; in azx_prepare()
1031 chip->pm_prepared = 1; in azx_prepare()
1034 flush_work(&azx_bus(chip)->unsol_work); in azx_prepare()
1037 * and system suspend, so don't use direct-complete here. in azx_prepare()
1050 chip = card->private_data; in azx_complete()
1052 chip->pm_prepared = 0; in azx_complete()
1064 chip = card->private_data; in azx_suspend()
1067 if (bus->irq >= 0) { in azx_suspend()
1068 free_irq(bus->irq, chip); in azx_suspend()
1069 bus->irq = -1; in azx_suspend()
1070 chip->card->sync_irq = -1; in azx_suspend()
1073 if (chip->msi) in azx_suspend()
1074 pci_disable_msi(chip->pci); in azx_suspend()
1088 chip = card->private_data; in azx_resume()
1089 if (chip->msi) in azx_resume()
1090 if (pci_enable_msi(chip->pci) < 0) in azx_resume()
1091 chip->msi = 0; in azx_resume()
1093 return -EIO; in azx_resume()
1107 struct azx *chip = card->private_data; in azx_freeze_noirq()
1112 if (chip->driver_type == AZX_DRIVER_SKL) in azx_freeze_noirq()
1121 struct azx *chip = card->private_data; in azx_thaw_noirq()
1126 if (chip->driver_type == AZX_DRIVER_SKL) in azx_thaw_noirq()
1140 chip = card->private_data; in azx_runtime_suspend()
1157 chip = card->private_data; in azx_runtime_resume()
1176 chip = card->private_data; in azx_runtime_idle()
1178 if (chip->disabled || hda->init_failed) in azx_runtime_idle()
1182 azx_bus(chip)->codec_powered || !chip->running) in azx_runtime_idle()
1183 return -EBUSY; in azx_runtime_idle()
1185 /* ELD notification gets broken when HD-audio bus is off */ in azx_runtime_idle()
1187 return -EBUSY; in azx_runtime_idle()
1220 struct azx *chip = card->private_data; in azx_vs_set_state()
1225 wait_for_completion(&hda->probe_wait); in azx_vs_set_state()
1226 if (hda->init_failed) in azx_vs_set_state()
1230 if (chip->disabled == disabled) in azx_vs_set_state()
1233 if (!hda->probe_continued) { in azx_vs_set_state()
1234 chip->disabled = disabled; in azx_vs_set_state()
1236 dev_info(chip->card->dev, in azx_vs_set_state()
1239 dev_err(chip->card->dev, "initialization error\n"); in azx_vs_set_state()
1242 dev_info(chip->card->dev, "%s via vga_switcheroo\n", in azx_vs_set_state()
1245 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1249 pm_runtime_suspend(card->dev); in azx_vs_set_state()
1250 pm_runtime_disable(card->dev); in azx_vs_set_state()
1254 pci->current_state = PCI_D3cold; in azx_vs_set_state()
1255 chip->disabled = true; in azx_vs_set_state()
1256 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_set_state()
1257 dev_warn(chip->card->dev, in azx_vs_set_state()
1260 snd_hda_unlock_devices(&chip->bus); in azx_vs_set_state()
1261 chip->disabled = false; in azx_vs_set_state()
1262 pm_runtime_enable(card->dev); in azx_vs_set_state()
1263 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1274 struct azx *chip = card->private_data; in azx_vs_can_switch()
1277 wait_for_completion(&hda->probe_wait); in azx_vs_can_switch()
1278 if (hda->init_failed) in azx_vs_can_switch()
1280 if (chip->disabled || !hda->probe_continued) in azx_vs_can_switch()
1282 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_can_switch()
1284 snd_hda_unlock_devices(&chip->bus); in azx_vs_can_switch()
1297 if (hda->use_vga_switcheroo && !needs_eld_notify_link(chip)) { in setup_vga_switcheroo_runtime_pm()
1298 list_for_each_codec(codec, &chip->bus) in setup_vga_switcheroo_runtime_pm()
1299 codec->auto_runtime_pm = 1; in setup_vga_switcheroo_runtime_pm()
1301 if (chip->running) in setup_vga_switcheroo_runtime_pm()
1310 struct azx *chip = card->private_data; in azx_vs_gpu_bound()
1313 chip->bus.keep_power = 0; in azx_vs_gpu_bound()
1320 struct pci_dev *p = get_bound_vga(chip->pci); in init_vga_switcheroo()
1323 dev_info(chip->card->dev, in init_vga_switcheroo()
1325 hda->use_vga_switcheroo = 1; in init_vga_switcheroo()
1331 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1; in init_vga_switcheroo()
1332 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME; in init_vga_switcheroo()
1349 if (!hda->use_vga_switcheroo) in register_vga_switcheroo()
1352 p = get_bound_vga(chip->pci); in register_vga_switcheroo()
1353 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p); in register_vga_switcheroo()
1358 hda->vga_switcheroo_registered = 1; in register_vga_switcheroo()
1374 struct pci_dev *pci = chip->pci; in azx_free()
1378 if (hda->freed) in azx_free()
1381 if (azx_has_pm_runtime(chip) && chip->running) in azx_free()
1382 pm_runtime_get_noresume(&pci->dev); in azx_free()
1383 chip->running = 0; in azx_free()
1387 hda->init_failed = 1; /* to be sure */ in azx_free()
1388 complete_all(&hda->probe_wait); in azx_free()
1391 if (chip->disabled && hda->probe_continued) in azx_free()
1392 snd_hda_unlock_devices(&chip->bus); in azx_free()
1393 if (hda->vga_switcheroo_registered) in azx_free()
1394 vga_switcheroo_unregister_client(chip->pci); in azx_free()
1397 if (bus->chip_init) { in azx_free()
1403 if (bus->irq >= 0) in azx_free()
1404 free_irq(bus->irq, (void*)chip); in azx_free()
1405 if (chip->msi) in azx_free()
1406 pci_disable_msi(chip->pci); in azx_free()
1407 iounmap(bus->remap_addr); in azx_free()
1413 if (chip->region_requested) in azx_free()
1414 pci_release_regions(chip->pci); in azx_free()
1416 pci_disable_device(chip->pci); in azx_free()
1418 release_firmware(chip->fw); in azx_free()
1422 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) in azx_free()
1425 hda->freed = 1; in azx_free()
1430 struct azx *chip = device->device_data; in azx_dev_disconnect()
1433 chip->bus.shutdown = 1; in azx_dev_disconnect()
1434 cancel_work_sync(&bus->unsol_work); in azx_dev_disconnect()
1441 azx_free(device->device_data); in azx_dev_free()
1455 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1465 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1491 switch (pci->vendor) { in get_bound_vga()
1494 if (pci->devfn == 1) { in get_bound_vga()
1495 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1496 pci->bus->number, 0); in get_bound_vga()
1503 if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) && in get_bound_vga()
1511 if (pci->devfn == 1) { in get_bound_vga()
1512 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1513 pci->bus->number, 0); in get_bound_vga()
1515 if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) in get_bound_vga()
1540 * allow/deny-listing for position_fix
1552 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1555 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1556 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1575 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); in check_position_fix()
1577 dev_info(chip->card->dev, in check_position_fix()
1579 q->value, q->subvendor, q->subdevice); in check_position_fix()
1580 return q->value; in check_position_fix()
1583 /* Check VIA/ATI HD Audio Controller exist */ in check_position_fix()
1584 if (chip->driver_type == AZX_DRIVER_VIA) { in check_position_fix()
1585 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); in check_position_fix()
1588 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) { in check_position_fix()
1589 dev_dbg(chip->card->dev, "Using FIFO position fix\n"); in check_position_fix()
1592 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { in check_position_fix()
1593 dev_dbg(chip->card->dev, "Using LPIB position fix\n"); in check_position_fix()
1596 if (chip->driver_type == AZX_DRIVER_SKL) { in check_position_fix()
1597 dev_dbg(chip->card->dev, "Using SKL position fix\n"); in check_position_fix()
1615 chip->get_position[0] = chip->get_position[1] = callbacks[fix]; in assign_position_fix()
1617 /* combo mode uses LPIB only for playback */ in assign_position_fix()
1619 chip->get_position[1] = NULL; in assign_position_fix()
1622 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { in assign_position_fix()
1623 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1628 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1633 * deny-lists for probe_mask
1637 * to the non-working (or non-existing) modem codec slot.
1660 chip->codec_probe_mask = probe_mask[dev]; in check_probe_mask()
1661 if (chip->codec_probe_mask == -1) { in check_probe_mask()
1662 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); in check_probe_mask()
1664 dev_info(chip->card->dev, in check_probe_mask()
1666 q->value, q->subvendor, q->subdevice); in check_probe_mask()
1667 chip->codec_probe_mask = q->value; in check_probe_mask()
1672 if (chip->codec_probe_mask != -1 && in check_probe_mask()
1673 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { in check_probe_mask()
1674 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff; in check_probe_mask()
1675 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n", in check_probe_mask()
1676 (int)azx_bus(chip)->codec_mask); in check_probe_mask()
1681 * allow/deny-list for enable_msi
1693 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1702 chip->msi = !!enable_msi; in check_msi()
1705 chip->msi = 1; /* enable MSI as default */ in check_msi()
1706 q = snd_pci_quirk_lookup(chip->pci, msi_deny_list); in check_msi()
1708 dev_info(chip->card->dev, in check_msi()
1710 q->subvendor, q->subdevice, q->value); in check_msi()
1711 chip->msi = q->value; in check_msi()
1716 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { in check_msi()
1717 dev_info(chip->card->dev, "Disabling MSI\n"); in check_msi()
1718 chip->msi = 0; in check_msi()
1722 /* check the snoop mode availability */
1728 dev_info(chip->card->dev, "Force to %s mode by module option\n", in azx_check_snoop_available()
1729 snoop ? "snoop" : "non-snoop"); in azx_check_snoop_available()
1730 chip->snoop = snoop; in azx_check_snoop_available()
1731 chip->uc_buffer = !snoop; in azx_check_snoop_available()
1737 chip->driver_type == AZX_DRIVER_VIA) { in azx_check_snoop_available()
1738 /* force to non-snoop mode for a new VIA controller in azx_check_snoop_available()
1742 pci_read_config_byte(chip->pci, 0x42, &val); in azx_check_snoop_available()
1743 if (!(val & 0x80) && (chip->pci->revision == 0x30 || in azx_check_snoop_available()
1744 chip->pci->revision == 0x20)) in azx_check_snoop_available()
1748 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) in azx_check_snoop_available()
1751 chip->snoop = snoop; in azx_check_snoop_available()
1753 dev_info(chip->card->dev, "Force to non-snoop mode\n"); in azx_check_snoop_available()
1754 /* C-Media requires non-cached pages only for CORB/RIRB */ in azx_check_snoop_available()
1755 if (chip->driver_type != AZX_DRIVER_CMEDIA) in azx_check_snoop_available()
1756 chip->uc_buffer = true; in azx_check_snoop_available()
1763 azx_probe_continue(&hda->chip); in azx_probe_work()
1769 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) { in default_bdl_pos_adj()
1770 switch (chip->pci->device) { in default_bdl_pos_adj()
1777 switch (chip->driver_type) { in default_bdl_pos_adj()
1809 hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL); in azx_create()
1812 return -ENOMEM; in azx_create()
1815 chip = &hda->chip; in azx_create()
1816 mutex_init(&chip->open_mutex); in azx_create()
1817 chip->card = card; in azx_create()
1818 chip->pci = pci; in azx_create()
1819 chip->ops = &pci_hda_ops; in azx_create()
1820 chip->driver_caps = driver_caps; in azx_create()
1821 chip->driver_type = driver_caps & 0xff; in azx_create()
1823 chip->dev_index = dev; in azx_create()
1825 chip->jackpoll_interval = msecs_to_jiffies(jackpoll_ms[dev]); in azx_create()
1826 INIT_LIST_HEAD(&chip->pcm_list); in azx_create()
1827 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); in azx_create()
1828 INIT_LIST_HEAD(&hda->list); in azx_create()
1830 init_completion(&hda->probe_wait); in azx_create()
1837 chip->fallback_to_single_cmd = 1; in azx_create()
1839 chip->single_cmd = single_cmd; in azx_create()
1844 chip->bdl_pos_adj = default_bdl_pos_adj(chip); in azx_create()
1846 chip->bdl_pos_adj = bdl_pos_adj[dev]; in azx_create()
1854 /* use the non-cached pages in non-snoop mode */ in azx_create()
1856 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_UC; in azx_create()
1858 if (chip->driver_type == AZX_DRIVER_NVIDIA) { in azx_create()
1859 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); in azx_create()
1860 chip->bus.core.needs_damn_long_delay = 1; in azx_create()
1865 dev_err(card->dev, "Error creating device [card]!\n"); in azx_create()
1871 INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work); in azx_create()
1880 int dev = chip->dev_index; in azx_first_init()
1881 struct pci_dev *pci = chip->pci; in azx_first_init()
1882 struct snd_card *card = chip->card; in azx_first_init()
1890 if (chip->driver_type == AZX_DRIVER_ULI) { in azx_first_init()
1901 chip->region_requested = 1; in azx_first_init()
1903 bus->addr = pci_resource_start(pci, 0); in azx_first_init()
1904 bus->remap_addr = pci_ioremap_bar(pci, 0); in azx_first_init()
1905 if (bus->remap_addr == NULL) { in azx_first_init()
1906 dev_err(card->dev, "ioremap error\n"); in azx_first_init()
1907 return -ENXIO; in azx_first_init()
1910 if (chip->driver_type == AZX_DRIVER_SKL) in azx_first_init()
1919 chip->gts_present = false; in azx_first_init()
1922 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART)) in azx_first_init()
1923 chip->gts_present = true; in azx_first_init()
1926 if (chip->msi) { in azx_first_init()
1927 if (chip->driver_caps & AZX_DCAPS_NO_MSI64) { in azx_first_init()
1928 dev_dbg(card->dev, "Disabling 64bit MSI\n"); in azx_first_init()
1929 pci->no_64bit_msi = true; in azx_first_init()
1932 chip->msi = 0; in azx_first_init()
1938 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); in azx_first_init()
1941 if (chip->pci->vendor == PCI_VENDOR_ID_AMD) in azx_first_init()
1945 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { in azx_first_init()
1952 if (p_smbus->revision < 0x30) in azx_first_init()
1959 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA) in azx_first_init()
1963 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { in azx_first_init()
1964 dev_dbg(card->dev, "Disabling 64bit DMA\n"); in azx_first_init()
1968 /* disable buffer size rounding to 128-byte multiples if supported */ in azx_first_init()
1970 chip->align_buffer_size = !!align_buffer_size; in azx_first_init()
1972 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE) in azx_first_init()
1973 chip->align_buffer_size = 0; in azx_first_init()
1975 chip->align_buffer_size = 1; in azx_first_init()
1981 if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) { in azx_first_init()
1982 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits)); in azx_first_init()
1984 dma_set_mask(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1985 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1991 chip->capture_streams = (gcap >> 8) & 0x0f; in azx_first_init()
1992 chip->playback_streams = (gcap >> 12) & 0x0f; in azx_first_init()
1993 if (!chip->playback_streams && !chip->capture_streams) { in azx_first_init()
1996 switch (chip->driver_type) { in azx_first_init()
1998 chip->playback_streams = ULI_NUM_PLAYBACK; in azx_first_init()
1999 chip->capture_streams = ULI_NUM_CAPTURE; in azx_first_init()
2003 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; in azx_first_init()
2004 chip->capture_streams = ATIHDMI_NUM_CAPTURE; in azx_first_init()
2008 chip->playback_streams = ICH6_NUM_PLAYBACK; in azx_first_init()
2009 chip->capture_streams = ICH6_NUM_CAPTURE; in azx_first_init()
2013 chip->capture_index_offset = 0; in azx_first_init()
2014 chip->playback_index_offset = chip->capture_streams; in azx_first_init()
2015 chip->num_streams = chip->playback_streams + chip->capture_streams; in azx_first_init()
2018 if (chip->num_streams > 15 && in azx_first_init()
2019 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) { in azx_first_init()
2020 dev_warn(chip->card->dev, "number of I/O streams is %d, " in azx_first_init()
2021 "forcing separate stream tags", chip->num_streams); in azx_first_init()
2022 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG; in azx_first_init()
2042 if (!azx_bus(chip)->codec_mask) { in azx_first_init()
2043 dev_err(card->dev, "no codecs found!\n"); in azx_first_init()
2048 return -EBUSY; in azx_first_init()
2050 strcpy(card->driver, "HDA-Intel"); in azx_first_init()
2051 strlcpy(card->shortname, driver_short_names[chip->driver_type], in azx_first_init()
2052 sizeof(card->shortname)); in azx_first_init()
2053 snprintf(card->longname, sizeof(card->longname), in azx_first_init()
2055 card->shortname, bus->addr, bus->irq); in azx_first_init()
2065 struct azx *chip = card->private_data; in azx_firmware_cb()
2068 chip->fw = fw; in azx_firmware_cb()
2070 dev_err(card->dev, "Cannot load firmware, continue without patching\n"); in azx_firmware_cb()
2071 if (!chip->disabled) { in azx_firmware_cb()
2083 free_irq(bus->irq, chip); in disable_msi_reset_irq()
2084 bus->irq = -1; in disable_msi_reset_irq()
2085 chip->card->sync_irq = -1; in disable_msi_reset_irq()
2086 pci_disable_msi(chip->pci); in disable_msi_reset_irq()
2087 chip->msi = 0; in disable_msi_reset_irq()
2100 struct azx *chip = apcm->chip; in pcm_mmap_prepare()
2101 if (chip->uc_buffer) in pcm_mmap_prepare()
2102 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); in pcm_mmap_prepare()
2107 * some HD-audio PCI entries are exposed without any codecs, and such devices
2134 dev_info(&pci->dev, "Skipping the device on the denylist\n"); in azx_probe()
2135 return -ENODEV; in azx_probe()
2139 return -ENODEV; in azx_probe()
2142 return -ENOENT; in azx_probe()
2151 dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n"); in azx_probe()
2152 return -ENODEV; in azx_probe()
2155 …dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option i… in azx_probe()
2158 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in azx_probe()
2161 dev_err(&pci->dev, "Error creating card!\n"); in azx_probe()
2165 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); in azx_probe()
2168 card->private_data = chip; in azx_probe()
2175 dev_err(card->dev, "Error registering vga_switcheroo client\n"); in azx_probe()
2180 dev_info(card->dev, "VGA controller is disabled\n"); in azx_probe()
2181 dev_info(card->dev, "Delaying initialization\n"); in azx_probe()
2182 chip->disabled = true; in azx_probe()
2185 schedule_probe = !chip->disabled; in azx_probe()
2189 dev_info(card->dev, "Applying patch firmware '%s'\n", in azx_probe()
2192 &pci->dev, GFP_KERNEL, card, in azx_probe()
2202 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n"); in azx_probe()
2206 schedule_delayed_work(&hda->probe_work, 0); in azx_probe()
2209 if (chip->disabled) in azx_probe()
2210 complete_all(&hda->probe_wait); in azx_probe()
2220 * popping sounds when ever we enter/leave powersaving mode. Ideally we would
2227 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2229 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2231 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2233 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2239 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2240 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2242 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2269 q = snd_pci_quirk_lookup(chip->pci, power_save_denylist); in set_default_power_save()
2271 …dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0… in set_default_power_save()
2272 q->subvendor, q->subdevice); in set_default_power_save()
2277 snd_hda_set_power_save(&chip->bus, val * 1000); in set_default_power_save()
2290 struct pci_dev *pci = chip->pci; in azx_probe_continue()
2291 int dev = chip->dev_index; in azx_probe_continue()
2294 if (chip->disabled || hda->init_failed) in azx_probe_continue()
2295 return -EIO; in azx_probe_continue()
2296 if (hda->probe_retry) in azx_probe_continue()
2299 to_hda_bus(bus)->bus_probing = 1; in azx_probe_continue()
2300 hda->probe_continued = 1; in azx_probe_continue()
2303 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) { in azx_probe_continue()
2312 dev_err(chip->card->dev, in azx_probe_continue()
2313 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n"); in azx_probe_continue()
2317 chip->driver_caps &= ~AZX_DCAPS_I915_COMPONENT; in azx_probe_continue()
2323 hda->need_i915_power = 1; in azx_probe_continue()
2338 chip->beep_mode = beep_mode[dev]; in azx_probe_continue()
2342 if (bus->codec_mask) { in azx_probe_continue()
2343 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); in azx_probe_continue()
2349 if (chip->fw) { in azx_probe_continue()
2350 err = snd_hda_load_patch(&chip->bus, chip->fw->size, in azx_probe_continue()
2351 chip->fw->data); in azx_probe_continue()
2355 release_firmware(chip->fw); /* no longer needed */ in azx_probe_continue()
2356 chip->fw = NULL; in azx_probe_continue()
2362 if (bus->codec_mask && !(probe_only[dev] & 1)) { in azx_probe_continue()
2365 if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) && in azx_probe_continue()
2366 ++hda->probe_retry < 60) { in azx_probe_continue()
2367 schedule_delayed_work(&hda->probe_work, in azx_probe_continue()
2371 dev_err(chip->card->dev, "Cannot probe codecs, giving up\n"); in azx_probe_continue()
2376 err = snd_card_register(chip->card); in azx_probe_continue()
2382 chip->running = 1; in azx_probe_continue()
2388 pm_runtime_use_autosuspend(&pci->dev); in azx_probe_continue()
2389 pm_runtime_allow(&pci->dev); in azx_probe_continue()
2390 pm_runtime_put_autosuspend(&pci->dev); in azx_probe_continue()
2399 if (!hda->need_i915_power) in azx_probe_continue()
2401 complete_all(&hda->probe_wait); in azx_probe_continue()
2402 to_hda_bus(bus)->bus_probing = 0; in azx_probe_continue()
2403 hda->probe_retry = 0; in azx_probe_continue()
2415 chip = card->private_data; in azx_remove()
2428 device_unlock(&pci->dev); in azx_remove()
2429 cancel_delayed_work_sync(&hda->probe_work); in azx_remove()
2430 device_lock(&pci->dev); in azx_remove()
2443 chip = card->private_data; in azx_shutdown()
2444 if (chip && chip->running) in azx_shutdown()
2475 /* Lynx Point-LP */
2478 /* Lynx Point-LP */
2481 /* Wildcat Point-LP */
2487 /* Sunrise Point-LP */
2493 /* Kabylake-LP */
2496 /* Kabylake-H */
2505 /* CometLake-LP */
2508 /* CometLake-H */
2513 /* CometLake-S */
2516 /* CometLake-R */
2522 /* Icelake-H */
2533 /* Tigerlake-H */
2539 /* Alderlake-S */
2542 /* Alderlake-P */
2550 /* Broxton-P(Apollolake) */
2553 /* Broxton-T */
2556 /* Gemini-Lake */
2613 /* ATI SB 450/600/700/800/900 */
2634 /* ATI HDMI */
2757 /* Creative X-Fi (CA0110-IBG) */
2764 /* the following entry conflicts with snd-ctxfi driver,
2765 * as ctxfi driver mutates from HD-audio to native mode with
2774 /* this entry seems still valid -- i.e. without emu20kx chip */
2787 /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */