hda_intel.c (4750c212174892d26645cdf5ad73fb0e9d594ed3) hda_intel.c (82d9d54a6c0ee8b12211fa4e59fd940a2da4e063)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 *
4 * hda_intel.c - Implementation of primary alsa driver code base
5 * for Intel HD Audio.
6 *
7 * Copyright(c) 2004 Intel Corporation. All rights reserved.
8 *

--- 32 unchanged lines hidden (view full) ---

41#include <asm/pgtable.h>
42#include <asm/set_memory.h>
43#include <asm/cpufeature.h>
44#endif
45#include <sound/core.h>
46#include <sound/initval.h>
47#include <sound/hdaudio.h>
48#include <sound/hda_i915.h>
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 *
4 * hda_intel.c - Implementation of primary alsa driver code base
5 * for Intel HD Audio.
6 *
7 * Copyright(c) 2004 Intel Corporation. All rights reserved.
8 *

--- 32 unchanged lines hidden (view full) ---

41#include <asm/pgtable.h>
42#include <asm/set_memory.h>
43#include <asm/cpufeature.h>
44#endif
45#include <sound/core.h>
46#include <sound/initval.h>
47#include <sound/hdaudio.h>
48#include <sound/hda_i915.h>
49#include <sound/intel-nhlt.h>
49#include <sound/intel-dsp-config.h>
50#include <linux/vgaarb.h>
51#include <linux/vga_switcheroo.h>
52#include <linux/firmware.h>
53#include <sound/hda_codec.h>
54#include "hda_controller.h"
55#include "hda_intel.h"
56
57#define CREATE_TRACE_POINTS

--- 61 unchanged lines hidden (view full) ---

119static int enable_msi = -1;
120#ifdef CONFIG_SND_HDA_PATCH_LOADER
121static char *patch[SNDRV_CARDS];
122#endif
123#ifdef CONFIG_SND_HDA_INPUT_BEEP
124static bool beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] =
125 CONFIG_SND_HDA_INPUT_BEEP_MODE};
126#endif
50#include <linux/vgaarb.h>
51#include <linux/vga_switcheroo.h>
52#include <linux/firmware.h>
53#include <sound/hda_codec.h>
54#include "hda_controller.h"
55#include "hda_intel.h"
56
57#define CREATE_TRACE_POINTS

--- 61 unchanged lines hidden (view full) ---

119static int enable_msi = -1;
120#ifdef CONFIG_SND_HDA_PATCH_LOADER
121static char *patch[SNDRV_CARDS];
122#endif
123#ifdef CONFIG_SND_HDA_INPUT_BEEP
124static bool beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] =
125 CONFIG_SND_HDA_INPUT_BEEP_MODE};
126#endif
127static bool dmic_detect = IS_ENABLED(CONFIG_SND_HDA_INTEL_DETECT_DMIC);
127static bool dsp_driver = 1;
128
129module_param_array(index, int, NULL, 0444);
130MODULE_PARM_DESC(index, "Index value for Intel HD audio interface.");
131module_param_array(id, charp, NULL, 0444);
132MODULE_PARM_DESC(id, "ID string for Intel HD audio interface.");
133module_param_array(enable, bool, NULL, 0444);
134MODULE_PARM_DESC(enable, "Enable Intel HD audio interface.");
135module_param_array(model, charp, NULL, 0444);

--- 18 unchanged lines hidden (view full) ---

154module_param_array(patch, charp, NULL, 0444);
155MODULE_PARM_DESC(patch, "Patch file for Intel HD audio interface.");
156#endif
157#ifdef CONFIG_SND_HDA_INPUT_BEEP
158module_param_array(beep_mode, bool, NULL, 0444);
159MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode "
160 "(0=off, 1=on) (default=1).");
161#endif
128
129module_param_array(index, int, NULL, 0444);
130MODULE_PARM_DESC(index, "Index value for Intel HD audio interface.");
131module_param_array(id, charp, NULL, 0444);
132MODULE_PARM_DESC(id, "ID string for Intel HD audio interface.");
133module_param_array(enable, bool, NULL, 0444);
134MODULE_PARM_DESC(enable, "Enable Intel HD audio interface.");
135module_param_array(model, charp, NULL, 0444);

--- 18 unchanged lines hidden (view full) ---

