-->Donations via PayPal [External Link Removed for Guests] :guitar
-->Installation/Post Installation Tutorial [Local Link Removed for Guests]
-->Useful Links [Local Link Removed for Guests]
-->Olarila Images - Updated images [Local Link Removed for Guests]
-->Guides and Tutorials [Local Link Removed for Guests]
-->Clover Folder for All Chipsets [Local Link Removed for Guests]
-->DSDT Patch Requests [Local Link Removed for Guests]

How to patch AppleHDA

Post Reply
User avatar
artur-pt
Olarila Staff
Olarila Staff
Posts: 5012
Joined: 24 May 2011, 11:04
CPU: i5
Motherboard: Lenovo
GPU: Intel

How to patch AppleHDA

#1

Post by artur-pt » 26 Nov 2012, 11:10

Guide to patch AppleHDA for your codec

Chapter 1: Getting Codec Information.

Intro: This guide is for those who want to use AppleHDA and / or trying to learn how it works. It is divided in to several steps and we will address each of them throughout the guide.

Step One: Getting Information from the codec. There are other ways but in this guide we will explain how to get to Linux. Using Ubuntu or another distro. (Note: Use the latest version of Linux and Alsa drivers)
in terminal type:

Code: [Local Link Removed for Guests]

cat /proc/asound/card0/codec#1 > ~/Desktop/codec_dump.txt
or

Code: [Local Link Removed for Guests]

cat /proc/asound/card0/codec#0 > ~/Desktop/codec_dump.txt
or if you prefer use zhell script:

Code: [Local Link Removed for Guests]

cd ~/Desktop && mkdir CodecDump && for c in /proc/asound/card*/codec#*; do f="${c/\/*card/card}"; cat "$c" > CodecDump/${f//\//-}.txt; done && zip -r CodecDump.zip CodecDump
Save it in a safe place.
In OS X, we use the codec_dump for a graphical interface, convert it to decimal (I'll explain why later), get him codec verbs and correct them for OS X.

Download and install: [External Link Removed for Guests] (only version for Lion)

Download CodecGraph: [External Link Removed for Guests] , unzip it to desktop, copy the generated codec_dump.txt linux folder to CodeGraph then type in termainal:

Code: [Local Link Removed for Guests]

cd ~/Desktop/codecgraph
and then:

Code: [Local Link Removed for Guests]

./codecgraph codec_dump.txt
Step Two: Converting CodecGraph CodecDump and hexadecimal to decimal:

Download convert_hex_to_dec.rb.zip [External Link Removed for Guests] Credits Munky . Unzip it in the same folder used previously (codecgraph) - In the terminal:

Code: [Local Link Removed for Guests]

cd ~/Desktop/codecgraph 

chmod +x ./convert_hex_to_dec.rb

./convert_hex_to_dec.rb codec_dump.txt.svg > ~/Desktop/codecgraph/codec_dump_dec.txt.svg
* Replace "codec_dump.txt" with your user name and codec file (if you gave a specific name)

Code: [Local Link Removed for Guests]

./convert_hex_to_dec.rb codec_dump.txt > ~/Desktop/codecgraph/codec_dump_dec.txt
* Replace "codec_dump.txt" with your user name and codec file (if you gave a specific name)

Step Three: For our standard onboard sound card be recognized by OS X must add the device to our HDEF DSDT.aml. For this we use the following patches: HDEF or AZAL to HDEF in both DTGP method has to be present in our DSDT.aml. We use the DSDT Editor to apply the patches correctly [Local Link Removed for Guests] The Patchs you find here [Local Link Removed for Guests] This is a Audio Injection standard and should work for all codecs:

Code: [Local Link Removed for Guests]

Device (HDEF)
            {
                Name (_ADR, 0x001B0000)
                Method (_DSM, 4, NotSerialized)
                {
                    Store (Package (0x04)
                        {
                            "layout-id",
                            Buffer (0x04)
                            {
                                0x0C, 0x00, 0x00, 0x00
                            },

                            "PinConfigurations",
                            Buffer (Zero) {}

                        }, Local0)
                    DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
                    Return (Local0)
                }
            }

Code: [Local Link Removed for Guests]

Method (DTGP, 5, NotSerialized)
    {
        If (LEqual (Arg0, Buffer (0x10)
                {
                    /* 0000 */    0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44,
                    /* 0008 */    0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B
                }))
        {
            If (LEqual (Arg1, One))
            {
                If (LEqual (Arg2, Zero))
                {
                    Store (Buffer (One)
                        {
                            0x03
                        }, Arg4)
                    Return (One)
                }

                If (LEqual (Arg2, One))
                {
                    Return (One)
                }
            }
        }

        Store (Buffer (One)
            {
                0x00
            }, Arg4)
        Return (Zero)
    }

Chapter 2: Correction AppleHDA.Kext

For the AppleHDA Work correctly for our codec we make some modifications in the same plists.
So what are these changes?

If you look at it (click the right mouse button / Show Package Contents), you will find in the Content folder of the main Info.plist (not touching it) and a folder plugins. There are plugins that we have to fix, but not all just Info.plist from this one:

1-AppleHDAController.kext
2-AppleHDAHardwareConfigDriver.kext
3-platform.xml and layout12.xml or Layout1.xml (in Folder Resources)
4-BinPatch

1-AppleHDAController.kext
(Click with the right mouse button / Show Package Contents) Open Plist with a Plist editor. [External Link Removed for Guests]
within IOKitPersonalities key change:

Code: [Local Link Removed for Guests]

<key>IOPCIClassMatch</key>
<string>0x04020000&0xFFFE0000</string>
to:

Code: [Local Link Removed for Guests]

<key>IOPCIPrimaryMatch</key>
<string>0x1c208086</string>
The 0x1c208086 is my device and Audio Vendor ID. Change according to your codec.

Image

2-AppleHDAHardwareConfigDriver.kext

To edit this kext need to get configdata / CodecVerbs.
You can fix them in two ways, either manually or automatically using the script called Signal64 Verbit that performs the entire process automatically
requiring a few adjustments you can download it here:
verbit.zip

Unzip it in the same folder codecgraph used previously. then Run this command in Terminal:

Code: [Local Link Removed for Guests]

cd /Users/your_user_name/Desktop/codecgraph


and then:

Code: [Local Link Removed for Guests]

./Verbit codec_dump.txt> verbs.txt
Note: You must delete the line codec_dump.txt: AFG Function Id: 0x1 (unsol 0)
Having done this codecgraph open the folder and you will see two files and another one called verbs.txt verbitdebug.txt.
verbit.texto is in our interest. For in him we find our configdata / CodecVerbs original and corrected tops underneath.
verbs.txt:

Code: [Local Link Removed for Guests]

Verbs from Linux Codec Dump File: codec_dump.txt


Codec: Realtek ALC887-VD   Address: 0   DevID: 283904135 (0x10ec0887)

   Jack   Color  Description                  Node     PinDefault             Original Verbs
--------------------------------------------------------------------------------------------------------
  ATAPI Unknown  SPDIF Out at Int ATAPI      17 0x11   0x99430140   01171c40 01171d01 01171e43 01171f99
    1/8   Black  Speaker at Ext Rear         18 0x12   0x411111f0   01271cf0 01271d11 01271e11 01271f41
    1/8   Green  Line Out at Ext Rear        20 0x14   0x01014010   01471c10 01471d40 01471e01 01471f01
    1/8   Black  Line Out at Ext Rear        21 0x15   0x01011012   01571c12 01571d10 01571e01 01571f01
    1/8  Orange  Line Out at Ext Rear        22 0x16   0x01016011   01671c11 01671d60 01671e01 01671f01
    1/8    Grey  Line Out at Ext Rear        23 0x17   0x01012014   01771c14 01771d20 01771e01 01771f01
 Mic at Ext Rear    0x18 0x18                        27367504 01871c50 01871d98     01871ea1 01871f01  
 Mic at Ext Front    0x19 0x19                        44145760 01971c60 01971d9c     01971ea1 01971f02  
    1/8    Blue  Line In at Ext Rear         26 0x1a   0x0181305f   01a71c5f 01a71d30 01a71e81 01a71f01
 HP Out at Ext Front    0x1b 0x1b                        35736608 01b71c20 01b71d4c     01b71e21 01b71f02  
    1/8   Black  Speaker at Ext Rear         28 0x1c   0x411111f0   01c71cf0 01c71d11 01c71e11 01c71f41
Optical   White  Line Out at Ext N/A         29 0x1d   0x4005e601   01d71c01 01d71de6 01d71e05 01d71f40
Optical  Orange  SPDIF Out at Ext Rear       30 0x1e   0x01456130   01e71c30 01e71d61 01e71e45 01e71f01
    1/8   Black  Speaker at Ext Rear         31 0x1f   0x411111f0   01f71cf0 01f71d11 01f71e11 01f71f41
--------------------------------------------------------------------------------------------------------


   Jack   Color  Description                  Node     PinDefault             Modified Verbs
--------------------------------------------------------------------------------------------------------
  ATAPI Unknown  SPDIF Out at Int ATAPI      17 0x11   0x99430140   01171c40 01171d00 01171e43 01171f90
    1/8   Green  Line Out at Ext Rear        20 0x14   0x01014010   01471c10 01471d40 01471e01 01471f01
    1/8   Black  Line Out at Ext Rear        21 0x15   0x01011012   01571c70 01571d10 01571e01 01571f01
    1/8  Orange  Line Out at Ext Rear        22 0x16   0x01016011   01671c80 01671d60 01671e01 01671f01
    1/8    Grey  Line Out at Ext Rear        23 0x17   0x01012014   01771c90 01771d20 01771e01 01771f01
 Mic at Ext Rear    0x18 0x18                          27367504     01871c50 01871d90 01871ea1 01871f01  
 Mic at Ext Front    0x19 0x19                         44145760     01971c60 01971d90 01971ea1 01971f01  
    1/8    Blue  Line In at Ext Rear         26 0x1a   0x0181305f   01a71ca0 01a71d30 01a71e81 01a71f01
 HP Out at Ext Front    0x1b 0x1b                        35736608   01b71c20 01b71d40 01b71e21 01b71f01  
Optical   White  Line Out at Ext N/A         29 0x1d   0x4005e601   01d71cb0 01d71de0 01d71e05 01d71f40
Optical  Orange  SPDIF Out at Ext Rear       30 0x1e   0x01456130   01e71c30 01e71d60 01e71e45 01e71f01
--------------------------------------------------------------------------------------------------------
verbitdebug.txt:

Code: [Local Link Removed for Guests]

Blacklist:
411111f0 400000f0 CD at Int ATAPI
Removed Nodes: 0x12 0x1c 0x1f 
Checking 71c Associations

Current Associations
 01171c40 = 4 
 01471c10 = 1 
 01571c12 = 1 
 01671c11 = 1 
 01771c14 = 1 
 01871c50 = 5 
 01971c60 = 6 
 01a71c5f = 5 
 01b71c20 = 2 
 01d71c01 = 1  note: Changed 0 to 1
 01e71c30 = 3 

  Used associations = 4 1 1 1 1 5 6 5 2 1 3
Unused associations = 7 8 9 a b c d e

Correcting duplicate associations

Checking if 4 already exists in: 1 1 1 1 5 6 5 2 1 3 
   no duplicate found
Checking if 1 already exists in: 4 1 1 1 5 6 5 2 1 3 
   duplicate found - Is this the first time we've seen this association?
   yes - ignoring
Checking if 1 already exists in: 4 1 1 1 5 6 5 2 1 3 
   duplicate found - Is this the first time we've seen this association?
   no - replacing association with: 7
Checking if 1 already exists in: 4 1 7 1 5 6 5 2 1 3 
   duplicate found - Is this the first time we've seen this association?
   no - replacing association with: 8
Checking if 1 already exists in: 4 1 7 8 5 6 5 2 1 3 
   duplicate found - Is this the first time we've seen this association?
   no - replacing association with: 9
Checking if 5 already exists in: 4 1 7 8 9 6 5 2 1 3 
   duplicate found - Is this the first time we've seen this association?
   yes - ignoring
Checking if 6 already exists in: 4 1 7 8 9 5 5 2 1 3 
   no duplicate found
Checking if 5 already exists in: 4 1 7 8 9 5 6 2 1 3 
   duplicate found - Is this the first time we've seen this association?
   no - replacing association with: a
Checking if 2 already exists in: 4 1 7 8 9 5 6 a 1 3 
   no duplicate found
Checking if 1 already exists in: 4 1 7 8 9 5 6 a 2 3 
   duplicate found - Is this the first time we've seen this association?
   no - replacing association with: b
Checking if 3 already exists in: 4 1 7 8 9 5 6 a 2 b 
   no duplicate found

New 71c Associations
 Before      After
--------------------------------------------------
01171c40   01171c40  01171d01  01171e43  01171f99
01471c10   01471c10  01471d40  01471e01  01471f01
01571c12   01571c70  01571d10  01571e01  01571f01
01671c11   01671c80  01671d60  01671e01  01671f01
01771c14   01771c90  01771d20  01771e01  01771f01
01871c50   01871c50  01871d98  01871ea1  01871f01
01971c60   01971c60  01971d9c  01971ea1  01971f02
01a71c5f   01a71ca0  01a71d30  01a71e81  01a71f01
01b71c20   01b71c20  01b71d4c  01b71e21  01b71f02
01d71c01   01d71cb0  01d71de6  01d71e05  01d71f40
01e71c30   01e71c30  01e71d61  01e71e45  01e71f01

Reset 71d Misc to 0
New 71d Associations
 Before                After
--------------------------------------------------
01171d01   01171c40  01171d00  01171e43  01171f99
01471d40   01471c10  01471d40  01471e01  01471f01
01571d10   01571c70  01571d10  01571e01  01571f01
01671d60   01671c80  01671d60  01671e01  01671f01
01771d20   01771c90  01771d20  01771e01  01771f01
01871d98   01871c50  01871d90  01871ea1  01871f01
01971d9c   01971c60  01971d90  01971ea1  01971f02
01a71d30   01a71ca0  01a71d30  01a71e81  01a71f01
01b71d4c   01b71c20  01b71d40  01b71e21  01b71f02
01d71de6   01d71cb0  01d71de0  01d71e05  01d71f40
01e71d61   01e71c30  01e71d60  01e71e45  01e71f01

Correct 71f 02 FP to 01
New 71f Associations
 Before                                    After
--------------------------------------------------
01171d01   01171c40  01171d00  01171e43  01171f90
01471d40   01471c10  01471d40  01471e01  01471f01
01571d10   01571c70  01571d10  01571e01  01571f01
01671d60   01671c80  01671d60  01671e01  01671f01
01771d20   01771c90  01771d20  01771e01  01771f01
01871d98   01871c50  01871d90  01871ea1  01871f01
01971d9c   01971c60  01971d90  01971ea1  01971f01
01a71d30   01a71ca0  01a71d30  01a71e81  01a71f01
01b71d4c   01b71c20  01b71d40  01b71e21  01b71f01
01d71de6   01d71cb0  01d71de0  01d71e05  01d71f40
01e71d61   01e71c30  01e71d60  01e71e45  01e71f01
The codec used in the above example as you can see is a ALC887-VD was necessary to change only one of the external microphones.
To understand how these changes are made we need to go deeper.
So what is a codec verb?
For each input/output there is a sequence of 4 verbs.
Lets take an example from codec used before:


Its about NodeID(NID) 0x14 in hex, 20 in decimal:

The default verbs for it: 21471c10 21471d44 21471e01 21471f01
21471c10:
2471c10 = CAd (Codec Adress)
21471c10 = NID (NodeID)
21471c10 = Verb Commands like 71"c" then "d", "e" ,"f"
21471c10 = Verb Data
And the same for the rest.

I think Cad, NID and Verb Commands are pretty simple to figure out: first 2 you get them from linux dump, and commands are standard 71c, 71d, 71e, 71f.
Lets see about verb data:

- 71cXY X=Default Association Y=Sequence

Default Association and Sequence are used together by software to group Pin Complexes (and therefore jacks) together into functional blocks to support multichannel operation. Software may assume that all jacks with the same association number are intended to be grouped together, for instance to provide six channel analog output. The Default Association can also be used by software to prioritize resource allocation in constrained situations. Lower Default Association values would be higher in priority for resources such as processing nodes or Input and Output Converters. Note that this is the default association only, and software can override this value if required, in particular if the user provides additional information about the particular system configuration. A value of 0000b is reserved and should not be used. Software may interpret this value to indicate that the Pin Configuration data has not been properly initialized. A value of 1111b is a special value indicating that the Association has the lowest priority. Multiple different Pin Complexes may share this value, and each is intended to be exposed as independent devices.

Sequence indicates the order of the jacks in the association group. The lowest numbered jack in the association group should be assigned the lowest numbered channels in the stream, etc. The numbers need not be sequential within the group, only the order matters. Sequence numbers within a set of Default Associations must be unique.

*My notes for this, if you look on the vanilla codec verb(no matter what codec) you will see that Sequence is always 0.
Why that, and why for us on our codec verbs is different? Simple b/c Apple dosen't have multichannel analog out! so you must change it to 0.

*About Default Association, Keep the default one, in order, and on those that are the same replace them with new one that dosen't exist already in the dump... the values you can use are: 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d and f.(see what does verbit if you still don't understand)

