I need to get Graphics card information in my application. The information I need is the same as displayed by *system_profiler SPDisplays* command under the section Graphics/Displays:. I have already considered using sysctl(), but I am unable to find proper hardware selector for graphics card in sysctl.h
Any suggestions highly appericiated.
On a GNOME desktop, open the “Settings” dialog, and then click “Details” in the sidebar. In the “About” panel, look for a “Graphics” entry. This tells you what kind of graphics card is in the computer, or, more specifically, the graphics card that's currently in use. Your machine might have more than one GPU.
The command glxinfo will give you all available OpenGL information for the graphics processor, including its vendor name, if the drivers are correctly installed. To get clock speed information, there is no standard tool.
The GPU. Like a motherboard, a graphics card is a printed circuit board that houses a processor and VRAM. It also has an input/output system (BIOS) chip that stores the card's settings and performs diagnostics on the memory, input and output at startup.
After fiddling with IOKit I have managed to fetch the required information. The code can be seen here (original source)and below:
- (void)displayGraphicsInfo
{
// Get dictionary of all the PCI Devicces
CFMutableDictionaryRef matchDict = IOServiceMatching("IOPCIDevice");
// Create an iterator
io_iterator_t iterator;
if (IOServiceGetMatchingServices(kIOMasterPortDefault,matchDict,
&iterator) == kIOReturnSuccess)
{
// Iterator for devices found
io_registry_entry_t regEntry;
while ((regEntry = IOIteratorNext(iterator))) {
// Put this services object into a dictionary object.
CFMutableDictionaryRef serviceDictionary;
if (IORegistryEntryCreateCFProperties(regEntry,
&serviceDictionary,
kCFAllocatorDefault,
kNilOptions) != kIOReturnSuccess)
{
// Service dictionary creation failed.
IOObjectRelease(regEntry);
continue;
}
const void *GPUModel = CFDictionaryGetValue(serviceDictionary, @"model");
if (GPUModel != nil) {
if (CFGetTypeID(GPUModel) == CFDataGetTypeID()) {
// Create a string from the CFDataRef.
NSString *modelName = [[NSString alloc] initWithData:
(NSData *)GPUModel encoding:NSASCIIStringEncoding];
NSLog(@"GPU Model: %@", modelName);
[modelName release];
}
}
// Release the dictionary
CFRelease(serviceDictionary);
// Release the serviceObject
IOObjectRelease(regEntry);
}
// Release the iterator
IOObjectRelease(iterator);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With