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 <[email protected]>
This commit is contained in:
Jérôme Duval
2020-04-27 07:38:40 +00:00
parent 97f2b91169
commit ceb94d0080
4 changed files with 31 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src add-ons kernel drivers wmi ; SubDir HAIKU_TOP src add-ons kernel drivers wmi ;
UsePrivateHeaders wmi ; UsePrivateHeaders drivers wmi ;
UsePrivateKernelHeaders ; UsePrivateKernelHeaders ;
KernelAddon wmi : KernelAddon wmi :
+2 -1
View File
@@ -17,6 +17,7 @@
device_manager_info *gDeviceManager; device_manager_info *gDeviceManager;
smbios_module_info *gSMBios;
acpi_status wmi_acpi_adr_space_handler(uint32 function, acpi_status wmi_acpi_adr_space_handler(uint32 function,
@@ -453,9 +454,9 @@ wmi_acpi_register_child_devices(void *cookie)
} }
module_dependency module_dependencies[] = { module_dependency module_dependencies[] = {
{ B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&gDeviceManager }, { B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&gDeviceManager },
{ SMBIOS_MODULE_NAME, (module_info**)&gSMBios },
{} {}
}; };
+26 -1
View File
@@ -19,6 +19,8 @@
#define ASUS_WMI_METHODID_DSTS 0x53545344 #define ASUS_WMI_METHODID_DSTS 0x53545344
#define ASUS_WMI_METHODID_DEVS 0x53564544 #define ASUS_WMI_METHODID_DEVS 0x53564544
#define ASUS_WMI_DEVID_ALS_ENABLE 0x00050001
#define ASUS_WMI_DEVID_BRIGHTNESS 0x00050012 #define ASUS_WMI_DEVID_BRIGHTNESS 0x00050012
#define ASUS_WMI_DEVID_KBD_BACKLIGHT 0x00050021 #define ASUS_WMI_DEVID_KBD_BACKLIGHT 0x00050021
@@ -37,12 +39,14 @@ private:
static void _NotifyHandler(acpi_handle handle, static void _NotifyHandler(acpi_handle handle,
uint32 notify, void *context); uint32 notify, void *context);
void _Notify(acpi_handle handle, uint32 notify); void _Notify(acpi_handle handle, uint32 notify);
status_t _EnableAls(uint32 enable);
private: private:
device_node* fNode; device_node* fNode;
wmi_device_interface* wmi; wmi_device_interface* wmi;
wmi_device wmi_cookie; wmi_device wmi_cookie;
uint32 fDstsID; uint32 fDstsID;
const char* fEventGuidString; const char* fEventGuidString;
bool fEnableALS;
}; };
@@ -51,7 +55,8 @@ WMIAsus::WMIAsus(device_node *node)
: :
fNode(node), fNode(node),
fDstsID(ASUS_WMI_METHODID_DSTS), fDstsID(ASUS_WMI_METHODID_DSTS),
fEventGuidString(NULL) fEventGuidString(NULL),
fEnableALS(false)
{ {
CALLED(); CALLED();
@@ -77,6 +82,13 @@ WMIAsus::WMIAsus(device_node *node)
TRACE("_SFUN: %x\n", value); 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 // install event handler
if (wmi->install_event_handler(wmi_cookie, ACPI_ASUS_WMI_EVENT_GUID, if (wmi->install_event_handler(wmi_cookie, ACPI_ASUS_WMI_EVENT_GUID,
_NotifyHandler, this) == B_OK) { _NotifyHandler, this) == B_OK) {
@@ -87,6 +99,11 @@ WMIAsus::WMIAsus(device_node *node)
WMIAsus::~WMIAsus() WMIAsus::~WMIAsus()
{ {
// for ALS
if (fEnableALS && _EnableAls(0) == B_OK) {
TRACE("ALSC disabled\n");
}
if (fEventGuidString != NULL) if (fEventGuidString != NULL)
wmi->remove_event_handler(wmi_cookie, fEventGuidString); 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 status_t
WMIAsus::_GetDevState(uint32 devId, uint32 *value) WMIAsus::_GetDevState(uint32 devId, uint32 *value)
{ {
@@ -12,6 +12,7 @@
#include <string.h> #include <string.h>
#include <lock.h> #include <lock.h>
#include <smbios.h>
#include <util/AutoLock.h> #include <util/AutoLock.h>
#include <wmi.h> #include <wmi.h>
@@ -43,6 +44,7 @@ class WMIDevice;
extern device_manager_info *gDeviceManager; extern device_manager_info *gDeviceManager;
extern smbios_module_info *gSMBios;
extern wmi_device_interface gWMIDeviceModule; extern wmi_device_interface gWMIDeviceModule;
extern driver_module_info gWMIAsusDriverModule; extern driver_module_info gWMIAsusDriverModule;