1
0
Fork 0
mirror of https://github.com/NixOS/nixos-hardware synced 2024-12-27 12:09:45 +01:00

Merge branch 'microsoft/surface/specialisation/common-files' into microsoft/surface/specialisation/surface-go

This commit is contained in:
mexisme 2023-01-11 01:51:01 +13:00
commit 5b713dd72e
11 changed files with 187 additions and 57 deletions

View file

@ -195,8 +195,7 @@ See code for all available configurations.
| [MSI GL62/CX62](msi/gl62) | `<nixos-hardware/msi/gl62>` |
| [Microsoft Surface Pro 3](microsoft/surface-pro/3) | `<nixos-hardware/microsoft/surface-pro/3>` |
| [Microsoft Surface Go](microsoft/surface/surface-go) | `<nixos-hardware/microsoft/surface/surface-go>` |
| [Microsoft Surface Range (Deprecated version)](microsoft/surface) | `<nixos-hardware/microsoft/surface>` |
| [Microsoft Surface Range (Old Behaviour)](microsoft/surface/old) | `<nixos-hardware/microsoft/surface/old>` |
| [Microsoft Surface Range (Common Modules)](microsoft/surface/common)| `<nixos-hardware/microsoft/surface/common>` |
| [Omen en00015p](omen/en00015p) | `<nixos-hardware/omen/en00015p>` |
| [One-Netbook OneNetbook 4](onenetbook/4) | `<nixos-hardware/onenetbook/4>` |
| [Panasonic Let's Note CF-LX4 ](panasonic/letsnote/cf-lx4) | `<nixos-hardware/panasonic/letsnote/cf-lx4>` |

View file

@ -130,9 +130,8 @@
lenovo-thinkpad-z13 = import ./lenovo/thinkpad/z/z13;
lenovo-yoga-6-13ALC6 = import ./lenovo/yoga/6/13ALC6;
letsnote-cf-lx4 = import ./panasonic/letsnote/cf-lx4;
microsoft-surface = import ./microsoft/surface;
microsoft-surface-common = import ./microsoft/surface/common;
microsoft-surface-go = import ./microsoft/surface/surface-go;
microsoft-surface-old-behaviour = import ./microsoft/surface/old;
microsoft-surface-pro-3 = import ./microsoft/surface-pro/3;
msi-gs60 = import ./msi/gs60;
msi-gl62 = import ./msi/gl62;

View file

@ -11,6 +11,16 @@ models, and they would fail gracefully enough that we could mostly ignore warnin
Now, however --- as-of 2023-01-10 --- we have a much wider variety of chipsets, incl. models with
some of the newer AMD CPUs, and this is breaking small things in annoying ways for more people.
## How to update
By preference, there will already be a specialised module for your model's configuration.
If not, the `microsoft/surface/common/` module can also be imported directly, and the options
provided can be used in your own system's configuration.
Alternatively, you can create a new specialisation for your model under `microsoft/surface`
configured for that model.
## Changes
### Model Specialisations
@ -33,12 +43,12 @@ Tools / services that are shared among several models are now extracted to their
`common/` and imported by `common/default.nix`.
These new "common" modules now have an `enable` option, which is `false` by default.
### "Old Behaviour" module
### "Deprecated Behaviour" module
The original `./default.nix` module has been replaced by a new `old/` module, which replicates the
The original `./default.nix` module has been replaced by a new `deprecated/` module, which replicates the
original behaviour.
The new `./default.nix` will load the new `old/` module, but will also pop-up a warning asking users
The new `./default.nix` will load the new `deprecated/` module, but will also pop-up a warning asking users
to update how they use the microsoft/surface profile from now on.
This warning will probably change to a fail assertion at some point in the future.

View file

@ -1,13 +1,28 @@
# NOTE: Structure changes from 2023-01-10
Please read the [Old Behaviour README](./old/README.md) to understand how some structural changes to
Please read the [Deprecated Behaviour README](./OLD-BEHAVIOUR-DEPRECATED.md) to understand how some structural changes to
the code might affect you!
# Derivatives for Microsoft Surface notebooks
# Derivations 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
## Importing
By preference, there will already be a specialised module for your model's configuration.
If not, the `microsoft/surface/common/` module can also be imported directly, and the options
provided can be used in your own system's configuration.
Alternatively, you can create a new specialisation for your model under `microsoft/surface`
configured for that model.
## Common Modules
Most shared / common modules are under the [`common/`](./common/) directory.
This includes the patched kernel build modules, as well as tools and service like `IPTSd` and `surface-control`.
### 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.
@ -16,21 +31,19 @@ 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.
The kernel-specific derivations are under the [`common/kernel/`](./common/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.
### Support Tools
### IPTS
Enable this with the `microsoft-surface.ipts.enable = true;` config option.
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
@ -49,10 +62,21 @@ kernel-space driver into events for the HID / input sub-system.
#### surface-control
Enable this with the `config.microsoft-surface.surface-control.enable = true;` config option.
For controlling the performance modes and other aspects of the device, the [`surface-control`](https://github.com/linux-surface/surface-control) tool is included.
To be able to control the performance mode without using `sudo`, add your user to the `surface-control` group.
## Firmware and Drivers
### WiFi on Surface Go
For the Surface Go, please see the "Issues" sections below.
Including the [`microsoft/surface/surface-go/firmware/ath-10k/`](./surface-go/firmware/ath-10k/)
module will replace the default firmware with the updated firmware.
# ToDo's Not Done
See: [TODO.org](./TODO.org)
@ -73,8 +97,8 @@ You will see messages like "Can't ping firmware".
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.
The derivative in `firmware/surface-go/ath10k/` can configure this, if you set the option
`config.hardware.microsoft-surface.firmware.surface-go-ath10k.replace` to `true`.
The derivative in `surface-go/firmware/ath10k/` can configure this, with the
`config.hardware.microsoft-surface.firmware.surface-go-ath10k.replace = true` config option.
_*NOTE:*_ This is destructive, as it deletes all the `board.bin` and `board-2.bin` files for the
`ath10k` QCA6174 device, and replaces them with KillerNetworking's version.

View file

@ -10,7 +10,7 @@ in {
./surface-control
];
microsoft-surface.kernelVersion = mkDefault "6.0.11";
microsoft-surface.kernelVersion = mkDefault "6.0.17";
# Seems to be required to properly enable S0ix "Modern Standby":
boot.kernelParams = mkDefault [ "mem_sleep_default=deep" ];

View file

@ -6,7 +6,7 @@ let
in {
imports = [
./linux-5.19.17
./linux-6.0.11
./linux-6.0.17
];
options.microsoft-surface.kernelVersion = mkOption {

View file

@ -8,7 +8,7 @@ let
cfg = config.microsoft-surface;
version = "6.0.11";
version = "6.0.17";
extraMeta.branch = "6.0";
patchDir = repos.linux-surface + "/patches/${extraMeta.branch}";
kernelPatches = pkgs.callPackage ./patches.nix {
@ -20,17 +20,17 @@ let
inherit version extraMeta kernelPatches;
src = fetchurl {
url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz";
sha256 = "sha256-K65hMeZJceHjT/OV+lQpcRNMhXvbCykGmrhHx8mpx2I=";
sha256 = "sha256-p+6SCSpUWbtGq/C1RJpOV+i3klkaxOesBO0lQtLOHQg=";
};
};
in {
options.microsoft-surface.kernelVersion = mkOption {
type = types.enum [ "6.0.11" ];
type = types.enum [ "6.0.17" ];
};
config = mkIf (cfg.kernelVersion == "6.0.11") {
config = mkIf (cfg.kernelVersion == "6.0.17") {
boot = {
inherit kernelPackages;
};

View file

@ -0,0 +1,122 @@
{ kernel,
patchDir,
version,
}:
[
{
name = "microsoft-surface-patches-linux-${version}";
patch = null;
structuredExtraConfig = with kernel; {
#
# Surface Aggregator Module
#
CONFIG_SURFACE_AGGREGATOR = module;
CONFIG_SURFACE_AGGREGATOR_ERROR_INJECTION = no;
CONFIG_SURFACE_AGGREGATOR_BUS = yes;
CONFIG_SURFACE_AGGREGATOR_CDEV = module;
CONFIG_SURFACE_AGGREGATOR_HUB = module;
CONFIG_SURFACE_AGGREGATOR_REGISTRY = module;
CONFIG_SURFACE_AGGREGATOR_TABLET_SWITCH = module;
CONFIG_SURFACE_ACPI_NOTIFY = module;
CONFIG_SURFACE_DTX = module;
CONFIG_SURFACE_PLATFORM_PROFILE = module;
CONFIG_SURFACE_HID = module;
CONFIG_SURFACE_KBD = module;
CONFIG_BATTERY_SURFACE = module;
CONFIG_CHARGER_SURFACE = module;
#
# Surface Hotplug
#
CONFIG_SURFACE_HOTPLUG = module;
#
# IPTS touchscreen
#
# This only enables the user interface for IPTS data.
# For the touchscreen to work, you need to install iptsd.
#
CONFIG_MISC_IPTS = module;
#
# Cameras: IPU3
#
CONFIG_VIDEO_DW9719 = module;
CONFIG_VIDEO_IPU3_IMGU = module;
CONFIG_VIDEO_IPU3_CIO2 = module;
CONFIG_CIO2_BRIDGE = yes;
CONFIG_INTEL_SKL_INT3472 = module;
CONFIG_REGULATOR_TPS68470 = module;
CONFIG_COMMON_CLK_TPS68470 = module;
#
# Cameras: Sensor drivers
#
CONFIG_VIDEO_OV5693 = module;
CONFIG_VIDEO_OV7251 = module;
CONFIG_VIDEO_OV8865 = module;
#
# ALS Sensor for Surface Book 3, Surface Laptop 3, Surface Pro 7
#
CONFIG_APDS9960 = module;
#
# Other Drivers
#
CONFIG_INPUT_SOC_BUTTON_ARRAY = module;
CONFIG_SURFACE_3_POWER_OPREGION = module;
CONFIG_SURFACE_PRO3_BUTTON = module;
CONFIG_SURFACE_GPE = module;
CONFIG_SURFACE_BOOK1_DGPU_SWITCH = module;
};
}
{
name = "ms-surface/0001-surface3-oemb";
patch = patchDir + "/0001-surface3-oemb.patch";
}
{
name = "ms-surface/0002-mwifiex";
patch = patchDir + "/0002-mwifiex.patch";
}
{
name = "ms-surface/0003-ath10k";
patch = patchDir + "/0003-ath10k.patch";
}
{
name = "ms-surface/0004-ipts";
patch = patchDir + "/0004-ipts.patch";
}
{
name = "ms-surface/0005-surface-sam";
patch = patchDir + "/0005-surface-sam.patch";
}
{
name = "ms-surface/0006-surface-sam-over-hid";
patch = patchDir + "/0006-surface-sam-over-hid.patch";
}
{
name = "ms-surface/0007-surface-button";
patch = patchDir + "/0007-surface-button.patch";
}
{
name = "ms-surface/0008-surface-typecover";
patch = patchDir + "/0008-surface-typecover.patch";
}
{
name = "ms-surface/0009-cameras";
patch = patchDir + "/0009-cameras.patch";
}
{
name = "ms-surface/0010-amd-gpio";
patch = patchDir + "/0010-amd-gpio.patch";
}
{
name = "ms-surface/0011-rtc";
patch = patchDir + "/0011-rtc.patch";
}
]

View file

@ -4,8 +4,8 @@
linux-surface = fetchFromGitHub {
owner = "linux-surface";
repo = "linux-surface";
rev = "8995c6b3b4fb659397f4ebc760c6ac8b5efc5488";
sha256 = "sha256-r7nbW0WKmvw7mMZL1BzuFwgwftyN5FIfP5xLDiQMEiI=";
rev = "487e64047ca047dde9a062909a87410e7bb86845";
sha256 = "sha256-HTIuRBZk0prhUPd2KnsXGo+ZyBsMwERN7P8WJH1RG3M=";
};
# This is the owner and repo for the pre-patched kernel from the "linux-surface" project:

View file

@ -1,12 +1,10 @@
{ lib, ... }:
{ ... }:
let
inherit (lib) warn;
in {
imports = [
( warn
"Please don't import microsoft/surface/ (default.nix) any longer; use microsoft/surface/old or see microsoft/surface/old/README.md for more details."
./old )
{
assertions = [
{
assertion = false;
message = "Importing microsoft/surface/ (default.nix) directly is deprecated! See microsoft/surface/OLD-BEHAVIOUR-DEPRECATED.md for more details.";
}
];
}

View file

@ -1,22 +0,0 @@
{ lib, pkgs, ... }:
let
inherit (lib) mkDefault;
in {
imports = [
../common
../surface-go/firmware/ath10k
];
boot.extraModprobeConfig = 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
'';
microsoft-surface.surface-control.enable = true;
microsoft-surface.ipts.enable = true;
}