Skip to content

Commit

Permalink
Add support for HdaCodecDump.efi dumper
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaker76 committed Mar 5, 2020
1 parent c7c662b commit 08f4a26
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 78 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 = 0222;
CURRENT_PROJECT_VERSION = 0223;
ENABLE_STRICT_OBJC_MSGSEND = NO;
INFOPLIST_FILE = PinConfigurator/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.8;
MARKETING_VERSION = 2.2.2;
MARKETING_VERSION = 2.2.3;
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 = 0222;
CURRENT_PROJECT_VERSION = 0223;
ENABLE_STRICT_OBJC_MSGSEND = NO;
INFOPLIST_FILE = PinConfigurator/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.8;
MARKETING_VERSION = 2.2.2;
MARKETING_VERSION = 2.2.3;
PRODUCT_BUNDLE_IDENTIFIER = com.Headsoft.PinConfigurator;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,12 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
uuid = "B9F6F4D1-54E5-40BD-B629-982975712DE5"
uuid = "9A3B0018-C80D-4C2B-9387-604481E44A9A"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
stopOnStyle = "0">
<Actions>
<BreakpointActionProxy
ActionExtensionID = "Xcode.BreakpointAction.DebuggerCommand">
<ActionContent
consoleCommand = "">
</ActionContent>
</BreakpointActionProxy>
</Actions>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
Expand Down
6 changes: 4 additions & 2 deletions PinConfigurator/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ - (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename
[self clear];

_fileName = [filename retain];
NSStringEncoding stringEncoding;
NSData *configData = [NSData dataWithContentsOfFile:filename];

if ([[filename lastPathComponent] caseInsensitiveCompare:@"PinConfigs.kext"] == NSOrderedSame)
Expand All @@ -945,9 +946,10 @@ - (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename
return YES;
}

NSString *configString = [[NSString alloc] initWithData:configData encoding:NSUTF8StringEncoding];
NSError *error;
NSString *configString = [NSString stringWithContentsOfFile:filename usedEncoding:&stringEncoding error:&error];

[self parseConfigString:configString];
[configString release];

return YES;
}
Expand Down
122 changes: 63 additions & 59 deletions PinConfigurator/HdaCodec.m
Original file line number Diff line number Diff line change
Expand Up @@ -573,38 +573,38 @@ + (bool)parseHdaCodecNode_Voodoo:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)
// =============================================================================
// Widget cap: 0x0040018f
// =============================================================================
if (getRegExArray(@"(.*)Widget cap: 0x(.*)", line, 2, &itemArray))
hdaWidget.capabilities = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)Widget cap: (.*)", line, 2, &itemArray))
hdaWidget.capabilities = getInt(itemArray[1]);

// =============================================================================
// EAPD: 0x00000002
// =============================================================================
if (getRegExArray(@"(.*)EAPD: 0x(.*)", line, 2, &itemArray))
hdaWidget.defaultEapd = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)EAPD: (.*)", line, 2, &itemArray))
hdaWidget.defaultEapd = getInt(itemArray[1]);

// =============================================================================
// Pin cap: 0x00010014
// =============================================================================
if (getRegExArray(@"(.*)Pin cap: 0x(.*)", line, 2, &itemArray))
hdaWidget.pinCapabilities = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)Pin cap: (.*)", line, 2, &itemArray))
hdaWidget.pinCapabilities = getInt(itemArray[1]);

// =============================================================================
// Pin config: 0x99130110
// =============================================================================
if (getRegExArray(@"(.*)Pin config: 0x(.*)", line, 2, &itemArray))
hdaWidget.defaultConfiguration = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)Pin config: (.*)", line, 2, &itemArray))
hdaWidget.defaultConfiguration = getInt(itemArray[1]);

// =============================================================================
// Pin control: 0x00000000
// =============================================================================
if (getRegExArray(@"(.*)Pin control: 0x(.*)", line, 2, &itemArray))
hdaWidget.defaultPinControl = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)Pin control: (.*)", line, 2, &itemArray))
hdaWidget.defaultPinControl = getInt(itemArray[1]);

// =============================================================================
// Output amp: 0x80000000
// =============================================================================
if (getRegExArray(@"(.*)Output amp: 0x(.*)", line, 2, &itemArray))
hdaWidget.ampOutCapabilities = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)Output amp: (.*)", line, 2, &itemArray))
hdaWidget.ampOutCapabilities = getInt(itemArray[1]);

// =============================================================================
// Output val: [0x80 0x80]
Expand All @@ -620,10 +620,10 @@ + (bool)parseHdaCodecNode_Voodoo:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)

if ([stereoArray count] > 0)
{
hdaWidget.ampOutLeftDefaultGainMute = getHexInt(stereoArray[0]);
hdaWidget.ampOutLeftDefaultGainMute = getInt(stereoArray[0]);

if ([stereoArray count] == 2)
hdaWidget.ampOutRightDefaultGainMute = getHexInt(stereoArray[1]);
hdaWidget.ampOutRightDefaultGainMute = getInt(stereoArray[1]);
}

break;
Expand All @@ -635,8 +635,8 @@ + (bool)parseHdaCodecNode_Voodoo:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)
// =============================================================================
// Input amp: 0x002f0300
// =============================================================================
if (getRegExArray(@"(.*)Input amp: 0x(.*)", line, 2, &itemArray))
hdaWidget.ampInCapabilities = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)Input amp: (.*)", line, 2, &itemArray))
hdaWidget.ampInCapabilities = getInt(itemArray[1]);

// =============================================================================
// Input val: [0x00 0x00] [0x00 0x00]
Expand All @@ -654,10 +654,10 @@ + (bool)parseHdaCodecNode_Voodoo:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)

if ([stereoArray count] > 0)
{
[hdaWidget.ampInLeftDefaultGainMute addObject:[NSNumber numberWithInteger:getHexInt(stereoArray[0])]];
[hdaWidget.ampInLeftDefaultGainMute addObject:[NSNumber numberWithInteger:getInt(stereoArray[0])]];

if ([stereoArray count] == 2)
[hdaWidget.ampInRightDefaultGainMute addObject:[NSNumber numberWithInteger:getHexInt(stereoArray[1])]];
[hdaWidget.ampInRightDefaultGainMute addObject:[NSNumber numberWithInteger:getInt(stereoArray[1])]];
}
}

Expand Down Expand Up @@ -744,14 +744,14 @@ + (bool)parseHdaCodecString_Voodoo:(NSString *)hdaCodecString hdaCodec:(HdaCodec
// =============================================================================
// HDA Codec ID: 0x10ec0269
// =============================================================================
if (getRegExArray(@"(.*)HDA Codec ID: 0x(.*)", line, 2, &itemArray))
hdaCodec.vendorID = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)HDA Codec ID: (.*)", line, 2, &itemArray))
hdaCodec.vendorID = getInt(itemArray[1]);

// =============================================================================
// Revision: 0x01
// =============================================================================
if (getRegExArray(@"(.*)Revision: 0x(.*)", line, 2, &itemArray))
hdaCodec.revisionID |= getHexInt(itemArray[1]) << 16;
if (getRegExArray(@"(.*)Revision: (.*)", line, 2, &itemArray))
hdaCodec.revisionID |= getInt(itemArray[1]) << 16;
}

hdaCodec.widgets = [NSMutableArray array];
Expand Down Expand Up @@ -798,15 +798,15 @@ + (bool)parseHdaCodecNode_Linux:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)h
// =============================================================================
// Node 0x14 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
// =============================================================================
if (getRegExArray(@"Node 0x(.*) \\[(.*)\\] wcaps 0x(.*):(.*)", line, 4, &itemArray))
if (getRegExArray(@"Node (.*) \\[(.*)\\] wcaps (.*):(.*)", line, 4, &itemArray))
{
if (hdaWidget != nil)
[hdaWidget release];

hdaWidget = [[HdaWidget alloc] initWithNodeID:getHexInt(itemArray[0])];
hdaWidget = [[HdaWidget alloc] initWithNodeID:getInt(itemArray[0])];
[hdaCodec.widgets addObject:hdaWidget];

hdaWidget.capabilities = getHexInt(itemArray[2]);
hdaWidget.capabilities = getInt(itemArray[2]);
}

// =============================================================================
Expand All @@ -818,13 +818,13 @@ + (bool)parseHdaCodecNode_Linux:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)h
// =============================================================================
// Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
// =============================================================================
if (getRegExArray(@"(.*)Amp-In caps: ofs=0x(.*), nsteps=0x(.*), stepsize=0x(.*), mute=(.*)", line, 5, &itemArray))
if (getRegExArray(@"(.*)Amp-In caps: ofs=(.*), nsteps=(.*), stepsize=(.*), mute=(.*)", line, 5, &itemArray))
{
hdaWidget.ampInCapabilities |= getHexInt(itemArray[1]);
hdaWidget.ampInCapabilities |= getHexInt(itemArray[2]) << 8;
hdaWidget.ampInCapabilities |= getHexInt(itemArray[3]) << 16;
hdaWidget.ampInCapabilities |= getHexInt(itemArray[4]) ? HDA_PARAMETER_AMP_CAPS_MUTE : 0;
}
hdaWidget.ampInCapabilities |= getInt(itemArray[1]);
hdaWidget.ampInCapabilities |= getInt(itemArray[2]) << 8;
hdaWidget.ampInCapabilities |= getInt(itemArray[3]) << 16;
hdaWidget.ampInCapabilities |= getInt(itemArray[4]) ? HDA_PARAMETER_AMP_CAPS_MUTE : 0;
}

// =============================================================================
// Amp-In vals: [0x00 0x00]
Expand All @@ -842,10 +842,10 @@ + (bool)parseHdaCodecNode_Linux:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)h

if ([stereoArray count] > 0)
{
[hdaWidget.ampInLeftDefaultGainMute addObject:[NSNumber numberWithInteger:getHexInt(stereoArray[0])]];
[hdaWidget.ampInLeftDefaultGainMute addObject:[NSNumber numberWithInteger:getInt(stereoArray[0])]];

if ([stereoArray count] == 2)
[hdaWidget.ampInRightDefaultGainMute addObject:[NSNumber numberWithInteger:getHexInt(stereoArray[1])]];
[hdaWidget.ampInRightDefaultGainMute addObject:[NSNumber numberWithInteger:getInt(stereoArray[1])]];
}
}

Expand All @@ -855,12 +855,12 @@ + (bool)parseHdaCodecNode_Linux:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)h
// =============================================================================
// Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
// =============================================================================
if (getRegExArray(@"(.*)Amp-Out caps: ofs=0x(.*), nsteps=0x(.*), stepsize=0x(.*), mute=(.*)", line, 5, &itemArray))
if (getRegExArray(@"(.*)Amp-Out caps: ofs=(.*), nsteps=(.*), stepsize=(.*), mute=(.*)", line, 5, &itemArray))
{
hdaWidget.ampOutCapabilities |= getHexInt(itemArray[1]);
hdaWidget.ampOutCapabilities |= getHexInt(itemArray[2]) << 8;
hdaWidget.ampOutCapabilities |= getHexInt(itemArray[3]) << 16;
hdaWidget.ampOutCapabilities |= getHexInt(itemArray[4]) ? HDA_PARAMETER_AMP_CAPS_MUTE : 0;
hdaWidget.ampOutCapabilities |= getInt(itemArray[1]);
hdaWidget.ampOutCapabilities |= getInt(itemArray[2]) << 8;
hdaWidget.ampOutCapabilities |= getInt(itemArray[3]) << 16;
hdaWidget.ampOutCapabilities |= getInt(itemArray[4]) ? HDA_PARAMETER_AMP_CAPS_MUTE : 0;
}

// =============================================================================
Expand All @@ -877,10 +877,10 @@ + (bool)parseHdaCodecNode_Linux:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)h

if ([stereoArray count] > 0)
{
hdaWidget.ampOutLeftDefaultGainMute = getHexInt(stereoArray[0]);
hdaWidget.ampOutLeftDefaultGainMute = getInt(stereoArray[0]);

if ([stereoArray count] == 2)
hdaWidget.ampOutRightDefaultGainMute = getHexInt(stereoArray[1]);
hdaWidget.ampOutRightDefaultGainMute = getInt(stereoArray[1]);
}

break;
Expand All @@ -906,7 +906,7 @@ + (bool)parseHdaCodecNode_Linux:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)h
for (int j = 0; j < [connectionArray count]; j++)
{
bool selected = [connectionArray[j] hasSuffix:@"*"];
uint32_t connection = getHexInt(connectionArray[j]);
uint32_t connection = getInt(connectionArray[j]);
[hdaWidget.connections addObject:[NSNumber numberWithInteger:connection]];

if (selected)
Expand All @@ -921,26 +921,26 @@ + (bool)parseHdaCodecNode_Linux:(NSString *)hdaNodeString hdaCodec:(HdaCodec *)h
// =============================================================================
// Pincap 0x00010014: OUT EAPD Detect
// =============================================================================
if (getRegExArray(@"(.*)Pincap 0x(.*):(.*)", line, 3, &itemArray))
hdaWidget.pinCapabilities = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)Pincap (.*):(.*)", line, 3, &itemArray))
hdaWidget.pinCapabilities = getInt(itemArray[1]);

// =============================================================================
// EAPD 0x2: EAPD
// =============================================================================
if (getRegExArray(@"(.*)EAPD 0x(.*):(.*)", line, 3, &itemArray))
hdaWidget.defaultEapd = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)EAPD (.*):(.*)", line, 3, &itemArray))
hdaWidget.defaultEapd = getInt(itemArray[1]);

// =============================================================================
// Pin Default 0x90170110: [Fixed] Speaker at Int N/A
// =============================================================================
if (getRegExArray(@"(.*)Pin Default 0x(.*):(.*)", line, 3, &itemArray))
hdaWidget.defaultConfiguration = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)Pin Default (.*):(.*)", line, 3, &itemArray))
hdaWidget.defaultConfiguration = getInt(itemArray[1]);

// =============================================================================
// Pin-ctls: 0x40: OUT
// =============================================================================
if (getRegExArray(@"(.*)Pin-ctls: 0x(.*):(.*)", line, 3, &itemArray))
hdaWidget.defaultPinControl = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)Pin-ctls: (.*):(.*)", line, 3, &itemArray))
hdaWidget.defaultPinControl = getInt(itemArray[1]);
}

if (hdaWidget != nil)
Expand All @@ -964,6 +964,7 @@ + (bool)parseHdaCodecString_Linux:(NSString *)hdaCodecString hdaCodec:(HdaCodec

NSString *headerString = [hdaCodecString substringWithRange:NSMakeRange(0, nodeRange.location)];
NSString *allNodesString = [hdaCodecString substringFromIndex:nodeRange.location];
allNodesString = [allNodesString stringByReplacingOccurrencesOfString:@"\r" withString:@""];
NSArray *nodeArray = [allNodesString componentsSeparatedByString:@"Node"];
NSArray *headerLineArray = [headerString componentsSeparatedByString:@"\n"];
NSMutableArray *itemArray;
Expand All @@ -986,20 +987,20 @@ + (bool)parseHdaCodecString_Linux:(NSString *)hdaCodecString hdaCodec:(HdaCodec
// Vendor Id: 0x10EC0283
// =============================================================================
if (getRegExArray(@"Vendor Id: (.*)", line, 1, &itemArray))
hdaCodec.vendorID = getHexInt(itemArray[0]);
hdaCodec.vendorID = getInt(itemArray[0]);

// =============================================================================
// Revision Id: 0x00100003
// =============================================================================
if (getRegExArray(@"Revision Id: (.*)", line, 1, &itemArray))
hdaCodec.revisionID = getHexInt(itemArray[0]);
hdaCodec.revisionID = getInt(itemArray[0]);

// =============================================================================
// AFG Function Id: 0x1 (unsol 1)
// =============================================================================
if (getRegExArray(@"AFG Function Id: 0x(.*) \\(unsol (.*)\\)", line, 2, &itemArray))
if (getRegExArray(@"AFG Function Id: (.*) \\(unsol (.*)\\)", line, 2, &itemArray))
{
hdaCodec.audioFuncID = getHexInt(itemArray[0]);
hdaCodec.audioFuncID = getInt(itemArray[0]);
hdaCodec.unsol = getInt(itemArray[1]);
}

Expand All @@ -1008,20 +1009,23 @@ + (bool)parseHdaCodecString_Linux:(NSString *)hdaCodecString hdaCodec:(HdaCodec
// bits [0x000E]: 16 20 24
// formats [0x00000001]: PCM
// =============================================================================
if (getRegExArray(@"(.*)rates \\[0x(.*)\\]:(.*)", line, 3, &itemArray))
hdaCodec.rates = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)rates \\[(.*)\\]:(.*)", line, 3, &itemArray))
hdaCodec.rates = getInt(itemArray[1]);

if (getRegExArray(@"(.*)bits \\[0x(.*)\\]:(.*)", line, 3, &itemArray))
hdaCodec.rates |= getHexInt(itemArray[1]) << 16;
if (getRegExArray(@"(.*)bits \\[(.*)\\]:(.*)", line, 3, &itemArray))
hdaCodec.rates |= getInt(itemArray[1]) << 16;

if (getRegExArray(@"(.*)formats \\[0x(.*)\\]:(.*)", line, 3, &itemArray))
hdaCodec.formats = getHexInt(itemArray[1]);
if (getRegExArray(@"(.*)formats \\(.*)\\]:(.*)", line, 3, &itemArray))
hdaCodec.formats = getInt(itemArray[1]);
}

hdaCodec.widgets = [NSMutableArray array];

for (NSString *nodeString in nodeArray)
{
if ([nodeString isEqualToString:@""])
continue;

NSString *newNodeString = [@"Node" stringByAppendingString:nodeString];

[HdaCodec parseHdaCodecNode_Linux:newNodeString hdaCodec:hdaCodec];
Expand Down
Loading

0 comments on commit 08f4a26

Please sign in to comment.