nixos-config/modules/hardware/surface-pro6.nix

162 lines
5.0 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
2021-09-03 13:17:43 +00:00
let
2021-10-21 21:37:31 +00:00
fetchurl = pkgs.fetchurl;
2021-12-06 12:36:35 +00:00
commit = "a602640f4334990828e07cf78bc78217b4e7901e";
kernelVersion = "5.15";
2021-09-03 13:17:43 +00:00
mkPatch = name: sha256: {
name = name;
patch = fetchurl {
inherit sha256;
url = "https://raw.githubusercontent.com/linux-surface/linux-surface/${commit}/patches/${kernelVersion}/${name}.patch";
2021-09-03 13:17:43 +00:00
};
};
cfg = config.ptw.hardware.surface;
2021-09-03 13:17:43 +00:00
in {
options.ptw.hardware.surface = {
enable = lib.mkEnableOption "Enable support for the Microsoft Surface Pro 6";
};
config = lib.mkIf cfg.enable {
environment.etc = {
"ipts.conf".text = ''
[Config]
BlockOnPalm = true
'';
"thermald/thermal-cpu-cdev-order.xml".source = fetchurl {
url = "https://raw.githubusercontent.com/linux-surface/linux-surface/${commit}/contrib/thermald/surface_pro_5/thermal-conf.xml.auto.mobile";
sha256 = "1wsrgad6k4haw4m0jjcjxhmj4742kcb3q8rmfpclbw0czm8384al";
};
2021-10-21 21:37:31 +00:00
};
2021-09-05 11:26:29 +00:00
powerManagement = {
enable = true;
cpuFreqGovernor = "powersave";
};
hardware.video.hidpi.enable = true;
systemd.services.iptsd = {
description = "Userspace daemon for Intel Precise Touch & Stylus";
wantedBy = [ "multi-user.target" ];
wants = [ "dev-ipts-15.device" ];
after = [ "dev-ipts-15.device" ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.iptsd}/bin/iptsd";
};
};
environment.systemPackages = with pkgs; [ iptsd surface-control ];
services = {
udev.packages = with pkgs; [ iptsd surface-control ];
thermald = {
enable = true;
configFile = fetchurl {
url = "https://raw.githubusercontent.com/linux-surface/linux-surface/${commit}/contrib/thermald/thermal-conf.xml";
sha256 = "1xj70n9agy41906jgm4yjmsx58i7pzsizpvv3rkzq78k95qjfmc9";
};
};
};
2021-09-03 13:17:43 +00:00
boot = {
2021-12-06 12:36:35 +00:00
kernelPackages = pkgs.linuxPackages_5_15;
kernelPatches = [
2021-12-06 12:36:35 +00:00
(mkPatch "0001-surface3-oemb" "0id92a1g9ghvw2wf05ad3j4i294m118rvb23rywvm04wcasgav4a")
(mkPatch "0002-mwifiex" "091380bv1gmbzh9ldcnhdw64g8m5lz0akync7r0lazcm6fjcwnxa")
(mkPatch "0003-ath10k" "1hy22n8mdw743gnh82asnyjiivx9hz95a6svf6lr2pkdz5dl48ra")
(mkPatch "0004-ipts" "0c192h414wp0zgcm78q79wcavrzah33k94vb1cjzfl6y53agzjam")
(mkPatch "0005-surface-sam" "1awffwlp6wz0i0kb4xd7zy7y7syggzc04ay53nxjhn54n8djlb1r")
(mkPatch "0006-surface-sam-over-hid" "1nf9wy57hqr28f2lqk9vjvk0fkm9vs3j8nq4f8izhdqmazl8bbak")
(mkPatch "0007-surface-gpe" "0a77haazdsmv4kr76cfng829cgd4zrzvbn3pf1rl67vbl6il9wli")
(mkPatch "0008-surface-button" "1ja9n1iia3p6cjifds95cv684w8cr2kibj19k7fm8bm58achia6f")
(mkPatch "0009-surface-typecover" "0dmcsilqcqzr3rdc8lpq857pjgkj9agmns8g1nrax9h0rfh9gl3m")
(mkPatch "0010-cameras" "1clvd09qbl3cjmxmpjvnfq4f9csqarzk13ahz3s69hq401a2a83m")
(mkPatch "0011-amd-gpio" "0552k7d9hajafryvjvlxbaxbxkqmhjmk4i3hxbpdb3czz7i9cyzj") # TODO: Maybe drop
(mkPatch "0012-misc-fixes" "16fslvys2zjp8fpysig51cchikskzpvjww9w4nk3wsz6yh1xdm0f")
2021-09-03 13:17:43 +00:00
{
name = "surface-config";
patch = null;
# Options from https://github.com/linux-surface/linux-surface/blob/master/configs/surface-5.13.config
extraConfig = ''
2021-09-03 13:17:43 +00:00
#
# Surface Aggregator Module
#
2021-09-04 18:16:58 +00:00
SURFACE_AGGREGATOR m
SURFACE_AGGREGATOR_ERROR_INJECTION n
SURFACE_AGGREGATOR_BUS y
SURFACE_AGGREGATOR_CDEV m
SURFACE_AGGREGATOR_REGISTRY m
2021-09-03 13:17:43 +00:00
2021-09-04 18:16:58 +00:00
SURFACE_ACPI_NOTIFY m
SURFACE_DTX m
SURFACE_PLATFORM_PROFILE m
2021-09-03 13:17:43 +00:00
2021-09-04 18:16:58 +00:00
SURFACE_HID m
SURFACE_KBD m
2021-09-03 13:17:43 +00:00
2021-09-04 18:16:58 +00:00
BATTERY_SURFACE m
CHARGER_SURFACE m
2021-09-03 13:17:43 +00:00
#
# Surface Hotplug
#
2021-09-04 18:16:58 +00:00
SURFACE_HOTPLUG m
2021-09-03 13:17:43 +00:00
#
# IPTS touchscreen
#
# This only enables the user interface for IPTS data.
# For the touchscreen to work, you need to install iptsd.
#
2021-09-04 18:16:58 +00:00
MISC_IPTS m
2021-09-03 13:17:43 +00:00
#
# Cameras: IPU3
#
2021-09-04 18:16:58 +00:00
#VIDEO_IPU3_IMGU m
VIDEO_IPU3_CIO2 m
CIO2_BRIDGE y
#INTEL_SKL_INT3472 m
2021-09-03 13:17:43 +00:00
#
# Cameras: Sensor drivers
#
2021-09-04 18:16:58 +00:00
#VIDEO_OV5693 m
VIDEO_OV8865 m
2021-09-03 13:17:43 +00:00
#
# ALS Sensor for Surface Book 3, Surface Laptop 3, Surface Pro 7
#
2021-09-04 18:16:58 +00:00
APDS9960 m
2021-09-03 13:17:43 +00:00
#
# Other Drivers
#
2021-09-04 18:16:58 +00:00
INPUT_SOC_BUTTON_ARRAY m
SURFACE_3_BUTTON m
SURFACE_3_POWER_OPREGION m
SURFACE_PRO3_BUTTON m
SURFACE_GPE m
SURFACE_BOOK1_DGPU_SWITCH m
#
# Other
#
# Prevent a non-fatal "kernel oops" at boot crashing udev
# (https://github.com/linux-surface/linux-surface/issues/61#issuecomment-579298172)
PINCTRL_INTEL y
PINCTRL_SUNRISEPOINT y
# Required for reading battery data
# (https://github.com/linux-surface/surface-aggregator-module/wiki/Testing-and-Installing)
SERIAL_DEV_BUS y
SERIAL_DEV_CTRL_TTYPORT y
MFD_INTEL_LPSS_PCI y
INTEL_IDMA64 y
2021-09-03 13:17:43 +00:00
'';
}
];
};
2021-09-03 13:17:43 +00:00
};
}