Skip to content

Commit

Permalink
Get IOPCIDevice of parent in getIORegAudioDeviceArray
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaker76 committed Mar 17, 2020
1 parent 9040913 commit 6c3159f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 47 deletions.
8 changes: 4 additions & 4 deletions PinConfigurator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,15 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0225;
CURRENT_PROJECT_VERSION = 0226;
ENABLE_STRICT_OBJC_MSGSEND = NO;
INFOPLIST_FILE = PinConfigurator/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 2.2.5;
MARKETING_VERSION = 2.2.6;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.PinConfigurator;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -388,15 +388,15 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0225;
CURRENT_PROJECT_VERSION = 0226;
ENABLE_STRICT_OBJC_MSGSEND = NO;
INFOPLIST_FILE = PinConfigurator/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 2.2.5;
MARKETING_VERSION = 2.2.6;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.PinConfigurator;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
Binary file not shown.
93 changes: 50 additions & 43 deletions PinConfigurator/IORegTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,65 +157,72 @@ bool getIORegAudioDeviceArray(NSMutableArray **audioDeviceArray)
}
}

CFMutableDictionaryRef pciDevicePropertyDictionaryRef = 0;

kr = IORegistryEntryCreateCFProperties(pciDevice, &pciDevicePropertyDictionaryRef, kCFAllocatorDefault, kNilOptions);

if (kr == KERN_SUCCESS)
{
NSMutableDictionary *pciDevicePropertyDictionary = (__bridge NSMutableDictionary *)pciDevicePropertyDictionaryRef;
io_service_t parentDevice;

uint32_t deviceID = propertyToUInt32([pciDevicePropertyDictionary objectForKey:@"device-id"]);
uint32_t vendorID = propertyToUInt32([pciDevicePropertyDictionary objectForKey:@"vendor-id"]);
uint32_t revisionID = propertyToUInt32([pciDevicePropertyDictionary objectForKey:@"revision-id"]);
uint32_t alcLayoutID = propertyToUInt32([pciDevicePropertyDictionary objectForKey:@"alc-layout-id"]);
uint32_t subSystemID = propertyToUInt32([pciDevicePropertyDictionary objectForKey:@"subsystem-id"]);
uint32_t subSystemVendorID = propertyToUInt32([pciDevicePropertyDictionary objectForKey:@"subsystem-vendor-id"]);
if (getIORegParent(device, @"IOPCIDevice", &parentDevice, true))
{
CFMutableDictionaryRef parentPropertyDictionaryRef = 0;

uint32_t deviceIDNew = (vendorID << 16) | deviceID;
uint32_t subDeviceIDNew = (subSystemVendorID << 16) | subSystemID;
kr = IORegistryEntryCreateCFProperties(parentDevice, &parentPropertyDictionaryRef, kCFAllocatorDefault, kNilOptions);

AudioDevice *audioDevice = [[AudioDevice alloc] initWithDeviceBundleID:bundleID deviceClass:[NSString stringWithUTF8String:className] audioDeviceName:audioDeviceName audioDeviceManufacturerName:audioDeviceManufacturerName audioDeviceModelID:audioDeviceDeviceIDNew deviceID:deviceIDNew revisionID:revisionID alcLayoutID:alcLayoutID subDeviceID:subDeviceIDNew];

io_service_t codecDevice;

if (getIORegParent(device, @"IOHDACodecDevice", &codecDevice, true))
if (kr == KERN_SUCCESS)
{
CFMutableDictionaryRef codecPropertyDictionaryRef = 0;
NSMutableDictionary *parentPropertyDictionary = (__bridge NSMutableDictionary *)parentPropertyDictionaryRef;

uint32_t deviceID = propertyToUInt32([parentPropertyDictionary objectForKey:@"device-id"]);
uint32_t vendorID = propertyToUInt32([parentPropertyDictionary objectForKey:@"vendor-id"]);
uint32_t revisionID = propertyToUInt32([parentPropertyDictionary objectForKey:@"revision-id"]);
uint32_t alcLayoutID = propertyToUInt32([parentPropertyDictionary objectForKey:@"alc-layout-id"]);
uint32_t subSystemID = propertyToUInt32([parentPropertyDictionary objectForKey:@"subsystem-id"]);
uint32_t subSystemVendorID = propertyToUInt32([parentPropertyDictionary objectForKey:@"subsystem-vendor-id"]);

kr = IORegistryEntryCreateCFProperties(codecDevice, &codecPropertyDictionaryRef, kCFAllocatorDefault, kNilOptions);
uint32_t deviceIDNew = (vendorID << 16) | deviceID;
uint32_t subDeviceIDNew = (subSystemVendorID << 16) | subSystemID;

AudioDevice *audioDevice = [[AudioDevice alloc] initWithDeviceBundleID:bundleID deviceClass:[NSString stringWithUTF8String:className] audioDeviceName:audioDeviceName audioDeviceManufacturerName:audioDeviceManufacturerName audioDeviceModelID:audioDeviceDeviceIDNew deviceID:deviceIDNew revisionID:revisionID alcLayoutID:alcLayoutID subDeviceID:subDeviceIDNew];

io_service_t codecDevice;

if (kr == KERN_SUCCESS)
if (getIORegParent(device, @"IOHDACodecDevice", &codecDevice, true))
{
NSMutableDictionary *codecPropertyDictionary = (__bridge NSMutableDictionary *)codecPropertyDictionaryRef;
CFMutableDictionaryRef codecPropertyDictionaryRef = 0;

audioDevice.digitalAudioCapabilities = [codecPropertyDictionary objectForKey:@"DigitalAudioCapabilities"];
audioDevice.codecAddress = propertyToUInt32([codecPropertyDictionary objectForKey:@"IOHDACodecAddress"]);
audioDevice.codecID = propertyToUInt32([codecPropertyDictionary objectForKey:@"IOHDACodecVendorID"]);
audioDevice.revisionID = propertyToUInt32([codecPropertyDictionary objectForKey:@"IOHDACodecRevisionID"]);
kr = IORegistryEntryCreateCFProperties(codecDevice, &codecPropertyDictionaryRef, kCFAllocatorDefault, kNilOptions);

if (kr == KERN_SUCCESS)
{
NSMutableDictionary *codecPropertyDictionary = (__bridge NSMutableDictionary *)codecPropertyDictionaryRef;

audioDevice.digitalAudioCapabilities = [codecPropertyDictionary objectForKey:@"DigitalAudioCapabilities"];
audioDevice.codecAddress = propertyToUInt32([codecPropertyDictionary objectForKey:@"IOHDACodecAddress"]);
audioDevice.codecID = propertyToUInt32([codecPropertyDictionary objectForKey:@"IOHDACodecVendorID"]);
audioDevice.revisionID = propertyToUInt32([codecPropertyDictionary objectForKey:@"IOHDACodecRevisionID"]);
}
}
}

if (getIORegParent(device, @"AppleHDACodec", &codecDevice, true))
{
CFMutableDictionaryRef codecPropertyDictionaryRef = 0;

kr = IORegistryEntryCreateCFProperties(codecDevice, &codecPropertyDictionaryRef, kCFAllocatorDefault, kNilOptions);

if (kr == KERN_SUCCESS)
if (getIORegParent(device, @"AppleHDACodec", &codecDevice, true))
{
NSMutableDictionary *codecPropertyDictionary = (__bridge NSMutableDictionary *)codecPropertyDictionaryRef;
CFMutableDictionaryRef codecPropertyDictionaryRef = 0;

NSArray *hdaConfigDefaultArray = [codecPropertyDictionary objectForKey:@"HDAConfigDefault"];
kr = IORegistryEntryCreateCFProperties(codecDevice, &codecPropertyDictionaryRef, kCFAllocatorDefault, kNilOptions);

if (hdaConfigDefaultArray != nil && [hdaConfigDefaultArray count] > 0)
audioDevice.hdaConfigDefaultDictionary = [hdaConfigDefaultArray objectAtIndex:0];
if (kr == KERN_SUCCESS)
{
NSMutableDictionary *codecPropertyDictionary = (__bridge NSMutableDictionary *)codecPropertyDictionaryRef;

NSArray *hdaConfigDefaultArray = [codecPropertyDictionary objectForKey:@"HDAConfigDefault"];

if (hdaConfigDefaultArray != nil && [hdaConfigDefaultArray count] > 0)
audioDevice.hdaConfigDefaultDictionary = [hdaConfigDefaultArray objectAtIndex:0];
}
}

[*audioDeviceArray addObject:audioDevice];

[audioDevice release];
}

[*audioDeviceArray addObject:audioDevice];

[audioDevice release];
IOObjectRelease(parentDevice);
}
}
}
Expand Down

0 comments on commit 6c3159f

Please sign in to comment.