tylernguyen/x1c6-hackintosh

Adding EDID to config.plist

velaar opened this issue · 16 comments

Please test the attached EDID. I added 65Hz in and it works well on my laptop.
ONLY for HDR screen.

<key>AAPL00,override-no-connect</key> <data>AP///////wAwrq5AAAAAAAAbAQSQHxF44vvVplM0tiUOUFQAAAABAQEBAQEBAQEBAQEBAQEB5l8AoKCgQFAwIDUAgGghAAAYj2YAoKCgLVAwIDUAgGghAAAY22cAoKCgKVAwIDUAgGghAAAYMGUAoKCgMFAwIDUAgGghAAAYADc=</data>

@velaar What method did you use to create this EDID? I want to add instructions on the repo for others to follow for their own display.

@tylernguyen It is a bit involved.

  1. Dump the EDID in Linux (I used arch linux) and dumped it from /sys/drm/...
  2. Added additional refresh rates through CRU (custom resolution utility) on Windows
  3. Ran it through this script (it picks up edid.bin from the same folder):
#!/bin/bash
# This code is based off HP ProBook 4x30s Fix EDID by pokenguyen

GenEDID() {
    /usr/libexec/PlistBuddy -c "Print :$1" /tmp/display.plist &> /dev/null || return 0

    rm -f /tmp/EDID.bin

    EDID=$(cat edid.bin | xxd -p |tr -d '\n\t\s')
    version=${EDID:38:2}
    basicparams=${EDID:40:2}
    checksum=${EDID:254:2}

    newchecksum=$(printf '%x' $((0x$checksum + 0x$version +0x$basicparams - 0x04 - 0x90)) | tail -c 2)
    newedid=${EDID:0:38}0490${EDID:42:212}${newchecksum}

    echo $newedid | xxd -r -p >> /tmp/EDID.bin

    if [ $? -eq 0 ]; then
        RegName=$(/usr/libexec/PlistBuddy -c "Print :$1:IORegistryEntryName" /tmp/display.plist)
        DisplayFlags=$(/usr/libexec/PlistBuddy -c "Print :$1:IODisplayConnectFlags" /tmp/display.plist)
        VenID=$(/usr/libexec/PlistBuddy -c "Print :$1:DisplayVendorID" /tmp/display.plist)
        VenIDhex=$(printf '%x\n' $VenID)
        ProdID=$(/usr/libexec/PlistBuddy -c "Print :$1:DisplayProductID" /tmp/display.plist)
        ProdIDhex=$(printf '%x\n' $ProdID)
        GenPlist=~/"Desktop/${VenIDhex}_${ProdIDhex}.plist"
        GenBin=~/"Desktop/${VenIDhex}_${ProdIDhex}.bin"

        rm -f "$GenPlist" "$GenBin"

        # This check does not really detect external displays
        if [ "$RegName" == "AppleBacklightDisplay" -o "$DisplayFlags" == "$(echo AAgAAA== | /usr/bin/base64 -D)" ] ||
           [ "$RegName" == "AppleDisplay" -o "$DisplayFlags" == "$(echo AAgAAA== | /usr/bin/base64 -D)" ]; then

            /usr/libexec/PlistBuddy -c "Add :DisplayProductName string 'Display'" "$GenPlist"
            /usr/libexec/PlistBuddy -c "Add :test array" "$GenPlist"
            /usr/libexec/PlistBuddy -c "Merge /tmp/display.plist :test" "$GenPlist"
            /usr/libexec/PlistBuddy -c "Copy :test:$1:DisplayProductID :DisplayProductID" "$GenPlist"
            /usr/libexec/PlistBuddy -c "Copy :test:$1:DisplayVendorID :DisplayVendorID" "$GenPlist"

            /usr/libexec/PlistBuddy -c "Remove :test" "$GenPlist"
            /usr/libexec/PlistBuddy -c "Import :IODisplayEDID /tmp/EDID.bin" "$GenPlist"

            mv /tmp/EDID.bin "$GenBin"

            echo "Display $1"
            echo "  vendor id  ${VenIDhex}"
            echo "  product id ${ProdIDhex}"
            echo "EDID:"
            xxd -i "$GenBin" | grep -vE 'unsigned|}'

            echo "If you cannot inject this EDID via SSDT (AAPL00,override-no-connect), save $GenPlist as:"
            echo "/System/Library/Displays/Contents/Resources/Overrides/DisplayVendorID-${VenIDhex}/DisplayProductID-${ProdIDhex}.plist"
        else
            echo "External display detected (${VenIDhex}_${ProdIDhex}}!"
        fi
    else
        echo "No display detected!"
    fi
}

rm -f /tmp/display.plist

case $(ioreg -n AppleBacklightDisplay -rxw0) in
    "")
        ioreg -n AppleDisplay -arxw0 > /tmp/display.plist
        ;;
    *)
        ioreg -n AppleBacklightDisplay -arxw0 > /tmp/display.plist
        ;;
esac

GenEDID 0 && GenEDID 1 && GenEDID 2
rm -f /tmp/display.plist /tmp/EDID.bin
  1. Added the <data> from the generated plist to config.plist

@velaar It's also working on my machine. That's great, it seems all HDR screens on the x1c6 may be the same after all.

Furthermore, you fixed my other headache, the damn framebuffer patching. It seems that an EDID override will fix an issue where HDMI hotplug will result in an internal black screen. Thanks so much for contributing again @velaar . I will update the repo soon with a Internal Display folder within patches where all these config will be stored and can also serve as a place for pull requests for other display models.

@tylernguyen
Always welcome! We are all working on it together. Hopefully one day we will beat the last big boss - Thunderbolt (BTW, there was a recent update from Lenovo with NVM45)

Did you try the overclocked refresh rates? My display works 100% only up to 64Hz. 65Hz there are refresh artifacts and 66Hz the picture is garbage.

But even at 64Hz that is almost 7% refresh rate increase. Not much, but feels great to have the machine a little tiny bit different :)

@velaar My experience is the same as yours. 66Hz and the display will go crazy. 65Hz will have artifacts. Would you like to remove those two from the EDID and leave 64Hz since it's the only one that seems to be stable? If that's too much trouble, I'm fine with adding the current EDID override to the repo and leaving a note.

@tylernguyen
Here you are:

	<data>
	AP///////wAwrq5AAAAAAAAbAQSQHxF44vvVplM0tiUOUFQAAAABAQEBAQEBAQEBAQEB
	AQEB5l8AoKCgQFAwIDUAgGghAAAY+2QAoKCgLVAwIDUAgGghAAAYI2MAoKCgKVAwIDUA
	gGghAAAYBmIAoKCgMFAwIDUAgGghAAAYALY=
	</data>

UNTESTED though, but should work.

You might also keep 66Hz for adventurous people who might have a display from a different batch.

@velaar Noted. I will just update the repo with the original patch and leave a note then. If you don't mind, it would be great if you could leave more details on the first two steps (dumping the EDID and patching refresh rate in Windows). I want it to be as easy as possible for others to follow this issue and create pull requests for other display models.

*Note for future display patches: correct EDID profile should fix the following problems:

  1. Internal display will not go black upon HDMI hotplug.
    2. With FileVault enabled, on the 2nd login phase, everything should be displayed as normal. Whereas WITHOUT an EDID override, the second login phase will only show the progress bar and the rest of the screen will be black.

@velaar Noted. I will just update the repo with the original patch and leave a note then. If you don't mind, it would be great if you could leave more details on the first two steps (dumping the EDID and patching refresh rate in Windows).

@tylernguyen will do. But no time today unfortunately.

  1. With FileVault enabled, on the 2nd login phase, everything should be displayed as normal. Whereas WITHOUT an EDID override, the second login phase will only show the progress bar and the rest of the screen will be black.

It worked only the first time this way. Maybe because of the one-key-hidpi but starting with the run 2 I again get the black screen. Can you please confirm that it is consistent for you?

@velaar You're right. The FileVault issue will reappear after a few reboots. I've edited my comment above.

Implemented as of commit 622cf9d
When you get the chance, please update this issue with your instructions.
Thanks again so much for your contribution @velaar

For the FHD display the EDID is the following:

AP///////wAJ5d8GAAAAAAEaAQSQHxF4AoYxo1ROmyUOUFQAAAABAQEBAQEBAQEBAQEB
AQEBPDeA3nA4FEA8IDYANa0QAAAaMCyA3nA4FEAwIDYANa0QAAAaAAAA/gBCT0UgQ1EK
ICAgICAgAAAA/gBIVjE0MEZITS1ONjEKAF4=

Works fine on my computer for HDMI hotplug. I can't say anything about FileVault because I haven't enabled it yet.

For the FHD display the EDID is the following:

AP///////wAJ5d8GAAAAAAEaAQSQHxF4AoYxo1ROmyUOUFQAAAABAQEBAQEBAQEBAQEB
AQEBPDeA3nA4FEA8IDYANa0QAAAaMCyA3nA4FEAwIDYANa0QAAAaAAAA/gBCT0UgQ1EK
ICAgICAgAAAA/gBIVjE0MEZITS1ONjEKAF4=

Works fine on my computer for HDMI hotplug. I can't say anything about FileVault because I haven't enabled it yet.

Thanks @Paolo97Gll I'll add it to the repo on the next commit. I think that the only EDID missing is the one for the regular non-HDR 1440p screen.

@tylernguyen @velaar after enabling FileVault, I also confirm the bug you reported.

@velaar 's EDID with 60,62,63,64 Hz options works for me on macOS 11.2.2 with xzhih/one-key-hidpi option 1 Enable HIDPI without patch.

Before that, I had some strange issue with the repo's EDID that includes the 66 Hz option where I could choose any of the refresh rates except when I was on the "Default" scaling, which was stuck at 66 Hz with the drop-down disabled. Since 66 Hz caused screen tearing and artifacts, I couldn't use default scaling, until I used @velaar 's EDID. That removed 66 Hz as an option, and also for some reason the refresh rate drop-down also became enabled ¯_(ツ)_/¯ Anyway thanks!

@adwiens

Not sure why you had that problem... The repo's 4k edid and @velaar 's are identical.

@tylernguyen I'm talking about his 64 Hz one, the last one he shared in this thread. This one:

<data>
	AP///////wAwrq5AAAAAAAAbAQSQHxF44vvVplM0tiUOUFQAAAABAQEBAQEBAQEBAQEB
	AQEB5l8AoKCgQFAwIDUAgGghAAAY+2QAoKCgLVAwIDUAgGghAAAYI2MAoKCgKVAwIDUA
	gGghAAAYBmIAoKCgMFAwIDUAgGghAAAYALY=
</data>