Setting an ACPI field in Linux

不羁的心 提交于 2019-12-23 04:12:03

问题


I've a netbook that is running the fan a bit to early for my liking. I've found a Windows-only solution to reducing the fan noise but I'm using Ubuntu on this computer.

In the Windows solution the guy is using a program called Notebook Hardware Control (NHC) which, from what I can make out, is reading and setting ACPI values. (http://hpmini110c.siteboard.eu/f3t31-lueftersteuerung-fuer-den-mini.html, relevant source in the 7z-file, the .cs-file in there is a C#-file with the logic for setting the fan on)

The part I would like to find a way to replicate in a Linux environment is:

# Where the value is being set
write = ACPI.FIELD.Write("_SP.PCIO.SBRG.ECO.CTPM", 40);
# Reading the temperature
int temp1 = 0;
bool _tmp = APCI.FIELD.Read("_SB.PCIO.SBRG.ECO.TPM1", ref temp1)

I'll be honest that I'm over my head on this, but if someone could nudge me in the right direction I'd be very grateful!


回答1:


Michal Kottman created a kernel module which allows you to execute such ACPI commands. It was designed for calling commands to toggle video cards, but can be used for other purposed as well. It's available from Github, installation instructions below:

  1. Install the kernel headers matching the current kernel
  2. Get the source and build it

    git clone git://github.com/mkottman/acpi_call.git
    cd acpi_call
    make
    
  3. Load the module:

    /sbin/insmod acpi_call.ko
    

    If everything went well, you should now have a /proc/acpi/call "file".

  4. To execute a command, write it to /proc/acpi/call. I guess you made a typo with _SP and therefore replaced it by \_SB:

    echo '\_SB.PCIO.SBRG.ECO.CTPM' > /proc/acpi/call
    
  5. To get the result of this command, check your kernel log (dmesg) or read the result:

    cat /proc/acpi/call
    

    After reading it, the value will be cleared so be sure to save the output somewhere if you want to re-use it later.




回答2:


Not sure if it's exactly what you are wanting, but have you looked into lm_sensors? They support hw monoriting with kernel drivers, but provide a user space library.




回答3:


Reflector says that NHC.exe is a managed assembly, and it contains the classes that provide ACPI.FIELD.Write() and ACPI.FIELD.Read() and so on. The author of NHC has described, in the chm file, how to author your own classes that include calls to those things, for specific hardware types, something like a plugin model.

Rather than dropping in a .DLL, though, you drop in the actual C# code into a special folder; apparently nhc.exe dynamically compiles and runs this code when nhc.exe starts. If all of that is true, you should be able to write your own app that uses ACPI.FIELD.Read and Write calls, compile it into an exe, specifying the nhc.exe as a reference.

The kicker though, is that nhc.exe is obfuscated, and all those classes are not visible. So you cannot simply run csc.exe and reference nhc.exe. I don't know for sure, but it seems to me that It's only possible to run that code within the context of nhc.exe, which does a special compile to handle it.

The other bad news is that NHC development seems to have ceased; the forum website is dead, and the last update was from 2007.



来源:https://stackoverflow.com/questions/2759412/setting-an-acpi-field-in-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!