Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpd-win-max-2-2023: init #804

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>` |
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions gpd/win-max-2/2023/default.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 67 additions & 0 deletions gpd/win-max-2/default.nix
Original file line number Diff line number Diff line change
@@ -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}"
'';
};
}