Skip to content

Commit e38e486

Browse files
committed
ALSA: hda: Modify stream stripe mask only when needed
The recent commit in HD-audio stream management for changing the stripe control seems causing a regression on some platforms. The stripe control is currently used only by HDMI codec, and applying the stripe mask unconditionally may lead to scratchy and static noises as seen on some MacBooks. For addressing the regression, this patch changes the stream management code to apply the stripe mask conditionally only when the codec driver requested. Fixes: 9b6f7e7 ("ALSA: hda: program stripe bits for controller") BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204477 Tested-by: Michael Pobega <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent d2cd795 commit e38e486

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

include/sound/hdaudio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ struct hdac_stream {
493493
bool prepared:1;
494494
bool no_period_wakeup:1;
495495
bool locked:1;
496+
bool stripe:1; /* apply stripe control */
496497

497498
/* timestamp */
498499
unsigned long start_wallclk; /* start + minimum wallclk */

sound/hda/hdac_stream.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,14 @@ void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start)
9696
1 << azx_dev->index,
9797
1 << azx_dev->index);
9898
/* set stripe control */
99-
if (azx_dev->substream)
100-
stripe_ctl = snd_hdac_get_stream_stripe_ctl(bus, azx_dev->substream);
101-
else
102-
stripe_ctl = 0;
103-
snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK,
104-
stripe_ctl);
99+
if (azx_dev->stripe) {
100+
if (azx_dev->substream)
101+
stripe_ctl = snd_hdac_get_stream_stripe_ctl(bus, azx_dev->substream);
102+
else
103+
stripe_ctl = 0;
104+
snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK,
105+
stripe_ctl);
106+
}
105107
/* set DMA start and interrupt mask */
106108
snd_hdac_stream_updateb(azx_dev, SD_CTL,
107109
0, SD_CTL_DMA_START | SD_INT_MASK);
@@ -118,7 +120,10 @@ void snd_hdac_stream_clear(struct hdac_stream *azx_dev)
118120
snd_hdac_stream_updateb(azx_dev, SD_CTL,
119121
SD_CTL_DMA_START | SD_INT_MASK, 0);
120122
snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
121-
snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0);
123+
if (azx_dev->stripe) {
124+
snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0);
125+
azx_dev->stripe = 0;
126+
}
122127
azx_dev->running = false;
123128
}
124129
EXPORT_SYMBOL_GPL(snd_hdac_stream_clear);

sound/pci/hda/patch_hdmi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <sound/hda_codec.h>
3333
#include "hda_local.h"
3434
#include "hda_jack.h"
35+
#include "hda_controller.h"
3536

3637
static bool static_hdmi_pcm;
3738
module_param(static_hdmi_pcm, bool, 0644);
@@ -1249,6 +1250,10 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
12491250
per_pin->cvt_nid = per_cvt->cvt_nid;
12501251
hinfo->nid = per_cvt->cvt_nid;
12511252

1253+
/* flip stripe flag for the assigned stream if supported */
1254+
if (get_wcaps(codec, per_cvt->cvt_nid) & AC_WCAP_STRIPE)
1255+
azx_stream(get_azx_dev(substream))->stripe = 1;
1256+
12521257
snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id);
12531258
snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0,
12541259
AC_VERB_SET_CONNECT_SEL,

0 commit comments

Comments
 (0)