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

tuxedo-keyboard: fix compilation for kernel 6.10 and 6.11 #336633

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Keksgesicht
Copy link

@Keksgesicht Keksgesicht commented Aug 22, 2024

Description of changes

It seems like the tuxedo-keyboard has moved to GitLab a little time ago. Thus, I changed the source git the new GitLab URL and updated the version number. This also fixes a bug when compiling with Kernel 6.10.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@K900
Copy link
Contributor

K900 commented Aug 25, 2024

Please change the commit message format to fit the guidelines in CONTRIBUTING.md

@K900
Copy link
Contributor

K900 commented Aug 25, 2024

Also, it may be worth renaming the package to fit its presumably now extended scope?

@Keksgesicht
Copy link
Author

I also renamed the related config options to the new scope of the tuxedo driver. I hope this is ok.

@Keksgesicht
Copy link
Author

There are already commit in the new upstream repo to fix compile errors with kernel 6.11. Thus, I will most likely provide a follow up pull request the coming days to update this driver to version 4.6.3.

@Keksgesicht Keksgesicht changed the title fix compilation of tuxedo-keyboard for kernel 6.10 tuxedo-keyboard: fix compilation for kernel 6.10 Sep 4, 2024
@@ -488,7 +488,7 @@ in {

rust-out-of-tree-module = if lib.versionAtLeast kernel.version "6.7" then callPackage ../os-specific/linux/rust-out-of-tree-module { } else null;

tuxedo-keyboard = if lib.versionAtLeast kernel.version "4.14" then callPackage ../os-specific/linux/tuxedo-keyboard { } else null;
tuxedo-driver = if lib.versionAtLeast kernel.version "4.14" then callPackage ../os-specific/linux/tuxedo-driver { } else null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you renamed the package here, could you add an alias to block at line 608, in-case someone didn't use the module.
Something like this:

tuxedo-keyboard = self.tuxedo-drivers;

Copy link
Contributor

@MinerSebas MinerSebas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still works on my Pulse Gen 1.

@Keksgesicht
Copy link
Author

Now it also runs with kernel 6.11 on my Aura 15 Gen1.

@Keksgesicht Keksgesicht changed the title tuxedo-keyboard: fix compilation for kernel 6.10 tuxedo-keyboard: fix compilation for kernel 6.10 and 6.11 Sep 21, 2024
@Keksgesicht
Copy link
Author

@blanky0230 What do you think? As you are the maintainer could you review my changes please so it's clear to committers in what state this is?

@h7x4 h7x4 mentioned this pull request Sep 28, 2024
13 tasks
Copy link
Member

@blanky0230 blanky0230 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hate to nitpick catching up with reviews this late but: Since the manufacturer's repo is named "tuxedo-drivers" (plural), I think the corresponding linuxPackage and nixosModule in nixpkgs should share the same name in order to minimize the possibility for mix-ups and user's confusion in the future.

Other than that this PR is looking good to me 👍

@WhiteBlackGoose
Copy link
Member

WhiteBlackGoose commented Oct 14, 2024

doesn't build for me:

error: builder for '/nix/store/l0l897lralncq6mjj8cx1cr0wkjmsm96-tuxedo-keyboard-6.11.2-3.2.14.drv' failed with exit code 2;
       last 10 log lines:
       > /build/source/./src/uniwill_keyboard.h:1259:19: error: initialization of 'void (*)(struct platform_device *)' from incompatible pointer type 'int (*)(struct platform_device *)' [8;;https://gcc.gnu.org/onlinedocs/gcc/W
arning-Options.html#index-Wincompatible-pointer-types-Werror=incompatible-pointer-types8;;]
       >  1259 |         .remove = uniwill_keyboard_remove,
       >       |                   ^~~~~~~~~~~~~~~~~~~~~~~
       > /build/source/./src/uniwill_keyboard.h:1259:19: note: (near initialization for 'platform_driver_uniwill.<anonymous>.remove')
       > cc1: some warnings being treated as errors
       > make[3]: *** [/nix/store/q3jgpnpxqcvh4pcicb9d6ry8mhkwlh9s-linux-6.11.2-dev/lib/modules/6.11.2/source/scripts/Makefile.build:244: /build/source/./src/tuxedo_keyboard.o] Error 1
       > make[2]: *** [/nix/store/q3jgpnpxqcvh4pcicb9d6ry8mhkwlh9s-linux-6.11.2-dev/lib/modules/6.11.2/source/Makefile:1926: /build/source] Error 2
       > make[1]: *** [/nix/store/q3jgpnpxqcvh4pcicb9d6ry8mhkwlh9s-linux-6.11.2-dev/lib/modules/6.11.2/source/Makefile:224: __sub-make] Error 2
       > make[1]: Leaving directory '/nix/store/q3jgpnpxqcvh4pcicb9d6ry8mhkwlh9s-linux-6.11.2-dev/lib/modules/6.11.2/build'
       > make: *** [Makefile:29: all] Error 2
       For full logs, run 'nix log /nix/store/l0l897lralncq6mjj8cx1cr0wkjmsm96-tuxedo-keyboard-6.11.2-3.2.14.drv'.
error: 1 dependencies of derivation '/nix/store/j6wr97kgdks67ypkwb8j1c7p5awpymxh-linux-6.11.2-modules.drv' failed to build
error: 1 dependencies of derivation '/nix/store/b38jgykmzv3chac6yhm5g0cfzhwv3hy0-nixos-system-tuxedo-infinitypro14-nixos-24.11.20241009.5633bcf.drv' failed to build

I just updated my flake (on unstable) to the latest version and copied tuxedo-drivers/default.nix into tuxedo-new.nix and added as a boot package:

  boot.extraModulePackages = [ 
    (config.boot.kernelPackages.callPackage ./tuxedo-new.nix { })
  ];

@Keksgesicht
Copy link
Author

@WhiteBlackGoose. I tested you method myself and it compiles.

Your error message still mentions tuxedo-keyboard. You probably did not use the correct nixpkgs commit when you tested this.

In my flake.nix I use something like this to test the currently unmerged PR:

{
  inputs = {
    nixpkgs-master = {
      type = "github";
      owner = "NixOS";
      repo = "nixpkgs";
      ref = "master";
      rev = "c5989b0173fa669297d1f92cee201cf77aa6c3eb";
    };
  };

  outputs = {
    nixpkgs-master,
  }@inputs: {
    nixosConfigurations = {
      "myMachineName" = nixpkgs-master.lib.nixosSystem {
      };
    };
  };
}

@papanito
Copy link

I added the config as @Keksgesicht mentioned in his comment. Build works fine, however somehow I still don't see any backlight on my keyboard.

I also have this

  boot = {
    initrd = {
      availableKernelModules = [
        "xhci_pci"
        "thunderbolt"
        "nvme"
        "usb_storage"
        "usbhid"
        "sd_mod"
      ];
      kernelModules = [ ];
    };
    runSize = "50%";
    kernelModules = [ 
      "kvm-intel"
      "tuxedo_keyboard"
    ];
    kernelPackages = pkgs.linuxPackages_latest;
  };  

@Keksgesicht
Copy link
Author

Why haven't you tried using hardware.tuxedo-drivers.enable instead? This will also add boot.extraModulePackages = [ tuxedo-drivers ];. Making the package which includes the kernel module available to be easily used.

Also, did you reboot after a nixos-rebuild switch/boot? Did you try inserting the module into the kernel manually after building?

@chmanie
Copy link
Contributor

chmanie commented Oct 17, 2024

I would love to help testing this. Is there a way to enable this without setting all of my main config to this branch?

@Keksgesicht
Copy link
Author

@chmanie disable the old tuxedo-keyboard option and copy the pkgs/os-specific/linux/tuxedo-drivers/default.nix file from this PR to local file.

Then try to something like that to your config:

{ config, ... }:

let
  cfgLinuxKernel  = config.boot.kernelPackages;
  tuxedo-pkg-file = pkgs/os-specific/linux/tuxedo-drivers/default.nix;
  tuxedo-drivers  = cfgLinuxKernel.callPackage tuxedo-pkg-file {};
in
{
  boot.kernelModules = [ "tuxedo_keyboard" ];
  boot.extraModulePackages = [ tuxedo-drivers ];
}

An alternative would be to clone your current nixpkgs commit and rebase the changes of this PR onto it. Then use this version of nixpkgs for your machine config. Just add the local path to your input.

Another thought that I had is to only use the package from the commit of this PR, but this does not work as the kernel minor version already changed over the time:

{ inputs, system, ... }:

let
  pkgs-master = import inputs.nixpkgs-master { # see a few messages above
    inherit system;
  };
  cfgLinuxKernel = pkgs-master.linuxKernel.packages.linux_6_11;
  tuxedo-drivers = cfgLinuxKernel.tuxedo-keyboard;
in
{
  boot.kernelModules = [ "tuxedo_keyboard" ];
  boot.extraModulePackages = [ tuxedo-drivers ];
}

@papanito
Copy link

Why haven't you tried using hardware.tuxedo-drivers.enable instead? This will also add boot.extraModulePackages = [ tuxedo-drivers ];. Making the package which includes the kernel module available to be easily used.

I also did try hardware.tuxedo-drivers.enable

Also, did you reboot after a nixos-rebuild switch/boot? Did you try inserting the module into the kernel manually after building

Yes both use the switch parameter and then reboot

@Keksgesicht
Copy link
Author

@papanito does this show any file:

realpath /run/*-system/kernel-modules/lib/modules/*/updates/src/tuxedo*

or (this is only the case before the latest commit where the build commands changed)

realpath /run/*-system/kernel-modules/lib/modules/*/tuxedo*

Also look whether your kernel loaded the modules:

lsmod | grep tuxedo

Report what is not the case. Did it work with an LTS kernel and the older tuxedo-keyboard package?
I am currently unsure if tuxedo has devices which do not need a driver and the backlight is part of the firmware. But there are devices which do not have any backlight.
Also, without the driver my device initializes the backlight in blue, but I cannot change the color or brightness. When it goes to sleep/suspend the backlight is gone :(

@papanito
Copy link

Report what is not the case. Did it work with an LTS kernel and the older tuxedo-keyboard package?

It never worked on my InfinityBook, but I assumed also maybe cause the package seemed very outdated.

lsmod looks fine, relpath as well

@Keksgesicht
Copy link
Author

@papanito do you have something like this?

/sys/devices/platform/tuxedo_keyboard/leds/rgb:kbd_backlight

Try changing brightness or multi_intensity in there.

echo "51" | sudo tee /sys/devices/platform/tuxedo_keyboard/leds/rgb:kbd_backlight/brightness
echo "0 255 0" | sudo tee /sys/devices/platform/tuxedo_keyboard/leds/rgb:kbd_backlight/multi_intensity

@papanito
Copy link

papanito commented Oct 17, 2024

My tuxedo has

White backlit keyboard, means that the writing on the keys have backlight! Brightness can be controlled and deactivated by special keys.

hence I can see

ls /sys/devices/platform/tuxedo_keyboard/leds/
white:kbd_backlight

But when I do this

echo "51" | sudo tee /sys/devices/platform/tuxedo_keyboard/leds/white:kbd_backlight/brightness
51

The keyboard still shows no light :-(

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/installing-tuxedo-keyboard-drivers/40161/7

@Keksgesicht
Copy link
Author

If does not create any error. Not even in the log (see journalctl -k | tail). When I cannot do anything for you and you have to talk to Tuxedo Computers or one of their software development partners.

@papanito
Copy link

Thanks @Keksgesicht for your time and effort. I probably have to talk to them yes....

@chmanie
Copy link
Contributor

chmanie commented Oct 18, 2024

@Keksgesicht thank you, I tested it the way you described. Here are some logs, not sure if this is expected or not (Tuxedo InfinityBook 14 Gen8):

| lsmod | rg tuxedo
tuxedo_nb02_nvidia_power_ctrl    12288  0
tuxedo_io              24576  1
tuxedo_keyboard       106496  4 tuxedo_io,uniwill_wmi,clevo_wmi,tuxedo_nb02_nvidia_power_ctrl
tuxedo_compatibility_check    12288  1 tuxedo_keyboard
led_class_multicolor    16384  1 tuxedo_keyboard
battery                28672  2 asus_wmi,tuxedo_keyboard
sparse_keymap          12288  3 intel_hid,asus_wmi,tuxedo_keyboard
led_class              20480  7 snd_hda_codec_generic,videodev,input_leds,iwlmvm,asus_wmi,tuxedo_keyboard,led_class_multicolor

And testing tuxedo-rs

| systemctl status tailord.service
● tailord.service - Tuxedo Tailor hardware control service
     Loaded: loaded (/etc/systemd/system/tailord.service; enabled; preset: ignored)
     Active: active (running) since Fri 2024-10-18 02:13:59 CEST; 1min 27s ago
 Invocation: ab708c3e7e314e99a79592f56570900b
   Main PID: 1184 (tailord)
         IP: 0B in, 0B out
         IO: 10.9M read, 0B written
      Tasks: 2 (limit: 76804)
     Memory: 6.6M (peak: 7.3M)
        CPU: 294ms
     CGroup: /system.slice/tailord.service
             └─1184 /nix/store/4lnjd6v4gj1wz5idc8g0wwcajq287hqx-tuxedo-rs-0.3.1/bin/tailord

Okt 18 02:13:59 cassis systemd[1]: Starting Tuxedo Tailor hardware control service...
Okt 18 02:13:59 cassis tailord[1184]:  INFO start_runtime: tailord: Starting tailord
Okt 18 02:13:59 cassis tailord[1184]:  INFO start_runtime: tailord::profiles: Loaded profile at `/etc/tailord/active_profile.json`: ProfileInfo { fans: ["default"], leds: [], performance_profile: None }
Okt 18 02:13:59 cassis tailord[1184]:  INFO start_runtime: tailord: Connected to Tuxedo ioctl interface with version 0.3.9
Okt 18 02:13:59 cassis tailord[1184]:  INFO start_runtime: tailord: Tailord started
Okt 18 02:13:59 cassis tailord[1184]:  INFO tailord::suspend: Setting up suspend service
Okt 18 02:13:59 cassis systemd[1]: Started Tuxedo Tailor hardware control service.
Okt 18 02:14:15 cassis tailord[1184]: ERROR tailord::fancontrol: Failed reading the current temperature: `Device not available`

@papanito
Copy link

Lol I feel a bit stupid, but actually it works once I enable the backlight using Fn+Space

@Keksgesicht
Copy link
Author

@chmanie looks fine so far. You could test if the Fn keys control the brightness. If your DM/WM does not comply with that and your InfintyBook has also only a "white" keyboard backlight, you maybe have to do this instead: #336633 (comment)

For the failed temperature reading I am not sure whether this driver or a generic one for the Intel or AMD platform provides this sensor. Try running sensors-detect of the lm-sensors package and look into /etc/sysconfig/lm_sensors afterwards. Then add them to boot.kernelModules and see whether this ERROR from tailord goes away.

@Keksgesicht
Copy link
Author

So, I rebased and fixed a merge conflict because someone added some system76 things above of my changes in pkgs/top-level/linux-kernels.nix. I even updated the package to the newest upstream version.

Is there something else I have to do? How do I get the attention of a committer to merge this?

@xaverdh
Copy link
Contributor

xaverdh commented Oct 23, 2024

The Failed reading the current temperature error occurs on startup for me as well, and used to with the old module as well. I think it's race condition with the driver and not something we can fix.

@xaverdh
Copy link
Contributor

xaverdh commented Oct 23, 2024

cc @SuperSandro2000

@ofborg ofborg bot requested a review from blanky0230 October 23, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.