nixos-hardware
nixos-hardware copied to clipboard
Legion 16irx8h Speaker Issue
Using the nixos-hardware/lenovo/legion/16irx8h with latest (6.9.8) linux kernel. Speaker seem to work for a few minutes after boot, then get disabled/shutdown. I could not find any related logs in journalctl -b. I tried the default kernel 6.6 as well, same result. There is a firmware specified in https://forums.lenovo.com/t5/Ubuntu/Ubuntu-and-legion-pro-7-16IRX8H-audio-issues/m-p/5210709?page=22#6155866 firmware-TAS-2781... However this requires copying to /lib/firmware normally. I'm not very familiar with NixOS architecture just yet, any help is appreciated to make the 16irx8h work perfectly.
Another related discussion here https://github.com/clearlinux/distribution/issues/2992
Running this script https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/6/8306.2pa_2D00_byps.sh as root via ./8306.2pa_2D00_byps.sh 13 works after enabling i2c via hardware.i2c.enable = true; on configuration.nix however sound feels a bit janky, almost like it does not enable bass speakers or not enough amps, and when there is no sound for a while, it turns off the speakers again so we have to run the command again.
Another related discussion including several hacks https://forums.lenovo.com/t5/Ubuntu/Ubuntu-and-legion-pro-7-16IRX8H-audio-issues/m-p/5210709?page=32
Same issue here with my Lenovo Legion Pro 7 16IRX9H. Maybe related: https://discourse.nixos.org/t/sound-speaker-problem-after-connect-bluetooth-device/52443 (no solution).
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/sound-speaker-problem-after-connect-bluetooth-device/52443/1
I found a (temporary?) solution at:
New Lenovo Legion 7 Pro (2023) no sound from speakers in Linux (Reddit)
It worked to me.
I added it to my configuration file:
{ config, lib, pkgs, modulesPath, ... }:
{
boot.extraModprobeConfig = ''
options snd-hda-intel model=auto
'';
boot.blacklistedKernelModules = [ "snd_soc_avs" ];
}
PR: https://github.com/NixOS/nixos-hardware/pull/1227
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/sound-speaker-problem-after-connect-bluetooth-device/52443/2
I found a (temporary?) solution at:
New Lenovo Legion 7 Pro (2023) no sound from speakers in Linux (Reddit)
It worked to me.
I added it to my configuration file:
{ config, lib, pkgs, modulesPath, ... }: { boot.extraModprobeConfig = '' options snd-hda-intel model=auto ''; boot.blacklistedKernelModules = [ "snd_soc_avs" ]; }PR: #1227
This sadly does not work for me. Same behavior as before, there is sound right after booting. So you need to constantly play audio. After 10 minutes or so, when you stop playing and speakers become silent, they don't start again. After restart rinse and repeat. Problem is possibly related to speaker drivers going into some kind of power saving mode and you need to either manually trigger it to wake up, or linux driver needs to handle that power management.
Finally I was able to fix it: Guide: Fixing Speaker Audio on Lenovo Legion Pro 7 with NixOS.
I was still having issues, then found a hack that fixed it for me, at least it's been working now for a week now. I basically play a continuous but inaudible tone right from the boot so the speaker driver never sleeps.
Add this to configuration.nix
systemd.user.services.play-boot-tone = {
description = "Play 22 kHz tone at -90 dB (user)";
wantedBy = [ "default.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.sox}/bin/play -q -n -c2 synth 86400 sin 22000 vol -90dB";
Restart = "always";
RestartSec = 2;
};
};
then under your user nix settings (same configuration.nix file), set linger true like below
users.users.USERNAME = {
linger = true;
...
}
finally in your system packages add sox
environment.systemPackages = with pkgs; [
sox
...
Then rebuild and restart. This survived for a long time now. If you are still having issues with latest updates, give this one a try.
Edit: Only time this stopped working is if I connect a headphone, then it probably stops playing the audio from speakers so it puts the device into sleep again. Restart fixes it.