Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] Distorted sound over HDMI with kernel-5.4.3
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 253

PostPosted: Sun Dec 15, 2019 4:10 pm    Post subject: [solved] Distorted sound over HDMI with kernel-5.4.3 Reply with quote

Hi there,

since i updated to kernel-5.4.3 (gentoo-sources) the sound coming over hdmi is distorted, loud and comes just from on speaker.
I did a little investigation in the kernel changes between 5.4.2 and 5.4.3, and found the commit e38e486d66e2a3b902768fd71c32dbf10f77e1cb.

As a shot in the dark i created a patch which reverted this commit and the problem was gone.
I'll try to reply to this patch to find out whats going wrong here.

Since then here is the patch i put into /etc/portage/patches/sys-kernel/gentoo-sources-5.4.3/hdmi-strip.patch, just in case someone trip over the same problem.
Code:

diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index e05b95e83d5a..b260c5fd2337 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -493,7 +493,6 @@ 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 */
diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c
index f9707fb05efe..d8fe7ff0cd58 100644
--- a/sound/hda/hdac_stream.c
+++ b/sound/hda/hdac_stream.c
@@ -96,14 +96,12 @@ 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->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);
-       }
+       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);
@@ -120,10 +118,7 @@ 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 */
-       if (azx_dev->stripe) {
-               snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0);
-               azx_dev->stripe = 0;
-       }
+       snd_hdac_stream_updateb(azx_dev, SD_CTL_3B, SD_CTL_STRIPE_MASK, 0);
        azx_dev->running = false;
 }
 EXPORT_SYMBOL_GPL(snd_hdac_stream_clear);
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 78647ee02339..8e7e773b6518 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -32,7 +32,6 @@
 #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);
@@ -1250,10 +1249,6 @@ 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,

_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.


Last edited by donmartio on Mon Dec 16, 2019 7:09 pm; edited 1 time in total
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 253

PostPosted: Sun Dec 15, 2019 6:33 pm    Post subject: Reply with quote

After a little bit of research the patch boiled down to the following:

Code:

--- a/sound/hda/hdac_stream.c   2019-12-15 19:15:37.512583523 +0100
+++ b/sound/hda/hdac_stream.c   2019-12-15 19:15:48.976584590 +0100
@@ -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;
 }


Update: had to remove the patch of the hdaudio.h since this wont compile.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.


Last edited by donmartio on Sun Dec 15, 2019 7:08 pm; edited 1 time in total
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 253

PostPosted: Sun Dec 15, 2019 7:04 pm    Post subject: Reply with quote

So my explanation is this. The stripe property was initially set to 1 and set to 0 in the function snd_hdac_stream_clear.
With this patch the property is set to 1 if the AC_WCAP_STRIPE flag is set and never touched again.

I can't test this on another machine.

After all since nobody has issues with this, there is maybe something else wrong with my machine/config.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
papas
Tux's lil' helper
Tux's lil' helper


Joined: 01 Dec 2014
Posts: 115
Location: Athens

PostPosted: Sun Dec 15, 2019 7:12 pm    Post subject: Reply with quote

same problem for me, my solution was to revert all the patches for " /sound/hda" and "/sound/pci" files.
Thank you for your explanation. :D
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 253

PostPosted: Sun Dec 15, 2019 10:53 pm    Post subject: Reply with quote

I got an answer from the dev, he already fixed that yesterday. I adjusted my patch according to his changes:

Code:

diff -ru a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c
--- a/sound/hda/hdac_stream.c   2019-12-15 19:15:37.512583523 +0100
+++ b/sound/hda/hdac_stream.c   2019-12-15 21:36:32.786855989 +0100
@@ -120,10 +120,8 @@
    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 */
-   if (azx_dev->stripe) {
+   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);
diff -ru a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
--- a/sound/pci/hda/patch_hdmi.c    2019-12-15 21:37:39.791854848 +0100
+++ b/sound/pci/hda/patch_hdmi.c    2019-12-15 22:01:29.397830504 +0100
@@ -1983,6 +1983,8 @@
        per_cvt->assigned = 0;
        hinfo->nid = 0;

+       azx_stream(get_azx_dev(substream))->stripe = 0;
+
        mutex_lock(&spec->pcm_lock);
        snd_hda_spdif_ctls_unassign(codec, pcm_idx);
        clear_bit(pcm_idx, &spec->pcm_in_use);


_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
rommel
Veteran
Veteran


Joined: 19 Apr 2002
Posts: 1145
Location: Williamsburg Virginia

PostPosted: Mon Dec 16, 2019 11:27 am    Post subject: Reply with quote

how was this fixed? for next kernel update? can you post complete patch that applied and compiled for you
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 253

PostPosted: Mon Dec 16, 2019 5:03 pm    Post subject: Reply with quote

The above patch is the one i have applied on my system.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
papas
Tux's lil' helper
Tux's lil' helper


Joined: 01 Dec 2014
Posts: 115
Location: Athens

PostPosted: Wed Dec 18, 2019 7:03 am    Post subject: Reply with quote

kernel 5.4.4 still exist the problem
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 539

PostPosted: Wed Dec 18, 2019 7:22 am    Post subject: Reply with quote

Yeah, 5.4.4 had no change regarding this. It's "apparently" set to be merged in 5.5-rc3 and will likely end up in 5.4.5 whenever that releases. 5.4.4 came out too early to get it I guess.

While waiting, the patch (from post #5 or here) still applies cleanly given nothing in those files changed since 5.4.3 (if anyone in doubt, just stick to the working as-is 5.4.2 for now).

Edit: 5.4.5 came out earlier than I thought, and situation seem unchanged (as-in, doesn't look fixed and patch should still work).


Last edited by Ionen on Thu Dec 19, 2019 2:45 am; edited 1 time in total
Back to top
View user's profile Send private message
papas
Tux's lil' helper
Tux's lil' helper


Joined: 01 Dec 2014
Posts: 115
Location: Athens

PostPosted: Wed Dec 18, 2019 7:39 am    Post subject: Reply with quote

worked, thank you
Back to top
View user's profile Send private message
rommel
Veteran
Veteran


Joined: 19 Apr 2002
Posts: 1145
Location: Williamsburg Virginia

PostPosted: Wed Dec 18, 2019 12:11 pm    Post subject: Reply with quote

thanks for the link lonen, that patch applied and compiled cleanly and sound in 5.4.4 is working properly

[edit] so this is still the case with 5.4.5 but the patch applies and sound is working with it
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 539

PostPosted: Sat Dec 21, 2019 4:31 pm    Post subject: Reply with quote

It's fixed in 5.4.6.
Back to top
View user's profile Send private message
RayDude
Veteran
Veteran


Joined: 29 May 2004
Posts: 1558
Location: San Jose, CA

PostPosted: Wed Jan 01, 2020 7:40 pm    Post subject: Reply with quote

Is anyone having problems with pulse crashing when driving HDMI audio?

It dies for me periodically (several times a day) and I have to restart pulse with pulseaudio -k.
_________________
Some day there will only be free software.
Back to top
View user's profile Send private message
Anton Gubarkov
n00b
n00b


Joined: 13 Mar 2008
Posts: 52

PostPosted: Fri Jan 03, 2020 2:28 pm    Post subject: Reply with quote

I also experience this on 5.3.18. Apparently some patches from 5.4 were backported. However I don't have hdac_* files in sound/pci/hda to patch.

clean 5.3 doesn't have the problem. Can you share how you came down to the commit to blame? I have troubles starting the bisect since I can't run 5.4 on my machine (I have root on ZFS) and 5.3.18 is not a tag in the kernel git tree.
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 539

PostPosted: Fri Jan 03, 2020 2:55 pm    Post subject: Reply with quote

Are you sure you don't? I just tried the patch from above, and it applied on clean 5.3.18 for me (with an offset), not that I've booted it to see.
Back to top
View user's profile Send private message
Anton Gubarkov
n00b
n00b


Joined: 13 Mar 2008
Posts: 52

PostPosted: Fri Jan 03, 2020 3:47 pm    Post subject: Reply with quote

@Ionen, thanks for the link. This patch applies cleanly indeed.
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 253

PostPosted: Thu Jan 16, 2020 9:18 am    Post subject: Reply with quote

Quote:
Can you share how you came down to the commit to blame?


I searched the git log between 5.4.2 and 5.4.3 for changes to anything regarding audio/hdmi.
Luckily the first commit i found and created a revert patch from, did do the trick.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum