Giter Club home page Giter Club logo

Comments (30)

Ann1kaB avatar Ann1kaB commented on September 25, 2024 3

I added gpu fan sensor to my fork
https://github.com/Hyper-KVM/faustus

from faustus.

rublag avatar rublag commented on September 25, 2024 2

I managed to make it work. My laptop is TUF Gaming FX706II.

dmidecode info:

BIOS Information
        Vendor: American Megatrends Inc.
        Version: FA706II.304
...
System Information
        Manufacturer: ASUSTeK COMPUTER INC.
        Product Name: TUF Gaming FA706II_FX706II
...
Base Board Information
        Manufacturer: ASUSTeK COMPUTER INC.
        Product Name: FA706II

Module asus-nb-wmi (or faustus) cannot load and prints error:

ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT, Field [IIA3] at bit offset/length 96/32 exceeds size of target Buffer (96 bits) (20200110/dsopcode-198)
ACPI Error: Aborting method \_SB.ATKD.WMNB due to previous error (AE_AML_BUFFER_LIMIT) (20200110/psparse-529)

It occurs because of the difference between acpi code.
ASL code for working models:

CreateDWordField (Arg2, Zero, IIA0)
CreateDWordField (Arg2, 0x04, IIA1)
CreateDWordField (Arg2, 0x08, IIA2)

ASL code for my model:

CreateDWordField (Arg2, Zero, IIA0)
CreateDWordField (Arg2, 0x04, IIA1)
CreateDWordField (Arg2, 0x08, IIA2)
CreateDWordField (Arg2, 0x0C, IIA3)
CreateDWordField (Arg2, 0x10, IIA4)

It is similar to this issue https://patchwork.kernel.org/patch/10909549/

So I edited faustus.c like in the patch above

diff --git a/src/faustus.c b/src/faustus.c
index 39c1f19..814d242 100644
--- a/src/faustus.c
+++ b/src/faustus.c
@@ -150,6 +150,8 @@ struct bios_args {
        u32 arg0;
        u32 arg1;
        u32 arg2; /* At least TUF Gaming series uses 3 dword input buffer. */
+       u32 arg3;
+       u32 arg4;
 } __packed;
 
 /*
@@ -315,13 +317,15 @@ static void asus_wmi_input_exit(struct asus_wmi *asus)
 
 /* WMI ************************************************************************/
 
-static int asus_wmi_evaluate_method3(u32 method_id,
-               u32 arg0, u32 arg1, u32 arg2, u32 *retval)
+static int asus_wmi_evaluate_method5(u32 method_id,
+               u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 *retval)
 {
        struct bios_args args = {
                .arg0 = arg0,
                .arg1 = arg1,
                .arg2 = arg2,
+               .arg3 = arg3,
+               .arg4 = arg4,
        };
        struct acpi_buffer input = { (acpi_size) sizeof(args), &args };
        struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -350,6 +354,12 @@ static int asus_wmi_evaluate_method3(u32 method_id,
        return 0;
 }
 
+static int asus_wmi_evaluate_method3(u32 method_id, 
+               u32 arg0, u32 arg1, u32 arg2, u32 *retval)
+{
+       return asus_wmi_evaluate_method5(method_id, arg0, arg1, arg2, 0, 0, retval);
+}
+
 static int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval)
 {
        return asus_wmi_evaluate_method3(method_id, arg0, arg1, 0, retval);

Now keyboard backlight management works.

But there are problems during loading:

faustus: Failed to set throttle thermal policy (retval): 0x0
battery: extension failed to load: ASUS Battery Extension
battery: extension unregistered: ASUS Battery Extension

When calling set_rgb.sh following error occurs (but color changes):

faustus: RGB keyboard device 1, write error (retval): 0

When pressing Aura next/previous key (Fn-Left/Fn-Right) it says about unknown keys:

faustus: Unknown key b3 pressed

P. S. If display brightness control doesn't work, you can use this patch (https://patchwork.freedesktop.org/patch/367486/)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index ddc979e3eebe..acd4874e0743 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1377,13 +1377,10 @@ static int dm_late_init(void *handle)
         */
        params.min_abm_backlight = 0x28F;
 
-       /* todo will enable for navi10 */
-       if (adev->asic_type <= CHIP_RAVEN) {
-               ret = dmcu_load_iram(dmcu, params);
+       ret = dmcu_load_iram(dmcu, params);
 
-               if (!ret)
-                       return -EINVAL;
-       }
+       if (!ret)
+               return -EINVAL;
 
        return detect_mst_link_for_all_connectors(adev->ddev);
 }

