Lines Matching +full:south +full:- +full:field
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 */
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;
247 (((chip)->driver_caps & AZX_DCAPS_SNOOP_MASK) >> 10)
327 #define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo)
328 #define needs_eld_notify_link(chip) ((chip)->bus.keep_power)
334 #define CONTROLLER_IN_GPU(pci) (((pci)->device == 0x0a0c) || \
335 ((pci)->device == 0x0c0c) || \
336 ((pci)->device == 0x0d0c) || \
337 ((pci)->device == 0x160c) || \
338 ((pci)->device == 0x490d))
340 #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
358 [AZX_DRIVER_CMEDIA] = "HDA C-Media",
360 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
385 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) in azx_init_pci()
391 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) { in azx_init_pci()
392 dev_dbg(chip->card->dev, "Clearing TCSEL\n"); in azx_init_pci()
393 update_pci_byte(chip->pci, AZX_PCIREG_TCSEL, 0x07, 0); in azx_init_pci()
400 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n", in azx_init_pci()
402 update_pci_byte(chip->pci, in azx_init_pci()
409 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n", in azx_init_pci()
411 update_pci_byte(chip->pci, in azx_init_pci()
414 update_pci_byte(chip->pci, in azx_init_pci()
417 update_pci_byte(chip->pci, in azx_init_pci()
425 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); in azx_init_pci()
431 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop); in azx_init_pci()
432 pci_read_config_word(chip->pci, in azx_init_pci()
435 dev_dbg(chip->card->dev, "SCH snoop: %s\n", in azx_init_pci()
442 * In BXT-P A0, HD-Audio DMA requests is later than expected,
473 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCAP); in intel_get_lctl_scf()
481 dev_warn(chip->card->dev, "set audio clock frequency to 6MHz"); in intel_get_lctl_scf()
495 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
498 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
502 if (((readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL)) & in intel_ml_lctl_set_power()
505 timeout--; in intel_ml_lctl_set_power()
509 return -1; in intel_ml_lctl_set_power()
519 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
541 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
552 struct pci_dev *pci = chip->pci; in hda_intel_init_chip()
556 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
562 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
574 if (bus->mlcap != NULL) in hda_intel_init_chip()
582 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_lpib()
583 int stream = substream->stream; in azx_get_delay_from_lpib()
588 delay = pos - lpib_pos; in azx_get_delay_from_lpib()
590 delay = lpib_pos - pos; in azx_get_delay_from_lpib()
592 if (delay >= azx_dev->core.delay_negative_threshold) in azx_get_delay_from_lpib()
595 delay += azx_dev->core.bufsize; in azx_get_delay_from_lpib()
598 if (delay >= azx_dev->core.period_bytes) { in azx_get_delay_from_lpib()
599 dev_info(chip->card->dev, in azx_get_delay_from_lpib()
601 delay, azx_dev->core.period_bytes); in azx_get_delay_from_lpib()
603 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; in azx_get_delay_from_lpib()
604 chip->get_delay[stream] = NULL; in azx_get_delay_from_lpib()
607 return bytes_to_frames(substream->runtime, delay); in azx_get_delay_from_lpib()
620 azx_dev->irq_pending = 0; in azx_position_check()
624 azx_dev->irq_pending = 1; in azx_position_check()
625 schedule_work(&hda->irq_pending_work); in azx_position_check()
635 * periods. Returns non-zero if it's OK.
637 * Many HD-audio controllers appear pretty inaccurate about
638 * the update-IRQ timing. The IRQ is issued before actually the
644 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_position_ok()
645 int stream = substream->stream; in azx_position_ok()
649 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk; in azx_position_ok()
650 if (wallclk < (azx_dev->core.period_wallclk * 2) / 3) in azx_position_ok()
651 return -1; /* bogus (too early) interrupt */ in azx_position_ok()
653 if (chip->get_position[stream]) in azx_position_ok()
654 pos = chip->get_position[stream](chip, azx_dev); in azx_position_ok()
657 if (!pos || pos == (u32)-1) { in azx_position_ok()
658 dev_info(chip->card->dev, in azx_position_ok()
660 chip->get_position[stream] = azx_get_pos_lpib; in azx_position_ok()
661 if (chip->get_position[0] == azx_get_pos_lpib && in azx_position_ok()
662 chip->get_position[1] == azx_get_pos_lpib) in azx_position_ok()
663 azx_bus(chip)->use_posbuf = false; in azx_position_ok()
665 chip->get_delay[stream] = NULL; in azx_position_ok()
667 chip->get_position[stream] = azx_get_pos_posbuf; in azx_position_ok()
668 if (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY) in azx_position_ok()
669 chip->get_delay[stream] = azx_get_delay_from_lpib; in azx_position_ok()
673 if (pos >= azx_dev->core.bufsize) in azx_position_ok()
676 if (WARN_ONCE(!azx_dev->core.period_bytes, in azx_position_ok()
677 "hda-intel: zero azx_dev->period_bytes")) in azx_position_ok()
678 return -1; /* this shouldn't happen! */ in azx_position_ok()
679 if (wallclk < (azx_dev->core.period_wallclk * 5) / 4 && in azx_position_ok()
680 pos % azx_dev->core.period_bytes > azx_dev->core.period_bytes / 2) in azx_position_ok()
681 /* NG - it's below the first next period boundary */ in azx_position_ok()
682 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
683 azx_dev->core.start_wallclk += wallclk; in azx_position_ok()
693 struct azx *chip = &hda->chip; in azx_irq_pending_work()
698 if (!hda->irq_pending_warned) { in azx_irq_pending_work()
699 dev_info(chip->card->dev, in azx_irq_pending_work()
701 chip->card->number); in azx_irq_pending_work()
702 hda->irq_pending_warned = 1; in azx_irq_pending_work()
707 spin_lock_irq(&bus->reg_lock); in azx_irq_pending_work()
708 list_for_each_entry(s, &bus->stream_list, list) { in azx_irq_pending_work()
710 if (!azx_dev->irq_pending || in azx_irq_pending_work()
711 !s->substream || in azx_irq_pending_work()
712 !s->running) in azx_irq_pending_work()
716 azx_dev->irq_pending = 0; in azx_irq_pending_work()
717 spin_unlock(&bus->reg_lock); in azx_irq_pending_work()
718 snd_pcm_period_elapsed(s->substream); in azx_irq_pending_work()
719 spin_lock(&bus->reg_lock); in azx_irq_pending_work()
725 spin_unlock_irq(&bus->reg_lock); in azx_irq_pending_work()
732 /* clear irq_pending flags and assure no on-going workq */
738 spin_lock_irq(&bus->reg_lock); in azx_clear_irq_pending()
739 list_for_each_entry(s, &bus->stream_list, list) { in azx_clear_irq_pending()
741 azx_dev->irq_pending = 0; in azx_clear_irq_pending()
743 spin_unlock_irq(&bus->reg_lock); in azx_clear_irq_pending()
750 if (request_irq(chip->pci->irq, azx_interrupt, in azx_acquire_irq()
751 chip->msi ? 0 : IRQF_SHARED, in azx_acquire_irq()
752 chip->card->irq_descr, chip)) { in azx_acquire_irq()
753 dev_err(chip->card->dev, in azx_acquire_irq()
755 chip->pci->irq); in azx_acquire_irq()
757 snd_card_disconnect(chip->card); in azx_acquire_irq()
758 return -1; in azx_acquire_irq()
760 bus->irq = chip->pci->irq; in azx_acquire_irq()
761 chip->card->sync_irq = bus->irq; in azx_acquire_irq()
762 pci_intx(chip->pci, !chip->msi); in azx_acquire_irq()
775 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in azx_via_get_position()
784 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); in azx_via_get_position()
785 mod_dma_pos %= azx_dev->core.period_bytes; in azx_via_get_position()
787 fifo_size = azx_stream(azx_dev)->fifo_size - 1; in azx_via_get_position()
789 if (azx_dev->insufficient) { in azx_via_get_position()
794 azx_dev->insufficient = 0; in azx_via_get_position()
798 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; in azx_via_get_position()
800 mini_pos = link_pos - fifo_size; in azx_via_get_position()
803 mod_mini_pos = mini_pos % azx_dev->core.period_bytes; in azx_via_get_position()
804 mod_link_pos = link_pos % azx_dev->core.period_bytes; in azx_via_get_position()
806 bound_pos = link_pos - mod_link_pos; in azx_via_get_position()
808 bound_pos = mini_pos - mod_mini_pos; in azx_via_get_position()
810 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; in azx_via_get_position()
811 if (bound_pos >= azx_dev->core.bufsize) in azx_via_get_position()
824 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_pos_fifo()
825 struct snd_pcm_runtime *runtime = substream->runtime; in azx_get_pos_fifo()
832 runtime->delay = AMD_FIFO_SIZE; in azx_get_pos_fifo()
834 if (azx_dev->insufficient) { in azx_get_pos_fifo()
837 runtime->delay = bytes_to_frames(runtime, pos); in azx_get_pos_fifo()
839 azx_dev->insufficient = 0; in azx_get_pos_fifo()
844 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in azx_get_pos_fifo()
846 pos += azx_dev->core.bufsize; in azx_get_pos_fifo()
847 pos -= delay; in azx_get_pos_fifo()
856 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_fifo()
859 return substream->runtime->delay; in azx_get_delay_from_fifo()
868 azx_dev->core.index)); in azx_skl_get_dpib_pos()
875 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in azx_get_pos_skl()
909 list_add(&hda->list, &card_list); in azx_add_card_list()
917 list_del_init(&hda->list); in azx_del_card_list()
921 /* trigger power-save check at writing parameter */
934 chip = &hda->chip; in param_set_xint()
935 if (!hda->probe_continued || chip->disabled) in param_set_xint()
937 snd_hda_set_power_save(&chip->bus, power_save * 1000); in param_set_xint()
953 chip = card->private_data; in azx_is_pm_ready()
955 if (chip->disabled || hda->init_failed || !chip->running) in azx_is_pm_ready()
968 if (hda->need_i915_power) in __azx_runtime_resume()
978 if (!chip->pm_prepared) { in __azx_runtime_resume()
979 list_for_each_codec(codec, &chip->bus) { in __azx_runtime_resume()
980 if (codec->relaxed_resume) in __azx_runtime_resume()
983 if (codec->forced_resume || (status & (1 << codec->addr))) in __azx_runtime_resume()
988 /* power down again for link-controlled chips */ in __azx_runtime_resume()
989 if (!hda->need_i915_power) in __azx_runtime_resume()
1002 chip = card->private_data; in azx_prepare()
1003 chip->pm_prepared = 1; in azx_prepare()
1006 flush_work(&azx_bus(chip)->unsol_work); in azx_prepare()
1009 * and system suspend, so don't use direct-complete here. in azx_prepare()
1022 chip = card->private_data; in azx_complete()
1024 chip->pm_prepared = 0; in azx_complete()
1036 chip = card->private_data; in azx_suspend()
1039 if (bus->irq >= 0) { in azx_suspend()
1040 free_irq(bus->irq, chip); in azx_suspend()
1041 bus->irq = -1; in azx_suspend()
1042 chip->card->sync_irq = -1; in azx_suspend()
1045 if (chip->msi) in azx_suspend()
1046 pci_disable_msi(chip->pci); in azx_suspend()
1060 chip = card->private_data; in azx_resume()
1061 if (chip->msi) in azx_resume()
1062 if (pci_enable_msi(chip->pci) < 0) in azx_resume()
1063 chip->msi = 0; in azx_resume()
1065 return -EIO; in azx_resume()
1079 struct azx *chip = card->private_data; in azx_freeze_noirq()
1084 if (chip->driver_type == AZX_DRIVER_SKL) in azx_freeze_noirq()
1093 struct azx *chip = card->private_data; in azx_thaw_noirq()
1098 if (chip->driver_type == AZX_DRIVER_SKL) in azx_thaw_noirq()
1112 chip = card->private_data; in azx_runtime_suspend()
1129 chip = card->private_data; in azx_runtime_resume()
1148 chip = card->private_data; in azx_runtime_idle()
1150 if (chip->disabled || hda->init_failed) in azx_runtime_idle()
1154 azx_bus(chip)->codec_powered || !chip->running) in azx_runtime_idle()
1155 return -EBUSY; in azx_runtime_idle()
1157 /* ELD notification gets broken when HD-audio bus is off */ in azx_runtime_idle()
1159 return -EBUSY; in azx_runtime_idle()
1192 struct azx *chip = card->private_data; in azx_vs_set_state()
1197 wait_for_completion(&hda->probe_wait); in azx_vs_set_state()
1198 if (hda->init_failed) in azx_vs_set_state()
1202 if (chip->disabled == disabled) in azx_vs_set_state()
1205 if (!hda->probe_continued) { in azx_vs_set_state()
1206 chip->disabled = disabled; in azx_vs_set_state()
1208 dev_info(chip->card->dev, in azx_vs_set_state()
1211 dev_err(chip->card->dev, "initialization error\n"); in azx_vs_set_state()
1214 dev_info(chip->card->dev, "%s via vga_switcheroo\n", in azx_vs_set_state()
1217 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1221 pm_runtime_suspend(card->dev); in azx_vs_set_state()
1222 pm_runtime_disable(card->dev); in azx_vs_set_state()
1226 pci->current_state = PCI_D3cold; in azx_vs_set_state()
1227 chip->disabled = true; in azx_vs_set_state()
1228 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_set_state()
1229 dev_warn(chip->card->dev, in azx_vs_set_state()
1232 snd_hda_unlock_devices(&chip->bus); in azx_vs_set_state()
1233 chip->disabled = false; in azx_vs_set_state()
1234 pm_runtime_enable(card->dev); in azx_vs_set_state()
1235 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1246 struct azx *chip = card->private_data; in azx_vs_can_switch()
1249 wait_for_completion(&hda->probe_wait); in azx_vs_can_switch()
1250 if (hda->init_failed) in azx_vs_can_switch()
1252 if (chip->disabled || !hda->probe_continued) in azx_vs_can_switch()
1254 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_can_switch()
1256 snd_hda_unlock_devices(&chip->bus); in azx_vs_can_switch()
1269 if (hda->use_vga_switcheroo && !needs_eld_notify_link(chip)) { in setup_vga_switcheroo_runtime_pm()
1270 list_for_each_codec(codec, &chip->bus) in setup_vga_switcheroo_runtime_pm()
1271 codec->auto_runtime_pm = 1; in setup_vga_switcheroo_runtime_pm()
1273 if (chip->running) in setup_vga_switcheroo_runtime_pm()
1282 struct azx *chip = card->private_data; in azx_vs_gpu_bound()
1285 chip->bus.keep_power = 0; in azx_vs_gpu_bound()
1292 struct pci_dev *p = get_bound_vga(chip->pci); in init_vga_switcheroo()
1295 dev_info(chip->card->dev, in init_vga_switcheroo()
1297 hda->use_vga_switcheroo = 1; in init_vga_switcheroo()
1303 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1; in init_vga_switcheroo()
1304 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME; in init_vga_switcheroo()
1321 if (!hda->use_vga_switcheroo) in register_vga_switcheroo()
1324 p = get_bound_vga(chip->pci); in register_vga_switcheroo()
1325 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p); in register_vga_switcheroo()
1330 hda->vga_switcheroo_registered = 1; in register_vga_switcheroo()
1346 struct pci_dev *pci = chip->pci; in azx_free()
1350 if (hda->freed) in azx_free()
1353 if (azx_has_pm_runtime(chip) && chip->running) in azx_free()
1354 pm_runtime_get_noresume(&pci->dev); in azx_free()
1355 chip->running = 0; in azx_free()
1359 hda->init_failed = 1; /* to be sure */ in azx_free()
1360 complete_all(&hda->probe_wait); in azx_free()
1363 if (chip->disabled && hda->probe_continued) in azx_free()
1364 snd_hda_unlock_devices(&chip->bus); in azx_free()
1365 if (hda->vga_switcheroo_registered) in azx_free()
1366 vga_switcheroo_unregister_client(chip->pci); in azx_free()
1369 if (bus->chip_init) { in azx_free()
1375 if (bus->irq >= 0) in azx_free()
1376 free_irq(bus->irq, (void*)chip); in azx_free()
1383 release_firmware(chip->fw); in azx_free()
1387 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) in azx_free()
1390 hda->freed = 1; in azx_free()
1395 struct azx *chip = device->device_data; in azx_dev_disconnect()
1398 chip->bus.shutdown = 1; in azx_dev_disconnect()
1399 cancel_work_sync(&bus->unsol_work); in azx_dev_disconnect()
1406 azx_free(device->device_data); in azx_dev_free()
1420 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1430 dhandle = ACPI_HANDLE(&pdev->dev); in atpx_present()
1456 switch (pci->vendor) { in get_bound_vga()
1459 if (pci->devfn == 1) { in get_bound_vga()
1460 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1461 pci->bus->number, 0); in get_bound_vga()
1468 if (((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) && in get_bound_vga()
1476 if (pci->devfn == 1) { in get_bound_vga()
1477 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1478 pci->bus->number, 0); in get_bound_vga()
1480 if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) in get_bound_vga()
1505 * allow/deny-listing for position_fix
1517 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1520 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1521 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1540 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); in check_position_fix()
1542 dev_info(chip->card->dev, in check_position_fix()
1544 q->value, q->subvendor, q->subdevice); in check_position_fix()
1545 return q->value; in check_position_fix()
1549 if (chip->driver_type == AZX_DRIVER_VIA) { in check_position_fix()
1550 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); in check_position_fix()
1553 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) { in check_position_fix()
1554 dev_dbg(chip->card->dev, "Using FIFO position fix\n"); in check_position_fix()
1557 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { in check_position_fix()
1558 dev_dbg(chip->card->dev, "Using LPIB position fix\n"); in check_position_fix()
1561 if (chip->driver_type == AZX_DRIVER_SKL) { in check_position_fix()
1562 dev_dbg(chip->card->dev, "Using SKL position fix\n"); in check_position_fix()
1580 chip->get_position[0] = chip->get_position[1] = callbacks[fix]; in assign_position_fix()
1584 chip->get_position[1] = NULL; in assign_position_fix()
1587 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { in assign_position_fix()
1588 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1593 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1598 * deny-lists for probe_mask
1602 * to the non-working (or non-existing) modem codec slot.
1625 chip->codec_probe_mask = probe_mask[dev]; in check_probe_mask()
1626 if (chip->codec_probe_mask == -1) { in check_probe_mask()
1627 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); in check_probe_mask()
1629 dev_info(chip->card->dev, in check_probe_mask()
1631 q->value, q->subvendor, q->subdevice); in check_probe_mask()
1632 chip->codec_probe_mask = q->value; in check_probe_mask()
1637 if (chip->codec_probe_mask != -1 && in check_probe_mask()
1638 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { in check_probe_mask()
1639 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff; in check_probe_mask()
1640 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n", in check_probe_mask()
1641 (int)azx_bus(chip)->codec_mask); in check_probe_mask()
1646 * allow/deny-list for enable_msi
1658 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1667 chip->msi = !!enable_msi; in check_msi()
1670 chip->msi = 1; /* enable MSI as default */ in check_msi()
1671 q = snd_pci_quirk_lookup(chip->pci, msi_deny_list); in check_msi()
1673 dev_info(chip->card->dev, in check_msi()
1675 q->subvendor, q->subdevice, q->value); in check_msi()
1676 chip->msi = q->value; in check_msi()
1681 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { in check_msi()
1682 dev_info(chip->card->dev, "Disabling MSI\n"); in check_msi()
1683 chip->msi = 0; in check_msi()
1693 dev_info(chip->card->dev, "Force to %s mode by module option\n", in azx_check_snoop_available()
1694 snoop ? "snoop" : "non-snoop"); in azx_check_snoop_available()
1695 chip->snoop = snoop; in azx_check_snoop_available()
1696 chip->uc_buffer = !snoop; in azx_check_snoop_available()
1702 chip->driver_type == AZX_DRIVER_VIA) { in azx_check_snoop_available()
1703 /* force to non-snoop mode for a new VIA controller in azx_check_snoop_available()
1707 pci_read_config_byte(chip->pci, 0x42, &val); in azx_check_snoop_available()
1708 if (!(val & 0x80) && (chip->pci->revision == 0x30 || in azx_check_snoop_available()
1709 chip->pci->revision == 0x20)) in azx_check_snoop_available()
1713 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) in azx_check_snoop_available()
1716 chip->snoop = snoop; in azx_check_snoop_available()
1718 dev_info(chip->card->dev, "Force to non-snoop mode\n"); in azx_check_snoop_available()
1719 /* C-Media requires non-cached pages only for CORB/RIRB */ in azx_check_snoop_available()
1720 if (chip->driver_type != AZX_DRIVER_CMEDIA) in azx_check_snoop_available()
1721 chip->uc_buffer = true; in azx_check_snoop_available()
1728 azx_probe_continue(&hda->chip); in azx_probe_work()
1734 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) { in default_bdl_pos_adj()
1735 switch (chip->pci->device) { in default_bdl_pos_adj()
1742 switch (chip->driver_type) { in default_bdl_pos_adj()
1774 hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL); in azx_create()
1776 return -ENOMEM; in azx_create()
1778 chip = &hda->chip; in azx_create()
1779 mutex_init(&chip->open_mutex); in azx_create()
1780 chip->card = card; in azx_create()
1781 chip->pci = pci; in azx_create()
1782 chip->ops = &pci_hda_ops; in azx_create()
1783 chip->driver_caps = driver_caps; in azx_create()
1784 chip->driver_type = driver_caps & 0xff; in azx_create()
1786 chip->dev_index = dev; in azx_create()
1788 chip->jackpoll_interval = msecs_to_jiffies(jackpoll_ms[dev]); in azx_create()
1789 INIT_LIST_HEAD(&chip->pcm_list); in azx_create()
1790 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); in azx_create()
1791 INIT_LIST_HEAD(&hda->list); in azx_create()
1793 init_completion(&hda->probe_wait); in azx_create()
1800 chip->fallback_to_single_cmd = 1; in azx_create()
1802 chip->single_cmd = single_cmd; in azx_create()
1807 chip->bdl_pos_adj = default_bdl_pos_adj(chip); in azx_create()
1809 chip->bdl_pos_adj = bdl_pos_adj[dev]; in azx_create()
1815 /* use the non-cached pages in non-snoop mode */ in azx_create()
1817 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC; in azx_create()
1819 if (chip->driver_type == AZX_DRIVER_NVIDIA) { in azx_create()
1820 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); in azx_create()
1821 chip->bus.core.needs_damn_long_delay = 1; in azx_create()
1826 dev_err(card->dev, "Error creating device [card]!\n"); in azx_create()
1832 INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work); in azx_create()
1841 int dev = chip->dev_index; in azx_first_init()
1842 struct pci_dev *pci = chip->pci; in azx_first_init()
1843 struct snd_card *card = chip->card; in azx_first_init()
1851 if (chip->driver_type == AZX_DRIVER_ULI) { in azx_first_init()
1863 bus->addr = pci_resource_start(pci, 0); in azx_first_init()
1864 bus->remap_addr = pcim_iomap_table(pci)[0]; in azx_first_init()
1866 if (chip->driver_type == AZX_DRIVER_SKL) in azx_first_init()
1875 chip->gts_present = false; in azx_first_init()
1878 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART)) in azx_first_init()
1879 chip->gts_present = true; in azx_first_init()
1882 if (chip->msi) { in azx_first_init()
1883 if (chip->driver_caps & AZX_DCAPS_NO_MSI64) { in azx_first_init()
1884 dev_dbg(card->dev, "Disabling 64bit MSI\n"); in azx_first_init()
1885 pci->no_64bit_msi = true; in azx_first_init()
1888 chip->msi = 0; in azx_first_init()
1894 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); in azx_first_init()
1897 if (chip->pci->vendor == PCI_VENDOR_ID_AMD) in azx_first_init()
1901 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { in azx_first_init()
1908 if (p_smbus->revision < 0x30) in azx_first_init()
1915 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA) in azx_first_init()
1919 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { in azx_first_init()
1920 dev_dbg(card->dev, "Disabling 64bit DMA\n"); in azx_first_init()
1924 /* disable buffer size rounding to 128-byte multiples if supported */ in azx_first_init()
1926 chip->align_buffer_size = !!align_buffer_size; in azx_first_init()
1928 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE) in azx_first_init()
1929 chip->align_buffer_size = 0; in azx_first_init()
1931 chip->align_buffer_size = 1; in azx_first_init()
1937 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits))) in azx_first_init()
1938 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1943 chip->capture_streams = (gcap >> 8) & 0x0f; in azx_first_init()
1944 chip->playback_streams = (gcap >> 12) & 0x0f; in azx_first_init()
1945 if (!chip->playback_streams && !chip->capture_streams) { in azx_first_init()
1948 switch (chip->driver_type) { in azx_first_init()
1950 chip->playback_streams = ULI_NUM_PLAYBACK; in azx_first_init()
1951 chip->capture_streams = ULI_NUM_CAPTURE; in azx_first_init()
1955 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; in azx_first_init()
1956 chip->capture_streams = ATIHDMI_NUM_CAPTURE; in azx_first_init()
1960 chip->playback_streams = ICH6_NUM_PLAYBACK; in azx_first_init()
1961 chip->capture_streams = ICH6_NUM_CAPTURE; in azx_first_init()
1965 chip->capture_index_offset = 0; in azx_first_init()
1966 chip->playback_index_offset = chip->capture_streams; in azx_first_init()
1967 chip->num_streams = chip->playback_streams + chip->capture_streams; in azx_first_init()
1969 /* sanity check for the SDxCTL.STRM field overflow */ in azx_first_init()
1970 if (chip->num_streams > 15 && in azx_first_init()
1971 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) { in azx_first_init()
1972 dev_warn(chip->card->dev, "number of I/O streams is %d, " in azx_first_init()
1973 "forcing separate stream tags", chip->num_streams); in azx_first_init()
1974 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG; in azx_first_init()
1994 if (!azx_bus(chip)->codec_mask) { in azx_first_init()
1995 dev_err(card->dev, "no codecs found!\n"); in azx_first_init()
2000 return -EBUSY; in azx_first_init()
2002 strcpy(card->driver, "HDA-Intel"); in azx_first_init()
2003 strscpy(card->shortname, driver_short_names[chip->driver_type], in azx_first_init()
2004 sizeof(card->shortname)); in azx_first_init()
2005 snprintf(card->longname, sizeof(card->longname), in azx_first_init()
2007 card->shortname, bus->addr, bus->irq); in azx_first_init()
2017 struct azx *chip = card->private_data; in azx_firmware_cb()
2020 chip->fw = fw; in azx_firmware_cb()
2022 dev_err(card->dev, "Cannot load firmware, continue without patching\n"); in azx_firmware_cb()
2023 if (!chip->disabled) { in azx_firmware_cb()
2035 free_irq(bus->irq, chip); in disable_msi_reset_irq()
2036 bus->irq = -1; in disable_msi_reset_irq()
2037 chip->card->sync_irq = -1; in disable_msi_reset_irq()
2038 pci_disable_msi(chip->pci); in disable_msi_reset_irq()
2039 chip->msi = 0; in disable_msi_reset_irq()
2048 * some HD-audio PCI entries are exposed without any codecs, and such devices
2074 dev_info(&pci->dev, "Skipping the device on the denylist\n"); in azx_probe()
2075 return -ENODEV; in azx_probe()
2079 return -ENODEV; in azx_probe()
2082 return -ENOENT; in azx_probe()
2091 dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n"); in azx_probe()
2092 return -ENODEV; in azx_probe()
2095 …dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option i… in azx_probe()
2098 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in azx_probe()
2101 dev_err(&pci->dev, "Error creating card!\n"); in azx_probe()
2105 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); in azx_probe()
2108 card->private_data = chip; in azx_probe()
2115 dev_err(card->dev, "Error registering vga_switcheroo client\n"); in azx_probe()
2120 dev_info(card->dev, "VGA controller is disabled\n"); in azx_probe()
2121 dev_info(card->dev, "Delaying initialization\n"); in azx_probe()
2122 chip->disabled = true; in azx_probe()
2125 schedule_probe = !chip->disabled; in azx_probe()
2129 dev_info(card->dev, "Applying patch firmware '%s'\n", in azx_probe()
2132 &pci->dev, GFP_KERNEL, card, in azx_probe()
2142 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n"); in azx_probe()
2146 schedule_delayed_work(&hda->probe_work, 0); in azx_probe()
2149 if (chip->disabled) in azx_probe()
2150 complete_all(&hda->probe_wait); in azx_probe()
2167 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2169 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2171 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2173 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2177 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2178 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2180 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2207 q = snd_pci_quirk_lookup(chip->pci, power_save_denylist); in set_default_power_save()
2209 …dev_info(chip->card->dev, "device %04x:%04x is on the power_save denylist, forcing power_save to 0… in set_default_power_save()
2210 q->subvendor, q->subdevice); in set_default_power_save()
2215 snd_hda_set_power_save(&chip->bus, val * 1000); in set_default_power_save()
2228 struct pci_dev *pci = chip->pci; in azx_probe_continue()
2229 int dev = chip->dev_index; in azx_probe_continue()
2232 if (chip->disabled || hda->init_failed) in azx_probe_continue()
2233 return -EIO; in azx_probe_continue()
2234 if (hda->probe_retry) in azx_probe_continue()
2237 to_hda_bus(bus)->bus_probing = 1; in azx_probe_continue()
2238 hda->probe_continued = 1; in azx_probe_continue()
2241 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) { in azx_probe_continue()
2250 dev_err(chip->card->dev, in azx_probe_continue()
2251 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n"); in azx_probe_continue()
2255 chip->driver_caps &= ~AZX_DCAPS_I915_COMPONENT; in azx_probe_continue()
2261 hda->need_i915_power = true; in azx_probe_continue()
2276 chip->beep_mode = beep_mode[dev]; in azx_probe_continue()
2280 if (bus->codec_mask) { in azx_probe_continue()
2281 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); in azx_probe_continue()
2287 if (chip->fw) { in azx_probe_continue()
2288 err = snd_hda_load_patch(&chip->bus, chip->fw->size, in azx_probe_continue()
2289 chip->fw->data); in azx_probe_continue()
2293 release_firmware(chip->fw); /* no longer needed */ in azx_probe_continue()
2294 chip->fw = NULL; in azx_probe_continue()
2300 if (bus->codec_mask && !(probe_only[dev] & 1)) { in azx_probe_continue()
2303 if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) && in azx_probe_continue()
2304 ++hda->probe_retry < 60) { in azx_probe_continue()
2305 schedule_delayed_work(&hda->probe_work, in azx_probe_continue()
2309 dev_err(chip->card->dev, "Cannot probe codecs, giving up\n"); in azx_probe_continue()
2314 err = snd_card_register(chip->card); in azx_probe_continue()
2320 chip->running = 1; in azx_probe_continue()
2326 pm_runtime_use_autosuspend(&pci->dev); in azx_probe_continue()
2327 pm_runtime_allow(&pci->dev); in azx_probe_continue()
2328 pm_runtime_put_autosuspend(&pci->dev); in azx_probe_continue()
2337 if (!hda->need_i915_power) in azx_probe_continue()
2339 complete_all(&hda->probe_wait); in azx_probe_continue()
2340 to_hda_bus(bus)->bus_probing = 0; in azx_probe_continue()
2341 hda->probe_retry = 0; in azx_probe_continue()
2353 chip = card->private_data; in azx_remove()
2366 device_unlock(&pci->dev); in azx_remove()
2367 cancel_delayed_work_sync(&hda->probe_work); in azx_remove()
2368 device_lock(&pci->dev); in azx_remove()
2381 chip = card->private_data; in azx_shutdown()
2382 if (chip && chip->running) in azx_shutdown()
2413 /* Lynx Point-LP */
2416 /* Lynx Point-LP */
2419 /* Wildcat Point-LP */
2425 /* Sunrise Point-LP */
2431 /* Kabylake-LP */
2434 /* Kabylake-H */
2443 /* CometLake-LP */
2446 /* CometLake-H */
2451 /* CometLake-S */
2454 /* CometLake-R */
2460 /* Icelake-H */
2471 /* Tigerlake-H */
2477 /* Alderlake-S */
2480 /* Alderlake-P */
2483 /* Alderlake-M */
2491 /* Broxton-P(Apollolake) */
2494 /* Broxton-T */
2497 /* Gemini-Lake */
2701 /* Creative X-Fi (CA0110-IBG) */
2708 /* the following entry conflicts with snd-ctxfi driver,
2709 * as ctxfi driver mutates from HD-audio to native mode with
2718 /* this entry seems still valid -- i.e. without emu20kx chip */