platform/x86: hp-wmi: Correctly determine method id in WMI calls
authorPaulo Alcantara <pcacjr@zytor.com>
Sun, 30 Jul 2017 12:47:55 +0000 (09:47 -0300)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Sun, 13 Aug 2017 12:17:24 +0000 (15:17 +0300)
commitfbcb4a578bc29cfad82f838247ff1c2869433759
treec917238bb34050b69f6cc9806f9c07c12eb40ce6
parentc801603e6d0c1bf87930402462d2e4185b1e9264
platform/x86: hp-wmi: Correctly determine method id in WMI calls

The WMI queries are performed by evaluating the WMPV() method from ACPI
DSDT tables, and it takes three arguments: instance index, method id and
input data (buffer).

Currently the method id is hard-coded to 0x3 in hp_wmi_perform_query()
which means that it will perform WMI calls that expect an output data of
size 0x80 (128). The output size is usually OK for the WMI queries we
perform, however it would be better to pick the correct one before
evaluating the WMI method.

Which correct method id to choose can be figured out by looking at the
following ASL code from WVPI() method:

...
Name (PVSZ, Package (0x05)
            {
            Zero,
            0x04,
            0x80,
            0x0400,
            0x1000
            })
Store (Zero, Local0)
If (LAnd (LGreaterEqual (Arg1, One), LLessEqual (Arg1, 0x05)))
{
    Store (DerefOf (Index (PVSZ, Subtract (Arg1, One))), Local0)
}
...

Arg1 is the method id and PVSZ is the package used to index the
corresponding output size; 1 -> 0, 2 -> 4, 3 -> 128, 4 -> 1024, 5 ->
4096.

This patch maps the output size passed in hp_wmi_perform_query() to the
correct method id before evaluating the WMI method.

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/platform/x86/hp-wmi.c