Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -purN a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
- --- a/drivers/platform/x86/asus-wmi.c 2019-09-16 00:19:32.000000000 +0300
- +++ b/drivers/platform/x86/asus-wmi.c 2019-11-03 13:40:38.768657383 +0200
- @@ -58,6 +58,7 @@ MODULE_LICENSE("GPL");
- #define NOTIFY_KBD_BRTDWN 0xc5
- #define NOTIFY_KBD_BRTTOGGLE 0xc7
- #define NOTIFY_KBD_FBM 0x99
- +#define NOTIFY_KBD_FBM_2 0xae
- #define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0)
- @@ -182,7 +183,7 @@ struct asus_wmi {
- int asus_hwmon_num_fans;
- int asus_hwmon_pwm;
- - bool fan_boost_mode_available;
- + int fan_boost_mode_available;
- u8 fan_boost_mode_mask;
- u8 fan_boost_mode;
- @@ -1492,24 +1493,36 @@ static int fan_boost_mode_check_present(
- u32 result;
- int err;
- - asus->fan_boost_mode_available = false;
- + asus->fan_boost_mode_available = 0;
- err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE,
- &result);
- - if (err) {
- - if (err == -ENODEV)
- +
- + if (err == 0) {
- + if ((result & ASUS_WMI_DSTS_PRESENCE_BIT) &&
- + (result & ASUS_FAN_BOOST_MODES_MASK)) {
- + asus->fan_boost_mode_available = 1;
- + asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK;
- return 0;
- - else
- - return err;
- + }
- }
- -
- - if ((result & ASUS_WMI_DSTS_PRESENCE_BIT) &&
- - (result & ASUS_FAN_BOOST_MODES_MASK)) {
- - asus->fan_boost_mode_available = true;
- - asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK;
- + else {
- + err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE_2,
- + &result);
- +
- + if (err == 0 &&
- + (result & ASUS_WMI_DSTS_PRESENCE_BIT) &&
- + (result & ASUS_FAN_BOOST_MODES_MASK)) {
- + asus->fan_boost_mode_available = 2;
- + asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK;
- + return 0;
- + }
- }
- - return 0;
- + if (err == -ENODEV)
- + return 0;
- +
- + return err;
- }
- static int fan_boost_mode_write(struct asus_wmi *asus)
- @@ -1521,8 +1534,10 @@ static int fan_boost_mode_write(struct a
- value = asus->fan_boost_mode;
- pr_info("Set fan boost mode: %u\n", value);
- - err = asus_wmi_set_devstate(ASUS_WMI_DEVID_FAN_BOOST_MODE, value,
- - &retval);
- + err = asus_wmi_set_devstate(asus->fan_boost_mode_available == 1 ?
- + ASUS_WMI_DEVID_FAN_BOOST_MODE : ASUS_WMI_DEVID_FAN_BOOST_MODE_2,
- + value,
- + &retval);
- if (err) {
- pr_warn("Failed to set fan boost mode: %d\n", err);
- @@ -1538,6 +1553,18 @@ static int fan_boost_mode_write(struct a
- return 0;
- }
- +static int fan_boost_mode_set_default(struct asus_wmi *asus) {
- + int result = 0;
- +
- + if (asus->fan_boost_mode_available) {
- + // Set default fan mode to normal
- + asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL;
- + result = fan_boost_mode_write(asus);
- + }
- +
- + return result;
- +}
- +
- static int fan_boost_mode_switch_next(struct asus_wmi *asus)
- {
- u8 mask = asus->fan_boost_mode_mask;
- @@ -1595,7 +1622,7 @@ static ssize_t fan_boost_mode_store(stru
- asus->fan_boost_mode = new_mode;
- fan_boost_mode_write(asus);
- - return result;
- + return count;
- }
- // Fan boost mode: 0 - normal, 1 - overboost, 2 - silent
- @@ -1879,7 +1906,8 @@ static void asus_wmi_handle_event_code(i
- return;
- }
- - if (asus->fan_boost_mode_available && code == NOTIFY_KBD_FBM) {
- + if (asus->fan_boost_mode_available &&
- + (code == NOTIFY_KBD_FBM || code == NOTIFY_KBD_FBM_2)) {
- fan_boost_mode_switch_next(asus);
- return;
- }
- @@ -2063,7 +2091,7 @@ static umode_t asus_sysfs_is_visible(str
- else if (attr == &dev_attr_als_enable.attr)
- devid = ASUS_WMI_DEVID_ALS_ENABLE;
- else if (attr == &dev_attr_fan_boost_mode.attr)
- - ok = asus->fan_boost_mode_available;
- + ok = asus->fan_boost_mode_available != 0;
- if (devid != -1)
- ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
- @@ -2324,6 +2352,7 @@ static int asus_wmi_add(struct platform_
- err = fan_boost_mode_check_present(asus);
- if (err)
- goto fail_fan_boost_mode;
- + fan_boost_mode_set_default(asus);
- err = asus_wmi_sysfs_init(asus->platform_device);
- if (err)
- diff -purN a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
- --- a/include/linux/platform_data/x86/asus-wmi.h 2019-09-16 00:19:32.000000000 +0300
- +++ b/include/linux/platform_data/x86/asus-wmi.h 2019-11-03 11:59:28.926438572 +0200
- @@ -58,6 +58,7 @@
- #define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */
- #define ASUS_WMI_DEVID_LIGHTBAR 0x00050025
- #define ASUS_WMI_DEVID_FAN_BOOST_MODE 0x00110018
- +#define ASUS_WMI_DEVID_FAN_BOOST_MODE_2 0x00120075
- /* Misc */
- #define ASUS_WMI_DEVID_CAMERA 0x00060013
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement