zearp / OptiHack

Dell OptiPlex 7020/9020 Hackintosh Stuff
https://zearp.github.io/OptiHack/
155 stars 54 forks source link

Use correct setting for audio layout #15

Closed pkendall64 closed 4 years ago

pkendall64 commented 4 years ago

According to the docs https://dortania.github.io/OpenCore-Post-Install/universal/audio.html#making-layout-id-more-permanent we should really be using layout-id.

This also fixes an error on the startup logs. Unfortunately it doesn't fix the rear audio.

pkendall64 commented 4 years ago

So i did some more reading and forum searching and it appears that we can use...

apparently layout-id=13 date (0d000000) is rear and front with manual switching, but I haven't tried this.

So pick whichever suits your situation.

mgrimace commented 4 years ago

Tested layout-id with data 0D000000 (id=13) and my headphones work on both the front and back audio jack, but no system audio is available in the audio selection menu (menubar). The headphone's in-line mic doesn't work (i.e., doesn't record sound in Zoom mic test) in either the audio or mic jacks. However, it wasn't working before with the alc-layout-id property either.

I'm going to default to (id=16) internal + front (which is my main use for now), I'll continue testing. Ideally system + front + back but this is outside my knowledge area.

mgrimace commented 4 years ago

I'll add that the layout-id with data 10000000 is working as expected in brief testing. Both the front audio jack and the system audio are working the same as the previous alc-layout-id

zearp commented 4 years ago

It doesn't matter if the layout id is configured as data or number (integer).

I been using layout id 16 because in my case that's the one that works best. I use the front headphone port a lot and having the internal speaker work (even though it sounds crap) can be useful at times.

For others layout 16 might not work and they can use another one. Layout id 16 is taken from the Dell 9020.

Edit: I will remove the alc- bit, completely missed that part 🥱  ☕️ 

zearp commented 4 years ago

@mgrimace I think to get all audio ports working properly a new layout has to be made from scratch or editing the 9020 one to work with all ports. This is a very low priority for me as I use an audio interface 99% of the time and when I don't, I just use the headphone jack the front. It can be very time consuming creating or adjusting an existing layout.

I assume most people either use audio over hdmi or the front or back ports for speakers/headphone. A lot of computer speakers have a headphone plug on them too so not having the headphone port on front work isn't as much of an issue. It would be nice to have a proper 7020 layout. I just don't know if the effort is worth the payout.

mgrimace commented 4 years ago

@mgrimace I think to get all audio ports working properly a new layout has to be made from scratch or editing the 9020 one to work with all ports.

That's great to know, thanks! It's certainly a low priority for me as well, more curiosity than need at this point for what I do as well (system audio or headphones for Zoom, etc.). Nice to know about the option above to use 15 for rear audio if I ever get around to getting a proper speaker set, I'll have to note that somewhere

pkendall64 commented 4 years ago

Cool, thanks @zearp. I'm running mine with id=15 as I have some logitech pebbles plugged in at the rear and leave the front jack for headphones later at night. The internal speaker is next to useless.

pkendall64 commented 4 years ago

Perhaps a new PR with some documentation around setting the layout-id in the README.md might help others choose a good setting for their situation.

mgrimace commented 4 years ago

Could I suggest adding the two ID options suggested by @pkendall64 to the readme? e.g., Note: the audio layout-id is set at 16, which will enable the system volume and the front audio jack. You can replace this value with 15 to enable the rear audio jack, but this will disable the system audio. This can be changed in the config.plist under DeviceProperties. Might be useful to keep this tracked in case someone wants to change it down the road.

Edit: lol, 30s late

zearp commented 4 years ago

Yeah good idea to make it more clear what the options are.

There's some info now but its not worked out yet. The readme got quite dense over time. I think the Github .md files are not really suitable to contain a lot of information unless it's being split up into a few sections. Like a general intro, making install media and setting up the config file for the first time, first boot and BIOS stuffs, then install and another for post-install and finally the stuff that didn't fit in the previous categories.

The audio would sit in the config file section with maybe more in-depth in post install section. I will see there's some css magic that can be done to prevent having separate files before going that route. But it may be the only way to keep things legible.

Also I think setting the default to 15 would make more sense for most people. As both from and back work and who expects internal speakers nowadays? As long as the front headphone switches automatically and maybe those combines line/mic jacks work for headsets most people will be happy. I hope to find some time today to test and change/clean things up a bit.

Of course the best solution would be to either edit the 9020 layout which I think comes closest to all ports working and is based on a very similar model or make a new one where all the ports work as they should. I'm not sure if there's a difference in audio ports between 9020 and 7020. Maybe the 9020 layout is simply missing some entries.

Thank you both for the ideas and tips!

zearp commented 4 years ago

There must be more to this than just the layout files because layout xml files for 15 and 16 are exactly the same except for the number. I thought to be smart and copy over the back ports section from 15 to 16. But the xml files are the same.

I noticed in Hackintool that with layout 16 there's some fancy displaying of the in and outputs. This does not appear when using layout 15. Probably means nothing.

% diff layout15.xml layout16.xml 
6c6
<   <integer>15</integer>
---
>   <integer>16</integer>
953c953
<           <integer>15</integer>
---
>           <integer>16</integer>

In the platforms file only the NodeID in the Amp section is different.

% diff Platforms15.xml Platforms16.xml                                                               
185c185
<                               <integer>27</integer>
---
>                               <integer>20</integer>
301c301
<           <integer>15</integer>
---
>           <integer>16</integer>

16

zearp commented 4 years ago

I've extracted the codec info in Linux as part of gathering information needed to create a custom layout. No idea if creating a custom layout would do anything but I'l see how far I get. I put the codec info here.

zearp commented 4 years ago

There is very little info on how to create a custom layout/etc for AppleALC. I can find lots of AppleHDA patching guides, but they're pretty old by now and modifying stuff on the system itself is not preferred.

Maybe it is the only way to go; disable AppleALC and patch AppleHDA and if possible inject it with OpenCore. But I have no idea if this works or overrides the system kext (I think it does). But if it doesn't then there's no other way than patching AppleHDA in /S/L/E itself. To be honest it is quite some work and I only did some initial information gathering and testing.

I'm not sure where to go from here. I gathered as much information as I could. Everything needed for a custom layout should be in the file I linked above.

mgrimace commented 4 years ago

Thanks for compiling all the info! I just started reading into this myself. It’s all new for me so nothing to add yet, but if I come across anything I’ll report back.

pkendall64 commented 4 years ago

So I've done a lot of reading and some investigation into building AppleALC with a mind to fixing this problem. I do have it working with all 3 devices and switching when things are plugged in/removed.

The problem is that Apple have decided that the priority order should be LineOut > Headphone > Speaker. Found info https://github.com/acidanthera/AppleALC/commit/efba32ed2d8b02c3959027691d9b1af59e023649

So if you have something plugged in the rear plug (LineOut) it takes precedence. This is not what we want. It would be better that the front plug is the first option, then rear falling back to internal.

We have 2 options

  1. Remap the devices so the rear is the Headphones and the front is Line Out. This means that the name in the Preferences would be wrong. Not what users would expect, but the behaviour would be correct.

  2. Make all 3 devices available and let the user manually select which one to output to.

What do you guys think?

pkendall64 commented 4 years ago

Ok, I think I've got the best of both worlds with a new layout 17.

There will be 2 devices listed in the preferences Internal Speaker/Line Out depending on if theres something plugged in the rear green plug, and 'Headphones'. You can manually select between these two devices in the preferences or on the sound icon on the top bar.

The main limitations lie with the hardware and with apples decision to have line-out override the headphones. The hardware limitation is that the internal speaker cannot not function if there is something in the line-out plug because they share the same AMP etc. So it only makes sense to have this part auto-switch. And because of the apple decision we really need to manually select that part.

AppleALC.kext.zip

Attached is a modified AppleALC.kext that has layout 17 that supports this behaviour if you'd like to try. If you think it's a good compromise then I'll make my changes available to the OpenCore folk in a PR.

mgrimace commented 4 years ago

Thanks for your work here @pkendall64, I’ll test this out over the next few days on my 7020 SFF. Much appreciated!

pkendall64 commented 4 years ago

BTW, I'm using a 9020 SFF.

pkendall64 commented 4 years ago

I've added a PR to the AppleALC repo https://github.com/acidanthera/AppleALC/pull/591, so hopefully that will get merged and we can use layout 17 as a good default.

zearp commented 4 years ago

Awesome work @pkendall64! Thanks for the explanations too. Will test it hopefully very soon. Layout 16 is was taken from a 9020 SFF, maybe it was incomplete? Manual selection is not a very big deal if it means all in and outputs are available.

Of all the things I didn't expect audio layouts to be so complex lol. Apple used to be pretty generous, my old MacBook Pro has an auto-sensing 1/8 socket that can do normal line out and in but also optical. On my newer ones I don't recall a combo jack headphone/mic working properly.

zearp commented 4 years ago

Looks like its been merged!

https://github.com/acidanthera/AppleALC/commit/872d9b67c4f36856e1984e7c3cc2f6c9506cf672