Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
540c80a
Initial port from github.com/linux-surface/linux-surface, vendorising…
mexisme Jan 13, 2020
6ee57bb
Add a TODO tracking doc
mexisme Jan 2, 2021
eda6f9d
Add Kernel 5.9.2 patches
mexisme Nov 1, 2020
d3fb0c7
Use Kernel 5.9.2 on Surface Go
mexisme Nov 1, 2020
ac8f98f
Create a "repos" nix file
mexisme Jan 2, 2021
54b7d7e
Drop the ath10k firmware, build the ipts firmware (again)
mexisme Jan 2, 2021
233c69d
Use the upstream repo to provide the ipts firmware
mexisme Jan 2, 2021
bf271c9
Delete vendored IPTS and ath10k firmware
mexisme Jan 3, 2021
4533632
Build the 5.10.4 kernel using the upstream patches, instead of local …
mexisme Jan 2, 2021
d6a9c7e
Refactor kernels and patches for MS Surface
mexisme Jan 3, 2021
aa0dc15
Remove vendored 5.1, 5.2, 5.3, 5.4, 5.5 and 5.9 kernel patches
mexisme Jan 3, 2021
079b01a
Update Kernels
mexisme Jan 3, 2021
2243dad
Update TODO.org
mexisme Jan 3, 2021
c400fde
Beginnings of README
mexisme Jan 9, 2021
db5fb34
Update README
mexisme Jan 12, 2021
fc3efdc
Remove `ipts` firmware derivative.
mexisme Jan 12, 2021
7b884ec
Merge remote-tracking branch 'upstream/master' into microsoft/surface…
mexisme Jan 13, 2021
5af4629
Fix for enabling Keyboard and Trackpad on Surface Laptop 3 (et al)
mexisme Jan 14, 2021
b5d482b
Update README
mexisme Jan 14, 2021
c72a04b
Remove obsolete surface-ipts-firmware repo entry
mexisme Jan 23, 2021
a8d7159
Remove the libwacom-surface repos
mexisme Jan 23, 2021
cbad2d9
Update README
mexisme Jan 23, 2021
09f8a21
Update TODO's
mexisme Jan 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions microsoft/surface/README.md
Original file line number Diff line number Diff line change
@@ -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 changes: 38 additions & 0 deletions microsoft/surface/TODO.org
Original file line number Diff line number Diff line change
@@ -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 changes: 8 additions & 0 deletions microsoft/surface/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ config, lib, pkgs, ... }:
{
imports = [
./kernel
./firmware
./hardware_configuration.nix
];
}
6 changes: 6 additions & 0 deletions microsoft/surface/firmware/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ config, lib, pkgs, ... }:
{
hardware.enableAllFirmware = true;
hardware.firmware = [
];
}
18 changes: 18 additions & 0 deletions microsoft/surface/hardware_configuration.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions microsoft/surface/kernel/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ config, lib, pkgs, ... }:

{
boot.kernelPackages = pkgs.callPackage ./linux-5.10.2 {};
}
112 changes: 112 additions & 0 deletions microsoft/surface/kernel/linux-5.10.2/default.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions microsoft/surface/kernel/linux-5.10.2/linux-5.10.2.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 8 additions & 0 deletions microsoft/surface/repos.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ lib, pkgs, fetchgit }:
{
linux-surface = fetchgit {
url="https://github.com/linux-surface/linux-surface.git";
rev="25ab2cf75e5eda5ab9739db1907300010c06dacf";
sha256="0h8624d7ix1p6ysw9bllmnnwnv164z8xkx56zj3vdczn91vmqcf9";
};
}