diff --git a/src/uniwill_interfaces.h b/src/uniwill_interfaces.h index ae95e39..c0a3ab0 100644 --- a/src/uniwill_interfaces.h +++ b/src/uniwill_interfaces.h @@ -68,6 +68,7 @@ struct uniwill_device_features_t { bool uniwill_profile_v1_two_profs; bool uniwill_profile_v1_three_profs; bool uniwill_profile_v1_three_profs_leds_only; + bool uniwill_has_charging_prio; }; u32 uniwill_add_interface(struct uniwill_interface_t *new_interface); diff --git a/src/uniwill_keyboard.h b/src/uniwill_keyboard.h index e921a8f..9d987c3 100644 --- a/src/uniwill_keyboard.h +++ b/src/uniwill_keyboard.h @@ -208,60 +208,6 @@ u32 uniwill_get_active_interface_id(char **id_str) } EXPORT_SYMBOL(uniwill_get_active_interface_id); -struct uniwill_device_features_t *uniwill_get_device_features(void) -{ - struct uniwill_device_features_t *uw_feats = &uniwill_device_features; - u32 status; - - status = uniwill_read_ec_ram(0x0740, &uw_feats->model); - if (status != 0) - uw_feats->model = 0; - - uw_feats->uniwill_profile_v1_two_profs = false - || dmi_match(DMI_BOARD_NAME, "PF5PU1G") - || dmi_match(DMI_BOARD_NAME, "PULSE1401") - || dmi_match(DMI_BOARD_NAME, "PULSE1501") - ; - - uw_feats->uniwill_profile_v1_three_profs = false - // Devices with "classic" profile support - || dmi_match(DMI_BOARD_NAME, "POLARIS1501A1650TI") - || dmi_match(DMI_BOARD_NAME, "POLARIS1501A2060") - || dmi_match(DMI_BOARD_NAME, "POLARIS1501I1650TI") - || dmi_match(DMI_BOARD_NAME, "POLARIS1501I2060") - || dmi_match(DMI_BOARD_NAME, "POLARIS1701A1650TI") - || dmi_match(DMI_BOARD_NAME, "POLARIS1701A2060") - || dmi_match(DMI_BOARD_NAME, "POLARIS1701I1650TI") - || dmi_match(DMI_BOARD_NAME, "POLARIS1701I2060") - // Note: XMG Fusion removed for now, seem to have - // neither same power profile control nor TDP set - //|| dmi_match(DMI_BOARD_NAME, "LAPQC71A") - //|| dmi_match(DMI_BOARD_NAME, "LAPQC71B") - //|| dmi_match(DMI_PRODUCT_NAME, "A60 MUV") - ; - - uw_feats->uniwill_profile_v1_three_profs_leds_only = false - // Devices where profile mainly controls power profile LED status -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) - || dmi_match(DMI_PRODUCT_SKU, "POLARIS1XA02") - || dmi_match(DMI_PRODUCT_SKU, "POLARIS1XI02") - || dmi_match(DMI_PRODUCT_SKU, "POLARIS1XA03") - || dmi_match(DMI_PRODUCT_SKU, "POLARIS1XI03") - || dmi_match(DMI_PRODUCT_SKU, "STELLARIS1XI03") - || dmi_match(DMI_PRODUCT_SKU, "STELLARIS1XA03") - || dmi_match(DMI_PRODUCT_SKU, "STELLARIS1XI04") - || dmi_match(DMI_PRODUCT_SKU, "STEPOL1XA04") -#endif - ; - - uw_feats->uniwill_profile_v1 = - uw_feats->uniwill_profile_v1_two_profs || - uw_feats->uniwill_profile_v1_three_profs; - - return uw_feats; -} -EXPORT_SYMBOL(uniwill_get_device_features); - static void key_event_work(struct work_struct *work) { sparse_keymap_report_known_event( @@ -848,6 +794,20 @@ static int uw_get_charging_priority(u8 *charging_priority) return result; } +static int uw_has_charging_priority(bool *status) +{ + u8 data; + int result; + result = uniwill_read_ec_ram(0x0742, &data); + + if (data & (1 << 5)) + *status = true; + else + *status = false; + + return result; +} + /* * charging_prio values * 0 => high capacity @@ -975,6 +935,62 @@ static struct attribute_group uw_charging_prio_attr_group = { .attrs = uw_charging_prio_attrs_list }; +struct uniwill_device_features_t *uniwill_get_device_features(void) +{ + struct uniwill_device_features_t *uw_feats = &uniwill_device_features; + u32 status; + + status = uniwill_read_ec_ram(0x0740, &uw_feats->model); + if (status != 0) + uw_feats->model = 0; + + uw_feats->uniwill_profile_v1_two_profs = false + || dmi_match(DMI_BOARD_NAME, "PF5PU1G") + || dmi_match(DMI_BOARD_NAME, "PULSE1401") + || dmi_match(DMI_BOARD_NAME, "PULSE1501") + ; + + uw_feats->uniwill_profile_v1_three_profs = false + // Devices with "classic" profile support + || dmi_match(DMI_BOARD_NAME, "POLARIS1501A1650TI") + || dmi_match(DMI_BOARD_NAME, "POLARIS1501A2060") + || dmi_match(DMI_BOARD_NAME, "POLARIS1501I1650TI") + || dmi_match(DMI_BOARD_NAME, "POLARIS1501I2060") + || dmi_match(DMI_BOARD_NAME, "POLARIS1701A1650TI") + || dmi_match(DMI_BOARD_NAME, "POLARIS1701A2060") + || dmi_match(DMI_BOARD_NAME, "POLARIS1701I1650TI") + || dmi_match(DMI_BOARD_NAME, "POLARIS1701I2060") + // Note: XMG Fusion removed for now, seem to have + // neither same power profile control nor TDP set + //|| dmi_match(DMI_BOARD_NAME, "LAPQC71A") + //|| dmi_match(DMI_BOARD_NAME, "LAPQC71B") + //|| dmi_match(DMI_PRODUCT_NAME, "A60 MUV") + ; + + uw_feats->uniwill_profile_v1_three_profs_leds_only = false + // Devices where profile mainly controls power profile LED status +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) + || dmi_match(DMI_PRODUCT_SKU, "POLARIS1XA02") + || dmi_match(DMI_PRODUCT_SKU, "POLARIS1XI02") + || dmi_match(DMI_PRODUCT_SKU, "POLARIS1XA03") + || dmi_match(DMI_PRODUCT_SKU, "POLARIS1XI03") + || dmi_match(DMI_PRODUCT_SKU, "STELLARIS1XI03") + || dmi_match(DMI_PRODUCT_SKU, "STELLARIS1XA03") + || dmi_match(DMI_PRODUCT_SKU, "STELLARIS1XI04") + || dmi_match(DMI_PRODUCT_SKU, "STEPOL1XA04") +#endif + ; + + uw_feats->uniwill_profile_v1 = + uw_feats->uniwill_profile_v1_two_profs || + uw_feats->uniwill_profile_v1_three_profs; + + uw_has_charging_priority(&uw_feats->uniwill_has_charging_prio); + + return uw_feats; +} +EXPORT_SYMBOL(uniwill_get_device_features); + static int uniwill_keyboard_probe(struct platform_device *dev) { u32 i;