154module_param_array(patch, charp, NULL, 0444);
155MODULE_PARM_DESC(patch, "Patch file for Intel HD audio interface.");
156#endif
157#ifdef CONFIG_SND_HDA_INPUT_BEEP
158module_param_array(beep_mode, bool, NULL, 0444);
159MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode "
160 "(0=off, 1=on) (default=1).");
161#endif
162module_param(dmic_detect, bool, 0444);
163MODULE_PARM_DESC(dmic_detect, "DMIC detect on SKL+ platforms");
162module_param(dsp_driver, bool, 0444);
163MODULE_PARM_DESC(dsp_driver, "Allow DSP driver selection (bypass this driver) "
164 "(0=off, 1=on) (default=1)");
164
165#ifdef CONFIG_PM
166static int param_set_xint(const char *val, const struct kernel_param *kp);
167static const struct kernel_param_ops param_ops_xint = {
168 .set = param_set_xint,
169 .get = param_get_int,
170};
171#define param_check_xint param_check_int

--- 1103 unchanged lines hidden (view full) ---

1275 chip->bus.keep_power = 0;
1276 setup_vga_switcheroo_runtime_pm(chip);
1277}
1278
1279static void init_vga_switcheroo(struct azx *chip)
1280{
1281 struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
1282 struct pci_dev *p = get_bound_vga(chip->pci);
165
166#ifdef CONFIG_PM
167static int param_set_xint(const char *val, const struct kernel_param *kp);
168static const struct kernel_param_ops param_ops_xint = {
169 .set = param_set_xint,
170 .get = param_get_int,
171};
172#define param_check_xint param_check_int

--- 1103 unchanged lines hidden (view full) ---

1276 chip->bus.keep_power = 0;
1277 setup_vga_switcheroo_runtime_pm(chip);
1278}
1279
1280static void init_vga_switcheroo(struct azx *chip)
1281{
1282 struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
1283 struct pci_dev *p = get_bound_vga(chip->pci);
1284 struct pci_dev *parent;
1283 if (p) {
1284 dev_info(chip->card->dev,
1285 "Handle vga_switcheroo audio client\n");
1286 hda->use_vga_switcheroo = 1;
1285 if (p) {
1286 dev_info(chip->card->dev,
1287 "Handle vga_switcheroo audio client\n");
1288 hda->use_vga_switcheroo = 1;
1287 chip->bus.keep_power = 1; /* cleared in either gpu_bound op or codec probe */
1289
1290 /* cleared in either gpu_bound op or codec probe, or when its
1291 * upstream port has _PR3 (i.e. dGPU).
1292 */
1293 parent = pci_upstream_bridge(p);
1294 chip->bus.keep_power = parent ? !pci_pr3_present(parent) : 1;
1288 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME;
1289 pci_dev_put(p);
1290 }
1291}
1292
1293static const struct vga_switcheroo_client_ops azx_vs_ops = {
1294 .set_gpu_state = azx_vs_set_state,
1295 .can_switch = azx_vs_can_switch,

--- 719 unchanged lines hidden (view full) ---

2015}
2016
2017static const struct hda_controller_ops pci_hda_ops = {
2018 .disable_msi_reset_irq = disable_msi_reset_irq,
2019 .pcm_mmap_prepare = pcm_mmap_prepare,
2020 .position_check = azx_position_check,
2021};
2022
1295 chip->driver_caps |= AZX_DCAPS_PM_RUNTIME;
1296 pci_dev_put(p);
1297 }
1298}
1299
1300static const struct vga_switcheroo_client_ops azx_vs_ops = {
1301 .set_gpu_state = azx_vs_set_state,
1302 .can_switch = azx_vs_can_switch,

--- 719 unchanged lines hidden (view full) ---

2022}
2023
2024static const struct hda_controller_ops pci_hda_ops = {
2025 .disable_msi_reset_irq = disable_msi_reset_irq,
2026 .pcm_mmap_prepare = pcm_mmap_prepare,
2027 .position_check = azx_position_check,
2028};
2029
2023static int azx_check_dmic(struct pci_dev *pci, struct azx *chip)
2024{
2025 struct nhlt_acpi_table *nhlt;
2026 int ret = 0;
2027
2028 if (chip->driver_type == AZX_DRIVER_SKL &&
2029 pci->class != 0x040300) {
2030 nhlt = intel_nhlt_init(&pci->dev);
2031 if (nhlt) {
2032 if (intel_nhlt_get_dmic_geo(&pci->dev, nhlt)) {
2033 ret = -ENODEV;
2034 dev_info(&pci->dev, "Digital mics found on Skylake+ platform, aborting probe\n");
2035 }
2036 intel_nhlt_free(nhlt);
2037 }
2038 }
2039 return ret;
2040}
2041
2042static int azx_probe(struct pci_dev *pci,
2043 const struct pci_device_id *pci_id)
2044{
2045 static int dev;
2046 struct snd_card *card;
2047 struct hda_intel *hda;
2048 struct azx *chip;
2049 bool schedule_probe;
2050 int err;
2051
2052 if (dev >= SNDRV_CARDS)
2053 return -ENODEV;
2054 if (!enable[dev]) {
2055 dev++;
2056 return -ENOENT;
2057 }
2058
2030static int azx_probe(struct pci_dev *pci,
2031 const struct pci_device_id *pci_id)
2032{
2033 static int dev;
2034 struct snd_card *card;
2035 struct hda_intel *hda;
2036 struct azx *chip;
2037 bool schedule_probe;
2038 int err;
2039
2040 if (dev >= SNDRV_CARDS)
2041 return -ENODEV;
2042 if (!enable[dev]) {
2043 dev++;
2044 return -ENOENT;
2045 }
2046
2047 /*
2048 * stop probe if another Intel's DSP driver should be activated
2049 */
2050 if (dsp_driver) {
2051 err = snd_intel_dsp_driver_probe(pci);
2052 if (err != SND_INTEL_DSP_DRIVER_ANY &&
2053 err != SND_INTEL_DSP_DRIVER_LEGACY)
2054 return -ENODEV;
2055 }
2056
2059 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2060 0, &card);
2061 if (err < 0) {
2062 dev_err(&pci->dev, "Error creating card!\n");
2063 return err;
2064 }
2065
2066 err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
2067 if (err < 0)
2068 goto out_free;
2069 card->private_data = chip;
2070 hda = container_of(chip, struct hda_intel, chip);
2071
2057 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2058 0, &card);
2059 if (err < 0) {
2060 dev_err(&pci->dev, "Error creating card!\n");
2061 return err;
2062 }
2063
2064 err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
2065 if (err < 0)
2066 goto out_free;
2067 card->private_data = chip;
2068 hda = container_of(chip, struct hda_intel, chip);
2069
2072 /*
2073 * stop probe if digital microphones detected on Skylake+ platform
2074 * with the DSP enabled. This is an opt-in behavior defined at build
2075 * time or at run-time with a module parameter
2076 */
2077 if (dmic_detect) {
2078 err = azx_check_dmic(pci, chip);
2079 if (err < 0)
2080 goto out_free;
2081 }
2082
2083 pci_set_drvdata(pci, card);
2084
2085 err = register_vga_switcheroo(chip);
2086 if (err < 0) {
2087 dev_err(card->dev, "Error registering vga_switcheroo client\n");
2088 goto out_free;
2089 }
2090

