IOServiceGetMatchingServices returning empty iterator

The following code sequence works on Catalina and on Intel Big Sur devices, it does not work on the new Apple M1 devices running Big Sur.

Code Block    
CFMutableDictionaryRef matching = IOServiceMatching("IODisplayConnect");
io_iterator_t iter = 99;
kern_return_t err = IOServiceGetMatchingServices( kIOMasterPortDefault, matching, &iter );

The "matching" variable seems valid:

Code Block
matching CFMutableDictionaryRef 1 key/value pair
[0] "IOProviderClass" : "IODisplayConnect"
key NSCFConstantString * "IOProviderClass"
value NSCFString * "IODisplayConnect"

The call to "IOServiceGetMatchingServices" sets the "iter" value to 0.

If I use another class name in the "IOServiceMatching" call, say "IOMediaBSDClient", "IOServiceGetMatchingServices" returns a valid iterator.

Would Big Sur on Apple M1 devices need additional calls, or has this service class been deprecated?

Using "IODisplayConnect" allows me to get display information via "IODisplayCreateInfoDictionary".

Suggestions...




  • Same issue faced, Then tried an alternative method to read serial number using shell command. But same result empty for serial number. Fetching all other details of monitor but empty for ""spdisplays_display-serial-number"" key.

Add a Comment

Replies

I am now going to answer my own question:

According to Apple Developer Support, IODisplayConnect is no longer supported on Apple M1 systems.

In order for me to get to the display information I had to look for IODPDevice to iterate on. Then get properties from the child service of the IODPDevice.

Be aware that the IODPDevice service does not contain the same data that IODisplayConnect did.
Thanks for posting this follow-up! Might you be willing to expand a bit on what you heard from Apple and whether/how you got it working? I've tried starting with IOServiceMatching("IODPDevice"), but I still get a null iterator—and there's nothing like IODPDevice in ioreg's output.

Otherwise, the only option I've found for getting any EDID info on an M1 appears to be to use CoreDisplay, but I'd rather use something documented.

EDID info on an M1

There is no supported way to get EDID info on Apple silicon Macs )-: Clearly this is a serious limitation but I don’t have any info to share as to when it’ll be fixed (r. 66708357).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Just like @Jatravartid, I've tried IOServiceMatching("IODPDevice") but getting an empty iterator, so any additional clue that would lead us the right direction would be much welcomed, thank you! 🙏 😊
@alanfromtewksbury 
Hello! Would you agree to share what you found about IODPDevice? Don't have M1 to test, so it would help a lot. My app is using IODisplayCreateInfoDictionary from IODisplayConnect, but if I iterate to IODPDevice, what's the structure I will found? Thanks
How does it work? in my M1 laptop


CFMutableDictionaryRef matching = IOServiceMatching("IODPDevice");
ioiteratort iter = 99;
 kernreturnt err = IOServiceGetMatchingServices( kIOMasterPortDefault, matching, &iter ); //You got back empty iterator here

  ioservicet serv;
  serv = IOIteratorNext( iter );

BTW, you can get some display information from NSScreen, but not EDID.

A slightly different topic, but I hope this may be helpful to others in the future.

I had a similar issue, but I was looking for IODisplayConnect for the purposes of reading the display brightness.

On a M1 Mac with Big Sur, I found the easiest way to get the brightness info is by running corebrightnessdiag (this can also read keyboard backlight brightness):

Code Block
$ /usr/libexec/corebrightnessdiag status-info | grep 'DisplayServicesBrightness '
DisplayServicesBrightness = "0.9302966";


To get and set brightness from code, you can use private APIs from the DisplayServices framework (/System/Library/PrivateFrameworks/DisplayServices.framework):
Code Block
extern int DisplayServicesGetBrightness(int display, float *brightness);
extern int DisplayServicesSetBrightness(int display, float brightness);
/* Change brightness */
float brightness = 0.8;
int err = DisplayServicesSetBrightness(1, brightness);
/* Get current brightness */
err = DisplayServicesGetBrightness(1, &brightness);

  • Is there a way to set brightness via iPad OS?

Add a Comment

i have contacted apple developer support and here is the reply i received from them

Thank you for contacting Apple Developer Technical Support (DTS). We have reviewed your request and have concluded that there is no supported way to achieve the desired functionality given the currently shipping system configurations.

If you would like for Apple to consider adding support for such features, please submit your suggestion request via Feedback Assistant (https://feedbackassistant.apple.com). For more information on Feedback Assistant, please visit https://developer.apple.com/bug-reporting/.

Is there a way to set brightness via iPad OS?

No.

Note that there’s no supported way to set the display brightness on macOS either. The techniques being discussed here are definitely not supported.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"