wmi: some ASUS laptops need have ALS forced enabled

Change-Id: Ie0752419b1e60d78cdfe60e5b35303a09db10400
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2504
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Jérôme Duval 2020-04-20 13:55:26 +02:00
parent 97f2b91169
commit ceb94d0080
4 changed files with 31 additions and 3 deletions

View File

@ -1,6 +1,6 @@
SubDir HAIKU_TOP src add-ons kernel drivers wmi ;
UsePrivateHeaders wmi ;
UsePrivateHeaders drivers wmi ;
UsePrivateKernelHeaders ;
KernelAddon wmi :

View File

@ -17,6 +17,7 @@
device_manager_info *gDeviceManager;
smbios_module_info *gSMBios;
acpi_status wmi_acpi_adr_space_handler(uint32 function,
@ -453,9 +454,9 @@ wmi_acpi_register_child_devices(void *cookie)
}
module_dependency module_dependencies[] = {
{ B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&gDeviceManager },
{ SMBIOS_MODULE_NAME, (module_info**)&gSMBios },
{}
};

View File

@ -19,6 +19,8 @@
#define ASUS_WMI_METHODID_DSTS 0x53545344
#define ASUS_WMI_METHODID_DEVS 0x53564544
#define ASUS_WMI_DEVID_ALS_ENABLE 0x00050001
#define ASUS_WMI_DEVID_BRIGHTNESS 0x00050012
#define ASUS_WMI_DEVID_KBD_BACKLIGHT 0x00050021
@ -37,12 +39,14 @@ private:
static void _NotifyHandler(acpi_handle handle,
uint32 notify, void *context);
void _Notify(acpi_handle handle, uint32 notify);
status_t _EnableAls(uint32 enable);
private:
device_node* fNode;
wmi_device_interface* wmi;
wmi_device wmi_cookie;
uint32 fDstsID;
const char* fEventGuidString;
bool fEnableALS;
};
@ -51,7 +55,8 @@ WMIAsus::WMIAsus(device_node *node)
:
fNode(node),
fDstsID(ASUS_WMI_METHODID_DSTS),
fEventGuidString(NULL)
fEventGuidString(NULL),
fEnableALS(false)
{
CALLED();
@ -77,6 +82,13 @@ WMIAsus::WMIAsus(device_node *node)
TRACE("_SFUN: %x\n", value);
}
// some ASUS laptops need to be ALS forced
fEnableALS =
gSMBios->match_vendor_product("ASUSTeK COMPUTER INC.", "UX430UAR");
if (fEnableALS && _EnableAls(1) == B_OK) {
TRACE("ALSC enabled\n");
}
// install event handler
if (wmi->install_event_handler(wmi_cookie, ACPI_ASUS_WMI_EVENT_GUID,
_NotifyHandler, this) == B_OK) {
@ -87,6 +99,11 @@ WMIAsus::WMIAsus(device_node *node)
WMIAsus::~WMIAsus()
{
// for ALS
if (fEnableALS && _EnableAls(0) == B_OK) {
TRACE("ALSC disabled\n");
}
if (fEventGuidString != NULL)
wmi->remove_event_handler(wmi_cookie, fEventGuidString);
}
@ -119,6 +136,14 @@ WMIAsus::_EvaluateMethod(uint32 methodId, uint32 arg0, uint32 arg1,
}
status_t
WMIAsus::_EnableAls(uint32 enable)
{
CALLED();
return _SetDevState(ASUS_WMI_DEVID_ALS_ENABLE, enable, NULL);
}
status_t
WMIAsus::_GetDevState(uint32 devId, uint32 *value)
{

View File

@ -12,6 +12,7 @@
#include <string.h>
#include <lock.h>
#include <smbios.h>
#include <util/AutoLock.h>
#include <wmi.h>
@ -43,6 +44,7 @@ class WMIDevice;
extern device_manager_info *gDeviceManager;
extern smbios_module_info *gSMBios;
extern wmi_device_interface gWMIDeviceModule;
extern driver_module_info gWMIAsusDriverModule;