Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MuteGPIO and AMP Values ALC255 + Add Layout21 for ALC272 Lenovo All In One PC C440 (CodecCommander.kext must be installed in Library/Extensions) #485

Merged
merged 5 commits into from Dec 11, 2019

Conversation

andreszerocross
Copy link
Contributor

Update MuteGPIO and AMP Values ALC255 layoutID = 21 by Andres ZeroCross

Andres ZeroCross added 5 commits December 9, 2019 16:59
Add MuteGPIO for Internal Mic and External Mic by Andres ZeroCross
Update AMP Values ALC255 by Andres ZeroCross
PinConfig for ALC272 Layout 21 by Andres ZeroCross (Lenovo All In One PC C440)
Add Path Layout and Platform for LayoutID 21 for Lenovo All In One PC C440 by Andres ZeroCross
Platform21.xml and Layout21.xml for ALC272 by Andres ZeroCross for Lenovo All In One PC C440
@andreszerocross andreszerocross changed the title Update MuteGPIO and AMP Values ALC255 Update MuteGPIO and AMP Values ALC255 + Add Layout21 for ALC272 Lenovo All In One PC C440 (CodecCommander.kext must be installed in Library/Extensions) Dec 9, 2019
@Sniki
Copy link
Contributor

Sniki commented Dec 9, 2019

@andreszerocross why would you need CodecCommander.kext installed into Library/Extensions ?
It works just fine into EFI/OC/kexts ; EFI/Clover/kexts/Other
Is there a specific reason for that ?, just curious to know.

I use it on all my hacks because all of my laptops/desktop have codecs that need it.
As for hda-verb installing it on usr/local/bin should be fine as it doesn't ask for Volume to be mounted for RW.

@andreszerocross
Copy link
Contributor Author

No, it wouldn't work if you put CodecCommander in EFI/CLOVER/Kexts/Other or OC/Kexts. I have Creative CA0132, CodecCommander is necessery. Without this,, i have "annoying high pitch sound" in speaker. AFAIK, CodecCommander.kext must be installed in Library/Extensions.

ALC272 of AIO Lenovo PC C440 must put CodecCommadner.kext in Library/Extensions, if not there is no sound from Internal Speaker (but output is detected,).

I made new resource because node id of internal speaker is 0x1A not 0x14.

I have found 2 codec with same habit (Current ALC272 in AIO Lenovo and ALC298 in notebook), need CodecCommander in Library/Extensions and rebuild kext cache, then sound will work.

Sorry for bad english

@vandroiy2013 vandroiy2013 merged commit 8b7a532 into acidanthera:master Dec 11, 2019
@vit9696
Copy link
Collaborator

vit9696 commented Dec 11, 2019

Why do we merge stuff that needs CodecCommander? AppleALC has everything that fully replaces CodecCommander, it makes no sense to me to add borked resources that suddenly do require this legacy again?

@Sniki
Copy link
Contributor

Sniki commented Dec 11, 2019

@vit9696 since you joined here, for example for ALC292 codec we need this configuration override SSDT for CodecCommander.kext:

DefinitionBlock ("", "SSDT", 1, "Sniki", "_ALC292", 0)
{
    External(_SB.PCI0.HDEF, DeviceObj)
    Name(_SB.PCI0.HDEF.RMCF, Package()
    {
        "CodecCommander", Package()
        {
            "Custom Commands", Package()
            {
                Package(){}, // signifies Array instead of Dictionary
                Package()
                {
                    // 0x15 SET_UNSOLICITED_ENABLE 0x83
                    "Command", Buffer() { 0x01, 0x57, 0x08, 0x83 },
                    "On Init", ">y",
                    "On Sleep", ">n",
                    "On Wake", ">y",
                },
                Package()
                {
                    // 0x1a SET_PIN_WIDGET_CONTROL 0x24
                    // Node 0x1a - Pin Control (In Enable / VRefEn)
                    "Command", Buffer() { 0x01, 0xa7, 0x07, 0x24 },
                    "On Init", ">y",
                    "On Sleep", ">n",
                    "On Wake", ">y",
                },
            },
            "Perform Reset", ">n",
            "Send Delay", 10,
            "Sleep Nodes", ">n",
        },
    })
}

I couldn't find proper evidence for this so can you or any other acidanthera member provide just a small example on how should i port these fixes into AppleALC, on what place should i put those because im a bit confused and couldn't figure out myself.

There are many codecs on AppleALC merged like this with the use in combination with CodecCommander.kext in mind.

I would really like to know how to do add those values into AppleALC.kext and get rid of CodecCommander.kext for good for the sake or a simpler and cleaner setup in general.

Thanks.

Additional note: we use AppleALC layout-id 28 comment: vusun123 - ALC 292 for Lenovo T440

@vit9696
Copy link
Collaborator

vit9696 commented Dec 11, 2019

@roddy20 could you please provide the brief details on the matter? You know more than I do.

@andreszerocross
Copy link
Contributor Author

My codec Audio is Creative CA0312, with layoutid 4 i need to set this profile to overide custom command of CodecCommander.kext

`Name (RMCF, Package (0x02)
{
"CodecCommander",
Package (0x0A)
{
"Custom Commands",
Package (0x09)
{
Package (0x00){},
Package (0x08)
{
"Command",
Buffer (0x04)
{
0x00, 0x17, 0x16, 0x1F
},

                            "On Init", 
                            ">n", 
                            "On Sleep", 
                            ">n", 
                            "On Wake", 
                            ">y"
                        }, 

                        Package (0x08)
                        {
                            "Command", 
                            Buffer (0x04)
                            {
                                 0x01, 0x57, 0x17, 0x0D                         
                            }, 

                            "On Init", 
                            ">n", 
                            "On Sleep", 
                            ">n", 
                            "On Wake", 
                            ">y"
                        }, 

                        Package (0x08)
                        {
                            "Command", 
                            Buffer (0x04)
                            {
                                 0x01, 0x57, 0x18, 0x24                         
                            }, 

                            "On Init", 
                            ">n", 
                            "On Sleep", 
                            ">n", 
                            "On Wake", 
                            ">y"
                        }, 

                        Package (0x08)
                        {
                            "Command", 
                            Buffer (0x04)
                            {
                                 0x00, 0x17, 0x17, 0x1E                         
                            }, 

                            "On Init", 
                            ">y", 
                            "On Sleep", 
                            ">n", 
                            "On Wake", 
                            ">y"
                        }, 

                        Package (0x08)
                        {
                            "Command", 
                            Buffer (0x04)
                            {
                                 0x00, 0x17, 0x15, 0x14                         
                            }, 

                            "On Init", 
                            ">y", 
                            "On Sleep", 
                            ">n", 
                            "On Wake", 
                            ">y"
                        }, 

                        Package (0x08)
                        {
                            "Command", 
                            Buffer (0x04)
                            {
                                 0x01, 0x17, 0x07, 0x44                         
                            }, 

                            "On Init", 
                            ">n", 
                            "On Sleep", 
                            ">n", 
                            "On Wake", 
                            ">y"
                        }, 

                        Package (0x08)
                        {
                            "Command", 
                            Buffer (0x04)
                            {
                                 0x01, 0x27, 0x07, 0x24                         
                            }, 

                            "On Init", 
                            ">n", 
                            "On Sleep", 
                            ">n", 
                            "On Wake", 
                            ">y"
                        }, 

                        Package (0x08)
                        {
                            "Command", 
                            Buffer (0x04)
                            {
                                 0x01, 0x57, 0x0A, 0x00                         
                            }, 

                            "On Init", 
                            ">y", 
                            "On Sleep", 
                            ">n", 
                            "On Wake", 
                            ">y"
                        }
                    }, 

                    "Perform Reset", 
                    ">y", 
                    "Perform Reset on External Wake", 
                    ">n", 
                    "Sleep Nodes", 
                    ">n", 
                    "Update Nodes", 
                    ">n"
                }
            })`

If i don't use that, I will get high pitch noise in my speaker. I used 5.1 Speaker Configuration.
AFAIK, AppleALC.kext only support for EAPD wake, but how about other custom command???

@roddy20
Copy link
Collaborator

roddy20 commented Dec 17, 2019

for
"Command",
Buffer (0x04)
{
0x01, 0x57, 0x17, 0x0D
},

                        "On Init", 
                        ">n", 
                        "On Sleep", 
                        ">n", 
                        "On Wake", 
                        ">y"

add 0157170D to WakeConfigData
and enable WakeVerbReinit
at wakeup this will send to node 0x015 GPIO direction verb (717) with parameter 0D
add all the other commands in the similar way
01571824
718 is GPIO Wake Enable
0017171E
etc

well known example is 01470C02 for a lot of Realtek codecs
node 0x014
EAPD Enable verb 70C
Enabled 02

all possible values for Verbs and their parameters are described in
High Definition Audio Specification
https://www.intel.com/content/www/us/en/standards/high-definition-audio-specification.html

@andreszerocross
Copy link
Contributor Author

andreszerocross commented Dec 17, 2019

for
"Command",
Buffer (0x04)
{
0x01, 0x57, 0x17, 0x0D
},

                        "On Init", 
                        ">n", 
                        "On Sleep", 
                        ">n", 
                        "On Wake", 
                        ">y"

add 0157170D to WakeConfigData
and enable WakeVerbReinit
at wakeup this will send to node 0x015 GPIO direction verb (717) with parameter 0D
add all the other commands in the similar way
01571824
718 is GPIO Wake Enable
0017171E
etc

well known example is 01470C02 for a lot of Realtek codecs
node 0x014
EAPD Enable verb 70C
Enabled 02

all possible values for Verbs and their parameters are described in
High Definition Audio Specification
https://www.intel.com/content/www/us/en/standards/high-definition-audio-specification.html

It won't work, i have tried this for CA0132 with LayoutID = 4

  1. I add "0017161F 0157170D 01571824 0017171E 00171514 01170744 01270724 01570A00 " for WakeConfigData and set WakeVerbReinit = YES then Recompile new AppleALC.kext and use it.. Then i remove CodecCommander.kext from L/E and remove CustomCommand from SSDT. Result = High Pitch SOund Speaker / No 5.1 Sound

  2. I add "01170744 01270724 01570A00" to "ConfigData" (because other Values is existing, so i just need to add these) and add "0017161F 0157170D 01571824 0017171E 00171514 01170744 01270724 01570A00" for WakeConfigData and set WakeVerbReinit = Yes then Recompile new AppleALC.kext and use it. Then i Remove CodecCommander.kext from L/E and remove CustomCommand from SSDT. Result = No Audio Device except HDMI Audio.

  3. Just use AppleALC.kext Release version and put CodecCommander.kext in OC/Kexts and keep using CustomCommand in SSDT. Result = High Pitch Sound from speaker and no 5.1 Audio Output

So, we still need CodecCommander.kext in Library/Extensions and somehow some verb can't be sent with AppleALC.kext.
image

@Sniki
Copy link
Contributor

Sniki commented Dec 17, 2019

@roddy20 i do confirm the same as @andreszerocross said.

I just added the verbs but high pitch sound when i plug headphones and no audio output.
External Microphone (Line-In) doesn't show up and stays in Internal Microphone

For my codec Realtek ALC3232 (know as ALC292) aside of CodecCommander + AppleALC to have perfect audio inputs and outputs i also need ALCPlugFix which i have a fork with customized entries for my specific audio codec.

See here: https://github.com/Sniki/ALCPlugFix

The commands that you modify according to the specific codec are here:
https://github.com/Sniki/ALCPlugFix/blob/4140e54da788cf6cf6e1642e7701cfaec6c6b7de/ALCPlugFix/main.m#L136-L137

However since you guys said all those are supported by AppleALC itself i wanted to get rid of CodecCommander to have a cleaner setup (-1 SSDT, -1 kext, -2 config.plist entries).

However i believe ALCPlugFix is still a necessity although i believe it's something that can be added into AppleALC as well so we have AppleALC as the perfect ALL IN ONE solution for audio.

But it is not working for me without CodecCommander.kext
I can provide logs if you want just let me know what logs and what boot-args you need to provide them.

Thanks

@Sniki
Copy link
Contributor

Sniki commented Dec 17, 2019

@roddy20 i do confirm the same as @andreszerocross said.

I just added the verbs but high pitch sound when i plug headphones and no audio output.
External Microphone (Line-In) doesn't show up and stays in Internal Microphone

For my codec Realtek ALC3232 (know as ALC292) aside of CodecCommander + AppleALC to have perfect audio inputs and outputs i also need ALCPlugFix which i have a fork with customized entries for my specific audio codec.

See here: https://github.com/Sniki/ALCPlugFix

The commands that you modify according to the specific codec are here:
https://github.com/Sniki/ALCPlugFix/blob/4140e54da788cf6cf6e1642e7701cfaec6c6b7de/ALCPlugFix/main.m#L136-L137

However since you guys said all those are supported by AppleALC itself i wanted to get rid of CodecCommander to have a cleaner setup (-1 SSDT, -1 kext, -2 config.plist entries).

But it is not working for me.

@roddy20
Copy link
Collaborator

roddy20 commented Dec 17, 2019

then Recompile new AppleALC.kext

no need to recompile
ConfigData, WakeUpConfigData are editable by user

try this https://github.com/roddy20/VerbStub
it is like Codec Commander but it sends verbs interactively and you can see (hear) the result

@Sniki
Copy link
Contributor

Sniki commented Dec 17, 2019

thanks @roddy20

I see and i will give it a try but i prefer automatic selection without having a popup to pick what i want.
If my earphones/earpods have their own mic, i love how it automatically works and switches to headphones+LineIn without having to manually select them.
All i wanted to do is just get rid of CodecCommander.kext but it doesn't seem to work without it.
I have perfect audio with my current setup, i just wanted less kext if same functionality is present on AppleALC.

My Lenovo ThinkPad X240 does have a Docking Station, which it does have a combo jack there as well. so in total two combo jacks (2x Line-In=1x for laptop jack, 1x for dock jack) 1x Headphones(laptop jack), 1x LineOut(for the dock jack).

What i noticed from people when patching audio, they patch it that way so you have to select from right click of volume icon on the menu bar which input or output you want.
I don't like that, i want same behavior as on Windows and Linux since it's possible why wouldn't someone do that, i heard words that it's not possible, you have to ditch one input source and manually switch as auto switch/detection doesn't work, which is wrong, i did that and it's working perfect. sending a pull request soon for ALC3232 (aka ALC292) for Lenovo ThinkPads X240,L440,T440,T440S,T440P (all thinkpads of haswell and broadwell generation that use this codec).
You simply leave the two jack mics as Line-In and have two Line-In into layout**.xml > Inputs >
And just for cosmetic reason i left the Dock Jack on Output to show as LineOut so for whatever reasons i check volume icon it shows LineOut on Dock Jack and Headphones on Laptop Jack.
But you can have two headphones and two Line-In into pinconfigdata

Basically a lot of desktop codecs are patched sort of that wrong way, no auto switch.
Example is my HP Elite 8300 SFF, it has a Headphone and a Microphone Jack in front and a Headphone and Microphone jack on the back.

Current existing patch is like this, if you plug headphones on the back audio does output into headphones automatically (that's fine), but if you plug headphones in front headphone jack, the audio will continue playing unless i rightclick menu bar and click on LineOut. same behavior for microphones.

Anyway to the straight point, so by this now i can assume that AppleALC doesn't have that complete functionality that CodecCommander does have ?

If yes, i can provide logs if needed, if not it would be great to port those, same for VerbStub and or ALCPlugFix functionality so we can have a fusion like WhateverGreen.kext had but now for audio.

Sorry for this TLDR

@vit9696
Copy link
Collaborator

vit9696 commented Dec 17, 2019

We believe the exact same functionality is supported by AppleALC. It might be, however, that CodecCommander does something else (e.g. more verbs that are not configured) to the HDA codec, or the amount of verbs you need to send with AppleALC are slightly different due to the order of the verbs sent. The suggestion to try VerbStub may unveil these differences by manually probing the commands and checking the result.

There is some room that there is a race condition, and some verbs need to be sent e.g. twice, but I hope there is none. All in all, patience and trial and error are needed here.

@roddy20
Copy link
Collaborator

roddy20 commented Dec 17, 2019

thanks @roddy20

I see and i will give it a try but i prefer automatic selection without having a popup to pick what i want.

it is not for everyday usage
it is for debug, to be sure that your verbs work as expected,
or examine the internal state of codec

@andreszerocross
Copy link
Contributor Author

Take a look at info.plist of CodecCommander.kext
image. There is no profile for ALC272 except default ones.

with my resource ALC272 LayoutId = 21 without codecCommande.kext in L/E then there is no sound for internal speaker (Audio device is detected). Even in cold boot, there is no sound for Internal Speaker until we put CodecCommander.kext to Library/Extensions.

Just curious, what did codecCommadnder.kext did with default codec profiles??

@Sniki
Copy link
Contributor

Sniki commented Dec 17, 2019

We believe the exact same functionality is supported by AppleALC. It might be, however, that CodecCommander does something else (e.g. more verbs that are not configured) to the HDA codec, or the amount of verbs you need to send with AppleALC are slightly different due to the order of the verbs sent. The suggestion to try VerbStub may unveil these differences by manually probing the commands and checking the result.

There is some room that there is a race condition, and some verbs need to be sent e.g. twice, but I hope there is none. All in all, patience and trial and error are needed here.

Thanks @vit9696

That's good to know, i will try VerbStub and provide more details into this.
Not in a rush at all, just explaining the current working state, English not my native language so forgive me if it looks somewhere that i acted harsh or something, not in purpose/intentional.
Yes i am ready to patiently debug this so we can hopefully have a positive result in the end.
As you said, i hope there is no race condition either, that may complicate things but i will go ahead and do some initial testing and let you all know what we can find out from this.

@roddy20 correct me if im wrong with the order of things that i need to do:

  • Remove ALCPlugFix
  • Remove CodecCommander.kext and the config SSDT for CodecCommander.kext
  • Add VerbStub.kext
  • add wakeconfigdata and configdata into AppleALC.kext/contents/resources/info.plist
    i believe there is no need to rebuild it as it can be edited from there.
  • Do i need combojack installer as well ? as explained on the linked forum at tmx86 ?

I would appreciate a short brief to-do list so i can provide logs.

@roddy20
Copy link
Collaborator

roddy20 commented Dec 19, 2019

yes, remove all these (ALCPlugFix, Commander, Combojack etc)
add VerbStub
send verbs manually and check the result
add verbs to ConfigData/WakeupConfigData

@roddy20
Copy link
Collaborator

roddy20 commented Dec 19, 2019

installation and usage

sudo chmod -R 755 ./VerbStub.kext
sudo chown -R root:wheel ./VerbStub.kext
sudo kextload ./VerbStub.kext
./hda-verb 0 PARAMETERS VENDOR_ID 0
0x11d4198b



./hda-verb -l
known verbs:
  GET_STREAM_FORMAT, GET_AMP_GAIN_MUTE, GET_PROC_COEF, GET_COEF_INDEX
  PARAMETERS, GET_CONNECT_SEL, GET_CONNECT_LIST, GET_PROC_STATE
  GET_SDI_SELECT, GET_POWER_STATE, GET_CONV, GET_PIN_WIDGET_CONTROL
  GET_UNSOLICITED_RESPONSE, GET_PIN_SENSE, GET_BEEP_CONTROL
  GET_EAPD_BTLENABLE, GET_DIGI_CONVERT_1, GET_DIGI_CONVERT_2
  GET_VOLUME_KNOB_CONTROL, GET_GPIO_DATA, GET_GPIO_MASK
  GET_GPIO_DIRECTION, GET_GPIO_WAKE_MASK, GET_GPIO_UNSOLICITED_RSP_MASK
  GET_GPIO_STICKY_MASK, GET_CONFIG_DEFAULT, GET_SUBSYSTEM_ID
  SET_STREAM_FORMAT, SET_AMP_GAIN_MUTE, SET_PROC_COEF, SET_COEF_INDEX
  SET_CONNECT_SEL, SET_PROC_STATE, SET_SDI_SELECT, SET_POWER_STATE
  SET_CHANNEL_STREAMID, SET_PIN_WIDGET_CONTROL, SET_UNSOLICITED_ENABLE
  SET_PIN_SENSE, SET_BEEP_CONTROL, SET_EAPD_BTLENABLE, SET_DIGI_CONVERT_1
  SET_DIGI_CONVERT_2, SET_VOLUME_KNOB_CONTROL, SET_GPIO_DATA
  SET_GPIO_MASK, SET_GPIO_DIRECTION, SET_GPIO_WAKE_MASK
  SET_GPIO_UNSOLICITED_RSP_MASK, SET_GPIO_STICKY_MASK
  SET_CONFIG_DEFAULT_BYTES_0, SET_CONFIG_DEFAULT_BYTES_1
  SET_CONFIG_DEFAULT_BYTES_2, SET_CONFIG_DEFAULT_BYTES_3, SET_CODEC_RESET
known parameters:
  VENDOR_ID, SUBSYSTEM_ID, REV_ID, NODE_COUNT, FUNCTION_TYPE
  AUDIO_FG_CAP, AUDIO_WIDGET_CAP, PCM, STREAM, PIN_CAP, AMP_IN_CAP
  CONNLIST_LEN, POWER_STATE, PROC_CAP, GPIO_CAP, AMP_OUT_CAP
  VOL_KNB_CAP



@roddy20
Copy link
Collaborator

roddy20 commented Dec 19, 2019

Verbs names and numbers are described in HDA Spec, or here
https://github.com/roddy20/VerbStub/blob/master/hda-verb/hda-verb.c


#define AC_VERB_SET_EAPD_BTLENABLE		0x70c
#define AC_VERB_SET_DIGI_CONVERT_1		0x70d
#define AC_VERB_SET_DIGI_CONVERT_2		0x70e
#define AC_VERB_SET_VOLUME_KNOB_CONTROL		0x70f
#define AC_VERB_SET_GPIO_DATA			0x715
#define AC_VERB_SET_GPIO_MASK			0x716
#define AC_VERB_SET_GPIO_DIRECTION		0x717
#define AC_VERB_SET_GPIO_WAKE_MASK		0x718
#define AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK	0x719
#define AC_VERB_SET_GPIO_STICKY_MASK		0x71a

etc
0x01, 0x57, 0x17, 0x0D = ./hda-verb 0x15 AC_VERB_SET_GPIO_DIRECTION 0x0D

@Sniki
Copy link
Contributor

Sniki commented Jan 30, 2020

@roddy20 i did some testing but i need to know which commands do i need for debugging my current problem

for example:
hda-verb 0x15 AC_VERB_SET_GPIO_DIRECTION 0x83 gives me this result:
No key matching with 'AC_VERB_SET_GPIO_DIRECTION'
One thing i noticed is, if i let laptop sleep and then wake it, plugging headsets will have good working sound and also external mic is detected correctly as LineIn, however if i unplug headsets and plug them again it will go into static whitenoise and internal mic only (no linein detected).
Realtek ALC3232 Dump.txt

Let me know what are further commands that i need to try.
hda-verb 0x1A SET_PIN_WIDGET_CONTROL 0x24 will make audio work again on headphones as soon as i press enter.

@andreszerocross
Copy link
Contributor Author

@roddy20 i did some testing but i need to know which commands do i need for debugging my current problem

for example:
hda-verb 0x15 AC_VERB_SET_GPIO_DIRECTION 0x83 gives me this result:
No key matching with 'AC_VERB_SET_GPIO_DIRECTION'
One thing i noticed is, if i let laptop sleep and then wake it, plugging headsets will have good working sound and also external mic is detected correctly as LineIn, however if i unplug headsets and plug them again it will go into static whitenoise and internal mic only (no linein detected).
Realtek ALC3232 Dump.txt

Let me know what are further commands that i need to try.
hda-verb 0x1A SET_PIN_WIDGET_CONTROL 0x24 will make audio work again on headphones as soon as i press enter.

I thougt just "hda-verb 0x15 SET_GPIO_DIRECTION 0x83"

no need to use AC_VERB

@Sniki
Copy link
Contributor

Sniki commented Jan 31, 2020

@roddy20 i did some testing but i need to know which commands do i need for debugging my current problem
for example:
hda-verb 0x15 AC_VERB_SET_GPIO_DIRECTION 0x83 gives me this result:
No key matching with 'AC_VERB_SET_GPIO_DIRECTION'
One thing i noticed is, if i let laptop sleep and then wake it, plugging headsets will have good working sound and also external mic is detected correctly as LineIn, however if i unplug headsets and plug them again it will go into static whitenoise and internal mic only (no linein detected).
Realtek ALC3232 Dump.txt
Let me know what are further commands that i need to try.
hda-verb 0x1A SET_PIN_WIDGET_CONTROL 0x24 will make audio work again on headphones as soon as i press enter.

I thougt just "hda-verb 0x15 SET_GPIO_DIRECTION 0x83"

no need to use AC_VERB

I believe that if there is a "PerformReset" command on boot, now my codec should work correctly, without CodecCommander and Without AlcPlugFix with the changes that i did.
As soon as i sleep the laptop and wake it again, everything works perfect.
@roddy20 @vit9696 is there a perform reset command on AppleALC at boot ? (Like codeccommander.kext have ?)

@Sniki
Copy link
Contributor

Sniki commented Feb 1, 2020

@andreszerocross try adding the WakeConfigData to ConfigData as well, that fixed almost completely my audio codec, mine just needs a full reset on Cold Boot, after wake from sleep everything works perfect.

@roddy20 @vit9696 sorry for bothering you again, but can any of you or another member that can answer this: let me know if there is a "ResetHDA" function into AppleALC or OpenCore itself like we have this option on Clover or CodecCommander as i couldn't find any evidence or answer for this into documentations available.

My codec needs a Full reset on Cold Boot to function completely fine.

As for your point @vit9696 , yes you are right those commands are supported on AppleALC but they seem to be necessary to be included into ConfigData as well, not just on WakeConfigData.
That seemed to be the problem.

Thanks guys !

@wern-apfel
Copy link
Contributor

Interesting conversation. I also tested the Wake ConfigData, all verbs are sent, but the codec doesn't work. It works after restarting the core audio daemon. Maybe this could be a workaround.
You can also try the D3cold power state. Will do some more tests later.

Regarding the CA0132 codec. CodecCommander has to be in /L/E because some commands have to be executed later. But already fixed, try AppleALC from the CA0132 topic on Insanelymac, where CC can be run by the boot loader.

@Sniki
Copy link
Contributor

Sniki commented Feb 22, 2020

@wern-apfel how can i restart the audio daemon ? same for D3 cold power state ?
In my case it's a problem on Boot, a sleep and wake fixes all the issue and audio will be working until next reboot.

I can do some debugging and send logs, i just need the directions on what/how to collect them.

@wern-apfel
Copy link
Contributor

D3cold "hda-verb 0x1 0x705 0x4" assuming CC is loaded. then do a force restart coreaudio, enter "sudo killall coreaudiod"
Whats your pin control value after startup ? Which layout-id and resources do you use?

@Sniki
Copy link
Contributor

Sniki commented Feb 23, 2020

@wern-apfel i currently use a modified version of vusun123 - ALC292 for ThinkPad T440.
layout-id 28, his version lacks the dock support and the wakeconfigdata to fix the issues.
I modified it with all the known fixes and added dock support.
Technically it seems that 01A70724 is not being executed at ConfigData cause i did add that there as well assuming that it should be executed with the rest of ConfigData but it is not working there.
Wake from sleep fixes the problem:
On cold boot when i plug headphones, i get high pitch noise and the external mic (headset mic) doesn't get detected.
However if i let laptop to sleep and wake it, i insert headphones and no more problems, audio works fine, headset mic detected "LineIn" and everything will work perfect until next reboot without a sleep/wake cycle happening, you can unplug and plugin headset 100 times it will work everytime after the sleep/wake cycle happened.

Here are the files (codec_dump.txt, info.plist"of pinconfigs.kext, layout28.xml and Platforms28.xml):
ALC3232.zip
If you want to take a look.

@wern-apfel
Copy link
Contributor

After a quick look, the MuteGPIO value is 1342242854 in hex 0x50010026. The pin should be in hex. 26 = 1a means 0x5001001a dec. 1342242842.

@Sniki
Copy link
Contributor

Sniki commented Feb 23, 2020

After a quick look, the MuteGPIO value is 1342242854 in hex 0x50010026. The pin should be in hex. 26 = 1a means 0x5001001a dec. 1342242842.

Are you refering to Layout28.xml > PathMapRef > LineIn :
Change 1342242854 to 1342242842 ?

@wern-apfel
Copy link
Contributor

Yes. With CodecCommander loaded and hda-verb in the path, you can use the script to display
the actual value.
script.zip

@Sniki
Copy link
Contributor

Sniki commented Feb 24, 2020

@wern-apfel
As you have seen on the codec_dump, these are the nodes on use:
0x12 (Internal Mic),
0x14 (Speaker),
0x15 (Headphones Laptop ComboJack),
0x16 (Dock Headphones ComboJack),
0x19 (Dock ExternalMic ComboJack),
0x1a (External Mic Laptop ComboJack)

here is what i got with CodecCommander.kext installed:

Pin Widget Control
		Pin 0x02 = 00
		Pin 0x03 = 00
		Pin 0x04 = 00
		Pin 0x05 = 00
		Pin 0x06 = 00
		Pin 0x07 = 00
		Pin 0x08 = 00
		Pin 0x09 = 00
		Pin 0x0a = 00
		Pin 0x0b = 00
		Pin 0x0c = 00
		Pin 0x0d = 00
		Pin 0x0e = 00
		Pin 0x0f = 00
		Pin 0x10 = 00
		Pin 0x11 = 00
		Pin 0x12 = 20
		Pin 0x13 = 00
		Pin 0x14 = 40
		Pin 0x15 = 00
		Pin 0x16 = 00
		Pin 0x17 = 00
		Pin 0x18 = 00
		Pin 0x19 = 00
		Pin 0x1a = 02
		Pin 0x1b = 00
		Pin 0x1c = 00
		Pin 0x1d = 20
		Pin 0x1e = 00
		Pin 0x1f = 00
		Pin 0x20 = 00
		Pin 0x21 = 00
		Pin 0x22 = 00
		Pin 0x23 = 00
		Pin 0x24 = 00
Here is GET_UNSOLICITED_RESPONSE:
GET_UNSOLICITED_RESPONSE

                Pin 0x02 = 00
		Pin 0x03 = 00
		Pin 0x04 = 00
		Pin 0x05 = 00
		Pin 0x06 = 00
		Pin 0x07 = 00
		Pin 0x08 = 00
		Pin 0x09 = 00
		Pin 0x0a = 00
		Pin 0x0b = 00
		Pin 0x0c = 00
		Pin 0x0d = 00
		Pin 0x0e = 00
		Pin 0x0f = 00
		Pin 0x10 = 00
		Pin 0x11 = 00
		Pin 0x12 = 00
		Pin 0x13 = 00
		Pin 0x14 = 00
		Pin 0x15 = 83
		Pin 0x16 = 81
		Pin 0x17 = 00
		Pin 0x18 = 00
		Pin 0x19 = 85
		Pin 0x1a = 85
		Pin 0x1b = 00
		Pin 0x1c = 00
		Pin 0x1d = 00
		Pin 0x1e = 00
		Pin 0x1f = 00
		Pin 0x20 = 00
		Pin 0x21 = 00
		Pin 0x22 = 00
		Pin 0x23 = 00
		Pin 0x24 = 00

Those are the results, hopefully this can bring into surface a possible issue on my patch.

Thanks !

Note: Aside from the codec_dump, is it possible to dump the hda-verb values from Linux and get a better understanding on what should be done to correct this codec ?

@wern-apfel
Copy link
Contributor

I think you have a TRRS audio jack and the MIC and HP have pin sense. You must disable it for the microphone and call it via detect delegate. Try the simplified script.
pin_ctrl_dump.sh.zip

@Sniki
Copy link
Contributor

Sniki commented Feb 26, 2020

I think you have a TRRS audio jack and the MIC and HP have pin sense. You must disable it for the microphone and call it via detect delegate. Try the simplified script.
pin_ctrl_dump.sh.zip
This is the result:

Pin Widget Control
		Pin 0x12 = ff
		Pin 0x14 = ff
		Pin 0x15 = ff
		Pin 0x16 = ff
		Pin 0x19 = ff
		Pin 0x1a = ff
	Usolicited Response
		Pin 0x12 = ff
		Pin 0x14 = ff
		Pin 0x15 = ff
		Pin 0x16 = ff
		Pin 0x19 = ff
		Pin 0x1a = ff
	Pin Sense
		Pin 0x12 = 0xffffffff
		Pin 0x14 = 0xffffffff
		Pin 0x15 = 0xffffffff
		Pin 0x16 = 0xffffffff
		Pin 0x19 = 0xffffffff
		Pin 0x1a = 0xffffffff

@roddy20
Copy link
Collaborator

roddy20 commented Feb 26, 2020

Is there any working example of detect delegate for Hackintosh codec with TRRS ?

@wern-apfel
Copy link
Contributor

@Sniki hda-verb is only a client of CodecCommander, to make it work CC must be loaded.

@roddy20 I don't have a Laptop with a TRRS jack, but I'm going to create an AppleALC for Sniki to see if it works.
Below is an example where output 11 (0xb) has no pinsense but 12 (0xd), pin 11 (0xb) has pin sense in this way and works.
pinsense

@roddy20
Copy link
Collaborator

roddy20 commented Feb 28, 2020

it is very interesting
I saw very similar code in MacBook's resources, but never managed to make it work at Hackintosh
a lot of codecs with TRRS need it

@wern-apfel
Copy link
Contributor

Oh, my old Dell laptop has an TRRS jack but my son uses it with Windows. Let's see if I can found a USB-to SATA adapter to do some tests. @Sniki in the meantime, you can try this sample. It is configured like the Dell.

AppleALC-1.4.7-RELEASE.zip

@Sniki
Copy link
Contributor

Sniki commented Mar 1, 2020

Oh, my old Dell laptop has an TRRS jack but my son uses it with Windows. Let's see if I can found a USB-to SATA adapter to do some tests. @Sniki in the meantime, you can try this sample. It is configured like the Dell.

AppleALC-1.4.7-RELEASE.zip

@wern-apfel not sure with what layout-id have done the configuration, i assumed it was the same: layout-id 28 that i was using on my files.

However i get greyed out volume icon, sound doesn't work with your AppleALC.kext

@wern-apfel
Copy link
Contributor

I'm sorry, I made a mistake. Try this one.
AppleALC-1.4.7-RELEASE.zip

@Sniki
Copy link
Contributor

Sniki commented Mar 3, 2020

I'm sorry, I made a mistake. Try this one.
AppleALC-1.4.7-RELEASE.zip

No problem.
This one doesn't work either, greyed out icon.

@andreszerocross
Copy link
Contributor Author

andreszerocross commented Mar 4, 2020

Interesting conversation. I also tested the Wake ConfigData, all verbs are sent, but the codec doesn't work. It works after restarting the core audio daemon. Maybe this could be a workaround.
You can also try the D3cold power state. Will do some more tests later.

Regarding the CA0132 codec. CodecCommander has to be in /L/E because some commands have to be executed later. But already fixed, try AppleALC from the CA0132 topic on Insanelymac, where CC can be run by the boot loader.

Can you merge the AppleALC version of yours to AppleALC Github resource so i can use CodecCommander from Bootloader?? I can't use CodecCommander in Bootloader for CA0132 yet.

@wern-apfel
Copy link
Contributor

I'm sorry, I made a mistake. Try this one.
AppleALC-1.4.7-RELEASE.zip

No problem.
This one doesn't work either, greyed out icon.

Ok, now I see it. The Info.plist you provided is not the plist form the resources. I simply copied them without checking the content.
AppleALC-1.4.7-RELEASE.zip

@wern-apfel
Copy link
Contributor

Interesting conversation. I also tested the Wake ConfigData, all verbs are sent, but the codec doesn't work. It works after restarting the core audio daemon. Maybe this could be a workaround.
You can also try the D3cold power state. Will do some more tests later.
Regarding the CA0132 codec. CodecCommander has to be in /L/E because some commands have to be executed later. But already fixed, try AppleALC from the CA0132 topic on Insanelymac, where CC can be run by the boot loader.

Can you merge the AppleALC version of yours to AppleALC Github resource so i can use CodecCommander from Bootloader?? I can't use CodecCommander in Bootloader for CA0132 yet.

Did you test it, does it work like before? I am not currently using the mainboard with the R3Di codec.

@Sniki
Copy link
Contributor

Sniki commented Mar 4, 2020

I'm sorry, I made a mistake. Try this one.
AppleALC-1.4.7-RELEASE.zip

No problem.
This one doesn't work either, greyed out icon.

Ok, now I see it. The Info.plist you provided is not the plist form the resources. I simply copied them without checking the content.
AppleALC-1.4.7-RELEASE.zip

Yes, that was just so i have a source of the hdaconfigdefault.

Now it loads but the same problem is present: static noise on Headphones.

@wern-apfel
Copy link
Contributor

Interesting conversation. I also tested the Wake ConfigData, all verbs are sent, but the codec doesn't work. It works after restarting the core audio daemon. Maybe this could be a workaround.
You can also try the D3cold power state. Will do some more tests later.
Regarding the CA0132 codec. CodecCommander has to be in /L/E because some commands have to be executed later. But already fixed, try AppleALC from the CA0132 topic on Insanelymac, where CC can be run by the boot loader.

Can you merge the AppleALC version of yours to AppleALC Github resource so i can use CodecCommander from Bootloader?? I can't use CodecCommander in Bootloader for CA0132 yet.

I created a pull request with the changes. Can you try it and report? Thanks

@Sniki
Copy link
Contributor

Sniki commented Jun 10, 2020

@wern-apfel any update or information gathered that you could provide for TRRS Jack ?

@wern-apfel
Copy link
Contributor

@wern-apfel any update or information gathered that you could provide for TRRS Jack ?

I didn't have enough time to test. It seems that the issue is not the TRRS jack. When the GPIO entry is added, VREF is activated, but only if it is not configured in switch mode. The same behaviour on my desktop. I will do a few more tests.

@Sniki
Copy link
Contributor

Sniki commented Jun 11, 2020

@wern-apfel any update or information gathered that you could provide for TRRS Jack ?

I didn't have enough time to test. It seems that the issue is not the TRRS jack. When the GPIO entry is added, VREF is activated, but only if it is not configured in switch mode. The same behaviour on my desktop. I will do a few more tests.

Yes, so currently we are using the MacPeet version of AppleALC patch with Manual Mode switch from Speaker to Headphones, so if we plug headphones, we lose audio from speakers but we have to click on the volume icon on the menu bar to select Line Out to get audio output from Headphones and vice versa (manual switch).

Interestingly enough, instead of headphones, he choosed LineOut which seems to work for some reasons, i tried playing around with his patch and just to modify the pinconfigs so it shows "headphone" instead of "LineOut" and the static noise comes back.

So current situation is: Manual mode works and headphones should be configured as LineOut.

Here is the reference:
#508

@Sniki
Copy link
Contributor

Sniki commented Jun 17, 2020

@wern-apfel @roddy20

Is it possible to setup an input device as a External Microphone instead of LineIn.
Did any of you had success with that ?

On my MBP 13” Retina (Early 2015) when i plugin EarPods, in input it shows External Microphone and on Outputs it shows Headphones (as it should).
For comparison, on hackintosh all inputs are configured as LineIn.
But in the case of this codec, Lenovo ThinkPads have docking stations which does have a combo jack, so in our case we need 3 input devices.

  • Internal Microphone
  • Laptop Input from jack (LineIn or ExtMic)
  • Dock Input from Jack (ExtMic or LineIn)

Output devices:

  • Speakers
  • Laptop Output from jack (Headphones)
  • Dock Output from Jack (LineOut)

The problem is i don’t know what pinconfig should i make for ExtMic as the only option is MicIn or LineIn from documentations available, is it supposed to be left as micIn and then specify it on layout**.xml file > Inputs > ExtMic ? Or is there a ExtMic pin value ?

If i leave both inputs from both jacks as LineIn, one of them won’t work, no input reception.

I tried to leave the pinconfig value of one of the jacks as MicIn and add the ExtMic on one of the layout.xml but i get no external microphone listed for that input and the menu bar icon stays greyed out for like 1 min after i boot into desktop, so i will have no audio for that 1 min period until the configuration loads.

@wern-apfel
Copy link
Contributor

@wern-apfel @roddy20

Is it possible to setup an input device as a External Microphone instead of LineIn.

In my experience, it only works when the microphone is the second device in auto switch mode.
Set port connectivity and location to 0xx71F00. Here my patched kext as an example.

Regarding microphone on TRRS jacks. The VREF of the second device (in our case the external microphone) in switch mode is always 0V (ground) however VREF 80% is required, a workaround would be a binary patch, which changes VREF to 80

@Andrey1970AppleLife
Copy link
Contributor

Use forums for discussion.

@acidanthera acidanthera locked and limited conversation to collaborators Jun 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
7 participants