Kategorien

DIY (3) Gnome Extension (3) Laptop (1) Linux (8) Server (2) Windows (1)

10 Januar 2022

EC-Control

EC-Control ist ein Script welches es erlaubt, Werte in bestimmten OffSets des EC's zu lesen und zu schreiben. Es wird als Unterbau für die EC-Control Gnome Shell Extension verwendet, kann aber auch Standalone genutzt werden. EC-Control ermöglicht es Lüfter, Bluetooth, Touchpad, Tastaturbeleuchtung, Webcam etc. eines Laptops unter Linux zu steuern. Voraussetzung ist ein aktiviertes DebugFS im Kernel sowie dem aktiven ec_sys Kernelmodul, alternativ ein aktives acpi_ec Kernelmodul.

Für Windows werden von den jeweiligen Herstellern Tools zum einstellen von Laptop Eigenschaften wie Bluetooth, Lüfter etc., mitgeliefert. Für mein Gigabyte P57W beispielsweise, war es mir anfangs nicht möglich, unter Linux die Lüfter im Automatik Modus zu betreiben, stattdessen liefen diese stets im Performance Modus - was akustisch einem Fön gleicht. Aus der Not heraus und mit ein wenig Reverse-Engineering, habe ich die wichtigsten möglichen Werte des Laptops in einer Datenbank zusammengetragen.

Was ist nun der Unterschied zu NBFC?

NBFC ist ein klasse Projekt, verfolgt allerdings ein anderes Ziel. Unter NBFC ist es möglich die Lüfter - und nur die Lüfter - je nach Hersteller und sofern Unterstützt, stufenlos zu regeln. Ich möchte jedoch gerne Dinge wie Tastaturbeleuchtung, Webcam, oder das Touchpad steuern können.

Voraussetzungen:
  • Kernel mit DebugFS Support und aktiven EC_SYS Kernelmodul oder aktiven ACPI_EC Kernel Modul
  • xxd um Werte aus dem EC zu lesen
  • dd um Werte im EC zu schreiben
  • pkexec um EC-Control das schreiben im EC zu ermöglichen

Installation:
  • ec-control herunterladen und im folgenden Verzeichnis kopieren:
sudo cp ec-control /usr/bin/
  • ec-control ausführbar machen:
sudo chmod +x /usr/bin/ec-control

Benutzung ohne Gnome Shell Extension:
EC-Control ist auch ohne Gnome Extension nutzbar. Wenn der Offset des Registers und die entsprechenden Werte bekannt sind, lassen sich diese wie folgt steuern:
Einen Wert in einem Offset ermitteln:
sudo /usr/bin/ec-control get offset ec_path
Einen Wert in einem Offset schreiben:
sudo /usr/bin/ec-control set value offset ec_path
Beispiel: Gigabyte P57 - Lüftersteuerung Automatik
sudo /usr/bin/ec-control set 20 6 /dev/ec
Beispiel: Gigabyte P57 - Tastaturbeleuchtung 100%
sudo /usr/bin/ec-control set 02 215 /dev/ec
Beispiel: Gigabyte P57 - Touchpad Abschalten
sudo /usr/bin/ec-control set 80 3 /dev/ec
Auf diesem Wege kann auch der EC mittels Starter im KDE oder Gnome gesteuert werden. Die Werte sind der entsprechenden Datenbank zu entnehmen.

Changelog:
  • 1.0.0: Initial release
ToDo:
  • Read and validate database files
Download:
Last Update: 11.01.2022

4 Kommentare:

Paul Fenwick hat gesagt…

Thank you so much! I've got a P57W laptop as well, and needing to boot into windows to enable my camera and keyboard backlight has always been such a pain! I'm recompiling with ACPI DEBUGFS support now and will be trying your tools shortly. You totally rock.

Also, is there a github repo for your tools at all?

Many thanks again!

~ Paul

Sven K. hat gesagt…

Thanks. No Github repo yet, maybe in future. In newer Kernels i need to patch a bit at ec_sys, cause if not - i dont get write support at all. Dont know why...

--- drivers/acpi/ec_sys.c 2016-06-12 16:20:35.000000000 +0200
+++ drivers/acpi/ec_sys.c 2016-06-16 20:58:33.373867883 +0200
@@ -73,9 +73,6 @@
loff_t init_off = *off;
int err = 0;

- if (!write_support)
- return -EINVAL;
-
if (*off >= EC_SPACE_SIZE)
return 0;
if (*off + count >= EC_SPACE_SIZE) {

Paul Fenwick hat gesagt…

I have your code working! Thank you so much!

With regards to `ec_sys`, it looks like one has to flip on the write option now. With a module, that means `sudo modprobe ec_sys write_support=1`. In my kernel it's compiled in, so I added `ec_sys.write_support=1` to the `GRUB_CMDLINE_LINUX_DEFAULT` line in `/etc/default/grub`.

Thank you so much again! I'm so delighted to have these features running at last! You've made my day!

Sven K. hat gesagt…

Im glad to hear that :)
Yes, i compiled it in too, but with bootoptions, he ignores sometimes my write_support=1. So i decided to patch that out and voila - all seems well :)

Have fun, the P57W is really Linux friendly, except that EC thing... :)