Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built-in screen wake blackscreen with a surface logo on it #1

Open
kingo132 opened this issue May 6, 2021 · 14 comments
Open

Built-in screen wake blackscreen with a surface logo on it #1

kingo132 opened this issue May 6, 2021 · 14 comments

Comments

@kingo132
Copy link
Owner

kingo132 commented May 6, 2021

After sleep and wake, it will just show a black screen with a surface logo on it. And the type cover can't wake the computer, also the USB mouse can't wake it too. It has to push the power button to wake it. And I can certain the system is waked up already, except the screen. And also if I connect an external monitor, the external monitor will show the login screen. No matter by sleep menu of left-top cornor or by close the type cover, the result is the same.

I have researched this problem for several days. Nearly tried all the methods about the wake black screen fix of Hackintosh. No luck.

I can somewhat certain it is related to iGPU, built-in display or maybe the power button, other components seems fine after the wake.

What I have tried:

  1. Different framebuffer id and many other Whatevergreen fixes
  2. After USB mapping, still the same
  3. Unlocked cfg-lock in BIOS, still the same
  4. darkwake boot arg, tried from 0 to 11, all the same
  5. SSDT-GPRW fix, no luck
  6. HibernationFixup.kext, no luck
  7. Played many combos with pmset, no luck
  8. Tried many fixes in DSDT, no luck
  9. Injected EDID of built-in display, no luck
  10. Turned on the hidpi, no luck
  11. Disabled discrete gpu, no luck
  12. Compared the framebuffers info in ioreg before and after sleep, they are the same except the IOHibernateState and IOScreenREstoreState properties, as in the screenshot below
    QQ20210506-111250
    QQ20210506-111321

Here is what I'm planning to do next:

  1. Continue playing around pmset
  2. Continue playing around DSDT debug and fixes
@kingo132
Copy link
Owner Author

kingo132 commented May 6, 2021

image

From this screenshot of the ACPI debug log. You can see when the system wake, the function _WAK is called with the Arg0 0x3, which means wake from S03 I think. In this _WAK function of the DSDT of surface go2. It will notify 0x80 event to LIDD (which is the lid or lid0 in some other devices), and also it will notify all the USB devices to wake up, and also many other codes that I didn't understand.

Here is the entire body of this function.

