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

Support for Ideapad 5 Pro 16ACH6 #6

Open
agorgl opened this issue Oct 29, 2021 · 9 comments
Open

Support for Ideapad 5 Pro 16ACH6 #6

agorgl opened this issue Oct 29, 2021 · 9 comments

Comments

@agorgl
Copy link

agorgl commented Oct 29, 2021

Laptop model: Lenovo IdeaPad 5 Pro 16ACH6 82L5005RMH
Product name: 82L5

Getting 'Unrecognized battery mode, please retry' and 'Unrecognized battery charge mode, please retry' respectively for -r and -rc flags.

Tried both main and experimental_support branches.

I'm willing to make relevant PR provided some guidance on what I should look for to add support for my model.

@0xless
Copy link
Owner

0xless commented Oct 30, 2021

Thanks for showing interest in this project!

The reason for this error is that battery/charge values read with ACPI calls are not the same as Ideapad 15are05's.
Please check this function for reference:

battmngr/battmngr

Lines 308 to 331 in 56be748

function read_operation(){
echo '\_SB.PCI0.LPC0.EC0.SPMO' > /proc/acpi/call
check=$(cat /proc/acpi/call | cut -d '' -f1)
case $check in
"0x0")
echo "Intelligent Cooling"
;;
"0x1")
echo "Extreme Performance"
;;
"0x2")
echo "Battery Saving"
;;
*)
error 4
;;
esac
}

If the problem is present for read functions only, I think we could support your laptop! If you feel free to hack the script a little bit, you could report the hex values (and corresponding modes) read back by the read_operation and read_charge_operation functions. If you want to explore with supporting your laptop yourself, I would suggest you try the experimental_support branch as it uses a json configuration file to load the calls/values relative to a specific laptop.

In the mean time, if you could please provide us with the output of each battmngr command, it would be amazing to evaluate the support state of your laptop.

@agorgl
Copy link
Author

agorgl commented Oct 30, 2021

Do you have the dsdt.dat or the decoded dsdt.dsl of your (working) model in order to compare it with mine?
I see for example the SBMC method in mine that accepts argument that either is 0x03 0x05 0x07 0x08 but I need to know how your read op looks like in order to find mine similar one

@0xless
Copy link
Owner

0xless commented Oct 30, 2021

Sure, you can find the zipped dsdt.dsl file attached.
I've only gave a quick look to the code but I couldn't find some of the functions or argument values that works and that are in use in battmngr.

Let me know how it goes!

dsdt.zip

@agorgl
Copy link
Author

agorgl commented Oct 30, 2021

Hmmm, your dsdt.dsl seems way more straightforward than mine, as in the SBMC method it sets the BTSM and QCHO values that you read back directly.
In my case:

  • It calls another method that
  • In ALL cases (both battery conservation and rapid charge) it sets two values in SystemMemory that the first seems to be the type of the operation (0x30 for battery conservation and 0x31 for rapid charge) and the toggle (0xA0 for ON and 0xA1 for OFF) and then
  • It goes into a sleep loop for a while. I suppose it waits for some interrupt to handle the change into that memory region?

@agorgl
Copy link
Author

agorgl commented Oct 30, 2021

Relevant acpi methods:

Method (SBMC, 1, NotSerialized)
{
    If ((Arg0 == 0x03))
    {
        ECCC (0x30, 0xA0, Zero, Zero)
        ECCC (0x31, 0xA1, Zero, Zero)
        Return (Zero)
    }

    If ((Arg0 == 0x05))
    {
        ECCC (0x30, 0xA1, Zero, Zero)
        Return (Zero)
    }

    If ((Arg0 == 0x07))
    {
        ECCC (0x31, 0xA0, Zero, Zero)
        ECCC (0x30, 0xA1, Zero, Zero)
        Return (Zero)
    }

    If ((Arg0 == 0x08))
    {
        ECCC (0x31, 0xA1, Zero, Zero)
        Return (Zero)
    }

    Return (Zero)
}

and

Method (ECCC, 4, Serialized)
{
    Local0 = Acquire (QEVT, 0x07D0)
    If ((Local0 == Zero))
    {
        DAT0 = Arg1
        DAT1 = Arg2
        DAT2 = Arg3
        CMDB = Arg0
        Local0 = 0x0100
        While ((Local0 && CMDB))
        {
            Sleep (0x02)
            Local0--
        }

        If ((CMDB == Zero))
        {
            Local0 = Zero
        }
        Else
        {
            Local0 = 0xFF
        }

        Release (QEVT)
        Return (Local0)
    }

    Release (QEVT)
    Return (0xFF)
}

The CMDB seems to be the type of operation (rapid charge / battery conservation) and DAT0 the on/off toggle

@agorgl
Copy link
Author

agorgl commented Oct 30, 2021

The relevant memory region is this:

OperationRegion (SMA2, SystemMemory, 0xFEFF0A00, 0x80)
Field (SMA2, ByteAcc, Lock, Preserve)
{
    CMDB,   8, 
    STAT,   8, 
    NUMB,   8, 
    DAT0,   8, 
    DAT1,   8, 
    DAT2,   8, 
    DAT3,   8, 
    DAT4,   8, 
    DAT5,   8, 
    DAT6,   8, 
    DAT7,   8, 
    DAT8,   8, 
    DAT9,   8, 
    DATA,   8, 
    DATB,   8, 
    DATC,   8
}

I'm not really familiar with ACPI/DSDT but I cannot find any read references for CMDB or any reference for SMA2 at all.

@0xless
Copy link
Owner

0xless commented Nov 3, 2021

You went way more in depth than I did analyzing the code, thanks for the effort.
As you pointed out, references to some of the functions used are not present in the file.

In my opinion it would be easier to setup a Windows test environment, install Lenovo Vantage and sniff the ACPI calls sent by the software. I didn't try this yet, but looking around on the internet, this seems to be doable.

@xaibex
Copy link

xaibex commented May 5, 2022

@0xless : do you have recommendations on how to sniff ACPI calls (software etc,)?

@0xless
Copy link
Owner

0xless commented Jun 12, 2022

@xaibex never attempted that, but if you find any interesting software, please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants