Skip to content

Instantly share code, notes, and snippets.

@mrbuk
Last active October 8, 2017 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrbuk/4af9fe3e5f797339f3df4e95fdc44d23 to your computer and use it in GitHub Desktop.
Save mrbuk/4af9fe3e5f797339f3df4e95fdc44d23 to your computer and use it in GitHub Desktop.
LG31MU97 MacOS 50Hz patched EDID
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DisplayPixelDimensions</key>
<data>
AAAQAAAACHA=
</data>
<key>DisplayProductID</key>
<integer>30439</integer>
<key>DisplayProductName</key>
<string>31MU97</string>
<key>DisplayVendorID</key>
<integer>7789</integer>
<key>IODisplayEDID</key>
<data>
AP///////wAebed2AQEBAQEYAQSlRiV4mB3xrk81syUNUFQhCABxQIGAgcCpwNHAAQEB
AQEBUNAAoPBwPoAIkGUMjW8hAAAaKGgAoPBwPoAIkGUMjW8hAAAaAAAAEAAAAAAAAAAA
AAAAAAAAAAAA/AAzMU1VOTcKICAgICAgAv0CAxHwRBAEAwEjCQcHgwEAAAI6gBhxOC1A
WCxFALhvIQAAHgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
x3AReQMAAwAUtLgAh/8PnwA7AFcAbwg9AC8ABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAECQ
</data>
<key>SwitchResX backuped settings</key>
<dict>
<key>DisplayProductID</key>
<integer>30439</integer>
<key>DisplayVendorID</key>
<integer>7789</integer>
<key>IODisplayEDID</key>
<data>
AP///////wAebed2AQEBAQEYAQSlRiV4mB3xrk81syUNUFQhCABxQIGAgcCp
wNHAAQEBAQEBUNAAoPBwPoAIkGUMjW8hAAAaKGgAoPBwPoAIkGUMjW8hAAAa
AAAAEAAAAAAAAAAAAAAAAAAAAAAA/AAzMU1VOTcKICAgICAgAv0CAxHwRBAE
AwEjCQcHgwEAAAI6gBhxOC1AWCxFALhvIQAAHgAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAx3AReQMAAwAoeNkAh/8P
TwAHAB8Abwg9AC8ABwC0uACH/w+fADsAVwBvCD0ALwAHAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAOeQ
</data>
</dict>
<key>default-resolution</key>
<data>
AAAQAAAACHAAMgAA
</data>
<key>trng</key>
<data>
gGhGAEBgAABoAHIAAAAAAPcfMwMBAAAAeAAAAAAAAAB/BUgAAAAAAABGwyMAAAAAQJJI
AEBgAABAyZPs/n8AAAoAAAAyAAAAECcAACChBwAwxTQDAQAAAAEAAAAAAAAA+MmT7P5/
AAD3HzMDAQAAAIBoRgBAYAAAAMMfAEBgAAA3ADQANgA4AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAcB2TV/HGXkIAAAAAAAAAAAAAAAAAAAAA
</data>
</dict>
</plist>
package main
import (
"bufio"
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
)
func check(e error) {
if e != nil {
panic(e)
}
}
const recordLength = 128
func main() {
var inputPath, outputPath string
flag.StringVar(&inputPath, "in", "", "input file, default STDIN")
flag.StringVar(&outputPath, "out", "", "output file, default STDOUT")
flag.Parse()
// read from STDIN if no input file was provided
input := os.Stdin
if inputPath != "" {
f, err := os.Open(inputPath)
check(err)
input = f
}
reader := bufio.NewReader(input)
// write to STDOUT if no output file was provided
output := os.Stdout
if outputPath != "" {
f, err := os.Create(outputPath)
check(err)
output = f
}
writer := bufio.NewWriter(output)
defer writer.Flush()
orginal, err := ioutil.ReadAll(reader)
check(err)
// ensure that we have a least three records
sz := len(orginal)
fmt.Printf("Byte length: %d\n", sz)
if sz < 3*recordLength {
log.Fatalf("Data smaller (%d) than expected (%d).\n", sz, 3*recordLength)
}
data := []byte{}
// create an index for easy access
//
// we want to skip two records as we know the last
// record is the one we are interested in
thirdRecordIndex := 2 * recordLength
x := thirdRecordIndex
for i := range orginal {
switch {
// everything between 0 - 5 is meta data that we don't
// really need to touch. Its start getting intersting with index 7
//
// each Timing Descriptor Block is 20 bytes long
// record[7] indicates how many Timing Descriptor Blocks
// 20 => 1 block, 40 => 2 blocks, 60 => 3 blocks etc.
//
// as we want to reduce that no. of blocks from 2 to 1 we
// need to set this one to 20, so it indicates only 1 block exists
case i == x+7:
data = append(data, 20)
// map 2nd record to place of 1st
// 1st record = record[8] - record[27]
// 2nd record = record[28] - record[47]
case i >= x+8 && i <= x+27:
data = append(data, orginal[i+20])
// zero the 2nd Timing Descriptor Block
// as that one was moved to the first one
case i >= x+28 && i <= x+47:
data = append(data, 0x00)
// add newly calculated checksum
case i == x+126:
// data = append(data, 0x40)
checksum, err := calculateChecksumForRecord(x, data)
if err != nil {
log.Fatalln(err)
}
data = append(data, checksum)
default:
data = append(data, orginal[i])
}
}
writer.Write(data)
// ioutil.WriteFile(fixedFilepath, data, 0644)
}
func calculateChecksumForRecord(recordIndex int, data []byte) (byte, error) {
if len(data)-recordIndex < 126 {
return byte(0), errors.New("Can't calculate checksum for record smaller than 127 bytes")
}
// exclude the DisplayID magic byte from checksum
var sum byte
for i := recordIndex + 1; i < len(data); i++ {
sum = sum + data[i]
}
checksum := -sum & 0xff
fmt.Println("Cheksum: ", checksum)
return byte(checksum), nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment