nixos-hardware icon indicating copy to clipboard operation
nixos-hardware copied to clipboard

[Request] Add workaround for Skylake and Kabylake R built-in Speaker and Mic Support

Open LazyGeniusMan opened this issue 3 years ago • 3 comments

There was a bug on Skylake and Kabylake R laptop where built-in soundcard (ALC256) is not detected^1^3

There is a fix for that bug that require compile something with alsatplg and copy the file to /lib/firmware/ and add a line in /etc/modprobe.d/*.conf. Complete steps is here: https://gist.github.com/crojewsk/4e6382bfb0dbfaaf60513174211f29cb#topology

Could someone do this or atleast help me implement this? I read that modprobe can be added in config file but I'm not sure where /lib/firmware/ is, I can't find the folder in NixOS. When I use other distro I can find the folder and this workaround is working.

LazyGeniusMan avatar Sep 04 '22 11:09 LazyGeniusMan

In NixOS firmware is added via the hardware.firmware option. Here is an usage example: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/hardware/video/amdgpu-pro.nix#L43

Mic92 avatar Sep 06 '22 10:09 Mic92

I tried with this nix file but it's not working (it was working when I apply it in other distro), anything I missed based on the guide on gist?

{ config, pkgs, ... }:

let alsa-topology = pkgs.alsa-topology-conf;
in
{
  # Add necessary packages
  environment.systemPackages = with pkgs; [
    alsa-ucm-conf
    alsa-topology-conf
    alsa-lib
    alsa-utils
  ];

  # Compile ALSA Topology
  hardware.firmware = [
    (pkgs.runCommand "alsa-hda-dsp-topology" { nativeBuildInputs = [ pkgs.alsa-utils ]; } ''
      mkdir -p $out/lib/firmware
      alsatplg -c ${alsa-topology}/share/alsa/topology/hda-dsp/skl_hda_dsp_generic-tplg.conf -o $out/lib/firmware/skl_hda_dsp_generic-tplg.bin
    '')
    pkgs.alsa-firmware
    pkgs.sof-firmware
  ];
  
  # Replace default DSP Firmware
  system.replaceRuntimeDependencies = [
    {
      original = pkgs.firmwareLinuxNonfree;
      replacement = pkgs.firmwareLinuxNonfree.overrideAttrs (super: {
        postInstall = ''
          cd $out/lib/firmware/intel/
          rm dsp_fw_release.bin
          ln -s dsp_fw_kbl_v3420.bin dsp_fw_release.bin
        '';
      });
    }
  ];
  
  # Add modprobe
  boot.extraModprobeConfig = "options snd-intel-dspcfg dsp_driver=1\n";
}

LazyGeniusMan avatar Sep 12 '22 01:09 LazyGeniusMan

Have you checked if /run/current-system/firmware contains the changes you would expect it to have? An alternative to replaceRuntimeDependencies would be to use nixpkgs.config.packageOverrides to override firmwareLinuxNonfree

Mic92 avatar Sep 15 '22 08:09 Mic92