Jump to content

AppleALC — dynamic AppleHDA patching


vit9696
5,371 posts in this topic

Recommended Posts

Hi,

 

I compile for alc 892.

I get this error at boot :

 

AppleALC: mach @ no slide is present.

AppleALC: alc @ failed to setup kext hooking.

 

no error if i load it with kextload.

 

Fred

Link to comment
Share on other sites

attachicon.gifResources.zip

Resources for HDA Codec #0: Analog Devices AD1988B

HDA Codec ID: 0x11d4198b

Vendor: 0x11d4

Device: 0x198b

 

but it doesn't work

what's wrong?

Hi,

 

I assume you are the same guy from life, therefore I will reply there.

 

 

Hi,

 

I compile for alc 892.

I get this error at boot :

 

AppleALC: mach @ no slide is present.

AppleALC: alc @ failed to setup kext hooking.

 

no error if i load it with kextload.

 

Fred

 

Hi,

Please enable alc_dbg in boot arguments, and pass me the whole log grepped by AppleALC.

Link to comment
Share on other sites

i've try to patch hd4600.

But does not works.

I don't forget to add AppleHDAController to kext.plist

 

ALC892-with patch hdmi hd4600.zip

debug.log.zip

 

Patch is not like other, Toleda do that.

 

# HD4600/0c0c HDMI El Capitan

sudo xxd -ps /System/Library/Extensions/AppleHDA.kext/Contents/Plugins/AppleHDAController.kext/Contents/MacOS/AppleHDAController | tr -d > /tmp/AppleHDAController.txt

sudo perl -pi -e 's|3d0c0a0000|3d0c0c0000|g' /tmp/AppleHDAController.txt

sudo xxd -r -p /tmp/AppleHDAController.txt /System/Library/Extensions/AppleHDA.kext/Contents/Plugins/AppleHDAController.kext/Contents/MacOS/AppleHDAController

sudo rm -R /tmp/AppleHDAController.txt

 

 

One more thing, debug boot-args parsing does not work for me.

To get debug i need to : debugEnabled = true; //PE_parse_boot_argn(booatargDebug, buf, sizeof(buf));

 

Fred

 

PS Bootloader Ozmosis, GA-H97N-WIFI

Link to comment
Share on other sites

Indeed AppleHDAController patching is currently broken, thanks for the log which made it clear.

Although, it might be a little problematic. Given that we detect the codecs by AppleHDAController results.

Do you have any good ideas on how to detect them before AppleHDAController loads other than direct probing?

 

Perhaps, 3d0c0a0000 → 3d0c0c0000 patching can be used regardless of the codec? Does this patch conflict with anything? Do AppleHDAController patches need anything special other than that for other platforms?

 

From what I can from the disassembly tell this patch simply changes the some id from 0xA0C to 0xC0C.

 if ( v15 != 0xC0C /* this thing */ && v15 != 0xD0C && v15 != 0x160C )  {
    LODWORD(v16) = (*(int (__fastcall **)(AppleHDAController *, _QWORD, _BYTE *))(*(_QWORD *)v4 + 696LL))(
                     v4,
                     AppleHDAController::DPAudioDeviceExclusionString,
                     byte_11FE8);

or

bool __fastcall AppleHDAController::shouldSetGraphicsClockDivider(AppleHDAController *this){
  int id; // eax@2
  bool result; // al@5


  result = 0;
  if ( *((_DWORD *)this + 948) == 0x8086 )      // Intel
  {
    id = *((_DWORD *)this + 949);
    if ( id == 0xA0C || id == 0xD0C || id == 0x160C )
      result = 1;
  }
  return result;
}

Making it not to exclude 0xC0C from the supported list.

May it be a good idea to replace the jmps instead of the id itself? Or that is going to conflict with some completely unsupported devices?

 

As for boot-args, the debug argument changed to -alcdbg. Are you sure you use the new one?

Link to comment
Share on other sites

Indeed AppleHDAController patching is currently broken, thanks for the log which made it clear.

Although, it might be a little problematic. Given that we detect the codecs by AppleHDAController results.

Do you have any good ideas on how to detect them before AppleHDAController loads other than direct probing?

 

Perhaps, 3d0c0a0000 → 3d0c0c0000 patching can be used regardless of the codec? Does this patch conflict with anything? Do AppleHDAController patches need anything special other than that for other platforms?

 

From what I can from the disassembly tell this patch simply changes the some id from 0xA0C to 0xC0C.

 if ( v15 != 0xC0C /* this thing */ && v15 != 0xD0C && v15 != 0x160C )  {
    LODWORD(v16) = (*(int (__fastcall **)(AppleHDAController *, _QWORD, _BYTE *))(*(_QWORD *)v4 + 696LL))(
                     v4,
                     AppleHDAController::DPAudioDeviceExclusionString,
                     byte_11FE8);

or

bool __fastcall AppleHDAController::shouldSetGraphicsClockDivider(AppleHDAController *this){
  int id; // eax@2
  bool result; // al@5


  result = 0;
  if ( *((_DWORD *)this + 948) == 0x8086 )      // Intel
  {
    id = *((_DWORD *)this + 949);
    if ( id == 0xA0C || id == 0xD0C || id == 0x160C )
      result = 1;
  }
  return result;
}

Making it not to exclude 0xC0C from the supported list.

May it be a good idea to replace the jmps instead of the id itself? Or that is going to conflict with some completely unsupported devices?

 

As for boot-args, the debug argument changed to -alcdbg. Are you sure you use the new one?

 

Hi,

 

Debug trace is ok now with new option -alcdbg. (Update wiki, if not done)

I try to patch with dsdt but does not work.

i'm not able to help on this kind of issue, i've no skill on that.

But what i find strange is the way taken by Toleda to patch this kext.

May be he can explain why it can't be done like other ?

 

Fred

Link to comment
Share on other sites

I had a talk with a few people, and I think I got the point of this kind of patching.

Such patches are not codec patches but codec controller patches. Therefore they are not dependent on codec detection.

I am writing an update in the periods I have free time, hopefully it will be ready soon. In a new version one will be able to apply codec controller patches and therefore use AppleALC for Intel HD4600 HDMI audio, x99 analog audio, and possibly more.

Link to comment
Share on other sites

I had a talk with a few people, and I think I got the point of this kind of patching.

Such patches are not codec patches but codec controller patches. Therefore they are not dependent on codec detection.

I am writing an update in the periods I have free time, hopefully it will be ready soon. In a new version one will be able to apply codec controller patches and therefore use AppleALC for Intel HD4600 HDMI audio, x99 analog audio, and possibly more.

 

 

Very nice, as i see you able to patch on the fly, should be interesting to patch other kind of kext. i think about usb limit. ;)

So i know it's not the goal of you project...

 

Fred

Link to comment
Share on other sites

Will test ASAP, nice work. This is a great idea, now audio can work regardless of SIP settings/etc and with a clean install.

 

Edit: Working fine with ALC898 here. Removed /L/E/AppleHDA898.kext (generated with Pike's script) and deleted Clover kext patch entries, then rebuilt kext caches - audio is still working well.

Link to comment
Share on other sites

I added controller patching code to trunk with x99/hd4600 examples. HDMI audio should be addible now.

Any other (even non-audio) kext patching can be done as well, the platform allows it, just edit the plists.

 

Rockey12, pretty much no one here will write anything for you, and me in particular. There is a decent instruction, follow it and make the codec supported if it is not already. Why do people think I am the one going to set their audio up after creating a platform and even writing the docs on how to use it.

 

pmcnano, I use nvidia web drivers here, and the system boots at least. No idea what fails for you, be more descriptive if you want to get a decent reply.

  • Like 3
Link to comment
Share on other sites

I added controller patching code to trunk with x99/hd4600 examples. HDMI audio should be addible now.

Any other (even non-audio) kext patching can be done as well, the platform allows it, just edit the plists.

 

Rockey12, pretty much no one here will write anything for you, and me in particular. There is a decent instruction, follow it and make the codec supported if it is not already. Why do people think I am the one going to set their audio up after creating a platform and even writing the docs on how to use it.

 

pmcnano, I use nvidia web drivers here, and the system boots at least. No idea what fails for you, be more descriptive if you want to get a decent reply.

 

 

Hello,

 

AppleALC does not work for me.

 

debug.log.zip

 

Fred

Link to comment
Share on other sites

AppleALC does not work for me.

 

Fred

 

Same alc892 & log here. Got it working with latest Andrey1970s compiled kext from applelife. Looks like applealc always failed to patch the target binary (only working with clover patch) when i compile it myself. And now receiving error when compiling with latest commit from repo. Could anyone share your "working" full project source here please

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...