Copy the keys CommonPeripheralDSP and PathMaps from LegacyHDA to AppleHDA.kext/Contents/Resources/Platforms.xml (replace original contents);
Copy the keys LayoutID and PathMapRef (they're inside key Layouts) to AppleHDA.kext/Contents/Resources/layout??.xml (replace original contents or create a new file if it doesn't exist, ?? = LayoutID);
Copy the dict from key HDAConfigDefault (it's inside key HDA Hardware Config Resource) to key HDAConfigDefault in AppleHDA.kext/Contents/PlugIns/AppleHDAHardwareConfigDriver.kext/Contents/Info.plist (paste as child);
Use PlistEdit Pro to edit the plist files.
If the codec isn't ALC889A or AD1988B you will also need to edit the file AppleHDA.kext/Contents/MacOS/AppleHDA (binary).
For Realtek (ALC88x) replace the 4 instances of 85 08 EC 10 (inverted bytes of codec 0885 and vendor 10EC) by your codec, for example, 88 08 EC 10.
Use an hex editor (0xED) or the command
sudo perl -pi -e 's|\x85\x08\xec\x10|\x88\x08\xec\x10|g' /System/Library/Extensions/AppleHDA.kext/Contents/MacOS/AppleHDA
For Analog Devices (AD) replace the 4 instances of 8B 19 D4 11 by your codec
sudo perl -pi -e 's|\x8b\x19\xd4\x11|\x9b\x98\xd4\x11|g' /System/Library/Extensions/AppleHDA.kext/Contents/MacOS/AppleHDA
If you have a patched AppleHDA for Snow Leopard (10.6.7 or older), instead of taking values from LegacyHDA you will get them from AppleHDA plug-ins.
CommonPeripheralDSP, PathMaps, LayoutID and PathMapRef come from AppleHDA.kext/Contents/PlugIns/AppleHDAPlatformDriver.kext/Contents/Info.plist
The dict in HDAConfigDefault comes from AppleHDA.kext/Contents/PlugIns/AppleHDAController.kext/Contents/Info.plist
Snow Leopard 10.6.8 AppleHDA has the same structure as Lion one.