Port of linux-surface/linux-surface Kernel patches to NixOS (#221)
This commit is contained in:
parent
874830945a
commit
a0d8383c42
73
microsoft/surface/README.md
Normal file
73
microsoft/surface/README.md
Normal file
|
@ -0,0 +1,73 @@
|
|||
# Derivatives for Microsoft Surface notebooks
|
||||
|
||||
These derivatives use the patches from the [linux-surface repo](https://github.com/linux-surface/linux-surface/tree/master/patches).
|
||||
|
||||
## Kernel
|
||||
|
||||
The kernel needs several patches to make it work correctly with some of the hardware on various
|
||||
Surface models, e.g. keyboard/trackpad, camera, wifi.
|
||||
|
||||
Not all hardware is fully supported, but the
|
||||
[linux-surface feature matrix](https://github.com/linux-surface/linux-surface/wiki/Supported-Devices-and-Features#feature-matrix)
|
||||
provides details on which devices are supported on which types of machine.
|
||||
|
||||
The kernel-specific derivations are under the `kernel/` sub-directory.
|
||||
In order to simplify maintenance of the Nix code, only the most-recent kernel patch-set is expected
|
||||
to be maintained in this repo.
|
||||
|
||||
_*NOTE:*_Some built-in Kernel config items need to be set, that aren't set by default:
|
||||
- https://github.com/linux-surface/surface-aggregator-module/wiki/Testing-and-Installing
|
||||
|
||||
## Firmware, Drivers and Support Tools
|
||||
|
||||
### WiFi
|
||||
|
||||
For the Surface Go, please see the "Issues" sections below.
|
||||
|
||||
### IPTS
|
||||
|
||||
IPTS is used on most of the Surface range, except for Surface Go and Surface Laptop 3 (AMD version).
|
||||
|
||||
Older kernels used specialised firmware which used a method that's no longer supported by the
|
||||
more-recent kernels.
|
||||
|
||||
Newer kernels use the kernel-space `intel-precise-touch` driver and user-space `ipstd` daemon.
|
||||
|
||||
The `iptsd` daemon works with the `intel-precise-touch` driver to convert raw touch data from the
|
||||
kernel-space driver into events for the HID / input sub-system.
|
||||
|
||||
- https://github.com/linux-surface/iptsd
|
||||
- https://github.com/linux-surface/intel-precise-touch
|
||||
- _*NOTE:*_ The patches from this repo are included in the above kernel patches, already.
|
||||
|
||||
### DTX, `surface-control`
|
||||
|
||||
*TODO*
|
||||
|
||||
# ToDo's Not Done
|
||||
|
||||
See: [TODO.org](./TODO.org)
|
||||
|
||||
# Issues
|
||||
|
||||
## TLP daemon
|
||||
|
||||
TLP is known to cause problems on Surface unless correctly configured.
|
||||
See: https://github.com/linux-surface/linux-surface/blob/master/README.md
|
||||
|
||||
## Wifi Firmware for Surface Go
|
||||
|
||||
On the Surface Go, the standard firmware from the official Linux Firmware repo has issues with the
|
||||
`ath10k` QCA6174 Wifi device.
|
||||
You will see messages like "Can't ping firmware" *TODO - Copy messages from console*
|
||||
|
||||
The most effective fix to-date is to remove the `board-2.bin` file or replace it with a copy of the
|
||||
`board.bin` file.
|
||||
|
||||
References:
|
||||
- https://github.com/jakeday/linux-surface/issues/441
|
||||
- https://www.reddit.com/r/SurfaceLinux/comments/e8quqg/surface_go_official_wifi_fix/
|
||||
- https://hackmd.io/@dasgeek/ryA5i5Dor
|
||||
- https://github.com/thebitstick/surfacego-wifi
|
||||
- https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/ath10k
|
||||
- https://wireless.wiki.kernel.org/en/users/drivers/ath10k/firmware
|
38
microsoft/surface/TODO.org
Normal file
38
microsoft/surface/TODO.org
Normal file
|
@ -0,0 +1,38 @@
|
|||
* Kernel Patching
|
||||
** DONE Create derivative to patch kernel 5.10.2
|
||||
- Latest from linux-surface
|
||||
- [X] Download github.com/linux-surface/linux-surface kernel patches
|
||||
- [X] Build kernel using downloaded patches
|
||||
** TODO Create a function for selecting preferred kernel
|
||||
** DONE Fix how Keyboard & Trackpad are not being enabled on SL3
|
||||
- https://github.com/linux-surface/surface-aggregator-module/wiki/Testing-and-Installing
|
||||
* Firmware
|
||||
** DONE Remove old firmware binaries
|
||||
- Looks like the ath10k files aren't needed, any more
|
||||
** DONE Create derivative for `ipts` firmware
|
||||
- [X] Download github.com/linux-surface/surface-ipts-firmware firmware
|
||||
- [X] Install the binaries
|
||||
** DONE Remove `ipts` firmware derivative
|
||||
- This is only needed on the 4.19 kernel
|
||||
** TODO Investigate problem with ath10k wifi firmware on Surface Go
|
||||
*** TODO README entry explaining problem(s) with nonfree firmware on Surface Go
|
||||
*** TODO Create derivative for `ath10k` firmware on Surface Go
|
||||
- [X] Download github.com/kvalo/ath10k-firmware ?
|
||||
- [X] Download kernel.org linux-firmware?
|
||||
- [ ] Download `board.bin` from Killer Networks?
|
||||
- [ ] Install ath10k firmware fix for Surface Go
|
||||
- `board-2.bin` needs to be removed / replaced with `board.bin`
|
||||
* Support Tools
|
||||
** TODO Incorporate @hpfr's function(s) from this commit:
|
||||
- https://github.com/hpfr/system/commit/03fa1b0a83f8a336e812910d0d50f5247a8a630c
|
||||
** TODO Create derivative for `iptsd` touch-screen daemon
|
||||
- [ ] Download
|
||||
- [ ] Install binary
|
||||
- [ ] Enable via systemd
|
||||
** TODO Create derivative to patch and rebuild libwacom
|
||||
- github.com/linux-surface/libwacom-surface
|
||||
- The plan is to do this in a separate PR against `nixpkgs` instead of `nixos-hardware`
|
||||
** TODO Create derivative to install `surface-control`
|
||||
- Download github.com/linux-surface/surface-control
|
||||
** TODO Create derivative to install `surface-dtx-daemon`
|
||||
- Download github.com/linux-surface/surface-dtx-daemon
|
8
microsoft/surface/default.nix
Normal file
8
microsoft/surface/default.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
./kernel
|
||||
./firmware
|
||||
./hardware_configuration.nix
|
||||
];
|
||||
}
|
6
microsoft/surface/firmware/default.nix
Normal file
6
microsoft/surface/firmware/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
hardware.enableAllFirmware = true;
|
||||
hardware.firmware = [
|
||||
];
|
||||
}
|
18
microsoft/surface/hardware_configuration.nix
Normal file
18
microsoft/surface/hardware_configuration.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
boot.extraModprobeConfig = lib.mkDefault ''
|
||||
options i915 enable_fbc=1 enable_rc6=1 modeset=1
|
||||
options snd_hda_intel power_save=1
|
||||
options snd_ac97_codec power_save=1
|
||||
options iwlwifi power_save=Y
|
||||
options iwldvm force_cam=N
|
||||
options ath10k_core skip_otp=Y
|
||||
'';
|
||||
|
||||
boot.kernelParams = [ "mem_sleep_default=deep" ];
|
||||
|
||||
# NOTE: Check the README before enabling TLP:
|
||||
services.tlp.enable = lib.mkDefault false;
|
||||
|
||||
hardware.sensor.iio.enable = lib.mkDefault true;
|
||||
}
|
5
microsoft/surface/kernel/default.nix
Normal file
5
microsoft/surface/kernel/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
boot.kernelPackages = pkgs.callPackage ./linux-5.10.2 {};
|
||||
}
|
112
microsoft/surface/kernel/linux-5.10.2/default.nix
Normal file
112
microsoft/surface/kernel/linux-5.10.2/default.nix
Normal file
|
@ -0,0 +1,112 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
repos = (pkgs.callPackage ../../repos.nix {});
|
||||
# TODO: Can I append the path ./patches instead of a string?
|
||||
patches = repos.linux-surface + "/patches";
|
||||
surface_kernelPatches = [
|
||||
{ name = "microsoft-surface-patches-linux-5.10.2";
|
||||
patch = null;
|
||||
extraConfig = ''
|
||||
#
|
||||
# Surface Aggregator Module
|
||||
#
|
||||
SURFACE_AGGREGATOR m
|
||||
SURFACE_AGGREGATOR_ERROR_INJECTION n
|
||||
SURFACE_AGGREGATOR_BUS y
|
||||
SURFACE_AGGREGATOR_CDEV m
|
||||
SURFACE_AGGREGATOR_REGISTRY m
|
||||
SURFACE_ACPI_NOTIFY m
|
||||
SURFACE_BATTERY m
|
||||
SURFACE_DTX m
|
||||
SURFACE_HID m
|
||||
SURFACE_PERFMODE m
|
||||
|
||||
#
|
||||
# These built-in modules are required for the Surface Aggregator Module
|
||||
# See: https://github.com/linux-surface/surface-aggregator-module/wiki/Testing-and-Installing
|
||||
#
|
||||
SERIAL_DEV_BUS y
|
||||
SERIAL_DEV_CTRL_TTYPORT y
|
||||
|
||||
#
|
||||
# Surface Hotplug
|
||||
#
|
||||
SURFACE_HOTPLUG m
|
||||
|
||||
#
|
||||
# IPTS touchscreen
|
||||
#
|
||||
# This only enables the user interface for IPTS data.
|
||||
# For the touchscreen to work, you need to install iptsd.
|
||||
#
|
||||
MISC_IPTS m
|
||||
|
||||
#
|
||||
# Cameras: IPU3
|
||||
#
|
||||
## TODO: Fix for kernel 5.10.2:
|
||||
##VIDEO_IPU3_IMGU m
|
||||
VIDEO_IPU3_CIO2 m
|
||||
CIO2_BRIDGE y
|
||||
INT3472 m
|
||||
|
||||
#
|
||||
# Cameras: Sensor drivers
|
||||
#
|
||||
VIDEO_OV5693 m
|
||||
## TODO: Fix for kernel 5.10.2:
|
||||
##VIDEO_OV8865 m
|
||||
|
||||
#
|
||||
# Other Drivers
|
||||
#
|
||||
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
|
||||
'';
|
||||
}
|
||||
{
|
||||
name = "ms-surface/0001-surface3-oemb";
|
||||
patch = patches + "/5.10/0001-surface3-oemb.patch";
|
||||
}
|
||||
{
|
||||
name = "ms-surface/0002-wifi";
|
||||
patch = patches + "/5.10/0002-wifi.patch";
|
||||
}
|
||||
{
|
||||
name = "ms-surface/0003-ipts";
|
||||
patch = patches + "/5.10/0003-ipts.patch";
|
||||
}
|
||||
{
|
||||
name = "ms-surface/0004-surface-gpe";
|
||||
patch = patches + "/5.10/0004-surface-gpe.patch";
|
||||
}
|
||||
{
|
||||
name = "ms-surface/0005-surface-sam-over-hid";
|
||||
patch = patches + "/5.10/0005-surface-sam-over-hid.patch";
|
||||
}
|
||||
{
|
||||
name = "ms-surface/0006-surface-sam";
|
||||
patch = patches + "/5.10/0006-surface-sam.patch";
|
||||
}
|
||||
{
|
||||
name = "ms-surface/0007-surface-hotplug";
|
||||
patch = patches + "/5.10/0007-surface-hotplug.patch";
|
||||
}
|
||||
{
|
||||
name = "ms-surface/0008-surface-typecover";
|
||||
patch = patches + "/5.10/0008-surface-typecover.patch";
|
||||
}
|
||||
{
|
||||
name = "ms-surface/0009-cameras";
|
||||
patch = patches + "/5.10/0009-cameras.patch";
|
||||
}
|
||||
];
|
||||
in (with pkgs; recurseIntoAttrs (linuxPackagesFor (
|
||||
callPackage ./linux-5.10.2.nix {
|
||||
kernelPatches = surface_kernelPatches;
|
||||
}
|
||||
)))
|
18
microsoft/surface/kernel/linux-5.10.2/linux-5.10.2.nix
Normal file
18
microsoft/surface/kernel/linux-5.10.2/linux-5.10.2.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ stdenv, buildPackages, fetchurl, perl, buildLinux, modDirVersionArg ? null, ... } @ args:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
buildLinux (args // rec {
|
||||
version = "5.10.2";
|
||||
|
||||
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
||||
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
|
||||
|
||||
# branchVersion needs to be x.y
|
||||
extraMeta.branch = versions.majorMinor version;
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz";
|
||||
sha256 = "18l1ywp99inm90434fm74w8rjfl4yl974kfcpizg2sp2p8xf311v";
|
||||
};
|
||||
} // (args.argsOverride or {}))
|
8
microsoft/surface/repos.nix
Normal file
8
microsoft/surface/repos.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{ lib, pkgs, fetchgit }:
|
||||
{
|
||||
linux-surface = fetchgit {
|
||||
url="https://github.com/linux-surface/linux-surface.git";
|
||||
rev="25ab2cf75e5eda5ab9739db1907300010c06dacf";
|
||||
sha256="0h8624d7ix1p6ysw9bllmnnwnv164z8xkx56zj3vdczn91vmqcf9";
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue