kingo132 / a51m-r2-5700m-hackintosh

Hackintosh for alienware a51m r2 with 5700m gpu
28 stars 2 forks source link

Let's make the current audio patch a bajillion times better! #8

Open TechProgenitor opened 2 years ago

TechProgenitor commented 2 years ago

Hi Kingo, I know that I’ve been bombarding you with threads recently, (sorry for doing this) but this one’s important, and will probably will be the last one for a while: This Hackintosh is pretty much a MacBook at this point, but I’d like to finish this project knowing that the audio is in a good place.

Regarding the current patch in your repo, to fix the headphones overriding the speakers in split mode on startup, you need to change the output type for the internal speakers to “Line Out.” I don’t know if there’s order precedence in macOS or if it has to do with the codec, but this works, and your previously selected output will remain selected on reboot.

Regarding the headphone distortion issue, I’ve worked out the correct verb commands to eliminate this and power on/off the EAPD on the combojack: (you’ll need to have “alcverbs = 1” in your boot arguments and “alc-verb.exe"/"ResourceConverter.exe" installed in usr/local/bin in order to write verb commands to the codec)

alc-verb 0x19 SET_PIN_WIDGET_CONTROL 0x20 (removes headphone distortion) alc-verb 0x21 SET_EAPD_BTLENABLE 0x0 (powers off the EAPD) alc-verb 0x21 SET_EAPD_BTLENABLE 0x2 (powers on the EAPD)

I’m currently using ALCPlugFix-Swift with this config file in order to pass these verb commands to the codec in split mode: com.black-dragon74.ALCPlugFix.plist.zip I tried to use ALCPlugFix-Swift with the platform file’s outputs wired in “switching mode,” but it failed miserably. (I can’t get the EAPD verb commands to work sequentially.) https://www.insanelymac.com/forum/topic/350094-verb-command-mayhem-realtek-alc215/

I don’t know why in switching mode, the EAPD is sometimes in tristate on startup and powers down when headphones are detected (in switching mode with my current pathmaps, the EAPD doesn't power up when headphones are disconnected). I noticed that you're using a special cable to aggregate the line in/out ports. I've never owned a cable like that before and am guessing it has something to do with this?

It would be nice to get the audio working in switching mode, but technically the audio within Windows is in split mode, so I’m not too upset if we can’t switch the outputs automatically. Regardless, ALCPlugFix wouldn’t always load on boot until last May when its developer updated the daemon.

Because I believe in having a vanilla build, I don’t think that this is great long term solution for the audio. This is because at any point in the future, Apple could flag this daemon on startup again. At least with a kext, I don’t run into this issue and can have it installed in the EFI folder.

I’ve been exploring getting the verb commands working with AppleALC and CodecCommander, and I’ve had some success! With kexts, the verb commands don’t get passed on boot, but they always get passed when waking up the computer. I’m fully convinced that this is because the verb commands on boot are being passed too early. Fixing this might require rewriting some specific while loop / boolean condition within AppleALC/CodecCommander, but I’m convinced that either you or me will figure how to reprogram whichever kext if necessary. Regardless this method isn’t 100% vanilla because you’ll have to install alc-verb/ResourceConverter or hda-verb, but I believe that this is a better way to to ensure compatibility in whichever few future macOS versions we’ve got left (until Apple finally pulls the plug on Intel).

Finally, I’ve got some things that I’d like to share with you:

Along with my Hackintoshing skills I’m a musician/audio engineer and have poured several years of experience into trying to make these speakers sound their best. I've written an audio patch for this laptop with a ton of DSP processing applied to the internal speakers, and I hope you'll enjoy it! a51m-R2 Remastered Speakers.zip

Because these speakers are downfiring, they’ll sound their best when the laptop is placed on a flat surface. Along with figuring out the verb data and pathmaps, I used the Ida Pro software that you sent me last year in order to reverse engineer the equalization parameters within the AppleHDA kext. Here’s the writeup that I did on InsanelyMac regarding this: https://www.insanelymac.com/forum/topic/350193-cannot-find-any-information-on-applehdas-eq-parameters/

Unfortunately the 24 bit DAC limits my remastered patch’s dynamic range before clipping. (A 32 bit floating point DAC has a much higher bit depth and wouldn’t have this issue.) In the future, I’m thinking of possibly attenuating the digital signal by -20DB, and using a linear gain op amp to raise the analog output signal +20DB before the DAC can clip it. Hopefully the quantization noise would still be inaudible afterwards and I won’t blow my speakers.

I still want to remaster the microphone and apply noise reduction, but before I do this, I’d like to try to make the current solution more native. Either through AppleALC or CodecCommander so I don’t have to worry about the newest macOS update flagging ALCPlugFix.

And yes, I’ll try to generate the same EQ curve on Windows/Linux (I’m planning to make my laptop a triple boot configuration), and share information on how to do this.

Lastly, it’s hilarious that your startup chime is a Windows chime but your main operating system is macOS! It sounds beautiful though so I remastered your startup chime to sound great through this computer's speakers: Kingo's Chime Remastered.wav.zip

For maximum fidelity, make the following changes to your config.plist file: set SystemAudioVolumeDB to <00> set MaximumGain to 0

kingo132 commented 2 years ago

Hi, thanks for providing so many connoisseur optimizations. I tried to apply them but encountered problems.

First, I tried to use your AppleALC.kext directly. But the sound is broken when the song goes to the mega bass part. You can listen to my recording below for that broken sound.

Aimou Ophthalmology.m4a.zip

https://www.youtube.com/watch?v=h3h035Eyz5A

Second, I tried to build a new AppleALC.kext by using your PinConfig data. However, the newly built AppleALC.kext can not find the sound device, and I don't know why. So, I'm wondering if you have a full AppleALC source code with your modification that you could provide me. So I can try to see if I can figure out why the sound is broken in some parts of the song.

Thank you for your great work!

TechProgenitor commented 2 years ago

Hi Kingo, this is expected behavior from my audio patch. It happens on my computer too, and I can tell you exactly why the audio is clipping… It has nothing to do with AppleALC or AppleHDA. It's my fault and has to do with the sound card itself. It’s because I’ve maxed out the bass in the 100-200HZ range by over +30DB, and the sound card can’t supply enough voltage to meet the demands of my insane EQ curve in the bass region.

Original Volume Level

Along with my source code, I’ve sent you the exact Logic Pro project that I used to build this patch in the first place. The only difference is the stereo enhancement. It’s a lot stronger in the Logic Pro file because it covers all frequencies so I disabled it by default. Pay close attention to the “Stereo Out” channel. That’s what’s getting routed to the speakers. If you max out the volume on your laptop, and the “Stereo Out” volume meter goes past 0DB, clipping will occur.

This is why I wish this laptop had a 32 Bit Floating Point DAC instead of a 24 Bit Fixed Point DAC. These types of audio converters can go past 0DB by quite a ton of DBs.

The version of the patch that I've sent you with its current frequency response is exactly what I’d like to do, but it might be more trouble than it’s worth. In order to use this frequency response, I’m trying to add a -20DB gain and limiter DSP to the layoutid, and install a +20DB analog linear gain amplifier into the laptop. However whenever I program the extra DSPs into the layoutid nothing happens for some reason. To be honest though, it’s probably better to just tweak the EQ curve in the 100-200HZ range to eliminate clipping and save the hassle.

If you want a huge relief on the DAC, on the second channel EQ plugin, you could get rid of the narrow +15DB bandpass filter to see if that helps. But you’ll eventually hear why I blasted that frequency range to death in the equalizer. (Set the gain on filter 4 within the layoutid to zero.) By all means go crazy with this Logic Pro file and see if you can come up with something that works. If you're up to the challenge of adding the -20DB gain and limiter, take a look at Apple's layout ids within the AppleHDA.kext and decompile the executable for "DSPFuncLib.kext" stored in: /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/DspFuncLib.kext/Contents/MacOS

More importantly though, I’d like to try and make the headphone distortion verb command get sent on startup without using ALCPlugFix. Through AppleALC, it gets sent on sleep/wake successfully, but not on startup! Edit the PinConfig data that I sent you and add 01970720 to it to eliminate the headphone distortion.

Attached files: AppleALC.zip Clone MacKernelSDK into the root directory. I couldn't include it because it was too big for the file upload. a51m-r2 Remastered Speakers.logicx.zip The "Mastered Speakers" channel is my original patch, and the "Stereo Out" channel now includes the gain and limiter DSPs. macOS Big Sur DSP Functions.txt This is a reverse engineered list of every DSP function available in macOS Big Sur.

kingo132 commented 2 years ago

Hi, TechProgenitor. I finally got time to manipulate this audio patch now.

I did several things. First of all, I still can't eliminate that sound clipping while playing mega bass. So I just removed your optimizing in "Line Out" in my AppleALC.kext. It's not deprecating your modification, but just my personal choice.

Secondly, your configuration does not support the headphone while using that forking adapter (That special cable you mentioned earlier, I guess this adapter is the only way to use the headphone mic). So I changed the LineIn section and also switched back to my layout to get that headphone mic to work properly. I don't know the exact reason why this change worked. I got this result just by testing. If you prefer to abandon that mic port in this machine, then it's OK not to change this and use that adapter.

You can compare the configuration files of your's and mine to find out what I have modified.

ALC215.compare.zip

And here is my modified entire source code

AppleALC.1.7.4.zip

By far, this AppleALC.kext is very perfect for this machine. Thank you again for your great work.

kingo132 commented 2 years ago

Hi, I'm also curious about what Wifi card you are using. I'm using the BCM94352Z which has a serious problem that the wifi speed will become extremely slow after sleep and wake. I tried many methods but still could not fix it. I'm considering changing it to BCM94360CS2. But this native card is longer than BCM94352Z, so maybe I need to chop some of the plastic inside the a51m to install it. Besides, I still don't know if this chopping is possible and if BCM94360CS2 will have the same sleep/wake slow problem.

TechProgenitor commented 2 years ago

Hi Kingo, Regarding my DSP processing, I realize that it isn’t really practical or ready for prime time at the moment due to the popping problem. No worries if you don’t want to use my EQ curve, it’s your system and you can do whatever you’d like with your audio. I’ll see though if I can fix the popping sometime, and integrate the verb commands on startup into the kext as well.

I’ve got to buy that adapter to see this headset/mic combo issue firsthand, but I haven't had problems personally connecting separate devices to the headphone/line-in jacks at the same time.

codec#0

I've still got a lot to learn regarding verbs/pathmaps, but observing the codec dump for this machine, it looks like switching that line input in your PlatformID connects the computer's audio devices to the same mixer which is better suited for using a forking adapter, and might be a better routing configuration for this soundcard than mine. To be honest though, I'm still kind of confused on how node 0x1B works and why node 0x19 and the pin widget command are responsible for eliminating headphone distortion. Perhaps there might even be a better way to route the audio so that the outputs can be wired in switching mode also, and verb commands can be reduced or not be required to run during headphone jack detection.

Just a note for the repo, the 0x19 verb command is all that’s needed to fix the headphone distortion. The 0x21 verb commands turn on/off the internal speakers. However, the verb commands that are used on node 0x21 work on nodes 0x1B and 0x14 for what appear to be obvious reasons.

Interestingly enough, I was going to get back to you regarding the WiFi on the Hackintosh! I’m using the Fenvi version of the BCM94352Z, and it seems to work much better with BrcmBluetoothInjector.kext, BrcmPatchRAM3.kext, and BrcmFirmwareData.kext. With AirportBrcmFixup.kext, sometimes the WiFi won’t work and I have to reboot the computer to get WiFi working. I did purchase the original (non-rebranded) version of the Broadcom WiFi card, but it was defective and costed 4x more than the Fenvi one.

I don’t seem to have the issue that you’re facing with the WiFi speed after sleep/wake (so don't do the plastic surgery XD), but I wouldn’t say that my router is well optimized for this card. I have a 6G router that auto selects the best speed instead of a 5G one which lets you individually select the 2G/5G speeds. For both Windows and macOS my WiFi speed is quite sporadic soaring to over 200 Mbps and going under 100Mbps. I think that it’s a firmware issue with my router than a kext issue.

I purchased the Fenvi version of the BCM94352Z from here: https://www.ebay.com/itm/273905200517?epid=15033164402&hash=item3fc605ad85:g:7VkAAOSw8Dhe3dvi

kingo132 commented 2 years ago

Hi, TechProgenitor, to be honest, these Hackintosh audio technologies are really complex for me, so I will dig into them later.

One thing I'd like to mention about the Wifi card is that you are using the same card as me. And this problem is not 100% happen depending on the wifi router it is connecting to. I use this machine in several places, and this sleep/wake slow problem only happens in one place with 5Ghz, 149 channel Wifi. So I suspect you are not free from this problem, maybe it's just a matter of time before you encounter a specific Wifi router.

Currently, I'm using the SleepWatcher to shutdown wifi before sleep and bring it back after wake: https://www.bernhard-baehr.de/, and using some instructions like this: https://chattymango.com/automatically-turn-off-wifi-when-putting-your-mac-to-sleep/

TechProgenitor commented 2 years ago

Hi Kingo, I’m full of it, It turns out that you might be correct, and I was just too far away from the router to notice. I moved right next to the router, and see that I'm usually getting around half of the max rated speed in macOS compared to Windows, and this is both before and after sleep/wake. Are you getting the same speed as Windows before sleep/wake?

I don’t know that I’m willing to chop up the plastic frame in my computer, but perhaps a different WiFi card would be more suitable to increase performance. I wish Intel Macs supported 6G WiFi cards…

If it helps I'm running macOS Big Sur Version 11.5.2.

kingo132 commented 2 years ago

I didn't encounter speed drop before sleep when compared to Windows. Only sleep/wake make it become crap, it will drop to 0.5Mbps speed and 200ms + ping latency after sleep with some specific router.

Here is my Wifi speed test result using BCM94352Z in Mac OS and Windows. It does have some performance drop in Mac OS, but not that significant. image image

TechProgenitor commented 2 years ago

Hi Kingo, Just wanted to let you know that I figured out how to display the correct GPU name in “About this Mac.” Just add the following device property and it should look like this:

Screen Shot 2022-08-28 at 4 33 32 PM

Any news with the WiFi card? I see that you upgraded your display again! I haven’t opened my current one and am tempted to resell it for the mini led one possibly. In case I decide to purchase this display, could you link a guide or just briefly explain what I'd need to do to modify the EDID info in the registry for Windows?

TechProgenitor commented 2 years ago

Also, I made some more startup chimes if you’re interested! For the volume, -5dB (FB) seems to be the sweet spot in my opinion. Right now for the chime that you’re currently using, I personally use -15dB (F1). Make the volume whatever you want though :) Mac Chimes for a51m-R2.zip

kingo132 commented 2 years ago

I decided not to chop up my frame as well, so I decided to live with this Wifi problem and prefer to solve it by SleepWatcher.

For my new Mini-LED display, there are several problems needed to be noticed.

First of all, most video service providers have problems playing 4k hdr content in Hackintosh due to the notorious DRM problem. Netflix can only be played by chrome with 720p resolution. If you try to play Netflix 4k using Safari, it will report an S7760 error. Apple TV+ also will black screen when playing videos. So if you want to enjoy the HDR movies on this display. You have to watch some casual or HDR test videos on youtube or download the 4k HDR movies directly using torrent software on some pirate website and play them by Movist. By using these two methods, the HDR effect on this Mini-LED display is good. By the way, you can play Netflix HDR video in Windows using the EDGE browser, but not in Hackintosh. But in my experience, the HDR effect in Windows is not as good as in macOS. So overall, despite you have a relatively good Mini-LED display, you have few opportunities to use it.

Secondly, this display has a strange effect. It will darken the surrounding area of a really bright area on the screen. So if you opened some white background application, such as chrome with a website with a huge white background. It looks like the white website will absorb all the LED power and become brighter, and the surrounding area will be dimmed. When you minimize or close this website and return to some dark background app, the dimmed area will turn brighter. So because of this sophisticated effect which may be provided by the display manufacturer, this display will become dark or bright by itself. Relatively, the XDR display in Macbook pro does not have this effect. It will be a little uncomfortable if you have half of the screen dark and another half white, eg, some E-mail app with a dark title list and white mail content. Because the dark side will be darker than normal and the white side will be brighter than normal.

Thirdly, this display also has a strange problem. The brightness adjusting function will become invalid after the system sleep and wake up. I have to turn off the display and light it again to reenable the brightness adjusting function. It was a little annoying. But I fixed it by adding some workaround method code in WhateverGreen, by coding this turning off and lighting up actions into WhateverGreen after the system wakes up, although this code may be a little dirty. My latest update of whatevergreen.kext has fixed this.

Fourthly, the crash problem in the Windows AMD driver I mentioned earlier. It can be fixed by using Custom Resolution Utility. After connecting to an external display and closing the lid, add the 4k@120hz resolution using CRU like this, and the problem will be solved.

image image image

Besides, this screen's controlling circuit is hotter than my prior display. The temperature underneath the ALIENWARE logo will go around 60~70 degrees+ and the finger will hurt if touched that area directly.

Apart from these problems, this Mini-LED display is better than my prior 4k@120hz WLED display. But I suppose the difference is not very very huge, it's not that huge difference when I first used the XDR display in the Macbook pro. Maybe the Macbook pro has a better user experience. However, in spite of these drawbacks, this display seems to be the most advanced Mini-LED laptop display right now, apart from the XDR display of Apple. So there's nothing to say, although it is not as good as the XDR display, but is the best apart from Apple.

TechProgenitor commented 2 years ago

Hi Kingo, thanks for the detailed technical writeup! I’m not sure how I can help you with the Netflix/Apple TV+ issues as I don’t have any subscription services. Regarding the second paragraph, I know that Mini-Led displays are suppose to have a high contrast ratio. Perhaps lowering it slightly through a new color profile or EDID would make doing casual work more comfortable? You could try doing the same in Windows to match the colors in macOS. I don’t have an XDR display to compare with, but I believe that should minimize the whole dimming and brightening of the screen.

kingo132 commented 2 years ago

You don't need a Netflix to test DRM. Look at this: https://dortania.github.io/OpenCore-Post-Install/universal/drm.html. Play the FairPlay videos there, and you can see the result. In my a51m, the FairPlay 1.x test will black screen. And I have tried many methods to fix it but without success. Maybe the current solution only supports the lower version of Safari or macOS. Plus, Apple TV+ has many free first episodes there and can be tested free.

I suppose it is not the color contrast. It is the brightness contrast that is higher than the standard display. No matter how I adjust the brightness, it will have darker black areas and brighter white areas. It should be OK if you have the whole screen black or white, but a little disturbing when half of the screen is dark and another half white, especially when reading text in this kind of scenario, imaging your eyes need to adjust to the bright and dark areas rapidly, although this scenario may not be very common.

I recorded a small video. You can somewhat feel this kind of brightness adjustment. https://user-images.githubusercontent.com/46492291/187334527-85901656-d980-4403-8add-649ff5ae8d02.mp4

Refer to the color profile of this display. It uses sRGB IEC61966-2.1 in Windows, and I can also choose this profile in macOS. The saturation is a bit high when using this color profile. I will try calibrating it using some professional devices a few weeks later.

TechProgenitor commented 2 years ago

I see exactly what you’re talking about for the DRM content: I get sound, but a black screen for the FairPlay 1.x test. I’ll see if I can come up with anything to solve this. Regarding the monitor situation, have you tried lowering the refresh rate to see if it helps? Also, I found a bug in your EFI... (Though you might have done this on purpose.) For the iGPU, your AAPL,ig-platform-id should be 07009B3E and not 0300C59B.

TechProgenitor commented 2 years ago

I worked out how to get the DRM working for the FairPlay 1.x test: Change the SMBIOS to iMacPro1,1 and use the boot argument -igfxvesa. (Just going to warn you now that if you change the SMBIOS, the keyboard will stop working. So plug in an external keyboard.)

I think what's going on in general is that for FairPlay 1.x, the iGPU is being selected to decode the video. This is because using -igfxvesa with the iMac20,2 SMBIOS won't even let you play the video.

It sounds like the way to fix the DRM is to get whatever is decoding the video signal to use the AMD GPU instead of the iGPU. I'm not sure how to do this currently. I'd personally like to be able to fix DRM completely without sacrificing the iGPU or SMBIOS. Just out of curiosity though, let me know if this fix currently gets Netflix, AppleTV+, etc working.

Finally, if you use the iMacPro1,1 SMBIOS without the -igfxvesa boot argument, Quicktime will crash with a debug log.

TechProgenitor commented 2 years ago

Looks like -igfxvesa and unfairgva=4 also get DRM working for the FairPlay 1.x test! Still, let’s see if we can do this and keep our iGPU.

TechProgenitor commented 2 years ago

Actually, I think I see why you chose that ig-platform-id: The headless configuration might be more stable. I didn’t even realize that the iGPU was disabled over the past few weeks, and to be honest, I’ll probably reach for the AMD GPU every time I connect to an external monitor. If we can get the iGPU working properly though with DRM, that would be awesome.

TechProgenitor commented 2 years ago

Here’s how to modify your config file to fix DRM at the expense of the iGPU: I guess I’m preparing for the day that I get a streaming account to binge watch some Rick and Morty. (ignore the boot arguments and SMBIOS change that I mentioned earlier)

Screen Shot 2022-08-31 at 2 47 04 AM

It looks like the Thunderbolt 3 port still works properly for data transfer, you just can’t output a video signal from it. To be fair, this laptop takes a Graphics Amplifier which gives me even more video outputs anyways.

Unless there’s issues with this patch or anything else that I can help with, I’m going to get back to trying to fix the audio verb commands and make my patch not pop. I’ve got a little more time to explore this now.

kingo132 commented 2 years ago

Hi, thank you for your brilliant work. I do get that FairPlay 1.x video playing after following your steps. However, Apple TV+ still got a black screen, and Netflix still cannot be played in Safari. So I guess maybe the software decoding is working now. But the FairPlay 2.x/3.x/4.x hardware decoding still has problems.

I kind of forgot why I chose 0300C59B instead of 07009B3E. Maybe disabling connectors can speed up the boot process. And these connectors are only useful when connecting to a type-c display through that type-c port, which is unlikely to happen in normal scenarios. And the real Apple iMac20,2, which also has 10900K, used 0300C59B as well.

Regarding the display brightness problem, lowering the refresh rate does not fix this. I'm using ProMotion already.

TechProgenitor commented 2 years ago

Dang, well at least we’re one step closer. I’m able to get the Apple TV+ trailers to play properly, but I can’t test any of the free episodes until I’ve signed into my Apple ID. I was planning to ask you what guide you’d recommend currently to fully configure an SMBIOS and activate IM/FT/iCloud/Apps/etc on macOS Monterey (I think Ventura will only be released in October and I’d rather let the bugs get ironed out). I’ve done this successfully on Clover, but I haven’t done it on OpenCore before.

Regarding hardware decoding, give the overrides on this page a try, and perhaps another SMBIOS such as the MacPro7,1. I don’t understand why the SMBIOS/iGPU affect the software decoding. Perhaps a binary patch might be necessary somewhere to fix the hardware decoding.

TechProgenitor commented 2 years ago

Hi Kingo, Just wanted to let you know that I figured out how to configure an SMBIOS with the Dorantina guide, and have gotten all of my iServices working! I’ve hardly looked at the DRM, but the strangest thing happens with the free episodes on AppleTV+… It seems to play back fine, but the video will stop abruptly, and I’ll get kicked out. (This is with the config.plist edits that I talked about earlier.) Not sure what could be causing this?

kingo132 commented 2 years ago

Hi Kingo, Just wanted to let you know that I figured out how to configure an SMBIOS with the Dorantina guide, and have gotten all of my iServices working! I've hardly looked at the DRM, but the strangest thing happens with the free episodes on AppleTV+… It seems to play back fine, but the video will stop abruptly, and I'll get kicked out. (This is with the config.plist edits that I talked about earlier.) Not sure what could be causing this?

I didn't encounter kicking out while watching Apple TV+. But the video will turn black after a few seconds of playing. The sound is OK, and it will continue playing with only the sound and black video playback.

TechProgenitor commented 2 years ago

Hi Kingo, You must have run this command: defaults write com.apple.AppleGVA gvaForceAMDKE -boolean yes

Before running this command, the player would crash. Looks like I’m now getting exactly what you described… after some time, the video goes black and I just have audio. (setting the above command to no makes the video crash after a few seconds) I can go back to where the video was working to get a picture though.

TechProgenitor commented 2 years ago

The free AppleTV+ content works perfectly on an external display! And if you mirror your display, you can select “optimize for (external display)” to get a picture. (see attached video) I feel like I’ve got a more general idea now of what we’re trying to fix for hardware decoding, but I’m not sure what will work.

https://user-images.githubusercontent.com/89800154/210321540-af5804aa-9718-47d7-8f0e-12fd8df53c01.MOV

kingo132 commented 2 years ago

It is hilarious, I never noticed the external display would have the video image. Nice finding. But it is mysterious and hard to know what exactly happened and also have no clues on how to fix it.

TechProgenitor commented 2 years ago

I don’t want to steer you in the wrong direction, but I’m thinking that it could be a handshake issue related to HDCP… I wonder if overriding something within the Radeon driver's framebuffer, AppleGVA, or the injected VBIOS (aty,bin_image property) is the solution? I’m predicting that HDCP is currently enabled on the external connections, but is disabled on the internal DisplayPort connection. Perhaps there's a way to spoof an iMac internal display's device and vendor ids? This could prove to be as challenging as fixing the brightness...

TechProgenitor commented 2 years ago

HDCP functions are located within the executable AMDRadeonX6000Framebuffer. Using Ida Pro, you can see that there's a couple of getters within the AmdHdcp2Lib class to return the HDCP status.

Perhaps we can interface with them to verify if HDCP is working on all of the GPU heads. Two getters in particular that look interesting are "getHdcp2AuthStatus" and "GetHDCPIsHDCPCapable."

This way we can absolutely be certain that this is an HDCP problem.

TechProgenitor commented 2 years ago

For these two functions, I believe that they'll tell you if HDCP is working. I'm thinking that the external monitor will return true and the internal monitor will return false. There might be a return value or condition though in some other function that we can exploit to force HDCP on the internal monitor.

TechProgenitor commented 2 years ago

Hi Kingo, I’ve got some exciting news to share with you!

Over the past few days, I’ve put the DRM aside and resorted back to fixing the audio. I’ve managed to completely eliminate the headphone distortion issue, and just have the EAPD issue left. To elaborate on the EAPD issue, the internal speakers don’t always come on or stay on, and have to be reset either through verb commands or a partial/full sleep/wake. In split mode, the speakers behave properly most of the time, but in switching mode (the ideal configuration), they don’t behave properly at all.

I realize that you can just use CodecCommander/ALCPlugFix to fix this, but I’m trying to see if we can possibly keep this Hackintosh installation vanilla.

The vanilla solution for this is to use node 0x14 instead of node 0x17 for our internal speakers. This is because this node sends the correct power state transitions to the codec. Through experimentation I’ve created a crazy patch that makes node 0x14 work using two speaker outs, but it isn’t stable on battery power for some reason (hoping this is just due to the pathmap configuration).

I’m trying to work out for my crazy patch what causes the audio signal to jump from node 0x17 to node 0x14 after using headphones, and back to node 0x17 after partial/full sleep/wake. I’m hoping that it’s as simple as translating a verb command or two into the pinconfig data. Was hoping that you might have an idea.

Once we work this out, we can then switch to node 0x14 for our internal speakers, and we should have perfectly working audio!

Below I’ve attached updated AppleALC source code, and a shell script from CodecCommander which I updated for AppleALC which dumps the present state of every node in the codec.

AppleALC Package for A51m-R2.zip