--- 303 unchanged lines hidden (view full) ---

2394 { PCI_DEVICE(0x8086, 0x02C8),
2395 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
2396 /* CometLake-H */
2397 { PCI_DEVICE(0x8086, 0x06C8),
2398 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
2399 /* Icelake */
2400 { PCI_DEVICE(0x8086, 0x34c8),
2401 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
2070 pci_set_drvdata(pci, card);
2071
2072 err = register_vga_switcheroo(chip);
2073 if (err < 0) {
2074 dev_err(card->dev, "Error registering vga_switcheroo client\n");
2075 goto out_free;
2076 }
2077

--- 303 unchanged lines hidden (view full) ---

2381 { PCI_DEVICE(0x8086, 0x02C8),
2382 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
2383 /* CometLake-H */
2384 { PCI_DEVICE(0x8086, 0x06C8),
2385 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
2386 /* Icelake */
2387 { PCI_DEVICE(0x8086, 0x34c8),
2388 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
2402 /* Jasperlake */
2403 { PCI_DEVICE(0x8086, 0x38c8),
2404 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
2405 /* Tigerlake */
2406 { PCI_DEVICE(0x8086, 0xa0c8),
2407 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
2408 /* Elkhart Lake */
2409 { PCI_DEVICE(0x8086, 0x4b55),
2410 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
2411 /* Broxton-P(Apollolake) */
2412 { PCI_DEVICE(0x8086, 0x5a98),
2413 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_BROXTON },
2414 /* Broxton-T */
2415 { PCI_DEVICE(0x8086, 0x1a98),

--- 232 unchanged lines hidden ---
2389 /* Elkhart Lake */
2390 { PCI_DEVICE(0x8086, 0x4b55),
2391 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
2392 /* Broxton-P(Apollolake) */
2393 { PCI_DEVICE(0x8086, 0x5a98),
2394 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_BROXTON },
2395 /* Broxton-T */
2396 { PCI_DEVICE(0x8086, 0x1a98),

--- 232 unchanged lines hidden ---