Skip to content

Commit

Permalink
force builder to specifiy GPU vendor
Browse files Browse the repository at this point in the history
there is no single default for the I2C wait time
that will not crash any Macintoshes.

patches welcome for runtime GPU detection! (#57)

relates to #1 #18 #35 #42 #57
  • Loading branch information
kfix committed Nov 28, 2019
1 parent 5d4b943 commit 0fe2ef4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
6 changes: 5 additions & 1 deletion DDC.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
#!/bin/make -f

CCFLAGS ?=
CCFLAGS ?= -Wno-unused-variable

## Reply Transaction Type
## uncomment one only one
## comment both to use automatic detection
#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
Expand All @@ -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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----
Expand Down

0 comments on commit 0fe2ef4

Please sign in to comment.