First, before anyone goes bonkers, I personally have nothing against Microsoft neither Windows, but what if you simply don't have Windows Vista? And I'm not going to download a torrent or get it otherwise. No thanks.
And what if you don't want to install Windows again and happen to have a Linux codec dump? Well, here's what I did to get my Leopard 10.5.6 installation going on an ASUS P5K-PRO motherboard � it should still work with 10.5.7 and Snow Leopard (10.6.0).
Work in progress - last edit:
7 June 2009 � fixed a typo (1 > 0) and gram error (thanks for spotting it guys).
11 June 2009 � removed spurious spaces inserted by Full edit (making a mess of it).
12 June 2009 � cleanups and adding some additional some of the info wasn't clear enough.
14 June 2009 � CodecDump compared with Ubuntu 9.04 (8.10 and are exactly the same).
15 June 2009 � New Pin Default Cheat Sheet in the make!!!
17 June 2009 � New findings about vanilla audio posted here.
17 June 2009 � PinConfiguration and ConfigData fixed (no more "None" for the Microphone) thanks to tmongkol
19 June 2009 � Adding links and text to "Patching com.apple.Boot.plist"
Introduction
Let me start by saying that this tutorial is (far) from complete, but I'm a very busy person (Mozilla Application Developer) and thus all this has to be done in spare time so yeah... it'll take me some time to finish it. The good news is that this old geezer is writing a new article about audio stuff on the hackintosh, and thus we might get there one day soon.
Spotting errors or a broken link: PM me and I'll fix it. Thanks!
What this is not: Please note that this is not a freeway to audio heaven. And no I am not going to fix your audio kexts. It's all up to you... or you'll have to find someone else to do it for you. I simply won't have the time for it since I'm also a father of four children... go figure. Hey, I am already writing this tutorial, remember?
The first thing you need is either a Windows or Linux codec dump. And you can generate it on Linux with:
cat /proc/asound/card0/codec#0 > ~/Desktop/codecname_codec_dump.txtNote: You might need to: cd /proc/asound/card0/ and look for the right codex#
I personally used my Ubuntu 8.10 installation, which was the latest official release at the time of this writing, to create the attached alc883_codec_dump.hex. I later compared the codec dump with Ubuntu 9.04 and they are exactly.
Don't have Linux, yet? Simply get the Ubuntu LiveCD here (instructions included), but you might as well try one of the other Linux distributions.
The next thing you want to do is, that is if you didn't already, is to install XCode IDE � a must have developer tool. And no you don't have to become a developer, but Xcode comes with a few great tools like: Property List Editor and IORegistry Explorer. And yes it is a free download � though you need to sign-up to get it (no worries). Probably just a way for Apple to say: "We have 10 million developers world wide". Right. Just because people need Xcode IDE and thus have to become a registered developer. Whatever.
Codec Dumps Part I � A First Glance
Let's get started. First download the attached codec (scroll down to Files) and open it with something like TextEdit or whatever tools you prefer to use. We'll be using this codec throughout this tutorial, as an example, but you should first compare it with your own codec (look for similarities). Now let's have a look at the codec here, starting with the following lines:
Codec: Realtek ALC883
Address: 0
Vendor Id: 0x10ec0883
Subsystem Id: 0x1043829f
The most important parts here are highlighted in red � the green one shows up in System Profiler (most prominently) and is constructed from the subsystem-vendor-id (1043) and subsystem-id (829f) which you can find with Apple's IORegistry Explorer (part of Apple's Xcode IDE) or simply by entering the following command in a terminal window:
sudo ioreg -l (lowercase L) > ~/Desktop/ioreg-out.txt
Codec Dumps Part II � What Exactly Are We Looking For?
So what exactly are we looking for? Good question. The first value we need is the Address aka CAd (CodecAddress) which in this case is: 0 (zero). It might not be 0 but for example 1 or 2. And you'll be using this value in the following paragraphs so yeah, it is pretty important. The second value is... well the Vendor ID, which in this case is: 0x10ec0883 or 283904131 decimal � we'll have to use decimal values in our plist files.
Let's get to the first snippet, and in the attached alc883_codec_dump.hex this looks like this:
Node 0x14 [Pin Complex] wcaps 0x40018f: Stereo Amp-In Amp-Out
Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
Amp-In vals: [0x00 0x00]
Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
Amp-Out vals: [0x00 0x00]
Pincap 0x083e: IN OUT HP Detect Trigger
Pin Default 0x01014010: [Jack] Line Out at Ext Rear
Conn = 1/8, Color = Green
DefAssociation = 0x1, Sequence = 0x0
Pin-ctls: 0x40: OUT
Unsolicited: tag=00, enabled=0
Connection: 5
0x0c* 0x0d 0x0e 0x0f 0x26
Again, the most important parts here are highlighted in red � the green lines will be discussed in a later stage. The data we're after (for now) is: Node 0x14 being the NID (Node ID) and the Pin Default 0x01014010.
The Pin Default (a 32-bit register in the Pin Complex Widget) is used by software as an aid in determining the configuration of jacks and devices attached to the codec. At the time the codec is first powered on, this register is internally loaded with default values indicating the typical system use of this particular pin/jack
We also need to keep an eye on the Sequence, simply because it can only be 0 on real Mac's. Let's start by looking at the following Pin Default: 0x76543210 � just a simple example to identify all digits.
Where:
0 = Sequence
1 = Default Association
2 = Miscellaneous
3 = Color
4 = Connection Type
5 = Default Device
6 = Location
7 = Port Connectivity
Note the right-to-left or host-byte-order, which might look strange at first for non-developers, but that's how it works. Follow the jump to the Intel HDA specification for a complete description (starting at page 149) which I tell you is a must read.
Codec Dumps Part III � Constructing Verbs
Let's construct our first "Verb Layout" with help of the following *cough* formula *cough*:
CAd + NID + 71X + Masked Pin Default � where X is either: c, d, e, or f.
Like this:
0 + 14 + 71c + 10
0 + 14 + 71d + 40
0 + 14 + 71e + 01
0 + 14 + 71f + 01
Note: the 71x part in this group is the Verb ID which is used by the software to identify verbs. We skip 710 thru 71a in this example aka the GPIO (General Purpose Input/Output) control bytes, which are discussed in great detail in the Intel HDA specification. And there's no word about 71b in the Intel HDA specifications so we'll simply ignore it here.
Which gives us:
01471c10 01471d40 01471e01 01471f01
Now repeat this procedure for all other snippets containing: Node and Pin Default. Let's take the second snippet from my alc883_codec_dump.hex to make sure you understand it � most unnecessary parts have been removed in the following snippet:
Node 0x15 [Pin Complex] wcaps 0x40018f: Stereo Amp-In Amp-Out
Pincap 0x083e: IN OUT HP Detect Trigger
Pin Default 0x01011012: [Jack] Line Out at Ext Rear
Conn = 1/8, Color = Black
DefAssociation = 0x1, Sequence = 0x2
Like this:
0 + 15 + 71c + 12
0 + 15 + 71d + 10
0 + 15 + 71e + 01
0 + 15 + 71f + 01
Giving us: 01571c12 01571d10 01571e01 01571f01
Codec Dumps Part IV � Fixing Sequence Errors
The above value for Sequence can only be 0 on a Mac and thus we simply need to change it, or things won't work properly. And here's the patched group:
01571c10 01571d10 01571e01 01571f01Note: The c,d,e, and f are used by the software to identify the verb!
Codec Dumps Part V � Finishing Up
Let's do the rest, but this time even more information ls removed, and that is why we start with the following color table from the Intel HDA Specifications (Table 105):
Where:
0 = Unknown
1 = Black
2 = Grey
3 = Blue
4 = Green
5 = Red
6 = Orange
7 = Yellow
8 = Purple
9 = Pink
E = White
F = Other
Node 0x16 [Pin Complex] wcaps 0x40018f: Stereo Amp-In Amp-Out
Pin Default 0x01016011: [Jack] Line Out at Ext Rear
01671c10 01671d60 01671e01 01671f01
Note: 1 is invalid and has been changed to 0!
Node 0x17 [Pin Complex] wcaps 0x40018f: Stereo Amp-In Amp-Out
Pin Default 0x01012014: [Jack] Line Out at Ext Rear
01771c10 01771d20 01771e01 01771f01
Note: 4 is invalid and has been changed to 0!
Node 0x18 [Pin Complex] wcaps 0x40018f: Stereo Amp-In Amp-Out
Pin Default 0x01a19840: [Jack] Mic at Ext Rear
01871c40 01871d98 01871ea1 01871f01
Node 0x19 [Pin Complex] wcaps 0x40018f: Stereo Amp-In Amp-Out
Pin Default 0x02a19c50: [Jack] Mic at Ext Front
01971c50 01971d9c 01971ea1 01971f02
Node 0x1a [Pin Complex] wcaps 0x40018f: Stereo Amp-In Amp-Out
Pin Default 0x0181304f: [Jack] Line In at Ext Rear
01a71c40 01a71d30 01a71e81 01a71f01
Note: f is invalid and has been changed to 0!
Node 0x1b [Pin Complex] wcaps 0x40018f: Stereo Amp-In Amp-Out
Pin Default 0x02214c20: [Jack] HP Out at Ext Front
01b71c20 01b71d4c 01b71e21 01b71f02
Node 0x1c [Pin Complex] wcaps 0x400001: Stereo
Pin Default 0x593301f0: [N/A] CD at Int ATAPI
01c71cf0 01c71d01 01c71e33 01c71f59
Node 0x1d [Pin Complex] wcaps 0x400000: Mono
Pin Default 0x4015e601: [N/A] Speaker at Ext N/A
01d71c00 01d71de6 01d71e15 01d71f40
Note: 1 is invalid and has been changed to 0!
Node 0x1e [Pin Complex] wcaps 0x400300: Mono Digital
Pin Default 0x01441130: [Jack] SPDIF Out at Ext Rear
01e71c30 01e71d11 01e71e44 01e71f01
Node 0x1f [Pin Complex] wcaps 0x400200: Mono Digital
Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
01f71cf0 01f71d11 01f71e11 01f71f41
ConfigData
Putting the whole bunch together gives us the ConfigData we need for Info.plist � com.apple.Boot.plist and dsdt.dsl modifications are also discussed, but later on:
"<" + 01471c10 01471d40 01471e01 01471f01 01571c10 01571d10 01571e01 01571f01 01671c10 01671d60 01671e01 01671f01 01771c10 01771d20 01771e01 01771f01 01871c40 01871d98 01871ea1 01871f90 01971c50 01971d9c 01971ea1 01971f02 01a71c40 01a71d30 01a71e81 01a71f01 01b71c20 01b71d4c 01b71e21 01b71f02 01c71cf0 01c71d01 01c71e33 01c71f59 01d71c00 01d71de6 01d71e15 01d71f40 01e71c30 01e71d11 01e71e44 01e71f01 01f71cf0 01f71d11 01f71e11 01f71f41 + ">"And this is how it should look (no tabs, no weird spaces or other illegal characters):
<01471c10 01471d40 01471e01 01471f01 01571c10 01571d10 01571e01 01571f01 01671c10 01671d60 01671e01 01671f01 01771c10 01771d20 01771e01 01771f01 01871c40 01871d98 01871ea1 01871f90 01971c50 01971d9c 01971ea1 01971f02 01a71c40 01a71d30 01a71e81 01a71f01 01b71c20 01b71d4c 01b71e21 01b71f02 01c71cf0 01c71d01 01c71e33 01c71f59 01d71c00 01d71de6 01d71e15 01d71f40 01e71c30 01e71d11 01e71e44 01e71f01 01f71cf0 01f71d11 01f71e11 01f71f41>
Converting NodeID's
The next step is to convert the hexadecimal NID's (NodeID's) to decimal values (plist files work with decimal values). You can use the OS X Calculator (select Menu View -> Programmer) to convert them, or use this script - written by Munky (yah). Whichever you pick, I've done my work and added both the hexadecimal and decimal values (where possible) like this: 0xnn/n
Line 01: NID 0x14/20 [Jack] Line Out at Ext Rear - Front Speaker Out (Green) Line 02: NID 0x15/21 [Jack] Line Out at Ext Rear - Rear Speaker Out (Black) Line 03: NID 0x16/22 [Jack] Line Out at Ext Rear - Center/ Subwoofer (Orange) Line 04: NID 0x17/23 [Jack] Line Out at Ext Rear - Side Speaker (Grey) Line 05: NID 0x18/24 [Jack] Mic at Ext Rear (Pink) Line 06: NID 0x19/25 [Jack] Mic at Ext Front (Pink) Line 07: NID 0x1a/26 [Jack] Line In at Ext Rear (Blue) Line 08: NID 0x1b/27 [Jack] HP Out at Ext Front (Green) Line 09: NID 0x1c/28 [N/A] CD at Int ATAPI Line 10: NID 0x1d/29 [N/A] Speaker at Ext N/A (White) Line 11: NID 0x1e/30 [Jack] SPDIF Out at Ext Rear (Black) Line 12: NID 0x1f/31 [N/A] Speaker at Ext Rear (Black)The (colors) were added by me, and your NID's are probably different (BTW; the color of the SPDIF out RCA adapter on the Asus P5K-PRO isn't really black, but yellow).
Our First Result
Here's what I've got so far in System Profiler/Audio(builtin). Please note that the green in and output devices became visual after I added the above ConfigData to AppleHDAController's Info.plist:
Intel High Definition Audio:
Device ID: 0x1043829F
Audio ID: 12
Available Devices:
Line Out:
Connection: 1/8 inch Jack
Microphone:
Connection: 1/8 inch Jack
Microphone:
Connection: 1/8 inch Jack
Headphone:
Connection: 1/8 inch Jack
S/P-DIF Out:
Connection: RCA
The above Device ID (in red) should match your codec's Subsystem Id and the Audio ID (also in red) represents the used layout-id. Please note that there are two kind of data sets, of which one make System Profiler show the info, and another to make your sound actually work and show up under Output and Input in System Preferences (sound).
Please keep in mind that having something in System Profiler, under Audio (Built-in) doesn't necessarily mean that your sound will actually work, but merely that it can find something to show!
Note: There's more work to be done, because it doesn't really match with the hardware (P5K-PRO). It is however a start, and used as an example only here.
Installing Software
The next thing you might need to do is to install Codecgraph and Graphviz. This to generate a graphical presentation (Scalable Vector Graphics) of your codec.
Please note that you don't necessarily need to do this, at least not when your codec dump is listed under the "Known codecs" section of the first link. But here's a little how for us Linux users:
./codecgraph alc883_codec_dump.hexYou might want to scroll down to Files and have a look at the attached SVG files. Open it with Mozilla Firefox (Safari failed to show both scrollbars) but first unpack it (it's a ZIP file) � other examples can be found by following the first link in this paragraph.
Note: Continue reading "The next step - making connections" when you already have a codec dump!
Making connections
We are about to collect the data we need to add/or modify in our Info.plist
files. But more about plist files later. For now; let's have another look at the nodes in alc883_codec_dump.hex, starting with Node 0x14/20. I'll remove everything but the lines we're interested in:
Connection: 5
0x0c* 0x0d 0x0e 0x0f 0x26
This tells us that there are five (5) connections, of which the one marked with the asterisk (*) is the most interesting - the one we're looking for. That's the Audio Mixer (gray hexagon in the SVG file) we're looking for. Let's have a look at the connections of Node 0x0c/12:
Connection: 2
0x02 0x0b
No asterisk this time. No, we're gonna have to figure that out ourself, which is pretty easy because we know what kind of connection we're working on - being our output device. And looking at Node 0x02/2. Yep, that's the one we're looking for. That's our Audio Output (blue ellipse in the SVG file). This is the first one:
NID [0x14/20] Jack - Line Out at Ext Rear - Front Speaker Out (Green) <0x0c/12> (0x02/2)
Note the used colors and characters - this to make it easier to read/understand:
[green] = Pin Complex
<gray> = Audio Mixer
(red) = input node
(blue) = output node
where 0xnn/n = hexadecimal value / decimal value (Info.plist wants decimal values)
Now, let's do another one. Node 0x15/21 this time. Again, I'll remove everything but the interesting lines:
Connection: 5
0x0c 0x0d* 0x0e 0x0f 0x26
Again, we're after the one with the asterisk and that'll be 0x0d/13 in this case. That's the Audio Mixer we're looking for. And here's the connection list:
Connection: 2
0x03 0x0b
Right, 0x03/3 is another Audio Output so we take that. Done. That was the second one. Here's the outcome:
NID [0x15/21] Jack - Line Out at Ext Rear - Rear Speaker Out (Black) <0x0d/13> (0x03/3)
Read this: Analog output devices can be tracked from the source, being the Pin Complex to their corresponding Audio Mixer. Digital devices however don't need the latter and thus these are a little less complex to setup. Input devices are a different kind of beast, because you need to follow the opposite direction, being from the connector towards the corresponding Audio Mixer and Pin Complex.
Let's try to figure out the connections for Node 0x18/24. Here's the connections list:
Connection: 5
0x0c* 0x0d 0x0e 0x0f 0x26
Which is pretty useless now since we've already used/setup 0x0c/12 Remember? Dead end. Back to the codec dump. There you'll find the two Audio Input nodes being 0x08/8 and 0x09/9 (red ellipses in the SVG file). That's what we need. Check the connection lists to find 0x23/34 and 0x24/35 which are the two Audio Mixers we're looking for. Both have connections to either Audio Mixer so just pick one. Leading to the following input devices:
NID [0x18/24] Jack - Mic at Ext Rear (Pink) <0x22/34> (0x09/9)
NID [0x19/25] Jack - Mic at Ext Front (Pink) <0x22/34> (0x09/9)
NID [0x1a/26] Jack - Line In at Ext Rear (Blue) <0x23/35> (0x08/8)
Putting it together
Let's start with kext files. Which are just folders with data and/or sub-directories in it. Nothing magic; though they might look a bit strange at first.
Kext files usually reside in /System/Library/Extensions/ but you might as well use /Extra for your legacy (modified plist only) kext files. In fact that way things are less messy, and OS upgrades are less likely to break your installation.
It also depends on the installed version of OS X, and how you want to fix your audio (when needed) because injecting data with legacy kexts is not the same thing as injecting data from your modified dsdt.dsl (dsdt.aml) or using device properties in com.apple.Boot.plist The effect should all be the same, of course... giving you audio, but copying a few available legacy kexts is probably the first thing you'll want to do.
Please note that you still might need one or more legacy kexts when you use the DSDT injection method because in the end it all depends on the used hardware, and if that is somewhat compatible with real available/supported Apple hardware.
Note: DSDT hacking is not the holy grail and is probably a bit too difficult for many people (no offense) so only take this route when you know what you are doing!
Now back to hacking. Have a look at /System/Library/Extensions/AppleHDA.kext and the files in it. The most importantly two are just property files:
AppleHDA.kext/Contents/PlugIns/AppleHDAController.kext/Contents/Info.plist AppleHDA.kext/Contents/PlugIns/AppleHDAPlatformDriver.kext/Contents/Info.plist
You'll want to use either Property List Editor, which comes with Apple's Xcode IDE (developer tools) or just: sudo nano <path to file>Info.plist � using the latter will probably be a daunting task at first, but it will be fine when you got used to it.
PinConfigurations
People who inject data with a modified dsdt.dsl or com.apple.Boot.plist (device properties often referred to as EFI-Strings) also need the PinConfigurations, which we get by taking the last two digits from the ConfigData (scroll up):
10 40 01 01 10 10 01 01 11 60 01 01 10 20 01 01 40 98 a1 90 50 9c a1 02 40 30 81 01 20 4c 21 02 f0 01 33 59 00 e6 15 40 30 11 44 01 f0 11 11 41
Patching dsdt.dsl
The corresponding PinConfigurations snipped for dsdt.dsl hackers looks like:
"PinConfigurations",
Buffer (0x30)
{
/* 0000 */ 0x10, 0x40, 0x01, 0x01, 0x10, 0x10, 0x01, 0x01,
/* 0008 */ 0x11, 0x60, 0x01, 0x01, 0x10, 0x20, 0x01, 0x01,
/* 0010 */ 0x40, 0x98, 0xa1, 0x90, 0x50, 0x9c, 0xa1, 0x02,
/* 0018 */ 0x40, 0x30, 0x81, 0x01, 0x20, 0x4c, 0x21, 0x02,
/* 0020 */ 0xf0, 0x01, 0x33, 0x59, 0x00, 0xe6, 0x15, 0x40,
/* 0028 */ 0x30, 0x11, 0x44, 0x01, 0xf0, 0x11, 0x11, 0x41
}
Note: The value 0x30 (hex) represents the buffer length!Giving us:
Device (HDEF)
{
Name (_ADR, 0x001B0000)
Method (_PRW, 0, NotSerialized)
{
Return (Package (0x02)
{
0x0D,
0x05
})
}
Method (_DSM, 4, NotSerialized)
{
Store (Package (0x06)
{
"built-in",
Buffer (One)
{
0x00
},
"layout-id",
Buffer (0x04)
{
0x0c, 0x00, 0x00, 0x00
},
"PinConfigurations",
Buffer (0x30)
{
/* 0000 */ 0x10, 0x40, 0x01, 0x01, 0x10, 0x10, 0x01, 0x01,
/* 0008 */ 0x11, 0x60, 0x01, 0x01, 0x10, 0x20, 0x01, 0x01,
/* 0010 */ 0x40, 0x98, 0xa1, 0x90, 0x50, 0x9c, 0xa1, 0x02,
/* 0018 */ 0x40, 0x30, 0x81, 0x01, 0x20, 0x4c, 0x21, 0x02,
/* 0020 */ 0xf0, 0x01, 0x33, 0x59, 0x00, 0xe6, 0x15, 0x40,
/* 0028 */ 0x30, 0x11, 0x44, 0x01, 0xf0, 0x11, 0x11, 0x41
}
}, Local0)
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
}
Note: The value 0x06 represents the number of items you've put in the package, and needs to be increased when you add items in this scope!
Patching com.apple.Boot.plist
You'll find com.apple.Boot.plist in /Library/Preferences/SystemConfiguration/ and the corresponding PinConfigurations snippet for com.apple.Boot.plist hackers will be something like this:
<key>PciRoot(0x0)/Pci(0x1b,0x0)</key> <dict> <key>built-in</key> <string>0x00</string> <key>PinConfigurations</key> <data>EEABARAQAQERYAEBECABAUCYoZBQnKECQDCBASBMIQLwATNZAOYVQDARRAHwERFB</data> <key>layout-id</key> <string>0x0000000c</string> </dict>
The first thing you probably noticed is that weird string of character between the <data> tags. Well, that's a base64 representation of the PinConfigurations. And that is why people here advise you to use a plist editor � because that will encode it for you in the used Info.plist.
People who know how things work can, of course, use one of the many on-line base64 converters or save their data in a hex file, with say HexEdit, and encode the PinConfigurations with help of OpenSSL like this:
openssl base64 -e -in ~/Desktop/PinConfigurations.hex
It might still look like magic now, but you can easily verify your own findings with help of the graphical presentation of your codec dump - the SVG file because they should match. You need these connections, or there won't be sound, or on the wrong port. Link being at the wrong airport... err no flight. Sorry.
I hope you've learned enough new stuff to keep you busy (for now). Just open the attached codec dump, or better your own, and give it a go. Next time we'll discuss the steps to add/modify the Info.plist files. That'll be fun. I promise.
Thank you
I would like to thank TheKing for his information (for now just follow this link for additional info) about the sequence value, which always should be 0 (as in zero), my buddy at Intel Tom, macgirl for doing Perl scripting. Thanks folks!
Background Information
I noticed that some of the information we need for System Profiler is right in front of us:
Conn = 1/8, Color = Green DefAssociation = 0x1, Sequence = 0x0I figured that the Intel HDA specification would be a great help so I did a Google search and got the information I was looking for. You might want to print the pages 151 and 152, as I did (by far the most interesting pages for starters).
Software and Tools
Property List Editor � part of XCode
PlistEdit Pro
Files - used in this tutorial



Sign In
Create Account