Method (_WAK, 1, Serialized)  // _WAK: Wake
{
    If (((Arg0 < One) || (Arg0 > 0x05)))
    {
        \RMDT.P2 ("Invalid _WAK: ", Arg0)
        Arg0 = 0x03
    }

    P8XH (One, 0xAB)
    If ((Arg0 == One))
    {
        H2OP (0xE1)
    }

    If ((Arg0 == 0x03))
    {
        H2OP (0xE3)
    }

    If ((Arg0 == 0x04))
    {
        H2OP (0xE4)
    }

    If ((Arg0 == 0x05))
    {
        H2OP (0xE5)
    }

    \RMDT.P2 ("MY _WAK: ", Arg0)
    TBPE = One
    If ((TBTS == One))
    {
        \RMDT.P1 (" TRD3 = Zero")
        TRD3 = Zero
    }

    \_SB.PCI0.GEXP.INVC ()
    If ((S0ID == One))
    {
        \RMDT.P1 ("_SB.SCGE = One")
        \_SB.SCGE = One
    }

    If (NEXP)
    {
        If ((OSCC & One))
        {
            \RMDT.P1 ("_SB.PCI0.NHPG")
            \_SB.PCI0.NHPG ()
        }

        If ((OSCC & 0x04))
        {
            \RMDT.P1 ("_SB.PCI0.NPME")
            \_SB.PCI0.NPME ()
        }
    }

    If ((\_SB.PCI0.LPCB.EC.HFON == Zero))
    {
        If (CondRefOf (\_SB.PWRB.BPST))
        {
            \RMDT.P1 ("Notify _SB.PWRB")
            \_SB.PWRB.BPST = One
            Notify (\_SB.PWRB, One) // Device Check
        }
    }

    If (((Arg0 == 0x03) || (Arg0 == 0x04)))
    {
        If ((\_SB.PCI0.LPCB.EC.DKST == One))
        {
            If (((\_SB.PCI0.LPCB.EC.TYCM == 0x03) || (\_SB.PCI0.LPCB.EC.TYCM == 0x04)))
            {
                \RMDT.P1 ("PB1E &= 0xFFFFFFFFFFFFFFEF 1")
                PB1E &= 0xFFFFFFFFFFFFFFEF
                \_SB.PCI0.LPCB.EC.UPBT (0x07, Zero)
                PB1E &= 0xFFFFFFFFFFFFFFF7
                \_SB.PCI0.LPCB.EC.UPBT (0x06, Zero)
            }
            ElseIf ((\_SB.PCI0.LPCB.EC.TYCM == 0x02))
            {
                \RMDT.P1 ("PB1E |= 0x10 1")
                PB1E |= 0x10
                \_SB.PCI0.LPCB.EC.UPBT (0x07, One)
                \RMDT.P1 ("Notify QD7 0xCA")
                Notify (\_SB.HIDD, 0xCA) // Hardware-Specific
                PB1E &= 0xFFFFFFFFFFFFFFF7
                \_SB.PCI0.LPCB.EC.UPBT (0x06, Zero)
                \RMDT.P1 ("Notify QD7 0xCC")
                Notify (\_SB.HIDD, 0xCC) // Hardware-Specific
            }
            ElseIf ((\_SB.PCI0.LPCB.EC.TYCM == One))
            {
                \RMDT.P1 ("PB1E |= 0x10 2")
                PB1E |= 0x10
                \_SB.PCI0.LPCB.EC.UPBT (0x07, One)
                PB1E |= 0x08
                \_SB.PCI0.LPCB.EC.UPBT (0x06, One)
            }
        }
        Else
        {
            \RMDT.P1 ("PB1E &= 0xFFFFFFFFFFFFFFEF 2")
            PB1E &= 0xFFFFFFFFFFFFFFEF
            \_SB.PCI0.LPCB.EC.UPBT (0x07, Zero)
            PB1E &= 0xFFFFFFFFFFFFFFF7
            \_SB.PCI0.LPCB.EC.UPBT (0x06, Zero)
        }

        If (CondRefOf (\_SB.PCI0.LPCB.EC.ONTM))
        {
            \RMDT.P1 ("_SB.PCI0.LPCB.EC.ONTM = One")
            \_SB.PCI0.LPCB.EC.ONTM = One
        }

        If (CondRefOf (\_PR.DTSE))
        {
            If ((\_PR.DTSE && (TCNT > One)))
            {
                \RMDT.P1 ("TRAP (0x02, 0x14)")
                TRAP (0x02, 0x14)
            }
        }

        If ((\_SB.PCI0.LPCB.EC.ELID == One))
        {
            \RMDT.P1 ("LIDS = Zero")
            LIDS = Zero
        }
        Else
        {
            \RMDT.P1 ("LIDS = One")
            LIDS = One
        }

        If (IGDS)
        {
            \RMDT.P2 ("Notify _SB.LIDD before: ", \_SB.LIDD._LID ())
            \RMDT.P2 ("Notify _SB.LIDD before ELID: ", \_SB.PCI0.LPCB.EC.ELID)
            \RMDT.P2 ("Notify _SB.LIDD before CLID: ", \_SB.PCI0.GFX0.CLID)
            Notify (\_SB.LIDD, 0x80) // Status Change
            \RMDT.P2 ("Notify _SB.LIDD after: ", \_SB.LIDD._LID ())
            \RMDT.P2 ("Notify _SB.LIDD after ELID: ", \_SB.PCI0.LPCB.EC.ELID)
            \RMDT.P2 ("Notify _SB.LIDD after CLID: ", \_SB.PCI0.GFX0.CLID)
        }

        If ((TBTS == One))
        {
            \RMDT.P1 ("Acquire (OSUM, 0xFFFF)")
            Acquire (OSUM, 0xFFFF)
            \_GPE.TINI (TBSE)
            If ((TBMP == One))
            {
                \_GPE.TINI (TBS1)
            }

            Release (OSUM)
        }

        If ((\_SB.PCI0.RP01.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP01, Zero)")
            Notify (\_SB.PCI0.RP01, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP02.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP02, Zero)")
            Notify (\_SB.PCI0.RP02, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP03.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP03, Zero)")
            Notify (\_SB.PCI0.RP03, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP04.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP04, Zero)")
            Notify (\_SB.PCI0.RP04, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP05.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP05, Zero)")
            Notify (\_SB.PCI0.RP05, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP06.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP06, Zero)")
            Notify (\_SB.PCI0.RP06, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP07.VDID != 0xFFFFFFFF))
        {
            If ((DSTS == Zero))
            {
                \RMDT.P1 (" Notify (_SB.PCI0.RP07, Zero)")
                Notify (\_SB.PCI0.RP07, Zero) // Bus Check
            }
        }

        If ((\_SB.PCI0.RP08.VDID != 0xFFFFFFFF))
        {
            If ((DSTS == Zero))
            {
                \RMDT.P1 (" Notify (_SB.PCI0.RP08, Zero)")
                Notify (\_SB.PCI0.RP08, Zero) // Bus Check
            }
        }

        If ((\_SB.PCI0.RP09.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP09, Zero)")
            Notify (\_SB.PCI0.RP09, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP10.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP10, Zero)")
            Notify (\_SB.PCI0.RP10, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP11.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP11, Zero)")
            Notify (\_SB.PCI0.RP11, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP12.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP12, Zero)")
            Notify (\_SB.PCI0.RP12, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP13.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP13, Zero)")
            Notify (\_SB.PCI0.RP13, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP14.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP14, Zero)")
            Notify (\_SB.PCI0.RP14, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP15.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP15, Zero)")
            Notify (\_SB.PCI0.RP15, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP16.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP16, Zero)")
            Notify (\_SB.PCI0.RP16, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP17.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP17, Zero)")
            Notify (\_SB.PCI0.RP17, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP18.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP18, Zero)")
            Notify (\_SB.PCI0.RP18, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP19.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP19, Zero)")
            Notify (\_SB.PCI0.RP19, Zero) // Bus Check
        }

        If ((\_SB.PCI0.RP20.VDID != 0xFFFFFFFF))
        {
            \RMDT.P1 (" Notify (_SB.PCI0.RP20, Zero)")
            Notify (\_SB.PCI0.RP20, Zero) // Bus Check
        }

        If (CondRefOf (\_SB.VMEN))
        {
            \RMDT.P1 ("_SB.VMEN = 0xFF")
            \_SB.VMEN = 0xFF
        }
    }

    If ((TBTS == One))
    {
        \RMDT.P1 ("Signal (WFEV)")
        Signal (WFEV)
    }

    Return (Package (0x02)
    {
        Zero, 
        Zero
    })
}

I tried to disable some lines or enabled some false condition codes, no effect.

Also, one thing is very strange, unlike other Hackintosh devices. When I pushed the power or volume up/down button. Both Q25 and Q26 will be called. You can see the ACPI debug log above. I can't determine which DSDT function is bind to which button. It's very wired.

@kingo132 kingo132 changed the title Built-in screen wake blackscreen and show a surface log instead Built-in screen wake blackscreen and show a surface logo instead May 6, 2021
@kingo132 kingo132 changed the title Built-in screen wake blackscreen and show a surface logo instead Built-in screen wake blackscreen with a surface logo on it May 6, 2021
@kingo132
Copy link
Owner Author

kingo132 commented May 7, 2021

If you read the article here: https://github.com/linux-surface/linux-surface/wiki/Surface-Go-2
You can find there's a word saying:

Suspend (S3 Sleep) / Modern Standby (S0iX)

Suspend (S3 Sleep) and Modern Standby (S0iX) are both available on the Surface Go 2. Suspend consumes less battery than Modern Standby, but takes slightly longer to resume from standby. Modern Standby resumes almost immediately when opening the Type Cover, whereas Suspend needs the power button to be pressed to resume from standby.

To check which standby mode is currently active on your system:

# cat /sys/power/mem_sleep

The system returns:

[s2idle] deep

The Surface Go 2 defaults to s2idle, which means Modern Standby. If you'd prefer your system to Suspend and consume less battery during standby, add mem_sleep_default=deep to your kernel parameters.

As of kernel 5.6.15, Suspend seems to be broken, with the system getting stuck at the Surface Logo on resume from standby. A possible, atm unverified fix is to add resume=pci to the kernel parameters. [Update 2021-02-05: There is no evidence that the kernel does or ever did support a "resume=pci" parameter. Not sure what this workaround was intended to be, but this definitely does not work.]

