1
0
mirror of https://github.com/NixOS/nixos-hardware synced 2024-06-02 19:13:33 +02: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>` | | [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 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 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 (Common Modules)](microsoft/surface/common)| `<nixos-hardware/microsoft/surface/common>` |
| [Microsoft Surface Range (Old Behaviour)](microsoft/surface/old) | `<nixos-hardware/microsoft/surface/old>` |
| [Omen en00015p](omen/en00015p) | `<nixos-hardware/omen/en00015p>` | | [Omen en00015p](omen/en00015p) | `<nixos-hardware/omen/en00015p>` |
| [One-Netbook OneNetbook 4](onenetbook/4) | `<nixos-hardware/onenetbook/4>` | | [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>` | | [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-thinkpad-z13 = import ./lenovo/thinkpad/z/z13;
lenovo-yoga-6-13ALC6 = import ./lenovo/yoga/6/13ALC6; lenovo-yoga-6-13ALC6 = import ./lenovo/yoga/6/13ALC6;
letsnote-cf-lx4 = import ./panasonic/letsnote/cf-lx4; 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-go = import ./microsoft/surface/surface-go;
microsoft-surface-old-behaviour = import ./microsoft/surface/old;
microsoft-surface-pro-3 = import ./microsoft/surface-pro/3; microsoft-surface-pro-3 = import ./microsoft/surface-pro/3;
msi-gs60 = import ./msi/gs60; msi-gs60 = import ./msi/gs60;
msi-gl62 = import ./msi/gl62; 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 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. 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 ## Changes
### Model Specialisations ### 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`. `common/` and imported by `common/default.nix`.
These new "common" modules now have an `enable` option, which is `false` by default. 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. 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. 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. 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 # 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! 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). 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 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. 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) [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. 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 In order to simplify maintenance of the Nix code, only the most-recent kernel patch-set is expected
to be maintained in this repo. to be maintained in this repo.
_*NOTE:*_ Some built-in Kernel config items need to be set, that aren't set by default: _*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 - https://github.com/linux-surface/surface-aggregator-module/wiki/Testing-and-Installing
## Firmware, Drivers and Support Tools ### Support Tools
### WiFi
For the Surface Go, please see the "Issues" sections below.
### IPTS ### 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). 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 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 #### 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. 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. 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 # ToDo's Not Done
See: [TODO.org](./TODO.org) 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 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. `board.bin` file.
The derivative in `firmware/surface-go/ath10k/` can configure this, if you set the option The derivative in `surface-go/firmware/ath10k/` can configure this, with the
`config.hardware.microsoft-surface.firmware.surface-go-ath10k.replace` to `true`. `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 _*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. `ath10k` QCA6174 device, and replaces them with KillerNetworking's version.

View File

@ -10,7 +10,7 @@ in {
./surface-control ./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": # Seems to be required to properly enable S0ix "Modern Standby":
boot.kernelParams = mkDefault [ "mem_sleep_default=deep" ]; boot.kernelParams = mkDefault [ "mem_sleep_default=deep" ];

View File

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

View File

@ -8,7 +8,7 @@ let
cfg = config.microsoft-surface; cfg = config.microsoft-surface;
version = "6.0.11"; version = "6.0.17";
extraMeta.branch = "6.0"; extraMeta.branch = "6.0";
patchDir = repos.linux-surface + "/patches/${extraMeta.branch}"; patchDir = repos.linux-surface + "/patches/${extraMeta.branch}";
kernelPatches = pkgs.callPackage ./patches.nix { kernelPatches = pkgs.callPackage ./patches.nix {
@ -20,17 +20,17 @@ let
inherit version extraMeta kernelPatches; inherit version extraMeta kernelPatches;
src = fetchurl { src = fetchurl {
url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz"; url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz";
sha256 = "sha256-K65hMeZJceHjT/OV+lQpcRNMhXvbCykGmrhHx8mpx2I="; sha256 = "sha256-p+6SCSpUWbtGq/C1RJpOV+i3klkaxOesBO0lQtLOHQg=";
}; };
}; };
in { in {
options.microsoft-surface.kernelVersion = mkOption { 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 = { boot = {
inherit kernelPackages; 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 { linux-surface = fetchFromGitHub {
owner = "linux-surface"; owner = "linux-surface";
repo = "linux-surface"; repo = "linux-surface";
rev = "8995c6b3b4fb659397f4ebc760c6ac8b5efc5488"; rev = "487e64047ca047dde9a062909a87410e7bb86845";
sha256 = "sha256-r7nbW0WKmvw7mMZL1BzuFwgwftyN5FIfP5xLDiQMEiI="; sha256 = "sha256-HTIuRBZk0prhUPd2KnsXGo+ZyBsMwERN7P8WJH1RG3M=";
}; };
# This is the owner and repo for the pre-patched kernel from the "linux-surface" project: # 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; assertions = [
{
in { assertion = false;
imports = [ message = "Importing microsoft/surface/ (default.nix) directly is deprecated! See microsoft/surface/OLD-BEHAVIOUR-DEPRECATED.md for more details.";
( 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 )
]; ];
} }

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;
}