Jump to content

AppleHDA Binary Patching


EMlyDinEsH

Recommended Posts

Hello,

This post is going to be a part of my AppleHDA Patching guide. However, this post alone can be used to Patch AppleHDA binary. I'm using the codec ALC269 as an example for explaining the process. The credit goes to RevoGirl (R.I.P), TimeWalker and others who contributed for discovering the binary patch details.
 
Basically, what we try to do with binary patch is matching our codec ID with codec ID of Apple. By this way our codec gets enabled and work like an Apple codec. There are three Apple codecs from AppleHDA known to work very well for binary patching.

 

They are:

  • ADI 1984 [0x11d41984]

          Hex Value for patching = "84 19 D4 11"

  • ADI 1984B Analog [0x11d4198b]

          Hex Value for patching = "8B 19 D4 11"

  • ALC 885 [0x10ec0885]

          Hex Value for patching = "85 08 EC 10"

 

Now, what we are gonna do is just replace the Vendor and Device id of our codec for any one of the above three Apple codec ID's and zero out/patch some lines which does the comparison and prevents the codec getting enabled. This method works very well for many codecs so far, but it might not for some codecs.

 

Note:
There is a script created by bcc9 from InsanelyMac for this bin patching. So, if want to do this in a script way then follow this post: Binary Patch Script

 

I'm going to use Apple codec ADI 1984 for the ALC 269 which works very well.
Things needed:

  • Untouched AppleHDA from OSX 10.7 or greater
  • Hex Fiend Application (For Patching binary)
  • Codec dump from Linux (Read AppleHDA Complete guide for steps to get dump )
  • Plist Editor (or) Xcode

 

Steps to patch AppleHDA binary:  [ALC269 codec is used as an example]
1. Go to the folder "AppleHDA.kext/Contents/MacOS" inside AppleHDA kext
2. Copy the binary file "AppleHDA" inside the folder MacOS to Desktop
3. Open the binary file "AppleHDA" from the application "Hex fiend"
4. Press the shortcut keys "Command+F" in Hex fiend app to open Find and Replace boxes
 

For AppleHDA 10.8 or later:

Enter "84 19 D4 11" in Find Box (Apple codec) and
      "69 02 EC 10" in replace box (use your ‘Vendor Id’ value from codec dump)
Press "Replace All" button to replace

Note 1: For ADI 1984/1984B patch,  if your codec device id value is less "884" then you need this additional patch.

If your codec device id is less than "884" then you need to clear a check in AppleHDA, otherwise it will try to skip this and will load ALC885 codec instead.  Because in our example of ALC269 whose device id "0269 (0x10ec0269)" is less than "884", so we need to apply this patch which clear the comparison to use the ADI 1984 codec. 

Enter "84 08 EC 10" in Find box and 
      "00 00 00 00" in replace box
Press "Replace All" button to replace

Note 2: For ADI 1984B, you need this additional patch.

If you use Apple codec ADI 1984B to patch, then you have to clear ADI 1984 check for loading the codec ADI 1984B.

Enter "84 19 D4 11" in Find box and 
      "00 00 00 00" in replace box
Press "Replace All" button to replace

For AppleHDA in 10.7:

In 10.7, we need the below additional patch along with the patches used in 10.8 or greater.

Enter "83 19 D4 11" in Find Box and
      "00 00 00 00" in replace box
Press "Replace All" button to replace

5. After above replaces, save the file from File menu and copy the patched AppleHDA binary from desktop to back too "AppleHDA.kext/Contents/MacOS".
 
Binary patch is finished, next we need to patch the AppleHDA kext with the details of layout, codec id and calculated codec verbs from the AppleHDA guide.
 
Patching AppleHDA Kext:
1. Open the file Info.plist from the folder "AppleHDA.kext/Contents/Plugins/AppleHDAHardwareConfigDriver.kext/" using Xcode/Plist editor
2. Go to the section "IOKitPersonalities->HDA Hardware Config Resource->HDAConfigDefault->Item 0"  in info.plist
3. Edit the item "CodecID" to the decimal value of Vendor Id f
ound from codec dump, which is “283902569” (0x10EC0269) for ALC269 as shown in the below picture of the codec dump.

 

11270360876_85c4e0bc61.jpg

4. Edit the item “ConfigData" to the calculated codec verb data by following the AppleHDA complete guide

<01271cf0 01271d00 01271e00 01271f40 
01471c10 01471d01 01471e13 01471f90 
01771cf0 01771d00 01771e00 01771f40 
01871c20 01871d10 01871e81 01871f04 
01971c30 01971d01 01971ea0 01971f90 
01a71cf0 01a71d00 01a71e00 01a71f40 
01b71cf0 01b71d00 01b71e00 01b71f40 
01d71cf0 01d71d00 01d71e00 01d71f40 
01e71cf0 01e71d00 01e71e00 01e71f40 
02171c40 02171d10 02171e21 02171f04 01470c02>

5. Edit the item “LayoutID" to “28” for Realtek ALC2xx (or) â€œ12” for ALC8xx/IDT/Conexant and save the file.

6. Patch your DSDT with the layout value.

7. Everything is done, now you can install the patched AppleHDA kext and reboot.
 

DSDT Patch:

Add (or) edit the _DSM method to HDEF device in DSDT using below code (or) use the attached patch files in DSDT editor.

 

