summaryrefslogtreecommitdiff
path: root/drivers/dahdi
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2008-05-21 15:12:46 +0000
committerKevin P. Fleming <kpfleming@digium.com>2008-05-21 15:12:46 +0000
commit8c0a3d5841120b634547514da836ce8a105d1934 (patch)
tree517339a6e3675382ef7283cb810f5f559ea687d9 /drivers/dahdi
parent802b567e6c7ba7803a950324cbed13f7d57944cb (diff)
remove unsupported modules
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@4316 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi')
-rw-r--r--drivers/dahdi/torisa.c1172
-rw-r--r--drivers/dahdi/wcusb.c1490
-rw-r--r--drivers/dahdi/wcusb.h142
3 files changed, 0 insertions, 2804 deletions
diff --git a/drivers/dahdi/torisa.c b/drivers/dahdi/torisa.c
deleted file mode 100644
index 9fa24b8..0000000
--- a/drivers/dahdi/torisa.c
+++ /dev/null
@@ -1,1172 +0,0 @@
-/*
- * Zapata Telephony "Tormenta" ISA card LINUX driver, version 2.2 11/29/01
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Modified from original tor.c by Mark Spencer <markster@digium.com>
- * original by Jim Dixon <jim@lambdatel.com>
- */
-
-#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
-#include <linux/config.h>
-#endif
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <asm/io.h>
-#ifdef STANDALONE_ZAPATA
-#include "zaptel.h"
-#else
-#include <zaptel/zaptel.h>
-#endif
-#ifdef LINUX26
-#include <linux/moduleparam.h>
-#endif
-
-/* Board address offsets (specified in word (not byte) offsets) */
-#define DDATA 0 /* Data I/O Register */
-#define DADDR 0x100 /* Dallas Card Address Reg., 0x200 in byte offset higher */
-#define CTLREG 0x100 /* Control/Status Reg., 0x200 in byte offset */
-
-/* Control register bits */
-#define OUTBIT 8 /* Status output bit (for external measurements) */
-#define INTENA 4 /* Interrupt enable bit */
-#define MASTERVAL 0x41 /* Enable E1 master clock on Rev. B board */
-#define ENA16 0x80 /* 16 bit bus cycle enable bit */
-
-#define TYPE_T1 1 /* is a T1 card */
-#define TYPE_E1 2 /* is an E1 card */
-
-#define E1SYNCSTABLETHRESH 15000 /* amount of samples needed for E1 Sync stability */
-
-static int syncsrc;
-
-static int syncs[2];
-
-static int debug;
-
-#define MASTERCLOCK (*clockvals) /* value for master clock */
-
-/* clock values */
-static u_char clockvals_t1[] = {MASTERVAL,0x12,0x22,MASTERVAL};
-static u_char clockvals_e1[] = {MASTERVAL,0x13,0x23,MASTERVAL};
-
-static u_char *clockvals;
-
-/* translations of data channels for 24 channels in a 32 bit PCM highway */
-unsigned datxlt_t1[] = { 0,
- 1 ,2 ,3 ,5 ,6 ,7 ,9 ,10,11,13,14,15,17,18,19,21,22,23,25,26,27,29,30,31 };
-
-/* translations of data channels for 30/31 channels in a 32 bit PCM highway */
-unsigned datxlt_e1[] = { 0,
- 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,
- 25,26,27,28,29,30,31 };
-
-unsigned int *datxlt;
-
-/* This is the order that the data (audio) channels get
-scanned in. This was done in this rather poopy manner because when outputting
-(and inputting) a sine wave, such as in the case of TDD, any repeated samples
-(because of PCM bus contention) will result in nasty-sounding distortion. The
-Mitel STPA chips (MT8920) have a contention mechanism, which results in a
-situation where, if the processor accesses a timeslot that is currently
-being transmitted or received, it will HOLD the bus until it is done with
-the timeslot. This means that there can be cases where we are trying
-to write to a timeslot, and its already outputting the same value
-as the last one (since we didnt get there in time), and in a sine-wave
-output, distortion will occur. In any other output, it will be utterly
-un-noticeable. So, what we do is use a pattern that gives us the most
-flexibility in how long our interrupt latency is (note: Even with this,
-our interrupt latency must be between 4 and 28 microseconds!!!) Essentially
-we receive the interrupt just after the 24th channel is read. It will
-take us AT LEAST 30 microseconds to read it, but could take as much as
-35 microseconds to read all the channels. In any case it's the very
-first thing we do in the interrupt handler. Worst case (30 microseconds)
-is that the MT8920 has only moved 7 channels. That's where the 6 comes from.
-*/
-
-static int chseq_t1[] =
- { 6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,1,2,3,4,5 } ;
-
-static int chseq_e1[] =
- { 6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,1,2,3,4,5 } ;
-
-static int *chseq;
-
-struct torisa_pvt {
- int span;
-};
-
-static struct zt_span spans[2];
-static struct zt_chan chans[64];
-static struct torisa_pvt pvts[64];
-static u_char txsigs[2][16];
-static int loopupcnt[2];
-static int loopdowncnt[2];
-static int alarmtimer[2];
-
-static int channels_per_span = 24;
-
-static int card_type = TYPE_T1;
-
-static int prefmaster = 0;
-
-static int spansstarted = 0;
-
-#ifdef DEFINE_RWLOCK
-static DEFINE_RWLOCK(torisa);
-#else
-static rwlock_t torisa = RW_LOCK_UNLOCKED;
-#endif
-
-static u_char readdata[2][64][ZT_MAX_CHUNKSIZE];
-static u_char writedata[2][64][ZT_MAX_CHUNKSIZE];
-static u_char last_ecwrite[2][32];
-static int curread;
-
-static unsigned long base;
-volatile static unsigned short *maddr;
-
-static int irq;
-static unsigned int irqcount = 0;
-static unsigned int taskletsched = 0;
-static unsigned int taskletrun = 0;
-static unsigned int taskletexec = 0;
-
-/* set the control register */
-static void setctlreg(unsigned char val)
-{
-volatile register char *cp;
-
- cp = (char *) &maddr[CTLREG];
- *cp = val;
-}
-
-/* output a byte to one of the registers in one of the Dallas T-1 chips */
-static void t1out(int spanno, int loc, unsigned char val)
-{
-register int n;
-volatile register char *cp;
-
- /* get the memory offset */
- n = spanno << 9;
- /* point a char * at the address location */
- cp = (char *) &maddr[DADDR + n];
- *cp = loc; /* set address in T1 chip */
- /* point a char * at the data location */
- cp = (char *) &maddr[DDATA + n];
- *cp = val; /* out the value */
-}
-
-/* get a byte from one of the registers in one of the Dallas T-1 chips */
-static unsigned char t1in(int spanno, int loc)
-{
-register int n;
-volatile register char *cp;
-
- /* get the memory offset */
- n = spanno << 9;
- /* point a char * at the address location */
- cp = (char *) &maddr[DADDR + n];
- *cp = loc; /* set address in T1 chip */
- cp = (char *) &maddr[DDATA + n];
- /* point a char * at the data location */
- return(*cp);
-}
-
-/* get input from the status register */
-static unsigned char getctlreg(void)
-{
-register char *cp;
-
- cp = (char *) &maddr[CTLREG];
- return(*cp);
-}
-
-static void set_clear(void)
-{
- int i,j,s;
- unsigned short val=0;
- for (s=0;s<2;s++) {
- for (i=0;i<channels_per_span;i++) {
- j = (i/8);
- if (spans[s].chans[i].flags & ZT_FLAG_CLEAR)
- val |= 1 << (i % 8);
-
- if ((i % 8)==7) {
-#if 0
- printk("Putting %d in register %02x on span %d\n",
- val, 0x39 + j, 1 + s);
-#endif
- t1out(1 + s, 0x39 + j, val);
- val = 0;
- }
- }
- }
-
-}
-
-/* device probe routine .. determines if the Tormenta device is present in
- the system */
-static int
-tor_probe(void)
-{
- int i,status;
- u_char c1,c2;
- maddr = phys_to_virt(base);
-
- status = -1; /* default status return is 'not present' */
-
- clockvals = clockvals_t1;
- datxlt = datxlt_t1;
- chseq = chseq_t1;
-
- /* initialize control register */
- setctlreg(MASTERCLOCK);
-
- /* init all the registers in first T-1 chip to 0 */
- for(i = 0; i <= 0xff; i++) t1out(1,i,0); /* set register to 0 */
- /* simple test that will fail if tried in an array of standard memory */
- /* put an 0x55 here */
- t1out(1,0x2b,0x55);
- /* put an 0xaa here */
- t1out(1,0x2c,0xaa);
- /* get input from first location */
- c1 = t1in(1,0x2b);
- /* get input from second location */
- c2 = t1in(1,0x2c);
- /* see if we read back what we put in */
- if ((c1 == 0x55) && (c2 == 0xaa)) {
- /* We now need to determine card type */
- /* This test is documented in Dallas app note 341 */
- t1out(1, 0x7D, 0);
- t1out(1, 0x36, 0);
- t1out(1, 0x15, 0);
- t1out(1, 0x19, 0);
- t1out(1, 0x23, 0x55);
- c1 = t1in(1, 0x23);
- if (c1 == 0x55) { /* if this is an E-1 card */
-
- clockvals = clockvals_e1;
- chseq = chseq_e1;
- channels_per_span = 31;
- datxlt = datxlt_e1;
- card_type = TYPE_E1;
-
- /* initialize control register */
- setctlreg(MASTERCLOCK);
- }
- /* Try to get the irq if the user didn't specify one */
- if (irq < 1) {
-#ifdef LINUX26
- unsigned long irqs;
- unsigned long delay = jiffies + 5;
- irqs = probe_irq_on();
- setctlreg(MASTERCLOCK|INTENA);
- while((long)(jiffies - delay) < 0);
- irq = probe_irq_off(irqs);
-#else
- autoirq_setup(0);
- setctlreg(MASTERCLOCK|INTENA);
- /* Wait a jiffie -- that's plenty of time */
- irq = autoirq_report(5);
-#endif
- }
- /* disable interrupts having gotten one */
- setctlreg(MASTERCLOCK);
- if (irq == 2)
- irq = 9;
- if (irq) {
- /* init both STPA's to all silence */
- for(i = 0; i < 32; i++) maddr[i] = 0x7f7f;
-
- status = 0; /* found */
- if (debug)
- printk("ISA Tormenta %s Card found at base addr 0x%lx, irq %d\n",
- ((card_type == TYPE_E1) ? "E1" : "T1"),
- base,irq);
- } else
- printk("ISA Tormenta %s Card found at base addr 0x%lx, but unable to determine IRQ. Try using irq= option\n",
- ((card_type == TYPE_E1) ? "E1" : "T1"), base );
- }
- return status;
-}
-
-static void make_chans(void)
-{
- int x,y;
- int c;
- for (x=0;x<2;x++)
- for (y=0;y<channels_per_span;y++) {
- c = x * channels_per_span + y;
- sprintf(chans[c].name, "TorISA/%d/%d", x + 1, y + 1);
- chans[c].sigcap = ZT_SIG_EM | ZT_SIG_CLEAR | ZT_SIG_FXSLS | ZT_SIG_FXSGS | ZT_SIG_FXSKS |
- ZT_SIG_FXOLS | ZT_SIG_FXOGS | ZT_SIG_FXOKS | ZT_SIG_CAS | ZT_SIG_SF;
- chans[c].pvt = &pvts[c];
- pvts[c].span = x;
- chans[c].chanpos = y + 1;
- }
-
-}
-
-static int torisa_rbsbits(struct zt_chan *chan, int bits)
-{
- u_char m,c;
- int k,n,b;
- struct torisa_pvt *p = chan->pvt;
- unsigned long flags;
-#if 0
- printk("Setting bits to %x hex on channel %s\n", bits, chan->name);
-#endif
- if (card_type == TYPE_E1) { /* do it E1 way */
- if (chan->chanpos > 30) return 0; /* cant do this for chan 31 */
- n = chan->chanpos - 1;
- k = p->span;
- b = (n % 15) + 1;
- c = txsigs[k][b];
- m = (n / 15) * 4; /* nibble selector */
- c &= (15 << m); /* keep the other nibble */
- c |= (bits & 15) << (4 - m); /* put our new nibble here */
- txsigs[k][b] = c;
- /* output them into the chip */
- t1out(k + 1,0x40 + b,c);
- return 0;
- }
- n = chan->chanpos - 1;
- k = p->span;
- b = (n / 8); /* get byte number */
- m = 1 << (n & 7); /* get mask */
- c = txsigs[k][b];
- c &= ~m; /* clear mask bit */
- /* set mask bit, if bit is to be set */
- if (bits & ZT_ABIT) c |= m;
- txsigs[k][b] = c;
- write_lock_irqsave(&torisa, flags);
- t1out(k + 1,0x70 + b,c);
- b += 3; /* now points to b bit stuff */
- /* get current signalling values */
- c = txsigs[k][b];
- c &= ~m; /* clear mask bit */
- /* set mask bit, if bit is to be set */
- if (bits & ZT_BBIT) c |= m;
- /* save new signalling values */
- txsigs[k][b] = c;
- /* output them into the chip */
- t1out(k + 1,0x70 + b,c);
- b += 3; /* now points to c bit stuff */
- /* get current signalling values */
- c = txsigs[k][b];
- c &= ~m; /* clear mask bit */
- /* set mask bit, if bit is to be set */
- if (bits & ZT_CBIT) c |= m;
- /* save new signalling values */
- txsigs[k][b] = c;
- /* output them into the chip */
- t1out(k + 1,0x70 + b,c);
- b += 3; /* now points to d bit stuff */
- /* get current signalling values */
- c = txsigs[k][b];
- c &= ~m; /* clear mask bit */
- /* set mask bit, if bit is to be set */
- if (bits & ZT_DBIT) c |= m;
- /* save new signalling values */
- txsigs[k][b] = c;
- /* output them into the chip */
- t1out(k + 1,0x70 + b,c);
- write_unlock_irqrestore(&torisa, flags);
- return 0;
-}
-
-static inline int getspan(struct zt_span *span)
-{
- if (span == spans)
- return 1;
- if (span == spans + 1)
- return 2;
- return -1;
-}
-
-static int torisa_shutdown(struct zt_span *span)
-{
- int i;
- int tspan;
- int wasrunning;
- unsigned long flags;
-
- tspan = getspan(span);
- if (tspan < 0) {
- printk("TorISA: Span '%d' isn't us?\n", span->spanno);
- return -1;
- }
-
- write_lock_irqsave(&torisa, flags);
- wasrunning = span->flags & ZT_FLAG_RUNNING;
-
- span->flags &= ~ZT_FLAG_RUNNING;
- /* Zero out all registers */
- for (i = 0; i< 0xff; i++) t1out(tspan, i, 0);
- if (wasrunning)
- spansstarted--;
- write_unlock_irqrestore(&torisa, flags);
- if (!spans[0].flags & ZT_FLAG_RUNNING &&
- !spans[1].flags & ZT_FLAG_RUNNING)
- /* No longer in use, disable interrupts */
- setctlreg(clockvals[syncsrc]);
-
- if (debug)
- printk("Span %d (%s) shutdown\n", span->spanno, span->name);
- return 0;
-}
-
-static int torisa_startup(struct zt_span *span)
-{
- unsigned long endjif;
- int i;
- int tspan;
- unsigned long flags;
- char *coding;
- char *framing;
- char *crcing;
- int alreadyrunning;
-
- tspan = getspan(span);
- if (tspan < 0) {
- printk("TorISA: Span '%d' isn't us?\n", span->spanno);
- return -1;
- }
-
-
- write_lock_irqsave(&torisa, flags);
-
- alreadyrunning = span->flags & ZT_FLAG_RUNNING;
-
- /* initialize the start value for the last ec buffer */
- for(i = 0; i < span->channels; i++)
- {
- last_ecwrite[tspan - 1][i] = ZT_LIN2X(0,&span->chans[i]);
- }
- crcing = "";
- if (card_type == TYPE_T1) { /* if its a T1 card */
- if (!alreadyrunning) {
-
- setctlreg(MASTERCLOCK);
- /* Zero out all registers */
- for (i = 0x20; i< 0x40; i++)
- t1out(tspan, i, 0);
- for (i = 0x60; i< 0x80; i++)
- t1out(tspan, i, 0);
-
- /* Full-on Sync required (RCR1) */
- t1out(tspan, 0x2b, 8);
- /* RSYNC is an input (RCR2) */
- t1out(tspan, 0x2c, 8);
- /* RBS enable (TCR1) */
- t1out(tspan, 0x35, 0x10);
- /* TSYNC to be output (TCR2) */
- t1out(tspan, 0x36, 4);
- /* Tx & Rx Elastic store, sysclk = 2.048 mhz, loopback controls (CCR1) */
- t1out(tspan, 0x37, 0x8c);
- }
- /* Enable F bits pattern */
- i = 0x20;
- if (span->lineconfig & ZT_CONFIG_ESF)
- i = 0x88;
- if (span->lineconfig & ZT_CONFIG_B8ZS)
- i |= 0x44;
- t1out(tspan, 0x38, i);
- if (i & 0x80)
- coding = "ESF";
- else
- coding = "SF";
- if (i & 0x40)
- framing = "B8ZS";
- else {
- framing = "AMI";
- t1out(tspan,0x7e,0x1c); /* F bits pattern (0x1c) into FDL register */
- }
- t1out(tspan, 0x7c, span->txlevel << 5);
-
- if (!alreadyrunning) {
- /* LIRST to 1 in CCR3 */
- t1out(tspan, 0x30, 1);
-
- /* Wait 100 ms */
- endjif = jiffies + 10;
- write_unlock_irqrestore(&torisa, flags);
-
- while(jiffies < endjif); /* wait 100 ms */
-
- write_lock_irqsave(&torisa, flags);
- t1out(tspan,0x30,0x40); /* set CCR3 to 0x40, resetting Elastic Store */
-
- span->flags |= ZT_FLAG_RUNNING;
- spansstarted++;
-
-#if 0
- printk("Enabling interrupts: %d\n", clockvals[syncsrc] | INTENA);
-#endif
-
- /* output the clock info and enable interrupts */
- setctlreg(clockvals[syncsrc] | INTENA);
- }
- set_clear(); /* this only applies to a T1 */
- } else { /* if its an E1 card */
- u_char ccr1 = 0, tcr1 = 0;
-
- if (!alreadyrunning) {
- t1out(tspan,0x1a,4); /* CCR2: set LOTCMC */
- for(i = 0; i <= 8; i++) t1out(tspan,i,0);
- for(i = 0x10; i <= 0x4f; i++) if (i != 0x1a) t1out(tspan,i,0);
- t1out(tspan,0x10,0x20); /* RCR1: Rsync as input */
- t1out(tspan,0x11,6); /* RCR2: Sysclk=2.048 Mhz */
- t1out(tspan,0x12,8); /* TCR1: TSiS mode */
- }
- tcr1 = 8; /* base TCR1 value: TSis mode */
- if (span->lineconfig & ZT_CONFIG_CCS) {
- ccr1 |= 8; /* CCR1: Rx Sig mode: CCS */
- coding = "CCS";
- } else {
- tcr1 |= 0x20;
- coding = "CAS";
- }
- if (span->lineconfig & ZT_CONFIG_HDB3) {
- ccr1 |= 0x44; /* CCR1: TX and RX HDB3 */
- framing = "HDB3";
- } else framing = "AMI";
- if (span->lineconfig & ZT_CONFIG_CRC4) {
- ccr1 |= 0x11; /* CCR1: TX and TX CRC4 */
- crcing = "/CRC4";
- }
- t1out(tspan,0x12,tcr1);
- t1out(tspan,0x14,ccr1);
- t1out(tspan, 0x18, 0x80);
-
- if (!alreadyrunning) {
- t1out(tspan,0x1b,0x8a); /* CCR3: LIRST & TSCLKM */
- t1out(tspan,0x20,0x1b); /* TAFR */
- t1out(tspan,0x21,0x5f); /* TNAFR */
- t1out(tspan,0x40,0xb); /* TSR1 */
- for(i = 0x41; i <= 0x4f; i++) t1out(tspan,i,0x55);
- for(i = 0x22; i <= 0x25; i++) t1out(tspan,i,0xff);
- /* Wait 100 ms */
- endjif = jiffies + 10;
- write_unlock_irqrestore(&torisa, flags);
- while(jiffies < endjif); /* wait 100 ms */
- write_lock_irqsave(&torisa, flags);
- t1out(tspan,0x1b,0x9a); /* CCR3: set also ESR */
- t1out(tspan,0x1b,0x82); /* CCR3: TSCLKM only now */
-
- /* output the clock info and enable interrupts */
- setctlreg(clockvals[syncsrc] | INTENA);
- }
-
- }
-
- write_unlock_irqrestore(&torisa, flags);
-
- if (debug) {
- if (card_type == TYPE_T1) {
- if (alreadyrunning)
- printk("TorISA: Reconfigured span %d (%s/%s) LBO: %s\n", span->spanno, coding, framing, zt_lboname(span->txlevel));
- else
- printk("TorISA: Startup span %d (%s/%s) LBO: %s\n", span->spanno, coding, framing, zt_lboname(span->txlevel));
- } else {
- if (alreadyrunning)
- printk("TorISA: Reconfigured span %d (%s/%s%s) 120 ohms\n", span->spanno, coding, framing, crcing);
- else
- printk("TorISA: Startup span %d (%s/%s%s) 120 ohms\n", span->spanno, coding, framing, crcing);
- }
- }
- if (syncs[0] == span->spanno) printk("SPAN %d: Primary Sync Source\n",span->spanno);
- if (syncs[1] == span->spanno) printk("SPAN %d: Secondary Sync Source\n",span->spanno);
- return 0;
-}
-
-static int torisa_spanconfig(struct zt_span *span, struct zt_lineconfig *lc)
-{
- if (debug)
- printk("TorISA: Configuring span %d\n", span->spanno);
-
- span->syncsrc = syncsrc;
-
- /* remove this span number from the current sync sources, if there */
- if (syncs[0] == span->spanno) syncs[0] = 0;
- if (syncs[1] == span->spanno) syncs[1] = 0;
- /* if a sync src, put it in proper place */
- if (lc->sync) syncs[lc->sync - 1] = span->spanno;
-
- /* If we're already running, then go ahead and apply the changes */
- if (span->flags & ZT_FLAG_RUNNING)
- return torisa_startup(span);
-
- return 0;
-}
-
-static int torisa_chanconfig(struct zt_chan *chan, int sigtype)
-{
- int alreadyrunning;
- unsigned long flags;
- alreadyrunning = chan->span->flags & ZT_FLAG_RUNNING;
- if (debug) {
- if (alreadyrunning)
- printk("TorISA: Reconfigured channel %d (%s) sigtype %d\n", chan->channo, chan->name, sigtype);
- else
- printk("TorISA: Configured channel %d (%s) sigtype %d\n", chan->channo, chan->name, sigtype);
- }
- write_lock_irqsave(&torisa, flags);
- if (alreadyrunning && (card_type == TYPE_T1))
- set_clear();
- write_unlock_irqrestore(&torisa, flags);
- return 0;
-}
-
-static int torisa_open(struct zt_chan *chan)
-{
-#ifndef LINUX26
- MOD_INC_USE_COUNT;
-#endif
- return 0;
-}
-
-static int torisa_close(struct zt_chan *chan)
-{
-#ifndef LINUX26
- MOD_DEC_USE_COUNT;
-#endif
- return 0;
-}
-
-static int torisa_maint(struct zt_span *span, int cmd)
-{
- int tspan = getspan(span);
-
- switch(cmd) {
- case ZT_MAINT_NONE:
- t1out(tspan,0x1a,4); /* clear system */
- break;
- case ZT_MAINT_LOCALLOOP:
- t1out(tspan,0x1a,5); /* local loopback */
- break;
- case ZT_MAINT_REMOTELOOP:
- t1out(tspan,0x37,6); /* remote loopback */
- break;
- case ZT_MAINT_LOOPUP:
- if (card_type == TYPE_E1) return -ENOSYS;
- t1out(tspan,0x30,2); /* send loopup code */
- break;
- case ZT_MAINT_LOOPDOWN:
- if (card_type == TYPE_E1) return -ENOSYS;
- t1out(tspan,0x30,4); /* send loopdown code */
- break;
- case ZT_MAINT_LOOPSTOP:
- if (card_type == TYPE_T1)
- t1out(tspan,0x30,0); /* stop sending loopup code */
- break;
- default:
- printk("torisa: Unknown maint command: %d\n", cmd);
- break;
- }
- return 0;
-}
-
-static int taskletpending;
-
-static struct tasklet_struct torisa_tlet;
-
-static void torisa_tasklet(unsigned long data)
-{
- int x,y;
- u_char mychunk[2][ZT_CHUNKSIZE];
- taskletrun++;
- if (taskletpending) {
- taskletexec++;
- /* Perform receive data calculations. Reverse to run most
- likely master last */
- if (spans[1].flags & ZT_FLAG_RUNNING) {
- /* Perform echo cancellation */
- for (x=0;x<channels_per_span;x++)
- {
- for(y = 0; y < ZT_CHUNKSIZE; y++)
- {
- mychunk[1][y] = last_ecwrite[1][x];
- last_ecwrite[1][x] =
- writedata[1-curread][x + channels_per_span][y];
- }
- zt_ec_chunk(&spans[1].chans[x],
- spans[1].chans[x].readchunk,mychunk[1]);
- }
- zt_receive(&spans[1]);
- }
- if (spans[0].flags & ZT_FLAG_RUNNING) {
- /* Perform echo cancellation */
- for (x=0;x<channels_per_span;x++)
- {
- for(y = 0; y < ZT_CHUNKSIZE; y++)
- {
- mychunk[0][y] = last_ecwrite[0][x];
- last_ecwrite[0][x] = writedata[1-curread][x][y];
- }
- zt_ec_chunk(&spans[0].chans[x],
- spans[0].chans[x].readchunk,mychunk[0]);
- }
- zt_receive(&spans[0]);
- }
-
- /* Prepare next set for transmission */
- if (spans[1].flags & ZT_FLAG_RUNNING)
- zt_transmit(&spans[1]);
- if (spans[0].flags & ZT_FLAG_RUNNING)
- zt_transmit(&spans[0]);
- }
- taskletpending = 0;
-}
-
-static int txerrors;
-
-ZAP_IRQ_HANDLER(torisa_intr)
-{
- static unsigned int passno = 0, mysynccnt = 0, lastsyncsrc = -1;
- int n, n1, i, j, k, x, mysyncsrc, oldn;
- static unsigned short rxword[33],txword[33];
- unsigned char txc, rxc, c;
- unsigned char abits, bbits, cbits, dbits;
-
-
- irqcount++;
-
- /* 1. Do all I/O Immediately -- Normally we would ask for
- the transmission first, but because of the incredibly
- tight timing we're lucky to be able to do the I/O
- at this point */
-
- /* make sure its a real interrupt for us */
- if (!(getctlreg() & 1)) /* if not, just return */
- {
-#ifdef LINUX26
- return IRQ_NONE;
-#else
- return;
-#endif
- }
-
- /* set outbit and put int 16 bit bus mode, reset interrupt enable */
- setctlreg(clockvals[syncsrc] | OUTBIT | ENA16);
-
-#if 0
- if (!passno)
- printk("Interrupt handler\n");
-#endif
-
- /* Do the actual transmit and receive in poopy order */
- for(n1 = 0; n1 < channels_per_span; n1++)
- {
- n = chseq[n1];
- maddr[DDATA + datxlt[n]] = txword[n];
- rxword[n] = maddr[DDATA + datxlt[n]]; /* get rx word */
- }
-
-
- setctlreg(clockvals[syncsrc] | OUTBIT); /* clear 16 bit mode */
-
- /* Calculate the transmit, and receive go thru all the chans */
- oldn = -1;
- for(n1 = 0; n1 < channels_per_span; n1++) {
- n = chseq[n1];
- txword[n] = 0;
- if (n < oldn) {
- /* We've circled around.
- Now we increment the passno and stuff */
- if ((passno % ZT_CHUNKSIZE) == (ZT_CHUNKSIZE - 1)) {
- /* Swap buffers */
- for (x = 0;x < (channels_per_span * 2);x++) {
- chans[x].readchunk = readdata[curread][x];
- chans[x].writechunk = writedata[curread][x];
- }
- /* Lets work with the others now which presumably have been filled */
- curread = 1 - curread;
- if (!taskletpending) {
- taskletpending = 1;
- taskletsched++;
- tasklet_hi_schedule(&torisa_tlet);
- } else {
- txerrors++;
- }
- }
- passno++;
- }
- oldn = n;
- /* go thru both spans */
- for(j = 0; j < 2; j++)
- {
- /* enter the transmit stuff with i being channel number,
- leaving with txc being character to transmit */
- txc = writedata[curread][j * channels_per_span + n-1][passno % ZT_CHUNKSIZE];
- txword[n] |= txc << (j * 8);
-
- /* receive side */
- i = n + (j * channels_per_span); /* calc chan number */
- rxc = (rxword[n] >> (j * 8)) & 0xff;
- readdata[curread][j * channels_per_span + n - 1][passno % ZT_CHUNKSIZE] = rxc;
- }
- }
-
- i = passno & 127;
- /* if an E1 card, do rx signalling for it */
- if (i < 3 && (card_type == TYPE_E1)) { /* if an E1 card */
- for(j = (i * 3); j < (i * 3) + 5; j++)
- {
- for(k = 1,x = j; k <= 2; k++,x += channels_per_span) {
- c = t1in(k,0x31 + j);
- rxc = c & 15;
- if (rxc != chans[x + 15].rxsig) {
- /* Check for changes in received bits */
- if (!(chans[x + 15].sig & ZT_SIG_CLEAR))
- zt_rbsbits(&chans[x + 15], rxc);
- }
- rxc = c >> 4;
- if (rxc != chans[x].rxsig) {
- /* Check for changes in received bits */
- if (!(chans[x].sig & ZT_SIG_CLEAR))
- zt_rbsbits(&chans[x], rxc);
- }
- }
- }
- }
- /* if a t1 card, do rx signalling for it */
- if ((i < 6) && (card_type == TYPE_T1)) {
- k = (i / 3); /* get span */
- n = (i % 3); /* get base */
- abits = t1in(k + 1, 0x60 + n);
- bbits = t1in(k + 1, 0x63 + n);
- cbits = t1in(k + 1, 0x66 + n);
- dbits = t1in(k + 1, 0x69 + n);
- for (j=0; j< 8; j++) {
- /* Get channel number */
- i = (k * 24) + (n * 8) + j;
- rxc = 0;
- if (abits & (1 << j)) rxc |= ZT_ABIT;
- if (bbits & (1 << j)) rxc |= ZT_BBIT;
- if (cbits & (1 << j)) rxc |= ZT_CBIT;
- if (dbits & (1 << j)) rxc |= ZT_DBIT;
- if (chans[i].rxsig != rxc) {
- /* Check for changes in received bits */
- if (!(chans[i].sig & ZT_SIG_CLEAR))
- zt_rbsbits(&chans[i], rxc);
- }
- }
- }
-
- if (!(passno & 0x7)) {
- for(i = 0; i < 2; i++)
- {
- /* if alarm timer, and it's timed out */
- if (alarmtimer[i]) {
- if (!--alarmtimer[i])
- {
- /* clear recover status */
- spans[i].alarms &= ~ZT_ALARM_RECOVER;
- if (card_type == TYPE_T1)
- t1out(i + 1,0x35,0x10); /* turn off yel */
- else
- t1out(i + 1,0x21,0x5f); /* turn off remote alarm */
- zt_alarm_notify(&spans[i]); /* let them know */
- }
- }
- }
- }
-
- i = passno & 511;
- if ((i == 100) || (i == 101))
- {
- j = 0; /* clear this alarm status */
- i -= 100;
- if (card_type == TYPE_T1) {
- c = t1in(i + 1,0x31); /* get RIR2 */
- spans[i].rxlevel = c >> 6; /* get rx level */
- t1out(i + 1,0x20,0xff);
- c = t1in(i + 1,0x20); /* get the status */
- /* detect the code, only if we are not sending one */
- if ((!spans[i].mainttimer) && (c & 0x80)) /* if loop-up code detected */
- {
- /* set into remote loop, if not there already */
- if ((loopupcnt[i]++ > 80) &&
- (spans[i].maintstat != ZT_MAINT_REMOTELOOP))
- {
- t1out(i + 1,0x37,0x9c); /* remote loopback */
- spans[i].maintstat = ZT_MAINT_REMOTELOOP;
- }
- } else loopupcnt[i] = 0;
- /* detect the code, only if we are not sending one */
- if ((!spans[i].mainttimer) && (c & 0x40)) /* if loop-down code detected */
- {
- /* if in remote loop, get out of it */
- if ((loopdowncnt[i]++ > 80) &&
- (spans[i].maintstat == ZT_MAINT_REMOTELOOP))
- {
- t1out(i + 1,0x37,0x8c); /* normal */
- spans[i].maintstat = ZT_MAINT_NONE;
- }
- } else loopdowncnt[i] = 0;
- if (c & 3) /* if red alarm */
- {
- j |= ZT_ALARM_RED;
- }
- if (c & 8) /* if blue alarm */
- {
- j |= ZT_ALARM_BLUE;
- }
- } else { /* its an E1 card */
- t1out(i + 1,6,0xff);
- c = t1in(i + 1,6); /* get the status */
- if (c & 9) /* if red alarm */
- {
- j |= ZT_ALARM_RED;
- }
- if (c & 2) /* if blue alarm */
- {
- j |= ZT_ALARM_BLUE;
- }
- }
- /* only consider previous carrier alarm state */
- spans[i].alarms &= (ZT_ALARM_RED | ZT_ALARM_BLUE | ZT_ALARM_NOTOPEN);
- n = 1; /* set to 1 so will not be in yellow alarm if we dont
- care about open channels */
- /* if to have yellow alarm if nothing open */
- if (spans[i].lineconfig & ZT_CONFIG_NOTOPEN)
- {
- /* go thru all chans, and count # open */
- for(n = 0,k = (i * channels_per_span); k < (i * channels_per_span) + channels_per_span; k++)
- {
- if ((chans[k].flags & ZT_FLAG_OPEN) ||
- (chans[k].flags & ZT_FLAG_NETDEV)) n++;
- }
- /* if none open, set alarm condition */
- if (!n) j |= ZT_ALARM_NOTOPEN;
- }
- /* if no more alarms, and we had some */
- if ((!j) && spans[i].alarms)
- {
- alarmtimer[i] = ZT_ALARMSETTLE_TIME;
- }
- if (alarmtimer[i]) j |= ZT_ALARM_RECOVER;
- /* if going into alarm state, set yellow (remote) alarm */
- if ((j) && (!spans[i].alarms)) {
- if (card_type == TYPE_T1) t1out(i + 1,0x35,0x11);
- else t1out(i + 1,0x21,0x7f);
- }
- if (c & 4) /* if yellow alarm */
- j |= ZT_ALARM_YELLOW;
- if (spans[i].maintstat || spans[i].mainttimer) j |= ZT_ALARM_LOOPBACK;
- spans[i].alarms = j;
- zt_alarm_notify(&spans[i]);
- }
- if (!(passno % 8000)) /* even second boundary */
- {
- /* do both spans */
- for(i = 1; i <= 2; i++)
- {
- if (card_type == TYPE_T1) {
- /* add this second's BPV count to total one */
- spans[i - 1].bpvcount += t1in(i,0x24) + (t1in(i,0x23) << 8);
- } else {
- /* add this second's BPV count to total one */
- spans[i - 1].bpvcount += t1in(i,1) + (t1in(i,0) << 8);
- }
- }
- }
- /* re-evaluate active sync src */
- mysyncsrc = 0;
- /* if primary sync specified, see if we can use it */
- if (syncs[0])
- {
- /* if no alarms, use it */
- if (!(spans[syncs[0] - 1].alarms & (ZT_ALARM_RED | ZT_ALARM_BLUE |
- ZT_ALARM_LOOPBACK))) mysyncsrc = syncs[0];
- }
- /* if we dont have one yet, and there is a secondary, see if we can use it */
- if ((!mysyncsrc) && (syncs[1]))
- {
- /* if no alarms, use it */
- if (!(spans[syncs[1] - 1].alarms & (ZT_ALARM_RED | ZT_ALARM_BLUE |
- ZT_ALARM_LOOPBACK))) mysyncsrc = syncs[1];
- }
- /* on the E1 card, the PLL takes a bit of time to lock going
- between internal and external clocking. There needs to be some
- settle time before actually changing the source, otherwise it will
- oscillate between in and out of sync */
- if (card_type == TYPE_E1)
- {
- /* if stable, add to count */
- if (lastsyncsrc == mysyncsrc) mysynccnt++; else mysynccnt = 0;
- lastsyncsrc = mysyncsrc;
- /* if stable sufficiently long, change it */
- if (mysynccnt >= E1SYNCSTABLETHRESH)
- {
- mysynccnt = 0;
- syncsrc = mysyncsrc;
- }
- }
- else syncsrc = mysyncsrc; /* otherwise on a T1 card, just use current value */
- /* update sync src info */
- spans[0].syncsrc = spans[1].syncsrc = syncsrc;
- /* If this is the last pass, then prepare the next set */
- /* clear outbit, restore interrupt enable */
- setctlreg(clockvals[syncsrc] | INTENA);
-#ifdef LINUX26
- return IRQ_RETVAL(1);
-#endif
-}
-
-
-static int torisa_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long data)
-{
- struct torisa_debug td;
- switch(cmd) {
- case TORISA_GETDEBUG:
- td.txerrors = txerrors;
- td.irqcount = irqcount;
- td.taskletsched = taskletsched;
- td.taskletrun = taskletrun;
- td.taskletexec = taskletexec;
- td.span1flags = spans[0].flags;
- td.span2flags = spans[1].flags;
- if (copy_to_user((struct torisa_debug *)data, &td, sizeof(td)))
- return -EFAULT;
- return 0;
- default:
- return -ENOTTY;
- }
- return 0;
-}
-
-static int __init tor_init(void)
-{
- if (!base) {
- printk("Specify address with base=0xNNNNN\n");
- return -EIO;
- }
- if (tor_probe()) {
- printk(KERN_ERR "No ISA tormenta card found at %05lx\n", base);
- return -EIO;
- }
- if (request_irq(irq, torisa_intr, ZAP_IRQ_DISABLED, "torisa", NULL)) {
- printk(KERN_ERR "Unable to request tormenta IRQ %d\n", irq);
- return -EIO;
- }
- if (!request_mem_region(base, 4096, "Tormenta ISA")) {
- printk(KERN_ERR "Unable to request 4k memory window at %lx\n", base);
- free_irq(irq, NULL);
- return -EIO;
- }
-
- strcpy(spans[0].name, "TorISA/1");
- zap_copy_string(spans[0].desc, "ISA Tormenta Span 1", sizeof(spans[0].desc));
- spans[0].manufacturer = "Digium";
- zap_copy_string(spans[0].devicetype, "Tormenta ISA", sizeof(spans[0].devicetype));
- spans[0].spanconfig = torisa_spanconfig;
- spans[0].chanconfig = torisa_chanconfig;
- spans[0].startup = torisa_startup;
- spans[0].shutdown = torisa_shutdown;
- spans[0].rbsbits = torisa_rbsbits;
- spans[0].maint = torisa_maint;
- spans[0].open = torisa_open;
- spans[0].close = torisa_close;
- spans[0].channels = channels_per_span;
- spans[0].chans = &chans[0];
- spans[0].flags = ZT_FLAG_RBS;
- spans[0].ioctl = torisa_ioctl;
- spans[0].irq = irq;
-
- if (card_type == TYPE_E1) {
- spans[0].spantype = "E1";
- spans[0].linecompat = ZT_CONFIG_AMI | ZT_CONFIG_B8ZS | ZT_CONFIG_D4 | ZT_CONFIG_ESF;
- spans[0].deflaw = ZT_LAW_ALAW;
- } else {
- spans[0].spantype = "T1";
- spans[0].linecompat = ZT_CONFIG_HDB3 | ZT_CONFIG_CCS | ZT_CONFIG_CRC4;
- spans[0].deflaw = ZT_LAW_MULAW;
- }
-
- spans[1] = spans[0];
- strcpy(spans[1].name, "TorISA/2");
- strcpy(spans[1].desc, "ISA Tormenta Span 2");
- spans[1].chans = &chans[channels_per_span];
-
- init_waitqueue_head(&spans[0].maintq);
- init_waitqueue_head(&spans[1].maintq);
-
- make_chans();
- if (zt_register(&spans[0], prefmaster)) {
- printk(KERN_ERR "Unable to register span %s\n", spans[0].name);
- return -EIO;
- }
- if (zt_register(&spans[1], 0)) {
- printk(KERN_ERR "Unable to register span %s\n", spans[1].name);
- zt_unregister(&spans[0]);
- return -EIO;
- }
- tasklet_init(&torisa_tlet, torisa_tasklet, (long)0);
- printk("TORISA Loaded\n");
- return 0;
-}
-
-
-#if !defined(LINUX26)
-static int __init set_tor_base(char *str)
-{
- base = simple_strtol(str, NULL, 0);
- return 1;
-}
-
-__setup("tor=", set_tor_base);
-#endif
-
-static void __exit tor_exit(void)
-{
- free_irq(irq, NULL);
- release_mem_region(base, 4096);
- if (spans[0].flags & ZT_FLAG_REGISTERED)
- zt_unregister(&spans[0]);
- if (spans[1].flags & ZT_FLAG_REGISTERED)
- zt_unregister(&spans[1]);
-}
-
-MODULE_AUTHOR("Mark Spencer <markster@digium.com>");
-MODULE_DESCRIPTION("Tormenta ISA Zapata Telephony Driver");
-#ifdef MODULE_LICENSE
-MODULE_LICENSE("GPL");
-#endif
-
-#ifdef LINUX26
-module_param(prefmaster, int, 0600);
-module_param(base, long, 0600);
-module_param(irq, int, 0600);
-module_param(syncsrc, int, 0600);
-module_param(debug, int, 0600);
-#else
-MODULE_PARM(prefmaster, "i");
-MODULE_PARM(base, "i");
-MODULE_PARM(irq, "i");
-MODULE_PARM(syncsrc, "i");
-MODULE_PARM(debug, "i");
-#endif
-
-module_init(tor_init);
-module_exit(tor_exit);
diff --git a/drivers/dahdi/wcusb.c b/drivers/dahdi/wcusb.c
deleted file mode 100644
index 15205a4..0000000
--- a/drivers/dahdi/wcusb.c
+++ /dev/null
@@ -1,1490 +0,0 @@
-/*
- * Wildcard S100U USB FXS Interface Zapata Telephony Driver
- *
- * Written by Mark Spencer <markster@digium.com>
- * Matthew Fredrickson <creslin@digium.com>
- *
- * Copyright (C) 2001, Linux Support Services, Inc.
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/* Save power at the expense of not always being able to transmit on hook. If
- this is set, we only transit on hook for some time after a ring
- (POWERSAVE_TIMEOUT) */
-
-/* #define PROSLIC_POWERSAVE */
-#define POWERSAVE_TIME 4000
-
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-#include <linux/usb.h>
-#include <linux/errno.h>
-
-#include <linux/version.h>
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,19)
-#define USB2420
-#endif
-
-#ifdef STANDALONE_ZAPATA
-#include "zaptel.h"
-#else
-#include <zaptel/zaptel.h>
-#endif /* STANDALONE_ZAPATA */
-
-#include "wcusb.h"
-#include "proslic.h"
-
-#ifndef FILL_CONTROL_URB
-#define FILL_CONTROL_URB usb_fill_control_urb
-#endif
-
-#ifdef DEBUG_WILDCARD
-#define DPRINTK(x) printk x
-#else
-#define DPRINTK(x)
-#endif
-
-// Function prototypes
-static int readProSlicDirectReg(struct usb_device *dev, unsigned char address, unsigned char* data);
-static int initializeIndirectRegisters(struct usb_device *dev);
-static int verifyIndirectRegisters(struct usb_device *dev);
-static int writeProSlicDirectReg(struct usb_device *dev, unsigned char address, unsigned char data);
-static int writeProSlicInDirectReg(struct usb_device *dev, unsigned char address, unsigned short data);
-static int readProSlicInDirectReg(struct usb_device *dev, unsigned char address, unsigned short *data);
-static int writeProSlicInDirectReg(struct usb_device *dev, unsigned char address, unsigned short data);
-
-static alpha indirect_regs[] =
-{
-{0,255,"DTMF_ROW_0_PEAK",0x55C2},
-{1,255,"DTMF_ROW_1_PEAK",0x51E6},
-{2,255,"DTMF_ROW2_PEAK",0x4B85},
-{3,255,"DTMF_ROW3_PEAK",0x4937},
-{4,255,"DTMF_COL1_PEAK",0x3333},
-{5,255,"DTMF_FWD_TWIST",0x0202},
-{6,255,"DTMF_RVS_TWIST",0x0202},
-{7,255,"DTMF_ROW_RATIO_TRES",0x0198},
-{8,255,"DTMF_COL_RATIO_TRES",0x0198},
-{9,255,"DTMF_ROW_2ND_ARM",0x0611},
-{10,255,"DTMF_COL_2ND_ARM",0x0202},
-{11,255,"DTMF_PWR_MIN_TRES",0x00E5},
-{12,255,"DTMF_OT_LIM_TRES",0x0A1C},
-{13,0,"OSC1_COEF",0x7B30},
-{14,1,"OSC1X",0x0063},
-{15,2,"OSC1Y",0x0000},
-{16,3,"OSC2_COEF",0x7870},
-{17,4,"OSC2X",0x007D},
-{18,5,"OSC2Y",0x0000},
-{19,6,"RING_V_OFF",0x0000},
-{20,7,"RING_OSC",0x7EF0},
-{21,8,"RING_X",0x0160},
-{22,9,"RING_Y",0x0000},
-{23,255,"PULSE_ENVEL",0x2000},
-{24,255,"PULSE_X",0x2000},
-{25,255,"PULSE_Y",0x0000},
-//{26,"RECV_DIGITAL_GAIN",0x4000}, // playback volume set lower
-{26,13,"RECV_DIGITAL_GAIN",0x2000}, // playback volume set lower
-{27,14,"XMIT_DIGITAL_GAIN",0x4000},
-//{27,"XMIT_DIGITAL_GAIN",0x2000},
-{28,15,"LOOP_CLOSE_TRES",0x1000},
-{29,16,"RING_TRIP_TRES",0x3600},
-{30,17,"COMMON_MIN_TRES",0x1000},
-{31,18,"COMMON_MAX_TRES",0x0200},
-{32,19,"PWR_ALARM_Q1Q2",0x07C0},
-{33,20,"PWR_ALARM_Q3Q4",0x2600},
-{34,21,"PWR_ALARM_Q5Q6",0x1B80},
-{35,22,"LOOP_CLOSURE_FILTER",0x8000},
-{36,23,"RING_TRIP_FILTER",0x0320},
-{37,24,"TERM_LP_POLE_Q1Q2",0x008C},
-{38,25,"TERM_LP_POLE_Q3Q4",0x0100},
-{39,26,"TERM_LP_POLE_Q5Q6",0x0010},
-{40,27,"CM_BIAS_RINGING",0x0C00},
-{41,64,"DCDC_MIN_V",0x0C00},
-{42,255,"DCDC_XTRA",0x1000},
-{43,66,"LOOP_CLOSE_TRES_LOW",0x1000},
-};
-
-static int debug = 0;
-
-#define FLAG_FLIP_RELAYS (1 << 0)
-
-static struct wc_usb_desc wcusb = { "Wildcard S100U USB FXS Interface" };
-static struct wc_usb_desc wcusb2 = { "Wildcard S110U USB FXS Interface", FLAG_FLIP_RELAYS };
-static struct wc_usb_desc wc_usb_phone = { "Wildcard Phone Test driver" };
-static struct wc_usb_pvt *ifaces[WC_MAX_IFACES];
-
-
-
-static void wcusb_check_keypad(struct wc_usb_pvt *p);
-static int set_aux_ctrl(struct wc_usb_pvt *p, char auxpins, int on);
-
-
-
-static int Wcusb_WriteWcRegs(struct usb_device *dev, unsigned char index,
- unsigned char *data, int len)
-{
- unsigned int pipe = usb_sndctrlpipe(dev, 0);
- int requesttype;
- int res;
-
- requesttype = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
-
- res = usb_control_msg(dev, pipe, REQUEST_NORMAL, requesttype,
- 0, index, data, len, CONTROL_TIMEOUT_JIFFIES);
- if (res == -ETIMEDOUT) {
- printk("wcusb: timeout on vendor write\n");
- return -1;
- } else if (res < 0) {
- printk("wcusb: Error executing control: status=%d\n", le32_to_cpu(res));
- return -1;
- }
- return 0;
-}
-
-static int Wcusb_ReadWcRegs(struct usb_device *dev, unsigned char index,
- unsigned char *data, int len)
-{
- unsigned int pipe = usb_rcvctrlpipe(dev, 0);
- int requesttype;
- int res;
-
- requesttype = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
-
- res = usb_control_msg(dev, pipe, REQUEST_NORMAL, requesttype,
- 0, index, data, len, CONTROL_TIMEOUT_JIFFIES);
- if (res == -ETIMEDOUT) {
- printk("wcusb: timeout on vendor write\n");
- return -1;
- } else if (res < 0) {
- printk("wcusb: Error executing control: status=%d\n", le32_to_cpu(res));
- return -1;
- } else {
- DPRINTK(("wcusb: Executed read, result = %d (data = %04x)\n", le32_to_cpu(res), (int) *data));
- }
- return 0;
-}
-
-#ifdef USB2420
-#if defined(LINUX26) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
-static int wcusb_async_read(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(struct urb *urb, struct pt_regs *regs));
-static int wcusb_async_write(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(struct urb *urb, struct pt_regs *regs));
-static void wcusb_async_control(struct urb *urb, struct pt_regs *regs);
-#else
-static int wcusb_async_read(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(struct urb *urb));
-static int wcusb_async_write(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(struct urb *urb));
-static void wcusb_async_control(struct urb *urb);
-#endif /* LINUX26 */
-#else
-static int wcusb_async_read(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(urb_t *urb));
-static int wcusb_async_write(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(urb_t *urb));
-static void wcusb_async_control(urb_t *urb);
-#endif
-
-static void proslic_read_direct_async(struct wc_usb_pvt *p, unsigned char address)
-{
- p->wcregindex = address;
- p->wcregbuf[0] = address | 0x80;
- p->wcregbuf[1] = 0;
- p->wcregbuf[2] = 0;
- p->wcregbuf[3] = 0x67;
- wcusb_async_write(p, WCUSB_SPORT0, p->wcregbuf, 4, STATE_WCREAD_WRITEREG, wcusb_async_control);
-}
-
-static void proslic_write_direct_async(struct wc_usb_pvt *p, unsigned char address, unsigned char val)
-{
- p->wcregindex = address;
- p->wcregbuf[0] = address & 0x7f;
- p->wcregbuf[1] = val;
- p->wcregbuf[2] = 0;
- p->wcregbuf[3] = 0x27;
- wcusb_async_write(p, WCUSB_SPORT0, p->wcregbuf, 4, STATE_WCWRITE_WRITERES, wcusb_async_control);
-}
-
-#ifdef USB2420
-#if defined(LINUX26) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
-static void wcusb_async_control(struct urb *urb, struct pt_regs *regs)
-#else
-static void wcusb_async_control(struct urb *urb)
-#endif
-#else
-static void wcusb_async_control(urb_t *urb)
-#endif
-{
- struct wc_usb_pvt *p = urb->context;
- p->urbcount--;
- if (urb->status) {
- printk("Error in transfer...\n");
- /* return is the "right thing", but don't... */
- p->timer = 50;
- /* return; */
- }
- if (!(p->flags & FLAG_RUNNING)) {
- return;
- }
- switch (p->controlstate) {
- case STATE_WCREAD_WRITEREG:
- /* We've written the register to sport0, now read form sport 1 */
- wcusb_async_read(p, WCUSB_SPORT1, &p->wcregval, 1, STATE_WCREAD_READRES, wcusb_async_control);
- return;
- case STATE_WCREAD_READRES:
- switch(p->wcregindex) {
- case 68:
- if (!p->hookstate && (p->wcregval & 1)) {
- p->hookstate = 1;
- if (debug)
- printk("Going off hook...\n");
- zt_hooksig(&p->chan, ZT_RXSIG_OFFHOOK);
- } else if (p->hookstate && !(p->wcregval & 1)) {
- p->hookstate = 0;
- if (debug)
- printk("Going on hook...\n");
- zt_hooksig(&p->chan, ZT_RXSIG_ONHOOK);
- }
- /* Set outgoing hook state if necessary */
- if (p->txhook != p->newtxhook) {
- if (debug)
- printk("Really setting hook state to %d\n", p->newtxhook);
- p->txhook = p->newtxhook;
- proslic_write_direct_async(p, 64, p->newtxhook);
- } else
- p->timer = 50;
- break;
- case 64:
- if (debug)
- printk("Read hook state as %02x\n", p->wcregval);
- p->timer = 50;
- break;
- default:
- printk("dunno what to do with read/regindex %d\n", p->wcregindex);
- p->wcregindex = 0;
- }
- return;
- case STATE_WCWRITE_WRITERES:
- switch(p->wcregindex) {
- case 64:
- if (debug) {
- printk("Hook transition complete to %d\n", ((char *)(urb->transfer_buffer))[1]);
-#ifdef BOOST_RINGER
- }
- if (p->txhook == 4) {
- /* Ringing -- boost battery to 96V */
- proslic_write_direct_async(p, 74, 0x3f);
- } else {
- /* Leave battery at default 75V */
- proslic_write_direct_async(p, 74, 0x32);
- }
- break;
- case 74:
- if (debug) {
- printk("Battery set to -%dV\n", ((char *)(urb->transfer_buffer))[1] * 3 / 2);
-#endif
- proslic_read_direct_async(p, 64);
- } else
- p->timer = 50;
- break;
- default:
- printk("dunno what to do with write/regindex %d\n", p->wcregindex);
- p->wcregindex = 0;
- }
- return;
- default:
- printk("async control in unknown state %d\n", p->controlstate);
- }
-}
-
-#ifdef USB2420
-#if defined(LINUX26) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
-static void keypad_check_done(struct urb *urb, struct pt_regs *regs)
-#else
-static void keypad_check_done(struct urb *urb)
-#endif
-#else
-static void keypad_check_done(urb_t *urb)
-#endif
-{
- struct wc_usb_pvt *p = urb->context;
- struct wc_keypad_data *d = p->pvt_data;
- static char aux_pattern[] = {0x1e, 0x1d, 0x17, 0xf};
- char digit = 'z';
-
- p->urbcount--;
- if (!d->running) {
- printk("Stopping stream (check_done)\n");
- return;
- }
-
- if (urb->status) {
- printk("status %d\n", urb->status);
- }
-
- if (debug) printk("i is %d\n", d->i);
- switch (d->state) {
-loop_start:
- case STATE_FOR_LOOP_1_OUT:
- if (debug) printk("data12 is %x\n", d->data12);
- if(d->i < sizeof(aux_pattern) / sizeof(char)) {
- d->tmp = aux_pattern[d->i] | (d->data12 & 0xe0);
- d->state = STATE_FOR_LOOP_2_IN;
- if (debug) printk("tmp is %x\n", d->tmp);
- wcusb_async_write(p, 0x12, &d->tmp, 1, 0, keypad_check_done);
- return;
- } else {
- goto func_end;
- }
- case STATE_FOR_LOOP_2_IN:
- d->state = STATE_FOR_LOOP_PROC_DATA;
- wcusb_async_read(p, 0xc0, &d->data, 1, 0, keypad_check_done);
- return;
- case STATE_FOR_LOOP_PROC_DATA:
- d->state = STATE_FOR_LOOP_CLEAR_DIGIT;
- if(debug) printk("data is %x\n", d->data);
- if ((d->data & 0x1f) != 0x1f) {
- if(d->data == 0xe && aux_pattern[d->i] == 0x1e) { digit = '1';}
- else if(d->data == 0xd && aux_pattern[d->i] == 0x1e) { digit = '2';}
- else if(d->data == 0xb && aux_pattern[d->i] == 0x1e) { digit = '3';}
- else if(d->data == 0x7 && aux_pattern[d->i] == 0x1e) {
- p->hookstate = 0; /* On||Off */
- zt_hooksig(&p->chan, ZT_RXSIG_ONHOOK);
- }
-
- else if(d->data == 0xe && aux_pattern[d->i] == 0x1d) { digit = '4';}
- else if(d->data == 0xd && aux_pattern[d->i] == 0x1d) { digit = '5';}
- else if(d->data == 0xb && aux_pattern[d->i] == 0x1d) { digit = '6';}
- else if(d->data == 0x7 && aux_pattern[d->i] == 0x1d) {
- p->hookstate = 1;/* Dial */
- zt_hooksig(&p->chan, ZT_RXSIG_OFFHOOK);
- }
-
- else if(d->data == 0xe && aux_pattern[d->i] == 0x17) { digit = '7';}
- else if(d->data == 0xd && aux_pattern[d->i] == 0x17) { digit = '8';}
- else if(d->data == 0xb && aux_pattern[d->i] == 0x17) { digit = '9';}
- else if(d->data == 0x7 && aux_pattern[d->i] == 0x17) d->scanned_event = 15; /* ReDial */
-
- else if(d->data == 0xe && aux_pattern[d->i] == 0xf) { digit = '*';}/* '*' */
- else if(d->data == 0xd && aux_pattern[d->i] == 0xf) { digit = '0';}
- else if(d->data == 0xb && aux_pattern[d->i] == 0xf) { digit = '#';} /* '#' */
- else if(d->data == 0x7 && aux_pattern[d->i] == 0xf) d->scanned_event = 16; /* Volume? */
- else {
- (d->i)++;
- if (debug) printk("Scanned event %d; data = %x\n", d->scanned_event, d->data);
- goto loop_start;
- }
- } else {
- if(debug) printk("Hit new if\n");
- goto func_end;
- }
- if (debug) printk("wcusb: got digit %d\n", d->scanned_event);
- if (digit != 'z') {
- d->tone = zt_mf_tone(&p->chan, digit, p->chan.digitmode);
- if (!d->tone) {
- printk("wcusb: Didn't get a tone structure\n");
- goto func_end;
- }
- zt_init_tone_state(&d->ts, d->tone);
- p->sample = STREAM_DTMF;
- }
- d->count = 0;
- case STATE_FOR_LOOP_CLEAR_DIGIT:
- if (((d->data & 0xf) != 0xf) && d->count < 200) {
- wcusb_async_read(p, 0xc0, &d->data, 1, 0, keypad_check_done);
- return;
- }
- (d->i)++;
- p->sample = STREAM_NORMAL;
- goto loop_start;
- }
-func_end:
- p->timer = 100;
- return;
-}
-
-static void wcusb_check_interrupt(struct wc_usb_pvt *p)
-{
- /* Start checking for interrupts */
- if (p->devclass == WC_KEYPAD) {
- wcusb_check_keypad(p);
- } else {
- proslic_read_direct_async(p, 68);
- }
- return;
-}
-
-#ifdef USB2420
-#if defined(LINUX26) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
-static int wcusb_async_read(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(struct urb *urb, struct pt_regs *regs))
-#else
-static int wcusb_async_read(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(struct urb *urb))
-#endif /* LINUX26 */
-#else
-static int wcusb_async_read(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(urb_t *urb))
-#endif
-{
- __u16 size = len;
- __u16 ind = index;
-#ifdef USB2420
- struct urb *urb = &p->control;
- memset(urb, 0, sizeof(struct urb));
-
- p->dr.bRequestType = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
- p->dr.bRequest = REQUEST_NORMAL;
- p->dr.wValue = 0;
- p->dr.wIndex = cpu_to_le16(ind);
- p->dr.wLength = cpu_to_le16(size);
-#else
- urb_t *urb = &p->control;
- memset(urb, 0, sizeof(urb_t));
-
- p->dr.requesttype = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
- p->dr.request = REQUEST_NORMAL;
- p->dr.value = 0;
- p->dr.index = cpu_to_le16(ind);
- p->dr.length = cpu_to_le16(size);
-#endif
-
- FILL_CONTROL_URB(urb, p->dev, usb_rcvctrlpipe(p->dev, 0), (unsigned char *)&p->dr, data, len, complete, p);
-#ifdef LINUX26
- if (usb_submit_urb(urb, GFP_KERNEL))
-#else
- if (usb_submit_urb(urb))
-#endif
- {
- printk("wcusb_async_read: control URB died\n");
- p->timer = 50;
- return -1;
- }
- p->controlstate = state;
- p->urbcount++;
- return 0;
-}
-
-#ifdef USB2420
-#if defined(LINUX26) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
-static int wcusb_async_write(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(struct urb *urb, struct pt_regs *regs))
-#else
-static int wcusb_async_write(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(struct urb *urb))
-#endif /* LINUX26 */
-#else
-static int wcusb_async_write(struct wc_usb_pvt *p, unsigned char index, unsigned char *data, int len, int state, void (*complete)(urb_t *urb))
-#endif
-{
- __u16 size = len;
- __u16 ind = index;
-#ifdef USB2420
- struct urb *urb = &p->control;
- memset(urb, 0, sizeof(struct urb));
-
- p->dr.bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
- p->dr.bRequest = REQUEST_NORMAL;
- p->dr.wValue = 0;
- p->dr.wIndex = cpu_to_le16(ind);
- p->dr.wLength = cpu_to_le16(size);
-#else
- urb_t *urb = &p->control;
- memset(urb, 0, sizeof(urb_t));
-
- p->dr.requesttype = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
- p->dr.request = REQUEST_NORMAL;
- p->dr.value = 0;
- p->dr.index = cpu_to_le16(ind);
- p->dr.length = cpu_to_le16(size);
-#endif
-
- FILL_CONTROL_URB(urb, p->dev, usb_sndctrlpipe(p->dev, 0), (unsigned char *)&p->dr, data, len, complete, p);
-#ifdef LINUX26
- if (usb_submit_urb(urb, GFP_KERNEL))
-#else
- if (usb_submit_urb(urb))
-#endif
- {
- printk("wcusb_async_write: control URB died\n");
- return -1;
- }
- p->controlstate = state;
- p->urbcount++;
- return 0;
-}
-
-/*
-** Write register to Wc560
-*/
-static int wcoutp(struct usb_device *dev, unsigned char address, unsigned char data)
-{
- if (!Wcusb_WriteWcRegs(dev, address, &data, 1))
- return 0;
-
- return -1;
-}
-
-/*
-** read register from Wc560
-*/
-static int wcinp(struct usb_device *dev, unsigned char address, unsigned char* data )
-{
- if (!Wcusb_ReadWcRegs(dev, address, data, 1))
- return 0;
-
- return -1;
-}
-
-static int waitForProSlicIndirectRegAccess(struct usb_device *dev)
-{
- unsigned char count, data;
- count = 0;
- while (count++ < 3)
- {
- data = 0;
- readProSlicDirectReg(dev, I_STATUS, &data);
-
- if (!data)
- return 0;
-
- }
-
- if(count > 2) printk(" ##### Loop error #####\n");
-
- return -1;
-}
-
-static int writeProSlicInDirectReg(struct usb_device *dev, unsigned char address, unsigned short data)
-{
-
- if(!waitForProSlicIndirectRegAccess(dev))
- {
- if (!writeProSlicDirectReg(dev, IDA_LO,(unsigned char)(data & 0xFF)))
- {
- if(!writeProSlicDirectReg(dev, IDA_HI,(unsigned char)((data & 0xFF00)>>8)))
- {
- if(!writeProSlicDirectReg(dev, IAA,address))
- return 0;
- }
- }
- }
-
- return -1;
-}
-
-/*
-** Read register from ProSlic
-*/
-int readProSlicDirectReg(struct usb_device *dev, unsigned char address, unsigned char* dataRead)
-{
- unsigned char data[4];
-
- data[0] = address | 0x80;
- data[1] = 0;
- data[2] = 0;
- data[3] = 0x67;
-
- // write to WC register 0x26
- Wcusb_WriteWcRegs(dev, WCUSB_SPORT0, data, 4);
- Wcusb_ReadWcRegs(dev, WCUSB_SPORT1, data, 1);
- *dataRead = data[0];
-
- return 0;
-}
-
-/*
-** Write register to ProSlic
-*/
-int writeProSlicDirectReg(struct usb_device *dev, unsigned char address, unsigned char RegValue)
-{
- unsigned char data[4];
-
- data[0] = address & 0x7f;
- data[1] = RegValue;
- data[2] = 0;
- data[3] = 0x27;
-
- // write to WC register 0x26
- return Wcusb_WriteWcRegs(dev, WCUSB_SPORT0, data, 4);
-}
-
-static int readProSlicInDirectReg(struct usb_device *dev, unsigned char address, unsigned short *data)
-{
- if (!waitForProSlicIndirectRegAccess(dev))
- {
- if (!writeProSlicDirectReg(dev,IAA,address))
- {
- if(!waitForProSlicIndirectRegAccess(dev))
- {
- unsigned char data1, data2;
-
- if (!readProSlicDirectReg(dev,IDA_LO, &data1) && !readProSlicDirectReg (dev, IDA_HI, &data2))
- {
- *data = data1 | (data2 << 8);
- return 0;
- } else
- printk("Failed to read direct reg\n");
- } else
- printk("Failed to wait inside\n");
- } else
- printk("failed write direct IAA\n");
- } else
- printk("failed to wait\n");
-
- return -1;
-}
-
-static int initializeIndirectRegisters(struct usb_device *dev)
-{
- unsigned char i;
-
- for (i=0; i<43; i++)
- {
- if(writeProSlicInDirectReg(dev, i,indirect_regs[i].initial))
- return -1;
- }
-
- return 0;
-}
-
-static int verifyIndirectRegisters(struct usb_device *dev)
-{
- int passed = 1;
- unsigned short i,j, initial;
-
- for (i=0; i<43; i++)
- {
- if(readProSlicInDirectReg(dev, (unsigned char) i, &j)) {
- printk("Failed to read indirect register %d\n", i);
- return -1;
- }
- initial= indirect_regs[i].initial;
-
- if ( j != initial )
- {
- printk("!!!!!!! %s iREG %X = %X should be %X\n",
- indirect_regs[i].name,i,j,initial );
- passed = 0;
- }
- }
-
- if (passed) {
- if (debug)
- printk("Init Indirect Registers completed successfully.\n");
- } else {
- printk(" !!!!! Init Indirect Registers UNSUCCESSFULLY.\n");
- }
-
- return 0;
-}
-
-static int calibrateAndActivateProSlic(struct usb_device *dev)
-{
- unsigned char x;
-
- if(writeProSlicDirectReg(dev, 92, 0xc8))
- return -1;
-
- if(writeProSlicDirectReg(dev, 97, 0))
- return -1;
-
- if(writeProSlicDirectReg(dev, 93, 0x19))
- return -1;
-
- if(writeProSlicDirectReg(dev, 14, 0))
- return -1;
-
- if(writeProSlicDirectReg(dev, 93, 0x99))
- return -1;
-
- if(!readProSlicDirectReg (dev, 93, &x))
- {
- if (debug)
- printk("DC Cal x=%x\n",x);
-
- if (!writeProSlicDirectReg(dev, 97, 0))
- {
- if(!writeProSlicDirectReg(dev, CALIBR1, CALIBRATE_LINE))
- {
- unsigned char data;
-
- if(!readProSlicDirectReg(dev, CALIBR1, &data))
- return writeProSlicDirectReg(dev, LINE_STATE,ACTIVATE_LINE);
- }
- }
- }
-
- return -1;
-}
-
-static int InitProSlic(struct usb_device *dev)
-{
- if (writeProSlicDirectReg(dev, 67, 0x0e))
- /* Disable Auto Power Alarm Detect and other "features" */
- return -1;
- if (initializeIndirectRegisters(dev)) {
- printk(KERN_INFO "Indirect Registers failed to initialize.\n");
- return -1;
- }
- if (verifyIndirectRegisters(dev)) {
- printk(KERN_INFO "Indirect Registers failed verification.\n");
- return -1;
- }
- if (calibrateAndActivateProSlic(dev)) {
- printk(KERN_INFO "ProSlic Died on Activation.\n");
- return -1;
- }
- if (writeProSlicInDirectReg(dev, 97, 0x0)) { // Stanley: for the bad recording fix
- printk(KERN_INFO "ProSlic IndirectReg Died.\n");
- return -1;
- }
- if (writeProSlicDirectReg(dev, 1, 0x2a)) { // U-Law GCI 8-bit interface
- printk(KERN_INFO "ProSlic DirectReg Died.\n");
- return -1;
- }
- if (writeProSlicDirectReg(dev, 2, 0)) // Tx Start count low byte 0
- return -1;
- if (writeProSlicDirectReg(dev, 3, 0)) // Tx Start count high byte 0
- return -1;
- if (writeProSlicDirectReg(dev, 4, 0)) // Rx Start count low byte 0
- return -1;
- if (writeProSlicDirectReg(dev, 5, 0)) // Rx Start count high byte 0
- return -1;
- if (writeProSlicDirectReg(dev, 8, 0x0)) // disable loopback
- return -1;
- if (writeProSlicDirectReg(dev, 18, 0xff)) // clear all interrupt
- return -1;
- if (writeProSlicDirectReg(dev, 19, 0xff))
- return -1;
- if (writeProSlicDirectReg(dev, 20, 0xff))
- return -1;
- if (writeProSlicDirectReg(dev, 21, 0x00)) // enable interrupt
- return -1;
- if (writeProSlicDirectReg(dev, 22, 0x02)) // Loop detection interrupt
- return -1;
- if (writeProSlicDirectReg(dev, 23, 0x01)) // DTMF detection interrupt
- return -1;
- if (writeProSlicDirectReg(dev, 72, 0x20))
- return -1;
-#ifdef BOOST_RINGER
- /* Beef up Ringing voltage to 89V */
- if (writeProSlicInDirectReg(dev, 23, 0x1d1))
- return -1;
-#endif
- return 0;
-}
-
-static int init_hardware(struct wc_usb_pvt *p)
-{
- struct usb_device *dev = p->dev;
-
- switch (p->devclass) {
- case WC_PROSLIC:
- if (wcoutp(dev, 0x12, 0x00)) /* AUX6 as output, set to low */
- return -1;
- if (wcoutp(dev, 0x13, 0x40)) /* AUX6 is output */
- return -1;
- if (wcoutp(dev, 0, 0x50)) /* extrst, AUX2 is suspend */
- return -1;
- if (wcoutp(dev, 0x29, 0x20)) /* enable SerialUP AUX pin definition */
- return -1;
- if (wcoutp(dev, 0, 0x51)) /* no extrst, AUX2 is suspend */
- return -1;
- /* Make sure there is no gain */
- if (wcoutp(dev, 0x22, 0x00))
- return -1;
- if (wcoutp(dev, 0x23, 0xf2))
- return -1;
- if (wcoutp(dev, 0x24, 0x00))
- return -1;
- if (wcoutp(dev, 0x25, 0xc9))
- return -1;
- if (InitProSlic(dev)) {
- printk("wcusb: Failed to initialize proslic\n");
- return -1;
- }
- case WC_KEYPAD:
- set_aux_ctrl(p, WC_AUX0, 1);
- set_aux_ctrl(p, WC_AUX1, 1);
- set_aux_ctrl(p, WC_AUX2, 1);
- set_aux_ctrl(p, WC_AUX3, 1);
- }
-
- if (debug) printk("wcusb: Setting correct interfaces.\n");
-
- /* Setup correct settings (8000 Hz, signed linear) */
- if (usb_set_interface(dev, 2, 1)) {
- printk("wcusb: Unable to setup USB interface 2 to altsetting 1\n");
- return -1;
- }
- if (usb_set_interface(dev, 3, 1)) {
- printk("wcusb: Unable to setup USB interface 3 to altsetting 1\n");
- return -1;
- }
- return 0;
-}
-
-/* Don't call from an interrupt context */
-static int set_aux_ctrl(struct wc_usb_pvt *p, char uauxpins, int on)
-{
- char udata12 = 0;
- char udata13 = 0;
-
- wcinp(p->dev, 0x12, &udata12);
- wcinp(p->dev, 0x13, &udata13);
-
- wcoutp(p->dev, 0x12, on ? (uauxpins | udata12) : (~uauxpins & udata12));
- wcoutp(p->dev, 0x13, uauxpins | udata13);
-
- return 0;
-}
-
-static void wcusb_check_keypad(struct wc_usb_pvt *p)
-{
- struct wc_keypad_data *d = p->pvt_data;
-
- if (!d->running) {
- printk("Stopping keypad stream\n");
- return;
- }
- if (debug) printk("Launched a packet\n");
- d->state = STATE_FOR_LOOP_1_OUT;
- d->data = -1;
- d->data12 = -1;
- d->scanned_event = -1;
- d->i = 0;
- wcusb_async_read(p, 0x12, &d->data12, 1, 0, keypad_check_done);
- return;
-}
-
-static char wc_dtmf(struct wc_usb_pvt *p)
-{
- struct wc_keypad_data *d = p->pvt_data;
- short linsample = 0;
-
- if (!d) {
- printk("NULL pointer, go away\n");
- return 0;
- }
-
- linsample = zt_tone_nextsample(&d->ts, d->tone);
-
-
- return ZT_LIN2MU(linsample);
-}
-
-#if defined(LINUX26) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
-static void wcusb_read_complete(struct urb *q, struct pt_regs *regs)
-#else
-static void wcusb_read_complete(struct urb *q)
-#endif
-{
- struct wc_usb_pvt *p = q->context;
- short *chunk = q->transfer_buffer;
- int x;
-
- if (!p->flags & FLAG_RUNNING) {
- /* Stop sending URBs since we're not running anymore */
- p->urbcount--;
- return;
- }
-
- switch (p->sample) {
- case STREAM_NORMAL:
- for (x = 0; x < ZT_CHUNKSIZE; x++) {
- p->chan.readchunk[x] = ZT_LIN2MU(le16_to_cpu(chunk[x]));
- }
- break;
- case STREAM_DTMF:
- for (x = 0; x < ZT_CHUNKSIZE; x++) {
- p->chan.readchunk[x] = wc_dtmf(p);
- }
- break;
- }
- /* XXX We could probably optimize some here XXX */
- zt_ec_chunk(&p->chan, p->chan.readchunk, p->chan.writechunk);
-
- zt_receive(&p->span);
-
- q->dev = p->dev;
-
-#ifdef LINUX26
- if (usb_submit_urb(q, GFP_KERNEL))
-#else
- if (usb_submit_urb(q))
-#endif
- {
- printk("wcusb: Read cycle failed\n");
- }
-
- if (p->timer && !--p->timer) {
- if (p->devclass == WC_KEYPAD) {
- if(debug) printk("Checking keypad\n");
- wcusb_check_keypad(p);
- } else {
- wcusb_check_interrupt(p);
- }
- }
-
-#ifdef PROSLIC_POWERSAVE
- if (p->devclass != WC_KEYPAD) {
- if (p->lowpowertimer && !--p->lowpowertimer) {
- /* Switch back into low power mode */
- p->idletxhookstate = 1;
- if (p->txhook == 2)
- p->newtxhook = p->idletxhookstate;
- }
- }
-#endif
- return;
-}
-
-#if defined(LINUX26) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
-static void wcusb_write_complete(struct urb *q, struct pt_regs *regs)
-#else
-static void wcusb_write_complete(struct urb *q)
-#endif
-{
- struct wc_usb_pvt *p = q->context;
- short *chunk = q->transfer_buffer;
- int x;
-
- if (!p->flags & FLAG_RUNNING) {
- /* Stop sending URBs since we're not running anymore */
- p->urbcount--;
- return;
- }
-
- zt_transmit(&p->span);
- for (x = 0; x < ZT_CHUNKSIZE; x++) {
- chunk[x] = cpu_to_le16(ZT_MULAW(p->chan.writechunk[x]));
- }
- q->dev = p->dev;
-
-#ifdef LINUX26
- if (usb_submit_urb(q, GFP_KERNEL))
-#else
- if (usb_submit_urb(q))
-#endif
- {
- printk("wcusb: Write cycle failed\n");
- }
-
- return;
-}
-
-static int StopTransmit(struct wc_usb_pvt *p)
-{
- p->flags &= ~FLAG_RUNNING;
-
- if (p->devclass == WC_KEYPAD) {
- struct wc_keypad_data *d = p->pvt_data;
- d->running = 0;
- }
- while(p->urbcount) {
- schedule_timeout(1);
- }
- printk("ending transmit\n");
- return 0;
-}
-
-static int flip_relays(struct wc_usb_pvt *p, int onoff)
-{
- unsigned char ctl;
- unsigned char data;
- /* Read data */
- if (wcinp(p->dev, 0x12, &data))
- return -1;
- /* Read control */
- if (wcinp(p->dev, 0x13, &ctl))
- return -1;
- /* Setup values properly -- Pins AUX3 & AUX4 control the relays */
- ctl |= 0x18;
- if (onoff) {
- data |= 0x18;
- } else {
- data &= 0xe7;
- }
- if (wcoutp(p->dev, 0x12, data))
- return -1;
- if (wcoutp(p->dev, 0x13, ctl))
- return -1;
- return 0;
-}
-
-static int prepare_transfer_urbs(struct wc_usb_pvt *p)
-{
- int x;
- /* Endpoint 6 is the wave-in device */
- unsigned int readpipe = usb_rcvisocpipe(p->dev, 0x06);
- /* Endpoint 7 is the wave-out device */
- unsigned int writepipe = usb_sndisocpipe(p->dev, 0x07);
-
- for (x = 0; x < 2; x++) {
- p->dataread[x].urb.dev = p->dev;
- p->dataread[x].urb.pipe = readpipe;
-#ifdef LINUX26
- p->dataread[x].urb.transfer_flags = URB_ISO_ASAP;
-#else
- p->dataread[x].urb.transfer_flags = USB_ISO_ASAP;
-#endif
- p->dataread[x].urb.number_of_packets = 1;
- p->dataread[x].urb.context = p;
- p->dataread[x].urb.complete = wcusb_read_complete;
- p->dataread[x].urb.iso_frame_desc[0].length = ZT_CHUNKSIZE * 2;
- p->dataread[x].urb.iso_frame_desc[0].offset = 0;
- p->dataread[x].urb.transfer_buffer = p->readchunk + ZT_CHUNKSIZE * x;
- p->dataread[x].urb.transfer_buffer_length = ZT_CHUNKSIZE * 2;
-
- p->datawrite[x].urb.dev = p->dev;
- p->datawrite[x].urb.pipe = writepipe;
-#ifdef LINUX26
- p->datawrite[x].urb.transfer_flags = URB_ISO_ASAP;
-#else
- p->datawrite[x].urb.transfer_flags = USB_ISO_ASAP;
-#endif
- p->datawrite[x].urb.number_of_packets = 1;
- p->datawrite[x].urb.context = p;
- p->datawrite[x].urb.complete = wcusb_write_complete;
- p->datawrite[x].urb.iso_frame_desc[0].length = ZT_CHUNKSIZE * 2;
- p->datawrite[x].urb.iso_frame_desc[0].offset = 0;
- p->datawrite[x].urb.transfer_buffer = p->writechunk + ZT_CHUNKSIZE * x;
- p->datawrite[x].urb.transfer_buffer_length = ZT_CHUNKSIZE * 2;
-
- }
- return 0;
-}
-
-static int begin_transfer(struct wc_usb_pvt *p)
-{
-
- int x;
- p->urbcount = 4;
- p->flags |= FLAG_RUNNING;
-
- for (x = 0; x < 2; x++) {
-#ifdef LINUX26
- if (usb_submit_urb(&p->dataread[x].urb, GFP_KERNEL))
-#else
- if (usb_submit_urb(&p->dataread[x].urb))
-#endif
- {
- printk(KERN_ERR "wcusb: Read submit failed\n");
- return -1;
- }
-#ifdef LINUX26
- if (usb_submit_urb(&p->datawrite[x].urb, GFP_KERNEL))
-#else
- if (usb_submit_urb(&p->datawrite[x].urb))
-#endif
- {
- printk(KERN_ERR "wcusb: Write submit failed\n");
- return -1;
- }
- }
- /* Start checking for interrupts */
- wcusb_check_interrupt(p);
- return 0;
-}
-
-static int wc_usb_hooksig(struct zt_chan *chan, zt_txsig_t txsig)
-{
- struct wc_usb_pvt *p = chan->pvt;
-
- switch (p->devclass) {
- case WC_PROSLIC:
-#ifdef PROSLIC_POWERSAVE
- if (p->txhook == 4) {
- /* Switching out of ring... Be sure we idle at 2, not 1 at least
- for a bit so we can transmit caller*ID */
- p->idletxhookstate = 2;
- p->lowpowertimer = POWERSAVE_TIME;
- }
-#endif
-
- p->txhook = -1;
- switch(txsig) {
- case ZT_TXSIG_ONHOOK:
- switch(chan->sig) {
- case ZT_SIG_FXOKS:
- case ZT_SIG_FXOLS:
- p->newtxhook = p->idletxhookstate;
- break;
- case ZT_SIG_FXOGS:
- p->newtxhook = 3;
- break;
- }
- break;
- case ZT_TXSIG_OFFHOOK:
- p->newtxhook = p->idletxhookstate;
- break;
- case ZT_TXSIG_START:
- p->newtxhook = 4;
- break;
- case ZT_TXSIG_KEWL:
- p->newtxhook = 0;
- break;
- }
- case WC_KEYPAD:
- switch (txsig) {
- case ZT_TXSIG_ONHOOK:
- break;
- case ZT_TXSIG_OFFHOOK:
- break;
- case ZT_TXSIG_START:
- break;
- case ZT_TXSIG_KEWL:
- break;
- }
- break;
- }
- return 0;
-}
-
-static int wc_usb_open(struct zt_chan *chan)
-{
- struct wc_usb_pvt *p = chan->pvt;
- if (p->dead)
- return -1;
- switch (p->devclass) {
- case WC_KEYPAD:
- p->hookstate = 0;
- zt_hooksig(&p->chan, ZT_RXSIG_ONHOOK);
- break;
- default:
- break;
- }
-#ifndef LINUX26
- MOD_INC_USE_COUNT;
-#endif
- p->usecount++;
- return 0;
-}
-
-static int wc_usb_close(struct zt_chan *chan)
-{
- struct wc_usb_pvt *p = chan->pvt;
- p->usecount--;
- if (!p->usecount && p->dead) {
- /* Someone unplugged us while we were running, so now
- that the program exited, we can release our resources */
- zt_unregister(&p->span);
- ifaces[p->pos] = NULL;
- if (p->pvt_data)
- kfree(p->pvt_data);
- kfree(p);
- }
-#ifndef LINUX26
- MOD_DEC_USE_COUNT;
-#endif
- return 0;
-}
-
-static struct wc_usb_pvt *wc_detect_device(struct usb_device *dev, struct wc_usb_pvt *orig)
-{
- struct wc_usb_pvt *p;
-
- p = orig;
- if (!p) {
- p = kmalloc(sizeof(struct wc_usb_pvt), GFP_KERNEL);
- if (!p) {
- printk("wcusb: kmalloc failed\n");
- return NULL;
- }
-
- memset(p, 0, sizeof(struct wc_usb_pvt));
- }
- p->dev = dev;
-
-#ifdef PROSLIC_POWERSAVE
- /* By default we can't send on hook */
- p->idletxhookstate = 1;
-#else
- /* By default we can always send on hook */
- p->idletxhookstate = 2;
-#endif
-
- printk("wcusb: wc_detect_device\n");
- if (dev->descriptor.idProduct == 0xb210) {
- struct wc_keypad_data *d = kmalloc(sizeof(struct wc_keypad_data), GFP_KERNEL);
- printk("wcusb: Found a WC Keyed Phone\n");
- p->devclass = WC_KEYPAD;
- if (!d) {
- printk("wcusb: kmalloc failed in init_device_pvt\n");
- return NULL;
- }
- memset(d, 0, sizeof(struct wc_keypad_data));
- p->pvt_data = d;
- d->count = 0;
- d->running = 1;
- d->tone = NULL;
- return p;
- } else {
- p->pvt_data = NULL;
- p->devclass = WC_PROSLIC;
- }
- printk("Second exit\n");
- return p;
-}
-
-static int wc_set_zaptel(struct wc_usb_pvt *p)
-{
- int x;
-
- for (x = 0; x < WC_MAX_IFACES; x++)
- if (!ifaces[x]) break;
- if (x >= WC_MAX_IFACES) {
- printk("wcusb: Too many interfaces\n");
- return -1;
- }
-
- sprintf(p->span.name, "WCUSB/%d", x);
- snprintf(p->span.desc, sizeof(p->span.desc) - 1, "%s %d", p->span.name, x);
- sprintf(p->chan.name, "WCUSB/%d/%d", x, 0);
- p->span.manufacturer = "Digium";
- zap_copy_string(p->span.devicetype, p->variety, sizeof(p->span.devicetype));
-
- p->chan.sigcap = ZT_SIG_FXOKS | ZT_SIG_FXOLS | ZT_SIG_FXOGS; /* We're capabable of both FXOKS and FXOLS */
- p->chan.chanpos = 1;
- p->span.deflaw = ZT_LAW_MULAW;
- p->span.chans = &p->chan;
- p->span.channels = 1;
- p->span.hooksig = wc_usb_hooksig;
- p->span.open = wc_usb_open;
- p->span.close = wc_usb_close;
-
- ifaces[x] = p;
- p->pos = x;
- p->span.flags = ZT_FLAG_RBS;
- init_waitqueue_head(&p->span.maintq);
- p->span.pvt = p;
- p->chan.pvt = p;
-
- /* Set the stream to just pass the data from the device uninhibited */
- p->sample = STREAM_NORMAL;
-
- if (zt_register(&p->span, 0)) {
- printk("wcusb: Unable to register span %s\n", p->span.name);
- return -1;
- }
-
- return 0;
-}
-
-#ifdef LINUX26
-static int wc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
-#else
-static void *wc_usb_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id)
-#endif
-{
- struct wc_usb_pvt *p = NULL;
- struct wc_usb_desc *d = (struct wc_usb_desc *)id->driver_info;
-#ifdef LINUX26
- struct usb_device *dev = interface_to_usbdev(intf);
-#endif
-
- int x;
- for (x=0;x<WC_MAX_IFACES;x++) {
- /* Find first dead or empty space */
- p = ifaces[x];
- if (!p) {
- if (debug)
- printk("Device slot %d is free\n", x);
- break;
- }
- if (p->dead) {
- if (debug)
- printk("Device slot %d can be revived\n", x);
- break;
- }
- if (debug)
- printk("Device slot %d is still in use\n", x);
- }
-
- if (!(p = wc_detect_device(dev, p))) {
- printk("wcusb: No wcusb devices found\n");
-#ifdef LINUX26
- return -ENODEV;
-#else
- return NULL;
-#endif
- }
-
-#ifndef LINUX26
- if (usb_set_configuration(dev, dev->config[0].bConfigurationValue) < 0) {
- printk("wcusb: set_configuration failed (ConfigValue 0x%x)\n", dev->config[0].bConfigurationValue);
- return NULL;
- }
-#endif
-
- if (init_hardware(p)) {
- printk("wcusb: Hardware intialization failed.\n");
- goto cleanup;
- }
-
- if (prepare_transfer_urbs(p)) {
- printk("wcusb: problem preparing the urbs for transfer\n");
- goto cleanup;
- }
-
- if (d->flags & FLAG_FLIP_RELAYS) {
- flip_relays(p, 1);
- }
-
- if (!p->dead && wc_set_zaptel(p)) {
- printk("wcusb: Error in starting the zaptel stuff\n");
- goto cleanup;
- }
-
- if (begin_transfer(p)) {
- printk("wcusb: Something went wrong when starting the transfer\n");
- goto cleanup;
- }
-
- if (p->dead)
- printk("wcusb: Rekindling a %s (%s)\n", d->name, p->span.name);
- else
- printk("wcusb: Found a %s (%s)\n", d->name, p->span.name);
-
- /* Reset deadness */
- p->dead = 0;
- /* Clear alarms */
- p->span.alarms = 0;
- p->variety = d->name;
- zt_alarm_notify(&p->span);
-#ifdef LINUX26
- usb_set_intfdata(intf, p);
- return 0;
-#else
- return p;
-#endif
-
-cleanup:
- printk("cleanup\n");
- if (p) {
- if (p->pvt_data) {
- kfree(p->pvt_data);
- }
- kfree(p);
- }
-#ifdef LINUX26
- return -ENODEV;
-#else
- return NULL;
-#endif
-}
-
-#ifdef LINUX26
-static void wc_usb_disconnect(struct usb_interface *intf)
-#else
-static void wc_usb_disconnect(struct usb_device *dev, void *ptr)
-#endif
-{
- /* Doesn't handle removal if we're in use right */
-#ifdef LINUX26
- struct wc_usb_pvt *p = usb_get_intfdata(intf);
-#else
- struct wc_usb_pvt *p = ptr;
-#endif
- if (p) {
- StopTransmit(p);
- p->dev = NULL;
- if (!p->usecount) {
- zt_unregister(&p->span);
- if (p->pvt_data)
- kfree(p->pvt_data);
- ifaces[p->pos] = NULL;
- kfree(p);
- } else {
- /* Generate alarm and note that we're dead */
- p->span.alarms = ZT_ALARM_RED;
- zt_alarm_notify(&p->span);
- p->dead = 1;
- }
- }
- printk("wcusb: Removed a Wildcard device\n");
-#ifdef LINUX26
- usb_set_intfdata(intf, NULL);
-#endif
- return;
-}
-
-static struct usb_device_id wc_dev_ids[] = {
- /* This needs to be a USB audio device, and it needs to be made by us and have the right device ID */
- {
- match_flags: (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_DEVICE),
- bInterfaceClass: USB_CLASS_AUDIO,
- bInterfaceSubClass: 1,
- idVendor: 0x06e6,
- idProduct: 0x831c, /* Product ID / Chip configuration (you can't change this) */
- driver_info: (unsigned long)&wcusb,
- },
- {
- match_flags: (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_DEVICE),
- bInterfaceClass: USB_CLASS_AUDIO,
- bInterfaceSubClass: 1,
- idVendor: 0x06e6,
- idProduct: 0x831e,
- driver_info: (unsigned long)&wcusb2,
- },
- {
- match_flags: (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_DEVICE),
- bInterfaceClass: USB_CLASS_AUDIO,
- bInterfaceSubClass: 1,
- idVendor: 0x06e6,
- idProduct: 0xb210,
- driver_info: (unsigned long)&wc_usb_phone,
- },
- { } /* Terminating Entry */
-};
-
-static struct usb_driver wc_usb_driver =
-{
-#ifdef LINUX26
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
- owner: THIS_MODULE,
-#endif
-#else
- fops: NULL,
- minor: 0,
-#endif
- name: "wcusb",
- probe: wc_usb_probe,
- disconnect: wc_usb_disconnect,
- id_table: wc_dev_ids,
-};
-
-static int __init wc_init (void)
-{
- int res;
- res = usb_register(&wc_usb_driver);
- if (res)
- return res;
- printk("Wildcard USB FXS Interface driver registered\n");
- return 0;
-}
-
-static void __exit wc_cleanup(void)
-{
- usb_deregister(&wc_usb_driver);
-}
-
-MODULE_AUTHOR("Matthew Fredrickson <creslin@digium.com>");
-MODULE_DESCRIPTION("Wildcard USB FXS Interface driver");
-#ifdef MODULE_LICENSE
-MODULE_LICENSE("GPL");
-#endif
-
-MODULE_DEVICE_TABLE(usb, wc_dev_ids);
-
-module_init(wc_init);
-module_exit(wc_cleanup);
diff --git a/drivers/dahdi/wcusb.h b/drivers/dahdi/wcusb.h
deleted file mode 100644
index f22d0ac..0000000
--- a/drivers/dahdi/wcusb.h
+++ /dev/null
@@ -1,142 +0,0 @@
-
-#ifndef _WCUSB_H
-#define _WCUSB_H
-
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/module.h>
-#include <linux/usb.h>
-
-#include <linux/version.h>
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,19)
-#define USB2420
-#endif
-
-#include "zaptel.h"
-
-#define WC_MAX_IFACES 128
-
-#define POWERSAVE_TIME 4000 /* Powersaving timeout for devices with a proslic */
-
-/* Various registers and data ports on the tigerjet part */
-#define WCUSB_SPORT0 0x26
-#define WCUSB_SPORT1 0x27
-#define WCUSB_SPORT2 0x28
-#define WCUSB_SPORT_CTRL 0x29
-
-#define WC_AUX0 0x1
-#define WC_AUX1 0x2
-#define WC_AUX2 0x4
-#define WC_AUX3 0x8
-
-#define CONTROL_TIMEOUT_MS (500) /* msec */
-#define CONTROL_TIMEOUT_JIFFIES ((CONTROL_TIMEOUT_MS * HZ) / 1000)
-
-#define REQUEST_NORMAL 4
-
-#define FLAG_RUNNING (1 << 0)
-
-/* Important data structures and data types */
-
-
-/* States for the Proslic read state machine */
-typedef enum {
- STATE_WCREAD_WRITEREG,
- STATE_WCREAD_READRES,
- STATE_WCWRITE_WRITEREG,
- STATE_WCWRITE_WRITERES,
-} proslic_state_t;
-
-/* Used for current stream state */
-typedef enum {
- STREAM_NORMAL, /* Sends normal (unmodified) audio data */
- STREAM_DTMF, /* (For keypad device) Sends dtmf data */
-} stream_t;
-
-/* States for the Keypad state machine */
-typedef enum {
- STATE_FOR_LOOP_1_OUT,
- STATE_FOR_LOOP_2_IN,
- STATE_FOR_LOOP_PROC_DATA,
- STATE_FOR_LOOP_CLEAR_DIGIT,
-} keypad_state_t;
-
-/* Device types. For radical changes in a new device, use a switch based on the device type */
-typedef enum {
- WC_KEYPAD, /* The tigerjet phone with the keypad. That was a bugger to implement */
- WC_PROSLIC, /* For various devices with a proslic */
-} dev_type_t;
-
-struct wc_keypad_data {
- keypad_state_t state; /* Current state in the keypad detect routine */
-#ifdef USB2420
- struct urb urb; /* urb used for the keypad data transport ... can't remember whether it is used or not */
-#else
- urb_t urb; /* urb used for the keypad data transport ... can't remember whether it is used or not */
-#endif
- int running;
- char data;
- char data12;
- char tmp;
- int scanned_event;
- int i;
- int count;
- /* DTMF tone generation stuff for zaptel */
- struct zt_tone_state ts;
- struct zt_tone *tone;
-};
-
-struct stinky_urb {
-#ifdef USB2420
- struct urb urb;
-#ifndef LINUX26
- struct iso_packet_descriptor isoframe[1];
-#endif
-#else
- urb_t urb;
- iso_packet_descriptor_t isoframe[1];
-#endif
-};
-
-struct wc_usb_pvt {
- const char *variety;
- struct usb_device *dev;
- dev_type_t devclass;
- int usecount;
- int dead;
- struct zt_span span;
- struct zt_chan chan;
- struct stinky_urb dataread[2];
- struct stinky_urb datawrite[2];
-#ifdef USB2420
- struct urb control;
- struct usb_ctrlrequest dr;
-#else
- urb_t control;
- devrequest dr;
-#endif
- proslic_state_t controlstate;
- int urbcount;
- int flags;
- int timer;
- int lowpowertimer;
- int idletxhookstate;
- int hookstate;
- __u8 newtxhook;
- __u8 txhook;
- int pos;
- unsigned char auxstatus;
- unsigned char wcregindex;
- unsigned char wcregbuf[4];
- unsigned char wcregval;
- short readchunk[ZT_MAX_CHUNKSIZE * 2];
- short writechunk[ZT_MAX_CHUNKSIZE * 2];
- stream_t sample;
- void *pvt_data;
-};
-
-struct wc_usb_desc {
- char *name;
- int flags;
-};
-#endif