Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] ALSA on ThinkPad X1
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
vbar2
n00b
n00b


Joined: 19 Sep 2021
Posts: 8

PostPosted: Sun Sep 19, 2021 12:18 pm    Post subject: [SOLVED] ALSA on ThinkPad X1 Reply with quote

Hi,

I got a new laptop - ThinkPad X1 Carbon gen 9 - and am trying to get sound working on it... lspci says

00:1f.3 Audio device: Intel Corporation Tiger Lake-LP Smart Sound Technology Audio Controller (rev 20)

(see https://pastebin.com/chFHb2dZ for the full lspci output), so following
https://wiki.gentoo.org/wiki/ALSA , I've enabled CONFIG_SND_INTEL8X0 (see
https://pastebin.com/0mfKXGfM for the full kernel config), but it didn't really help: dmesg says

[ 2.031515] hdaudio hdaudioC0D0: Unable to bind the codec
[ 2.031566] hdaudio hdaudioC0D2: Unable to bind the codec

(see https://pastebin.com/s5tMu1qs for the full dmesg output) and aplay -l

aplay: device_list:274: no soundcards found...

So, what next?


Last edited by vbar2 on Mon Sep 20, 2021 7:01 pm; edited 1 time in total
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sun Sep 19, 2021 12:44 pm    Post subject: Reply with quote

Hi vbar2,

welcome to the Gentoo forums!

dmesg shows issues with firmware:
Code:
[    0.751114] Loading firmware: i915/tgl_dmc_ver2_08.bin
[    0.751123] i915 0000:00:02.0: Direct firmware load for i915/tgl_dmc_ver2_08.bin failed with error -2
[    0.751125] i915 0000:00:02.0: [drm] Failed to load DMC firmware i915/tgl_dmc_ver2_08.bin. Disabling runtime power management.

This page mentions that firmware is also required for the sound device. Is package 'sof-firmware' installed?

I haven't found a good HOWTO for a Gen9 machine, but you could try the instructions for Gen8: https://wiki.gentoo.org/wiki/Lenovo_ThinkPad_X1_Carbon_8th_generation: CONFIG_SND_MAESTRO3, CONFIG_SND_HDSP, CONFIG_SND_HDSPM, CONFIG_SND_YMFPCI are not enabled in your kernel config.

Mike
Back to top
View user's profile Send private message
vbar2
n00b
n00b


Joined: 19 Sep 2021
Posts: 8

PostPosted: Sun Sep 19, 2021 2:19 pm    Post subject: Reply with quote

mike155 wrote:

dmesg shows issues with firmware:
Code:
[    0.751114] Loading firmware: i915/tgl_dmc_ver2_08.bin
[    0.751123] i915 0000:00:02.0: Direct firmware load for i915/tgl_dmc_ver2_08.bin failed with error -2
[    0.751125] i915 0000:00:02.0: [drm] Failed to load DMC firmware i915/tgl_dmc_ver2_08.bin. Disabling runtime power management.

This page mentions that firmware is also required for the sound device. Is package 'sof-firmware' installed?


Yes, I've actually tried to follow that page as well and currently have

ALSA_CARDS="maestro3 hdsp hdspm ymfpci"

in my make.conf .

mike155 wrote:

I haven't found a good HOWTO for a Gen9 machine, but you could try the instructions for Gen8: https://wiki.gentoo.org/wiki/Lenovo_ThinkPad_X1_Carbon_8th_generation: CONFIG_SND_MAESTRO3, CONFIG_SND_HDSP, CONFIG_SND_HDSPM, CONFIG_SND_YMFPCI are not enabled in your kernel config.


I didn't realize that needs kernel changes, though - so I've enabled the above options now (see https://pastebin.com/TiPfzbb6 ) and rebooted, but it made no difference - dmesg
( https://pastebin.com/tzLCzf2M ) still has

[ 2.101932] hdaudio hdaudioC0D0: Unable to bind the codec
[ 2.102095] hdaudio hdaudioC0D2: Unable to bind the codec

and aplay -l shows

aplay: device_list:274: no soundcards found...
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sun Sep 19, 2021 2:44 pm    Post subject: Reply with quote

Let's assume the Arch Web page is right and that SOF firmware is needed.

If that's case, it's probably necessary to enable the SOF drivers in the kernel as well.

Please enable CONFIG_SND_SOC, then CONFIG_SND_SOC_SOF_TOPLEVEL and then CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL, CONFIG_SND_SOC_SOF_PCI, CONFIG_SND_SOC_SOF_ACPI

And please add the 'i915/tgl_dmc_ver2_08.bin' firmware file to your kernel - to get rid of the error message in the output of dmesg I posted above:
Code:
CONFIG_EXTRA_FIRMWARE="i915/tgl_dmc_ver2_08.bin"
CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"

sys-kernel/linux-firmware must be installed, too
Back to top
View user's profile Send private message
vbar2
n00b
n00b


Joined: 19 Sep 2021
Posts: 8

PostPosted: Sun Sep 19, 2021 3:15 pm    Post subject: Reply with quote

mike155 wrote:
Let's assume the Arch Web page is right and that SOF firmware is needed.

If that's case, it's probably necessary to enable the SOF drivers in the kernel as well.

Please enable CONFIG_SND_SOC, then CONFIG_SND_SOC_SOF_TOPLEVEL and then CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL, CONFIG_SND_SOC_SOF_PCI, CONFIG_SND_SOC_SOF_ACPI

And please add the 'i915/tgl_dmc_ver2_08.bin' firmware file to your kernel - to get rid of the error message in the output of dmesg I posted above:
Code:
CONFIG_EXTRA_FIRMWARE="i915/tgl_dmc_ver2_08.bin"
CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"

sys-kernel/linux-firmware must be installed, too


OK, I did ( https://pastebin.com/sB08rXu1 ), but I don't see any difference ( https://pastebin.com/uyHvGxEj ). I've also upgraded linux-firmware to 20210818 .
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sun Sep 19, 2021 3:39 pm    Post subject: Reply with quote

Ok, at least the firmware error is gone: :D
Code:
[    0.748755] Loading firmware: i915/tgl_dmc_ver2_08.bin
[    0.749263] i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/tgl_dmc_ver2_08.bin (v2.8)

Looking at your kernel config, CONFIG_SND_SOC_SOF_TIGERLAKE_SUPPORT is missing... It's probably a good idea to enable all CONFIG_SND_SOC_SOF_*_SUPPORT modules...
Back to top
View user's profile Send private message
vbar2
n00b
n00b


Joined: 19 Sep 2021
Posts: 8

PostPosted: Sun Sep 19, 2021 5:26 pm    Post subject: Reply with quote

mike155 wrote:

Looking at your kernel config, CONFIG_SND_SOC_SOF_TIGERLAKE_SUPPORT is missing... It's probably a good idea to enable all CONFIG_SND_SOC_SOF_*_SUPPORT modules...


OK, enabled ( https://pastebin.com/TTxwjPjg ), and it might indeed have been a good idea, because the "Unable to bind the codec" no longer appears in dmesg output ( https://pastebin.com/0Evbip6w ). But it isn't sufficient: aplay -l still says

aplay: device_list:274: no soundcards found...
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sun Sep 19, 2021 6:15 pm    Post subject: Reply with quote

We are getting closer... Step by step.

dmesg now shows:
Code:
[    0.801291] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040380
[    0.801292] snd_hda_intel 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver
[    0.801331] sof-audio-pci 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040380
[    0.801331] sof-audio-pci 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver
[    0.801414] sof-audio-pci 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if 0x040380
[    0.803401] sof-audio-pci 0000:00:1f.3: use msi interrupt mode
[    0.807795] sof-audio-pci 0000:00:1f.3: warning: No matching ASoC machine driver found
[    0.807796] sof-audio-pci 0000:00:1f.3: error: no matching ASoC machine driver found - aborting probe
[    0.807796] sof-audio-pci 0000:00:1f.3: error: failed to get machine info -19
[    0.807886] sof-audio-pci 0000:00:1f.3: error: failed to probe DSP hardware!

A machine driver is missing...

Please run "make menuconfig", and go to:
Code:
-> Device Drivers
   -> Sound card support
      -> Advanced Linux Sound Architecture
         -> ALSA for SoC audio support
            -> Intel Machine drivers

There aren't many menu entries, are there?

Now press 'Z', which is 'secret' key.

At least 30 drivers should appear. I guess that one of those drivers is required.

Those drivers are not shown (unless you press Z) because other options or modules are missing. As soon as those options or modules are enabled, those drivers will appear in the menu.

It seems, unfortunately, that each of those drivers needs different options to be enabled before it appears in the menu. :cry:

At this point I would boot from an up-to-date SystemRescue or Debian boot CD. When the system is up and running, I would run 'lsmod' and 'lspci -k'. Those commands will show all modules that are required for your machine, hopefully even the machine driver for the sound device. After that, I would reboot back to Gentoo and enable all options and modules in the kernel that were shown by 'lsmod' and 'lspci -k'.
Back to top
View user's profile Send private message
vbar2
n00b
n00b


Joined: 19 Sep 2021
Posts: 8

PostPosted: Mon Sep 20, 2021 7:22 am    Post subject: Reply with quote

mike155 wrote:

At this point I would boot from an up-to-date SystemRescue or Debian boot CD. When the system is up and running, I would run 'lsmod' and 'lspci -k'. Those commands will show all modules that are required for your machine, hopefully even the machine driver for the sound device. After that, I would reboot back to Gentoo and enable all options and modules in the kernel that were shown by 'lsmod' and 'lspci -k'.


Yes, my Gentoo installation USB actually seems to have sound - except it doesn't have mplayer (so I can't test it), but aplay -l shows

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC287 Analog [ALC287 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0

lsmod has

snd
snd_hda_codec
snd_hda_codec_generic
snd_hda_codec_hdmi
snd_hda_codec_realtek
snd_hda_core
snd_hda_intel
snd_intel_dspcfg
snd_pcm
snd_timer
soundcore

(see https://pastebin.com/qpZ552Nx for the full list ) and lspci -k

00:1f.3 Audio device: Intel Corporation Tiger Lake-LP Smart Sound Technology Audio Controller (rev 20)
Subsystem: Lenovo Tiger Lake-LP Smart Sound Technology Audio Controller
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel

(and I've run out of pastebin blobs 8O ). But I'm still not very clear on how to "enable all options"... The diff between the installation kernel and the one discussed above is over 180 KB, and I'm not very keen on trying to reconcile them - I mean sure, it can be done (and has been done, when I was trying to enable trackpad - I must have rebooted a thousand times :roll: ), but isn't there an easier way?
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Mon Sep 20, 2021 8:47 am    Post subject: Reply with quote

Do I understand correctly that your soundcard works when you boot from the USB stick and that the snd modules below are loaded?
Code:
snd
snd_hda_codec
snd_hda_codec_generic
snd_hda_codec_hdmi
snd_hda_codec_realtek
snd_hda_core
snd_hda_intel
snd_intel_dspcfg
snd_pcm
snd_timer
soundcore

That means we were on the wrong track with the SOF drivers. :(

But.. I think that all of those modules above are enabled in your kernel config... So why doesn't it work?

Maybe one of the low level modules like LPSS is missing.

Make sure that the snd modules shown above are enabled (I think they are) and enable CONFIG_X86_INTEL_LPSS, CONFIG_ACPI_WMI, CONFIG_WMI_BMOF, CONFIG_THINKPAD_ACPI

I think you can disable all SOF modules we enabled.
Back to top
View user's profile Send private message
vbar2
n00b
n00b


Joined: 19 Sep 2021
Posts: 8

PostPosted: Mon Sep 20, 2021 1:23 pm    Post subject: Reply with quote

mike155 wrote:
Do I understand correctly that your soundcard works when you boot from the USB stick and that the snd modules below are loaded?


Yes - I've built genkernel with config from the USB stick and got sound in my earbuds. :D Unfortunately that config also broke WiFi and X (and probably other things as well), so it isn't really usable as it is, but apparently there is a way...

mike155 wrote:
But.. I think that all of those modules above are enabled in your kernel config... So why doesn't it work?


You tell me... :wink:

mike155 wrote:
Make sure that the snd modules shown above are enabled (I think they are) and enable CONFIG_X86_INTEL_LPSS, CONFIG_ACPI_WMI, CONFIG_WMI_BMOF, CONFIG_THINKPAD_ACPI


Well, how do I make sure? IOW, how do I go from module name to config option? When I search for (for example) snd_intel_dspcfg inside menuconfig, it says "No matches found."...
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Mon Sep 20, 2021 1:52 pm    Post subject: Reply with quote

Well, some options are not accessible through "make menuconfig". SND_INTEL_DSP_CONFIG is one of them. You can find it in ".config":
Code:
# grep "INTEL_DSP" .config
CONFIG_SND_INTEL_DSP_CONFIG=y

You can't see or select it in "make menuconfig", because it's enabled automatically if you select SND_HDA_INTEL and SND_PCI.

Here is what I do if someone asks me to enable a module/option - let's say 'HDA_INTEL':
  1. I search for that option in the config file
    Code:
    cd /usr/src/linux
    grep "HDA_INTEL" .config

    Please note that modules/options in ".config" start with "CONFIG_", while the same options/modules in "make menuconfig" do NOT start with "CONFIG_".

  2. I'm done if the result is
    Code:
    CONFIG_SND_HDA_INTEL=y

  3. If the result is
    Code:
    # CONFIG_SND_HDA_INTEL is not set

    I start "make menuconfig" to enable it. If I know where that module is, I go to that module and enable it. If I don't know where its is, I use '/' to search for it. The search may return multiple matches. Please note the numbers on the left side ( '(2)', for example). Choose the right result and press the key with the associated number (2, for example). "make menuconfig" will jump directly to that module/option.

  4. If I don't get any result, I double-check for typos. It could also be that the name of the option is slightly different. I could grep for "INTEL" or "HDA" and see if any of the results is the module/option I want. It could also be that the option exists, but that it isn't shown because it depends on other modules which are not selected. That's what option 'Z' in "make menuconfig" is for. It shows hidden modules and options. If you select "help" for such a module, "make menconfig" will show a list of dependencies that must be enabled before the option/module can be enabled.
Back to top
View user's profile Send private message
vbar2
n00b
n00b


Joined: 19 Sep 2021
Posts: 8

PostPosted: Mon Sep 20, 2021 2:27 pm    Post subject: Reply with quote

mike155 wrote:
I start "make menuconfig" to enable it. If I know where that module is, I go to that module and enable it. If I don't know where its is, I use '/' to search for it. The search may return multiple matches. Please note the numbers on the left side ( '(2)', for example). Choose the right result and press the key with the associated number (2, for example). "make menuconfig" will jump directly to that module/option.


Ha! That will save me a lot of time... :)

mike155 wrote:
It could also be that the name of the option is slightly different.


Indeed. Anyway, I've configured a new kernel with the options above (config at https://hastebin.com/mesehofane.ini ), rebooted (dmesg at http://hastebin.com/sicoduyone.yaml ) and got basically to the same state as before: lspci -k says

00:1f.3 Audio device: Intel Corporation Tiger Lake-LP Smart Sound Technology Audio Controller (rev 20)
Subsystem: Lenovo Tiger Lake-LP Smart Sound Technology Audio Controller
Kernel driver in use: snd_hda_intel

(complete output at http://hastebin.com/xinegaxave.yaml ), but the module isn't loaded (lsmod at http://hastebin.com/igabetubar.apache ) and sound does not work.
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Mon Sep 20, 2021 5:46 pm    Post subject: Reply with quote

I think we're pretty close.
Code:
00:1f.3 Audio device: Intel Corporation Tiger Lake-LP Smart Sound Technology Audio Controller (rev 20)
Subsystem: Lenovo Tiger Lake-LP Smart Sound Technology Audio Controller
Kernel driver in use: snd_hda_intel

and
Code:
# dmesg | grep snd
[    0.814589] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040380
[    1.972929] snd_hda_intel 0000:00:1f.3: bound 0000:00:02.0 (ops 0xffffffffa5eaac40)
[    1.997628] hdaudio hdaudioC0D0: Unable to bind the codec
[    1.997685] hdaudio hdaudioC0D2: Unable to bind the codec

show that snd_hda_intel detects your audio device and that it is loaded. There's just a problem with the codec.

Some of your sound drivers are built directly into the kernel (=y), but the Realtek module is built as a module (=m). Maybe this is the reason why sound doesn't work?
  1. What happens if you run "modprobe snd_hda_codec_realtek"?

  2. What happens if you build the codec directly into your kernel? Change "CONFIG_SND_HDA_CODEC_REALTEK=m" to "CONFIG_SND_HDA_CODEC_REALTEK=y"

  3. What happens if you build all sound modules as modules? Change all sound drivers to "=m"
Your notebook is pretty new. What happens if you update to the latest kernel (5.14.6)?
Back to top
View user's profile Send private message
vbar2
n00b
n00b


Joined: 19 Sep 2021
Posts: 8

PostPosted: Mon Sep 20, 2021 6:59 pm    Post subject: Reply with quote

mike155 wrote:

Some of your sound drivers are built directly into the kernel (=y), but the Realtek module is built as a module (=m). Maybe this is the reason why sound doesn't work?
What happens if you run "modprobe snd_hda_codec_realtek"?


Well, it looks like succeeding - it doesn't say anything, and lsmod shows

Module Size Used by
snd_hda_codec_realtek 126976 0
snd_hda_codec_generic 81920 1 snd_hda_codec_realtek

- but it doesn't do anything...

mike155 wrote:

What happens if you build the codec directly into your kernel? Change "CONFIG_SND_HDA_CODEC_REALTEK=m" to "CONFIG_SND_HDA_CODEC_REALTEK=y"


Yes, that's it - aplay -l shows

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC287 Analog [ALC287 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: Generic Digital [Generic Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0

and I have sound! Thanks a lot!
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