Lines Matching +full:ati +full:- +full:mode
3 * hda_intel.c - Implementation of primary alsa driver code base
23 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
41 #include <linux/dma-mapping.h>
73 /* position fix mode */
84 /* Defines for ATI HD Audio support in SB450 south bridge */
107 /* ICH, ATI and VIA have 4 playback and 4 capture */
115 /* ATI HDMI may have up to 8 playbacks and 0 capture */
128 static int position_fix[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
129 static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
130 static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
133 static int single_cmd = -1;
134 static int enable_msi = -1;
139 static bool beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] =
153 …"(-1 = system default, 0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO, 4 = COMBO, 5 = SKL+, 6 = FIFO…
157 MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
173 MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode "
187 MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
192 MODULE_PARM_DESC(pm_blacklist, "Enable power-management blacklist");
194 /* reset the HD-audio controller in power save mode.
195 * this may give more power-saving, but will take longer time to
200 MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
205 static int align_buffer_size = -1;
211 static int hda_snoop = -1;
238 "{ATI, SB450},"
239 "{ATI, SB600},"
240 "{ATI, RS600},"
241 "{ATI, RS690},"
242 "{ATI, RS780},"
243 "{ATI, R600},"
244 "{ATI, RV630},"
245 "{ATI, RV610},"
246 "{ATI, RV670},"
247 "{ATI, RV635},"
248 "{ATI, RV620},"
249 "{ATI, RV770},"
289 (((chip)->driver_caps & AZX_DCAPS_SNOOP_MASK) >> 10)
338 /* quirks for ATI SB / AMD Hudson */
341 AZX_DCAPS_SNOOP_TYPE(ATI))
343 /* quirks for ATI/AMD HDMI */
348 /* quirks for ATI HDMI with snoop off */
355 AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME)
371 #define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo)
372 #define needs_eld_notify_link(chip) ((chip)->need_eld_notify_link)
378 #define CONTROLLER_IN_GPU(pci) (((pci)->device == 0x0a0c) || \
379 ((pci)->device == 0x0c0c) || \
380 ((pci)->device == 0x0d0c) || \
381 ((pci)->device == 0x160c))
383 #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
384 #define IS_CFL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa348)
385 #define IS_CNL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9dc8)
393 [AZX_DRIVER_ATI] = "HDA ATI SB",
394 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
395 [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI",
403 [AZX_DRIVER_CMEDIA] = "HDA C-Media",
404 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
414 if (!dmab || !dmab->area || !dmab->bytes) in __mark_pages_wc()
418 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) { in __mark_pages_wc()
419 struct snd_sg_buf *sgbuf = dmab->private_data; in __mark_pages_wc()
420 if (!chip->uc_buffer) in __mark_pages_wc()
423 set_pages_array_wc(sgbuf->page_table, sgbuf->pages); in __mark_pages_wc()
425 set_pages_array_wb(sgbuf->page_table, sgbuf->pages); in __mark_pages_wc()
430 pages = (dmab->bytes + PAGE_SIZE - 1) >> PAGE_SHIFT; in __mark_pages_wc()
432 set_memory_wc((unsigned long)dmab->area, pages); in __mark_pages_wc()
434 set_memory_wb((unsigned long)dmab->area, pages); in __mark_pages_wc()
445 if (azx_dev->wc_marked != on) { in mark_runtime_wc()
447 azx_dev->wc_marked = on; in mark_runtime_wc()
484 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) in azx_init_pci()
490 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) { in azx_init_pci()
491 dev_dbg(chip->card->dev, "Clearing TCSEL\n"); in azx_init_pci()
492 update_pci_byte(chip->pci, AZX_PCIREG_TCSEL, 0x07, 0); in azx_init_pci()
495 /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio, in azx_init_pci()
499 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n", in azx_init_pci()
501 update_pci_byte(chip->pci, in azx_init_pci()
508 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n", in azx_init_pci()
510 update_pci_byte(chip->pci, in azx_init_pci()
513 update_pci_byte(chip->pci, in azx_init_pci()
516 update_pci_byte(chip->pci, in azx_init_pci()
524 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); in azx_init_pci()
530 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, snoop); in azx_init_pci()
531 pci_read_config_word(chip->pci, in azx_init_pci()
534 dev_dbg(chip->card->dev, "SCH snoop: %s\n", in azx_init_pci()
541 * In BXT-P A0, HD-Audio DMA requests is later than expected,
572 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCAP); in intel_get_lctl_scf()
580 dev_warn(chip->card->dev, "set audio clock frequency to 6MHz"); in intel_get_lctl_scf()
594 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
597 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_ml_lctl_set_power()
601 if (((readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL)) & in intel_ml_lctl_set_power()
604 timeout--; in intel_ml_lctl_set_power()
608 return -1; in intel_ml_lctl_set_power()
618 val = readl(bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
640 writel(val, bus->mlcap + AZX_ML_BASE + AZX_REG_ML_LCTL); in intel_init_lctl()
651 struct pci_dev *pci = chip->pci; in hda_intel_init_chip()
654 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) in hda_intel_init_chip()
656 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
662 if (chip->driver_type == AZX_DRIVER_SKL) { in hda_intel_init_chip()
667 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) in hda_intel_init_chip()
674 if (bus->mlcap != NULL) in hda_intel_init_chip()
682 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_lpib()
683 int stream = substream->stream; in azx_get_delay_from_lpib()
688 delay = pos - lpib_pos; in azx_get_delay_from_lpib()
690 delay = lpib_pos - pos; in azx_get_delay_from_lpib()
692 if (delay >= azx_dev->core.delay_negative_threshold) in azx_get_delay_from_lpib()
695 delay += azx_dev->core.bufsize; in azx_get_delay_from_lpib()
698 if (delay >= azx_dev->core.period_bytes) { in azx_get_delay_from_lpib()
699 dev_info(chip->card->dev, in azx_get_delay_from_lpib()
701 delay, azx_dev->core.period_bytes); in azx_get_delay_from_lpib()
703 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; in azx_get_delay_from_lpib()
704 chip->get_delay[stream] = NULL; in azx_get_delay_from_lpib()
707 return bytes_to_frames(substream->runtime, delay); in azx_get_delay_from_lpib()
720 azx_dev->irq_pending = 0; in azx_position_check()
724 azx_dev->irq_pending = 1; in azx_position_check()
725 schedule_work(&hda->irq_pending_work); in azx_position_check()
740 * periods. Returns non-zero if it's OK.
742 * Many HD-audio controllers appear pretty inaccurate about
743 * the update-IRQ timing. The IRQ is issued before actually the
749 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_position_ok()
750 int stream = substream->stream; in azx_position_ok()
754 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk; in azx_position_ok()
755 if (wallclk < (azx_dev->core.period_wallclk * 2) / 3) in azx_position_ok()
756 return -1; /* bogus (too early) interrupt */ in azx_position_ok()
758 if (chip->get_position[stream]) in azx_position_ok()
759 pos = chip->get_position[stream](chip, azx_dev); in azx_position_ok()
762 if (!pos || pos == (u32)-1) { in azx_position_ok()
763 dev_info(chip->card->dev, in azx_position_ok()
765 chip->get_position[stream] = azx_get_pos_lpib; in azx_position_ok()
766 if (chip->get_position[0] == azx_get_pos_lpib && in azx_position_ok()
767 chip->get_position[1] == azx_get_pos_lpib) in azx_position_ok()
768 azx_bus(chip)->use_posbuf = false; in azx_position_ok()
770 chip->get_delay[stream] = NULL; in azx_position_ok()
772 chip->get_position[stream] = azx_get_pos_posbuf; in azx_position_ok()
773 if (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY) in azx_position_ok()
774 chip->get_delay[stream] = azx_get_delay_from_lpib; in azx_position_ok()
778 if (pos >= azx_dev->core.bufsize) in azx_position_ok()
781 if (WARN_ONCE(!azx_dev->core.period_bytes, in azx_position_ok()
782 "hda-intel: zero azx_dev->period_bytes")) in azx_position_ok()
783 return -1; /* this shouldn't happen! */ in azx_position_ok()
784 if (wallclk < (azx_dev->core.period_wallclk * 5) / 4 && in azx_position_ok()
785 pos % azx_dev->core.period_bytes > azx_dev->core.period_bytes / 2) in azx_position_ok()
786 /* NG - it's below the first next period boundary */ in azx_position_ok()
787 return chip->bdl_pos_adj ? 0 : -1; in azx_position_ok()
788 azx_dev->core.start_wallclk += wallclk; in azx_position_ok()
798 struct azx *chip = &hda->chip; in azx_irq_pending_work()
803 if (!hda->irq_pending_warned) { in azx_irq_pending_work()
804 dev_info(chip->card->dev, in azx_irq_pending_work()
806 chip->card->number); in azx_irq_pending_work()
807 hda->irq_pending_warned = 1; in azx_irq_pending_work()
812 spin_lock_irq(&bus->reg_lock); in azx_irq_pending_work()
813 list_for_each_entry(s, &bus->stream_list, list) { in azx_irq_pending_work()
815 if (!azx_dev->irq_pending || in azx_irq_pending_work()
816 !s->substream || in azx_irq_pending_work()
817 !s->running) in azx_irq_pending_work()
821 azx_dev->irq_pending = 0; in azx_irq_pending_work()
822 spin_unlock(&bus->reg_lock); in azx_irq_pending_work()
823 snd_pcm_period_elapsed(s->substream); in azx_irq_pending_work()
824 spin_lock(&bus->reg_lock); in azx_irq_pending_work()
830 spin_unlock_irq(&bus->reg_lock); in azx_irq_pending_work()
837 /* clear irq_pending flags and assure no on-going workq */
843 spin_lock_irq(&bus->reg_lock); in azx_clear_irq_pending()
844 list_for_each_entry(s, &bus->stream_list, list) { in azx_clear_irq_pending()
846 azx_dev->irq_pending = 0; in azx_clear_irq_pending()
848 spin_unlock_irq(&bus->reg_lock); in azx_clear_irq_pending()
855 if (request_irq(chip->pci->irq, azx_interrupt, in azx_acquire_irq()
856 chip->msi ? 0 : IRQF_SHARED, in azx_acquire_irq()
857 chip->card->irq_descr, chip)) { in azx_acquire_irq()
858 dev_err(chip->card->dev, in azx_acquire_irq()
860 chip->pci->irq); in azx_acquire_irq()
862 snd_card_disconnect(chip->card); in azx_acquire_irq()
863 return -1; in azx_acquire_irq()
865 bus->irq = chip->pci->irq; in azx_acquire_irq()
866 pci_intx(chip->pci, !chip->msi); in azx_acquire_irq()
879 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in azx_via_get_position()
888 mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); in azx_via_get_position()
889 mod_dma_pos %= azx_dev->core.period_bytes; in azx_via_get_position()
891 /* azx_dev->fifo_size can't get FIFO size of in stream. in azx_via_get_position()
894 fifo_size = readw(azx_bus(chip)->remap_addr + in azx_via_get_position()
897 if (azx_dev->insufficient) { in azx_via_get_position()
902 azx_dev->insufficient = 0; in azx_via_get_position()
906 mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; in azx_via_get_position()
908 mini_pos = link_pos - fifo_size; in azx_via_get_position()
911 mod_mini_pos = mini_pos % azx_dev->core.period_bytes; in azx_via_get_position()
912 mod_link_pos = link_pos % azx_dev->core.period_bytes; in azx_via_get_position()
914 bound_pos = link_pos - mod_link_pos; in azx_via_get_position()
916 bound_pos = mini_pos - mod_mini_pos; in azx_via_get_position()
918 bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; in azx_via_get_position()
919 if (bound_pos >= azx_dev->core.bufsize) in azx_via_get_position()
932 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_pos_fifo()
933 struct snd_pcm_runtime *runtime = substream->runtime; in azx_get_pos_fifo()
940 runtime->delay = AMD_FIFO_SIZE; in azx_get_pos_fifo()
942 if (azx_dev->insufficient) { in azx_get_pos_fifo()
945 runtime->delay = bytes_to_frames(runtime, pos); in azx_get_pos_fifo()
947 azx_dev->insufficient = 0; in azx_get_pos_fifo()
952 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in azx_get_pos_fifo()
954 pos += azx_dev->core.bufsize; in azx_get_pos_fifo()
955 pos -= delay; in azx_get_pos_fifo()
964 struct snd_pcm_substream *substream = azx_dev->core.substream; in azx_get_delay_from_fifo()
967 return substream->runtime->delay; in azx_get_delay_from_fifo()
976 azx_dev->core.index)); in azx_skl_get_dpib_pos()
983 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in azx_get_pos_skl()
1003 list_add(&hda->list, &card_list); in azx_add_card_list()
1011 list_del_init(&hda->list); in azx_del_card_list()
1015 /* trigger power-save check at writing parameter */
1028 chip = &hda->chip; in param_set_xint()
1029 if (!hda->probe_continued || chip->disabled) in param_set_xint()
1031 snd_hda_set_power_save(&chip->bus, power_save * 1000); in param_set_xint()
1055 chip = card->private_data; in azx_suspend()
1057 if (chip->disabled || hda->init_failed || !chip->running) in azx_suspend()
1065 if (bus->irq >= 0) { in azx_suspend()
1066 free_irq(bus->irq, chip); in azx_suspend()
1067 bus->irq = -1; in azx_suspend()
1070 if (chip->msi) in azx_suspend()
1071 pci_disable_msi(chip->pci); in azx_suspend()
1072 if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL) in azx_suspend()
1073 && hda->need_i915_power) in azx_suspend()
1091 chip = card->private_data; in azx_resume()
1094 if (chip->disabled || hda->init_failed || !chip->running) in azx_resume()
1097 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { in azx_resume()
1099 if (hda->need_i915_power) in azx_resume()
1103 if (chip->msi) in azx_resume()
1105 chip->msi = 0; in azx_resume()
1107 return -EIO; in azx_resume()
1112 /* power down again for link-controlled chips */ in azx_resume()
1113 if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL) && in azx_resume()
1114 !hda->need_i915_power) in azx_resume()
1129 struct azx *chip = card->private_data; in azx_freeze_noirq()
1132 if (chip->driver_type == AZX_DRIVER_SKL) in azx_freeze_noirq()
1141 struct azx *chip = card->private_data; in azx_thaw_noirq()
1144 if (chip->driver_type == AZX_DRIVER_SKL) in azx_thaw_noirq()
1161 chip = card->private_data; in azx_runtime_suspend()
1163 if (chip->disabled || hda->init_failed) in azx_runtime_suspend()
1176 if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL) in azx_runtime_suspend()
1177 && hda->need_i915_power) in azx_runtime_suspend()
1196 chip = card->private_data; in azx_runtime_resume()
1199 if (chip->disabled || hda->init_failed) in azx_runtime_resume()
1205 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { in azx_runtime_resume()
1207 if (hda->need_i915_power) in azx_runtime_resume()
1218 list_for_each_codec(codec, &chip->bus) in azx_runtime_resume()
1219 if (status & (1 << codec->addr)) in azx_runtime_resume()
1220 schedule_delayed_work(&codec->jackpoll_work, in azx_runtime_resume()
1221 codec->jackpoll_interval); in azx_runtime_resume()
1228 /* power down again for link-controlled chips */ in azx_runtime_resume()
1229 if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL) && in azx_runtime_resume()
1230 !hda->need_i915_power) in azx_runtime_resume()
1246 chip = card->private_data; in azx_runtime_idle()
1248 if (chip->disabled || hda->init_failed) in azx_runtime_idle()
1252 azx_bus(chip)->codec_powered || !chip->running) in azx_runtime_idle()
1253 return -EBUSY; in azx_runtime_idle()
1255 /* ELD notification gets broken when HD-audio bus is off */ in azx_runtime_idle()
1257 return -EBUSY; in azx_runtime_idle()
1286 struct azx *chip = card->private_data; in azx_vs_set_state()
1291 wait_for_completion(&hda->probe_wait); in azx_vs_set_state()
1292 if (hda->init_failed) in azx_vs_set_state()
1296 if (chip->disabled == disabled) in azx_vs_set_state()
1299 if (!hda->probe_continued) { in azx_vs_set_state()
1300 chip->disabled = disabled; in azx_vs_set_state()
1302 dev_info(chip->card->dev, in azx_vs_set_state()
1305 dev_err(chip->card->dev, "initialization error\n"); in azx_vs_set_state()
1306 hda->init_failed = true; in azx_vs_set_state()
1310 dev_info(chip->card->dev, "%s via vga_switcheroo\n", in azx_vs_set_state()
1313 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1317 pm_runtime_suspend(card->dev); in azx_vs_set_state()
1318 pm_runtime_disable(card->dev); in azx_vs_set_state()
1322 pci->current_state = PCI_D3cold; in azx_vs_set_state()
1323 chip->disabled = true; in azx_vs_set_state()
1324 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_set_state()
1325 dev_warn(chip->card->dev, in azx_vs_set_state()
1328 snd_hda_unlock_devices(&chip->bus); in azx_vs_set_state()
1329 chip->disabled = false; in azx_vs_set_state()
1330 pm_runtime_enable(card->dev); in azx_vs_set_state()
1331 list_for_each_codec(codec, &chip->bus) { in azx_vs_set_state()
1342 struct azx *chip = card->private_data; in azx_vs_can_switch()
1345 wait_for_completion(&hda->probe_wait); in azx_vs_can_switch()
1346 if (hda->init_failed) in azx_vs_can_switch()
1348 if (chip->disabled || !hda->probe_continued) in azx_vs_can_switch()
1350 if (snd_hda_lock_devices(&chip->bus)) in azx_vs_can_switch()
1352 snd_hda_unlock_devices(&chip->bus); in azx_vs_can_switch()
1365 if (hda->use_vga_switcheroo && !hda->need_eld_notify_link) { in setup_vga_switcheroo_runtime_pm()
1366 list_for_each_codec(codec, &chip->bus) in setup_vga_switcheroo_runtime_pm()
1367 codec->auto_runtime_pm = 1; in setup_vga_switcheroo_runtime_pm()
1369 if (chip->running) in setup_vga_switcheroo_runtime_pm()
1378 struct azx *chip = card->private_data; in azx_vs_gpu_bound()
1382 hda->need_eld_notify_link = 0; in azx_vs_gpu_bound()
1389 struct pci_dev *p = get_bound_vga(chip->pci); in init_vga_switcheroo()
1391 dev_info(chip->card->dev, in init_vga_switcheroo()
1393 hda->use_vga_switcheroo = 1; in init_vga_switcheroo()
1394 hda->need_eld_notify_link = 1; /* cleared in gpu_bound op */ in init_vga_switcheroo()
1395 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME; in init_vga_switcheroo()
1412 if (!hda->use_vga_switcheroo) in register_vga_switcheroo()
1415 p = get_bound_vga(chip->pci); in register_vga_switcheroo()
1416 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, p); in register_vga_switcheroo()
1421 hda->vga_switcheroo_registered = 1; in register_vga_switcheroo()
1437 struct pci_dev *pci = chip->pci; in azx_free()
1441 if (azx_has_pm_runtime(chip) && chip->running) in azx_free()
1442 pm_runtime_get_noresume(&pci->dev); in azx_free()
1443 chip->running = 0; in azx_free()
1447 hda->init_failed = 1; /* to be sure */ in azx_free()
1448 complete_all(&hda->probe_wait); in azx_free()
1451 if (chip->disabled && hda->probe_continued) in azx_free()
1452 snd_hda_unlock_devices(&chip->bus); in azx_free()
1453 if (hda->vga_switcheroo_registered) in azx_free()
1454 vga_switcheroo_unregister_client(chip->pci); in azx_free()
1457 if (bus->chip_init) { in azx_free()
1463 if (bus->irq >= 0) in azx_free()
1464 free_irq(bus->irq, (void*)chip); in azx_free()
1465 if (chip->msi) in azx_free()
1466 pci_disable_msi(chip->pci); in azx_free()
1467 iounmap(bus->remap_addr); in azx_free()
1473 if (chip->region_requested) in azx_free()
1474 pci_release_regions(chip->pci); in azx_free()
1476 pci_disable_device(chip->pci); in azx_free()
1478 release_firmware(chip->fw); in azx_free()
1481 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { in azx_free()
1482 if (hda->need_i915_power) in azx_free()
1485 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) in azx_free()
1494 struct azx *chip = device->device_data; in azx_dev_disconnect()
1497 chip->bus.shutdown = 1; in azx_dev_disconnect()
1498 cancel_work_sync(&bus->unsol_work); in azx_dev_disconnect()
1505 return azx_free(device->device_data); in azx_dev_free()
1517 switch (pci->vendor) { in get_bound_vga()
1521 if (pci->devfn == 1) { in get_bound_vga()
1522 p = pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), in get_bound_vga()
1523 pci->bus->number, 0); in get_bound_vga()
1525 if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY) in get_bound_vga()
1550 * white/black-listing for position_fix
1562 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
1565 SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB),
1566 SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB),
1585 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); in check_position_fix()
1587 dev_info(chip->card->dev, in check_position_fix()
1589 q->value, q->subvendor, q->subdevice); in check_position_fix()
1590 return q->value; in check_position_fix()
1593 /* Check VIA/ATI HD Audio Controller exist */ in check_position_fix()
1594 if (chip->driver_type == AZX_DRIVER_VIA) { in check_position_fix()
1595 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n"); in check_position_fix()
1598 if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) { in check_position_fix()
1599 dev_dbg(chip->card->dev, "Using FIFO position fix\n"); in check_position_fix()
1602 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { in check_position_fix()
1603 dev_dbg(chip->card->dev, "Using LPIB position fix\n"); in check_position_fix()
1606 if (chip->driver_type == AZX_DRIVER_SKL) { in check_position_fix()
1607 dev_dbg(chip->card->dev, "Using SKL position fix\n"); in check_position_fix()
1625 chip->get_position[0] = chip->get_position[1] = callbacks[fix]; in assign_position_fix()
1627 /* combo mode uses LPIB only for playback */ in assign_position_fix()
1629 chip->get_position[1] = NULL; in assign_position_fix()
1632 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { in assign_position_fix()
1633 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1638 chip->get_delay[0] = chip->get_delay[1] = in assign_position_fix()
1643 * black-lists for probe_mask
1647 * to the non-working (or non-existing) modem codec slot.
1670 chip->codec_probe_mask = probe_mask[dev]; in check_probe_mask()
1671 if (chip->codec_probe_mask == -1) { in check_probe_mask()
1672 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); in check_probe_mask()
1674 dev_info(chip->card->dev, in check_probe_mask()
1676 q->value, q->subvendor, q->subdevice); in check_probe_mask()
1677 chip->codec_probe_mask = q->value; in check_probe_mask()
1682 if (chip->codec_probe_mask != -1 && in check_probe_mask()
1683 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { in check_probe_mask()
1684 azx_bus(chip)->codec_mask = chip->codec_probe_mask & 0xff; in check_probe_mask()
1685 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n", in check_probe_mask()
1686 (int)azx_bus(chip)->codec_mask); in check_probe_mask()
1691 * white/black-list for enable_msi
1703 SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
1712 chip->msi = !!enable_msi; in check_msi()
1715 chip->msi = 1; /* enable MSI as default */ in check_msi()
1716 q = snd_pci_quirk_lookup(chip->pci, msi_black_list); in check_msi()
1718 dev_info(chip->card->dev, in check_msi()
1720 q->subvendor, q->subdevice, q->value); in check_msi()
1721 chip->msi = q->value; in check_msi()
1726 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { in check_msi()
1727 dev_info(chip->card->dev, "Disabling MSI\n"); in check_msi()
1728 chip->msi = 0; in check_msi()
1732 /* check the snoop mode availability */
1738 dev_info(chip->card->dev, "Force to %s mode by module option\n", in azx_check_snoop_available()
1739 snoop ? "snoop" : "non-snoop"); in azx_check_snoop_available()
1740 chip->snoop = snoop; in azx_check_snoop_available()
1741 chip->uc_buffer = !snoop; in azx_check_snoop_available()
1747 chip->driver_type == AZX_DRIVER_VIA) { in azx_check_snoop_available()
1748 /* force to non-snoop mode for a new VIA controller in azx_check_snoop_available()
1752 pci_read_config_byte(chip->pci, 0x42, &val); in azx_check_snoop_available()
1753 if (!(val & 0x80) && (chip->pci->revision == 0x30 || in azx_check_snoop_available()
1754 chip->pci->revision == 0x20)) in azx_check_snoop_available()
1758 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) in azx_check_snoop_available()
1761 chip->snoop = snoop; in azx_check_snoop_available()
1763 dev_info(chip->card->dev, "Force to non-snoop mode\n"); in azx_check_snoop_available()
1764 /* C-Media requires non-cached pages only for CORB/RIRB */ in azx_check_snoop_available()
1765 if (chip->driver_type != AZX_DRIVER_CMEDIA) in azx_check_snoop_available()
1766 chip->uc_buffer = true; in azx_check_snoop_available()
1773 azx_probe_continue(&hda->chip); in azx_probe_work()
1779 if (chip->pci->vendor == PCI_VENDOR_ID_INTEL) { in default_bdl_pos_adj()
1780 switch (chip->pci->device) { in default_bdl_pos_adj()
1787 switch (chip->driver_type) { in default_bdl_pos_adj()
1823 return -ENOMEM; in azx_create()
1826 chip = &hda->chip; in azx_create()
1827 mutex_init(&chip->open_mutex); in azx_create()
1828 chip->card = card; in azx_create()
1829 chip->pci = pci; in azx_create()
1830 chip->ops = &pci_hda_ops; in azx_create()
1831 chip->driver_caps = driver_caps; in azx_create()
1832 chip->driver_type = driver_caps & 0xff; in azx_create()
1834 chip->dev_index = dev; in azx_create()
1835 chip->jackpoll_ms = jackpoll_ms; in azx_create()
1836 INIT_LIST_HEAD(&chip->pcm_list); in azx_create()
1837 INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); in azx_create()
1838 INIT_LIST_HEAD(&hda->list); in azx_create()
1840 init_completion(&hda->probe_wait); in azx_create()
1847 chip->fallback_to_single_cmd = 1; in azx_create()
1849 chip->single_cmd = single_cmd; in azx_create()
1854 chip->bdl_pos_adj = default_bdl_pos_adj(chip); in azx_create()
1856 chip->bdl_pos_adj = bdl_pos_adj[dev]; in azx_create()
1860 chip->polling_mode = 1; in azx_create()
1869 if (chip->driver_type == AZX_DRIVER_NVIDIA) { in azx_create()
1870 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); in azx_create()
1871 chip->bus.needs_damn_long_delay = 1; in azx_create()
1876 dev_err(card->dev, "Error creating device [card]!\n"); in azx_create()
1882 INIT_WORK(&hda->probe_work, azx_probe_work); in azx_create()
1891 int dev = chip->dev_index; in azx_first_init()
1892 struct pci_dev *pci = chip->pci; in azx_first_init()
1893 struct snd_card *card = chip->card; in azx_first_init()
1901 if (chip->driver_type == AZX_DRIVER_ULI) { in azx_first_init()
1912 chip->region_requested = 1; in azx_first_init()
1914 bus->addr = pci_resource_start(pci, 0); in azx_first_init()
1915 bus->remap_addr = pci_ioremap_bar(pci, 0); in azx_first_init()
1916 if (bus->remap_addr == NULL) { in azx_first_init()
1917 dev_err(card->dev, "ioremap error\n"); in azx_first_init()
1918 return -ENXIO; in azx_first_init()
1921 if (chip->driver_type == AZX_DRIVER_SKL) in azx_first_init()
1930 chip->gts_present = false; in azx_first_init()
1933 if (bus->ppcap && boot_cpu_has(X86_FEATURE_ART)) in azx_first_init()
1934 chip->gts_present = true; in azx_first_init()
1937 if (chip->msi) { in azx_first_init()
1938 if (chip->driver_caps & AZX_DCAPS_NO_MSI64) { in azx_first_init()
1939 dev_dbg(card->dev, "Disabling 64bit MSI\n"); in azx_first_init()
1940 pci->no_64bit_msi = true; in azx_first_init()
1943 chip->msi = 0; in azx_first_init()
1947 synchronize_irq(bus->irq); in azx_first_init()
1950 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); in azx_first_init()
1953 if (chip->pci->vendor == PCI_VENDOR_ID_AMD) in azx_first_init()
1957 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { in azx_first_init()
1964 if (p_smbus->revision < 0x30) in azx_first_init()
1971 if (chip->pci->vendor == PCI_VENDOR_ID_NVIDIA) in azx_first_init()
1975 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { in azx_first_init()
1976 dev_dbg(card->dev, "Disabling 64bit DMA\n"); in azx_first_init()
1980 /* disable buffer size rounding to 128-byte multiples if supported */ in azx_first_init()
1982 chip->align_buffer_size = !!align_buffer_size; in azx_first_init()
1984 if (chip->driver_caps & AZX_DCAPS_NO_ALIGN_BUFSIZE) in azx_first_init()
1985 chip->align_buffer_size = 0; in azx_first_init()
1987 chip->align_buffer_size = 1; in azx_first_init()
1993 if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) { in azx_first_init()
1994 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits)); in azx_first_init()
1996 dma_set_mask(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
1997 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)); in azx_first_init()
2003 chip->capture_streams = (gcap >> 8) & 0x0f; in azx_first_init()
2004 chip->playback_streams = (gcap >> 12) & 0x0f; in azx_first_init()
2005 if (!chip->playback_streams && !chip->capture_streams) { in azx_first_init()
2008 switch (chip->driver_type) { in azx_first_init()
2010 chip->playback_streams = ULI_NUM_PLAYBACK; in azx_first_init()
2011 chip->capture_streams = ULI_NUM_CAPTURE; in azx_first_init()
2015 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; in azx_first_init()
2016 chip->capture_streams = ATIHDMI_NUM_CAPTURE; in azx_first_init()
2020 chip->playback_streams = ICH6_NUM_PLAYBACK; in azx_first_init()
2021 chip->capture_streams = ICH6_NUM_CAPTURE; in azx_first_init()
2025 chip->capture_index_offset = 0; in azx_first_init()
2026 chip->playback_index_offset = chip->capture_streams; in azx_first_init()
2027 chip->num_streams = chip->playback_streams + chip->capture_streams; in azx_first_init()
2030 if (chip->num_streams > 15 && in azx_first_init()
2031 (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG) == 0) { in azx_first_init()
2032 dev_warn(chip->card->dev, "number of I/O streams is %d, " in azx_first_init()
2033 "forcing separate stream tags", chip->num_streams); in azx_first_init()
2034 chip->driver_caps |= AZX_DCAPS_SEPARATE_STREAM_TAG; in azx_first_init()
2049 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) in azx_first_init()
2055 if (!azx_bus(chip)->codec_mask) { in azx_first_init()
2056 dev_err(card->dev, "no codecs found!\n"); in azx_first_init()
2061 return -EBUSY; in azx_first_init()
2063 strcpy(card->driver, "HDA-Intel"); in azx_first_init()
2064 strlcpy(card->shortname, driver_short_names[chip->driver_type], in azx_first_init()
2065 sizeof(card->shortname)); in azx_first_init()
2066 snprintf(card->longname, sizeof(card->longname), in azx_first_init()
2068 card->shortname, bus->addr, bus->irq); in azx_first_init()
2078 struct azx *chip = card->private_data; in azx_firmware_cb()
2081 chip->fw = fw; in azx_firmware_cb()
2083 dev_err(card->dev, "Cannot load firmware, continue without patching\n"); in azx_firmware_cb()
2084 if (!chip->disabled) { in azx_firmware_cb()
2131 free_irq(bus->irq, chip); in disable_msi_reset_irq()
2132 bus->irq = -1; in disable_msi_reset_irq()
2133 pci_disable_msi(chip->pci); in disable_msi_reset_irq()
2134 chip->msi = 0; in disable_msi_reset_irq()
2152 bus->dev, in dma_alloc_pages()
2196 struct azx *chip = apcm->chip; in pcm_mmap_prepare()
2197 if (chip->uc_buffer) in pcm_mmap_prepare()
2198 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); in pcm_mmap_prepare()
2214 * some HD-audio PCI entries are exposed without any codecs, and such devices
2244 dev_info(&pci->dev, "Skipping the blacklisted device\n"); in azx_probe()
2245 return -ENODEV; in azx_probe()
2249 return -ENODEV; in azx_probe()
2252 return -ENOENT; in azx_probe()
2255 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in azx_probe()
2258 dev_err(&pci->dev, "Error creating card!\n"); in azx_probe()
2262 err = azx_create(card, pci, dev, pci_id->driver_data, &chip); in azx_probe()
2265 card->private_data = chip; in azx_probe()
2272 dev_err(card->dev, "Error registering vga_switcheroo client\n"); in azx_probe()
2277 dev_info(card->dev, "VGA controller is disabled\n"); in azx_probe()
2278 dev_info(card->dev, "Delaying initialization\n"); in azx_probe()
2279 chip->disabled = true; in azx_probe()
2282 schedule_probe = !chip->disabled; in azx_probe()
2286 dev_info(card->dev, "Applying patch firmware '%s'\n", in azx_probe()
2289 &pci->dev, GFP_KERNEL, card, in azx_probe()
2299 dev_err(card->dev, "Haswell/Broadwell HDMI/DP must build in CONFIG_SND_HDA_I915\n"); in azx_probe()
2303 schedule_work(&hda->probe_work); in azx_probe()
2306 if (chip->disabled) in azx_probe()
2307 complete_all(&hda->probe_wait); in azx_probe()
2317 * popping sounds when ever we enter/leave powersaving mode. Ideally we would
2324 SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0),
2326 SND_PCI_QUIRK(0x1849, 0x0397, "Asrock N68C-S UCC", 0),
2328 SND_PCI_QUIRK(0x1849, 0x7662, "Asrock H81M-HDS", 0),
2330 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
2338 /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */
2339 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P55A-UD3 / Z87-D3HP", 0),
2341 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0),
2368 q = snd_pci_quirk_lookup(chip->pci, power_save_blacklist); in set_default_power_save()
2370 …dev_info(chip->card->dev, "device %04x:%04x is on the power_save blacklist, forcing power_save to … in set_default_power_save()
2371 q->subvendor, q->subdevice); in set_default_power_save()
2376 snd_hda_set_power_save(&chip->bus, val * 1000); in set_default_power_save()
2389 struct pci_dev *pci = chip->pci; in azx_probe_continue()
2390 int dev = chip->dev_index; in azx_probe_continue()
2393 to_hda_bus(bus)->bus_probing = 1; in azx_probe_continue()
2394 hda->probe_continued = 1; in azx_probe_continue()
2397 if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT) { in azx_probe_continue()
2406 dev_err(chip->card->dev, in azx_probe_continue()
2407 "HSW/BDW HD-audio HDMI/DP requires binding with gfx driver\n"); in azx_probe_continue()
2411 chip->driver_caps &= in azx_probe_continue()
2422 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { in azx_probe_continue()
2425 hda->need_i915_power = 1; in azx_probe_continue()
2429 dev_err(chip->card->dev, in azx_probe_continue()
2440 chip->beep_mode = beep_mode[dev]; in azx_probe_continue()
2444 if (bus->codec_mask) { in azx_probe_continue()
2445 err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); in azx_probe_continue()
2451 if (chip->fw) { in azx_probe_continue()
2452 err = snd_hda_load_patch(&chip->bus, chip->fw->size, in azx_probe_continue()
2453 chip->fw->data); in azx_probe_continue()
2457 release_firmware(chip->fw); /* no longer needed */ in azx_probe_continue()
2458 chip->fw = NULL; in azx_probe_continue()
2462 if (bus->codec_mask && !(probe_only[dev] & 1)) { in azx_probe_continue()
2468 err = snd_card_register(chip->card); in azx_probe_continue()
2474 chip->running = 1; in azx_probe_continue()
2480 pm_runtime_use_autosuspend(&pci->dev); in azx_probe_continue()
2481 pm_runtime_put_autosuspend(&pci->dev); in azx_probe_continue()
2485 if ((chip->driver_caps & AZX_DCAPS_I915_POWERWELL) in azx_probe_continue()
2486 && !hda->need_i915_power) in azx_probe_continue()
2491 hda->init_failed = 1; in azx_probe_continue()
2492 complete_all(&hda->probe_wait); in azx_probe_continue()
2493 to_hda_bus(bus)->bus_probing = 0; in azx_probe_continue()
2505 chip = card->private_data; in azx_remove()
2518 device_unlock(&pci->dev); in azx_remove()
2519 cancel_work_sync(&hda->probe_work); in azx_remove()
2520 device_lock(&pci->dev); in azx_remove()
2533 chip = card->private_data; in azx_shutdown()
2534 if (chip && chip->running) in azx_shutdown()
2565 /* Lynx Point-LP */
2568 /* Lynx Point-LP */
2571 /* Wildcat Point-LP */
2577 /* Sunrise Point-LP */
2583 /* Kabylake-LP */
2586 /* Kabylake-H */
2598 /* Broxton-P(Apollolake) */
2601 /* Broxton-T */
2604 /* Gemini-Lake */
2661 /* ATI SB 450/600/700/800/900 */
2682 /* ATI HDMI */
2777 /* Creative X-Fi (CA0110-IBG) */
2784 /* the following entry conflicts with snd-ctxfi driver,
2785 * as ctxfi driver mutates from HD-audio to native mode with
2794 /* this entry seems still valid -- i.e. without emu20kx chip */
2807 /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */