Adding Complex Impedance Support to Asterisk for an X100P FXO Card

First off – not all X100P clone cards are equal. If your card is NOT based in the Silicon Labs Si3014/Si3034 DAA, stop reading now, you’re wasting your time. I have an X100P SE from X100P.com, which is based on the required DAA, so I know mine can be set for complex impedance.

Right, a bit of background. I built my Asterisk server on an old VIA C3 EPIA board (Actually, a Wyse 9450 Winterminal) using Astlinux, as it’s one of the only Asterisk appliance distros that supports the Via C3 platform. I added an X100P card in order to receive incoming calls over copper, and to route outgoing local calls. I live in New Zealand, where our phone system requires complex AC termination impedance, so the standard modes offered by the DAHDI wcfxo kernel module, namely FCC and CTR21 were not optimal, as both modes only implement an AC termination impedance of 600Ω. It took a long time juggling tx and rx gains, and much playing with the echo canceller, before I got things acceptable. It’s not fun.

I knew that my card could support complex impedance from some documentation found on the suppliers website (novavox-x100p-se-global-line-standards), however, the patchfile that the documentation links to is long gone. Fortunately, the TBR21 patch for the wcfxo kernel module is well documented on the Digium website, and thus I was able to figure out what to do. As it turns out, it’s a really simple patch for the DAHDI wcfxo.c source file, as follows:

======================================
--- dahdi-linux-2.6.1/drivers/dahdi/wcfxo.c.orig 2012-10-13 09:35:10.000000000 -0500
+++ dahdi-linux-2.6.1/drivers/dahdi/wcfxo.c 2012-10-13 09:35:18.000000000 -0500
@@ -239,6 +239,13 @@
{ "CTR21", 0, 0, 3, 0, 0, 3, 0 }, /* Austria, Belgium, Denmark, Finland, France, Germany,
   Greece, Iceland, Ireland, Italy, Luxembourg, Netherlands,
   Norway, Portugal, Spain, Sweden, Switzerland, and UK */
+ { "TBR21", 0, 1, 3, 0, 0, 3, 0 }, /* CTR21 with complex impedance */
+ { "JATE", 0, 0, 1, 0, 0, 0, 0 }, /* Brazil, China, Egypt, Japan, Jordan, Kazakhstan, Malaysia,
+    Oman, Pakistan, Philipines, Russia, Syria, Taiwan, Thailand */
+ { "AUST", 1, 1, 1, 0, 0, 0, 0 }, /* Australia */
+ { "NZWL", 0, 1, 2, 0, 0, 0, 0 }, /* New Zealand */
+ { "PLSV", 0, 0, 2, 1, 1, 0, 0 }, /* Poland, Slovenia */
+ { "SAFR", 1, 0, 2, 1, 0, 0, 0 }, /* South Africa */
};
static inline void wcfxo_transmitprep(struct wcfxo *wc, unsigned char ints)
======================================

This gives six extra operating modes to the module. The required operating mode is passed to the module when loaded, like so:

# modprobe wcfxo opermode=x

where x is an integer that maps to the opermode as follows:

0 – FCC Mode
1 – CTR Mode
2 – TBR21 Mode
3 – JATE Mode
4 – AUST Mode
5 – NZWL Mode
6 – PLSV Mode
7 – SAFR Mode

You can see which mode is appropriate for which country from the comments contained in the patch. In Astlinux, the opermode for NZWL (New Zealand) is set in /etc/modprobe.d/options.conf as follows:

options wcfxo opermode=5

Now, having to crosscompile Astlinux for a Via C3 on a RedHat VM on my OS X box was going to be a pain. Luckily, Lonnie Abelbeck from the Astlinux project showed some interest in this patch, and very kindly compiled it for me. Hopefully if all goes well (As it has so far), this patch will become permanent in future Astlinux builds.

And lastly, a shameless plug, but from the point of view of a very satisfied user, and nothing more:

If you’re looking for an easy to use Asterisk appliance distro, which supports some of the more oddball hardware out there, look no further than Astlinux

 

Installing OS X Lion 10.7.4 on a Gigabyte X58A-UD3R Motherboard

I’ve been playing with Hackintoshes for quite a while now. Things have got a lot easier since the early days, but there are still a lot of quirks to it. The following is the installation procedure I followed for my set up. Of note is that I have a fairly problematic video card, based on the Radeon HD6670, mine is a Sapphire, PN 299-1E198-300SA.

Gather Your Prerequisites:

You will need:

  • An already functioning OS X machine (Easiest is to install 10.6 by following the procedures at http://tonymacx86.com for Snow Leopard)
  • An 8GB USB key for the installation media
  • Another USB key for the rest of what is required
  • myHack from http://myhack.sojugarden.com/
  • 10.7 installation media – You can buy this from Apple, or visit a torrent site
  • Your computer, based on an Gigabyte X58A-UD3R motherboard
  • From http://tonymacx86.comyou will need:
    • The correct DSDT for your board and BIOS version
    • Multibeast

Build Your Installation Media

If you don’t already have access to an OS X machine, build your Snow Leopard machine, or you can run up a VM. Once you have this going, follow the myHack instructions to build your installation binaries on the 8GB USB stick

Installing

When the Chameleon Bootloader starts counting down (While prompting you to hit any key to define boot parameters), go ahead an hit any key. If you don’t the boot WILL fail…

At the “Boot: ” prompt, type “-v -f cpus=1 arch=i386” – this also works as a general rule of thumb for ALL first-time boots.

Select your target, and let it build. Go and have a coffee. By the time you’ve finished your coffee, it will be asking you if you want to use a generic Extra directory – of course you do! Next it will ask if you want to remove the AppleTyMCEDriver.kext – May as well keep it. Do you want to remove the AppleUpstreamUserClient.kext? No…..I think we’ll keep that too……Restart when prompted

Configuring

When the Chameleon Bootloader starts counting down (While prompting you to hit any key to define boot parameters), go ahead an hit any key. If you don’t the boot WILL fail…

At the “Boot: ” prompt, type: “-v GraphicsEnabler=n cpus=1” (Minus the quotes)

Be prepared for much Matrix like crud scrolling on your screen. Eventually, you will get to the usual OS X initial account setup. Answer the questions. If you don’t know how to, give up, and go back to Windoze, OS X is not for you.

Right, you’ve got it booted, now the fun starts. There are a few initial considerations in order to achieve a clean boot, and also ensure that you can upgrade using the combo updater: The first is the DSDT. Remember that DSDT you downloaded for your board and firmware version? Copy it to the /Extra directory, ensuring it is named DSDT.aml. Remember, sudo is your friend. This will remove the requirement for the “cpus=1” boot flag. The second is to add some info specific to the Sapphire Radeon HD6670 graphics card. Edit /Extra/org.chameleon.Boot.plist, again, remember sudo is your friend. Just above the </dict> tag, add the following keys:

   <key>AtiConfig</key>
   <string>Pithecia</string>
   <key>AtiPorts</key>
   <string>3</string>

This will remove the requirement for the “GraphicsEnabler=No” boot flag, and ensure that you have a fully functioning graphics card Third, we want to be able to run the combo update without get a kernel panic. This requires a model identifier that is compatible, and the default model identifier (4,1) is not. So, again, editing org.chameleon.Boot.plist, just above the closing </dict> tag, add the following key:

    <key>SMBIOS</key>
    <string>/Extra/smbios.plist</string>

Now, add /Extra/smbios.plist – touch and edit, or just vi will do it. Give it the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>SMbiosversion</key>
    <string>MP51.007F.B03</string>
    <key>SMboardproduct</key>
    <string>Mac-F221BEC8</string>
    <key>SMfamily</key>
    <string>MacPro</string>
    <key>SMproductname</key>
    <string>MacPro5,1</string>
</dict>
</plist>

This will ensure that you can install the 10.7.4 combo update Now reboot. No boot flags required!

Combo Update and Kext Installation

OK, you’ve rebooted, you’ve got a flash OS X 10.7.0 Lion Hackintosh. You want 10.7.4, though. That’s easy, just run the combo updater you’ve already downloaded – Simple, isn’t it! Reboot Now, you’re ready to install the network, sound and SATA kexts. Note that you need to do this AFTER running the update. The updaters usually blow away the modified kexts.

Fire up Multibeast. Of note here is the Disk kext. You have two choices to make, “3rd Party SATA”, or “3rd Party eSATA”. Selecting “3rd Part SATA” will enable the eSATA ports, but they will not be hot-swappable. Using the eSATA option will make all of the SATA ports hot-swappable, except for those controlled by the Southbridge.  Make the following selections:

Multibeast Selections for X58A-UD3R

Reboot, and that’s it, all done!