Skip to content

Commit 8141742

Browse files
committed
microsoft/surface: add kernel switching for LTS and latest kernels
1 parent de6fc55 commit 8141742

File tree

9 files changed

+228
-87
lines changed

9 files changed

+228
-87
lines changed

microsoft/surface/common/default.nix

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,62 @@
1-
{ lib, ... }:
1+
{ config, lib, pkgs, ... }:
22

33
let
4-
inherit (lib) mkDefault;
4+
inherit (lib) mkDefault mkOption types;
5+
6+
version = config.microsoft-surface.kernelVersion;
7+
rev =
8+
if version == "6.12" then
9+
"arch-6.12.19-1"
10+
else if version == "6.13" then
11+
"arch-6.13.6-1"
12+
else
13+
abort "Invalid kernel version: ${version}";
14+
15+
hash =
16+
if version == "6.12" then
17+
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
18+
else if version == "6.13" then
19+
"sha256-otD1ckNxNnvV8xipf9SZpbfg+bBq5EPwyieYtLIV4Ck="
20+
else
21+
abort "Invalid kernel version: ${version}";
22+
23+
inherit (pkgs.callPackage ./kernel/linux-package.nix { repos = pkgs.callPackage ./kernel/repos.nix { rev = rev; hash = hash; }; }) linuxPackage surfacePatches;
24+
25+
kernelPatches = surfacePatches {
26+
inherit version;
27+
patchFn = ./kernel/${version}/patches.nix;
28+
};
29+
kernelPackages = linuxPackage {
30+
inherit version kernelPatches;
31+
sha256 = "sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE=";
32+
ignoreConfigErrors=true;
33+
};
534

635
in {
7-
imports = [
8-
./kernel
9-
];
36+
options.microsoft-surface.kernelVersion = mkOption {
37+
description = "Kernel Version to use (patched for MS Surface)";
38+
type = types.enum [
39+
"6.12"
40+
"6.13"
41+
];
42+
default = "6.12";
43+
};
1044

11-
microsoft-surface.kernelVersion = mkDefault "6.12";
45+
config = {
46+
boot = {
47+
inherit kernelPackages;
1248

13-
# Seems to be required to properly enable S0ix "Modern Standby":
14-
boot.kernelParams = mkDefault [ "mem_sleep_default=deep" ];
49+
kernelParams = mkDefault [ "mem_sleep_default=deep" ];
50+
# Seems to be required to properly enable S0ix "Modern Standby":
51+
};
1552

16-
# NOTE: Check the README before enabling TLP:
17-
services.tlp.enable = mkDefault false;
53+
# NOTE: Check the README before enabling TLP:
54+
services.tlp.enable = mkDefault false;
1855

19-
# i.e. needed for wifi firmware, see https://github.com/NixOS/nixos-hardware/issues/364
20-
hardware.enableRedistributableFirmware = mkDefault true;
21-
hardware.sensor.iio.enable = mkDefault true;
56+
# i.e. needed for wifi firmware, see https://github.com/NixOS/nixos-hardware/issues/364
57+
hardware = {
58+
enableRedistributableFirmware = mkDefault true;
59+
sensor.iio.enable = mkDefault true;
60+
};
61+
};
2262
}
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
{ lib,
2+
kernel ? lib.kernel,
3+
patchSrc,
4+
version,
5+
}:
6+
7+
[
8+
{
9+
name = "microsoft-surface-patches-linux-${version}";
10+
patch = null;
11+
extraStructuredConfig = with kernel; {
12+
STAGING_MEDIA = yes;
13+
14+
##
15+
## Surface Aggregator Module
16+
##
17+
CONFIG_SURFACE_AGGREGATOR= module;
18+
# CONFIG_SURFACE_AGGREGATOR_ERROR_INJECTION is not set
19+
CONFIG_SURFACE_AGGREGATOR_BUS= yes;
20+
CONFIG_SURFACE_AGGREGATOR_CDEV= module;
21+
CONFIG_SURFACE_AGGREGATOR_HUB= module;
22+
CONFIG_SURFACE_AGGREGATOR_REGISTRY= module;
23+
CONFIG_SURFACE_AGGREGATOR_TABLET_SWITCH= module;
24+
25+
CONFIG_SURFACE_ACPI_NOTIFY= module;
26+
CONFIG_SURFACE_DTX= module;
27+
CONFIG_SURFACE_PLATFORM_PROFILE= module;
28+
29+
CONFIG_SURFACE_HID= module;
30+
CONFIG_SURFACE_KBD= module;
31+
32+
CONFIG_BATTERY_SURFACE= module;
33+
CONFIG_CHARGER_SURFACE= module;
34+
35+
CONFIG_SENSORS_SURFACE_TEMP= module;
36+
CONFIG_SENSORS_SURFACE_FAN= module;
37+
38+
##
39+
## Surface Hotplug
40+
##
41+
CONFIG_SURFACE_HOTPLUG= module;
42+
43+
##
44+
## IPTS and ITHC touchscreen
45+
##
46+
## This only enables the user interface for IPTS/ITHC data.
47+
## For the touchscreen to work, you need to install iptsd.
48+
##
49+
CONFIG_HID_IPTS= module;
50+
CONFIG_HID_ITHC= module;
51+
52+
##
53+
## Cameras: IPU3
54+
##
55+
CONFIG_VIDEO_DW9719= module;
56+
CONFIG_VIDEO_IPU3_IMGU= module;
57+
CONFIG_VIDEO_IPU3_CIO2= module;
58+
CONFIG_IPU_BRIDGE= module;
59+
CONFIG_INTEL_SKL_INT3472= module;
60+
CONFIG_REGULATOR_TPS68470= module;
61+
CONFIG_COMMON_CLK_TPS68470= module;
62+
CONFIG_LEDS_TPS68470= module;
63+
64+
##
65+
## Cameras: Sensor drivers
66+
##
67+
CONFIG_VIDEO_OV5693= module;
68+
CONFIG_VIDEO_OV7251= module;
69+
CONFIG_VIDEO_OV8865= module;
70+
71+
##
72+
## Surface 3: atomisp causes problems (see issue #1095). Disable it for now.
73+
##
74+
# CONFIG_INTEL_ATOMISP is not set
75+
76+
##
77+
## ALS Sensor for Surface Book 3, Surface Laptop 3, Surface Pro 7
78+
##
79+
CONFIG_APDS9960= module;
80+
81+
##
82+
## Build-in UFS support (required for some Surface Go devices)
83+
##
84+
CONFIG_SCSI_UFSHCD= module;
85+
CONFIG_SCSI_UFSHCD_PCI= module;
86+
87+
##
88+
## Other Drivers
89+
##
90+
CONFIG_INPUT_SOC_BUTTON_ARRAY= module;
91+
CONFIG_SURFACE_3_POWER_OPREGION= module;
92+
CONFIG_SURFACE_PRO3_BUTTON= module;
93+
CONFIG_SURFACE_GPE= module;
94+
CONFIG_SURFACE_BOOK1_DGPU_SWITCH= module;
95+
};
96+
}
97+
{
98+
name = "ms-surface/0001-secureboot";
99+
patch = patchSrc + "/0001-secureboot.patch";
100+
}
101+
{
102+
name = "ms-surface/0002-surface3";
103+
patch = patchSrc + "/0002-surface3.patch";
104+
}
105+
{
106+
name = "ms-surface/0003-mwifiex";
107+
patch = patchSrc + "/0003-mwifiex.patch";
108+
}
109+
{
110+
name = "ms-surface/0004-ath10k";
111+
patch = patchSrc + "/0004-ath10k.patch";
112+
}
113+
{
114+
name = "ms-surface/0005-ipts";
115+
patch = patchSrc + "/0005-ipts.patch";
116+
}
117+
{
118+
name = "ms-surface/0006-ithc";
119+
patch = patchSrc + "/0006-ithc.patch";
120+
}
121+
{
122+
name = "ms-surface/0007-surface-sam";
123+
patch = patchSrc + "/0007-surface-sam.patch";
124+
}
125+
{
126+
name = "ms-surface/0008-surface-sam-over-hid";
127+
patch = patchSrc + "/0008-surface-sam-over-hid.patch";
128+
}
129+
{
130+
name = "ms-surface/0009-surface-button";
131+
patch = patchSrc + "/0009-surface-button.patch";
132+
}
133+
{
134+
name = "ms-surface/0010-surface-typecover";
135+
patch = patchSrc + "/0010-surface-typecover.patch";
136+
}
137+
{
138+
name = "ms-surface/0011-surface-shutdown";
139+
patch = patchSrc + "/0011-surface-shutdown.patch";
140+
}
141+
{
142+
name = "ms-surface/0012-surface-gpe";
143+
patch = patchSrc + "/0012-surface-gpe.patch";
144+
}
145+
{
146+
name = "ms-surface/0013-cameras";
147+
patch = patchSrc + "/0013-cameras.patch";
148+
}
149+
{
150+
name = "ms-surface/0014-amd-gpio";
151+
patch = patchSrc + "/0014-amd-gpio.patch";
152+
}
153+
{
154+
name = "ms-surface/0015-rtc";
155+
patch = patchSrc + "/0015-rtc.patch";
156+
}
157+
]

