Skip to content

Commit

Permalink
Adding support for GV302X* 2023 (#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjhaleprogrammer authored and mergify[bot] committed Jan 7, 2025
1 parent b98df18 commit d3b4fe4
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ See code for all available configurations.
| [Apple Macs with a T2 Chip](apple/t2) | `<nixos-hardware/apple/t2>` |
| [Asus Pro WS X570-ACE](asus/pro-ws-x570-ace) | `<nixos-hardware/asus/pro-ws-x570-ace>` |
| [Asus ROG Ally RC71L (2023)](asus/ally/rc71l) | `<nixos-hardware/asus/ally/rc71l>` |
| [Asus ROG Flow X13 GV302X\* (2023)](asus/zephyrus/gv302x/amdgpu) | `<nixos-hardware/asus/flow/gv302x/amdgpu>` |
| [Asus ROG Flow X13 GV302X\* (2023)](asus/zephyrus/gv302x/nvidia) | `<nixos-hardware/asus/flow/gv302x/nvidia>` |
| [Asus ROG Strix G513IM](asus/rog-strix/g513im) | `<nixos-hardware/asus/rog-strix/g513im>` |
| [Asus ROG Strix G713IE](asus/rog-strix/g713ie) | `<nixos-hardware/asus/rog-strix/g713ie>` |
| [Asus ROG Strix G733QS](asus/rog-strix/g733qs) | `<nixos-hardware/asus/rog-strix/g733qs>` |
Expand Down
44 changes: 44 additions & 0 deletions asus/flow/gv302x/amdgpu/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{ config,
lib,
...
}:

let
inherit (lib) mkEnableOption mkIf mkMerge;
cfg = config.hardware.asus.flow.gv302x;

in {
imports = [
../shared.nix
];

options.hardware.asus.flow.gv302x.amdgpu = {
recovery.enable = (mkEnableOption "Enable amdgpu.gpu_recovery kernel boot param") // { default = false; };
sg_display.enable = (mkEnableOption "Enable amdgpu.gpu_recovery kernel boot param") // { default = true; };
psr.enable = (mkEnableOption "Enable amdgpu.dcdebugmask=0x10 kernel boot param") // { default = true; };
};

config = mkMerge [
(mkIf cfg.amdgpu.recovery.enable {
# Hopefully fixes for where the kernel sometimes hangs when suspending or hibernating
# (Though, I'm very suspicious of the Mediatek Wifi...)
boot.kernelParams = [
"amdgpu.gpu_recovery=1"
];
})

(mkIf (!cfg.amdgpu.sg_display.enable) {
# Can help solve flickering/glitching display issues since Scatter/Gather code was reenabled
boot.kernelParams = [
"amdgpu.sg_display=0"
];
})

(mkIf (!cfg.amdgpu.psr.enable) {
# Can help solve flickering/glitching display issues since Scatter/Gather code was reenabled
boot.kernelParams = [
"amdgpu.dcdebugmask=0x10"
];
})
];
}
58 changes: 58 additions & 0 deletions asus/flow/gv302x/nvidia/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{ lib,
pkgs,
config,
...
}:

let
inherit (lib) mkDefault;

in {
imports = [
../shared.nix
## "prime.nix" loads this, aleady:
# ../../../common/gpu/nvidia
../../../../common/gpu/nvidia/prime.nix
../../../../common/gpu/nvidia/ada-lovelace

];

# NVIDIA GeForce RTX 4070 Mobile

boot = {
blacklistedKernelModules = [ "nouveau" ];
};



hardware = {
## Enable the Nvidia card, as well as Prime and Offload:
amdgpu.initrd.enable = mkDefault true;

nvidia = {

#to avoid problems with gnome 47 vulkan
package = mkDefault config.boot.kernelPackages.nvidiaPackages.beta;

modesetting.enable = true;
nvidiaSettings = mkDefault true;

prime = {
offload = {
enable = mkDefault true;
enableOffloadCmd = mkDefault true;
};
amdgpuBusId = "PCI:69:0:0";
nvidiaBusId = "PCI:1:0:0";
};

powerManagement = {
enable = mkDefault true;
finegrained = mkDefault true;
};

dynamicBoost.enable = mkDefault true;

};
};
}
106 changes: 106 additions & 0 deletions asus/flow/gv302x/shared.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{ config,
pkgs,
lib,
...
}:

let
inherit (lib) mkDefault mkEnableOption mkIf mkMerge version versionAtLeast versionOlder;

cfg = config.hardware.asus.flow.gv302x;
in {

imports = [
../../../common/cpu/amd
# Better power-savings from AMD PState:
../../../common/cpu/amd/pstate.nix
../../../common/gpu/amd
../../../common/pc/laptop
../../../common/pc/ssd
];

options.hardware.asus.flow.gv302x = {
# Kernels earlier than 6.9 (possibly even earlier) tend to take 1-2 key-presses
# to wake-up the internal keyboard after the device is suspended.
# Therefore, this option disables auto-suspend for the keyboard by default, but
# enables it for kernel 6.9.x onwards.
#
# Note: the device name is "ASUS N-KEY Device".
keyboard.autosuspend.enable = (
mkEnableOption "Enable auto-suspend on the internal USB keyboard (ASUS N-KEY Device) on Flow GV302X"
) // {
default = versionAtLeast config.boot.kernelPackages.kernel.version "6.9";
defaultText = lib.literalExpression "lib.versionAtLeast config.boot.kernelPackages.kernel.version \"6.9\"";
};
# The ASUS 8295 ITE device will cause an immediate wake-up when trying to suspend the laptop.
# After the first successful hibernate, it will work as expected, however.
# NOTE: I'm not actually sure what this device, as neither the touchpad nor the M1-M4 keys cause a wake-up.
ite-device.wakeup.enable = mkEnableOption "Enable power wakeup on the internal USB keyboard-like device (8295 ITE Device) on Flow GV302X";
};

config = mkMerge [
{
# Configure basic system settings:
boot = {
kernelModules = [ "kvm-amd" ];
kernelParams = [
"mem_sleep_default=deep"
"pcie_aspm.policy=powersupersave"
];
};

services = {
asusd = {
enable = mkDefault true;
enableUserService = mkDefault true;
};

supergfxd.enable = mkDefault true;

udev = {
extraHwdb = ''
# Fixes mic mute button
evdev:name:*:dmi:bvn*:bvr*:bd*:svnASUS*:pn*:*
KEYBOARD_KEY_ff31007c=f20
'';
};
};

#flow devices are 2 in 1 laptops
hardware.sensor.iio.enable = mkDefault true;

}

(mkIf (! cfg.keyboard.autosuspend.enable) {
services.udev.extraRules = ''
# Disable power auto-suspend for the ASUS N-KEY device, i.e. USB Keyboard.
# Otherwise on certain kernel-versions, it will tend to take 1-2 key-presses to wake-up after the device suspends.
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend", ATTR{idVendor}=="0b05", ATTR{idProduct}=="19b6", ATTR{power/autosuspend}="-1"
'';
})

(mkIf (! cfg.ite-device.wakeup.enable) {
services.udev.extraRules = ''
# Disable power wakeup for the 8295 ITE device.
# Otherwise on certain kernel-versions, it will tend to cause the laptop to immediately wake-up when suspending.
# ACTION=="add|change", SUBSYSTEM=="usb", DRIVER="usb", TEST="power/wakeup", ATTR{idVendor}=="0b05", ATTR{idProduct}=="193b", ATTR{power/wakeup}="disabled"
ACTION=="add|change", SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="193b", ATTR{power/wakeup}="disabled"
'';
})

(mkIf (config.networking.wireless.iwd.enable && config.networking.wireless.scanOnLowSignal) {
# Meditek doesn't seem to be quite sensitive enough on the default roaming settings:
# https://wiki.archlinux.org/title/Wpa_supplicant#Roaming
# https://wiki.archlinux.org/title/Iwd#iwd_keeps_roaming
#
# But NixOS doesn't have the tweaks for IWD, yet.
networking.wireless.iwd.settings = {
General = {
RoamThreshold = -75;
RoamThreshold5G = -80;
RoamRetryInterval = 20;
};
};
})
];
}
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
asus-fx506hm = import ./asus/fx506hm;
asus-fa507nv = import ./asus/fa507nv;
asus-fa507rm = import ./asus/fa507rm;
asus-flow-gv302x-amdgpu = import ./asus/flow/gv302x/amdgpu;
asus-flow-gv302x-nvidia = import ./asus/flow/gv302x/nvidia;
asus-pro-ws-x570-ace = import ./asus/pro-ws-x570-ace;
asus-rog-strix-g513im = import ./asus/rog-strix/g513im;
asus-rog-strix-g713ie = import ./asus/rog-strix/g713ie;
Expand Down

0 comments on commit d3b4fe4

Please sign in to comment.