from faustus.

rublag avatar rublag commented on September 25, 2024 2

Some news.

  1. It seems that armoury crate doesn't use relevant WMI ACPI calls (but I am not very sure yet)
  2. I managed to make cpu fan speed reading work. Same for gpu fan will not be hard.

from faustus.

xurei avatar xurei commented on September 25, 2024 1

I can't PM him either, but I believe I can try a few things given his messages.

To be continued... ;-)

from faustus.

rublag avatar rublag commented on September 25, 2024 1

@xurei I made a fork: https://github.com/rublag/faustus

from faustus.

rublag avatar rublag commented on September 25, 2024 1

@lknop @Hyper-KVM
Strange, but it really seems to work. Mode 2 is more quiet than others.
I think I'll research this more in July.

You need to recompile kernel
https://wiki.archlinux.org/index.php/Kernel/Arch_Build_System
Here is the guide.

Save patch as backlight.patch

and make these two changes in PKGBUILD:

source=(
  "$_srcname::git+https://git.archlinux.org/linux.git?signed#tag=$_srctag"
  config         # the main kernel config file
  sphinx-workaround.patch
  backlight.patch
)

and

sha256sums=('SKIP'
            '2a157fdbf3a6396e985db9ae5d11870a786717dca31de78cad09c06eb28761ff'
            '8cb21e0b3411327b627a9dd15b8eb773295a0d2782b1a41b2a8839d1b2f5778c'
            'SKIP')

from faustus.

Ann1kaB avatar Ann1kaB commented on September 25, 2024 1

There is a BIOS update available (at least for FA506IV) that has broken cpu_fan RPM reading (not that it matters since it returned 0 anyways, it just now does not show up) but at least now most IIA0 calls will return 0xFFFFFFFE aka UNSUPPORTED, this should make it easier to narrow down the correct addresses for everything.

So far there is CRFC (0x00120072) that is not defined in faustus.h, when I tried to see if that address would do anything with ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY it returned a value of -19, so I'm not sure what that means hopefully it means something to someone lol. anyway I will attach both the diff of BIOS 308 vs 304 and my full dsdt for 308.
dsdtv308FA506IV.tar.gz

from faustus.

xurei avatar xurei commented on September 25, 2024

I have a FA506II.302 myself. Did you manage to make it work ?

from faustus.

lknop avatar lknop commented on September 25, 2024

I have a FA506II.302 myself. Did you manage to make it work ?

Unfortunately no, I didn't. I got to the point of installing windows just to disable the blinking RGB, and spent over a day trying to make it work under windows. So far I only have red backlight, but the asus software fails to start. I tried OpenRGB under windows to sniff the i2c bus but no luck.

My plan is to try another kernel in linux and see if faustus cooperates, but I am not very optimistic about it.

I have one more lead, there is a user at arstechnica, nick lpt0 that seems to have made this model work reliably under linux, I assume he/she might have been able to figure out RGB keyboard as well. I cannot send PMs at arstechnica, but if you (or anyone else reading this) can - maybe you could ping that user and ask how he/she did it.

https://arstechnica.com/gadgets/2020/04/linux-on-laptops-asus-zephyrus-g14-with-ryzen-9-4900hs/?comments=1&start=120

from faustus.

xurei avatar xurei commented on September 25, 2024

I made some progress on stabilizing the beast... I have the Nvidia driver working through prime-run.

@lknop did you try to edit the code that checks the device descriptors ?

I am not sure it's safe to run it... @hackbnw, any remark ?
If you think it's safe I can try it and give feedback.

(to add at line 3250 in commit #35 )

	{
		.callback = dmi_check_callback,
		.ident = "FA506II",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
			DMI_MATCH(DMI_PRODUCT_NAME, "FA506II"),
		},
	},

from faustus.

lknop avatar lknop commented on September 25, 2024

@xurei no, I didn't edit the code but I used the flag that skips the DMI verification

sudo insmod ./src/faustus.ko let_it_burn=1

The log I pasted in the issue report is from that command as faustus nicely logged

[ 1454.866709] faustus: Omitting DMI verification

So I cannot say it's safe but it didn't break anything in my setup, just didn't work.

from faustus.

xurei avatar xurei commented on September 25, 2024

@rublag Do you have a fork so I can try it on my machine ?

from faustus.

rublag avatar rublag commented on September 25, 2024

@xurei Not yet. You can just apply patch yourself. Or I can make a fork with the patch in a few days.

from faustus.

Ann1kaB avatar Ann1kaB commented on September 25, 2024

I wish I knew how to debug this so I could try changing the address values to the correct ones in faustus.c. the address 0x00120075 does not exist on FA506IV, so throttle_thermal_policy returns 0x0 and fails. I have no idea which address controls the throttle_thermal_policy lol but having that working would be nice to have hopefully better clock speeds on battery than default.

from faustus.

rublag avatar rublag commented on September 25, 2024

@Hyper-KVM In faustus there are two methods for fan control: throttle thermal policy and fan boost mode.

Maybe just try to swap values for NOTIFY_KBD_TTP and NOTIFY_KBD_FBM in faustus.c?

from faustus.

rublag avatar rublag commented on September 25, 2024

@Hyper-KVM On my laptop # echo 2 > /sys/devices/platform/faustus/fan_boost_mode works without error. So it seems that ASUS changed keycode and we need to patch NOTIFY_KBD_FBM to use keycode 0xae which is now used by NOTIFY_KBD_TTP.

Also I don't know why, but check for thermal throttle policy passes. Probably bug in faustus driver.

from faustus.

Ann1kaB avatar Ann1kaB commented on September 25, 2024

Also I don't know why, but check for thermal throttle policy passes. Probably bug in faustus driver.

In dmesg I get: faustus: Failed to set throttle thermal policy (retval): 0x0

If i change the value of NOTIFY_KBD_FBM to 0xae, It does say in dmesg it applied the fan boost mode but it doesn't seem to work in practice when stress testing?

I made a fork: https://github.com/rublag/faustus

Also, the fork does work, i get this in dmesg:
faustus: Fan boost mode check successful
faustus: Fan boost mode check end
faustus: TTP check successful
faustus: TTP check end
the TTP check is weird because address 0x00120075 does not exist in my DSDT.

from faustus.

rublag avatar rublag commented on September 25, 2024

@Hyper-KVM Yes I've added these debug mesasges to understand what's going on. I don't know how fan boost should work. But yes, I don't see any effect and in ACPI table this function seems to have no effect:

Method (SFBM, 1, NotSerialized)
{
    If ((Arg0 == Zero)){}
    If ((Arg0 == One)){}
    If ((Arg0 == 0x02)){}
}

On one of the supported laptops this function is ~ 100 lines long.

Does fan boost work on Windows? How can we test if it works properly?

from faustus.

Ann1kaB avatar Ann1kaB commented on September 25, 2024

Does fan boost work on Windows? How can we test if it works properly?

@rublag As far as i can tell, all 3 fan modes work correctly. Using the armory crate software of course, not sure if that has anything to do with it.

from faustus.

xurei avatar xurei commented on September 25, 2024

@rublag @Hyper-KVM Fan boost does work on Windows for the FA506II as well.

from faustus.

Ann1kaB avatar Ann1kaB commented on September 25, 2024

OK So a temporary solution @rublag @xurei, I changed the expected return value of setting throttle_thermal_policy from 1 to 0, and it works! the fan modes work!
Edit: a better patch which shows the change made in dmesg.

From 308a7dd8ec5d16d80e82d437914d9eb1d4a39fa5 Mon Sep 17 00:00:00 2001
From: Hyper-KVM <[email protected]>
Date: Thu, 11 Jun 2020 18:59:35 -0400
Subject: [PATCH] Change expected retval from 1 to 0

---
 src/faustus.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/faustus.c b/src/faustus.c
index 01e1fcf..e8126b0 100644
--- a/src/faustus.c
+++ b/src/faustus.c
@@ -2136,6 +2136,8 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)

        value = asus->throttle_thermal_policy_mode;

+       pr_info("Set throttle thermal policy mode: %u\n", value);
+
        err = asus_wmi_set_devstate(ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY,
                                    value, &retval);
        if (err) {
@@ -2143,7 +2145,7 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)
                return err;
        }

