ALSA: hda: Modify stream stripe mask only when needed
PATCH 1/1 ALSA: hda: Modify stream stripe mask only when needed
The recent 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.
--- include/sound/hdaudio.h | 1 + sound/hda/hdac_stream.c | 19 ++++++++++++------- sound/pci/hda/patch_hdmi.c | 5 +++++ 3 files changed, 18 insertions(+), 7 deletions(-)
include/sound/hdaudio.h +1 -0
@@ -493,6 +493,7 @@ struct hdac_stream { bool prepared:1; bool no_period_wakeup:1; bool locked:1; + bool stripe:1; /* apply stripe control *//* timestamp */ unsigned long start_wallclk;/* start + minimum wallclk */
sound/hda/hdac_stream.c +12 -7
@@ -96,12 +96,14 @@ void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start)1 << azx_dev->index, 1 << azx_dev->index);/* set stripe control */ -if (azx_dev->substream) - stripe_ctl =snd_hdac_get_stream_stripe_ctl (bus, azx_dev->substream); -else - stripe_ctl =0 ; -snd_hdac_stream_updateb (azx_dev,SD_CTL_3B ,SD_CTL_STRIPE_MASK , - stripe_ctl); +if (azx_dev->stripe) { +if (azx_dev->substream) + stripe_ctl =snd_hdac_get_stream_stripe_ctl (bus, azx_dev->substream); +else + stripe_ctl =0 ; +snd_hdac_stream_updateb (azx_dev,SD_CTL_3B ,SD_CTL_STRIPE_MASK , + stripe_ctl); + }/* set DMA start and interrupt mask */ snd_hdac_stream_updateb (azx_dev,SD_CTL ,0 ,SD_CTL_DMA_START |SD_INT_MASK );
@@ -118,7 +120,10 @@ void snd_hdac_stream_clear(struct hdac_stream *azx_dev)snd_hdac_stream_updateb (azx_dev,SD_CTL ,SD_CTL_DMA_START |SD_INT_MASK ,0 );snd_hdac_stream_writeb (azx_dev,SD_STS ,SD_INT_MASK );/* to be sure */ -snd_hdac_stream_updateb (azx_dev,SD_CTL_3B ,SD_CTL_STRIPE_MASK ,0 ); +if (azx_dev->stripe) { +snd_hdac_stream_updateb (azx_dev,SD_CTL_3B ,SD_CTL_STRIPE_MASK ,0 ); + azx_dev->stripe =0 ; + } azx_dev->running = false; }EXPORT_SYMBOL_GPL (snd_hdac_stream_clear);
sound/pci/hda/patch_hdmi.c +5 -0
@@ -32,6 +32,7 @@#include <sound/hda_codec.h> #include "hda_local.h" #include "hda_jack.h" +#include "hda_controller.h" static bool static_hdmi_pcm;module_param (static_hdmi_pcm, bool,0644 );
@@ -1249,6 +1250,10 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, per_pin->cvt_nid = per_cvt->cvt_nid; hinfo->nid = per_cvt->cvt_nid; +/* flip stripe flag for the assigned stream if supported */ +if (get_wcaps (codec, per_cvt->cvt_nid) &AC_WCAP_STRIPE ) +azx_stream (get_azx_dev (substream))->stripe =1 ; +snd_hda_set_dev_select (codec, per_pin->pin_nid, per_pin->dev_id); snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, AC_VERB_SET_CONNECT_SEL,
Signature · 6 lines
2.16.4 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Hi there,
since i upgraded my gentoo system to kernel 5.4.3 the sound over hdmi is distorted, loud and seems to come only from one speaker. I checked the changes between 5.4.2 and 5.4.3 and as a shot in the dark, i reverted the commit e38e486d66e2a3b902768fd71c32dbf10f77e1cb, and the problem was gone.
I'll try to find out if the issue is on my system, but there is may something wrong with the condition which enables the stripe mask.
It would be really great if you could take a look into this issue again.
Kind regards
Martin
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 9 lines · Martin Regner
Hi there,
since i upgraded my gentoo system to kernel 5.4.3 the sound over hdmi is distorted, loud and seems to come only from one speaker. I checked the changes
between 5.4.2 and 5.4.3 and as a shot in the dark, i reverted the commite38e486d66e2a3b902768fd71c32dbf10f77e1cb, and the problem was gone.
Quoted 5 lines
I'll try to find out if the issue is on my system, but there is may something
wrong with the condition which enables the stripe mask.It would be really great if you could take a look into this issue again.
This should have been fixed by the patch below:
https://lore.kernel.org/r/[email protected]
It's already in my sound git tree.
Let me know if you still see the issue after this patch.
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Hi again,
i did a little bit of research and my current solution is this patch:
include/sound/hdaudio.h 2019-12-15 19:48:23.474688545 +0100 renamed from include/sound/hdaudio.h 2019-12-15 19:49:15.775689873 +0100 +0 -0
@@ -493,7 +493,7 @@
bool prepared:1;
bool no_period_wakeup:1;
bool locked:1;
- bool stripe:1; /* apply stripe control */ + bool stripe:0; /* apply stripe control */
/* timestamp */
unsigned long start_wallclk; /* start + minimum wallclk */
sound/hda/hdac_stream.c 2019-12-15 19:15:48.976584590 +0100 renamed from sound/hda/hdac_stream.c 2019-12-15 19:15:37.512583523 +0100 +0 -0
@@ -122,7 +122,6 @@
snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */ if (azx_dev->stripe) {
snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0); - azx_dev->stripe = 0;
}
azx_dev->running = false;
}
I don't really understand the approach in the original commit. As far as i understand this, the stripe property is initially set to 1. In the patch_hdmi.c it is set to 1 if the AC_WCAP_STRIPE flag is set. Finally it is set to 0 in the function snd_hdac_stream_clear.
With this patch the stripe property is initially 0, set to 1 if the AC_WCAP_STRIPE flag is set and never touched again.
Unfortunatly i can't test this on another machine.
Kind regards
Martin
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Sorry, the patch below did not compile. The working version is just this:
sound/hda/hdac_stream.c 2019-12-15 19:15:48.976584590 +0100 renamed from sound/hda/hdac_stream.c 2019-12-15 19:15:37.512583523 +0100 +0 -0
@@ -122,7 +122,6 @@
snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */ if (azx_dev->stripe) {
snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0); - azx_dev->stripe = 0;
}
azx_dev->running = false;
}
Sorry for bothering.
Quoted 32 lines · Martin Regner
Hi again,
i did a little bit of research and my current solution is this patch:
diff -ru
a/include/sound/hdaudio.hb/include/sound/hdaudio.hinclude/sound/hdaudio.h 2019-12-15 19:48:23.474688545 +0100 renamed from include/sound/hdaudio.h 2019-12-15 19:49:15.775689873 +0100 +1
-1@@ -493,7 +493,7 @@ bool prepared:1; bool no_period_wakeup:1; bool locked:1; - bool stripe:1; /* apply stripe control */ + bool stripe:0; /* apply stripe control */ /* timestamp */unsigned long start_wallclk; /* start + minimum wallclk */ diff -ru
a/sound/hda/hdac_stream.cb/sound/hda/hdac_stream.csound/hda/hdac_stream.c 2019-12-15 19:15:48.976584590 +0100 renamed from sound/hda/hdac_stream.c 2019-12-15 19:15:37.512583523 +0100 +0
-0@@ -122,7 +122,6 @@
snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */ if (azx_dev->stripe) {
snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0); -azx_dev->stripe= 0;
}
azx_dev->running= false;
}I don't really understand the approach in the original commit. As far as i understand this, the stripe property is initially set to 1. In the
patch_hdmi.cit is set to 1 if theAC_WCAP_STRIPEflag is set. Finally it is set to 0 in the functionsnd_hdac_stream_clear.
Quoted 8 lines
With this patch the stripe property is initially 0, set to 1 if the
AC_WCAP_STRIPEflag is set and never touched again.Unfortunatly i can't test this on another machine.
Kind regards
Martin
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel