• Paulo Alcantara's avatar
    platform/x86: hp-wmi: Correctly determine method id in WMI calls · fbcb4a57
    Paulo Alcantara authored
    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: default avatarPaulo Alcantara <pcacjr@zytor.com>
    Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
    fbcb4a57
hp-wmi.c 25 KB