-       if (retval != 1) {
+       if (retval != 0) {
                pr_warn("Failed to set throttle thermal policy (retval): 0x%x\n",
                        retval);
                return -EIO;
--
2.27.0

from faustus.

lknop avatar lknop commented on September 25, 2024

@xurei @rublag I have created a fork with the above patch from @Hyper-KVM.

@Hyper-KVM Have you figured out which thermal policy corresponds to which fan mode?
I also have broken display brightness, is the amdgpu_dm patch you posted available anywhere or do I need to compile the kernel myself? I am running manjaro at the moment.

from faustus.

Ann1kaB avatar Ann1kaB commented on September 25, 2024

@Hyper-KVM Have you figured out which thermal policy corresponds to which fan mode?

@lknop The fan modes correspond to those in the readme on my machine.

from faustus.

Ann1kaB avatar Ann1kaB commented on September 25, 2024

Strange, but it really seems to work. Mode 2 is more quiet than others.
I think I'll research this more in July.

I think it's due to the fact address 0x00120075 doesn't exist in the DSDT, so it will always return 0, but the address is present? It is strange indeed, There must be some other address that controls it now but I'm not experienced enough to figure out which, that patch I made was a shot in the dark. But I do look forward to what you come up with!

Edit: oh also do you guys also have an undefined method CTYP in your dmesg log? Looking in the DSDT, there's a function called _SCP which seems useless, so I removed it and that gets rid of at least that error lol.

from faustus.

Ann1kaB avatar Ann1kaB commented on September 25, 2024

Made a fork with support for all FA506* and also now takes 1 or 0 as a value instead of 0.

from faustus.

xurei avatar xurei commented on September 25, 2024

@Hyper-KVM I just tested your fork with my FA506II.

dmesg after modprobe:

[  273.084500] faustus: DMI checK: FA506II
[  273.084639] faustus: Initialization: 0x1
[  273.084693] faustus: BIOS WMI version: 8.1
[  273.084738] faustus: SFUN value: 0x4a0061
[  273.084740] faustus faustus: Use DSTS
[  273.084740] faustus faustus: Enable event queue
[  273.085220] faustus: Fan boost mode check successful
[  273.085220] faustus: Fan boost mode check end
[  273.086022] faustus: TTP check successful
[  273.086024] faustus: TTP check end
[  273.086764] faustus: Set throttle thermal policy mode: 0
[  273.089486] input: Asus WMI hotkeys as /devices/platform/faustus/input/input24
[  273.098413] battery: extension failed to load: ASUS Battery Extension
[  273.098416] battery: extension unregistered: ASUS Battery Extension
  • Keyboard Backlight is working.
  • Battery extension fails to load.
  • Fn-F5 gets captured by the driver and changes the thermal policy, but it doesn't seem to do anything. Fans are still in silent mode.
[  733.242247] faustus: Set throttle thermal policy mode: 0
[  733.242247] faustus: Set throttle thermal policy mode: 1
[  733.242247] faustus: Set throttle thermal policy mode: 2

Here is my dsdt file for completeness.
dsdt.zip

from faustus.

rublag avatar rublag commented on September 25, 2024

Fixed cpu fan reporting and battery error on my fork
https://github.com/rublag/faustus

from faustus.

Ann1kaB avatar Ann1kaB commented on September 25, 2024

Fixed cpu fan reporting and battery error on my fork
https://github.com/rublag/faustus

So I just tested this and battery module is loaded, but cpu_fan is output as N/A, but at least it is there I guess. but definetly making progress, I may try just changing the CPU FAN value from 0x00110013 to 0x00110014 to see if that works.

from faustus.

rublag avatar rublag commented on September 25, 2024

It is strange because in your dsdt there is 0x110013 and it looks like mine. So it should work. Did you try to read /sys/devices/platform/faustus/hwmon/hwmon5/fan1_input?

from faustus.

Ann1kaB avatar Ann1kaB commented on September 25, 2024

It is strange because in your dsdt there is 0x110013 and it looks like mine. So it should work. Did you try to read /sys/devices/platform/faustus/hwmon/hwmon5/fan1_input?

cat /sys/devices/platform/faustus/hwmon/hwmon5/fan1_input
returns nothing. Although, changing asus->fan_type = FAN_TYPE_SPEC83; to asus->fan_type = FAN_TYPE_AGFN; does give a value of 0 instead so I'm not sure what the issue is.

edit: nvm it works now....idk why

from faustus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.