### Example alc-verb Commands and Packed Output Source: https://github.com/acidanthera/applealc/wiki/Dumping-processing-coefficients Demonstrates how to use `alc-verb` with specific node, verb, and data values, and shows the resulting packed hexadecimal values. Processing coefficients typically involve a SET_COEF_INDEX verb followed by a SET_PROC_COEF verb. ```plaintext alc-verb 0x20 0x5 0x37 alc-verb 0x20 0x4 0x0101 ``` ```plaintext 0x02050037 0x02040101 ``` -------------------------------- ### Packing 12-bit Verbs for AppleALC Source: https://github.com/acidanthera/applealc/wiki/Dumping-processing-coefficients This shows the packing format for 12-bit verbs (verbs starting with 0x7 or 0xF). The format is `0x0nnvvvdd`, where `nn` is the node ID, `vvv` is the verb, and `dd` is the data. ```plaintext 0x0nnvvvdd ``` -------------------------------- ### AlcEnabler C++ API - Kernel Entry Point Source: https://context7.com/acidanthera/applealc/llms.txt Defines the kext entry point using the Lilu plugin API. It orchestrates the creation and initialization of the AlcEnabler singleton. ```cpp // kern_start.cpp — kext entry point wired via Lilu plugin API PluginConfiguration ADDPR(config) { xStringify(PRODUCT_NAME), parseModuleVersion(xStringify(MODULE_VERSION)), LiluAPI::AllowNormal | LiluAPI::AllowInstallerRecovery, bootargOff, arrsize(bootargOff), // "-alcoff" bootargDebug, arrsize(bootargDebug), // "-alcdbg" bootargBeta, arrsize(bootargBeta), // "-alcbeta" KernelVersion::Tiger, // minimum: macOS 10.4 KernelVersion::Tahoe, // maximum: macOS 26 []() { AlcEnabler::createShared(); // allocate singleton AlcEnabler::getShared()->init(); // register Lilu callbacks } }; ``` -------------------------------- ### Build and Run ResourceConverter Source: https://context7.com/acidanthera/applealc/llms.txt Build the ResourceConverter tool via Xcode and then execute it with the necessary plist files and resource directories. The output is the autogenerated kern_resources.cpp file. ```bash # Build ResourceConverter first via Xcode, then run: ./ResourceConverter/ResourceConverter \ Resources/Vendors.plist \ Resources/Kexts.plist \ Resources/CodecLookup.plist \ Resources/Controllers.plist \ Resources/ # Scans all codec subdirectories # Output: AppleALC/kern_resources.cpp (autogenerated — do not edit manually) # The generated file exports: # KernelPatcher::KextInfo kextList[] — kexts to watch/patch # ControllerModInfo controllerMod[] — HDA controller patches # VendorModInfo vendorMod[] — per-vendor codec databases # const size_t KextIdAppleHDA — index constants for patching ``` -------------------------------- ### Dump macOS Processing Coefficients with alc-verb Source: https://github.com/acidanthera/applealc/wiki/Dumping-processing-coefficients This script, part of AppleALC releases, dumps processing coefficients in macOS. Ensure 'alc-verb' is installed and enabled in your config.plist. You need to provide the device index, node ID, and count (ncoeff) obtained from the Linux dump. ```bash # Example usage (actual script not provided in source): # dump-coeff.sh ``` -------------------------------- ### Dump Debug Log via Boot Arguments Source: https://context7.com/acidanthera/applealc/llms.txt Combine `-alcdbg`, `-liludbg`, and `liludump=60` boot arguments to dump the debug log 60 seconds after boot. The output is saved to `/var/log/Lilu_VERSION_KERN_MAJOR.KERN_MINOR.txt`. ```bash boot-args: -alcdbg -liludbg liludump=60 ``` -------------------------------- ### Enable alc-verb User-Client Support via Boot Argument Source: https://context7.com/acidanthera/applealc/llms.txt Use the `alcverbs=1` boot argument to enable the alc-verb user-client, which allows runtime codec manipulation. ```bash alcverbs=1 ``` -------------------------------- ### Add New Codec: Create Info.plist Source: https://context7.com/acidanthera/applealc/llms.txt Create an Info.plist file within the new codec's directory (e.g., Resources/ALC299/). This file specifies codec details, layout, and platform information. Ensure the CodecID matches the hexadecimal value. ```xml Author YourName Vendor Realtek CodecID 4761 CodecName ALC299 Revisions 1048578 Files Layouts Comment YourName - ALC299 for YourDevice Id 21 Path layout21.xml.zlib MinKernel 13 Platforms Id 21 Path Platforms21.xml.zlib ``` -------------------------------- ### Local Validation and Build Commands Source: https://context7.com/acidanthera/applealc/llms.txt Commands for locally validating resource files and building the AppleALC kext. ```APIDOC ## Local Validation and Build ### Validate Resource Files #### Description Ensures that all `layout*.xml` and `Platforms*.xml` files in the `Resources/` directory are well-formed. #### Command ```bash find Resources -name "*.xml" | while read f; do xmllint --noout "$f" 2>&1 && echo "OK: $f" || echo "FAIL: $f" done ``` ### Rebuild Supported Codec Table #### Description Updates the `__wiki__/Supported-codecs.md` file with the latest codec information. #### Command ```bash bash Tools/wiki_table.command ``` ### Full Local Build #### Description Builds the AppleALC kext using Xcode. Requires Xcode and Lilu.kext headers in the parent directory. #### Command ```bash xcodebuild -project AppleALC.xcodeproj \ -target AppleALC \ -configuration Release \ SYMROOT=build ``` ``` -------------------------------- ### Enable on Unsupported macOS Versions via Boot Argument Source: https://context7.com/acidanthera/applealc/llms.txt Use the `-alcbeta` boot argument to enable AppleALC on unsupported or pre-release macOS versions. ```bash -alcbeta ``` -------------------------------- ### Using alc-verb with Different Verb Syntaxes Source: https://github.com/acidanthera/applealc/wiki/Dumping-processing-coefficients Illustrates that `alc-verb` accepts both Apple/Intel syntax (e.g., `0x5`) and Linux syntax (e.g., `0x500`) for verbs, as well as symbolic names. This flexibility aids in testing and debugging. ```plaintext alc-verb 0x20 0x4 0x0101 alc-verb 0x20 0x400 0x0101 alc-verb 0x20 SET_PROC_COEF 0x0101 ``` -------------------------------- ### alc-verb: Linux-syntax Verbs Source: https://context7.com/acidanthera/applealc/llms.txt Demonstrates using Linux-style verb commands with alc-verb, supported in version 1.6.9 and later. ```bash # Linux-syntax verbs also accepted (alc-verb >= 1.6.9): alc-verb 0 0x20 SET_PROC_COEF 0x0101 ``` -------------------------------- ### Enable Verbose Debug Logging via Boot Argument Source: https://context7.com/acidanthera/applealc/llms.txt Use the `-alcdbg` boot argument to enable verbose debug logging. This requires a debug build of AppleALC. ```bash -alcdbg ``` -------------------------------- ### GitHub Actions CI - Local Build Command Source: https://context7.com/acidanthera/applealc/llms.txt Command to perform a full local build of the AppleALC kext using xcodebuild, assuming Xcode and Lilu.kext headers are correctly set up. ```bash # Rebuild the supported codec table (updates __wiki__/Supported-codecs.md): bash Tools/wiki_table.command # Full local build (requires Xcode + Lilu.kext headers in ../Lilu/): xcodebuild -project AppleALC.xcodeproj \ -target AppleALC \ -configuration Release \ SYMROOT=build ``` -------------------------------- ### Add New Codec: Compress Layout XML Source: https://context7.com/acidanthera/applealc/llms.txt Compress the layout XML file using zlib-flate with the -compress option. This creates a .zlib file that will be referenced in the Info.plist. ```bash # Obtain layout XML from a working Linux or Windows driver dump, # or adapt an existing similar codec layout. # Compress with zlib: zlib-flate -compress < layout21.xml > layout21.xml.zlib ``` -------------------------------- ### Set layout-id via Boot Argument Source: https://context7.com/acidanthera/applealc/llms.txt Use the `alcid` boot argument to directly set the layout-id. This method is an alternative to using DeviceProperties. ```bash alcid=11 ``` -------------------------------- ### dump_coeff.sh: Pack and Add to Info.plist Source: https://context7.com/acidanthera/applealc/llms.txt Packs the corrected verb pairs into ConfigData hex values and instructs on how to append them to the AppleALC.kext Info.plist for permanent application. ```bash # Step 5: Pack and add to Info.plist ConfigData for your layout # Append to the existing ConfigData field: # 0x02050037 0x02040101 # Then edit: /EFI/OC/Kexts/AppleALC.kext/Contents/Info.plist # Locate your CodecID + LayoutID entry and append the packed verbs. ``` -------------------------------- ### Enable alc-verb Support Source: https://context7.com/acidanthera/applealc/llms.txt Enables the alc-verb tool for sending raw HDA verb commands. This can be set via boot arguments or DeviceProperties. ```bash # Enable alc-verb support (add to boot-args or DeviceProperties) # boot-args: alcverbs=1 ``` -------------------------------- ### ALCUserClientProvider C++ API - User-Space Verb Interface Source: https://context7.com/acidanthera/applealc/llms.txt Defines the ALCUserClientProvider class, which exposes a user-client connection for sending HDA verb commands from user space via the alc-verb tool. ```cpp // ALCUserClientProvider.hpp class ALCUserClientProvider : public IOService { public: // Called by ALCUserClient when alc-verb sends a command // nid: HDA node ID (e.g., 0x20) // verb: HDA verb code (e.g., 0x500 SET_COEF_INDEX, 0x400 SET_PROC_COEF) // param: verb data payload // returns: combined 64-bit result (upper 32 = status, lower 32 = output) virtual uint64_t sendHdaCommand(uint16_t nid, uint16_t verb, uint16_t param); }; // The IOUserClient method table maps kMethodExecuteVerb to methodExecuteVerb: // ALCUserClient::methodExecuteVerb receives IOExternalMethodArguments: // args->scalarInput[0] = nid // args->scalarInput[1] = verb // args->scalarInput[2] = param // args->scalarOutput[0] = result value // User-space invocation (via alc-verb CLI tool): // alc-verb 0 // Internally uses IOServiceOpen + IOConnectCallScalarMethod(kMethodExecuteVerb) ``` -------------------------------- ### ALCUserClientProvider User-Space Verb Interface Source: https://context7.com/acidanthera/applealc/llms.txt ALCUserClientProvider exposes a user-client connection allowing the `alc-verb` tool to send HDA verb commands directly from user space. ```APIDOC ## ALCUserClientProvider ### Description `ALCUserClientProvider` is the IOService that exposes a user-client connection so that the `alc-verb` tool can send HDA verb commands to the codec directly from user space without requiring a kernel debugger. ### Methods - **`sendHdaCommand(uint16_t nid, uint16_t verb, uint16_t param)`**: Called by ALCUserClient when `alc-verb` sends a command. ### Method: `sendHdaCommand` #### Description Sends an HDA verb command to the codec. #### Parameters - **`nid`** (uint16_t): HDA node ID (e.g., 0x20). - **`verb`** (uint16_t): HDA verb code (e.g., 0x500 SET_COEF_INDEX, 0x400 SET_PROC_COEF). - **`param`** (uint16_t): Verb data payload. #### Returns - **`uint64_t`**: Combined 64-bit result (upper 32 bits for status, lower 32 bits for output value). ### User-Space Invocation (via alc-verb CLI tool) - **Command**: `alc-verb ` - **Internal Mechanism**: Uses `IOServiceOpen` followed by `IOConnectCallScalarMethod` with `kMethodExecuteVerb`. ``` -------------------------------- ### Enable Coefficient Dumping in Linux Source: https://github.com/acidanthera/applealc/wiki/Dumping-processing-coefficients Execute this command to enable the dumping of processing coefficients in Linux for the duration of the current boot. This is a prerequisite for obtaining codec dumps. ```bash echo 1 | sudo tee /sys/module/snd_hda_codec/parameters/dump_coef ``` -------------------------------- ### alc-verb: Pack Verb Pairs for ConfigData Source: https://context7.com/acidanthera/applealc/llms.txt Shows how to pack verb pairs into ConfigData hex values for permanent inclusion in Info.plist. Supports 12-bit and 4-bit verb formats. ```bash # Pack verb pairs into ConfigData hex values for permanent inclusion in Info.plist: # 12-bit verb: 0x0nnvvvdd (nn=node, vvv=verb, dd=data) # 4-bit verb: 0x0nnvdddd (nn=node, v=verb, dddd=data) # # alc-verb 0x20 0x5 0x37 → 0x02050037 # alc-verb 0x20 0x4 0x0101 → 0x02040101 ``` -------------------------------- ### Add New Codec: Rebuild Kext Source: https://context7.com/acidanthera/applealc/llms.txt After adding the new codec's files and Info.plist, rebuild the kext using Xcode. The ResourceConverter will run automatically during the build process. ```bash # 6. Rebuild the kext in Xcode (ResourceConverter runs automatically) xcodebuild -project AppleALC.xcodeproj -target AppleALC -configuration Release ``` -------------------------------- ### Codec Detection Path (CodecLookup.plist) Source: https://context7.com/acidanthera/applealc/llms.txt Defines the IORegistry path to locate codec vendor and revision IDs. The 'Detect' key determines if the deepest node is searched for analog codecs. ```xml Tree PCI HDEF AppleHDACodecGeneric controllerNum 1 Detect ``` -------------------------------- ### Add New Codec: Find IORegistry Path Source: https://context7.com/acidanthera/applealc/llms.txt Use the ioreg command to find the IOHDACodecVendorID for your codec. This ID is crucial for identifying the codec in the system and is used when adding it to Resources/CodecLookup.plist. ```bash # Find IOHDACodecVendorID in IORegistryExplorer or: ioreg -l | grep IOHDACodecVendorID ``` -------------------------------- ### Dump Linux Codec Parameters Source: https://github.com/acidanthera/applealc/wiki/Dumping-processing-coefficients Use this command to dump the codec parameters in Linux. You may need to adjust 'card0' and 'codec#0' based on your system's configuration. Search the output for 'processing caps' to find relevant nodes and their 'ncoeff' values. ```bash cat /proc/asound/card0/codec#0 ```