Jump to content
  • 0
Sign in to follow this  
Mirone

Guide How To Fix The Applehda For Your Codec

Question

 

. CHAPTER 1: getting information of the Codec.

 

. Intro: this guide is for those who want to use AppleHDA and/or trying to learn how it works.

 It is divided into several steps and let's address ?each one of them along the Guide. ?

 

. FIRST STEP: getting the codec information. There are other ways but in this guide we will explain how to obtain by Linux. Using a LiveCD

 Ubuntu or another distribution of your choice.(Note: Use the latest version of Linux as well as the Alsa drivers). ? ?

 in terminal type:

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

?should be generated a folder on your desktop named Codec_dump, save it in a location of your choice. ?in this folder in addition to the codec_dump

of your audio codec should also contain the codec_dump of your video card, in this case, HDMI ?but we will not use the same. ?

In OS X, we use the codec_dump to get a graphical ?interface, convert it to decimal (I'll explain later why),

get the verbs ?his codec and correct them for OS x. Install:?GraphViz

 

. SECOND STEP: Converting CodecGraph and CodecDump of hexadecimal to decimal:

 Copy and paste the file Codec_dump to the folder?CodecGraph?copy the ?folder CodecGraph to your Desktop

 and run the file named "commands" inside the same. Inside the folder codecgraph are generated?5 files:

 codec_dump_dec.txt.svg, ?codec_dump.txt.svg, codec_dump_dec.txt, verbs.txt, verbitdebug.txt.

 Later we will use the same to fix the AppleHDA.

 

.NOTE:If your file is with another name rename for "codec_dump.txt" before proceeding with the previous step.

 

.THIRD STEP:by default our onboard sound card is not recognized by OS X so that it is recognized should add device to our HDEF DSDT.aml.

 For this we use the following patches: HDEF or AZAL to HDEF on both the DTGP Method has to be present in the our DSDT.aml.

 We should use the?MacIASL??Patches you can find here.?This is a general audio injection and should work for all codecs:

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)                }            }
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 of AppleHDA. Kext.

 

So the AppleHDA work properly for our codec should make some modifications in the same plists.

So what are these modifications? ?If you look at it (right-click the/Show package contents)

,you will find in the Content folder of the main (non-info.plist touch it) and a folder of plugins.

There are plugins that we have to correct, but not all just the Info. plist from this one:

 

1 AppleHDAHardwareConfigDriver.kext?

2-platform.xml and layoutxxx.xml or Layoutxxx.xml (Present in the Resources folder)?
3-BinPatch
 
.AppleHDAHardwareConfigDriver. kext 
To edit this kext we obtain ConfigData/CodecVerbs.
Open the folder and you will see two files codecgraph one called verbs.txt and the other verbitdebug.txt , verbs.txt is our interest.
For in him we find our ConfigData/CodecVerbs up and corrected documents below. I will use my ALC887-VD Codec as an example.
verbs.txt:
Verbs from Linux Codec Dump File: codec_dump.txtCodec: 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?Line Out at Ext Rear ? ? ? ? ? ? ? ? ? ? ? ?20 0x14 ? 16859152 ? ? 01471c10 01471d40 01471e01 01471f01 ?? ? 1/8 ? Black ?Line Out at Ext Rear ? ? ? ?21 0x15 ? 0x01011012 ? 01571c12 01571d10 01571e01 01571f01?Line Out at Ext Rear ? ? ? ? ? ? ? ? ? ? ? ?22 0x16 ? 16867345 ? ? 01671c11 01671d60 01671e01 01671f01 ?? ? 1/8 ? ?Grey ?Line Out at Ext Rear ? ? ? ?23 0x17 ? 0x01012014 ? 01771c14 01771d20 01771e01 01771f01?Mic at Ext Rear ? ? ? ? ? ? ? ? ? ? ? ? ? ? 24 0x18 ? 27367504 ? ? 01871c50 01871d98 01871ea1 01871f01 ??Mic at Ext Front ? ? ? ? ? ? ? ? ? ? ? ? ? ?25 0x19 ? 44145760 ? ? 01971c60 01971d9c 01971ea1 01971f02 ??Line In at Ext Rear ? ? ? ? ? ? ? ? ? ? ? ? 26 0x1a ? 25243743 ? ? 01a71c5f 01a71d30 01a71e81 01a71f01 ??HP Out at Ext Front ? ? ? ? ? ? ? ? ? ? ? ? 27 0x1b ? 35736608 ? ? 01b71c20 01b71d4c 01b71e21 01b71f02 ?? ? 1/8 ? Black ?Speaker at Ext Rear ? ? ? ? 28 0x1c ? 0x411111f0 ? 01c71cf0 01c71d11 01c71e11 01c71f41Optical ? White ?Line Out at Ext N/A ? ? ? ? 29 0x1d ? 0x4005e601 ? 01d71c01 01d71de6 01d71e05 01d71f40Optical ?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?Line Out at Ext Rear ? ? ? ? ? ? ? ? ? ? ? ?20 0x14 ? 16859152 ? ? 01471c10 01471d40 01471e01 01471f01 ?? ? 1/8 ? Black ?Line Out at Ext Rear ? ? ? ?21 0x15 ? 0x01011012 ? 01571c70 01571d10 01571e01 01571f01?Line Out at Ext Rear ? ? ? ? ? ? ? ? ? ? ? ?22 0x16 ? 16867345 ? ? 01671c80 01671d60 01671e01 01671f01 ?? ? 1/8 ? ?Grey ?Line Out at Ext Rear ? ? ? ?23 0x17 ? 0x01012014 ? 01771c90 01771d20 01771e01 01771f01?Mic at Ext Rear ? ? ? ? ? ? ? ? ? ? ? ? ? ? 24 0x18 ? 27367504 ? ? 01871c50 01871d90 01871ea1 01871f01 ??Mic at Ext Front ? ? ? ? ? ? ? ? ? ? ? ? ? ?25 0x19 ? 44145760 ? ? 01971c60 01971d90 01971ea1 01971f01 ??Line In at Ext Rear ? ? ? ? ? ? ? ? ? ? ? ? 26 0x1a ? 25243743 ? ? 01a71ca0 01a71d30 01a71e81 01a71f01 ??HP Out at Ext Front ? ? ? ? ? ? ? ? ? ? ? ? 27 0x1b ? 35736608 ? ? 01b71c20 01b71d40 01b71e21 01b71f01 ?Optical ? White ?Line Out at Ext N/A ? ? ? ? 29 0x1d ? 0x4005e601 ? 01d71cb0 01d71de0 01d71e05 01d71f40Optical ?Orange ?SPDIF Out at Ext Rear ? ? ? 30 0x1e ? 0x01456130 ? 01e71c30 01e71d60 01e71e45 01e71f01--------------------------------------------------------------------------------------------------------

About NodeId (NID) 0x14 in hexadecimal, in decimal: 20

1/8 Green Line Out at Ext Rear 20(Decimal) 0x14(Hexadecimal)   0x01014010 01471c10 01471d40 01471e01 01471f01
.THE STANDARD VERBS FOR HIM:?01471c10 01471d40 01471e01 01471f01?
?
01471c10:?
01471c10 = CAD (Codec Address)?
014 71c10 NID (NodeID)?
01471c10 71 = Commands verb like "c", "d", "e", "f"?
01471c10 Data = verb?
And the same for the rest. I think Cad, NID and verbal commands are very simple to understand:

 

the first 2 you take the dump Linux, and the commands are standard 71c, 71d, 71e, 71f.
 
1- Editing AppleHDAHardwareConfigDriver. kext (info.plist) ??
(right-click the/show package contents) Open the File with a Plist editor. ?
Navigate to the key IOKitPersonalities/HDA Hardware Config ResourceHDAConfigDefault.

?

1.a- CodecID: Put your codec ID in decimal numbers (Hexadecimal) 0x10ec0887--> 283,904,135 (Decimal)

?

2- CONFIGDATA: Here we put our ConfigData/Verbs codec which corrected anterirormente.

They are in the verbit.txt file, we use the Modified Verbs for example: 01471c10 01471d40 01471e01 01471f01 corresponding to a LineOut (line output).

In this case Speaker, and the same for the ? other inputs/outputs.

 

3- FUNCGROUP: should always be 1.

 

4- LAYOUTID: by default is 12 but can be any other number since you also change the number of the layout in your DSDT.aml

 

* NOTE: in the kexts from Mountain Lion on so we can use a layout that already has in own kext and not others like layout887.xml

as was used in the kexts from Lion.

 

 

2.a- EDITING PLATFORM.XML.ZLIB AND LAYOUTXXX.XML.ZLIB (present in the resources folder)

 

This is the trickiest part.

Within the Resources folder you will find several layouts.xml.zlib and Platforms.xml.zlib.
we will edit both according to the previous fixes ie in AppleHDAHardwareConfigDriver.kext
use the layout12 so let's make the due editions about this.
 
1- CODECID: PUT the ID of your codec in 0x10ec0887 Decimal Numbers (Hex) -> 283 904 135 (Decimal).
?Use the calculator mode Programmer to do this conversion. Calculator / View / Programmer.
 
2- PATHMAPID: Change to 1.
 
Within each key there are settings corresponding to its components:

 

CodecID: This is where we insert the ID of our codec as Decimal 0x10ec0887 (Hex) -> 283 904 135 (Decimal). 

 
Headphone: Normally this key has no value, although it is necessary in the case of laptops.
 
Inputs: Are the connections (jacks) output in this case, LineIn and Microphone.
 
IntSpeaker: Corresponds to velores of speakers.
 
LineIn: Output connection, you must use a MUTEGPIO.
 
Lineout: Normally this key has no value.
 
Mic: Output connection, you must use a MUTEGPIO.
 
Outputs: Displays the connections of output.
 
SPDFIn: Regarding Digital Output (Optical)
 
What had to fix in Layout12.xml is already completed.
Now let's edit the Platforms.xml is here that one finds the pathmaps. Within Key Pathmaps there are other keys
they are numbered and each corresponds to a specific layout.xml.zlib for example used within the same layout12.xml.zlib 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) -> Mixer- Audio> Audio Output
So we have to find a node Pin Complex (NodeID), an Audio Mixer node and finally a node of audio output
For input devices, the pathmap follow this pattern:
Pin-Complex (NodeID)> Audio Selector / Mixer- entry> 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 generated in codec_dump_dec.txt.svg codegraph folder you will see something like this:
 
note 20 (Pin complex) -> 12 (node Audio Mixer) -> 2 (node Audio Output)
from there we already have our pathmap formed to lineout (in the case node20 is an internal speaker).
We will do the same for the rest of our pathmaps.?
 Note: Note that in the above screen capture attached you can see that the solid lines are the links of nodes.
An example of Pathmaps Mic (External):?
 note 24 (Pin complex) -> 35 (node Audio Mixer) -> 9 (node Audio Output)?
Note: Usually starts unlike 9 -> 34 -> 24?
 The pathmaps for the codec used as an example were as follows:
 
9-34-24 = External Mic
9-34-25 = Front Mic
8-35-26 = Line Output
20-12-2 = Internal Speakers
27-38-37 = HeadPhone
? 23-15-5 = Line Output
? 22-14-4 = Line Output
? 23-13-3 = Line Output
? 30-6 = Digital Output
 
3- BINPATCH:?
 
Starting with version 10.6.3 of Snow Leopard was also necessary to correct the binary file Applehda.kext he is inside the MacOS folder
lies within the Kext for making this correction we use the script done by bcc9.?
 Copy the folder to the desktop and already with Applehda.kext edit and installed in S/L/E
 type the following commands in Terminal:
cd ~/desktop/patch-hda./patch-hda.pl 10ec0887?

? * NOTE: open the folder patch-hda and after the patch file-hda-codecs.pl inside him lies all the codecs supported by the script for more information:

? ??http://www.insanelym...-for-osx107108/?A hint if your codec is not supported by the script you can try to correct manually using a binary editor

 HexFiend as and replace one of the codecs used for its correction. In the example above was corrected the binary for the codec ALC887-VD

 if you are correct for your codec is required to override the codec supported by your codec id.

 In binary, they are written from right to left i.e. 10ec0887 = 8708ec10.

 
* IMPORTANT: ?from the Mountain Lion the AppleHDA has a new structure and the files are compressed into zlib. to unzip and edit these files use the Zlib.
This application is based on the RevoGirl script, it makes the process of zlib files of AppleHDA.
kext to decompress/compress easier. Just drag the file zlib. The application and It will unpack or drag the xml file.
And it will compress to. zlib?Download Zlib
 
CREDITS:?The King, bcc9, RevoGirl (R.I.P), EMlyDinEsH, Munky, TimeWalker, Signal64 and others.
 
?

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0

There's a hardcoded path to /Users/Mirone/Desktop in ?your comandos.sh file, is that deliberately?
?
Also there some typos in you're tutorial:

NOTE:?If your file is with another renowned name for "codec_dump.txt" before proceeding with the previous step.

?
Should be:
If your file has another name you must rename?to codec_dump.txt
?

Open the folder and you will see two files codecgraph one called verbs.txt and the other verbitdebug.txt , verbit.txt is our interest.


Should be:
verbit.txt -> verbs.txt

Edited by zooiit

Share this post


Link to post
Share on other sites
  • 0

Hi, my zlib files are not editable. What should I do ?
See example:

bash-3.2# cat layout10.xml.zlibx[R8}f&KR2*IgOb5u]دv-Blwn 짧$?,h_~><^Mv.ڭjv?.HN)i?Mɻ~zo9QO?qԞt;߬u*NtRwE$M*Nn/kz^siKsq3,ze\~6Lldly<A9ՔM1e<vRq7)LJHQ+$Nk!e8Nς`fuP97                                                                                 α{]I&0=Js6Ynn2iGĦ,h6.Ж                 KOϷPw\la{UtIG:WzDa                                                      1+.vf[2'͞X5֜o\sF\s)2F9WDճkz0z#AvSiL9nl6c1d6kfs.|qC5aiB)VslYllWzƩ3p7HIQ9U$޹.n"TY!j7EA$1)ÑOqP)JHg^)^g4G!EWjbϓx2Ų;                                                               whv0˿5F Gs`aip!`3<yhǑwj!y 3PX&ӄqd?(O{H@`0S  Hp;,y@)t?ZzP!	bLH9eك.!aj(!ce_P"8's7Iأ{	Pq*lx2\ҙ?F2dP-(J0Xjhzi?Hgm9pח8K6LlUܰwKU@Acի	Zl^.!|~u`!f/`sf	lןjs1w:v^lvk9œ`nl	9gV}a7UR9zrft[%ibe_ƽ``?fz{}@_pzXQF+}dQ/v7*|[:g=!σ>tr;m}gneZRҸIM?%?hn0@̎w)ب)p}8xt*Rg,q[jbash-3.2# !G)Ztl\

Share this post


Link to post
Share on other sites
  • 0

Hi i keep getting this error :-error: codec_dump.txt not a codec description when trying to run codecgraph.

Any ideas?

extract its codec_dump again
using a recent version of Ubuntu.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.