#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/dma-mapping.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/pci.h>
#include <linux/mutex.h>
#include <linux/io.h>
#include <linux/pm_runtime.h>
#include <linux/clocksource.h>
#include <linux/time.h>
#include <linux/completion.h>
#include <linux/acpi.h>
#include <linux/pgtable.h>
#ifdef CONFIG_X86
#include <linux/dma-map-ops.h>
#include <asm/set_memory.h>
#include <asm/cpufeature.h>
#endif
#include <sound/core.h>
#include <sound/initval.h>
#include <sound/hdaudio.h>
#include <sound/hda_i915.h>
#include <sound/intel-dsp-config.h>
#include <linux/vgaarb.h>
#include <linux/vga_switcheroo.h>
#include <linux/apple-gmux.h>
#include <linux/firmware.h>
#include <sound/hda_codec.h>
#include "hda_controller.h"
#include "hda_intel.h"
#define CREATE_TRACE_POINTS
#include "hda_intel_trace.h"
enum { … };
#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR …
#define ATI_SB450_HDAUDIO_ENABLE_SNOOP …
#define NVIDIA_HDA_TRANSREG_ADDR …
#define NVIDIA_HDA_ENABLE_COHBITS …
#define NVIDIA_HDA_ISTRM_COH …
#define NVIDIA_HDA_OSTRM_COH …
#define NVIDIA_HDA_ENABLE_COHBIT …
#define INTEL_HDA_CGCTL …
#define INTEL_HDA_CGCTL_MISCBDCGE …
#define INTEL_SCH_HDA_DEVC …
#define INTEL_SCH_HDA_DEVC_NOSNOOP …
#define ICH6_NUM_CAPTURE …
#define ICH6_NUM_PLAYBACK …
#define ULI_NUM_CAPTURE …
#define ULI_NUM_PLAYBACK …
#define ATIHDMI_NUM_CAPTURE …
#define ATIHDMI_NUM_PLAYBACK …
static int index[SNDRV_CARDS] = …;
static char *id[SNDRV_CARDS] = …;
static bool enable[SNDRV_CARDS] = …;
static char *model[SNDRV_CARDS];
static int position_fix[SNDRV_CARDS] = …;
static int bdl_pos_adj[SNDRV_CARDS] = …;
static int probe_mask[SNDRV_CARDS] = …;
static int probe_only[SNDRV_CARDS];
static int jackpoll_ms[SNDRV_CARDS];
static int single_cmd = …;
static int enable_msi = …;
#ifdef CONFIG_SND_HDA_PATCH_LOADER
static char *patch[SNDRV_CARDS];
#endif
#ifdef CONFIG_SND_HDA_INPUT_BEEP
static bool beep_mode[SNDRV_CARDS] = …;
#endif
static bool dmic_detect = …;
static bool ctl_dev_id = …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param(single_cmd, bint, 0444);
MODULE_PARM_DESC(…) …;
module_param(enable_msi, bint, 0444);
MODULE_PARM_DESC(…) …;
#ifdef CONFIG_SND_HDA_PATCH_LOADER
module_param_array(…);
MODULE_PARM_DESC(…) …;
#endif
#ifdef CONFIG_SND_HDA_INPUT_BEEP
module_param_array(…);
MODULE_PARM_DESC(…) …;
#endif
module_param(dmic_detect, bool, 0444);
MODULE_PARM_DESC(…) …;
module_param(ctl_dev_id, bool, 0444);
MODULE_PARM_DESC(…) …;
#ifdef CONFIG_PM
static int param_set_xint(const char *val, const struct kernel_param *kp);
static const struct kernel_param_ops param_ops_xint = …;
#define param_check_xint …
static int power_save = …;
module_param(power_save, xint, 0644);
MODULE_PARM_DESC(…) …;
static bool pm_blacklist = …;
module_param(pm_blacklist, bool, 0644);
MODULE_PARM_DESC(…) …;
static bool power_save_controller = …;
module_param(power_save_controller, bool, 0644);
MODULE_PARM_DESC(…) …;
#else
#define power_save …
#define pm_blacklist …
#define power_save_controller …
#endif
static int align_buffer_size = …;
module_param(align_buffer_size, bint, 0644);
MODULE_PARM_DESC(…) …;
#ifdef CONFIG_X86
static int hda_snoop = …;
module_param_named(snoop, hda_snoop, bint, 0444);
MODULE_PARM_DESC(…) …;
#else
#define hda_snoop …
#endif
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…) …;
#if defined(CONFIG_PM) && defined(CONFIG_VGA_SWITCHEROO)
#if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI)
#define SUPPORT_VGA_SWITCHEROO
#endif
#endif
enum { … };
#define azx_get_snoop_type(chip) …
#define AZX_DCAPS_SNOOP_TYPE(type) …
#define AZX_DCAPS_INTEL_ICH …
#define AZX_DCAPS_INTEL_PCH_BASE …
#define AZX_DCAPS_INTEL_PCH_NOPM …
#define AZX_DCAPS_INTEL_PCH …
#define AZX_DCAPS_INTEL_HASWELL …
#define AZX_DCAPS_INTEL_BROADWELL …
#define AZX_DCAPS_INTEL_BAYTRAIL …
#define AZX_DCAPS_INTEL_BRASWELL …
#define AZX_DCAPS_INTEL_SKYLAKE …
#define AZX_DCAPS_INTEL_BROXTON …
#define AZX_DCAPS_INTEL_LNL …
#define AZX_DCAPS_PRESET_ATI_SB …
#define AZX_DCAPS_PRESET_ATI_HDMI …
#define AZX_DCAPS_PRESET_ATI_HDMI_NS …
#define AZX_DCAPS_PRESET_AMD_SB …
#define AZX_DCAPS_PRESET_NVIDIA …
#define AZX_DCAPS_PRESET_CTHDA …
#ifdef SUPPORT_VGA_SWITCHEROO
#define use_vga_switcheroo(chip) …
#define needs_eld_notify_link(chip) …
#else
#define use_vga_switcheroo …
#define needs_eld_notify_link …
#endif
static const char * const driver_short_names[] = …;
static int azx_acquire_irq(struct azx *chip, int do_disconnect);
static void set_default_power_save(struct azx *chip);
static void update_pci_byte(struct pci_dev *pci, unsigned int reg,
unsigned char mask, unsigned char val)
{ … }
static void azx_init_pci(struct azx *chip)
{ … }
static void bxt_reduce_dma_latency(struct azx *chip)
{ … }
static int intel_get_lctl_scf(struct azx *chip)
{ … }
static int intel_ml_lctl_set_power(struct azx *chip, int state)
{ … }
static void intel_init_lctl(struct azx *chip)
{ … }
static void hda_intel_init_chip(struct azx *chip, bool full_reset)
{ … }
static int azx_get_delay_from_lpib(struct azx *chip, struct azx_dev *azx_dev,
unsigned int pos)
{ … }
static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev);
static int azx_position_check(struct azx *chip, struct azx_dev *azx_dev)
{ … }
#define display_power(chip, enable) …
static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
{ … }
static void azx_irq_pending_work(struct work_struct *work)
{ … }
static void azx_clear_irq_pending(struct azx *chip)
{ … }
static int azx_acquire_irq(struct azx *chip, int do_disconnect)
{ … }
static unsigned int azx_via_get_position(struct azx *chip,
struct azx_dev *azx_dev)
{ … }
#define AMD_FIFO_SIZE …
static unsigned int azx_get_pos_fifo(struct azx *chip, struct azx_dev *azx_dev)
{ … }
static int azx_get_delay_from_fifo(struct azx *chip, struct azx_dev *azx_dev,
unsigned int pos)
{ … }
static void __azx_shutdown_chip(struct azx *chip, bool skip_link_reset)
{ … }
static DEFINE_MUTEX(card_list_lock);
static LIST_HEAD(card_list);
static void azx_shutdown_chip(struct azx *chip)
{ … }
static void azx_add_card_list(struct azx *chip)
{ … }
static void azx_del_card_list(struct azx *chip)
{ … }
static int __maybe_unused param_set_xint(const char *val, const struct kernel_param *kp)
{ … }
static bool azx_is_pm_ready(struct snd_card *card)
{ … }
static void __azx_runtime_resume(struct azx *chip)
{ … }
static int azx_prepare(struct device *dev)
{ … }
static void azx_complete(struct device *dev)
{ … }
static int azx_suspend(struct device *dev)
{ … }
static int __maybe_unused azx_resume(struct device *dev)
{ … }
static int azx_freeze_noirq(struct device *dev)
{ … }
static int azx_thaw_noirq(struct device *dev)
{ … }
static int __maybe_unused azx_runtime_suspend(struct device *dev)
{ … }
static int __maybe_unused azx_runtime_resume(struct device *dev)
{ … }
static int __maybe_unused azx_runtime_idle(struct device *dev)
{ … }
static const struct dev_pm_ops azx_pm = …;
static int azx_probe_continue(struct azx *chip);
#ifdef SUPPORT_VGA_SWITCHEROO
static struct pci_dev *get_bound_vga(struct pci_dev *pci);
static void azx_vs_set_state(struct pci_dev *pci,
enum vga_switcheroo_state state)
{ … }
static bool azx_vs_can_switch(struct pci_dev *pci)
{ … }
static void setup_vga_switcheroo_runtime_pm(struct azx *chip)
{ … }
static void azx_vs_gpu_bound(struct pci_dev *pci,
enum vga_switcheroo_client_id client_id)
{ … }
static void init_vga_switcheroo(struct azx *chip)
{ … }
static const struct vga_switcheroo_client_ops azx_vs_ops = …;
static int register_vga_switcheroo(struct azx *chip)
{ … }
#else
#define init_vga_switcheroo …
#define register_vga_switcheroo …
#define check_hdmi_disabled …
#define setup_vga_switcheroo_runtime_pm …
#endif
static void azx_free(struct azx *chip)
{ … }
static int azx_dev_disconnect(struct snd_device *device)
{ … }
static int azx_dev_free(struct snd_device *device)
{ … }
#ifdef SUPPORT_VGA_SWITCHEROO
#ifdef CONFIG_ACPI
static bool atpx_present(void)
{ … }
#else
static bool atpx_present(void)
{
return false;
}
#endif
static struct pci_dev *get_bound_vga(struct pci_dev *pci)
{ … }
static bool check_hdmi_disabled(struct pci_dev *pci)
{ … }
#endif
static const struct snd_pci_quirk position_fix_list[] = …;
static int check_position_fix(struct azx *chip, int fix)
{ … }
static void assign_position_fix(struct azx *chip, int fix)
{ … }
static const struct snd_pci_quirk probe_mask_list[] = …;
#define AZX_FORCE_CODEC_MASK …
static void check_probe_mask(struct azx *chip, int dev)
{ … }
static const struct snd_pci_quirk msi_deny_list[] = …;
static void check_msi(struct azx *chip)
{ … }
static void azx_check_snoop_available(struct azx *chip)
{ … }
static void azx_probe_work(struct work_struct *work)
{ … }
static int default_bdl_pos_adj(struct azx *chip)
{ … }
static const struct hda_controller_ops pci_hda_ops;
static int azx_create(struct snd_card *card, struct pci_dev *pci,
int dev, unsigned int driver_caps,
struct azx **rchip)
{ … }
static int azx_first_init(struct azx *chip)
{ … }
#ifdef CONFIG_SND_HDA_PATCH_LOADER
static void azx_firmware_cb(const struct firmware *fw, void *context)
{ … }
#endif
static int disable_msi_reset_irq(struct azx *chip)
{ … }
static const struct pci_device_id driver_denylist[] = …;
static const struct hda_controller_ops pci_hda_ops = …;
static DECLARE_BITMAP(probed_devs, SNDRV_CARDS);
static int azx_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
{ … }
static const struct snd_pci_quirk power_save_denylist[] = …;
static void set_default_power_save(struct azx *chip)
{ … }
static const unsigned int azx_max_codecs[AZX_NUM_DRIVERS] = …;
static int azx_probe_continue(struct azx *chip)
{ … }
static void azx_remove(struct pci_dev *pci)
{ … }
static void azx_shutdown(struct pci_dev *pci)
{ … }
static const struct pci_device_id azx_ids[] = …;
MODULE_DEVICE_TABLE(pci, azx_ids);
static struct pci_driver azx_driver = …;
module_pci_driver(…) …;