Skip to content

Adding codec support

vandroiy2013 edited this page Sep 9, 2019 · 13 revisions

How to add a new codec to AppleALC

This task is fairly simple and requires no programming skills. In short you are meant to edit a few plists, copy the necessary files, and rebuild the kernel extension using Xcode.

File structure

All the data to be possibly edited exists in Resources folder, and each supported codec is meant to lie in its subfolder with an arbitrary suitable name.

  • Vendors.plist file is meant to contain all the necessary hardware manufacturers and their ids as an associative array. You will unlikely need to edit this.
  • Kexts.plist file is meant to contain all the necessary kext information possibly used for patching. It also is an associative array with kext dictionaries containing:
  • Id — CFBundleIdentifier from the kext's Info.plist;
  • Paths — Possible kext locations in an array.
  • CodecLookup.plist file is meant to let AppleALC detect your codecs by providing the IORegistry lookup paths. All the paths are prefixed, therefore PCI will match PCI0, for example.
  • Tree — array containing the IORegistry path starting from IOService:/PCI/AppleACPIPlatformExpert, its last key is meant to contain IOHDACodecVendorID and IOHDACodecRevisionID properties;
  • controllerNum — Tree path index containing controller properties (e. g. layout-id) starting from 0.
  • Detect — defines whether to look for codecs in the latest entry (set to YES for analog controllers like Realtek).
  • Controllers.plist file is meant to apply global modifications to audio controllers including but not limiting to HDMI audio. Each entry includes the following properties:
    • Vendor — Vendor name string from Vendors.plist;
    • Device — Device identifier (see device-id);
    • Name — Controller name (any form);
    • Platform — Matching AAPL,ig-platform-id value if is to be present (optional);
    • Revisions — Supported controller revisions in an array (optional, omit for no revision check);
    • Patches — all the binary patches possibly needed for applying in an array (optional):
      • Count — number of required replacements;
      • Find — what to look for;
      • Replace — what to replace with;
      • Name — kext name from Kexts.plist;
      • MinKernel — minimal suitable major kernel version (optional);
      • MaxKernel — maximum suitable major kernel version (optional).

Codec folder structure

Each codec must contain an Info.plist file describing the necessary changes AppleALC is to make. The other files in the folder may include layout/platform data mentioned in Info.plist. Info.plist should include:

  • Vendor — Vendor name string from Vendors.plist;
  • CodecID — Codec identifier (lower 2 bytes of IOHDACodecVendorID);
  • CodecName — Human readable codec name for logging;
  • Revisions — Supported codec revisions (IOHDACodecRevisionID values) in an array (optional, omit for no revision check);
  • Author — Human readable modification author (optional);
  • Files — All the files possibly needed for injection:
    • Platforms — platform variants (optional):
      • Id — matching layout-id number;
      • Path — file path in the codec directory;
      • MinKernel — minimal suitable major kernel version (optional, see uname -r shell command);
      • MaxKernel — maximum suitable major kernel version (optional).
    • Layouts — layout variants (optional):
      • Id — matching layout-id number;
      • Path — file path in the codec directory;
      • MinKernel — minimal suitable major kernel version (optional);
      • MaxKernel — maximum suitable major kernel version (optional).
  • Patches — all the binary patches possibly needed for applying in an array (optional):
  • Count — number of required replacements;
  • Find — what to look for;
  • Replace — what to replace with;
  • Name — kext name from Kexts.plist;
  • MinKernel — minimal suitable major kernel version (optional);
  • MaxKernel — maximum suitable major kernel version (optional).

Step by step algorithm (Xcode is necessary)

  1. Check if your codec vendor is present in Vendors.plist and add it if necessary.
  2. Check if the kexts you plan to patch are present in Kexts.plist and add them if necessary.
  3. Check the paths of IOHDACodecVendorID/IOHDACodecRevisionID/layout-id for your codec in the IORegistry and add them to CodecLookup.plist if necessary.
  4. Create a codec folder in Resources and copy the necessary layouts and platforms inside.
  5. Create an Info.plist file filled with the necessary information structured accordingly to the previous section
  6. Rebuild the kext

Rules to add Resources

Layouts from 1 to 10 reserved for Mirone/Toleda basic patches

Desktop codecs:

  • Layout 1, 2, 3 Toleda resources
  • Layout 5, 7 Mirone resources

Laptop codecs:

  • Layout 1, 2, 3, 4, 5, 6, 7, 8 Mirone resources

Custom user layouts (both desktop and laptop)

  • Layout from 11 to 99

Please don't add Toleda/Mirone resources as Custom User resources under layouts 11-99 to avoid unnesessary duplication and to reduce kext size.

Example:

Let's take a look on ALC282
layout3.xml.zlib and layout4.xml.zlib - Mirone resources for laptops
layout86.xml.zlib - Custom user resource
platforms86.xml.zlib - Custom platform relevant to layout86.xml.zlib
platformsM3.xml.zlib and platformsM4.xml.zlib - Mirone platform relevant to Mirone's layout 3 and 4

In codec info.plist and PinConfig info.plist please make comment line on every item you add for platform and layouts with description (Human readable codec name, author(Mirone, Toleda or Custom). If custom - determine the model of laptop or motherboard and your name.

You can’t perform that action at this time.