Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] No speakers sound on Gentoo, works on Ubuntu
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
sergeev917
n00b
n00b


Joined: 04 Apr 2014
Posts: 19

PostPosted: Thu Jan 06, 2022 8:28 pm    Post subject: [SOLVED] No speakers sound on Gentoo, works on Ubuntu Reply with quote

Hi, everyone!

I'm installing Gentoo on a new machine (HP laptop), but failed to get sound to work so far. Both speakers and headphone outputs are silent on Gentoo (though muting sound gives a small pop sound in headphones if plugged). But sound works fine out of the box on live Ubuntu 21.10.

Results of alsa-info on Ubuntu: https://alsa-project.org/db/?f=3947d6ce871cb16b3085fce515a81c82506595ea
For Gentoo: http://alsa-project.org/db/?f=2cde5633ba4789f280883552e23aaf0498857b9a

Note that my Gentoo setup includes a monolithic kernel without modules (everything is compiled-in). Ubuntu kernel is 5.13.0 (with vendor patches), while Gentoo kernel is 5.15.12. The ALSA card and controls are all there, and I cannot see any meaningful difference which I could investigate further. I would be grateful for a nudge in the right direction.


Last edited by sergeev917 on Wed Jan 12, 2022 9:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54236
Location: 56N 3W

PostPosted: Thu Jan 06, 2022 9:16 pm    Post subject: Reply with quote

sergeev917,

It looks like you want to use sound card 1 an the default sound card.
At the moment, Gentoo in using your video card sound output, which has no input capability.

Are you using pulseaudio or not?
Depending on how you answer, there may be other things to check too.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
sergeev917
n00b
n00b


Joined: 04 Apr 2014
Posts: 19

PostPosted: Thu Jan 06, 2022 9:37 pm    Post subject: Reply with quote

> It looks like you want to use sound card 1 an the default sound card.

Correct. But I'm testing with a command like

[quote]
env ALSA_CARD=Generic_1 aplay some-file.wav
[/quote].

> Are you using pulseaudio or not?

On Ubuntu pulseaudio is started by default, but I've disabled it to ensure the same test being done across systems (on Gentoo no pulseaudio or other sound server is used).
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54236
Location: 56N 3W

PostPosted: Thu Jan 06, 2022 10:12 pm    Post subject: Reply with quote

sergeev917,

You need to swap your sound cards. There are two ways

Add
Code:
snd-hda-intel.index=1,0
to the kernel command line. That's a bit of a faff, especially if the command line is built into the kernel.

Or make a file called
Code:
/etc/asound.conf

With the content
Code:
defaults!pcm.card 1
defaults!pcm.device 0
defaults!ctl.card 1


The permissions need to be 644 and it should be owned by root.

Pick one. If you do both at the same time your sound cards will be swapped over at boot and again at the time of use.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
sergeev917
n00b
n00b


Joined: 04 Apr 2014
Posts: 19

PostPosted: Thu Jan 06, 2022 10:29 pm    Post subject: Reply with quote

NeddySeagoon,

> You need to swap your sound cards. There are two ways [...]
> snd-hda-intel.index=1,0

I've tried swapping the order of cards using the first method (it seems that it should be snd_hda_intel.index=1,0 -- ie with underscores). The default card (in alsamixer) is now Realtek and not HDMI-related, but no sound as before.
Note that I did specify the desired card via ALSA_CARD environment variable for aplay previously (I've also tried "--device" argument for aplay just in case). Also, the order of cards is the same in Ubuntu (ie the first card is HDMI-related, as was in Gentoo).
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54236
Location: 56N 3W

PostPosted: Thu Jan 06, 2022 10:47 pm    Post subject: Reply with quote

sergeev917,

You can use underscores or hyphens interchangeable in module names.
The kernel accepts either.

In alsamixer unmute only Master, Front and PCM. Mute everything else.
Set the Master, Front and PCM sliders to about 70%

Your sound card can operate at either the 44.1kHz sample rate, for CD Digital Audio or 48kHz, used by DVDs, HDMI and other digital sound.
However, it can only ward with one at a time. As a result, if 48kHz outputs are enabled, the others are silent.

In your normal user in the audio group?
Although, that would give permission denied errors.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
sergeev917
n00b
n00b


Joined: 04 Apr 2014
Posts: 19

PostPosted: Thu Jan 06, 2022 11:03 pm    Post subject: Reply with quote

NeddySeagoon,

> You can use underscores or hyphens interchangeable in module names.

Neat, that is good to know.

> In alsamixer unmute only Master, Front and PCM. Mute everything else.
> Set the Master, Front and PCM sliders to about 70%

There is Master, Headphone, Speaker, PCM (and capture levels), but no Front. I've checked 70% at Master, Speaker, PCM with and without muted Headphone -- no changes.

Btw, alsa-info output (linked in the first post) contains "Mixer controls for card [...]" -- and previously I've matched all mixer levels precisely across known-good Ubuntu and Gentoo.

> In your normal user in the audio group?
> Although, that would give permission denied errors.

Yes, the permissions are fine. And I've also checked aplay under root.
Back to top
View user's profile Send private message
sergeev917
n00b
n00b


Joined: 04 Apr 2014
Posts: 19

PostPosted: Thu Jan 06, 2022 11:16 pm    Post subject: Reply with quote

There are some bug reports about similar problems with ALSA [1], [2], [3], so I'm thinking about checking a bunch of different kernel versions as well.
But it is way after midnight in my time zone, I'll return after some sleep.

[1] https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1857552
[2] https://github.com/thesofproject/linux/issues/2748
[3] https://bugzilla.kernel.org/show_bug.cgi?id=207019
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2964
Location: Edge of marsh USA

PostPosted: Fri Jan 07, 2022 4:08 am    Post subject: Reply with quote

Try installing the binary kernel to iron out your sound issues. That process may help guide what you put in your custom gentoo-sources.
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
APolozov
Apprentice
Apprentice


Joined: 28 Sep 2006
Posts: 189
Location: Voronezh, Russia

PostPosted: Fri Jan 07, 2022 9:43 am    Post subject: Reply with quote

Try this asound.conf, sound must be duplcated to two way (HDMI and Analog output)
Code:

pcm.!default {
    type plug
    slave {
        pcm {
            type route
            slave {
                pcm {
                    type multi;
                    slaves.a.pcm {
                        type dmix
                        ipc_key 4855689
                        ipc_perm 0666
                        slave {
                            channels 2
                            period_size 2048
                            buffer_size 262144
                            pcm {
                                #ATI HDMI
                                format S32_LE
                                rate 48000
                                type hw
                                card 0
                                device 3
                            }
                        }
                     }
                     slaves.b.pcm{
                        type dmix
                        ipc_key 2589455
                        ipc_perm 0666
                        slave {
                            channels 2
                            period_size 2048
                            buffer_size 262144
                            pcm {
                                #Intel HDA
                                format S32_LE
                                rate 48000
                                type hw
                                card 1
                                device 0
                           }
                        }
                     }
                     slaves.a.channels 2;
                     slaves.b.channels 2;
                     bindings.0.slave a;
                     bindings.0.channel 0;
                     bindings.1.slave a;
                     bindings.1.channel 1;
                     bindings.2.slave b;
                     bindings.2.channel 0;
                     bindings.3.slave b;
                     bindings.3.channel 1;
                }
            }
            ttable.0.0 1;
            ttable.1.1 1;
            ttable.0.2 1;
            ttable.1.3 1;
        }
    }
}

_________________
Excuse my bad English, I only study it.
Back to top
View user's profile Send private message
sergeev917
n00b
n00b


Joined: 04 Apr 2014
Posts: 19

PostPosted: Fri Jan 07, 2022 10:00 am    Post subject: Reply with quote

APolozov,

> Try this asound.conf, sound must be duplcated to two way (HDMI and Analog output)

This config gives me the following errors (I've tried as is and with fixed card indices as well):

Code:
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.6.1/work/alsa-lib-1.2.6.1/src/pcm/pcm_dmix.c:1032:(snd_pcm_dmix_open) unable to open slave
Back to top
View user's profile Send private message
sergeev917
n00b
n00b


Joined: 04 Apr 2014
Posts: 19

PostPosted: Fri Jan 07, 2022 10:32 am    Post subject: Reply with quote

Something strange has happened when I've tried the proposed asound.conf. It didn't work, but after removing the configuration and hitting "alsactl init" speakers did work. The first idea was that "alsactl init" is the reason, but after reboot I cannot reproduce it anymore (with the same steps and also variations on the theme).
Back to top
View user's profile Send private message
APolozov
Apprentice
Apprentice


Joined: 28 Sep 2006
Posts: 189
Location: Voronezh, Russia

PostPosted: Fri Jan 07, 2022 11:39 am    Post subject: Reply with quote

This config manualy configured two sound card to: HDMI (card 0 device 3) and Analog (card 1 device 0)

Your HDMI may be:
card 0: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
card 0: Generic [HD-Audio Generic], device 7: HDMI 1 [HDMI 1]
card 0: Generic [HD-Audio Generic], device 8: HDMI 2 [HDMI 2]
card 0: Generic [HD-Audio Generic], device 9: HDMI 3 [HDMI 3]
Try change HDMI device in config
_________________
Excuse my bad English, I only study it.
Back to top
View user's profile Send private message
sergeev917
n00b
n00b


Joined: 04 Apr 2014
Posts: 19

PostPosted: Sat Jan 08, 2022 10:05 pm    Post subject: Reply with quote

After many attempts I got a clean boot with working sound, but after rebooting (with no changes at all) there were no sound again. The only explaination I can think of is a kernel bug and behavior which depends on timings during driver initialization/etc.
Back to top
View user's profile Send private message
sergeev917
n00b
n00b


Joined: 04 Apr 2014
Posts: 19

PostPosted: Wed Jan 12, 2022 9:05 pm    Post subject: [SOLVED] No speaker sound on Gentoo, works on Ubuntu Reply with quote

For future reference and others with similar issues -- I've isolated the problem and it's related to a processing coefficient in hda codec. With snd_hda_codec.dump_coef=1 in kernel cmdline (or echo 1 > /sys/module/snd_hda_codec/parameters/dump_coef), /proc/asound/Generic_1/codec#0 (where Generic_1 is the sound card name) is populated with codec processing coefficients. Since I have some boots with working sound, I've managed to pinpoint the specific coefficient that caused all the trouble.

The working fix is to install alsa-tools and then run:

Code:

hda-verb /dev/snd/hwC1D0 0x20 SET_COEF_INDEX 0x19
hda-verb /dev/snd/hwC1D0 0x20 SET_PROC_COEF 0x8e11


For more details see [1] and [2].

Note that the coefficients and its values are specific for the particular hardware setup.
Also, there are still timing issues within the sound devices initialization, since otherwise it would either consistently work or consistently fail to work. But with a proper workaround I think the topic is to be considered closed.

APolozov, NeddySeagoon, figueroa thank you for your support on this quest!

[1] https://lkml.org/lkml/2022/1/11/950
[2] https://bugzilla.kernel.org/show_bug.cgi?id=195457
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