Skip to content

Commit

Permalink
add extract_hda.sh, gen_ahhcd.sh, cleanup PinConfigDefault code
Browse files Browse the repository at this point in the history
  • Loading branch information
RehabMan committed May 28, 2016
1 parent 465fd39 commit 7e500f6
Show file tree
Hide file tree
Showing 9 changed files with 602 additions and 166 deletions.
36 changes: 36 additions & 0 deletions CodecCommander.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
D4FB21F71A0CEBE1005D6019 /* IntelHDA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4FB21F61A0CEBE1005D6019 /* IntelHDA.cpp */; };
D4FD9E041A039E550095AA5A /* IntelHDA.h in Headers */ = {isa = PBXBuildFile; fileRef = D4FD9E031A039E550095AA5A /* IntelHDA.h */; };
ED1EDDF31CC7E2700004F8F0 /* SSDT-ALC280.dsl in Resources */ = {isa = PBXBuildFile; fileRef = ED1EDDF21CC7E2700004F8F0 /* SSDT-ALC280.dsl */; };
ED789AF41CFA1A840067F666 /* gen_ahhcd.sh in Resources */ = {isa = PBXBuildFile; fileRef = ED789AED1CFA1A840067F666 /* gen_ahhcd.sh */; };
ED789AF51CFA1A840067F666 /* extract_hda.sh in Resources */ = {isa = PBXBuildFile; fileRef = ED789AEE1CFA1A840067F666 /* extract_hda.sh */; };
ED789AF61CFA1A840067F666 /* convert.sh in Resources */ = {isa = PBXBuildFile; fileRef = ED789AEF1CFA1A840067F666 /* convert.sh */; };
ED789AF71CFA1A840067F666 /* config_dump.sh in Resources */ = {isa = PBXBuildFile; fileRef = ED789AF01CFA1A840067F666 /* config_dump.sh */; };
ED789AF81CFA1A840067F666 /* eapd_dump.sh in Resources */ = {isa = PBXBuildFile; fileRef = ED789AF11CFA1A840067F666 /* eapd_dump.sh */; };
ED789AF91CFA1A840067F666 /* node_dump.sh in Resources */ = {isa = PBXBuildFile; fileRef = ED789AF21CFA1A840067F666 /* node_dump.sh */; };
ED789AFA1CFA1A840067F666 /* widget_dump.sh in Resources */ = {isa = PBXBuildFile; fileRef = ED789AF31CFA1A840067F666 /* widget_dump.sh */; };
EDA1E4191C8DC4AD009C880D /* SSDT-ALC668.dsl in Resources */ = {isa = PBXBuildFile; fileRef = EDA1E4181C8DC4AD009C880D /* SSDT-ALC668.dsl */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -55,6 +62,13 @@
D4FB21F81A0CED3E005D6019 /* Common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Common.h; sourceTree = "<group>"; };
D4FD9E031A039E550095AA5A /* IntelHDA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = IntelHDA.h; sourceTree = "<group>"; usesTabs = 1; };
ED1EDDF21CC7E2700004F8F0 /* SSDT-ALC280.dsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "SSDT-ALC280.dsl"; sourceTree = "<group>"; };
ED789AED1CFA1A840067F666 /* gen_ahhcd.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = gen_ahhcd.sh; sourceTree = "<group>"; };
ED789AEE1CFA1A840067F666 /* extract_hda.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = extract_hda.sh; sourceTree = "<group>"; };
ED789AEF1CFA1A840067F666 /* convert.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = convert.sh; sourceTree = "<group>"; };
ED789AF01CFA1A840067F666 /* config_dump.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = config_dump.sh; sourceTree = "<group>"; };
ED789AF11CFA1A840067F666 /* eapd_dump.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = eapd_dump.sh; sourceTree = "<group>"; };
ED789AF21CFA1A840067F666 /* node_dump.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = node_dump.sh; sourceTree = "<group>"; };
ED789AF31CFA1A840067F666 /* widget_dump.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = widget_dump.sh; sourceTree = "<group>"; };
EDA1E4181C8DC4AD009C880D /* SSDT-ALC668.dsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "SSDT-ALC668.dsl"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -88,6 +102,7 @@
EDA1E4181C8DC4AD009C880D /* SSDT-ALC668.dsl */,
0C4B238314598AD20080D960 /* CodecCommander */,
D42D3C061A59558C006C4C8C /* CodecCommanderClient */,
ED789AEC1CFA1A690067F666 /* HDA tools */,
0C4B238014598AD20080D960 /* Frameworks */,
0C4B237F14598AD20080D960 /* Products */,
);
Expand Down Expand Up @@ -148,6 +163,20 @@
path = CodecCommanderClient;
sourceTree = "<group>";
};
ED789AEC1CFA1A690067F666 /* HDA tools */ = {
isa = PBXGroup;
children = (
ED789AED1CFA1A840067F666 /* gen_ahhcd.sh */,
ED789AEF1CFA1A840067F666 /* convert.sh */,
ED789AEE1CFA1A840067F666 /* extract_hda.sh */,
ED789AF01CFA1A840067F666 /* config_dump.sh */,
ED789AF11CFA1A840067F666 /* eapd_dump.sh */,
ED789AF21CFA1A840067F666 /* node_dump.sh */,
ED789AF31CFA1A840067F666 /* widget_dump.sh */,
);
name = "HDA tools";
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -235,8 +264,15 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
ED789AF91CFA1A840067F666 /* node_dump.sh in Resources */,
EDA1E4191C8DC4AD009C880D /* SSDT-ALC668.dsl in Resources */,
ED1EDDF31CC7E2700004F8F0 /* SSDT-ALC280.dsl in Resources */,
ED789AFA1CFA1A840067F666 /* widget_dump.sh in Resources */,
ED789AF81CFA1A840067F666 /* eapd_dump.sh in Resources */,
ED789AF71CFA1A840067F666 /* config_dump.sh in Resources */,
ED789AF51CFA1A840067F666 /* extract_hda.sh in Resources */,
ED789AF41CFA1A840067F666 /* gen_ahhcd.sh in Resources */,
ED789AF61CFA1A840067F666 /* convert.sh in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
30 changes: 2 additions & 28 deletions CodecCommander/CodecCommander-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,6 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>${MODULE_VERSION}</string>
<key>#IOKitPersonalities</key>
<dict>
<key>CodecCommanderProbeInit</key>
<dict>
<key>CFBundleIdentifier</key>
<string>${MODULE_NAME}</string>
<key>Codec Profile</key>
<dict>
<key>Default</key>
<dict>
<key>CodecAddressMask</key>
<integer>1</integer>
<key>Custom Commands</key>
<array/>
</dict>
</dict>
<key>IOClass</key>
<string>CodecCommanderProbeInit</string>
<key>IOPCIClassMatch</key>
<string>0x04010000&amp;0xFFFD0000</string>
<key>IOProviderClass</key>
<string>IOPCIDevice</string>
<key>IOProbeScore</key>
<integer>5000</integer>
</dict>
</dict>
<key>IOKitPersonalities</key>
<dict>
<key>CodecCommanderResidency</key>
Expand Down Expand Up @@ -403,7 +377,7 @@
<key>IOUserClientClass</key>
<string>CodecCommanderClient</string>
</dict>
<key>CodecCommanderProbeInit2</key>
<key>CodecCommanderProbeInit</key>
<dict>
<key>CFBundleIdentifier</key>
<string>${MODULE_NAME}</string>
Expand All @@ -416,7 +390,7 @@
</dict>
</dict>
<key>IOClass</key>
<string>CodecCommanderProbeInit2</string>
<string>CodecCommanderProbeInit</string>
<key>IOProviderClass</key>
<string>IOHDACodecDevice</string>
<key>IOProbeScore</key>
Expand Down
107 changes: 3 additions & 104 deletions CodecCommander/CodecCommander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,106 +699,6 @@ IOReturn CodecCommanderPowerHook::setPowerState(unsigned long powerStateOrdinal,

OSDefineMetaClassAndStructors(CodecCommanderProbeInit, IOService)

IOService* CodecCommanderProbeInit::probe(IOService* provider, SInt32* score)
{
DebugLog("CodecCommanderProbeInit::probe\n");

IORecursiveLockLock(g_lock);

IntelHDA intelHDA(provider, PIO);
if (!intelHDA.initialize(true))
{
IORecursiveLockUnlock(g_lock);
return NULL;
}

UInt32 layoutID = intelHDA.getLayoutID();
if (-1 == layoutID)
{
IORecursiveLockUnlock(g_lock);
return NULL;
}

Configuration mainConfig(this->getProperty(kCodecProfile), &intelHDA, kCodecCommanderProbeInitKey);
UInt16 codecBits = mainConfig.getCodecAddressMask();
DebugLog("configured codecBits: 0x%04x\n", codecBits);
DebugLog("ioDelayCount: %u\n", ioDelayCount);

//REVIEW: this actually works, but is a bit slow...
if (codecBits == (UInt16)-1)
{
UInt16 probedCodecBits = 0;
for (unsigned i = 0; i < HDA_MAX_CODECS; i++)
{
UInt32 codecVendorId = -1;
if (intelHDA.setCodecAddress(i))
codecVendorId = intelHDA.getCodecVendorId();
DebugLog("codec at address %u: 0x%08x\n", i, codecVendorId);
if (-1 != codecVendorId)
probedCodecBits |= 1<<i;
}
DebugLog("probedCodecBits = 0x%04x\n", probedCodecBits);
codecBits = probedCodecBits;
}
//#endif
DebugLog("ioDelayCount: %u\n", ioDelayCount);

#ifdef DOES_NOT_WORK
intelHDA.resetHDA();
UInt16 codecBits = intelHDA.getSTATESTS();
DebugLog("STATESTS 0x%04x\n", codecBits);
//REVIEW: temp
codecBits = (1<<0) | (1<<3); // this is what I know now...
#endif

for (UInt16 codecAddress = 0; codecAddress < HDA_MAX_CODECS; codecAddress++)
{
if (!(codecBits & (1<<codecAddress)))
continue; // codec not present

DebugLog("ProbeInit checking codec address %u\n", codecAddress);

intelHDA.setCodecAddress(codecAddress);

DebugLog("ProbeInit codec 0x%08x\n", intelHDA.getCodecVendorId());

Configuration config(this->getProperty(kCodecProfile), &intelHDA, kCodecCommanderProbeInitKey);
DebugLog("ioDelayCount: %u\n", ioDelayCount);

unsigned commandsSent = 0;
OSArray* commands = config.getCustomCommands();
unsigned count = commands->getCount();
for (unsigned i = 0; i < count; i++)
{
OSData* data = (OSData*)commands->getObject(i);
CustomCommand* customCommand = (CustomCommand*)data->getBytesNoCopy();
if (customCommand->OnProbe &&
(-1 == customCommand->layoutID || layoutID == customCommand->layoutID))
{
for (int i = 0; i < customCommand->CommandCount; i++)
{
DebugLog("--> custom probe command 0x%08x\n", customCommand->Commands[i]);
intelHDA.sendCommand(customCommand->Commands[i]);
DebugLog("ioDelayCount: %u\n", ioDelayCount);
}
commandsSent++;
}
}

DebugLog("ioDelayCount: %u\n", ioDelayCount);
if (commandsSent)
AlwaysLog("CodecCommanderProbeInit sent %d command(s) during probe (0x%08x)\n", commandsSent, intelHDA.getCodecVendorId());
}

DebugLog("ioDelayCount: %u\n", ioDelayCount);

IORecursiveLockUnlock(g_lock);

return NULL;
}

OSDefineMetaClassAndStructors(CodecCommanderProbeInit2, IOService)

static UInt32 getNumberFromArray(OSArray* array, unsigned index)
{
OSNumber* num = OSDynamicCast(OSNumber, array->getObject(index));
Expand All @@ -807,9 +707,9 @@ static UInt32 getNumberFromArray(OSArray* array, unsigned index)
return num->unsigned32BitValue();
}

IOService* CodecCommanderProbeInit2::probe(IOService* provider, SInt32* score)
IOService* CodecCommanderProbeInit::probe(IOService* provider, SInt32* score)
{
DebugLog("CodecCommanderProbeInit2::probe\n");
DebugLog("CodecCommanderProbeInit::probe\n");

IORecursiveLockLock(g_lock);

Expand Down Expand Up @@ -842,8 +742,7 @@ IOService* CodecCommanderProbeInit2::probe(IOService* provider, SInt32* score)
{
OSData* data = (OSData*)commands->getObject(i);
CustomCommand* customCommand = (CustomCommand*)data->getBytesNoCopy();
if (customCommand->OnProbe &&
(-1 == customCommand->layoutID || layoutID == customCommand->layoutID))
if (-1 == customCommand->layoutID || layoutID == customCommand->layoutID)
{
for (int i = 0; i < customCommand->CommandCount; i++)
{
Expand Down
10 changes: 0 additions & 10 deletions CodecCommander/CodecCommander.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,6 @@ class CodecCommanderProbeInit : public IOService
virtual IOService* probe(IOService* provider, SInt32* score);
};

class CodecCommanderProbeInit2 : public IOService
{
typedef IOService super;
OSDeclareDefaultStructors(CodecCommanderProbeInit2)

public:
// standard IOKit methods
virtual IOService* probe(IOService* provider, SInt32* score);
};

class CodecCommanderClient : public IOUserClient
{
/*
Expand Down
3 changes: 0 additions & 3 deletions CodecCommander/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#define kCommandOnInit "On Init"
#define kCommandOnSleep "On Sleep"
#define kCommandOnWake "On Wake"
#define kCommandOnProbe "On Probe"
#define kCommandLayoutID "LayoutID"

// Constants for Pin Configuration
Expand Down Expand Up @@ -461,7 +460,6 @@ Configuration::Configuration(OSObject* codecProfiles, IntelHDA* intelHDA, const
customCommand->OnInit = getBoolValue(dict, kCommandOnInit, false);
customCommand->OnSleep = getBoolValue(dict, kCommandOnSleep, false);
customCommand->OnWake = getBoolValue(dict, kCommandOnWake, false);
customCommand->OnProbe = getBoolValue(dict, kCommandOnProbe, false);
customCommand->layoutID = getIntegerValue(dict, kCommandLayoutID, -1);
mCustomCommands->setObject(commandData);
commandData->release();
Expand Down Expand Up @@ -502,7 +500,6 @@ Configuration::Configuration(OSObject* codecProfiles, IntelHDA* intelHDA, const
DebugLog("...OnInit: %s\n", customCommand->OnInit ? "true" : "false");
DebugLog("...OnWake: %s\n", customCommand->OnWake ? "true" : "false");
DebugLog("...OnSleep: %s\n", customCommand->OnSleep ? "true" : "false");
DebugLog("...OnSleep: %s\n", customCommand->OnProbe ? "true" : "false");
DebugLog("...LayoutID: %d\n", customCommand->layoutID);
}
}
Expand Down
1 change: 0 additions & 1 deletion CodecCommander/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ typedef struct
bool OnInit; // Execute command on initialization
bool OnSleep; // Execute command on sleep
bool OnWake; // Execute command on wake
bool OnProbe; // Execute command on probe
UInt32 layoutID;// layout-id filter
UInt32 CommandCount;
UInt32 Commands[0]; // 32-bit verb to execute (Codec Address will be filled in)
Expand Down
Loading

0 comments on commit 7e500f6

Please sign in to comment.