aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-11-25 05:28:07 -0500
committerTakashi Iwai <tiwai@suse.de>2014-11-28 02:47:28 -0500
commit37e661ee10c6d0d1310c62b3d29ae9a63073ac5d (patch)
tree7e4d170a18685cc15dc8a7942dcb0fd00bb3a905 /sound/pci
parentacf403ecc4155153e5e2c1640be90fc166e56ba7 (diff)
ALSA: hda - Add AZX_DCAPS_SNOOP_OFF (and refactor snoop setup)
Add a new driver_caps bit, AZX_DCAPS_SNOOP_OFF, to set the snoop off as default. This new bit is used for the checks in azx_check_snoop_available(). Most of case-switches are replaced with the new dcaps in each entry. While working on it, for avoiding to spend more bits, combine three bits AZX_DCAPS_SNOOP_SCH, AZX_DCAPS_SNOOP_ATI and AZX_DCAPS_SNOOP_NVIDIA bits into a flat type of two bits. This reduces the bits usages, and assign AZX_DCAPS_OFF to this empty bit now. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_intel.c71
-rw-r--r--sound/pci/hda/hda_priv.h12
2 files changed, 47 insertions, 36 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 966e6f98892d..633020de9bd2 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -272,42 +272,51 @@ enum {
272 AZX_NUM_DRIVERS, /* keep this as last entry */ 272 AZX_NUM_DRIVERS, /* keep this as last entry */
273}; 273};
274 274
275#define azx_get_snoop_type(chip) \
276 (((chip)->driver_caps & AZX_DCAPS_SNOOP_MASK) >> 10)
277#define AZX_DCAPS_SNOOP_TYPE(type) ((AZX_SNOOP_TYPE_ ## type) << 10)
278
275/* quirks for Intel PCH */ 279/* quirks for Intel PCH */
276#define AZX_DCAPS_INTEL_PCH_NOPM \ 280#define AZX_DCAPS_INTEL_PCH_NOPM \
277 (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_BUFSIZE | \ 281 (AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY |\
278 AZX_DCAPS_COUNT_LPIB_DELAY | AZX_DCAPS_REVERSE_ASSIGN) 282 AZX_DCAPS_REVERSE_ASSIGN | AZX_DCAPS_SNOOP_TYPE(SCH))
279 283
280#define AZX_DCAPS_INTEL_PCH \ 284#define AZX_DCAPS_INTEL_PCH \
281 (AZX_DCAPS_INTEL_PCH_NOPM | AZX_DCAPS_PM_RUNTIME) 285 (AZX_DCAPS_INTEL_PCH_NOPM | AZX_DCAPS_PM_RUNTIME)
282 286
283#define AZX_DCAPS_INTEL_HASWELL \ 287#define AZX_DCAPS_INTEL_HASWELL \
284 (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_ALIGN_BUFSIZE | \ 288 (AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY |\
285 AZX_DCAPS_COUNT_LPIB_DELAY | AZX_DCAPS_PM_RUNTIME | \ 289 AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_POWERWELL |\
286 AZX_DCAPS_I915_POWERWELL) 290 AZX_DCAPS_SNOOP_TYPE(SCH))
287 291
288/* Broadwell HDMI can't use position buffer reliably, force to use LPIB */ 292/* Broadwell HDMI can't use position buffer reliably, force to use LPIB */
289#define AZX_DCAPS_INTEL_BROADWELL \ 293#define AZX_DCAPS_INTEL_BROADWELL \
290 (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_ALIGN_BUFSIZE | \ 294 (AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_POSFIX_LPIB |\
291 AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_PM_RUNTIME | \ 295 AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_POWERWELL |\
292 AZX_DCAPS_I915_POWERWELL) 296 AZX_DCAPS_SNOOP_TYPE(SCH))
293 297
294/* quirks for ATI SB / AMD Hudson */ 298/* quirks for ATI SB / AMD Hudson */
295#define AZX_DCAPS_PRESET_ATI_SB \ 299#define AZX_DCAPS_PRESET_ATI_SB \
296 (AZX_DCAPS_ATI_SNOOP | AZX_DCAPS_NO_TCSEL | \ 300 (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB |\
297 AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB) 301 AZX_DCAPS_SNOOP_TYPE(ATI))
298 302
299/* quirks for ATI/AMD HDMI */ 303/* quirks for ATI/AMD HDMI */
300#define AZX_DCAPS_PRESET_ATI_HDMI \ 304#define AZX_DCAPS_PRESET_ATI_HDMI \
301 (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB) 305 (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB)
302 306
307/* quirks for ATI HDMI with snoop off */
308#define AZX_DCAPS_PRESET_ATI_HDMI_NS \
309 (AZX_DCAPS_PRESET_ATI_HDMI | AZX_DCAPS_SNOOP_OFF)
310
303/* quirks for Nvidia */ 311/* quirks for Nvidia */
304#define AZX_DCAPS_PRESET_NVIDIA \ 312#define AZX_DCAPS_PRESET_NVIDIA \
305 (AZX_DCAPS_NVIDIA_SNOOP | AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI |\ 313 (AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI | AZX_DCAPS_ALIGN_BUFSIZE |\
306 AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_NO_64BIT |\ 314 AZX_DCAPS_NO_64BIT | AZX_DCAPS_CORBRP_SELF_CLEAR |\
307 AZX_DCAPS_CORBRP_SELF_CLEAR) 315 AZX_DCAPS_SNOOP_TYPE(NVIDIA))
308 316
309#define AZX_DCAPS_PRESET_CTHDA \ 317#define AZX_DCAPS_PRESET_CTHDA \
310 (AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY) 318 (AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB |\
319 AZX_DCAPS_4K_BDLE_BOUNDARY | AZX_DCAPS_SNOOP_OFF)
311 320
312/* 321/*
313 * VGA-switcher support 322 * VGA-switcher support
@@ -436,6 +445,8 @@ static void update_pci_byte(struct pci_dev *pci, unsigned int reg,
436 445
437static void azx_init_pci(struct azx *chip) 446static void azx_init_pci(struct azx *chip)
438{ 447{
448 int snoop_type = azx_get_snoop_type(chip);
449
439 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) 450 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
440 * TCSEL == Traffic Class Select Register, which sets PCI express QOS 451 * TCSEL == Traffic Class Select Register, which sets PCI express QOS
441 * Ensuring these bits are 0 clears playback static on some HD Audio 452 * Ensuring these bits are 0 clears playback static on some HD Audio
@@ -450,7 +461,7 @@ static void azx_init_pci(struct azx *chip)
450 /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio, 461 /* For ATI SB450/600/700/800/900 and AMD Hudson azalia HD audio,
451 * we need to enable snoop. 462 * we need to enable snoop.
452 */ 463 */
453 if (chip->driver_caps & AZX_DCAPS_ATI_SNOOP) { 464 if (snoop_type == AZX_SNOOP_TYPE_ATI) {
454 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n", 465 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n",
455 azx_snoop(chip)); 466 azx_snoop(chip));
456 update_pci_byte(chip->pci, 467 update_pci_byte(chip->pci,
@@ -459,7 +470,7 @@ static void azx_init_pci(struct azx *chip)
459 } 470 }
460 471
461 /* For NVIDIA HDA, enable snoop */ 472 /* For NVIDIA HDA, enable snoop */
462 if (chip->driver_caps & AZX_DCAPS_NVIDIA_SNOOP) { 473 if (snoop_type == AZX_SNOOP_TYPE_NVIDIA) {
463 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n", 474 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n",
464 azx_snoop(chip)); 475 azx_snoop(chip));
465 update_pci_byte(chip->pci, 476 update_pci_byte(chip->pci,
@@ -474,7 +485,7 @@ static void azx_init_pci(struct azx *chip)
474 } 485 }
475 486
476 /* Enable SCH/PCH snoop if needed */ 487 /* Enable SCH/PCH snoop if needed */
477 if (chip->driver_caps & AZX_DCAPS_SCH_SNOOP) { 488 if (snoop_type == AZX_SNOOP_TYPE_SCH) {
478 unsigned short snoop; 489 unsigned short snoop;
479 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); 490 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop);
480 if ((!azx_snoop(chip) && !(snoop & INTEL_SCH_HDA_DEVC_NOSNOOP)) || 491 if ((!azx_snoop(chip) && !(snoop & INTEL_SCH_HDA_DEVC_NOSNOOP)) ||
@@ -1361,8 +1372,8 @@ static void azx_check_snoop_available(struct azx *chip)
1361{ 1372{
1362 bool snoop = chip->snoop; 1373 bool snoop = chip->snoop;
1363 1374
1364 switch (chip->driver_type) { 1375 if (azx_get_snoop_type(chip) == AZX_SNOOP_TYPE_NONE &&
1365 case AZX_DRIVER_VIA: 1376 chip->driver_type == AZX_DRIVER_VIA) {
1366 /* force to non-snoop mode for a new VIA controller 1377 /* force to non-snoop mode for a new VIA controller
1367 * when BIOS is set 1378 * when BIOS is set
1368 */ 1379 */
@@ -1372,17 +1383,11 @@ static void azx_check_snoop_available(struct azx *chip)
1372 if (!(val & 0x80) && chip->pci->revision == 0x30) 1383 if (!(val & 0x80) && chip->pci->revision == 0x30)
1373 snoop = false; 1384 snoop = false;
1374 } 1385 }
1375 break;
1376 case AZX_DRIVER_ATIHDMI_NS:
1377 /* new ATI HDMI requires non-snoop */
1378 snoop = false;
1379 break;
1380 case AZX_DRIVER_CTHDA:
1381 case AZX_DRIVER_CMEDIA:
1382 snoop = false;
1383 break;
1384 } 1386 }
1385 1387
1388 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF)
1389 snoop = false;
1390
1386 if (snoop != chip->snoop) { 1391 if (snoop != chip->snoop) {
1387 dev_info(chip->card->dev, "Force to %s mode\n", 1392 dev_info(chip->card->dev, "Force to %s mode\n",
1388 snoop ? "snoop" : "non-snoop"); 1393 snoop ? "snoop" : "non-snoop");
@@ -2116,13 +2121,13 @@ static const struct pci_device_id azx_ids[] = {
2116 { PCI_DEVICE(0x1002, 0xaa98), 2121 { PCI_DEVICE(0x1002, 0xaa98),
2117 .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, 2122 .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI },
2118 { PCI_DEVICE(0x1002, 0x9902), 2123 { PCI_DEVICE(0x1002, 0x9902),
2119 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI }, 2124 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
2120 { PCI_DEVICE(0x1002, 0xaaa0), 2125 { PCI_DEVICE(0x1002, 0xaaa0),
2121 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI }, 2126 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
2122 { PCI_DEVICE(0x1002, 0xaaa8), 2127 { PCI_DEVICE(0x1002, 0xaaa8),
2123 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI }, 2128 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
2124 { PCI_DEVICE(0x1002, 0xaab0), 2129 { PCI_DEVICE(0x1002, 0xaab0),
2125 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI }, 2130 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
2126 /* VIA VT8251/VT8237A */ 2131 /* VIA VT8251/VT8237A */
2127 { PCI_DEVICE(0x1106, 0x3288), 2132 { PCI_DEVICE(0x1106, 0x3288),
2128 .driver_data = AZX_DRIVER_VIA | AZX_DCAPS_POSFIX_VIA }, 2133 .driver_data = AZX_DRIVER_VIA | AZX_DCAPS_POSFIX_VIA },
@@ -2169,7 +2174,7 @@ static const struct pci_device_id azx_ids[] = {
2169 /* CM8888 */ 2174 /* CM8888 */
2170 { PCI_DEVICE(0x13f6, 0x5011), 2175 { PCI_DEVICE(0x13f6, 0x5011),
2171 .driver_data = AZX_DRIVER_CMEDIA | 2176 .driver_data = AZX_DRIVER_CMEDIA |
2172 AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB }, 2177 AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_SNOOP_OFF },
2173 /* Vortex86MX */ 2178 /* Vortex86MX */
2174 { PCI_DEVICE(0x17f3, 0x3010), .driver_data = AZX_DRIVER_GENERIC }, 2179 { PCI_DEVICE(0x17f3, 0x3010), .driver_data = AZX_DRIVER_GENERIC },
2175 /* VMware HDAudio */ 2180 /* VMware HDAudio */
diff --git a/sound/pci/hda/hda_priv.h b/sound/pci/hda/hda_priv.h
index 949cd437eeb2..602536c2147d 100644
--- a/sound/pci/hda/hda_priv.h
+++ b/sound/pci/hda/hda_priv.h
@@ -152,9 +152,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
152/* bits 0-7 are used for indicating driver type */ 152/* bits 0-7 are used for indicating driver type */
153#define AZX_DCAPS_NO_TCSEL (1 << 8) /* No Intel TCSEL bit */ 153#define AZX_DCAPS_NO_TCSEL (1 << 8) /* No Intel TCSEL bit */
154#define AZX_DCAPS_NO_MSI (1 << 9) /* No MSI support */ 154#define AZX_DCAPS_NO_MSI (1 << 9) /* No MSI support */
155#define AZX_DCAPS_ATI_SNOOP (1 << 10) /* ATI snoop enable */ 155#define AZX_DCAPS_SNOOP_MASK (3 << 10) /* snoop type mask */
156#define AZX_DCAPS_NVIDIA_SNOOP (1 << 11) /* Nvidia snoop enable */ 156#define AZX_DCAPS_SNOOP_OFF (1 << 12) /* snoop default off */
157#define AZX_DCAPS_SCH_SNOOP (1 << 12) /* SCH/PCH snoop enable */
158#define AZX_DCAPS_RIRB_DELAY (1 << 13) /* Long delay in read loop */ 157#define AZX_DCAPS_RIRB_DELAY (1 << 13) /* Long delay in read loop */
159#define AZX_DCAPS_RIRB_PRE_DELAY (1 << 14) /* Put a delay before read */ 158#define AZX_DCAPS_RIRB_PRE_DELAY (1 << 14) /* Put a delay before read */
160#define AZX_DCAPS_CTX_WORKAROUND (1 << 15) /* X-Fi workaround */ 159#define AZX_DCAPS_CTX_WORKAROUND (1 << 15) /* X-Fi workaround */
@@ -172,6 +171,13 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
172#define AZX_DCAPS_I915_POWERWELL (1 << 27) /* HSW i915 powerwell support */ 171#define AZX_DCAPS_I915_POWERWELL (1 << 27) /* HSW i915 powerwell support */
173#define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28) /* CORBRP clears itself after reset */ 172#define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28) /* CORBRP clears itself after reset */
174 173
174enum {
175 AZX_SNOOP_TYPE_NONE ,
176 AZX_SNOOP_TYPE_SCH,
177 AZX_SNOOP_TYPE_ATI,
178 AZX_SNOOP_TYPE_NVIDIA,
179};
180
175/* HD Audio class code */ 181/* HD Audio class code */
176#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403 182#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
177 183