diff --git a/DDC.c b/DDC.c index 2153dd2..27e0f84 100644 --- a/DDC.c +++ b/DDC.c @@ -210,7 +210,11 @@ bool DDCRead(CGDirectDisplayID displayID, struct DDCReadCommand *read) { request.sendBytes = 5; // Certain displays / graphics cards require a long-enough delay to give a response. // Relying on retry will not help if the delay is too short. - request.minReplyDelay = 30 * kMillisecondScale; // too short can freeze kernel + request.minReplyDelay = kDDCMinReplyDelay * kNanosecondScale; + // FIXME: this should be tuneable at runtime + // https://github.com/kfix/-vendorddcctl/issues/57 + // incorrect values for GPU-vendor can cause kernel panic + // https://developer.apple.com/documentation/iokit/ioi2crequest/1410394-minreplydelay?language=objc data[0] = 0x51; data[1] = 0x82; diff --git a/Makefile b/Makefile index 6cf9f87..9c82e4b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ #!/bin/make -f -CCFLAGS ?= +CCFLAGS ?= -Wno-unused-variable ## Reply Transaction Type ## uncomment one only one @@ -8,19 +8,26 @@ CCFLAGS ?= #CCFLAGS += -DTT_DDC #CCFLAGS += -DTT_SIMPLE -## Uncomment to use an external app 'OSDisplay' to have a BezelUI like OSD +## Uncomment to use an external app 'OSDisplay' to have a BezelUI-like OSD +## provided by https://github.com/zulu-entertainment/OSDisplay #CCFLAGS += -DOSD all: clean ddcctl +intel nvidia: CCFLAGS += -DkDDCMinReplyDelay=1 +intel nvidia: all + +amd: CCFLAGS += -DkDDCMinReplyDelay=30000000 +amd: all + debug: CCFLAGS += -DDEBUG debug: clean ddcctl %.o: %.c - $(CC) $(CCFLAGS) -Wall -c -o $@ $< + $(CC) -Wall $(CCFLAGS) -c -o $@ $< ddcctl: DDC.o - $(CC) $(CCFLAGS) -Wall -o $@ -lobjc -framework IOKit -framework AppKit -framework Foundation $< $@.m + $(CC) -Wall $(CCFLAGS) -o $@ -lobjc -framework IOKit -framework AppKit -framework Foundation $< $@.m install: ddcctl install ddcctl /usr/local/bin @@ -34,4 +41,4 @@ framebuffers: displaylist: ioreg -c IODisplayConnect -b -f -r -l -i -d 2 -.PHONY: all clean install displaylist +.PHONY: all clean install displaylist amd intel nvidia diff --git a/README.md b/README.md index 9d54bc9..19cae39 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ And *possibly* (if your monitor firmware is well implemented): Install ---- -```bash -make install -``` +* install Xcode +* figure out if your Mac is using an Intel, Nvidia or AMD gpu +* run `make intel` or make `make nvidia` or `make amd` Usage ----