microsoft/surface/common/kernel/default.nix

Lines changed: 0 additions & 15 deletions
This file was deleted.

microsoft/surface/common/kernel/linux-package.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
fetchurl,
44
buildLinux,
55
linuxPackagesFor,
6+
repos,
67
}:
78

89
let
910
inherit (builtins) elem;
1011
inherit (lib) recurseIntoAttrs types versions;
1112

12-
repos = pkgs.callPackage ../repos.nix {};
13-
1413
linuxPackage =
1514
{ url ? "mirror://kernel/linux/kernel/v${versions.major version}.x/linux-${version}.tar.xz",
1615
sha256 ? null,

microsoft/surface/common/kernel/linux-surface/default.nix

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{ fetchFromGitHub, rev, hash }:
2+
{
3+
linux-surface = fetchFromGitHub {
4+
owner = "linux-surface";
5+
repo = "linux-surface";
6+
rev = rev;
7+
hash = hash;
8+
};
9+
}

microsoft/surface/common/repos.nix

Lines changed: 0 additions & 25 deletions
This file was deleted.

microsoft/surface/surface-go/firmware/ath10k/ath10k-replace.nix

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
{ stdenv, lib, pkgs, firmwareLinuxNonfree, ... }:
22

33
let
4-
repos = pkgs.callPackage ../../../common/repos.nix {};
4+
repos = pkgs.callPackage {
5+
surface-go-ath10k-firmware_backup = lib.fetchFromGitHub {
6+
owner = "mexisme";
7+
repo = "linux-surface_ath10k-firmware";
8+
rev = "74e5409e699383d6ca2bc4da4a8433d16f3850b1";
9+
sha256 = "169vgvxpgad9anmchs22fj5qm6ahzjfdnwhd8pc280q705vx6pjk";
10+
};
11+
} {};
512
killernetworking_firmware = repos.surface-go-ath10k-firmware_backup + "/K1535_Debian";
613

714
in stdenv.mkDerivation {

0 commit comments

Comments
 (0)