1. Motivation
  2. Source modifications
    1. src/driver.h
    2. src/main.c
    3. src/tables.c
  3. Build
  4. Usage
  5. Demo LiveCD

Motivation

Trying to run multiple Fritz!Card PCI ISDN cards in one PC using the AVM's CAPI4Linux driver, I have found this howto. Since that howto is written for old driver and kernel version (2.4.x) and I wanted to use the last CAPI4Linux driver with a new kernel (2.6.x), I had to make myself the modifications to the driver sources.

Software:

Module

Version

Download

driver

03.11.02

ftp://ftp.avm.de/cardware/fritzcrd.pci/linux/suse.82/fcpci-suse8.2-03.11.02.tar.gz

kernel

2.6.9

-

Source modifications

src/driver.h

Declare the CAPI_INDEX variable by adding the following line at the end of the src/driver.h file:

extern short unsigned int CAPI_INDEX;

src/main.c

You have to prevent the multiple loading of the provided library lib/fcpci-lib.o when more than one Fritz!Card are detected. To do this, use the mycounter variable which will be incremented when the library is loaded.

--- fritz-3.11.02.orig/src/main.c
+++ fritz-3.11.02/src/main.c
@@ -52,10 +52,12 @@

 /*---------------------------------------------------------------------------*\
 \*---------------------------------------------------------------------------*/
-static char *  REVCONST        = "$Revision: 1.1.1.1 $";
+static char *  REVCONST        = "$Revision: 1.2 $";
 static char    REVISION[32];
 static int     mod_count       = 0;

+static int      mycounter       = 0;
+
 /*---------------------------------------------------------------------------*\
 \*---------------------------------------------------------------------------*/
 struct capi_driver fritz_capi_driver = {
@@ -259,8 +261,15 @@
        struct capicardparams           pars;
        int                             res = 0;

+       if ( mycounter > 0 )
+       {
+               NOTE("Don't want to load the library more times.\n");
+               return -ENODEV;
+       }
+
        assert (dev != NULL);
        UNUSED_ARG (id);
+
        if (pci_enable_device (dev) < 0) {
                ERROR("Error: Failed to enable " PRODUCT_LOGO "!\n");
                return -ENODEV;
@@ -274,7 +283,10 @@
                ERROR("Error: Driver library not available.\n");
                ERROR("Not loaded.\n");
                return -EBUSY;
-       }
+               }
+       else
+               mycounter = mycounter + 1;
+
        if (0 != (res = add_card (&fritz_capi_driver, &pars))) {
                ERROR("Not loaded.\n");
                return res;

src/tables.c

The CAPI_INDEX variable should be incremented for every new instance of the driver.
In this howto, the CAPI_INDEX variable will be evaluated from the driver name (f1pci, f2pci, ..., f9pci)

--- fritz-3.11.02.orig/src/tables.c
+++ fritz-3.11.02/src/tables.c
@@ -589,6 +589,7 @@
        appl_t *                appp;
        void *                  ptr;
        unsigned                nc;
+       const char*             myname = TARGET;

        MLOG("REGISTER(appl:%u)\n", appl);
        assert (ctrl != NULL);
@@ -630,6 +631,9 @@
                appp->data = ptr;
                unlock (card->appls->lock);
                (*card->reg_func) (ptr, appl);
+
+               if( (myname[1] >= '1') && (myname[1] <= '9') )
+                   CAPI_INDEX = myname[1] - 49;
        }
 } /* register_appl */


Build

You can build now the driver and you will get the file fcpci.ko. In this binary file, you should replace all occurrences of the "fcpci" string with "fXpci", where X is between 1 and 9. Here is an example for maximum 4 cards.

$ sed -r s/"fcpci"/"f1pci"/g fcpci.ko > f1pci.ko
$ sed -r s/"fcpci"/"f2pci"/g fcpci.ko > f2pci.ko
$ sed -r s/"fcpci"/"f3pci"/g fcpci.ko > f3pci.ko
$ sed -r s/"fcpci"/"f4pci"/g fcpci.ko > f4pci.ko

Usage

You can load now the new created drivers.

$ insmod f1pci.ko
$ insmod f2pci.ko
$ insmod f3pci.ko
$ insmod f4pci.ko

Demo LiveCD

If you want to give it a try before starting to build the drivers, you may use the Amatix InstantPBX LiveCD distribution.

MultipleFritzPCI (last edited 2006-07-25 22:17:20 by AmatiSoft)