I need to know when 2 displays are attached to the same video card or two different video cards.
Using "ioreg -S -w 0 -c NVDA", I see that my nVidia cards have an IOAccelTypes string which seems to correspond to the physical card.
I am wondering if this field is present for all driver (for example, does ATi cards presents this info) ?
If the string for 2 display is the same we could assume that they are on the same card ?
Thanks in advance.
David.
CGDirectDisplayID *displays = NULL;
io_service_t *dspPorts = NULL;
CGDisplayCount count = 0;
CGDisplayErr err;
CFTypeRef typeCode;
err = CGGetOnlineDisplayList (0, NULL, &count);
displays = (CGDirectDisplayID*)calloc(count, sizeof(CGDirectDisplayID));
dspPorts = (io_service_t*)calloc(count, sizeof(io_service_t));
err = CGGetOnlineDisplayList (count, displays, &count);
for (int i = 0; i < count; i++)
{
cout << "Display " << i << endl;
dspPorts[i] = CGDisplayIOServicePort(displays[i]);
// Get PCI card used
typeCode = IORegistryEntryCreateCFProperty(dspPorts[i],
CFSTR("IOAccelTypes"),
kCFAllocatorDefault,
kNilOptions);
// Ensure we have valid data from IOKit
if(typeCode && CFGetTypeID(typeCode) == CFStringGetTypeID())
{
// If so, convert the CFString to a cstring
const char *val = CFStringGetCStringPtr((CFStringRef)typeCode, kCFStringEncodingMacRoman);
cout << "AccelType : " << val << endl;
}
if(typeCode)
CFRelease(typeCode);
}
free(displays);
free(dspPorts);