2021-11-01 20:33:21 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2021-09-03 13:17:43 +00:00
|
|
|
|
|
|
|
let
|
2021-10-21 21:37:31 +00:00
|
|
|
fetchurl = pkgs.fetchurl;
|
2021-11-04 14:11:46 +00:00
|
|
|
commit = "821d8f0685ebad0fa2c05c7080f45eafb28ad08c";
|
2021-11-04 22:26:57 +00:00
|
|
|
kernelVersion = "5.14";
|
2021-09-03 13:17:43 +00:00
|
|
|
mkPatch = name: sha256: {
|
|
|
|
name = name;
|
2021-11-04 22:26:57 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
};
|
2021-11-01 20:33:21 +00:00
|
|
|
cfg = config.ptw.hardware.surface;
|
2021-09-03 13:17:43 +00:00
|
|
|
in {
|
2021-11-01 20:33:21 +00:00
|
|
|
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 = ''
|
2021-09-07 13:40:07 +00:00
|
|
|
[Config]
|
|
|
|
BlockOnPalm = true
|
|
|
|
'';
|
2021-11-01 20:33:21 +00:00
|
|
|
"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
|
|
|
|
2021-11-01 20:33:21 +00:00
|
|
|
powerManagement = {
|
2021-09-07 13:40:07 +00:00
|
|
|
enable = true;
|
2021-11-01 20:33:21 +00:00
|
|
|
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-07 13:40:07 +00:00
|
|
|
};
|
|
|
|
};
|
2021-09-03 13:17:43 +00:00
|
|
|
|
2021-11-01 20:33:21 +00:00
|
|
|
boot = {
|
2021-11-04 14:11:46 +00:00
|
|
|
kernelPackages = pkgs.linuxPackages_5_14;
|
2021-11-01 20:33:21 +00:00
|
|
|
kernelPatches = [
|
2021-11-04 14:11:46 +00:00
|
|
|
(mkPatch "0001-surface3-oemb" "0ji3glnbaiy10kzi2zi80278vyf0pp23s7dqx8pwirbqxi6pygnp")
|
|
|
|
(mkPatch "0002-mwifiex" "0d7jpfiyb74i5fm2gdhwa5bi9kd7ff4mb75yss0lvidga10r9hmp")
|
|
|
|
(mkPatch "0003-ath10k" "0a6iwdw5wkjd24bnz32msncr1am2db36x6qpf652rx12czia8ndj")
|
|
|
|
(mkPatch "0004-ipts" "0ib7bnh4xanz5cakr50nirshhzn3rb29x9kq4m0snp38fhyaa8dv")
|
|
|
|
(mkPatch "0005-surface-sam" "19yjxgznhv65g1v6dcv6fklahi2inmf7gllbzmh6k98r3531kzjg")
|
|
|
|
(mkPatch "0006-surface-sam-over-hid" "0np7zf8328yxy9xzbipqjw014kzy0kmm67c046fmgmvniibixvs7")
|
|
|
|
(mkPatch "0007-surface-gpe" "164hhw0jh800qxmwiahw4hdsprghm760i8c6pwq89mh440wkfxnk")
|
|
|
|
(mkPatch "0008-surface-button" "0w03azjlhwdz9isjc5swlpimj48zx7jgjws6ws8xxlb37vbg4lq6")
|
|
|
|
(mkPatch "0009-surface-typecover" "0s2i13x780zmwbksv4rk1lryrv6n6mvc49ljn3zdy4d9yy10x272")
|
|
|
|
(mkPatch "0010-cameras" "0vwz609vbrracc8qm1jzm471ls4imqlilf3hh2whsb2w2npmd0kf")
|
|
|
|
(mkPatch "0011-amd-gpio" "09xjc0fl9vccz1nks6v62359digrk92svr75qz9zcvfmpyxg18z7") # TODO: Maybe drop
|
2021-09-03 13:17:43 +00:00
|
|
|
|
2021-11-01 20:33:21 +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
|
2021-09-04 22:27:42 +00:00
|
|
|
|
2021-09-06 16:20:13 +00:00
|
|
|
#
|
|
|
|
# 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
|
2021-09-06 19:12:37 +00:00
|
|
|
# Required for reading battery data
|
2021-09-06 16:20:13 +00:00
|
|
|
# (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-11-01 20:33:21 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2021-09-03 13:17:43 +00:00
|
|
|
};
|
|
|
|
}
|