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

Help with implementing EC reading #114

Closed
ldan93 opened this issue Feb 1, 2021 · 9 comments
Closed

Help with implementing EC reading #114

ldan93 opened this issue Feb 1, 2021 · 9 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ldan93
Copy link

ldan93 commented Feb 1, 2021

Hello,
This issue is not directly related to YogaSMC. I'm kindly asking for some advice, your help would be very appreciated.

With @nekr0z and @profzei, we are trying to implement a battery conservation feature (charging thresholds) on the Huawei Matebook X Pro : nekr0z/matebook-applet#26 . @nekr0z wrote an app that works on Catalina. It relies on ioio and ACPI_Debug.kext to call ACPI methods to set the thresholds, and to read the related EC fields.

Reading the thresholds is currently done by outputting EC values to system logs, and then we get them by parsing the result of the log stream --predicate 'senderImagePath contains "ACPIDebug"' command.
The problems are :

  • Getting values this way doesn't sound very clean
  • ACPI_Debug.kext seems to be partially broken on Big Sur : ACPI methods can still be called, but outputting text to system logs doesn't work anymore. So the app is broken on Big Sur since we can't read the current thresholds...

I see that YogaSMC implement EC field reading. We would like to have your insight on our issue : is there a simple and cleaner way than parsing the system logs to get the EC values ? What would you advise us to do ?

@zhen-zen
Copy link
Owner

zhen-zen commented Feb 4, 2021

I also used to dig variables using ACPIDebug and customized ACPI methods before I come up with this kext.

Try if #115 will attach to the HWMI interface. (Use the Alter one.)

@ldan93
Copy link
Author

ldan93 commented Feb 8, 2021

Thank you !
I've successfully built the mate-attach branch and I've loaded the Alter kext with kextload. But then, I'm not sure what I should do / be looking for about the HWMI interface you mentioned...

@zhen-zen
Copy link
Owner

zhen-zen commented Feb 9, 2021

You can get prebuilt binary at https://github.com/zhen-zen/YogaSMC/actions/runs/536369821 . Please check your ioreg if YogaVPC is attached. For usage, see https://github.com/zhen-zen/YogaSMC#ec-reading

@zhen-zen zhen-zen added enhancement New feature or request help wanted Extra attention is needed labels Feb 9, 2021
@ldan93
Copy link
Author

ldan93 commented Feb 9, 2021

YogaVPC is not attached in my ioreg. But there are 2 mentions of YogaWMI.
Trying to read EC fields with ioio returns No service matching "YogaVPC"

@zhen-zen
Copy link
Owner

It seems that the driver couldn't match the interface by _UID. So I will just use AMW0 for now. The same name is also used by WMI reference code so it won't be merged into master in this way.

The driver also supports EC RW functionality through IOUserClient, which can be accessed directly from user-space and won't mess up with log format. Here is an example: 87074b4

@zhen-zen
Copy link
Owner

zhen-zen commented Feb 10, 2021

Please inject a fake device for YogaVPC to attach on unsupported models. Check the latest commit of linked PR for example.

@ldan93
Copy link
Author

ldan93 commented Feb 14, 2021

I've added SSDT-YVPC.dsl to my OpenCore. I don't understand what I'm supposed to do then to make the driver work on the matebook...

@zhen-zen
Copy link
Owner

Compile it first and add it to config.plist.

@zhen-zen
Copy link
Owner

Close it for now. I will continue working on #135 after receiving further response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants