Search code examples
linuxmacosreverse-engineering

Reverse engineering the "Target Display Mode" on an iMac


I have a computer lab with a couple of old-ish iMacs (around 2011). Most people now just want to use them as displays for their laptops, and with Target Display Mode in MacOS, this (mostly) works fine.

However, I'd also like to support this under Linux, which is installed on all the iMacs in parallel to MacOS. I'm fairly experienced with the Linux kernel (I already wrote kernel drivers), but I have basically no idea about MacOS - therefore, I'm looking for pointers regarding how to figure out how TDM is actually triggered (i.e. what happens after Cmd-F2 is pressed).

I'm guessing this mostly involves writing some Intel GPU registers, but I have no idea which bit of MacOS is actually responsible for that. Any hints?


Solution

  • So I figured it out on my own after all. After looking at libsmc, SMCKit, smc_util and the applesmc driver, I found that writing 0x02 to SMC key "MVMR" will cause the display to switch to DisplayPort input.

    For details, see my short blog post: https://floe.butterbrot.org/matrix/hacking/tdm/

    Tools are on Github: https://github.com/floe/smc_util