Merge pull request #903 from NixOS/refactor_fw0424

framework-12th-gen-intel: Refactor
This commit is contained in:
Jörg Thalheim 2024-04-27 08:29:42 +02:00 committed by GitHub
commit 504ebfbffb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 99 additions and 58 deletions

View file

@ -1,8 +1,17 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ {
boot.initrd.kernelModules = [ "i915" ]; options.hardware.intelgpu.loadInInitrd = lib.mkEnableOption (lib.mdDoc
"loading `i195` kernelModule at stage 1. (Add `i915` to `boot.initrd.kernelModules`)"
) // {
default = true;
};
config = lib.mkMerge [
(lib.mkIf config.hardware.intelgpu.loadInInitrd {
boot.initrd.kernelModules = [ "i915" ];
})
{
environment.variables = { environment.variables = {
VDPAU_DRIVER = lib.mkIf config.hardware.opengl.enable (lib.mkDefault "va_gl"); VDPAU_DRIVER = lib.mkIf config.hardware.opengl.enable (lib.mkDefault "va_gl");
}; };
@ -13,3 +22,5 @@
intel-media-driver intel-media-driver
]; ];
} }
];
}

View file

@ -1,25 +1,38 @@
{ lib, pkgs, ... }: { { config, lib, pkgs, ... }:
{
imports = [ imports = [
../common ../common
../common/intel.nix ../common/intel.nix
]; ];
config = lib.mkMerge [
{
hardware.intelgpu.loadInInitrd = lib.versionOlder config.boot.kernelPackages.kernel.version "6.2";
}
# https://community.frame.work/t/tracking-hard-freezing-on-fedora-36-with-the-new-12th-gen-system/20675/391
(lib.mkIf (lib.versionOlder config.boot.kernelPackages.kernel.version "6.2") {
boot.kernelParams = [ boot.kernelParams = [
# For Power consumption
# https://kvark.github.io/linux/framework/2021/10/17/framework-nixos.html
"mem_sleep_default=deep"
# Workaround iGPU hangs # Workaround iGPU hangs
# https://discourse.nixos.org/t/intel-12th-gen-igpu-freezes/21768/4 # https://discourse.nixos.org/t/intel-12th-gen-igpu-freezes/21768/4
"i915.enable_psr=1" "i915.enable_psr=1"
]; ];
})
(lib.mkIf (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") {
boot.blacklistedKernelModules = [ boot.blacklistedKernelModules = [
# This enables the brightness and airplane mode keys to work # This enables the brightness and airplane mode keys to work
# https://community.frame.work/t/12th-gen-not-sending-xf86monbrightnessup-down/20605/11 # https://community.frame.work/t/12th-gen-not-sending-xf86monbrightnessup-down/20605/11
"hid-sensor-hub" "hid-sensor-hub"
# This fixes controller crashes during sleep # This fixes controller crashes during sleep
# https://community.frame.work/t/tracking-fn-key-stops-working-on-popos-after-a-while/21208/32 # https://community.frame.work/t/tracking-fn-key-stops-working-on-popos-after-a-while/21208/32
"cros_ec_lpcs" (lib.mkIf (config.hardware.framework.enableKmod == false) "cros_ec_lpcs")
];
boot.kernelParams = [
# For Power consumption
# https://kvark.github.io/linux/framework/2021/10/17/framework-nixos.html
# Update 04/2024: Combined with acpi_osi from framework-intel it increases the idle power-usage in my test (SebTM)
# (see: https://github.com/NixOS/nixos-hardware/pull/903#issuecomment-2068146658)
"mem_sleep_default=deep"
]; ];
# Further tweak to ensure the brightness and airplane mode keys work # Further tweak to ensure the brightness and airplane mode keys work
@ -44,9 +57,6 @@
fi fi
''; '';
}; };
})
# Alder Lake CPUs benefit from kernel 5.18 for ThreadDirector ];
# https://www.tomshardware.com/news/intel-thread-director-coming-to-linux-5-18
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.18") (lib.mkDefault pkgs.linuxPackages_latest);
} }

View file

@ -2,6 +2,7 @@
imports = [ imports = [
../../../common/pc/laptop ../../../common/pc/laptop
../../../common/pc/laptop/ssd ../../../common/pc/laptop/ssd
../../kmod.nix
]; ];
# Fix TRRS headphones missing a mic # Fix TRRS headphones missing a mic

View file

@ -1,15 +1,17 @@
{ lib, pkgs, ... }: { { config, lib, pkgs, ... }: {
imports = [ imports = [
../../../common/cpu/intel ../../../common/cpu/intel
]; ];
boot.kernelParams = [ boot.kernelParams = [
# Fixes a regression in s2idle, making it more power efficient than deep sleep
"acpi_osi=\"!Windows 2020\""
# For Power consumption # For Power consumption
# https://community.frame.work/t/linux-battery-life-tuning/6665/156 # https://community.frame.work/t/linux-battery-life-tuning/6665/156
"nvme.noacpi=1" "nvme.noacpi=1"
]; ]
# Fixes a regression in s2idle, making it more power efficient than deep sleep
# Update 04/2024: It appears that s2idle-regression got fixed in newer kernel-versions (SebTM)
# (see: https://github.com/NixOS/nixos-hardware/pull/903#discussion_r1556096657)
++ lib.lists.optional (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") "acpi_osi=\"!Windows 2020\"";
# Requires at least 5.16 for working wi-fi and bluetooth. # Requires at least 5.16 for working wi-fi and bluetooth.
# https://community.frame.work/t/using-the-ax210-with-linux-on-the-framework-laptop/1844/89 # https://community.frame.work/t/using-the-ax210-with-linux-on-the-framework-laptop/1844/89

17
framework/kmod.nix Normal file
View file

@ -0,0 +1,17 @@
{ config, lib, ... }:
{
options.hardware.framework.enableKmod = lib.mkEnableOption (lib.mdDoc
"Enable the community created Framework kernel module that allows interacting with the embedded controller from sysfs."
) // {
# Enable by default if on new enough version of NixOS
default = (lib.versionAtLeast (lib.versions.majorMinor lib.version) "24.05");
};
config = lib.mkIf config.hardware.framework.enableKmod {
boot.extraModulePackages = with config.boot.kernelPackages; [
framework-laptop-kmod
];
# https://github.com/DHowett/framework-laptop-kmod?tab=readme-ov-file#usage
boot.kernelModules = [ "cros_ec" "cros_ec_lpcs" ];
};
}