If you are seeing a significant power-draw during s2idle/Modern Standby, your S2GO may not be entering S0ix sleep state due to some PCIe devices not sleeping. (The CPU/"package" may enter the S0ix state, but the rest of the "platform" doesn't.) In my case, debugging revealed that the device held in power gating status was the Micro-SD card controller. Disabling the Micro-SD card slot in the EFI Setup allows the S2GO to properly enter full platform S0ix state and consume significantly less power during s2idle sleep, so if you don't need the Micro-SD slot, this may be an option for you rather than waiting for "deep" sleep mode to be fixed. [ref: https://01.org/blogs/qwang59/2020/linux-s0ix-troubleshooting]

Maybe this will give some clue.

@shiecldk
Copy link

@shiecldk
Copy link

Post moved from #3 (comment)

@kingo132 This is the same account as @astro-lee-k
I installed your EFI on my Surface Go 2, and it works perfectly well with sleep and wake with MacBook Air8,1 SMBios. I'm currently on macOS Catalina 10.15.7.I found out to solve the sleep and wake issue, you may have to set the resolution to 1920x1280. With that resolution I am able to get sleep and wake working. Also, to improve the battery, you may want to add NVMeFix.kext as well. (I'm not really sure if it would work as Disk Utility shows the onboard SSD is PCIe.) I'm using the FF profile (best engery saving) with CPUFriendDataProvider.kext. These are the three additional kexts I'm using. Make sure to update Lilu, WhateverGreen, VitualSMC, etc before you update. Let me know if it improves the battery life on your device.

I'm only using these BIOS settings to get sleep/wake: (Others, including Hibernation, Fast Boot, etc are all default)

Name From To
CFG Lock Enable Disable
VT-d Enable Disable
DVMT 32MB 64MB

Surface Pro 7 also have display issue when setting to some resolutions but works well in other resolution. (source: https://www.tonymacx86.com/threads/surface-pro-7-hidpi-not-working.307078/)

I assume you might be using 1280x854 resolution. If you want to keep that resolution for sleep, a workaround might be writing a script to change the resolution to 1920x1280, and then set it back when it's waked. I'm hoping to get HiDPI working with the 1280x854 resolution and assume it might solve the sleep/wake issue at this resolution. I saw tonymac and pcbeta have some info on how to get lower HiDPI resolutions. I haven't got time to do it; let me know if you can get this work. You can also try the app, SwitchResX. I'm guessing to get 1280x854 resolution work would need a WhateverGreen.kext update.

Also, the WiFi is pretty slow on my device with AirportItlwm.kext. Are you having the same issue? Have you tested the HDMI or DP through USB-C?

One cosmetic thing: You may want to change the name of Intel UHD Graphics 617 to Intel UHD Graphics 615.

Kexts to save battery.zip

@shiecldk
Copy link

shiecldk commented Aug 21, 2021

Post moved from: #3 (comment)

Update 1: I found out I still have the same issue with sleep/wake after the above implementation.

Also, the option, "Slightly dim the display while on battery power", in Battery (Big Sur) or Energy Saver (Catalina) in System Preferences is missing. However, the display seems to dim itself at the set "Display sleep" time in System Preferences.

I tried with all the possible framebuffer patches with LVDS and DP connector with two sets of pips (00001200 and 00000800) and two sets of flags (98000000 for internal screen and C7030000 for fake external screen) but in vain. The index and bus-id both have to be 0x0 in order for the internal screen to be possibly lighted on. I still see the windows logo / Microsoft logo when the screen was attempting to wake. I can confirm the system is awaked by checking with the volume control buttons with sounds play out. With the flag being C7030000 (external monitor), the internal screen will always be a black screen (no signal).

I am guessing that changing the hibernation mode in macOS might solve the problem. Also, try to check with the "DVMT Total Gfx Mem" Bios setting and set it to MAX.

One interesting find is that for the frambuffer-con0-alldata to be 00000800 00040000 C7030000, the screen would be black screen because of C7030000; however, when the tablet is put into sleep and wake, the windows logo / Microsoft logo will still appear and hang at here. Since the black screen from the flag C7030000 means there is no signal to be put onto the screen, I suspect the problem may have nothing to do with the kext (WhateverGreen.kext and macOS's Intel graphics kext). It almost likely to be cause by the hardware issues of the internal screen itself. I will check the ADIA64 report from Windows to see what connector is used by the internal monitor. (most likely would be either LVDS or eDP) However, it seems unless we find the correct way to call the internal screen (maybe through DSDT to check for _PTS and _WAK methods), it will almost likely not be fixed by the hacked kexts or bootloader. We can still ask if WhateverGreen.kext developers have any ideas how to fix this issue.

Meanwhile, I am trying to find more ways to save battery. Since shutdown and restart the tablet can consume around 3-5% of battery life, I found another kext can disable/enable TurboBoost when the power adapter is unplugged/plug to save battery.
https://osxlatitude.com/forums/topic/2263-kext-to-disable-intel-turbo-boost-on-battery-power/?do=findComment&comment=86786
DisableTurboBoostBattery.kext.zip
However, the CPU clock seems to be stuck at 1.1GHz when it's on battery.

And an app as an alternative that might help switching TurboBoost on/off which I haven't tested:
http://tbswitcher.rugarciap.com

And an app to disable sleep:
https://www.macupdate.com/app/mac/37991/nosleep

Update 2:
Found some ways to make the display sleep without making the system sleep.
https://www.iclarified.com/76166/how-to-turn-off-your-macs-display-without-putting-your-computer-to-sleep

I tried pmset displaysleepnow, and the display was able to wake successfully without the windows logo, which makes me suspect the problem is on the Intel HD 615. Maybe a WhateverGreen update can fix this problem.
Some WhateverGreen parameters can be tested in here: https://github.com/acidanthera/WhateverGreen.
Similar problem was found in XPS 15 2-in-1's Intel 8705G, which the HD 630 was not usable until WhateverGreen and Lilu update.

Waiting to submit an issue on https://github.com/acidanthera/WhateverGreen

@shiecldk
Copy link

@kingo132 How do you turn on the HiDPI?

@kingo132
Copy link
Owner Author

I can't remember very well, may be using this command:
sudo defaults write /Library/Preferences/com.apple.windowserver.plist DisplayResolutionEnabled -bool true

@shiecldk
Copy link

shiecldk commented Aug 21, 2021

Quote to #1 (comment)

Original ACPI tables obtained by Clover EFI Bootloader:
origin-SSDT_Surface Pro 7.zip

Surface Pro 7 have this _PTS method instead: (Will test if sleep and wake works on Surface Pro 7)

Method (_PTS, 1, NotSerialized)  // _PTS: Prepare To Sleep
    {
        D8XH (Zero, Arg0)
        D8XH (One, Zero)
        ADBG (Concatenate ("_PTS=", ToHexString (Arg0)))
        If ((TBTS == One))
        {
            Reset (WFEV)
        }

        If ((Arg0 == 0x03))
        {
            If (CondRefOf (\_SB.DTSE))
            {
                If ((\_SB.DTSE && (TCNT > One)))
                {
                    TRAP (0x02, 0x1E)
                }
            }

            CWEF = CPWE /* \CPWE */
        }

        If (CondRefOf (\_SB.TPM.PTS))
        {
            \_SB.TPM.PTS (Arg0)
        }

        If (TRTD)
        {
            \_SB.PCI0.TCON ()
        }

        If (ITRT)
        {
            \_SB.PCI0.TG0N ()
            \_SB.PCI0.TG1N ()
        }
    }

Original _WAK method from Surface Pro 7:

Method (_WAK, 1, Serialized)  // _WAK: Wake
    {
        D8XH (One, 0xAB)
        ADBG ("_WAK")
        ADBG ("_WAK: SRTC notify")
        Notify (\_SB.SRTC, 0x02) // Device Wake
        \_SB.PWAK (Arg0)
        If (NEXP)
        {
            If ((OSCC & One))
            {
                NHPG ()
            }

            If ((OSCC & 0x04))
            {
                NPME ()
            }
        }

        If (((Arg0 == 0x03) || (Arg0 == 0x04)))
        {
            If (CondRefOf (\_SB.DTSE))
            {
                If ((\_SB.DTSE && (TCNT > One)))
                {
                    TRAP (0x02, 0x14)
                }
            }

            If (((Arg0 == 0x03) || (Arg0 == 0x04)))
            {
                If (CondRefOf (\_SB.LID0.ULID))
                {
                    \_SB.LID0.ULID ()
                }
            }

            If ((TBTS == One))
            {
                If ((RPN0 == One))
                {
                    Acquire (OSUM, 0xFFFF)
                    \_GPE.DINI (RPS0, RPT0)
                    Release (OSUM)
                }

                If ((RPN1 == One))
                {
                    Acquire (OSUM, 0xFFFF)
                    \_GPE.DINI (RPS1, RPT1)
                    Release (OSUM)
                }
            }

            If ((\_SB.PCI0.RP01.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP01, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP02.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP02, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP03.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP03, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP04.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP04, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP05.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP05, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP06.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP06, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP07.VDID != 0xFFFFFFFF))
            {
                If ((DSTS == Zero))
                {
                    Notify (\_SB.PCI0.RP07, Zero) // Bus Check
                }
            }

            If ((\_SB.PCI0.RP08.VDID != 0xFFFFFFFF))
            {
                If ((DSTS == Zero))
                {
                    Notify (\_SB.PCI0.RP08, Zero) // Bus Check
                }
            }

            If ((\_SB.PCI0.RP09.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP09, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP10.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP10, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP11.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP11, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP12.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP12, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP13.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP13, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP14.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP14, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP15.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP15, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP16.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP16, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP17.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP17, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP18.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP18, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP19.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP19, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP20.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP20, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP21.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP21, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP22.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP22, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP23.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP23, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP24.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP24, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP21.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP21, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP22.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP22, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP23.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP23, Zero) // Bus Check
            }

            If ((\_SB.PCI0.RP24.VDID != 0xFFFFFFFF))
            {
                Notify (\_SB.PCI0.RP24, Zero) // Bus Check
            }

            \_SB.TCWK (Arg0)
        }

        If ((TBTS == One))
        {
            Signal (WFEV)
        }

        Return (Package (0x02)
        {
            Zero, 
            Zero
        })
    }

@shiecldk
Copy link

shiecldk commented Aug 21, 2021

@kingo132
Copy link
Owner Author

kingo132 commented Aug 21, 2021

Also, the WiFi is pretty slow on my device with AirportItlwm.kext. Are you having the same issue? Have you tested the HDMI or DP through USB-C?

I can get around 50 Mbps/s using wifi connection.
I tested HDMI through USB-C, the external display can be wake up without any problem, but the built-in screen remains black screen with surface logo.

Also, I just tested your implementation, still got black screen, it's the same.

@kingo132
Copy link
Owner Author

I tried pmset displaysleepnow, and the display was able to wake successfully without the windows logo, which makes me suspect the problem is on the Intel HD 615.

Yes, you can also turn off display by close the lid and wake the screen without any problem, if you disabled sleep.

When I'm using an external display through USB-C, after wake up, the built-in display will disappear or become the second monitor (the external will become the first one) in IOReg, I don't know if this is a clue. I also suspect that it is a HD615 problem.

@kingo132
Copy link
Owner Author

kingo132 commented Aug 21, 2021

And an app as an alternative that might help switching TurboBoost on/off which I haven't tested:
http://tbswitcher.rugarciap.com

I'm using VoltageShift to disable TurboBoost or adjust PL1/PL2.

And an app to disable sleep:
https://www.macupdate.com/app/mac/37991/nosleep

I disabled/enable sleep by using this command:

-> disable sleep
sudo pmset -a sleep 0; sudo pmset -a hibernatemode 0; sudo pmset -a disablesleep 1;

-> enable sleep
sudo pmset -a sleep 1; sudo pmset -a hibernatemode 0; sudo pmset -a disablesleep 0;
sudo pmset restoredefaults;

Kexts to save battery.zip

The battery life seem good using your kexts. It gets 5~6 hours of caculated battery life when idle, CPU running at around 600Mhz.

I suspect the problem may have nothing to do with the kext (WhateverGreen.kext and macOS's Intel graphics kext)

Yes, you are right. I traced the code of macOS's intel graphics kext, it has already sent the display wake-up signal to the built-in display, which is called "the wake-up pin" in DP connection.

@shiecldk
Copy link

@kingo132 Try to add these two args and remove edid in your config for Big Sur. I found out these work well on my ZenBook Pro Duo UX582.
-igfxblr -igfxmpc

@lazd
Copy link

lazd commented Apr 6, 2023

FWIW, I can hibernate and wake up from hibernate just fine, and it only takes 13-16 seconds from power off to go back to the desktop. However, when I upgraded from Big Sur to Monterey, though hibernate still works, it instantly wakes up from hibernate... I'm still investigating, but some of this is due to Bluetooth, some is due to it thinking the lid is open, and some is due to "user" activity...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants