diff --git a/YogaSMC/YogaVPC/IdeaVPC.cpp b/YogaSMC/YogaVPC/IdeaVPC.cpp index f3c25851..a4fa7ae2 100644 --- a/YogaSMC/YogaVPC/IdeaVPC.cpp +++ b/YogaSMC/YogaVPC/IdeaVPC.cpp @@ -42,7 +42,7 @@ bool IdeaVPC::initVPC() { setPropertyBoolean(capabilities, "Camera", (config >> CFG_CAMERA_BIT) & 0x1); setPropertyBoolean(capabilities, "Touchpad", (config >> CFG_TOUCHPAD_BIT) & 0x1); - UInt8 cap_graphics = config >> CFG_GRAPHICS_BIT & 0x7; + UInt8 cap_graphics = config >> CFG_GRAPHICS_3BIT & 0x7; switch (cap_graphics) { case 1: setPropertyString(capabilities, "Graphics", "Intel"); @@ -322,13 +322,13 @@ void IdeaVPC::updateKeyboardCapability() { return; } - backlightCap = BIT(HA_BACKLIGHT_CAP_BIT) & kbdState; + backlightCap = BIT(HA_BACKLIGHT_CAP) & kbdState; if (!backlightCap) setProperty(backlightPrompt, "unsupported"); else setProperty(autoBacklightPrompt, automaticBacklightMode, 8); - FnlockCap = BIT(HA_FNLOCK_CAP_BIT) & kbdState; + FnlockCap = BIT(HA_FNLOCK_CAP) & kbdState; if (!FnlockCap) setProperty(FnKeyPrompt, "unsupported"); @@ -337,7 +337,7 @@ void IdeaVPC::updateKeyboardCapability() { else setProperty("PrimeKeyType", "FnKey"); - alwaysOnUSBCap = BIT(HA_AOUSB_CAP_BIT) & kbdState; + alwaysOnUSBCap = BIT(HA_AOUSB_CAP) & kbdState; if (!alwaysOnUSBCap) setProperty(alwaysOnUSBPrompt, "unsupported"); } @@ -352,16 +352,20 @@ void IdeaVPC::updateBatteryCapability() { return; } + rapidChargeCap = BIT(BM_RAPIDCHARGE_CAP) & batState; + if (!rapidChargeCap) + setProperty(rapidChargePrompt, "unsupported"); + OSDictionary *bat0 = OSDictionary::withCapacity(5); OSDictionary *bat1 = OSDictionary::withCapacity(5); - if (BIT(BM_BATTERY0BAD_BIT) & batState) { + if (BIT(BM0_BATTERYBAD_BIT) & batState) { bat0->setObject("Critical", kOSBooleanTrue); setProperty("Battery", "Critical"); AlwaysLog("Battery 0 critical!"); conservationModeLock = true; } - if (BIT(BM_BATTERY1BAD_BIT) & batState) { + if (BIT(BM1_BATTERYBAD_BIT) & batState) { bat1->setObject("Critical", kOSBooleanTrue); setProperty("Battery", "Critical"); AlwaysLog("Battery 1 critical!"); @@ -546,15 +550,16 @@ bool IdeaVPC::updateBattery(bool update) { return false; } - conservationMode = BIT(BM_CONSERVATION_BIT) & state; - rapidChargeMode = BIT(BM_RAPIDCHARGE_BIT) & state; - if (update) { DebugLog(updateSuccess, batteryPrompt, state); } + conservationMode = BIT(BM0_CONSERVATION_BIT) & state; setProperty(conservationPrompt, conservationMode); - setProperty(rapidChargePrompt, rapidChargeMode); + if (rapidChargeCap) { + rapidChargeMode = BIT(BM_RAPIDCHARGE_BIT) & state; + setProperty(rapidChargePrompt, rapidChargeMode); + } return true; } @@ -577,10 +582,6 @@ bool IdeaVPC::updateKeyboard(bool update) { // Inference from brightness cycle: 0 -> 1 -> 2 -> 0 backlightLevel = (BIT(HA_BACKLIGHT_BIT) & state) ? (backlightLevel ? 2 : 1) : 0; } - if (FnlockCap) - FnlockMode = BIT(HA_FNLOCK_BIT) & state; - if (alwaysOnUSBCap) - alwaysOnUSBMode = BIT(HA_AOUSB_BIT) & state; if (update) { DebugLog(updateSuccess, keyboardPrompt, state); @@ -588,10 +589,14 @@ bool IdeaVPC::updateKeyboard(bool update) { if (backlightCap) setProperty(backlightPrompt, backlightLevel, 32); - if (FnlockCap) + if (FnlockCap) { + FnlockMode = BIT(HA_FNLOCK_BIT) & state; setProperty(FnKeyPrompt, FnlockMode); - if (alwaysOnUSBCap) + } + if (alwaysOnUSBCap) { setProperty(alwaysOnUSBPrompt, alwaysOnUSBMode); + alwaysOnUSBMode = BIT(HA_AOUSB_BIT) & state; + } return true; } @@ -617,14 +622,14 @@ bool IdeaVPC::toggleAlwaysOnUSB() { } bool IdeaVPC::toggleConservation() { - IOReturn ret = evaluateIntegerParam(setBatteryMode, nullptr, conservationMode ? BMCMD_CONSERVATION_OFF : BMCMD_CONSERVATION_ON); + IOReturn ret = evaluateIntegerParam(setBatteryMode, nullptr, conservationMode ? BMCMD0_CONSERVATION_OFF : BMCMD0_CONSERVATION_ON); if (ret != kIOReturnSuccess) { AlwaysLog(toggleError, conservationPrompt, ret); return false; } conservationMode = !conservationMode; - DebugLog(toggleSuccess, conservationPrompt, (conservationMode ? BMCMD_CONSERVATION_ON : BMCMD_CONSERVATION_OFF), (conservationMode ? "on" : "off")); + DebugLog(toggleSuccess, conservationPrompt, (conservationMode ? BMCMD0_CONSERVATION_ON : BMCMD0_CONSERVATION_OFF), (conservationMode ? "on" : "off")); setProperty(conservationPrompt, conservationMode); notifyBattery(); @@ -632,18 +637,17 @@ bool IdeaVPC::toggleConservation() { } bool IdeaVPC::toggleRapidCharge() { - // experimental, reset required - if (conservationModeLock) - return false; + if (!rapidChargeCap) + return true; - IOReturn ret = evaluateIntegerParam(setBatteryMode, nullptr, rapidChargeMode ? BMCMD_RAPIDCHARGE_OFF : BMCMD_RAPIDCHARGE_ON); + IOReturn ret = evaluateIntegerParam(setBatteryMode, nullptr, rapidChargeMode ? BMCMD0_RAPIDCHARGE_OFF : BMCMD0_RAPIDCHARGE_ON); if (ret != kIOReturnSuccess) { AlwaysLog(toggleError, rapidChargePrompt, ret); return false; } rapidChargeMode = !rapidChargeMode; - DebugLog(toggleSuccess, rapidChargePrompt, (rapidChargeMode ? BMCMD_RAPIDCHARGE_ON : BMCMD_RAPIDCHARGE_OFF), (rapidChargeMode ? "on" : "off")); + DebugLog(toggleSuccess, rapidChargePrompt, (rapidChargeMode ? BMCMD0_RAPIDCHARGE_ON : BMCMD0_RAPIDCHARGE_OFF), (rapidChargeMode ? "on" : "off")); setProperty(rapidChargePrompt, conservationMode); return true; diff --git a/YogaSMC/YogaVPC/IdeaVPC.hpp b/YogaSMC/YogaVPC/IdeaVPC.hpp index 21a6e11d..37b59f46 100644 --- a/YogaSMC/YogaVPC/IdeaVPC.hpp +++ b/YogaSMC/YogaVPC/IdeaVPC.hpp @@ -17,45 +17,113 @@ // from linux/drivers/platform/x86/ideapad-laptop.c enum { - CFG_GRAPHICS_BIT = 8, - CFG_BT_BIT = 16, - CFG_3G_BIT = 17, - CFG_WIFI_BIT = 18, - CFG_CAMERA_BIT = 19, - CFG_TOUCHPAD_BIT = 30, + CFG_WIRELESS_COEX_BIT, /* 0 */ + CFG_RESERVED_BIT, /* 1 */ + CFG_PROCESSOR_BIT, /* 2 */ + CFG_QUITE_BIT, /* 3 */ + CFG_TOUCH_BIT, /* 4 */ + CFG_SUPER_PERF_BIT, /* 5 */ + CFG_UNDERCLOCK_BIT, /* 6 */ + CFG_DCR_BIT, /* 7 */ + CFG_GRAPHICS_3BIT, /* 8 */ + CFG_HDMI_BIT = 11, + CFG_ACTIVE_VGA_BIT, /* 12 */ + CFG_EQ_BUTTON_3BIT, /* 13 */ + CFG_BT_BIT = 16, + CFG_3G_BIT, /* 17 */ + CFG_WIFI_BIT, /* 18 */ + CFG_CAMERA_BIT, /* 19 */ + CFG_USER_BUTTON_3BIT, /* 20 */ + CFG_COLOR_ENGINE_BIT, /* 23 */ + CFG_PRODUCT_INFO_2BIT, /* 24 */ + CFG_TOUCHPAD_OSD_BIT, /* 26 */ + CFG_NUMLK_OSD_BIT, /* 27 */ + CFG_CAPSLK_OSD_BIT, /* 28 */ + CFG_MIC_OSD_BIT, /* 29 */ + CFG_TOUCHPAD_BIT, /* 30 */ + CFG_CAMERA_OSD_BIT, /* 31 */ }; enum { - BM_RAPIDCHARGE_BIT = 2, - BM_BATTERY0BAD_BIT = 3, - BM_BATTERY1BAD_BIT = 4, - BM_CONSERVATION_BIT = 5, + BM0_CALIBRATION_BIT, /* 0 */ + BM_STORAGEMODE_SEL_BIT, /* 1 */ + BM_RAPIDCHARGE_BIT, /* 2 */ + BM0_BATTERYBAD_BIT, /* 3 */ + BM1_BATTERYBAD_BIT, /* 4 */ + BM0_CONSERVATION_BIT, /* 5 */ + BM1_CONSERVATION_BIT, /* 6 */ + BM0_ILLEGAL_BIT, /* 7 */ + BM0_PERF_DEGRADE_BIT, /* 8 */ + BM0_STORAGEMODE_STA_BIT, /* 9 */ + BM1_ILLEGAL_BIT, /* 10 */ + BM0_NORMAL_BIT, /* 11 */ + BM1_NORMAL_BIT, /* 12 */ + BM1_PERF_DEGRADE_BIT, /* 13 */ + BM_BATTERYNUM_BIT, /* 14 */ + BM_ADAPTER_TYPE_2BIT, /* 15 */ + BM_RAPIDCHARGE_CAP, /* 17 */ + BM_SHIPMODE_CAP, /* 18 */ + BM_ADAPTER_TYPE_CAP, /* 19 */ + BM1_CALIBRATION_BIT, /* 20 */ + BM1_STORAGEMODE_STA_BIT, /* 21 */ + BM_SHIPMODE_BIT, /* 22 */ + BM_CHARGE_THRES_BIT, /* 23 */ }; enum { - BMCMD_CONSERVATION_ON = 0x3, - BMCMD_CONSERVATION_OFF = 0x5, - BMCMD_RAPIDCHARGE_ON = 0x7, - BMCMD_RAPIDCHARGE_OFF = 0x8, + BMCMD0_CALIBRATION_END, /* 0 */ + BMCMD0_CALIBRATION_INIT, /* 1 */ + BMCMD0_CONSERVATION_ON = 3, + BMCMD0_CONSERVATION_OFF = 5, + BMCMD0_STORAGEMODE_CLR, /* 6 */ + BMCMD0_RAPIDCHARGE_ON, /* 7 */ + BMCMD0_RAPIDCHARGE_OFF, /* 8 */ + BMCMD_SHIPMODE_ENTER, /* 9 */ + BMCMD1_CALIBRATION_END, /* 10 */ + BMCMD1_CALIBRATION_INIT, /* 11 */ + BMCMD1_CONSERVATION_ON = 13, + BMCMD1_CONSERVATION_OFF = 15, + BMCMD_SHIPMODE_EXIT, /* 16 */ }; enum { - HA_BACKLIGHT_CAP_BIT = 4, - HA_BACKLIGHT_BIT = 5, - HA_AOUSB_CAP_BIT = 6, - HA_AOUSB_BIT = 7, - HA_FNLOCK_CAP_BIT = 9, - HA_FNLOCK_BIT = 10, - HA_PRIMEKEY_BIT = 11, + HA_ALS_BIT, /* 0 */ + HA_ALSKBC_BIT, /* 1 */ + HA_ALSKBC_CAP, /* 2 */ + HA_ALS_CAP, /* 3 */ + HA_BACKLIGHT_CAP, /* 4 */ + HA_BACKLIGHT_BIT, /* 5 */ + HA_AOUSB_CAP, /* 6 */ + HA_AOUSB_BIT, /* 7 */ + HA_AUTODIS_CAP, /* 8 */ + HA_FNLOCK_CAP, /* 9 */ + HA_FNLOCK_BIT, /* 10 */ + HA_PRIMEKEY_BIT, /* 11 */ + HA_S0IL_CAP, /* 12 */ + HA_ITS_BIT, /* 13 */ + HA_AOUSBBAT_CAP, /* 14 */ + HA_AOUSBBAT_BIT, /* 15 */ }; enum { - HACMD_BACKLIGHT_ON = 0x8, - HACMD_BACKLIGHT_OFF = 0x9, - HACMD_AOUSB_ON = 0xa, - HACMD_AOUSB_OFF = 0xb, - HACMD_FNLOCK_ON = 0xe, - HACMD_FNLOCK_OFF = 0xf, + HACMD_S0IL_OFF, /* 0 */ + HACMD_S0IL_ON, /* 1 */ + HACMD_COLOR_ENG_ON = 4, + HACMD_COLOR_ENG_OFF, /* 5 */ + HACMD_ALS_OFF, /* 6 */ + HACMD_ALS_ON, /* 7 */ + HACMD_BACKLIGHT_ON, /* 8 */ + HACMD_BACKLIGHT_OFF, /* 9 */ + HACMD_AOUSB_ON, /* 10 */ + HACMD_AOUSB_OFF, /* 11 */ + HACMD_AUTOKT_ON, /* 12 */ + HACMD_AUTOKT_OFF, /* 13 */ + HACMD_FNLOCK_ON, /* 14 */ + HACMD_FNLOCK_OFF, /* 15 */ + HACMD_S0IL_ENTER, /* 16 */ + HACMD_S0IL_EXIT, /* 17 */ + HACMD_AOUSBBAT_OFF, /* 18 */ + HACMD_AOUSBBAT_ON, /* 19 */ }; enum { @@ -159,6 +227,11 @@ class IdeaVPC : public YogaVPC */ bool FnlockCap {false}; + /** + * Rapid charge mode capability, will be update on init + */ + bool rapidChargeCap {false}; + /** * Rapid charge mode status */ diff --git a/YogaSMCPane/Base.lproj/YogaSMCPane.xib b/YogaSMCPane/Base.lproj/YogaSMCPane.xib index a3d858dc..3f256a45 100644 --- a/YogaSMCPane/Base.lproj/YogaSMCPane.xib +++ b/YogaSMCPane/Base.lproj/YogaSMCPane.xib @@ -1,8 +1,8 @@ - + - + @@ -520,7 +520,7 @@