- 71dXY X=Color Y=Misc

Color indicates the color of the physical jack for use by software.
Unknown 0 Black 1 Grey 2 Blue 3 Green 4 Red 5 Orange 6 Yellow 7 Purple 8 Pink 9 Reserved A-D White E Other F
Misc is a bit field used to indicate other information about the jack. Currently, only bit 0 is defined. If bit 0 is set, it indicates that the jack has no presence detect capability, so even if a Pin Complex indicates that the codec hardware supports the presence detect functionality on the jack, the external circuitry is not capable of supporting the functionality.
Reserved 3
Reserved 2
Reserved 1
Jack Detect Override 0

*Use 0 for Jack Detect - External Device(e.g. Headphones Mic etc)
Use 1 for Jack Detect Disabled - Internal Device(e.g. Internal speakers, Internal mic)

71eXY X=Default Device Y=Connection Type

Default Device indicates the intended use of the jack or device. This can indicate either the label on the jack or the device that is hardwired to the port, as with integrated speakers and the like.
Line Out 0 Speaker 1 HP Out 2 CD 3 SPDIF Out 4 Digital Other Out 5 Modem Line Side 6 Modem Handset Side 7 Line In 8 AUX 9 Mic In A Telephony B SPDIF In C Digital Other In D Reserved E Other F
Connection Type indicates the type of physical connection, such as a 1/8-inch stereo jack or an optical digital connector, etc. Software can use this information to provide helpful user interface descriptions to the user or to modify reported codec capabilities based on the capabilities of the physical transport external to the codec.
Unknown 0 1/8" stereo/mono 1 1/4" stereo/mono 2 ATAPI internal 3 RCA 4 Optical 5 Other Digital 6 Other Analog 7 Multichannel Analog (DIN) 8 XLR/Professional 9 RJ-11 (Modem) A Combination B Other F
71fXY X=Port Connectivity Y=Location

Port Connectivity indicates the external connectivity of the Pin Complex. Software can use this value to know what Pin Complexes are connected to jacks, internal devices, or not connected at all.
00b - The Port Complex is connected to a jack (1/8", ATAPI, etc.).
01b - No physical connection for Port.
10b - A fixed function device (integrated speaker, integrated mic, etc.) is attached.
11b - Both a jack and an internal device are attached. The Information provided in all other fields refers to the integrated device. The PD pin will reflect the status of the jack; the user will need to be queried to figure out what it is.

Location indicates the physical location of the jack or device to which the pin complex is connected. This allows software to indicate, for instance, that the device is the “Front Panel Headphone Jack” as opposed to rear panel connections.

*Details:
Convert the 2 digit hex number to binary.
Pad the front with zero's to make it 8 dgits.

Example:

Code: [Local Link Removed for Guests]

0x02 = binary 10 = 00000010 8 digit binary

Reading the bits from left to right:

Port Connectivity bits 7:6 
-----------------------------------------------------------
00 - Port is connected to a Jack
01 - No External Port -or- No physical connection for Port  
10 - Fixed Function/Built In Device (integrated speaker, mic, etc)
11 - Jack and Internal device are attached 

Location Part 1 - bits 5:4
-----------------------------------------------------------
00 - External on primary chassis
01 - Internal
10 - Separate chassis
11 - Other

Location Part 2 - bits 3:0
-----------------------------------------------------------
The meaning depends on Location Part 1 

00 0000	N/A
00 0001   Rear
00 0010   Front
00 0011   Left
00 0100   Right
00 0101   Top
00 0110   Bottom
00 0111   Special (Rear panel)
00 1000   Special (Drive bay)

01 0000   N/A
01 0111   Special (Riser)
01 1000   HDMI
01 1001   ATAPI

10 0000	N/A
10 0001   Rear
10 0010   Front
10 0011   Left
10 0100   Right
10 0101   Top
10 0110   Bottom

11 0000   N/A
11 0110   ?
11 0111   Inside Mobile Lid (example: mic)
11 1000   Outside Mobile Lid

			Bits
Hex	  76 54 3210
-------------------
71cf01 = 00 00 0001 - Port has a jack - It is External - Rear Location
71cf02 = 00 00 0010 - Port has a jack - It is External - Front Panel Location 
71cf59 = 01 01 1001 - No External Port - ATAPI 
71cf18 = 00 01 1000 - Port has a jack - External - HDMI
71cf90 = 10 01 0000 - Built In Device - Internal - N/A 
		   |  |  ||||
		   |  |  |--------- Location part 2
		   |  |------------ Location part 1  
		   |--------------- Port Connectivity
Thanks again to Signal64 for his [External Link Removed for Guests]
*All info came from [External Link Removed for Guests] Read it for more details!

Conclusion:
The script does a great job, still not perfect as it does not know what are our options ... perhaps a GUI application may be added in the future.
So that those options may be?
- you may want to setup mic as internal to get ambient noise reduction for it.
- some codecs have only line outs same trick can apply and you can set first output as speaker and get as an option software dsp for it.
- for front panel support you may need to transform back mic in line in.
And so on ...
Now that we got all necessary information about configdata / CodecVerbs we edit the info.plist of AppleHDAHardwareConfigDriver.kext.

Editing AppleHDAHardwareConfigDriver.kext (Info.plist)
(Click with the right mouse button / Show Package Contents) Open Plist with a Plist editor.
Navigate to the key IOKitPersonalities / HDA Hardware Config ResourceHDAConfigDefault.

1-CodecID: Put the ID of your codec in Numbers 0x10ec0887 Decimal (Hexadecimal) -> 283 904 135 (Decimal)
2-configdata: Here we put our configdata / Verbs codec that previously corrected.
3-FuncGroup: Must always be 1.
4-LayoutID: By default is 12 but can be any other number provided that you also change the number of layout on your DSDT.aml
* NOTE: In the Mountain Lion kexts so we can use a layout that already has in itself no kext and others like layout887.xml as was used in the Lion kexts.
Image

3 - Editing and platform.xml layout12.xml or Layout1.xml (Folder Resources)
This is the trickiest part.
Within the Resources folder you will find several layouts.xml and a Platforms.xml.
You'll edit both according to the previous corrections ie in AppleHDAHardwareConfigDriver.kext use the layout12 so let's make the necessary edits on this.

1-CodecID: Put the ID of your codec in Numbers 0x10ec0887 Decimal (Hexadecimal) -> 283 904 135 (Decimal)
2-PathMapID: Change to 1
* Note: Exclude MuteGPIO, SignalProcessing of all keys.
Image
What we had to fix in Layout12.xml is already completed.
Now we edit the Platforms.xml is here that lies the pathmaps. Within Key Pathmaps there are other keys
which are numbered and each corresponds to a specific layout.xml eg use within the same layout12.xml has a key with pathmap Id = 1.
In the example we are using a codec ALC887-VD have 4 outputs and 2 audio inputs. Totaling 6 devices.
For output devices, the PathMap follows this pattern:
Pin Complex (NodeID) -> Audio Mixer-> Audio Output
So we have to find a node Pin Complex (NodeID), a node Audio Mixer and finally an audio output node.
For input devices, the PathMap follow this pattern:
Pin-Complex (NodeID)> Selector/Mixer- Audio Input> Audio
Here, we have to find a node Pin Complex (NodeID), an audio mixer / selector node and finally a node of audio input.
Open the file in the folder generated codec_dump_dec.txt.svg codegraph you will see something like this:
Image
note 20 (Pin Complex) -> 12 (node ​​Audio Mixer) -> 2 (Audio output node)
from there we have already formed our pathmap lineout to (in the case node20 is an internal speaker).
We will do the same for the rest of our pathmaps.
Note: Note that in the screenshot attached above you can see that the lines are continuous connections of nodes.
Image
An example of Pathmaps to Mic (External):
note 24 (Pin Complex) -> 35 (node ​​Audio Mixer) -> 9 (Audio output node)
Note: Usually starts unlike 9 -> 34 -> 24
Image

The pathmaps codec for example were used as well:
9-34-24 = External Mic
9-34-25 = External Mic Front
8-35-26 = Line Out
2-12-20 = Internal Speakers
27-38-37 = Phone
23-15-5 = Line Out
22-14-4 = Line Out
23-13-3 = Line Out
30-6 = Digital Output

4-BinPatch:

Starting with version 10.6.3 of Snow Leopard was also necessary to correct the binary file of Applehda.kext it is within the MacOs folder that sits inside the Kext to make this correction we will use the script done by bcc9.
patch-hda.zip
Copy the folder to your desktop and already with Applehda.kext edits and installed in S / L / E type the following commands in Terminal:

Code: [Local Link Removed for Guests]

cd ~/desktop/patch-hda
./patch-hda.pl 10ec0887
* Note: Open the folder hda-patch and then patch the file-hda-codecs.pl inside it is all supported codecs
the script for more information: [External Link Removed for Guests]
A tip if your codec is not supported by the script you can try to fix manually using a binary editor and replace HexFiend as one of the codecs used to correct for yours.
In the example above has been corrected for the binary codec ALC887-VD if you fix your codec is needed to replace the 10ec0887 the id of your codec.
In the binary they are written from right to esuerda ie = 10ec0887 8708ec10.
* Important: The Mountain Lion's kext has a new structure and the files are compressed in. Zlib
to unpack and edit these files will use the script RevoGirl (RIP).
Script RevoGirl AppleHda.zip
Copy the script zlib.pl to Desktop as Platforms.xml.zlib and layout12.xml.zlib found within Applehda.kext / Resources and terminal run the following commands:

Code: [Local Link Removed for Guests]

cd ~ / desktop 
perl zlib.pl inflate layout12.xml.zlib> layout12.xml (Unzip) 
perl zlib.pl deflate layout12.xml> layout12.xml.zlib (compress) 

perl zlib.pl inflate Platforms.xml.zlib> Platforms.xml (Unzip) 
perl zlib.pl deflate Platforms.xml> Platforms.xml.zlib (compress)
Kext used as an example for this guide: [External Link Removed for Guests]
Folder with all the necessary tools for editing and some kexts Applehda.kext several original versions of OS X: [External Link Removed for Guests]

Credits: The King, bcc9, RevoGirl (RIP), MlyDinEsH, Munky, Timewalker.

Original Post by Mirone
You do not have the required permissions to view the files attached to this post.
PB Easy Note TM 86 - i5 430 M - H55M - Ram - 6 GB - Alc272 - Radeon HD 5470 512 QE/CI
Lenovo G500 - i5 3230m - HM77 - Ram - 8 GB - Conexant audio - HD 4000
[External Link Removed for Guests] - join me at irc.freenode.net/##olarila
brividomortale
Posts: 50
Joined: 10 Sep 2012, 10:42
CPU: ntel Core i5 3210
Motherboard: Dell Vostro 3560
GPU: Intel HD4000 Mobile
Contact:

Re: How to patch AppleHDA

#2

Post by brividomortale » 29 Jan 2013, 14:21

I saw that guide, but I'm not able

I can not even start ubuntu because I only have USB 3.0
User avatar
artur-pt
Olarila Staff
Olarila Staff
Posts: 5012
Joined: 24 May 2011, 11:04
CPU: i5
Motherboard: Lenovo
GPU: Intel

Re: How to patch AppleHDA

#3

Post by artur-pt » 29 Jan 2013, 14:31

hello

use a ubuntu live cd...

and ask for help here about applehda

[Local Link Removed for Guests]

good hack
PB Easy Note TM 86 - i5 430 M - H55M - Ram - 6 GB - Alc272 - Radeon HD 5470 512 QE/CI
Lenovo G500 - i5 3230m - HM77 - Ram - 8 GB - Conexant audio - HD 4000
[External Link Removed for Guests] - join me at irc.freenode.net/##olarila
brividomortale
Posts: 50
Joined: 10 Sep 2012, 10:42
CPU: ntel Core i5 3210
Motherboard: Dell Vostro 3560
GPU: Intel HD4000 Mobile
Contact:

Re: How to patch AppleHDA

#4

Post by brividomortale » 29 Jan 2013, 14:53

I haven't CD-Rom
User avatar
Mirone
Site Admin
Site Admin
Posts: 1733
Joined: 15 Jun 2011, 14:22
CPU: Core i7-7700k
Motherboard: GA-Z270M-D3H
GPU: RX 560 - 4GB

Re: How to patch AppleHDA

#5

Post by Mirone » 29 Jan 2013, 15:37

brividomortale wrote:I haven't CD-Rom
Try this: [External Link Removed for Guests]
[External Link Removed for Guests]
brividomortale
Posts: 50
Joined: 10 Sep 2012, 10:42
CPU: ntel Core i5 3210
Motherboard: Dell Vostro 3560
GPU: Intel HD4000 Mobile
Contact:

Re: How to patch AppleHDA

#6

Post by brividomortale » 29 Jan 2013, 16:01

Tnks
ribben
Posts: 8
Joined: 03 Feb 2013, 23:07
CPU: Intel T7250
Motherboard: Napa
GPU: 8600m gt

Re: How to patch AppleHDA

#7

Post by ribben » 22 Feb 2013, 23:51

Great tutorial mate thanks a million!

But i am having difficulties understanding the procedure of patching platform.xml

A little help??? Below i have attached my codec_dump_dex.txt.svg...
codec_dump_dec.txt.svg.zip
My regards,
Ribben
You do not have the required permissions to view the files attached to this post.
User avatar
Mirone
Site Admin
Site Admin
Posts: 1733
Joined: 15 Jun 2011, 14:22
CPU: Core i7-7700k
Motherboard: GA-Z270M-D3H
GPU: RX 560 - 4GB

Re: How to patch AppleHDA

#8

Post by Mirone » 23 Feb 2013, 00:26

ribben wrote:Great tutorial mate thanks a million!

But i am having difficulties understanding the procedure of patching platform.xml

A little help??? Below i have attached my codec_dump_dex.txt.svg...
codec_dump_dec.txt.svg.zip
My regards,
Ribben
21-16-3-->Speaker
20-15-2-->Phone
7-36-25-->Mic Int.
8-35-24-->Mic Ext.
Note: For notebooks is necessary to add a codecverbs to the EAPD.
in your case would 01570C02.
[External Link Removed for Guests]
ribben
Posts: 8
Joined: 03 Feb 2013, 23:07
CPU: Intel T7250
Motherboard: Napa
GPU: 8600m gt

Re: How to patch AppleHDA

#9

Post by ribben » 23 Feb 2013, 00:33

Mirone wrote: 21-16-3-->Speaker
20-15-2-->Phone
7-36-25-->Mic Int.
8-35-24-->Mic Ext.
Note: For notebooks is necessary to add a codecverbs to the EAPD.
in your case would 01570C02.
Hello Mirone, thanks so much for the help... you are losing me mate what is EAPD??? do you mean binary patching of applehda??? a little more help :D
My soundcard is a realtek ALC268 if that is any help......
User avatar
Mirone
Site Admin
Site Admin
Posts: 1733
Joined: 15 Jun 2011, 14:22
CPU: Core i7-7700k
Motherboard: GA-Z270M-D3H
GPU: RX 560 - 4GB

Re: How to patch AppleHDA

#10

Post by Mirone » 23 Feb 2013, 00:39

ribben wrote:
Hello Mirone, thanks so much for the help... you are losing me mate what is EAPD??? do you mean binary patching of applehda??? a little more help :D
My soundcard is a realtek ALC268 if that is any help......
External Amplifier Power DownEAPD Application Note
Definition:
The term EAPD stands for External Amplifier Power Down. Logical Operation:
Although named External Amplifier Power Down by the Intel HD Audio Specification, this signal logically operates as an external amplifier POWER UP signal. A logic 1 on this signal is meant to cause an external amplifier to power up and a logic 0 is meant to cause an external amplifier to power down.
[External Link Removed for Guests]
ribben
Posts: 8
Joined: 03 Feb 2013, 23:07
CPU: Intel T7250
Motherboard: Napa
GPU: 8600m gt

Re: How to patch AppleHDA

#11

Post by ribben » 23 Feb 2013, 00:47

Ok i think i got what EAPD is... but where i have to put it, i mean is a key with value 0 in platform.xml???
User avatar
Mirone
Site Admin
Site Admin
Posts: 1733
Joined: 15 Jun 2011, 14:22
CPU: Core i7-7700k
Motherboard: GA-Z270M-D3H
GPU: RX 560 - 4GB

Re: How to patch AppleHDA

#12

Post by Mirone » 23 Feb 2013, 00:58

ribben wrote:Ok i think i got what EAPD is... but where i have to put it, i mean is a key with value 0 in platform.xml???
this value is a codec verbs.
example
01471c10 01471d40 01471e01 01471f01
are codecVerbs to node 20 which has EAPD EAPD if necessary
had to have an extra codecverb would 01470C02.

Editing AppleHDAHardwareConfigDriver.kext (Info.plist)
(Click with the right mouse button / Show Package Contents) Open Plist with a Plist editor.
Navigate to the key IOKitPersonalities / HDA Hardware Config ResourceHDAConfigDefault.

1-CodecID: Put the ID of your codec in Numbers 0x10ec0887 Decimal (Hexadecimal) -> 283 904 135 (Decimal)
2-configdata: Here we put our configdata / Verbs codec that previously corrected.
3-FuncGroup: Must always be 1.
4-LayoutID: By default is 12 but can be any other number provided that you also change the number of layout on your DSDT.aml
* NOTE: In the Mountain Lion kexts so we can use a layout that already has in itself no kext and others like layout887.xml as was used in the Lion kexts.
[External Link Removed for Guests]
mr_bartleboom
Posts: 5
Joined: 25 Nov 2011, 15:34

Re: How to patch AppleHDA

#13

Post by mr_bartleboom » 10 Mar 2013, 12:57

Hi guys,

I trying to patch on my self AppleHDA.kext but I can't get working the front microphone. I tried several ways modifying the config data and/or the platform.xml and/or layoutxx.xml. On my mb (ga-h61m-s2pv rev. 2, FD bios) I got 3 classical jacks (line in, line out, mic) and 2 jacks on chassis (headphones and mic). Everything works fine except the front microphone.
It seems that it doesn't like the microphones...if change the pin config value on 71eXY from 81 (line out) to A1 (microphone) I lose 1 or more IN connections. This is my current config data:

<21171CF0 21171D00 21171E00 21171F40 21271CF0 21271D00 21271E00 21271F40 21471C10 21471D40 21471E01 21471F01 21571CF0 21571D00 21571E00 21571F40 21671CF0 21671D00 21671E00 21671F40 21771CF0 21771D00 21771E00 21771F40 21871C50 21871D90 21871E81 21871F01 21971C60 21971D90 21971E81 21971F02 21A71C30 21A71D30 21A71E81 21A71F01 21B71C20 21B71D40 21B71E21 21B71F01 21C71CF0 21C71D00 21C71E00 21C71F40 21D71C40 21D71D00 21D71E04 21D71F40 21E71CF0 21E71D00 21E71E00 21E71F40 21F71CF0 21F71D00 21F71E00 21F71F40 21470C02 21B70C02>

In bold are:
Node 18: rear MIC
Node 19: front MIC
Node 1A: line IN

This is what I see on System Preferences:
Image Image

Also I noticed that I have a "sound assertion" in my kernel log:

Mar 10 12:59:57 Renatos-Mac-Pro kernel[0]: Sound assertion - Command/Response TIMED OUT and ( kRequestStateMatch == fCodecRequest->state = 2 ), fCodecRequest->command->codec: -549454577664, fCodecRequest->command->verb: 0xFFF, fPoweredDown: 0
Mar 10 12:59:57 Renatos-Mac-Pro kernel[0]: Sound assertion "0 == fResetAsserted" failed in AppleHDAController at line 4512 goto handler
Mar 10 12:59:57 Renatos-Mac-Pro kernel[0]: Sound assertion ""Command/Response TIMED OUT and ( kRequestStateMatch == fCodecRequest->state )"" failed in AppleHDAController at line 4513 goto handler
Mar 10 12:59:57 Renatos-Mac-Pro kernel[0]: Sound assertion "0 != executeCodecCommand ( fCodecList[addr], command, &response )" failed in AppleHDAController at line 7633 goto handler

Does anybody can help me?

Many thanks
Bye
You do not have the required permissions to view the files attached to this post.
User avatar
Mirone
Site Admin
Site Admin
Posts: 1733
Joined: 15 Jun 2011, 14:22
CPU: Core i7-7700k
Motherboard: GA-Z270M-D3H
GPU: RX 560 - 4GB

Re: How to patch AppleHDA

#14

Post by Mirone » 11 Mar 2013, 01:16

mr_bartleboom wrote:Hi guys,

I trying to patch on my self AppleHDA.kext but I can't get working the front microphone. I tried several ways modifying the config data and/or the platform.xml and/or layoutxx.xml. On my mb (ga-h61m-s2pv rev. 2, FD bios) I got 3 classical jacks (line in, line out, mic) and 2 jacks on chassis (headphones and mic). Everything works fine except the front microphone.
It seems that it doesn't like the microphones...if change the pin config value on 71eXY from 81 (line out) to A1 (microphone) I lose 1 or more IN connections. This is my current config data:

<21171CF0 21171D00 21171E00 21171F40 21271CF0 21271D00 21271E00 21271F40 21471C10 21471D40 21471E01 21471F01 21571CF0 21571D00 21571E00 21571F40 21671CF0 21671D00 21671E00 21671F40 21771CF0 21771D00 21771E00 21771F40 21871C50 21871D90 21871E81 21871F01 21971C60 21971D90 21971E81 21971F02 21A71C30 21A71D30 21A71E81 21A71F01 21B71C20 21B71D40 21B71E21 21B71F01 21C71CF0 21C71D00 21C71E00 21C71F40 21D71C40 21D71D00 21D71E04 21D71F40 21E71CF0 21E71D00 21E71E00 21E71F40 21F71CF0 21F71D00 21F71E00 21F71F40 21470C02 21B70C02>

In bold are:
Node 18: rear MIC
Node 19: front MIC
Node 1A: line IN

This is what I see on System Preferences:
Image Image

Also I noticed that I have a "sound assertion" in my kernel log:

Mar 10 12:59:57 Renatos-Mac-Pro kernel[0]: Sound assertion - Command/Response TIMED OUT and ( kRequestStateMatch == fCodecRequest->state = 2 ), fCodecRequest->command->codec: -549454577664, fCodecRequest->command->verb: 0xFFF, fPoweredDown: 0
Mar 10 12:59:57 Renatos-Mac-Pro kernel[0]: Sound assertion "0 == fResetAsserted" failed in AppleHDAController at line 4512 goto handler
Mar 10 12:59:57 Renatos-Mac-Pro kernel[0]: Sound assertion ""Command/Response TIMED OUT and ( kRequestStateMatch == fCodecRequest->state )"" failed in AppleHDAController at line 4513 goto handler
Mar 10 12:59:57 Renatos-Mac-Pro kernel[0]: Sound assertion "0 != executeCodecCommand ( fCodecList[addr], command, &response )" failed in AppleHDAController at line 7633 goto handler

Does anybody can help me?

Many thanks
Bye
Try This in the Pathmap:
Mic EXT Front: 9-34-25
Mic Ext Rear: 9-34-24
Line In: 8-35-26
Speaker: 20-12-2
Headphone:27-15-5
[External Link Removed for Guests]
mr_bartleboom
Posts: 5
Joined: 25 Nov 2011, 15:34

Re: How to patch AppleHDA

#15

Post by mr_bartleboom » 12 Mar 2013, 07:26

Try This in the Pathmap:
Mic EXT Front: 9-34-25
Mic Ext Rear: 9-34-24
Line In: 8-35-26
Speaker: 20-12-2
Headphone:27-15-5
[d]Thank you very much @Mirone, this evening I'll give a try and I'll let you know!!
Bye[/d]

OLD UPDATE:
@Mirone no good news...I my several attempts (I forgot it!) I had already tested this combination and it doesn't work. This evening I will give a try on ML, now I'm testing on SL (they are both installed on same machine). I'll let you know, thanks.

UPDATE:
@Mirone still no good news...
I ported my kext on ML but nothing changed:
1. It only accept "line-in" value on config data (81). using "mic" (A1) the input source disappears.
2. Still no sound from the front line-in... :shock:
amitkool21
Posts: 17
Joined: 13 Apr 2013, 07:34
CPU: i7-3770k
Motherboard: Z77X-UP5-TH
GPU: 8400GS

Re: How to patch AppleHDA

#16

Post by amitkool21 » 13 Apr 2013, 07:41

can someone help me to get my ALC898 working :(
User avatar
artur-pt
Olarila Staff
Olarila Staff
Posts: 5012
Joined: 24 May 2011, 11:04
CPU: i5
Motherboard: Lenovo
GPU: Intel

Re: How to patch AppleHDA

#17

Post by artur-pt » 13 Apr 2013, 09:07

hello

have u searched for ?

[External Link Removed for Guests]

so many kext for that codec

good hack
PB Easy Note TM 86 - i5 430 M - H55M - Ram - 6 GB - Alc272 - Radeon HD 5470 512 QE/CI
Lenovo G500 - i5 3230m - HM77 - Ram - 8 GB - Conexant audio - HD 4000
[External Link Removed for Guests] - join me at irc.freenode.net/##olarila
amitkool21
Posts: 17
Joined: 13 Apr 2013, 07:34
CPU: i7-3770k
Motherboard: Z77X-UP5-TH
GPU: 8400GS

Re: How to patch AppleHDA

#18

Post by amitkool21 » 13 Apr 2013, 09:23

artur-pt wrote:hello

have u searched for ?

[External Link Removed for Guests]

so many kext for that codec

good hack
the link you gave me is for 888 not 898 :(

tried that and it ain't working :(
amitkool21
Posts: 17
Joined: 13 Apr 2013, 07:34
CPU: i7-3770k
Motherboard: Z77X-UP5-TH
GPU: 8400GS

Re: How to patch AppleHDA

#19

Post by amitkool21 » 13 Apr 2013, 17:54

this dump is without any kext : [External Link Removed for Guests]
****************************
this darwin dump with working kexts, but those kexts have issues : [External Link Removed for Guests]
legot28
Posts: 37
Joined: 16 Dec 2011, 10:58

Re: How to patch AppleHDA

#20

Post by legot28 » 02 May 2013, 07:01

hello
my laptop is an HP G62 140SF
can you help me to patch my AppleHDA.kext for ML 10.8.2 12c60
only voodoo is ok
i send my codec dump from linux
help please
thanks
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “Guides and tutorials”