Jump to content
EMlyDinEsH

EAPD/Jack sense Fix (No sound and jack sense issue after sleep)

Recommended Posts

Hi,
 
 This is a standalone kext which i've created to do the job similar to patched IOAudioFamily kext for sending EAPD codec verb at boot and after sleep to power up the EAPD found in some audio codecs (which has EAPD in their output nodes of Speakers and Headphones) for working audio .
 
    This kext functions similar to TimeWalker solution (Thanks for the idea), but the implementation is based on my own IOAudioFamily patch and workarounds to address other problems too i've faced. My solution solves the issues of audio and Jack sense not working after 30 sec audio idle from sleep (which happens if there was no audio stream active after sleep within 30 sec then AppleHDA makes the codec to power down EAPD for some reason and loses codec states). So, I've implemented a workaround to fix this by sending a mute/un-mute bezel notification which generates a pop sound to start an audio stream and so AppleHDA won't lose Jack sense and audio. And my kext also uses new workaround which is checking the EAPD status in background and applies fix when audio playback is detected to power up EAPD which gets powered down after few secs of audio idle in AppleHDA v2.6 or later after sleep.

 

I've found new solution to solve all the problems we face after sleep using a AFG codec reset. The reason why we have these problems after sleep are due to the codec states are not properly initialized, so we need a Codec reset to initialize them to proper states for working with AppleHDA without problems.

 

Note: Even though background processing and JackSense fix are not needed anymore but i have them in kext as an alternate way to fix if there are any problems again in future.
 
 

Finding whether your codec has EAPD or not:
Try to get the codec dump from linux using the following steps:
 
1. Get into any of the Linux distro's and enter the following commands(any one of them has your codec dump) in terminal to get the codec dump at Desktop in text format:

cat /proc/asound/card0/codec#0 > ~/Desktop/codec_dump.txt
(or)
cat /proc/asound/card0/codec#1 > ~/Desktop/codec_dump.txt
(or)
cat /proc/asound/card0/codec#2 > ~/Desktop/codec_dump.txt

2. Open the text file and check for the EAPD by looking at the Nodes with [Pin Complex] and the control name of "Speaker Playback Switch" and "Headphone Playback Switch". To get the idea, take a look at the below example which has EAPD in Speaker node.

Node 0x14 [Pin Complex] wcaps 0x40018d: Stereo Amp-Out
Control: name="Speaker Playback Switch", index=0, device=0
ControlAmp: chs=3, dir=Out, idx=0, ofs=0
Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
Amp-Out vals: [0x00 0x00]
Pincap 0x00010014: OUT EAPD Detect
EAPD 0x2: EAPD
Pin Default 0x99130110: [Fixed] Speaker at Int ATAPI
Conn = ATAPI, Color = Unknown
DefAssociation = 0x1, Sequence = 0x0
Misc = NO_PRESENCE
Pin-ctls: 0x40: OUT
Unsolicited: tag=00, enabled=0
Connection: 2
0x0c* 0x0d

3. Write down the node values of Speaker, Headphone and External Mic then convert it to decimal value.

 

4. Note down the nodes which one has EAPD by looking at Speaker/Headphone nodes. 

 

5. You need to note down the codec address value as well, which you can get at the beginning of the codec dump  from the line "Address" and it will look like below:

Codec: Realtek ALC269VB
Address: 0
AFG Function Id: 0x1 (unsol 1)
Vendor Id: 0x10ec0269
Subsystem Id: 0x10431a33
Revision Id: 0x100100

 
Editing plist file to enable the Fix for your codec:
Open the "info.plist" file inside the EAPDFix.kext and look at the section "IOKitPersonalities->EAPDFix->Preferences".  You need to config the following values from there:

  • HDEFAddress - Add the address of the HDEF device if its not listed in plist.
  • SleepFixDelay - Delay for enabling EAPD after sleep in ms, default 1500 ms. (Some systems sleep wakeup routine needs more time, so try to increase this delay if its not working).
  • BootFixDelay - Delay for enabling EAPD at sleep in ms, default 1000 ms. (Some systems load AppleHDA late after my kext is loaded and might need need some delay for loading after AppleHDA, so try to increase this if its not working).
  • FixType - There are four fix types in my kext which you can select here with the values 1-4.
  • VerbSendCount - This value sets the number of times EAPD verb needs to be be sent in Fix type 1.
  • IntervalToCheck - Interval for background EAPD status check, default 1500 ms. It might be needed to fix EAPD issue from AppleHDA 2.6 or greater.
  • ResetCodec - Enable codec reset to initialize properly at boot, interrupted sleep and after sleep.
  • BackgroundCheck - Enables background EAPD status check after sleep, set this to "Yes/true" or "No/false" (only for AppleHDA 2.6 or greater).
  • SkipBootBgCheck - Enables background EAPD status check at boot, set this to "Yes/true" or "No/false" (only for AppleHDA 2.6 or greater).
  • JackSenseFix - set this to "Yes/true" only if you have the issue of Jack sense not working and no audio after 30 secs from sleep (from v2 mostly don't need this anymore).

FixType:

I've four types of fixes in my kext to solve EAPD and Jack sense problems which can be configured in plist entry "FixType". They are:

 

1. Fix Type 1

   Will send the verb once to enable EAPD/Jack Sense at boot and after sleep.

2. Fix Type 2

    Will send the verb to the number times its configured in plist entry "VerbSendCount" to enable EAPD/Jack Sense.

3. Fix Type 3

    Will do the background status check to enable Jack sense and EAPD when its disabled.

4. Fix Type 4

    Will do the background status check with manual I/O switch to enable Jack sense and EAPD when its disabled.

 

NOTE: This is optional from v2.2

My driver auto detects the nodes from v2.2, but for some reason if it fails then provide the following values here in the plist "IOKitPersonalities->EAPDFix->LaptopCodecValues".

  • CodecAddress - enter the value you got from the codec dump for the address.
  • Speakers - enter the decimal value of Speaker node.
  • Headphones - enter the decimal value of Headphone node.
  • ExternalMic - enter the decimal value of External mic node.
  • InternalMic - enter the decimal value of Internal mic node.
  • SpkHasEAPD - set this to "Yes" if speakers has EAPD, otherwise "No".
  • HpHasEAPD - set this to "Yes" if Headphones has EAPD, otherwise "No".

Note: Enabling JackSenseFix does volume mute/un-mute bezel notification after sleep for starting an audio stream in order wake the codec for fixing the issues we face after 30 sec from sleep.
 

NOTE: You need to provide Speaker, Headphone and External Mic node values in v1.5 or later, and InternalMic too in v2 or later for better support.

 
 

If you have problem with my kext then PM me for support.
 

 

Supports Mac OS X 10.6.8 or greater

 

Change Log:

Update - v2.3.5 Released

  • Improved auto detection of codec nodes 
  • Improved processing
  • Added plist option to control codec reset
  • Updated plist option to add HDEF addresses (skylake support, you can add future chipsets also)
  • Minor bug fixes and optimizations

Update - v2.3

  • Improved auto detection of EAPD Capable nodes (so you don't have to config plist anymore for nodes)
  • Added support for desktop codecs
  • Added support for creative codec
  • Minor bug fixes and optimizations

Update - v2.2

  • Improved support for 10.11
  • Added auto detection of EAPD Capable nodes (so you don't have to config plist anymore for nodes)
  • Updated plist options for fix delays
  • Minor bug fixes and optimizations.

Update - v2.1

  • Updated support for 10.11 (Fixes Kernel Panic)
  • Minor bug fixes and optimizations.

Update - v2.0.1

  • Minor bug fixes and optimizations.

Update - v2.0 

  • Uses new method to fix the EAPD and Jack sense problem
  • Added option to choose the old and new fixes in plist
  • Minor bug fixes and optimizations.

Update - v1.7.1 

  • Added plist option to choose the HDEF address for chipsets with different address.

Update - v1.7 

  • Fixed some bugs to improve the performance by reducing time needed for fix
  • Reduced interval to check the status from 5 to 4 sec
  • Optimized the code.

Update - v1.6 

  • Reworked code for better
  • Mad some changes to plist options to organize better
  • Fixed few bugs and optimized the code.

Update - v1.5 

  • Added a new workaround for fixing EAPD problem from AppleHDA 2.6 or later in 10.9.2 or greater.
  • Updated the old EAPD fixing method to better handle for other AppleHDA versions.
  • Works better for fixing Jack sense after sleep.
  • Optimized the code.

Update - v1.3

  • Fixed the Volume notification bug which was generating the character 's' after sleep.
  • Fixed an issue found in Haswell notebooks where EAPD Fix was not working
  • Optimized the code

Update - v1.2

  • Fixed the audio sense volume pop-up not working in Lion
  • Improved support 
  • Fixed an issue of kext not loading properly sometimes

First Release - v1.0

  • Implementation based on my IOAudioFamily patch
  • Fixes an issue(using a workaround) with ALC269 codecs, which doesn't work if there is no Audio stream within 30sec after sleep

 

PS: Please consider a small donation if possible which helps me and allows to spend some time on this for future updates.
 
Paypal:9157339471_69e721d064_o.png

 

Thanks to user Sherlocks for helping in beta tests for long time.

CREDITS: TimeWalker for the standalone kext Idea

EAPDFix_v2.0.1.zip

EAPDFix_v2.1_Final.zip

EAPDFix_v2.2_Final.zip

EAPDFix_v2_3_Final.zip

EAPDFix_v2.3.5.zip

Edited by Hervé
Updated kext to v2.3.5
  • Like 4

Share this post


Link to post
Share on other sites

There are codec verbs that can be used to mute and unmute the amps as well as the entire codec widgets, so there is no need to implement the entire HID class and emulate mute tickle. I too have the "30sec delay" issue which always existed for me but I never knew the cause of jack sensing suddenly failing..

I can't wrap my head around it sadly as I have very little experience in coding IOKit stuff... all the codec verbs are defined long ago in linux  hda-verb-0.3 .. it was used at some point to control HDA codecs in a matter we currently do. 

So for EAPD update this had to be called from elevated terminal:

 

hda-verb /dev/snd/hwC0D0 0x14 SET_EAPD_BTLENABLE 2

Where:

- hwCOD0 = codec address

- 0x14 = output (speaker) node

- SET_EAPD_BTLENABLE = the command verb 0x70c

- 2 = PCM parameter 0x02

So it ends up sending 0x01470c02 to the codec.. looks familiar, doesn't it ?

 

Take a look at the sources of hda-verb, maybe you can come up with more elegant solution.

 

Also, please consider removing the IOLog outputs (make them debug only) from your kext, the amount of text it spits out is just ridiculous for a kext that simple. Your human-readable copyright is more than enough, we have ton of kexts that want to shine copyright IOLog messages at boot that it's just getting out of hands.. I don't want to know (and see) any of the stuff that is happening behind the curtains, make it just do the job and that's it .. same goes for BT uploader kext.

Share this post


Link to post
Share on other sites

There are codec verbs that can be used to mute and unmute the amps as well as the entire codec widgets, so there is no need to implement the entire HID class and emulate mute tickle. I too have the "30sec delay" issue which always existed for me but I never knew the cause of jack sensing suddenly failing..

I can't wrap my head around it sadly as I have very little experience in coding IOKit stuff... all the codec verbs are defined long ago in linux  hda-verb-0.3 .. it was used at some point to control HDA codecs in a matter we currently do. 

So for EAPD update this had to be called from elevated terminal:

hda-verb /dev/snd/hwC0D0 0x14 SET_EAPD_BTLENABLE 2

Where:

- hwCOD0 = codec address

- 0x14 = output (speaker) node

- SET_EAPD_BTLENABLE = the command verb 0x70c

- 2 = PCM parameter 0x02

So it ends up sending 0x01470c02 to the codec.. looks familiar, doesn't it ?

 

Take a look at the sources of hda-verb, maybe you can come up with more elegant solution.

 

Also, please consider removing the IOLog outputs (make them debug only) from your kext, the amount of text it spits out is just ridiculous for a kext that simple. Your human-readable copyright is more than enough, we have ton of kexts that want to shine copyright IOLog messages at boot that it's just getting out of hands.. I don't want to know (and see) any of the stuff that is happening behind the curtains, make it just do the job and that's it .. same goes for BT uploader kext.

 

 Thanks for your suggestion. I already did take a look at the hda-verb source mute verbs before but couldn't get it work, will try to look at that once again and will reduce/remove Logs from my kexts.

Share this post


Link to post
Share on other sites

Edit: Same pop sound as Dolnor's fix after some tests.

 

----------

 

My patched applehda for ALC665 works fine now, with just a tiny pop sound at every startup.

 

Dolnor's fix does work either but with a very loud pop sound at every startup.

 

 

 Thanks for your suggestion. I already did take a look at the hda-verb source mute verbs before but couldn't get it work, will try to look at that once again and will reduce/remove Logs from my kexts.

Share this post


Link to post
Share on other sites

Hello.

 

My codec ALC275 and already pached AppleHDA. All working, but after second st-by no sound, can somebody help me?

 

What you mean after second st? Which version of Mac OSX you're using?

Share this post


Link to post
Share on other sites

Edit: Same pop sound as Dolnor's fix after some tests.

 

----------

 

My patched applehda for ALC665 works fine now, with just a tiny pop sound at every startup.

 

Dolnor's fix does work either but with a very loud pop sound at every startup.

 

What you mean pop sound? does it pop always (or) just once afer boot/sleep? Explain this problem clearly.

Share this post


Link to post
Share on other sites
Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Loading...

×
×
  • Create New...