Note: Replace the value "1c" to "0c" if you are using layout12.

          Method (_DSM, 4, NotSerialized)
                {
                    Store (Package (0x06)
                        {
                            "hda-gfx", 
                            Buffer (0x0A)
                            {
                                "onboard-1"
                            }, 
                            "layout-id", 
                            Buffer (0x04)
                            {
                                 0x1C, 0x00, 0x00, 0x00
                            }, 
                            "PinConfigurations", 
                            Buffer (Zero) {}
                        }, Local0)
                    DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
                    Return (Local0)
                }

 

Hope this helps for many. Please let me know if you have any doubts and I will try to answer and help if possible. I've attached patched AppleHDA files of ALC269 for reference.

AppleHDA_10.8_Patched.zip

AppleHDA_Patched_10.8.2.zip

AppleHDA.kext_10.7.4.zip

AppleHDA.kext_Patched_10.7.2.zip

AppleHDA.kext_Patched_10.7.3.zip

My_Codec_Dumps.zip

Platforms and Layout Files 10.8.zip

Platforms_Layout_10.7_Updated.zip

HDEF_Layout12_Patch.txt

HDEF_Layout28_Patch.txt

AppleHDA_Patched_10.9.zip

AppleHDA_Patched_10.9.1.zip

AppleHDA_Patched_10.9.4.zip

  • Like 8
Link to comment
Share on other sites

How to enable HDMI Audio on HD4000 and ALC270?

 

I insert in DSM method in GFX0 and HDEF;  get 

10.04.13 14:40:34,452 com.apple.kextd[12]: Failed to load /System/Library/Extensions/AppleIntelSNBGraphicsFB.kext - (libkern/kext) kext (kmod) start/stop routine failed.
10.04.13 14:40:34,453 com.apple.kextd[12]: Load com.apple.driver.AppleIntelSNBGraphicsFB failed; removing personalities from kernel.
10.04.13 14:40:34,000 kernel[0]: OSMetaClass: Kext com.apple.driver.AppleIntelSNBGraphicsFB class HDCPCtrl is a duplicate;kext com.apple.driver.AppleIntelFramebufferCapri already has a class by that name.
10.04.13 14:40:34,000 kernel[0]: Kext com.apple.driver.AppleIntelSNBGraphicsFB start failed (result 0xdc00400a).
10.04.13 14:40:34,000 kernel[0]: Kext com.apple.driver.AppleIntelSNBGraphicsFB failed to load (0xdc008017).
10.04.13 14:40:34,000 kernel[0]: Failed to load kext com.apple.driver.AppleIntelSNBGraphicsFB (error 0xdc008017).

 

and graphics not start

Link to comment
Share on other sites

How to enable HDMI Audio on HD4000 and ALC270?

 

I insert in DSM method in GFX0 and HDEF;  get 

10.04.13 14:40:34,452 com.apple.kextd[12]: Failed to load /System/Library/Extensions/AppleIntelSNBGraphicsFB.kext - (libkern/kext) kext (kmod) start/stop routine failed.
10.04.13 14:40:34,453 com.apple.kextd[12]: Load com.apple.driver.AppleIntelSNBGraphicsFB failed; removing personalities from kernel.
10.04.13 14:40:34,000 kernel[0]: OSMetaClass: Kext com.apple.driver.AppleIntelSNBGraphicsFB class HDCPCtrl is a duplicate;kext com.apple.driver.AppleIntelFramebufferCapri already has a class by that name.
10.04.13 14:40:34,000 kernel[0]: Kext com.apple.driver.AppleIntelSNBGraphicsFB start failed (result 0xdc00400a).
10.04.13 14:40:34,000 kernel[0]: Kext com.apple.driver.AppleIntelSNBGraphicsFB failed to load (0xdc008017).
10.04.13 14:40:34,000 kernel[0]: Failed to load kext com.apple.driver.AppleIntelSNBGraphicsFB (error 0xdc008017).
 

and graphics not start

 

 

You've dependencies failed with GPU kext, also you have issues with HD3000 GPU kexts as well in the dependency issues whereas you're talking about HD4000 so I suggest you to first install vanilla kexts of GPU and let me see your dsdt along with kexts used and Mac version.

Link to comment
Share on other sites

Here is your Patched AppleHDA along with codec verbs & Path Maps calculated for your codec if you intend to learn yourself for future.


SPK: 1b -> 0x0d -> 0x03
10 01 13 99 -> 10 01 13 90
Decimal:27 -> 13 -> 3

SPDIF: 1e -> 06

HP: 0x21 -> 0x0c -> 0x02
20 10 21 04
Decimal:33 -> 12 -> 2

MIC: 0x19 -> 0x23 -> 0x08
40 09 a3 99 -> 40 01 a0 90
Decimal:25 -> 35 -> 08

EMIC: 0x18 -> 0x22 -> 0x09
30 18 a1 04 -> 30 10 81 04
Decimal:24 -> 34 -> 09

Codec Verbs:
01471cf0 01471d00 01471e00 01471f40
01771cf0 01771d00 01771e00 01771f40
01871c20 01871d10 01871e81 01871f04
01971c30 01971d01 01971ea0 01971f90
01a71cf0 01a71d00 01a71e00 01a71f40
01b71c10 01b71d01 01b71e13 01b71f90
01d71cf0 01d71d00 01d71e00 01d71f40
01e71cf0 01e71d00 01e71e00 01e71f40
02171c40 02171d10 02171e21 02171f04>

AppleHDA.kext.zip

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...