Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.72 KB | None | 0 0
  1. diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
  2. index 2fbdde239936..48d863736b3c 100644
  3. --- a/sound/pci/hda/hda_controller.c
  4. +++ b/sound/pci/hda/hda_controller.c
  5. @@ -613,6 +613,13 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
  6. 20,
  7. 178000000);
  8.  
  9. + /* by some reason, the playback stream stalls on PulseAudio with
  10. + * tsched=1 when a capture stream triggers. Until we figure out the
  11. + * real cause, disable tsched mode by telling the PCM info flag.
  12. + */
  13. + if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND)
  14. + runtime->hw.info |= SNDRV_PCM_INFO_BATCH;
  15. +
  16. if (chip->align_buffer_size)
  17. /* constrain buffer sizes to be multiple of 128
  18. bytes. This is more efficient in terms of memory
  19. diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h
  20. index baa15374fbcb..f2a6df5e6bcb 100644
  21. --- a/sound/pci/hda/hda_controller.h
  22. +++ b/sound/pci/hda/hda_controller.h
  23. @@ -31,7 +31,7 @@
  24. /* 14 unused */
  25. #define AZX_DCAPS_CTX_WORKAROUND (1 << 15) /* X-Fi workaround */
  26. #define AZX_DCAPS_POSFIX_LPIB (1 << 16) /* Use LPIB as default */
  27. -/* 17 unused */
  28. +#define AZX_DCAPS_AMD_WORKAROUND (1 << 17) /* AMD-specific workaround */
  29. #define AZX_DCAPS_NO_64BIT (1 << 18) /* No 64bit address */
  30. #define AZX_DCAPS_SYNC_WRITE (1 << 19) /* sync each cmd write */
  31. #define AZX_DCAPS_OLD_SSYNC (1 << 20) /* Old SSYNC reg for ICH */
  32. diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
  33. index 1e14d7270adf..a6d8c0d77b84 100644
  34. --- a/sound/pci/hda/hda_intel.c
  35. +++ b/sound/pci/hda/hda_intel.c
  36. @@ -64,6 +64,7 @@ enum {
  37. POS_FIX_VIACOMBO,
  38. POS_FIX_COMBO,
  39. POS_FIX_SKL,
  40. + POS_FIX_FIFO,
  41. };
  42.  
  43. /* Defines for ATI HD Audio support in SB450 south bridge */
  44. @@ -135,7 +136,7 @@ module_param_array(model, charp, NULL, 0444);
  45. MODULE_PARM_DESC(model, "Use the given board model.");
  46. module_param_array(position_fix, int, NULL, 0444);
  47. MODULE_PARM_DESC(position_fix, "DMA pointer read method."
  48. - "(-1 = system default, 0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO, 4 = COMBO, 5 = SKL+).");
  49. + "(-1 = system default, 0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO, 4 = COMBO, 5 = SKL+, 6 = FIFO).");
  50. module_param_array(bdl_pos_adj, int, NULL, 0644);
  51. MODULE_PARM_DESC(bdl_pos_adj, "BDL position adjustment offset.");
  52. module_param_array(probe_mask, int, NULL, 0444);
  53. @@ -332,6 +333,11 @@ enum {
  54. #define AZX_DCAPS_PRESET_ATI_HDMI_NS \
  55. (AZX_DCAPS_PRESET_ATI_HDMI | AZX_DCAPS_SNOOP_OFF)
  56.  
  57. +/* quirks for AMD SB */
  58. +#define AZX_DCAPS_PRESET_AMD_SB \
  59. + (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_AMD_WORKAROUND |\
  60. + AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME)
  61. +
  62. /* quirks for Nvidia */
  63. #define AZX_DCAPS_PRESET_NVIDIA \
  64. (AZX_DCAPS_NO_MSI | AZX_DCAPS_CORBRP_SELF_CLEAR |\
  65. @@ -841,6 +847,49 @@ static unsigned int azx_via_get_position(struct azx *chip,
  66. return bound_pos + mod_dma_pos;
  67. }
  68.  
  69. +#define AMD_FIFO_SIZE 32
  70. +
  71. +/* get the current DMA position with FIFO size correction */
  72. +static unsigned int azx_get_pos_fifo(struct azx *chip, struct azx_dev *azx_dev)
  73. +{
  74. + struct snd_pcm_substream *substream = azx_dev->core.substream;
  75. + struct snd_pcm_runtime *runtime = substream->runtime;
  76. + unsigned int pos, delay;
  77. +
  78. + pos = snd_hdac_stream_get_pos_lpib(azx_stream(azx_dev));
  79. + if (!runtime)
  80. + return pos;
  81. +
  82. + runtime->delay = AMD_FIFO_SIZE;
  83. + delay = frames_to_bytes(runtime, AMD_FIFO_SIZE);
  84. + if (azx_dev->insufficient) {
  85. + if (pos < delay) {
  86. + delay = pos;
  87. + runtime->delay = bytes_to_frames(runtime, pos);
  88. + } else {
  89. + azx_dev->insufficient = 0;
  90. + }
  91. + }
  92. +
  93. + /* correct the DMA position for capture stream */
  94. + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  95. + if (pos < delay)
  96. + pos += azx_dev->core.bufsize;
  97. + pos -= delay;
  98. + }
  99. +
  100. + return pos;
  101. +}
  102. +
  103. +static int azx_get_delay_from_fifo(struct azx *chip, struct azx_dev *azx_dev,
  104. + unsigned int pos)
  105. +{
  106. + struct snd_pcm_substream *substream = azx_dev->core.substream;
  107. +
  108. + /* just read back the calculated value in the above */
  109. + return substream->runtime->delay;
  110. +}
  111. +
  112. static unsigned int azx_skl_get_dpib_pos(struct azx *chip,
  113. struct azx_dev *azx_dev)
  114. {
  115. @@ -1417,6 +1466,7 @@ static int check_position_fix(struct azx *chip, int fix)
  116. case POS_FIX_VIACOMBO:
  117. case POS_FIX_COMBO:
  118. case POS_FIX_SKL:
  119. + case POS_FIX_FIFO:
  120. return fix;
  121. }
  122.  
  123. @@ -1433,6 +1483,10 @@ static int check_position_fix(struct azx *chip, int fix)
  124. dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n");
  125. return POS_FIX_VIACOMBO;
  126. }
  127. + if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) {
  128. + dev_dbg(chip->card->dev, "Using FIFO position fix\n");
  129. + return POS_FIX_FIFO;
  130. + }
  131. if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) {
  132. dev_dbg(chip->card->dev, "Using LPIB position fix\n");
  133. return POS_FIX_LPIB;
  134. @@ -1453,6 +1507,7 @@ static void assign_position_fix(struct azx *chip, int fix)
  135. [POS_FIX_VIACOMBO] = azx_via_get_position,
  136. [POS_FIX_COMBO] = azx_get_pos_lpib,
  137. [POS_FIX_SKL] = azx_get_pos_skl,
  138. + [POS_FIX_FIFO] = azx_get_pos_fifo,
  139. };
  140.  
  141. chip->get_position[0] = chip->get_position[1] = callbacks[fix];
  142. @@ -1467,6 +1522,9 @@ static void assign_position_fix(struct azx *chip, int fix)
  143. azx_get_delay_from_lpib;
  144. }
  145.  
  146. + if (fix == POS_FIX_FIFO)
  147. + chip->get_delay[0] = chip->get_delay[1] =
  148. + azx_get_delay_from_fifo;
  149. }
  150.  
  151. /*
  152. @@ -2447,6 +2508,12 @@ static const struct pci_device_id azx_ids[] = {
  153. /* AMD Hudson */
  154. { PCI_DEVICE(0x1022, 0x780d),
  155. .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB },
  156. + /* AMD, X370 & co */
  157. + { PCI_DEVICE(0x1022, 0x1457),
  158. + .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_AMD_SB },
  159. + /* AMD, X570 & co */
  160. + { PCI_DEVICE(0x1022, 0x1487),
  161. + .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_AMD_SB },
  162. /* AMD Stoney */
  163. { PCI_DEVICE(0x1022, 0x157a),
  164. .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement