1
0
Fork 0
mirror of https://github.com/NixOS/nixos-hardware synced 2024-11-23 03:19:42 +01:00

gpd-win-max-2-2023: init

This commit is contained in:
Cryolitia 2023-12-25 09:04:38 +08:00 committed by mergify[bot]
parent 7763c6fd1f
commit e4ded1ec8e
4 changed files with 87 additions and 0 deletions

View file

@ -142,6 +142,7 @@ See code for all available configurations.
| [GPD P2 Max](gpd/p2-max) | `<nixos-hardware/gpd/p2-max>` |
| [GPD Pocket 3](gpd/pocket-3) | `<nixos-hardware/gpd/pocket-3>` |
| [GPD WIN 2](gpd/win-2) | `<nixos-hardware/gpd/win-2>` |
| [GPD WIN Max 2 2023](gpd/win-max-2/2023) | `<nixos-hardware/gpd/win-max-2/2023>` |
| [Google Pixelbook](google/pixelbook) | `<nixos-hardware/google/pixelbook>` |
| [HP Elitebook 2560p](hp/elitebook/2560p) | `<nixos-hardware/hp/elitebook/2560p>` |
| [HP Elitebook 845g7](hp/elitebook/845/g7) | `<nixos-hardware/hp/elitebook/845/g7>` |

View file

@ -78,6 +78,7 @@
gpd-p2-max = import ./gpd/p2-max;
gpd-pocket-3 = import ./gpd/pocket-3;
gpd-win-2 = import ./gpd/win-2;
gpd-win-max-2-2023 = import ./gpd/win-max-2/2023;
hp-elitebook-2560p = import ./hp/elitebook/2560p;
hp-elitebook-845g7 = import ./hp/elitebook/845/g7;
hp-elitebook-845g9 = import ./hp/elitebook/845/g9;

View file

@ -0,0 +1,18 @@
{ config, lib, pkgs, ...}:
with lib;
let
cfg = config.hardware.gpd.ppt;
in
{
imports = [
./..
../../../common/cpu/amd
../../../common/cpu/amd/pstate.nix
../../../common/gpu/amd
];
# fix suspend problem: https://www.reddit.com/r/gpdwin/comments/16veksm/win_max_2_2023_linux_experience_suspend_problems/
services.udev.extraRules = ''
ACTION=="add" SUBSYSTEM=="pci" ATTR{vendor}=="0x1022" ATTR{device}=="0x14ee" ATTR{power/wakeup}="disabled"
'';
}

67
gpd/win-max-2/default.nix Normal file
View file

@ -0,0 +1,67 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.gpd.ppt;
in
{
imports = [
../../common/pc/laptop
../../common/pc/ssd
../../common/hidpi.nix
];
# Linux default PPT is 24-22-22, BIOS default PPT is 35-32-28. It can be controlled by ryzenadj.
# NOTICE: Whenever you can limit PPT to 15W by pressing Fn + Shift to enter quiet mode.
options.hardware.gpd.ppt = {
enable = mkEnableOption (mdDoc "Enable PPT control for device by ryzenadj.") // {
# Default increase PPT to the BIOS default when power adapter plugin to increase performance.
default = true;
};
adapter = {
fast-limit = mkOption {
description = "Fast PTT Limit(milliwatt) when power adapter plugin.";
default = 35000;
type = types.ints.unsigned;
};
slow-limit = mkOption {
description = "Slow PTT Limit(milliwatt) when power adapter plugin.";
default = 32000;
type = types.ints.unsigned;
};
stapm-limit = mkOption {
description = "Stapm PTT Limit(milliwatt) when power adapter plugin.";
default = 28000;
type = types.ints.unsigned;
};
};
battery = {
fast-limit = mkOption {
description = "Fast PTT Limit(milliwatt) when using battery.";
default = 24000;
type = types.ints.unsigned;
};
slow-limit = mkOption {
description = "Slow PTT Limit(milliwatt) when using battery.";
default = 22000;
type = types.ints.unsigned;
};
stapm-limit = mkOption {
description = "Stapm PTT Limit(milliwatt) when using battery.";
default = 22000;
type = types.ints.unsigned;
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.ryzenadj ];
services.udev.extraRules = ''
SUBSYSTEM=="power_supply", KERNEL=="ADP1", ATTR{online}=="1", RUN+="${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit ${toString cfg.adapter.stapm-limit} --fast-limit ${toString cfg.adapter.fast-limit} --slow-limit ${toString cfg.adapter.slow-limit}"
SUBSYSTEM=="power_supply", KERNEL=="ADP1", ATTR{online}=="0", RUN+="${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit ${toString cfg.battery.stapm-limit} --fast-limit ${toString cfg.battery.fast-limit} --slow-limit ${toString cfg.battery.slow-limit}"
'';
};
}