[Pkg-voip-commits] r3298 - in zaptel/trunk: cwain debian
debian/patches qozap ztgsm
Tzafrir Cohen
tzafrir-guest at alioth.debian.org
Sat Mar 24 07:28:05 CET 2007
Author: tzafrir-guest
Date: 2007-03-24 06:28:03 +0000 (Sat, 24 Mar 2007)
New Revision: 3298
Added:
zaptel/trunk/qozap/zapata.conf.duoBRI
zaptel/trunk/qozap/zaptel.conf.duoBRI
Modified:
zaptel/trunk/cwain/cwain.c
zaptel/trunk/cwain/cwain.h
zaptel/trunk/debian/changelog
zaptel/trunk/debian/patches/bristuff.dpatch
zaptel/trunk/qozap/Makefile
zaptel/trunk/qozap/qozap.c
zaptel/trunk/qozap/zaptel.conf
zaptel/trunk/qozap/zaptel.conf.octoBRI
zaptel/trunk/ztgsm/ztgsm.c
zaptel/trunk/ztgsm/ztgsm.h
Log:
bristuff 0.3.0-PRE-1y-b.
Modified: zaptel/trunk/cwain/cwain.c
===================================================================
--- zaptel/trunk/cwain/cwain.c 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/cwain/cwain.c 2007-03-24 06:28:03 UTC (rev 3298)
@@ -5,7 +5,7 @@
*
* single/double E1 board
*
- * Copyright (C) 2004, 2005 Junghanns.NET GmbH
+ * Copyright (C) 2004, 2005, 2006, 2007 Junghanns.NET GmbH
*
* Klaus-Peter Junghanns <kpj at junghanns.net>
*
@@ -29,10 +29,12 @@
static int ports=-1; /* autodetect */
static int debug=0;
-static int hw_hdlc=0;
+static int hw_hdlc=1;
+static int hdlcnet=0;
static int pwm0 = 0x50; /* TX level */
-static int pwm1 = 0xff; /* RX level */
-static int dacs = 0; /* 0 = no dacs, 1 = oncard dacs */
+static int pwm1 = 0x50; /* RX level */
+static int dacs = 1; /* 0 = no dacs, 1 = oncard dacs */
+static int require_ext_clock = 0;
static struct zt_cwain *cwain_span_list = NULL;
static int cwain_span_count = 0;
static struct zt_cwain_card *cwain_card_list = NULL;
@@ -179,33 +181,52 @@
}
}
+void cwain_reset_pcm(struct zt_cwain *cwaintmp, int master, int int_clock) {
+ /* PCM reset */
+ cwain_outb(cwaintmp,cwain_R_CIRM,0x20);
+ cwain_outb(cwaintmp,cwain_R_CIRM,0x0);
+ cwain_waitbusy(cwaintmp);
+
+ if (master) {
+ cwain_outb(cwaintmp,cwain_R_PCM_MD0, 0x91);
+ cwain_outb(cwaintmp,cwain_R_PCM_MD1, 0x20);
+ if (int_clock) {
+ cwain_outb(cwaintmp,cwain_R_PCM_MD0, 0xA1);
+ cwain_outb(cwaintmp,cwain_R_PCM_MD2, 0x04);
+ } else {
+ cwain_outb(cwaintmp,cwain_R_PCM_MD0, 0xA1);
+ cwain_outb(cwaintmp,cwain_R_PCM_MD2, 0x00);
+ }
+ } else {
+ cwain_outb(cwaintmp,cwain_R_PCM_MD0, 0x90);
+ cwain_outb(cwaintmp,cwain_R_PCM_MD1, 0x20);
+ }
+}
+
void cwain_reset_span(struct zt_cwain *cwaintmp) {
- int i = 0;
pci_write_config_word(cwaintmp->pcidev, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_IO); // enable memio
- /* FIFO, HDLC reset */
- cwain_outb(cwaintmp,cwain_R_CIRM,0x10);
+ cwain_reset_pcm(cwaintmp,0,0);
+
+ /* E1 reset */
+ cwain_outb(cwaintmp,cwain_R_CIRM,0x40);
cwain_outb(cwaintmp,cwain_R_CIRM,0x0);
cwain_waitbusy(cwaintmp);
- /* PCM reset */
- cwain_outb(cwaintmp,cwain_R_CIRM,0x20);
+ /* soft reset */
+ cwain_outb(cwaintmp,cwain_R_CIRM,0x10);
cwain_outb(cwaintmp,cwain_R_CIRM,0x0);
cwain_waitbusy(cwaintmp);
- for (i=0; i<256; i++) {
- cwain_outb(cwaintmp,cwain_R_SLOT, i);
- cwain_outb(cwaintmp,cwain_A_SL_CFG, 0x0);
+ /* 128 byte B chans, 4096 byte D chans */
+ if (hdlcnet) {
+ cwain_outb(cwaintmp,cwain_R_FIFO_MD,0x3E);
+ } else {
+ cwain_outb(cwaintmp,cwain_R_FIFO_MD,0x36);
}
-
- /* E1 reset */
- cwain_outb(cwaintmp,cwain_R_CIRM,0x40);
- cwain_outb(cwaintmp,cwain_R_CIRM,0x0);
- cwain_waitbusy(cwaintmp);
- /* 128 byte B chans, 4096 byte D chans */
- cwain_outb(cwaintmp,cwain_R_FIFO_MD,0x36);
+
cwain_outb(cwaintmp,cwain_R_BRG_PCM_CFG,0x0);
cwain_outb(cwaintmp,cwain_R_CTRL,0x0);
@@ -329,14 +350,90 @@
return 0;
}
+static void cwain_dfifo_check(struct zt_cwain *cwaintmp) {
+ unsigned short z1=1,z2=1;
+ unsigned short oz1=0,oz2=0;
+ unsigned char f1=1,f2=1;
+ unsigned char of1=0,of2=0;
+ int space = 0;
+ int len;
+ int chan;
+ int fifo = 0x1f;
+ unsigned long flags;
+ int frames = 0;
+
+ if (hdlcnet) {
+ chan = 0;
+ } else {
+ chan = 15;
+ }
+
+
+ /* calculate how much data we can allow zaptel to transmit */
+ spin_lock_irqsave(&cwaintmp->lock,flags);
+ /* select tx fifo */
+
+ cwain_outb(cwaintmp,cwain_R_FIFO, fifo << 1);
+ cwain_waitbusy(cwaintmp);
+
+ while ((oz1 != z1) && (oz2 != z2)) {
+ oz1 = z1;
+ oz2 = z2;
+ z1 = cwain_inw(cwaintmp,cwain_A_Z1) & 0xfff;
+ z2 = cwain_inw(cwaintmp,cwain_A_Z2) & 0xfff;
+ }
+
+ len = z1-(z2 & 0xfff);
+ if (len < 0) {
+ len += cwain_DFIFO_SIZE;
+ }
+ space = cwain_DFIFO_SIZE - len;
+
+ if (((debug > 2) && (space < cwain_DFIFO_SIZE)) || (space == 0)) {
+ printk(KERN_INFO "cwain: card %d TX fifo %d space now %d\n", cwaintmp->cardno, fifo, space);
+ }
+ cwaintmp->chans[chan].maxbytes2transmit = space;
+
+
+ /* calculate how many frames are in the receive fifo */
+
+ /* select rx fifo */
+ cwain_outb(cwaintmp,cwain_R_FIFO,(fifo << 1) | 1);
+ cwain_waitbusy(cwaintmp);
+
+ while ((of1 != f1) && (of2 != f2)) {
+ of1 = f1;
+ of2 = f2;
+ f1 = cwain_inb(cwaintmp,cwain_A_F1) & 0xf;
+ f2 = cwain_inb(cwaintmp,cwain_A_F2) & 0xf;
+ }
+
+ frames = f1 - f2;
+ if (frames < 0) {
+ frames += cwain_DFIFO_FRAMES;
+ }
+ cwaintmp->drx = frames;
+
+ spin_unlock_irqrestore(&cwaintmp->lock,flags);
+
+ if ((frames > 0) && (debug > 3))
+ printk(KERN_INFO "\ncwain: %d frames in RX fifo\n", frames);
+}
+
static int cwain_dfifo_tx(struct zt_cwain *cwaintmp) {
- int chan = 15;
+ int chan;
int x=0;
char fifo = 0;
unsigned long flags = 0;
-
+
fifo = 0x1F;
+ if (hdlcnet) {
+ chan = 0;
+ } else {
+ chan = 15;
+ }
+
if (cwaintmp->chans[chan].bytes2transmit < 1) {
return 0;
} else {
@@ -344,24 +441,26 @@
/* select fifo */
cwain_outb(cwaintmp,cwain_R_FIFO,fifo << 1);
cwain_waitbusy(cwaintmp);
-
- if (debug)
+
+ if (((debug > 3 ) && hdlcnet) || ((!hdlcnet) && (debug > 3)))
printk(KERN_INFO "cwain: card %d TX [ ", cwaintmp->cardno);
/* copy frame to fifo */
for (x=0;x<cwaintmp->chans[chan].bytes2transmit;x++) {
- if (debug)
+ if (((debug > 3 ) && hdlcnet) || ((!hdlcnet) && (debug > 3)))
printk("%#x ",cwaintmp->dtxbuf[x]);
cwain_outb(cwaintmp,cwain_A_FIFO_DATA0,cwaintmp->dtxbuf[x]);
}
- if (debug)
+ if (((debug > 3 ) && hdlcnet) || ((!hdlcnet) && (debug > 3)))
printk("]\n");
- if (debug)
+ if (((debug > 2 ) && hdlcnet) || ((!hdlcnet) && (debug > 3)))
printk(KERN_INFO "ztx %d bytes\n",cwaintmp->chans[chan].bytes2transmit);
if (cwaintmp->chans[chan].eoftx == 1) {
/* transmit HDLC frame */
cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x1);
cwain_waitbusy(cwaintmp);
+ if ((debug > 3 ) && hdlcnet)
+ printk(KERN_INFO "cwain: TX flag\n");
}
spin_unlock_irqrestore(&cwaintmp->lock,flags);
}
@@ -371,11 +470,22 @@
static int cwain_fifo_tx(struct zt_cwain *cwaintmp, char fifo) {
int chan,f;
unsigned long flags = 0;
- if (fifo >= 15) {
- chan = fifo;
+
+ if (hw_hdlc) {
+ if (fifo <= 14) {
+ chan = fifo;
+ } else {
+ chan = fifo + 1;
+ }
} else {
chan = fifo;
}
+
+ if (dacs && (cwaintmp->ts_rx[chan] > -1)) {
+ /* dont transmit when we receive from the pcm bus */
+ return 0;
+ }
+
spin_lock_irqsave(&cwaintmp->lock,flags);
/* select fifo */
cwain_outb(cwaintmp,cwain_R_FIFO,0x80 | (fifo << 1));
@@ -389,16 +499,20 @@
}
static int cwain_dfifo_rx(struct zt_cwain *cwaintmp) {
- int chan = 15;
- unsigned char f1=1,f2=1,data,stat;
- unsigned char of1=0,of2=0;
- int len,i;
+ int chan;
+ unsigned char data,stat;
+ int len,i = 0;
unsigned short z1=1,z2=1;
unsigned short oz1=0,oz2=0;
char fifo = 0;
unsigned long flags = 0;
fifo = 0x1F;
+ if (hdlcnet) {
+ chan = 0;
+ } else {
+ chan = 15;
+ }
spin_lock_irqsave(&cwaintmp->lock,flags);
/* select fifo */
@@ -417,25 +531,21 @@
len += cwain_DFIFO_SIZE;
}
- while ((of1 != f1) && (of2 != f2)) {
- of1 = f1;
- of2 = f2;
- f1 = cwain_inb(cwaintmp,cwain_A_F1) & 0xf;
- f2 = cwain_inb(cwaintmp,cwain_A_F2) & 0xf;
- }
-
if (len > cwain_DFIFO_SIZE) {
printk(KERN_INFO "\ncwain: buffer overflow in D channel RX!\n");
cwaintmp->chans[chan].bytes2receive = 0;
cwaintmp->chans[chan].eofrx = 0;
} else {
- if (debug) printk(KERN_INFO "cwain: card %d RX [ ", cwaintmp->cardno);
+ if ((((debug > 3 ) && hdlcnet) || ((!hdlcnet) && (debug > 3))) && (cwaintmp->sync))
+ printk(KERN_INFO "cwain: card %d RX [ ", cwaintmp->cardno);
for (i=0; i<len; i++) {
data = cwain_inb(cwaintmp,cwain_A_FIFO_DATA0);
cwaintmp->drxbuf[i] = data;
- if (debug) printk("%#x ",data);
+ if ((((debug > 3 ) && hdlcnet) || ((!hdlcnet) && (debug > 3))) && (cwaintmp->sync))
+ printk("%#x ",data);
}
- if (debug) printk("] %d bytes\n", i);
+ if ((((debug > 3 ) && hdlcnet) || ((!hdlcnet) && (debug > 3))) && (cwaintmp->sync))
+ printk("] %d bytes\n", i);
cwaintmp->chans[chan].bytes2receive = i;
cwaintmp->chans[chan].eofrx = 1;
}
@@ -444,35 +554,51 @@
if (stat != 0x0) {
// bad CRC, skip it
if (cwaintmp->sync) {
- printk(KERN_INFO "cwain: BAD CRC for hdlc frame on card %d (cardID %d) stat %#x\n",cwaintmp->cardno, cwaintmp->cardID, stat);
+ printk(KERN_INFO "cwain: BAD CRC for hdlc frame on card %d (cardID %d) stat %#x len %d\n",cwaintmp->cardno, cwaintmp->cardID, stat, i);
}
cwaintmp->chans[chan].bytes2receive = 0;
cwaintmp->chans[chan].eofrx = 0;
-// zt_qevent_nolock(&cwaintmp->spans[stport].chans[chan], ZT_EVENT_BADFCS);
+// zt_qevent_nolock(&cwaintmp->chans[chan], ZT_EVENT_BADFCS);
}
cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x1);
cwain_waitbusy(cwaintmp);
/* frame received */
cwaintmp->drx--;
+ if (!cwaintmp->sync) {
+ cwaintmp->chans[chan].bytes2receive = 0;
+ cwaintmp->chans[chan].eofrx = 0;
+ stat = 0xff;
+ }
spin_unlock_irqrestore(&cwaintmp->lock,flags);
- return 0;
+ if (stat == 0) {
+ return 1;
+ } else {
+ return 0;
+ }
}
static int cwain_fifo_rx(struct zt_cwain *cwaintmp, char fifo) {
int chan;
unsigned int data;
- int len,i,f,flen = 0;
+ int len = 0,i,f,flen = 0;
unsigned short z1=1,z2=1;
unsigned short oz1=0,oz2=0;
int mumbojumbo=0;
unsigned long flags = 0;
int x = 1000;
- chan = fifo;
+ if (hw_hdlc) {
+ if (fifo <= 14) {
+ chan = fifo;
+ } else {
+ chan = fifo + 1;
+ }
+ } else {
+ chan = fifo;
+ }
// select rx fifo
-
spin_lock_irqsave(&cwaintmp->lock,flags);
// no hdlc, transparent data
cwain_outb(cwaintmp,cwain_R_FIFO,0x80 | (fifo << 1) | 1);
@@ -506,7 +632,7 @@
if (len < cwain_FRAME_SIZE) {
/* dont get nervous here */
if ((cwaintmp->clicks > 600) && (cwaintmp->span.alarms == ZT_ALARM_NONE)) {
- printk(KERN_INFO "cwain: not enough to receive (%d bytes)\n",len);
+ printk(KERN_INFO "cwain: cardID %d not enough to receive (%d bytes), fifo %d\n",cwaintmp->cardID, len, fifo);
}
spin_unlock_irqrestore(&cwaintmp->lock,flags);
return 0;
@@ -518,7 +644,7 @@
/* dont get nervous here */
- if ((cwaintmp->clicks > 500) && (cwaintmp->span.alarms == ZT_ALARM_NONE)) {
+ if (((cwaintmp->clicks > 50) || (debug > 3)) && ((cwaintmp->span.alarms == ZT_ALARM_NONE) && (mumbojumbo > 0))) {
printk(KERN_INFO "cwain: span %d dropped audio fifo %d mj %d flen %d z1 %d z2 %d\n", cwaintmp->cardID, fifo, mumbojumbo, flen, z1, z2);
cwaintmp->clicks = 0;
}
@@ -534,48 +660,42 @@
if (cwaintmp->syncsrc == span) return;
spin_lock_irqsave(&cwaintmp->lock,flags);
+ /* disable the old master */
for (i=0; i < cwaintmp->spans; i++) {
- if (i != span) {
- if (cwaintmp->syncs[i] > 0) {
- /* enable PCM slave mode, PCM32, synced to E1 receive */
- cwain_outb(cwaintmp->span[i],cwain_R_PCM_MD0, 0x90);
- cwain_outb(cwaintmp->span[i],cwain_R_PCM_MD1, 0x20);
- cwain_outb(cwaintmp->span[i],cwain_R_PCM_MD0, 0xA0);
- cwain_outb(cwaintmp->span[i],cwain_R_PCM_MD2, 0x0);
- } else {
- /* enable PCM slave mode, PCM32 */
- cwain_outb(cwaintmp->span[i],cwain_R_PCM_MD0, 0x90);
- cwain_outb(cwaintmp->span[i],cwain_R_PCM_MD1, 0x20);
- cwain_outb(cwaintmp->span[i],cwain_R_PCM_MD0, 0xA0);
- cwain_outb(cwaintmp->span[i],cwain_R_PCM_MD2, 0x04 | 0x8);
- }
+ if (cwaintmp->master[i]) {
+ /* enable PCM slave mode, PCM128 */
+ cwain_reset_pcm(cwaintmp->span[i],0,0);
cwaintmp->master[i] = 0;
- cwaintmp->span[i]->span.syncsrc = 0;
}
}
+ /* enable the new master */
if (cwaintmp->syncs[span] > 0) {
- /* enable PCM master mode, PCM32, synced to E1 receive */
+ /* enable PCM master mode, PCM128, synced to E1 receive */
+ cwain_reset_pcm(cwaintmp->span[span],1,0);
if (debug)
printk(KERN_INFO "cwain: cardID %d span %d, PCM master E1 sync\n", cwaintmp->cardID, span);
- cwain_outb(cwaintmp->span[span],cwain_R_PCM_MD0, 0x91);
- cwain_outb(cwaintmp->span[span],cwain_R_PCM_MD1, 0x20);
- cwain_outb(cwaintmp->span[span],cwain_R_PCM_MD0, 0xA1);
- cwain_outb(cwaintmp->span[span],cwain_R_PCM_MD2, 0x00);
- cwaintmp->span[span]->span.syncsrc = 1;
} else {
- /* enable PCM master mode, PCM32, free running */
+ /* enable PCM master mode, PCM128, free running */
+ cwain_reset_pcm(cwaintmp->span[span],1,1);
if (debug)
- printk(KERN_INFO "cwain: cardID %d span %d, PCM master\n", cwaintmp->cardID, span);
- cwain_outb(cwaintmp->span[span],cwain_R_PCM_MD0, 0x91);
- cwain_outb(cwaintmp->span[span],cwain_R_PCM_MD1, 0x20);
- cwain_outb(cwaintmp->span[span],cwain_R_PCM_MD0, 0xA1);
- cwain_outb(cwaintmp->span[span],cwain_R_PCM_MD2, 0x04);
- cwaintmp->span[span]->span.syncsrc = 0;
+ printk(KERN_INFO "cwain: cardID %d span %d, PCM master internal clock\n", cwaintmp->cardID, span);
}
+
+ /* reset the slaves */
+ for (i=0; i < cwaintmp->spans; i++) {
+ if (i != span) {
+ /* enable PCM slave mode, PCM128 */
+ cwain_reset_pcm(cwaintmp->span[i],0,0);
+ cwaintmp->master[i] = 0;
+ }
+ }
cwaintmp->master[span] = 1;
cwaintmp->syncsrc = span;
+
+ /* restore pcm assignments !!! */
+
spin_unlock_irqrestore(&cwaintmp->lock,flags);
}
@@ -622,8 +742,8 @@
}
}
- /* if reelection failed, find internal sync source */
- if (cwaintmp->syncsrc == -1) {
+ /* if reelection failed, find internal sync source, if not forbidden! */
+ if ((cwaintmp->syncsrc == -1) && !require_ext_clock) {
/* no master yet */
if (debug > 3)
printk(KERN_INFO "cwain: no clocksource found cardID %d\n", cwaintmp->cardID);
@@ -662,7 +782,17 @@
int dst_hfc_chan = dst_chan;
struct zt_cwain *cwain_src = NULL, *cwain_dst = NULL;
unsigned long flags = 0;
+ /* hw_hdlc == 1
+ fifo 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 >< 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
+ time 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ chan 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
+ hw_hdlc == 0
+ fifo 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
+ time 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ chan 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
+ */
+
if (hw_hdlc) {
if (dst_chan > 0x10) {
dst_fifo--;
@@ -680,15 +810,18 @@
}
if (debug)
- printk(KERN_INFO "cwain: assign(src_span %d, src_chan %d, dst_span %d, dst_chan %d, use_pcm_bus %d\n", src_span, src_chan, dst_span, dst_chan, use_pcm_bus);
+ printk(KERN_INFO "cwain: assign(src_span %d (ID %d), src_chan %d, dst_span %d (ID %d), dst_chan %d, use_pcm_bus %d, timeslot %d\n", src_span, cwain_src->cardID, src_chan, dst_span, cwain_dst->cardID, dst_chan, use_pcm_bus, timeslot);
spin_lock_irqsave(&cwaincard->lock,flags);
- cwain_outb(cwain_src,cwain_R_FIFO,(src_fifo << 1) | 1);
- cwain_waitbusy(cwain_src);
+
+ /* assign the data received from the hfc-channel "src_hfc_chan" to transmit pcm slot "timeslot" on pin STIO1 */
+ /* TX up */
+ cwain_outb(cwain_src,cwain_R_FIFO, src_fifo << 1);
+ cwain_waitbusy(cwain_src);
cwain_outb(cwain_src,cwain_R_INC_RES_FIFO,0x2);
cwain_waitbusy(cwain_src);
- cwain_outb(cwain_src,cwain_A_CHANNEL,(src_hfc_chan << 1) | 1);
- cwain_outb(cwain_src,cwain_A_CON_HDLC,0xDE);
+ cwain_outb(cwain_src,cwain_A_CON_HDLC,0xC2);
+ cwain_outb(cwain_src,cwain_A_CHANNEL,src_hfc_chan << 1);
cwain_outb(cwain_src,cwain_R_SLOT,timeslot << 1);
if (use_pcm_bus) {
@@ -696,21 +829,27 @@
} else {
cwain_outb(cwain_src,cwain_A_SL_CFG, (src_hfc_chan << 1) | 0 | 0x40);
}
+ cwain_src->ts_tx[src_chan - 1] = timeslot;
- cwain_outb(cwain_dst,cwain_R_FIFO, dst_fifo << 1);
- cwain_waitbusy(cwain_dst);
+ /* assign the data received from the receive pcm slot "timeslot" on pin STIO1 to the hfc-channel "dst_hfc_chan"*/
+ /* RX down */
+ cwain_outb(cwain_dst,cwain_R_FIFO, (dst_fifo << 1) | 1);
+ cwain_waitbusy(cwain_dst);
cwain_outb(cwain_dst,cwain_R_INC_RES_FIFO,0x2);
cwain_waitbusy(cwain_dst);
- cwain_outb(cwain_dst,cwain_A_CHANNEL,dst_hfc_chan << 1);
- cwain_outb(cwain_dst,cwain_A_CON_HDLC,0xDE);
+ cwain_outb(cwain_dst,cwain_A_CHANNEL,(dst_hfc_chan << 1) | 1);
+ cwain_outb(cwain_dst,cwain_A_CON_HDLC,0xC2);
cwain_outb(cwain_dst,cwain_R_SLOT,(timeslot << 1) | 1);
-
if (use_pcm_bus) {
cwain_outb(cwain_dst,cwain_A_SL_CFG, (dst_hfc_chan << 1) | 1 | 0xC0);
} else {
cwain_outb(cwain_dst,cwain_A_SL_CFG, (dst_hfc_chan << 1) | 1 | 0x40);
}
+ cwain_dst->ts_rx[dst_chan - 1] = timeslot;
+// printk(KERN_INFO "cwain: span %d ts_tx[%d] = %d\n", src_span, src_chan - 1, timeslot);
+// printk(KERN_INFO "cwain: span %d ts_rx[%d] = %d\n", dst_span, dst_chan - 1, timeslot);
+
spin_unlock_irqrestore(&cwaincard->lock,flags);
}
@@ -724,21 +863,40 @@
}
if (lock) spin_lock_irqsave(&cwaintmp->lock,flags);
- cwain_outb(cwaintmp,cwain_R_FIFO,(fifo << 1));
+
+ /* unassign from_where we receive and to_where we transmit */
+
+
+ /* we were transmitting on cwaintmp->ts_tx[chan - 1] */
+ cwain_outb(cwaintmp,cwain_R_SLOT, cwaintmp->ts_tx[chan - 1] << 1);
+ cwain_outb(cwaintmp,cwain_A_SL_CFG, 0x0);
+ cwaintmp->ts_tx[chan - 1] = -1;
+
+ /* we were receiving on cwaintmp->ts_rx[chan - 1] */
+ cwain_outb(cwaintmp,cwain_R_SLOT, (cwaintmp->ts_rx[chan - 1] << 1) | 1);
+ cwain_outb(cwaintmp,cwain_A_SL_CFG, 0x0);
+ cwaintmp->ts_rx[chan - 1] = -1;
+
+ /* restore our tx fifo */
+ cwain_outb(cwaintmp,cwain_R_FIFO,fifo << 1);
cwain_waitbusy(cwaintmp);
cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x02);
- cwain_outb(cwaintmp,cwain_A_CHANNEL,(hfc_chan << 1));
- cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x1);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,hfc_chan << 1);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ /* restore our rx fifo */
cwain_outb(cwaintmp,cwain_R_FIFO,(fifo << 1) | 1);
cwain_waitbusy(cwaintmp);
cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x02);
- cwain_outb(cwaintmp,cwain_A_CHANNEL,(hfc_chan << 1) | 1);
- cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x1);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,(hfc_chan << 1) | 1);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+
+// printk(KERN_INFO "cwain: ts_tx[%d] = %d\n", chan - 1, -1);
+// printk(KERN_INFO "cwain: ts_rx[%d] = %d\n", chan - 1, -1);
if (lock) spin_unlock_irqrestore(&cwaintmp->lock,flags);
}
@@ -747,7 +905,8 @@
struct zt_cwain *cwaintmp = NULL;
int use_pcm_bus = 0;
int timeslot = 0;
- if (!dacs) return 0;
+ if (hdlcnet) return -1;
+ if (!dacs) return -1;
if (src) {
cwaintmp = src->pvt;
@@ -766,9 +925,17 @@
} else {
if (debug)
printk("cwain: Assigning %d/%d -> %d/%d, same cwain card!\n", src->span->offset, src->chanpos, dst->span->offset, dst->chanpos);
- timeslot = src->channo;
- // timeslot = (src->span->offset * 30) + (src->chanpos - 1);
- use_pcm_bus = 0;
+ timeslot = src->channo;
+/* if (dacs == 2) {
+ timeslot = src->channo;
+ } else {
+ timeslot = (src->span->offset * 30) + (src->chanpos - 1);
+ } */
+ if (src->span == dst->span) {
+ use_pcm_bus = 0;
+ } else {
+ use_pcm_bus = 1;
+ }
}
if (hw_hdlc && ((src->chanpos == 16) || (dst->chanpos == 16))) {
@@ -785,70 +952,116 @@
if (debug)
printk("cwain: Not Unassigning D-channel %d/%d!\n", dst->span->offset, dst->chanpos);
} else {
- timeslot = dst->channo;
- cwain_unassign(cwaintmp, dst->chanpos, timeslot, 1);
- if (debug)
- printk("cwain: Unassigning channel %d/%d!\n", dst->span->offset, dst->chanpos);
+ timeslot = dst->channo;
+/* if (dacs == 2) {
+ timeslot = dst->channo;
+ } else {
+ timeslot = (dst->span->offset * 30) + (dst->chanpos - 1);
+ } */
+// printk(KERN_INFO "cwain: unassing chan %d ts_rx %d ts_tx %d ?\n", dst->chanpos - 1, cwaintmp->ts_rx[dst->chanpos - 1], cwaintmp->ts_tx[dst->chanpos - 1]);
+ if ((cwaintmp->ts_rx[dst->chanpos - 1] > -1) || (cwaintmp->ts_tx[dst->chanpos - 1] > -1)) {
+ cwain_unassign(cwaintmp, dst->chanpos, timeslot, 1);
+ if (debug)
+ printk("cwain: Unassigning channel %d/%d!\n", dst->span->offset, dst->chanpos);
+ }
}
}
return 0;
}
static inline void cwain_isr_run(struct zt_cwain *cwaintmp, int ticks) {
- int fifo=0;
+ int dchan;
+ int chan = 0;
+
if (cwaintmp->span.flags & ZT_FLAG_RUNNING) {
+
+ if (hdlcnet) {
+ dchan = 0;
+ } else {
+ dchan = 15;
+ }
+ cwaintmp->chans[dchan].bytes2transmit = 0;
+ cwaintmp->chans[dchan].eoftx = 0;
+ if (hw_hdlc) {
+ cwain_dfifo_check(cwaintmp);
+ }
+
/* oh zaptel! tell us what to transmit... */
zt_transmit(&cwaintmp->span);
- if (hw_hdlc) {
- /* B chans 1-15 mapped to fifos 0-14 */
- /* B chans 17-31 mapped to fifos 15-29 */
- for (fifo=0; fifo < 30; fifo++) {
- /* copy to fbuffer */
- if ((ticks < 1) || (ticks > 8)) {
- printk(KERN_INFO "cwain: whicked ticks make whicked tricks (%d)\n",cwaintmp->ticks);
- } else {
- memcpy(&cwaintmp->ftxbuf[fifo][(ticks-1)*8], cwaintmp->txbuf[fifo], ZT_CHUNKSIZE);
+ if (hdlcnet) {
+
+ if (cwaintmp->sync) {
+ cwain_dfifo_tx(cwaintmp);
}
- }
+
+ /* d-chan data */
+ while (cwaintmp->drx > 0) {
+ cwaintmp->chans[dchan].bytes2receive = 0;
+ cwaintmp->chans[dchan].eofrx = 0;
+ if (debug > 3)
+ printk(KERN_CRIT "drx = %d\n", cwaintmp->drx);
+ if (cwain_dfifo_rx(cwaintmp)) {
+ zt_receive(&(cwaintmp->span)); // XXX
+ }
+ }
+ cwaintmp->chans[dchan].bytes2receive = 0;
+ cwaintmp->chans[dchan].eofrx = 0;
+ } else {
+ if (hw_hdlc) {
+ /* B chans 1-15 mapped to fifos 0-14 */
+ /* B chans 17-31 mapped to fifos 15-29 */
+ for (chan=0; chan < 31; chan++) {
+ /* copy to fbuffer */
+ if ((ticks < 1) || (ticks > 8)) {
+ printk(KERN_INFO "cwain: whicked ticks make whicked tricks (%d)\n",cwaintmp->ticks);
+ } else {
+ if (chan != dchan) {
+ memcpy(&cwaintmp->ftxbuf[chan][(ticks-1)*8], cwaintmp->txbuf[chan], ZT_CHUNKSIZE);
+ }
+ }
+ }
- if (cwaintmp->sync) {
- cwain_dfifo_tx(cwaintmp);
- }
+ if (cwaintmp->sync) {
+ cwain_dfifo_tx(cwaintmp);
+ }
- cwaintmp->chans[15].bytes2receive = 0;
- cwaintmp->chans[15].bytes2transmit = 0;
- cwaintmp->chans[15].eofrx = 0;
- cwaintmp->chans[15].eoftx = 0;
+ cwaintmp->chans[dchan].bytes2receive = 0;
+ cwaintmp->chans[dchan].bytes2transmit = 0;
+ cwaintmp->chans[dchan].eofrx = 0;
+ cwaintmp->chans[dchan].eoftx = 0;
- for (fifo=0; fifo < 30; fifo++) {
- /* copy from fbuffer */
- memcpy(cwaintmp->rxbuf[fifo], &cwaintmp->frxbuf[fifo][(ticks-1)*8], ZT_CHUNKSIZE);
- zt_ec_chunk(&cwaintmp->span.chans[fifo], cwaintmp->span.chans[fifo].readchunk, cwaintmp->span.chans[fifo].writechunk);
- }
+ for (chan=0; chan < 31; chan++) {
+ /* copy from fbuffer */
+ if (chan != dchan) {
+ memcpy(cwaintmp->rxbuf[chan], &cwaintmp->frxbuf[chan][(ticks-1)*8], ZT_CHUNKSIZE);
+ zt_ec_chunk(&cwaintmp->span.chans[chan], cwaintmp->span.chans[chan].readchunk, cwaintmp->span.chans[chan].writechunk);
+ }
+ }
- /* d-chan data */
- if ((cwaintmp->drx > 0) && cwaintmp->sync){
- if (debug > 2)
- printk(KERN_CRIT "drx = %d\n", cwaintmp->drx);
- cwain_dfifo_rx(cwaintmp);
+ /* d-chan data */
+ if (cwaintmp->drx > 0) {
+ if (debug > 3)
+ printk(KERN_CRIT "drx = %d\n", cwaintmp->drx);
+ cwain_dfifo_rx(cwaintmp);
+ }
+ } else {
+ /* software HDLC */
+ for (chan=0; chan < 31; chan++) {
+ /* copy to fbuffer */
+ if ((ticks < 1) || (ticks > 8)) {
+ printk(KERN_INFO "cwain: whicked ticks make whicked tricks (%d)\n",cwaintmp->ticks);
+ } else {
+ memcpy(&cwaintmp->ftxbuf[chan][(ticks-1)*8], cwaintmp->txbuf[chan], ZT_CHUNKSIZE);
+ }
+ }
+
+ for (chan=0; chan < 31; chan++) {
+ /* copy from fbuffer */
+ memcpy(cwaintmp->rxbuf[chan], &cwaintmp->frxbuf[chan][(ticks-1)*8], ZT_CHUNKSIZE);
+ zt_ec_chunk(&cwaintmp->span.chans[chan], cwaintmp->span.chans[chan].readchunk, cwaintmp->span.chans[chan].writechunk);
+ }
}
- } else {
- /* software HDLC */
- for (fifo=0; fifo < 31; fifo++) {
- /* copy to fbuffer */
- if ((ticks < 1) || (ticks > 8)) {
- printk(KERN_INFO "cwain: whicked ticks make whicked tricks (%d)\n",cwaintmp->ticks);
- } else {
- memcpy(&cwaintmp->ftxbuf[fifo][(ticks-1)*8], cwaintmp->txbuf[fifo], ZT_CHUNKSIZE);
- }
- }
-
- for (fifo=0; fifo < 31; fifo++) {
- /* copy from fbuffer */
- memcpy(cwaintmp->rxbuf[fifo], &cwaintmp->frxbuf[fifo][(ticks-1)*8], ZT_CHUNKSIZE);
- zt_ec_chunk(&cwaintmp->span.chans[fifo], cwaintmp->span.chans[fifo].readchunk, cwaintmp->span.chans[fifo].writechunk);
- }
}
/* oh zaptel! thou shall receive! */
zt_receive(&(cwaintmp->span));
@@ -858,26 +1071,43 @@
static inline void cwain_isr_err(struct zt_cwain *cwaintmp) {
unsigned long flags = 0;
unsigned short crc, vio, ebit, fas;
+ unsigned short rx_slip, tx_slip;
spin_lock_irqsave(&cwaintmp->lock,flags);
crc = (cwain_inb(cwaintmp, cwain_R_CRC_ECH) << 8) | cwain_inb(cwaintmp, cwain_R_CRC_ECL);
vio = (cwain_inb(cwaintmp, cwain_R_VIO_ECH) << 8) | cwain_inb(cwaintmp, cwain_R_VIO_ECL);
ebit = (cwain_inb(cwaintmp, cwain_R_E_ECH) << 8) | cwain_inb(cwaintmp, cwain_R_E_ECL);
fas = (cwain_inb(cwaintmp, cwain_R_FAS_ECH) << 8) | cwain_inb(cwaintmp, cwain_R_FAS_ECL);
- spin_unlock_irqrestore(&cwaintmp->lock,flags);
-
+ rx_slip = cwain_inb(cwaintmp, cwain_R_SLIP) & 0x01;
+ tx_slip = (cwain_inb(cwaintmp, cwain_R_SLIP) >> 4) & 0x01;
+ if (cwaintmp->sync) {
+ if (rx_slip) {
+ cwain_outb(cwaintmp,cwain_R_RX_OFFS,0x06);
+ if (debug)
+ printk(KERN_INFO "cwain: cardID %d detected RX slip\n", cwaintmp->cardID);
+ }
+ if (tx_slip) {
+ cwain_outb(cwaintmp,cwain_R_TX_OFFS,0x06);
+ if (debug)
+ printk(KERN_INFO "cwain: cardID %d detected TX slip\n", cwaintmp->cardID);
+ }
+ }
+
cwaintmp->span.crc4count += crc;
cwaintmp->span.bpvcount += vio;
cwaintmp->span.ebitcount += ebit;
cwaintmp->span.fascount += fas;
- if (debug > 2)
- printk("cwain: CRC4 %d BPVIOL %d EBIT %d FAS %d\n", crc, vio, ebit, fas);
+ if ((debug > 3) && (crc || vio || ebit || fas))
+ printk(KERN_INFO "cwain: CRC4 %d BPVIOL %d EBIT %d FAS %d\n", cwaintmp->span.crc4count, cwaintmp->span.bpvcount, cwaintmp->span.ebitcount, cwaintmp->span.fascount);
+ spin_unlock_irqrestore(&cwaintmp->lock,flags);
}
static inline void cwain_audio_run(struct zt_cwain *cwaintmp) {
int fifo=0;
+ if (hdlcnet) return;
+
if (hw_hdlc) {
for (fifo=0; fifo < 30; fifo++) {
/* B tx */
@@ -907,7 +1137,7 @@
unsigned char sync_ok = 0;
unsigned char jatt_sta = 0;
unsigned long flags = 0;
- int chan = 0;
+// int chan = 0;
int res = 0; /* assume no l1event */
if (!cwainspan->span.flags & ZT_FLAG_RUNNING) {
@@ -927,11 +1157,11 @@
/* reset MFA detection */
cwain_outb(cwainspan ,cwain_R_RX_SL0_CFG1,0x41);
} else if ((sync_sta & 0x27) == 0x27) {
- if ((cwainspan->sync_sta & 0x27) != 0x27) {
+ if (((cwainspan->sync_sta & 0x27) != 0x27) && cwainspan->span.syncsrc) {
/* sync achieved, restart JATT */
- if (debug)
- printk(KERN_INFO "cwain: %d starting jitter attenuator\n", cwainspan->cardID);
- cwain_outb(cwainspan, cwain_R_JATT_CFG,0x9c);
+/* if (debug)
+ printk(KERN_INFO "cwain: %d starting jitter attenuator\n", cwainspan->cardID); */
+// cwain_outb(cwainspan, cwain_R_JATT_CFG,0x9c);
}
sync_ok = 0x27;
} else {
@@ -939,11 +1169,11 @@
}
} else {
if ((sync_sta & 0x07) == 0x07) {
- if ((cwainspan->sync_sta & 0x7) != 0x7) {
+ if (((cwainspan->sync_sta & 0x7) != 0x7) && cwainspan->span.syncsrc) {
/* sync achieved, restart JATT */
- if (debug)
- printk(KERN_INFO "cwain: %d starting jitter attenuator\n", cwainspan->cardID);
- cwain_outb(cwainspan, cwain_R_JATT_CFG,0x9c);
+ /* if (debug)
+ printk(KERN_INFO "cwain: %d starting jitter attenuator\n", cwainspan->cardID); */
+// cwain_outb(cwainspan, cwain_R_JATT_CFG,0x9c);
}
sync_ok = 0x07;
} else {
@@ -953,52 +1183,25 @@
cwainspan->sync_sta = sync_sta;
- jatt_sta = cwain_inb(cwainspan, cwain_R_JATT_STA);
- if ((jatt_sta & 0x60) != 0x60) {
- if (debug > 2)
- printk(KERN_INFO "cwain: %d jitter attenuator %#x\n", cwainspan->cardID, (jatt_sta & 0x60) >> 5);
- sync_ok = 0x00;
- } else if (!cwainspan->sync && sync_ok) {
- if (debug)
- printk(KERN_CRIT "cwain: %d jitter attenuator %#x ok!\n", cwainspan->cardID, (jatt_sta & 0x60) >> 5);
+ if (cwainspan->span.syncsrc) {
+ jatt_sta = cwain_inb(cwainspan, cwain_R_JATT_STA);
+ if ((jatt_sta & 0x60) != 0x60) {
+ if (debug > 2)
+ printk(KERN_INFO "cwain: %d jitter attenuator %#x\n", cwainspan->cardID, (jatt_sta & 0x60) >> 5);
+ sync_ok = 0x00;
+ } else if (!cwainspan->sync && sync_ok) {
+ if (debug)
+ printk(KERN_CRIT "cwain: %d jitter attenuator %#x ok!\n", cwainspan->cardID, (jatt_sta & 0x60) >> 5);
+ }
}
if (sync_ok && (!cwainspan->sync)) {
- /* elastic buffer offsets */
+ if (debug)
+ printk(KERN_INFO "cwain: cardID %d link up\n", cwainspan->cardID);
+
cwain_outb(cwainspan,cwain_R_RX_OFFS,0x06);
cwain_outb(cwainspan,cwain_R_TX_OFFS,0x06);
- if (hw_hdlc) {
- if (debug > 2)
- printk(KERN_INFO "cwain: enabling D channel fifos\n");
- cwain_outb(cwainspan,cwain_R_FIFO,0x1F << 1);
- cwain_waitbusy(cwainspan);
- cwain_outb(cwainspan,cwain_R_INC_RES_FIFO,0x2);
- cwain_waitbusy(cwainspan);
- cwain_outb(cwainspan,cwain_A_CON_HDLC,0xd);
- cwain_outb(cwainspan,cwain_A_IRQ_MSK,0x1);
-
- cwain_outb(cwainspan,cwain_R_FIFO,(0x1F << 1) | 1);
- cwain_waitbusy(cwainspan);
- cwain_outb(cwainspan,cwain_R_INC_RES_FIFO,0x2);
- cwain_waitbusy(cwainspan);
- cwain_outb(cwainspan,cwain_A_CON_HDLC,0xd);
- cwain_outb(cwainspan,cwain_A_IRQ_MSK,0x1);
- }
-
- if (hw_hdlc) {
- for (chan=1;chan<=15;chan++) {
- cwain_unassign(cwainspan, chan, chan, 0);
- }
- for (chan=17;chan<=31;chan++) {
- cwain_unassign(cwainspan, chan, chan, 0);
- }
- } else {
- for (chan=1;chan<=31;chan++) {
- cwain_unassign(cwainspan, chan, chan, 0);
- }
- }
-
cwainspan->span.crc4count = 0;
cwainspan->span.bpvcount = 0;
cwainspan->span.ebitcount = 0;
@@ -1008,19 +1211,13 @@
res = 1;
}
if (!sync_ok && cwainspan->sync) {
- if (hw_hdlc) {
- if (debug > 2)
- printk(KERN_INFO "cwain: disabling D channel fifos\n");
- cwain_outb(cwainspan,cwain_R_FIFO,0x1F << 1);
- cwain_waitbusy(cwainspan);
- cwain_outb(cwainspan,cwain_A_CON_HDLC,0x1);
- cwain_outb(cwainspan,cwain_A_IRQ_MSK,0x0);
- cwain_outb(cwainspan,cwain_R_FIFO,(0x1F << 1) | 1);
- cwain_waitbusy(cwainspan);
- cwain_outb(cwainspan,cwain_A_CON_HDLC,0x1);
- cwain_outb(cwainspan,cwain_A_IRQ_MSK,0x0);
- }
+ if (debug)
+ printk(KERN_INFO "cwain: cardID %d link down\n", cwainspan->cardID);
+ cwainspan->span.crc4count = 0;
+ cwainspan->span.bpvcount = 0;
+ cwainspan->span.ebitcount = 0;
+ cwainspan->span.fascount = 0;
cwainspan->span.alarms = ZT_ALARM_RED;
zt_alarm_notify(&cwainspan->span);
res = 1;
@@ -1084,10 +1281,13 @@
if (irq_foview & 0x80) {
fi = cwain_inb(cwainspan,cwain_R_IRQ_FIFO_BL7);
if (fi & 0x80) {
- if (debug > 2)
+ if (debug > 4)
printk(KERN_CRIT "cwain: fifo 31 RX irq for D channel cardID %d\n", cwainspan->cardID);
- cwainspan->drx += 1;
}
+ if (fi & 0x40) {
+ if (debug > 4)
+ printk(KERN_CRIT "cwain: fifo 31 TX irq for D channel cardID %d\n", cwainspan->cardID);
+ }
}
return 1;
}
@@ -1174,7 +1374,7 @@
for (i=0;i<cwaintmp->spans;i++) {
cwain_isr_run(cwaintmp->span[i], cwaintmp->ticks);
}
- if (cwaintmp->ticks == (cwain_FRAME_SIZE / 8)) {
+ if (cwaintmp->ticks == (cwain_FRAME_SIZE / ZT_CHUNKSIZE)) {
cwaintmp->ticks = 0;
}
}
@@ -1185,6 +1385,9 @@
l1event++;
}
if (irq_misc & 0x10) {
+ for (i=0;i<cwaintmp->spans;i++) {
+ cwain_isr_err(cwaintmp->span[i]);
+ }
if (l1event == 0) {
/* just in case we missed it */
for (i=0;i<cwaintmp->spans;i++) {
@@ -1262,6 +1465,7 @@
unsigned long flags;
int alreadyrunning;
int i=0;
+ int idx = 0;
// printk(KERN_INFO "cwain: startup spanno %d offset %d\n", span->spanno, span->offset);
@@ -1281,39 +1485,54 @@
// printk(KERN_CRIT "already running %d flags %d\n", alreadyrunning, span->flags);
if (!alreadyrunning) {
- if (hw_hdlc) {
- span->chans[15].flags &= ~ZT_FLAG_HDLC;
- span->chans[15].flags |= ZT_FLAG_BRIDCHAN; /* yes! */
+ for (i=0; i<31 ; i++) {
+ cwaintmp->ts_rx[i] = -1;
+ cwaintmp->ts_tx[i] = -1;
+ }
+
+ if (hdlcnet) {
+ span->chans[0].flags &= ~ZT_FLAG_HDLC;
+ span->chans[0].flags |= ZT_FLAG_BRIDCHAN; /* yes! */
+
+ memset(cwaintmp->dtxbuf,0x0,sizeof(cwaintmp->dtxbuf));
+ span->chans[0].writechunk = cwaintmp->dtxbuf;
+
+ cwaintmp->chans[0].maxbytes2transmit = 248;
+// cwaintmp->chans[0].maxbytes2transmit = 64;
+
+ memset(cwaintmp->drxbuf,0x0,sizeof(cwaintmp->drxbuf));
+ span->chans[0].readchunk = cwaintmp->drxbuf;
+ } else {
+ if (hw_hdlc) {
+ span->chans[15].flags &= ~ZT_FLAG_HDLC;
+ span->chans[15].flags |= ZT_FLAG_BRIDCHAN; /* yes! */
- /* setup B channel buffers (8 bytes each) */
- for (i=0; i<15 ; i++) {
- memset(cwaintmp->rxbuf[i],0x0,sizeof(cwaintmp->rxbuf[i]));
- memset(cwaintmp->txbuf[i],0x0,sizeof(cwaintmp->txbuf[i]));
- span->chans[i].readchunk = cwaintmp->rxbuf[i];
- span->chans[i].writechunk = cwaintmp->txbuf[i];
+ /* setup B channel buffers (8 bytes each) */
+ for (i=0; i<31 ; i++) {
+ if (i != 15) {
+ memset(cwaintmp->rxbuf[i],0x0,sizeof(cwaintmp->rxbuf[i]));
+ memset(cwaintmp->txbuf[i],0x0,sizeof(cwaintmp->txbuf[i]));
+ span->chans[i].readchunk = cwaintmp->rxbuf[i];
+ span->chans[i].writechunk = cwaintmp->txbuf[i];
+ }
+ }
+ /* setup D channel buffer */
+ memset(cwaintmp->dtxbuf,0x0,sizeof(cwaintmp->dtxbuf));
+ span->chans[15].writechunk = cwaintmp->dtxbuf;
+ cwaintmp->chans[15].maxbytes2transmit = sizeof(cwaintmp->dtxbuf) / 2;
+
+ memset(cwaintmp->drxbuf,0x0,sizeof(cwaintmp->drxbuf));
+ span->chans[15].readchunk = cwaintmp->drxbuf;
+ } else {
+ /* software HDLC */
+ /* setup B channel buffers (8 bytes each) */
+ for (i=0; i<31 ; i++) {
+ memset(cwaintmp->rxbuf[i],0x0,sizeof(cwaintmp->rxbuf[i]));
+ memset(cwaintmp->txbuf[i],0x0,sizeof(cwaintmp->txbuf[i]));
+ span->chans[i].readchunk = cwaintmp->rxbuf[i];
+ span->chans[i].writechunk = cwaintmp->txbuf[i];
+ }
}
- for (i=16; i<31 ; i++) {
- memset(cwaintmp->rxbuf[i-1],0x0,sizeof(cwaintmp->rxbuf[i-1]));
- memset(cwaintmp->txbuf[i-1],0x0,sizeof(cwaintmp->txbuf[i-1]));
- span->chans[i].readchunk = cwaintmp->rxbuf[i-1];
- span->chans[i].writechunk = cwaintmp->txbuf[i-1];
- }
- /* setup D channel buffer */
- memset(cwaintmp->dtxbuf,0x0,sizeof(cwaintmp->dtxbuf));
- span->chans[15].writechunk = cwaintmp->dtxbuf;
- cwaintmp->chans[15].maxbytes2transmit = sizeof(cwaintmp->dtxbuf);
-
- memset(cwaintmp->drxbuf,0x0,sizeof(cwaintmp->drxbuf));
- span->chans[15].readchunk = cwaintmp->drxbuf;
- } else {
- /* software HDLC */
- /* setup B channel buffers (8 bytes each) */
- for (i=0; i<31 ; i++) {
- memset(cwaintmp->rxbuf[i],0x0,sizeof(cwaintmp->rxbuf[i]));
- memset(cwaintmp->txbuf[i],0x0,sizeof(cwaintmp->txbuf[i]));
- span->chans[i].readchunk = cwaintmp->rxbuf[i];
- span->chans[i].writechunk = cwaintmp->txbuf[i];
- }
}
span->flags |= ZT_FLAG_RUNNING;
} else {
@@ -1322,97 +1541,149 @@
}
spin_lock_irqsave(&cwaintmp->lock,flags);
- // irqs off
+ /* irqs off */
cwain_outb(cwaintmp,cwain_R_IRQ_CTRL, 0);
- if (hw_hdlc) {
+ if (hdlcnet) {
+ /* map ts 1 to 31 to fifo 31 */
+ /* TX fifo */
+// cwain_outb(cwaintmp,cwain_R_FIFO_MD,0x3E);
+ cwain_outb(cwaintmp,cwain_R_FIRST_FIFO,0x1F << 1);
+ cwain_waitbusy(cwaintmp);
+
+ idx = 0;
+ for (i=1; i<=31; i++) {
+ cwain_outb(cwaintmp,cwain_R_FSM_IDX, idx++);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,i << 1);
+ if (i == 31) {
+ cwain_outb(cwaintmp,cwain_A_FIFO_SEQ, (0x1F << 1) | 1);
+// if (debug) printk(KERN_INFO "cwain: cardID %d fsm_idx %d channel %d fifo_seq %#x\n", cwaintmp->cardID, idx - 1, i , (0x1f << 1) | 1);
+ } else {
+ cwain_outb(cwaintmp,cwain_A_FIFO_SEQ, 0x1F << 1);
+// if (debug) printk(KERN_INFO "cwain: cardID %d fsm_idx %d channel %d fifo_seq %#x\n", cwaintmp->cardID, idx - 1, i ,0x1f << 1);
+ }
+ }
- /* setup D-FIFO TX */
+ /* map ts 1 to 31 to fifo 31 */
+ /* RX fifo */
+
+ for (i=1; i<=31; i++) {
+ cwain_outb(cwaintmp,cwain_R_FSM_IDX, idx++);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,(i << 1) | 1);
+ if (i == 31) {
+ cwain_outb(cwaintmp,cwain_A_FIFO_SEQ, 0x40);
+// if (debug) printk(KERN_INFO "cwain: cardID %d fsm_idx %d channel %d fifo_seq %#x\n", cwaintmp->cardID, idx - 1, i, 0x40);
+ } else {
+ cwain_outb(cwaintmp,cwain_A_FIFO_SEQ, (0x1F << 1) | 1);
+// if (debug) printk(KERN_INFO "cwain: cardID %d fsm_idx %d channel %d fifo_seq %#x\n", cwaintmp->cardID, idx - 1, i, (0x1f << 1) | 1);
+ }
+ }
+
+// cwain_outb(cwaintmp,cwain_R_FIFO_MD,0x36);
+
cwain_outb(cwaintmp,cwain_R_FIFO,0x1F << 1);
cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x1);
- cwain_outb(cwaintmp,cwain_A_SUBCH_CFG,0x0);
- cwain_outb(cwaintmp,cwain_A_CHANNEL,0x10 << 1);
- cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0xc);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK, 0x1);
- /* setup D-FIFO RX */
cwain_outb(cwaintmp,cwain_R_FIFO,(0x1F << 1) | 1);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x1);
- cwain_outb(cwaintmp,cwain_A_SUBCH_CFG,0x0);
- cwain_outb(cwaintmp,cwain_A_CHANNEL,(0x10 << 1) | 1);
- cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0xc);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK, 0x1);
- /* setup B-FIFOs TX */
- /* map ts 1 to 15 to fifos 0 to 14 */
- for (i=1; i<16 ; i++) {
- cwain_outb(cwaintmp,cwain_R_FIFO,(i - 1) << 1);
+// cwain_outb(cwaintmp,cwain_R_FIFO_MD,0x3E);
+
+ } else {
+ if (hw_hdlc) {
+ /* setup D-FIFO TX */
+ cwain_outb(cwaintmp,cwain_R_FIFO,0x1F << 1);
cwain_waitbusy(cwaintmp);
cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
- cwain_outb(cwaintmp,cwain_A_CHANNEL,i << 1);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0xd);
+ cwain_outb(cwaintmp,cwain_A_SUBCH_CFG,0x0);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,0x10 << 1);
cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x1);
- }
- /* map ts 17 to 31 to fifos 15 to 29 */
- for (i=17; i<32 ; i++) {
- cwain_outb(cwaintmp,cwain_R_FIFO,(i - 2) << 1);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
- cwain_outb(cwaintmp,cwain_A_CHANNEL,i << 1);
- cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x1);
- }
- /* setup B-FIFOs RX */
- /* map ts 1 to 15 to fifos 0 to 14 */
- for (i=1; i<16 ; i++) {
- cwain_outb(cwaintmp,cwain_R_FIFO,((i-1) << 1) | 1);
+ /* setup D-FIFO RX */
+ cwain_outb(cwaintmp,cwain_R_FIFO,(0x1F << 1) | 1);
cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
+ cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
- cwain_outb(cwaintmp,cwain_A_CHANNEL,(i << 1) | 1);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0xd);
+ cwain_outb(cwaintmp,cwain_A_SUBCH_CFG,0x0);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,(0x10 << 1) | 1);
cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x1);
+
+ /* setup B-FIFOs TX */
+ /* map ts 1 to 15 to fifos 0 to 14 */
+ for (i=1; i<16 ; i++) {
+ cwain_outb(cwaintmp,cwain_R_FIFO,(i - 1) << 1);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,i << 1);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ }
+ /* map ts 17 to 31 to fifos 15 to 29 */
+ for (i=17; i<32 ; i++) {
+ cwain_outb(cwaintmp,cwain_R_FIFO,(i - 2) << 1);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,i << 1);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ }
+
+ /* setup B-FIFOs RX */
+ /* map ts 1 to 15 to fifos 0 to 14 */
+ for (i=1; i<16 ; i++) {
+ cwain_outb(cwaintmp,cwain_R_FIFO,((i-1) << 1) | 1);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,(i << 1) | 1);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ }
+ /* map ts 17 to 31 to fifos 15 to 29 */
+ for (i=17; i<32 ; i++) {
+ cwain_outb(cwaintmp,cwain_R_FIFO,((i-2) << 1) | 1);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,(i << 1) | 1);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ }
+ } else {
+ /* software HDLC */
+ /* setup B-FIFOs TX */
+ for (i=1; i<32 ; i++) {
+ cwain_outb(cwaintmp,cwain_R_FIFO,(i - 1) << 1);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,i << 1);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ }
+ /* setup B-FIFOs RX */
+ for (i=1; i<32 ; i++) {
+ cwain_outb(cwaintmp,cwain_R_FIFO,((i-1) << 1) | 1);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
+ cwain_outb(cwaintmp,cwain_A_CHANNEL,(i << 1) | 1);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ }
+
}
- /* map ts 17 to 31 to fifos 15 to 29 */
- for (i=17; i<32 ; i++) {
- cwain_outb(cwaintmp,cwain_R_FIFO,((i-2) << 1) | 1);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
- cwain_outb(cwaintmp,cwain_A_CHANNEL,(i << 1) | 1);
- cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x1);
- }
- } else {
- /* software HDLC */
- /* setup B-FIFOs TX */
- for (i=1; i<32 ; i++) {
- cwain_outb(cwaintmp,cwain_R_FIFO,(i - 1) << 1);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
- cwain_outb(cwaintmp,cwain_A_CHANNEL,i << 1);
- cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x1);
- }
- /* setup B-FIFOs RX */
- for (i=1; i<32 ; i++) {
- cwain_outb(cwaintmp,cwain_R_FIFO,((i-1) << 1) | 1);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_R_INC_RES_FIFO,0x2);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_CON_HDLC,0x2);
- cwain_outb(cwaintmp,cwain_A_CHANNEL,(i << 1) | 1);
- cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x1);
- }
-
}
if (debug)
@@ -1428,10 +1699,10 @@
cwain_outb(cwaintmp,cwain_R_PWM1,pwm1);
/* setup E1 transceiver */
- cwain_outb(cwaintmp,cwain_R_TX_SL0,0xf8); // R_TX_FR1
+ cwain_outb(cwaintmp,cwain_R_TX_SL0,0xf8);
cwain_outb(cwaintmp,cwain_R_TX_SL0_CFG0,0x00); /* semiautomatic mode */
- cwain_outb(cwaintmp,cwain_R_RX_SL0_CFG0,0x6); /* 0x26 */
+ cwain_outb(cwaintmp,cwain_R_RX_SL0_CFG0,0x6);
if (cwaintmp->span.lineconfig & ZT_CONFIG_AMI) {
cwain_outb(cwaintmp,cwain_R_TX0,0x82);
@@ -1440,38 +1711,41 @@
cwain_outb(cwaintmp,cwain_R_TX0,0x81);
cwain_outb(cwaintmp,cwain_R_RX0,0x01);
}
+ cwain_outb(cwaintmp,cwain_R_TX1,0x60); /* transmitter mode */
- /* transmitter mode */
- cwain_outb(cwaintmp,cwain_R_TX1,0x60);
+ cwain_outb(cwaintmp,cwain_R_LOS0,0x0f);
+ cwain_outb(cwaintmp,cwain_R_LOS1,0x0f);
- cwain_outb(cwaintmp,cwain_R_LOS0,0x10);
- cwain_outb(cwaintmp,cwain_R_LOS1,0x10);
-
if (cwaintmp->span.lineconfig & ZT_CONFIG_CRC4) {
/* crc4 multiframe */
cwain_outb(cwaintmp,cwain_R_TX_SL0_CFG1,0x31);
-// cwain_outb(cwaintmp,cwain_R_RX_SL0_CFG1,0x41);
cwain_outb(cwaintmp,cwain_R_RX_SL0_CFG1,0x03);
} else {
/* doubleframe */
cwain_outb(cwaintmp,cwain_R_TX_SL0_CFG1,0x0);
-// cwain_outb(cwaintmp,cwain_R_RX_SL0_CFG1,0x40);
- cwain_outb(cwaintmp,cwain_R_RX_SL0_CFG1,0x02);
+ cwain_outb(cwaintmp,cwain_R_RX_SL0_CFG1,0x0);
}
+
+ /* automatic JATT */
+ cwain_outb(cwaintmp, cwain_R_JATT_CFG,0x9c);
/* setup sync mode */
if (cwaincard->syncs[span->offset] > 0) {
- cwain_outb(cwaintmp,cwain_R_SYNC_CTRL,0x2);
- cwain_outb(cwaintmp,cwain_R_SYNC_OUT,0xe0);
+ cwain_outb(cwaintmp,cwain_R_SYNC_CTRL,0x2); // phase offset arb.
+ cwain_outb(cwaintmp,cwain_R_SYNC_OUT,0x00); // sync from e1 tx
/* layer 1, here we go! */
cwain_outb(cwaintmp,cwain_R_E1_WR_STA,0x00);
} else {
- cwain_outb(cwaintmp,cwain_R_SYNC_CTRL,0x5);
- cwain_outb(cwaintmp,cwain_R_SYNC_OUT,0xe0);
+ cwain_outb(cwaintmp,cwain_R_SYNC_CTRL,0x5); // pcm_f0IO
+ cwain_outb(cwaintmp,cwain_R_SYNC_OUT,0x00); // sync from e1 tx
/* layer 1, up! */
cwain_outb(cwaintmp,cwain_R_E1_WR_STA,0x11);
}
+
+ /* elastic buffer offsets */
+ cwain_outb(cwaintmp,cwain_R_RX_OFFS,0x06);
+ cwain_outb(cwaintmp,cwain_R_TX_OFFS,0x06);
cwaintmp->sync = 0;
cwaintmp->sync_sta = 0;
@@ -1514,27 +1788,37 @@
// printk(KERN_CRIT "cwain: stopping card %d span %d/%d.\n",cwaintmp->cardno,span->spanno,span->offset);
// turn off irqs for all fifos
+ if (hdlcnet) {
+ cwain_outb(cwaintmp,cwain_R_FIFO,(0x1F << 1) | 1);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ } else {
+ /* disable FIFO TX */
+ for (i=0; i<0x20 ; i++) {
+ cwain_outb(cwaintmp,cwain_R_FIFO,i << 1);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ }
- /* disable FIFO TX */
- for (i=0; i<0x20 ; i++) {
- cwain_outb(cwaintmp,cwain_R_FIFO,i << 1);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ /* disable FIFO RX */
+ for (i=0; i<0x20 ; i++) {
+ cwain_outb(cwaintmp,cwain_R_FIFO,(i << 1) | 1);
+ cwain_waitbusy(cwaintmp);
+ cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
+ }
}
- /* disable FIFO RX */
- for (i=0; i<0x20 ; i++) {
- cwain_outb(cwaintmp,cwain_R_FIFO,(i << 1) | 1);
- cwain_waitbusy(cwaintmp);
- cwain_outb(cwaintmp,cwain_A_IRQ_MSK,0x0);
- }
-
-
/* Deactivate Layer 1 */
cwain_outb(cwaintmp,cwain_R_E1_WR_STA,0x10);
+ /* Disable transmit */
+ if (cwaintmp->span.lineconfig & ZT_CONFIG_AMI) {
+ cwain_outb(cwaintmp,cwain_R_TX0,0x02);
+ } else if (cwaintmp->span.lineconfig & ZT_CONFIG_HDB3) {
+ cwain_outb(cwaintmp,cwain_R_TX0,0x01);
+ }
+
cwain_outb(cwaintmp,cwain_R_IRQ_CTRL, 0);
-// cwain_outb(cwaintmp,cwain_R_IRQMSK_MISC, 0);
cwain_inb(cwaintmp,cwain_R_STATUS);
@@ -1596,7 +1880,11 @@
cwaintmp->span.dacs = ztcwain_dacs;
cwaintmp->span.chans = cwaintmp->chans;
- cwaintmp->span.channels = 31;
+ if (hdlcnet) {
+ cwaintmp->span.channels = 1;
+ } else {
+ cwaintmp->span.channels = 31;
+ }
cwaintmp->span.deflaw = ZT_LAW_ALAW;
cwaintmp->span.linecompat = ZT_CONFIG_AMI | ZT_CONFIG_HDB3 | ZT_CONFIG_CCS;
init_waitqueue_head(&cwaintmp->span.maintq);
@@ -1651,8 +1939,14 @@
/* no master yet, force reelection */
cwaintmp->syncsrc = -1;
+#if (ZT_CHUNKSIZE == 32)
+ /* set up the timer 250 Hz, zaptel timing */
+ cwain_outb(cwaintmp->span[0],cwain_R_TI_WD, 0x4);
+#endif
+#if (ZT_CHUNKSIZE == 8)
/* set up the timer 1 khz, zaptel timing */
cwain_outb(cwaintmp->span[0],cwain_R_TI_WD, 0x2);
+#endif
if (cwaintmp->spans == 2) {
// cwain_outb(cwaintmp->span[1],cwain_R_IRQMSK_MISC, 0x1);
@@ -1841,6 +2135,10 @@
int init_module(void) {
+ if (hdlcnet) {
+ hw_hdlc = 1; /* otherwise it makes no sense at all... */
+ dacs = 0;
+ }
multi_cwain = NULL;
cwain_find_spans(PCI_DEVICE_ID_CCD_E);
cwain_sort_cards();
@@ -1848,7 +2146,7 @@
if (cwain_card_count == 0) {
printk(KERN_INFO "cwain: no cwain cards found.\n");
} else {
- printk(KERN_INFO "cwain: %d cwain card(s) in this box, %d E1 ports total, hw_hdcl = %d.\n", cwain_card_count, cwain_span_count, hw_hdlc);
+ printk(KERN_INFO "cwain: %d cwain card(s) in this box, %d E1 ports total, hw_hdcl = %d, dacs =%d, require_ext_clock = %d, ZT_CHUNKSIZE = %d, timer = %d.\n", cwain_card_count, cwain_span_count, hw_hdlc, dacs, require_ext_clock, ZT_CHUNKSIZE, cwain_TIMER_INT);
}
return 0;
}
@@ -1887,16 +2185,20 @@
module_param(ports, int, 0600);
module_param(debug, int, 0600);
module_param(hw_hdlc, int, 0600);
+module_param(hdlcnet, int, 0600);
module_param(pwm0, int, 0600);
module_param(pwm1, int, 0600);
module_param(dacs, int, 0600);
+module_param(require_ext_clock, int, 0600);
#else
MODULE_PARM(ports,"i");
MODULE_PARM(debug,"i");
MODULE_PARM(hw_hdlc,"i");
+MODULE_PARM(hdlcnet,"i");
MODULE_PARM(pwm0,"i");
MODULE_PARM(pwm1,"i");
MODULE_PARM(dacs,"i");
+MODULE_PARM(require_ext_clock,"i");
#endif
MODULE_DESCRIPTION("cwain zaptel driver");
Modified: zaptel/trunk/cwain/cwain.h
===================================================================
--- zaptel/trunk/cwain/cwain.h 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/cwain/cwain.h 2007-03-24 06:28:03 UTC (rev 3298)
@@ -1,8 +1,11 @@
#define cwain_FIFO_SIZE 128
#define cwain_DFIFO_SIZE 4096
+#define cwain_DFIFO_FRAMES 0x10
#define cwain_FRAME_SIZE 64 /* has to be %4==0 */
#define cwain_FIFO_HW cwain_FRAME_SIZE * 2 + ZT_CHUNKSIZE
+#define cwain_TIMER_INT (8000 / ZT_CHUNKSIZE)
+
typedef struct zt_cwain {
/* pci resources */
unsigned int irq;
@@ -35,6 +38,9 @@
unsigned char rxbuf[31][ZT_CHUNKSIZE];
unsigned char txbuf[31][ZT_CHUNKSIZE];
+ signed short ts_rx[31];
+ signed short ts_tx[31];
+
/* buffers */
unsigned char frxbuf[31][cwain_FRAME_SIZE];
unsigned char ftxbuf[31][cwain_FRAME_SIZE];
Modified: zaptel/trunk/debian/changelog
===================================================================
--- zaptel/trunk/debian/changelog 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/debian/changelog 2007-03-24 06:28:03 UTC (rev 3298)
@@ -6,6 +6,7 @@
[ Tzafrir Cohen ]
* Should fix modules building: restore generated files that were
removed by a clean (Closes: #415280).
+ * bristuff 0.3.0-PRE-1y-b.
-- Tzafrir Cohen <tzafrir.cohen at xorcom.com> Sat, 24 Mar 2007 07:52:44 +0200
Modified: zaptel/trunk/debian/patches/bristuff.dpatch
===================================================================
--- zaptel/trunk/debian/patches/bristuff.dpatch 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/debian/patches/bristuff.dpatch 2007-03-24 06:28:03 UTC (rev 3298)
@@ -2,13 +2,15 @@
## bristuff.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
##
## All lines beginning with `## DP:' are a description of the patch.
-## DP: This is the patch zaptel.patch from bristuff, with the Makefile
-## DP: patch removed. Version: bristuff-0.3.0-PRE-1x
+## DP: This is the patch zaptel.patch from bristuff. Changes:
+## DP: * Makefile removed.
+## DP: * zaptel.c renamed zaptel-base.c
+## DP: Version: bristuff-0.3.0-PRE-1y-b
@DPATCH@
diff -urN zaptel-1.2.10.orig/zaptel.c zaptel-1.2.10/zaptel.c
--- zaptel-1.2.10.orig/zaptel-base.c 2006-09-16 09:45:04.000000000 +0200
-+++ zaptel-1.2.10/zaptel-base.c 2006-12-20 17:59:51.000000000 +0100
++++ zaptel-1.2.10/zaptel-base.c 2007-02-09 12:55:06.610589726 +0100
@@ -139,6 +139,7 @@
EXPORT_SYMBOL(zt_qevent_lock);
EXPORT_SYMBOL(zt_hooksig);
@@ -83,7 +85,7 @@
+ } else {
+ memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
+ ms->writeidx[ms->outwritebuf] += left + 2;
-+ txb += left;
++ txb += left + 2;
+ ms->bytes2transmit = left;
+ ms->eoftx = 1;
+ }
@@ -118,18 +120,20 @@
#ifdef CONFIG_ZAPATA_NET
if (ms->flags & ZT_FLAG_NETDEV)
netif_wake_queue(ztchan_to_dev(ms));
-@@ -5033,6 +5102,10 @@
+@@ -5033,6 +5102,12 @@
memset(txb, 0xFF, bytes);
}
bytes = 0;
+#if defined(CONFIG_ZAPATA_BRI_DCHANS)
+ } else if(ms->flags & ZT_FLAG_BRIDCHAN) {
++ ms->bytes2transmit = 0;
++ ms->eoftx = 0;
+ bytes = 0;
+#endif
} else {
memset(txb, ZT_LIN2X(0, ms), bytes); /* Lastly we use silence on telephony channels */
bytes = 0;
-@@ -5758,6 +5831,13 @@
+@@ -5758,6 +5833,13 @@
int left, x;
int bytes = ZT_CHUNKSIZE;
@@ -143,7 +147,7 @@
while(bytes) {
#if defined(CONFIG_ZAPATA_NET) || defined(CONFIG_ZAPATA_PPP)
-@@ -5816,6 +5896,19 @@
+@@ -5816,6 +5898,19 @@
}
}
}
Modified: zaptel/trunk/qozap/Makefile
===================================================================
--- zaptel/trunk/qozap/Makefile 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/qozap/Makefile 2007-03-24 06:28:03 UTC (rev 3298)
@@ -3,7 +3,9 @@
ZAP = $(shell [ -f $(BRISTUFFBASE)/zaptel/zaptel.h ] && echo "-I$(BRISTUFFBASE)/zaptel")
-CFLAGS+=-I. $(ZAP) -DRELAXED_LOCKING -O2 -g -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER
+HOSTCC=gcc
+
+CFLAGS+=-I. $(ZAP) -DRELAXED_LOCKING -O4 -g -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER
CFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
KFLAGS=-D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -DRELAXED_LOCKING -fomit-frame-pointer -O2 -Wall -I$(KINCLUDES) $(ZAP)
Modified: zaptel/trunk/qozap/qozap.c
===================================================================
--- zaptel/trunk/qozap/qozap.c 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/qozap/qozap.c 2007-03-24 06:28:03 UTC (rev 3298)
@@ -2,7 +2,7 @@
* qozap.c - Zaptel driver for the quadBRI PCI ISDN card
* and the octoBRI PCI ISDN card!
*
- * Copyright (C) 2003, 2004, 2005, 2006 Junghanns.NET GmbH
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007 Junghanns.NET GmbH
*
* Klaus-Peter Junghanns <kpj at junghanns.net>
*
@@ -107,18 +107,14 @@
void qoz_doLEDs(struct qoz_card *qoztmp) {
unsigned char leds = 0x0;
+ unsigned long ledw;
unsigned long flags;
spin_lock_irqsave(&qoztmp->lock,flags);
if ((qoztmp->type == 0xb520) && (qoztmp->stports == 4)){
-// if ((qoztmp->ticks > 0) && (qoztmp->ticks <= 300)) {
qoz_outb(qoztmp,qoz_R_GPIO_SEL,0x20 | 0x10);
qoz_outb(qoztmp,qoz_R_GPIO_EN1,0xf);
qoz_outb(qoztmp,qoz_R_GPIO_OUT1,(qoztmp->leds[0] | (qoztmp->leds[1] << 1) | (qoztmp->leds[2] << 2) | (qoztmp->leds[3] << 3)));
-/* }
- if ((qoztmp->ticks > 300) && (qoztmp->ticks <= 600)) {
- qoz_outb(qoztmp,qoz_R_GPIO_EN1,0x0);
- } */
} else if ((qoztmp->type == 0xb550) && (qoztmp->stports == 4)){
qoz_outb(qoztmp,qoz_R_GPIO_SEL,0x80 | 0x40 | 0x20 | 0x10);
qoz_outb(qoztmp,qoz_R_GPIO_EN1,0xff);
@@ -128,14 +124,14 @@
leds |= 0x40;
}
if (qoztmp->leds[1] == 0) {
+ leds |= 0x20;
+ } else {
leds |= 0x10;
- } else {
- leds |= 0x20;
}
if (qoztmp->leds[2] == 0) {
+ leds |= 0x08;
+ } else {
leds |= 0x04;
- } else {
- leds |= 0x08;
}
if (qoztmp->leds[3] == 0) {
leds |= 0x02;
@@ -152,6 +148,50 @@
0x01 st4r
*/
qoz_outb(qoztmp,qoz_R_GPIO_OUT1, leds);
+ } else if (qoztmp->type == 0xb556) {
+ /* TBD */
+ } else if (qoztmp->type == 0xb55b) {
+ qoz_outb(qoztmp,qoz_R_BRG_PCM_CFG,0x21);
+ /* 0x01 g1 st1
+ 0x02 g2 st2
+ 0x04 g3 st3
+ 0x08 g4 st4
+ 0x10 r8 st5
+ 0x20 r7 st6
+ 0x40 r6 st7
+ 0x80 r5 st8
+ */
+ if (qoztmp->leds[0] == 0) {
+ leds |= 0x01;
+ }
+ if (qoztmp->leds[1] == 0) {
+ leds |= 0x02;
+ }
+ if (qoztmp->leds[2] == 0) {
+ leds |= 0x04;
+ }
+ if (qoztmp->leds[3] == 0) {
+ leds |= 0x08;
+ }
+ if (qoztmp->leds[4] == 0) {
+ leds |= 0x10;
+ }
+ if (qoztmp->leds[5] == 0) {
+ leds |= 0x20;
+ }
+ if (qoztmp->leds[6] == 0) {
+ leds |= 0x40;
+ }
+ if (qoztmp->leds[7] == 0) {
+ leds |= 0x80;
+ }
+
+ ledw = leds << 24 | leds << 16 | leds << 8 | leds;
+
+ qoz_outdw_io(qoztmp,0x4000, ledw);
+
+ qoz_outb(qoztmp,qoz_R_BRG_PCM_CFG,0x20);
+
}
spin_unlock_irqrestore(&qoztmp->lock,flags);
}
@@ -173,17 +213,34 @@
void qoz_undoWD(struct qoz_card *qoztmp) {
unsigned long flags;
- spin_lock_irqsave(&qoztmp->lock,flags);
- printk(KERN_INFO "qozap: Stopping hardware watchdog.\n");
- qoz_outdw_io(qoztmp,0x4000, qoz_WD_P0);
- qoztmp->wdp = 0;
- qoz_inb_io(qoztmp,qoz_R_CHIP_ID);
- spin_unlock_irqrestore(&qoztmp->lock,flags);
+ if (qoztmp->wdp) {
+ printk(KERN_INFO "qozap: Stopping hardware watchdog.\n");
+ spin_lock_irqsave(&qoztmp->lock,flags);
+ qoz_outdw_io(qoztmp,0x4000, qoz_WD_P0);
+ qoztmp->wdp = 0;
+ qoz_inb_io(qoztmp,qoz_R_CHIP_ID);
+ spin_unlock_irqrestore(&qoztmp->lock,flags);
+ }
}
+void qoz_reset_pcm(struct qoz_card *qoztmp) {
+ qoz_outb(qoztmp,qoz_R_CIRM,0x20);
+ qoz_outb(qoztmp,qoz_R_CIRM,0x0);
+ qoz_waitbusy(qoztmp);
+
+ if (pcmslave) {
+ qoz_outb(qoztmp,qoz_R_PCM_MD0, 0x90);
+ qoz_outb(qoztmp,qoz_R_PCM_MD1, 0x20);
+ qoz_outb(qoztmp,qoz_R_PCM_MD0, 0xA0);
+ qoz_outb(qoztmp,qoz_R_PCM_MD2, 0x4 | 0x8);
+ } else {
+ qoz_outb(qoztmp,qoz_R_PCM_MD0, 0x91);
+ qoz_outb(qoztmp,qoz_R_PCM_MD1, 0x20);
+ }
+}
+
void qoz_resetCard(struct qoz_card *qoztmp) {
unsigned long flags;
- unsigned int i=0;
spin_lock_irqsave(&(qoztmp->lock),flags);
pci_write_config_word(qoztmp->pcidev, PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
@@ -192,6 +249,8 @@
qoz_outb(qoztmp,qoz_R_CIRM,0x0);
qoz_waitbusy(qoztmp);
+ qoz_reset_pcm(qoztmp);
+
// fifo reset
qoz_outb(qoztmp,qoz_R_CIRM,0x10);
qoz_outb(qoztmp,qoz_R_CIRM,0x0);
@@ -206,6 +265,8 @@
qoz_outb(qoztmp,qoz_R_PWM_MD,0xa0);
if (qoztmp->type == 0xb552) {
qoz_outb(qoztmp,qoz_R_PWM0,0x19);
+ } else if (qoztmp->type == 0xb55b) {
+ qoz_outb(qoztmp,qoz_R_PWM0,0x19);
} else {
qoz_outb(qoztmp,qoz_R_PWM0,0x1E);
}
@@ -214,26 +275,15 @@
qoz_outb(qoztmp,qoz_R_TI_WD, 0x2);
qoz_outb(qoztmp,qoz_R_IRQMSK_MISC, 0x2);
- if (pcmslave) {
- qoz_outb(qoztmp,qoz_R_PCM_MD0, 0x90);
- qoz_outb(qoztmp,qoz_R_PCM_MD1, 0x20);
- qoz_outb(qoztmp,qoz_R_PCM_MD0, 0xA0);
- qoz_outb(qoztmp,qoz_R_PCM_MD2, 0x4 | 0x8);
- } else {
- qoz_outb(qoztmp,qoz_R_PCM_MD0, 0x91);
- qoz_outb(qoztmp,qoz_R_PCM_MD1, 0x20);
- }
- for (i=0; i<256; i++) {
- qoz_outb(qoztmp,qoz_R_SLOT, i);
- qoz_outb(qoztmp,qoz_A_SL_CFG, 0x0);
- }
/* all state changes */
qoz_outb(qoztmp,qoz_R_SCI_MSK, 0xff);
if (qoztmp->type == 0xb552) {
qoz_outb(qoztmp,qoz_R_FIFO_MD,0x16);
+ } else if (qoztmp->type == 0xb55b) {
+ qoz_outb(qoztmp,qoz_R_FIFO_MD,0x16);
} else {
qoz_outb(qoztmp,qoz_R_FIFO_MD,0x26);
}
@@ -247,6 +297,8 @@
qoz_outb(qoztmp,qoz_R_BRG_PCM_CFG,0x0);
} else if (qoztmp->type == 0xb550) {
qoz_outb(qoztmp,qoz_R_BRG_PCM_CFG,0x23);
+ } else if (qoztmp->type == 0xb556) {
+ qoz_outb(qoztmp,qoz_R_BRG_PCM_CFG,0x23);
} else if (qoztmp->type == 0xb520) {
qoz_outb(qoztmp,qoz_R_BRG_PCM_CFG,0x20);
} else {
@@ -270,12 +322,16 @@
// qoz_outb(qoztmp,qoz_R_IRQ_CTRL, 0x8 | 0x1);
if (qoztmp->type == 0xb552) {
qoztmp->stports = 8;
+ } else if (qoztmp->type == 0xb55b) {
+ qoztmp->stports = 8;
+ } else if (qoztmp->type == 0xb556) {
+ qoztmp->stports = 2;
} else {
qoztmp->stports = 4;
}
qoztmp->ticks = 0;
qoztmp->clicks = 0;
- if (qoztmp->type == 0xb550) {
+ if ((qoztmp->type == 0xb550) || (qoztmp->type == 0xb556)) {
printk(KERN_INFO "qozap: Starting hardware watchdog.\n");
qoztmp->wdp = 2;
} else {
@@ -313,6 +369,8 @@
if (qoztmp->type == 0xb552) {
offset = 24;
+ } else if (qoztmp->type == 0xb55b) {
+ offset = 24;
} else {
offset = 28;
}
@@ -377,6 +435,8 @@
if (qoztmp->type == 0xb552) {
offset = 24;
+ } else if (qoztmp->type == 0xb55b) {
+ offset = 24;
} else {
offset = 28;
}
@@ -406,7 +466,7 @@
while ((oz1 != z1) && (oz2 != z2)) {
oz1 = z1;
oz2 = z2;
- if (qoztmp->type != 0xb552) {
+ if ((qoztmp->type != 0xb552) && (qoztmp->type != 0xb55b)){
z1 = qoz_inw(qoztmp,qoz_A_Z1) & 0x7ff;
z2 = qoz_inw(qoztmp,qoz_A_Z2) & 0x7ff;
} else {
@@ -415,7 +475,7 @@
}
}
- if (qoztmp->type == 0xb552) {
+ if ((qoztmp->type == 0xb552)|| (qoztmp->type == 0xb55b)) {
len = z1 - z2;
if (len < 0) {
len += qoz_DFIFO_SIZE8;
@@ -499,7 +559,8 @@
data = qoz_inb(qoztmp,qoz_A_FIFO_DATA0);
}
qoztmp->clicks++;
- if ((qoztmp->clicks > 50) && (debug > 1)) {
+// if ((qoztmp->clicks > 50) && (debug > 1)) {
+ if (((qoztmp->clicks > 50) || (debug > 3)) && (mumbojumbo > 0)) {
printk(KERN_CRIT "qozap: dropped audio card %d cardid %d bytes %d z1 %d z2 %d\n", qoztmp->cardno, qoztmp->cardID, mumbojumbo, z1, z2);
qoztmp->clicks = 0;
}
@@ -600,7 +661,7 @@
struct qoz_card *qoztmp = NULL;
int use_pcm_bus = 0;
int timeslot = 0;
- if (!dacs) return 0;
+ if (!dacs) return -1;
if (src) {
qoztmp = src->pvt;
@@ -650,6 +711,8 @@
int best=99;
int src=-1;
+ if (pcmslave) return;
+
for (i=0; i<qoztmp->stports; i++){
if (qoztmp->st[i].l1up && (qoztmp->st_sync[i] > 0) && (qoztmp->st_sync[i] < best)) {
best = qoztmp->st_sync[i];
@@ -820,6 +883,8 @@
}
if (qoztmp->type == 0xb552) {
offset = 24;
+ } else if (qoztmp->type == 0xb55b) {
+ offset = 24;
} else {
offset = 28;
}
@@ -841,7 +906,9 @@
// keep layer1 up!
if (qoztmp->stports == 8) {
sprintf(qoztmp->spans[st].desc,"octoBRI PCI ISDN Card %d Span %d [NT] Layer 1 ACTIVATED (G%d)",qoztmp->cardno ,st + 1, l1state);
- } else {
+ } else if (qoztmp->stports == 2) {
+ sprintf(qoztmp->spans[st].desc,"duoBRI PCI ISDN Card %d Span %d [NT] (cardID %d) Layer 1 ACTIVATED (G%d)",qoztmp->cardno ,st + 1,qoztmp->cardID, l1state);
+ } else{
sprintf(qoztmp->spans[st].desc,"quadBRI PCI ISDN Card %d Span %d [NT] (cardID %d) Layer 1 ACTIVATED (G%d)",qoztmp->cardno ,st + 1,qoztmp->cardID, l1state);
}
qoz_outb(qoztmp,qoz_A_ST_WR_STA,3 | 0x10 );
@@ -850,6 +917,8 @@
qoztmp->st[st].l1up = 0;
if (qoztmp->stports == 8) {
sprintf(qoztmp->spans[st].desc,"octoBRI PCI ISDN Card %d Span %d [NT] Layer 1 DEACTIVATED (G%d)",qoztmp->cardno ,st + 1, l1state);
+ } else if (qoztmp->stports == 2) {
+ sprintf(qoztmp->spans[st].desc,"duoBRI PCI ISDN Card %d Span %d [NT] (cardID %d) Layer 1 DEACTIVATED (G%d)",qoztmp->cardno ,st + 1,qoztmp->cardID, l1state);
} else {
sprintf(qoztmp->spans[st].desc,"quadBRI PCI ISDN Card %d Span %d [NT] (cardID %d) Layer 1 DEACTIVATED (G%d)",qoztmp->cardno ,st + 1,qoztmp->cardID, l1state);
}
@@ -880,6 +949,8 @@
qoztmp->leds[st] = 0;
if (qoztmp->stports == 8) {
sprintf(qoztmp->spans[st].desc,"octoBRI PCI ISDN Card %d Span %d [TE] Layer 1 DEACTIVATED (F%d)",qoztmp->cardno ,st + 1, l1state);
+ } else if (qoztmp->stports == 2) {
+ sprintf(qoztmp->spans[st].desc,"duoBRI PCI ISDN Card %d Span %d [TE] (cardID %d) Layer 1 DEACTIVATED (F%d)",qoztmp->cardno ,st + 1,qoztmp->cardID, l1state);
} else {
sprintf(qoztmp->spans[st].desc,"quadBRI PCI ISDN Card %d Span %d [TE] (cardID %d) Layer 1 DEACTIVATED (F%d)",qoztmp->cardno ,st + 1,qoztmp->cardID, l1state);
}
@@ -897,6 +968,8 @@
qoztmp->leds[st] = 1;
if (qoztmp->stports == 8) {
sprintf(qoztmp->spans[st].desc,"octoBRI PCI ISDN Card %d Span %d [TE] Layer 1 ACTIVATED (F%d)",qoztmp->cardno ,st + 1, l1state);
+ } else if (qoztmp->stports == 2) {
+ sprintf(qoztmp->spans[st].desc,"duoBRI PCI ISDN Card %d Span %d [TE] (cardID %d) Layer 1 ACTIVATED (F%d)",qoztmp->cardno ,st + 1,qoztmp->cardID, l1state);
} else {
sprintf(qoztmp->spans[st].desc,"quadBRI PCI ISDN Card %d Span %d [TE] (cardID %d) Layer 1 ACTIVATED (F%d)",qoztmp->cardno ,st + 1,qoztmp->cardID, l1state);
}
@@ -907,8 +980,11 @@
qoztmp->st[st].t4 = 0;
} else {
qoztmp->st[st].l1up = 0;
+ qoztmp->leds[st] = 0;
if (qoztmp->stports == 8) {
sprintf(qoztmp->spans[st].desc,"octoBRI PCI ISDN Card %d Span %d [TE] Layer 1 DEACTIVATED (F%d)",qoztmp->cardno ,st + 1, l1state);
+ } else if (qoztmp->stports == 2) {
+ sprintf(qoztmp->spans[st].desc,"duoBRI PCI ISDN Card %d Span %d [TE] (cardID %d) Layer 1 DEACTIVATED (F%d)",qoztmp->cardno ,st + 1,qoztmp->cardID, l1state);
} else {
sprintf(qoztmp->spans[st].desc,"quadBRI PCI ISDN Card %d Span %d [TE] (cardID %d) Layer 1 DEACTIVATED (F%d)",qoztmp->cardno ,st + 1,qoztmp->cardID, l1state);
}
@@ -992,7 +1068,7 @@
/* fifo irq */
spin_lock_irqsave(&(qoztmp->lock), flags);
irq_foview = qoz_inb(qoztmp,qoz_R_IRQ_OVIEW);
- if (qoztmp->type == 0xb552) {
+ if ((qoztmp->type == 0xb552) || (qoztmp->type == 0xb55b)) {
if (irq_foview & 0x60) {
offset = 0;
fi = qoz_inb(qoztmp,qoz_R_IRQ_FIFO_BL6);
@@ -1124,12 +1200,25 @@
return 0;
}
+ if (pcmslave && !span->offset) {
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout((100 * HZ) / 1000);
+ }
+
spin_lock_irqsave(&qoztmp->lock,flags);
+ if (pcmslave && !span->offset) {
+ if (debug)
+ printk(KERN_INFO "qozap: resetting PCM interface to slave mode\n");
+ qoz_reset_pcm(qoztmp);
+ }
+
// irqs off
qoz_outb(qoztmp,qoz_R_IRQ_CTRL, 0);
if (qoztmp->type == 0xb552) {
offset = 24;
+ } else if (qoztmp->type == 0xb55b) {
+ offset = 24;
} else {
offset = 28;
}
@@ -1261,6 +1350,8 @@
// turn off irqs for all fifos
if (qoztmp->type == 0xb552) {
offset = 24;
+ } else if (qoztmp->type == 0xb55b) {
+ offset = 24;
} else {
offset = 28;
}
@@ -1346,6 +1437,12 @@
} else {
sprintf(qoztmp->spans[s].desc,"octoBRI PCI ISDN Card %d Span %d [TE]",qoztmp->cardno,s + 1);
}
+ } else if (qoztmp->stports == 2) {
+ if (qoztmp->st[s].nt_mode == 1){
+ sprintf(qoztmp->spans[s].desc,"duoBRI PCI ISDN Card %d Span %d [NT]",qoztmp->cardno,s + 1);
+ } else {
+ sprintf(qoztmp->spans[s].desc,"duoBRI PCI ISDN Card %d Span %d [TE]",qoztmp->cardno,s + 1);
+ }
} else {
if (qoztmp->cardID < 0xff) {
if (qoztmp->st[s].nt_mode == 1){
@@ -1482,7 +1579,11 @@
if (pcidid == PCI_DEVICE_ID_CCD_M) {
qoztmp->stports = 8;
} else {
- qoztmp->stports = 4;
+ if (tmp->subsystem_device <= 0xb555) {
+ qoztmp->stports = 4;
+ } else {
+ qoztmp->stports = 2;
+ }
}
@@ -1538,21 +1639,30 @@
"qozap: CologneChip HFC-4S evaluation board configured at io port %#x IRQ %d HZ %d\n",
(u_int) qoztmp->ioport,
qoztmp->irq, HZ);
+ totalBRIs += 4;
break;
case 0xb520:
printk(KERN_INFO
"qozap: Junghanns.NET quadBRI card configured at io port %#x IRQ %d HZ %d CardID %d\n",
(u_int) qoztmp->ioport,
qoztmp->irq, HZ, cid);
+ totalBRIs += 4;
break;
case 0xb550:
printk(KERN_INFO
"qozap: Junghanns.NET quadBRI (Version 2.0) card configured at io port %#x IRQ %d HZ %d CardID %d\n",
(u_int) qoztmp->ioport,
qoztmp->irq, HZ, cid);
+ totalBRIs += 4;
break;
+ case 0xb556:
+ printk(KERN_INFO
+ "qozap: Junghanns.NET duoBRI card configured at io port %#x IRQ %d HZ %d CardID %d\n",
+ (u_int) qoztmp->ioport,
+ qoztmp->irq, HZ, cid);
+ totalBRIs += 2;
+ break;
}
- totalBRIs += 4;
} else {
switch (tmp->subsystem_device) {
case 0xb552:
@@ -1561,6 +1671,12 @@
(u_int) qoztmp->ioport,
qoztmp->irq, HZ);
break;
+ case 0xb55b:
+ printk(KERN_INFO
+ "qozap: Junghanns.NET octoBRI (Version 2.0) card configured at io port %#x IRQ %d HZ %d\n",
+ (u_int) qoztmp->ioport,
+ qoztmp->irq, HZ);
+ break;
default:
printk(KERN_INFO
"qozap: wtf\n");
@@ -1672,6 +1788,7 @@
tmplist = qoz_dev_list;
while (tmplist != NULL) {
tmplist->dead = 1;
+ qoz_resetCard(tmplist);
qoz_undoWD(tmplist);
qoz_shutdownCard(tmplist);
tmplist = tmplist->next;
Added: zaptel/trunk/qozap/zapata.conf.duoBRI
===================================================================
--- zaptel/trunk/qozap/zapata.conf.duoBRI 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/qozap/zapata.conf.duoBRI 2007-03-24 06:28:03 UTC (rev 3298)
@@ -0,0 +1,43 @@
+;
+; Zapata telephony interface
+;
+; Configuration file
+
+[channels]
+;
+; Default language
+;
+;language=en
+;
+; Default context
+;
+;
+switchtype = euroisdn
+
+; p2mp TE mode (for connecting ISDN lines in point-to-multipoint mode)
+signalling = bri_cpe_ptmp
+; p2p TE mode (for connecting ISDN lines in point-to-point mode)
+;signalling = bri_cpe
+; p2mp NT mode (for connecting ISDN phones in point-to-multipoint mode)
+;signalling = bri_net_ptmp
+; p2p NT mode (for connecting an ISDN pbx in point-to-point mode)
+;signalling = bri_net
+
+pridialplan = local
+prilocaldialplan = dynamic
+nationalprefix = 0
+internationalprefix = 00
+
+priindication = passthrough
+
+echocancel = yes
+
+context=demo
+group = 1
+; S/T port 1
+channel => 1-2
+
+group = 2
+; S/T port 2
+channel => 4-5
+
Modified: zaptel/trunk/qozap/zaptel.conf
===================================================================
--- zaptel/trunk/qozap/zaptel.conf 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/qozap/zaptel.conf 2007-03-24 06:28:03 UTC (rev 3298)
@@ -4,8 +4,8 @@
# most of the values should be bogus because we are not really zaptel
span=1,1,3,ccs,ami
span=2,2,3,ccs,ami
-span=3,0,3,ccs,ami
-span=4,0,3,ccs,ami
+span=3,3,3,ccs,ami
+span=4,4,3,ccs,ami
bchan=1,2
dchan=3
Added: zaptel/trunk/qozap/zaptel.conf.duoBRI
===================================================================
--- zaptel/trunk/qozap/zaptel.conf.duoBRI 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/qozap/zaptel.conf.duoBRI 2007-03-24 06:28:03 UTC (rev 3298)
@@ -0,0 +1,11 @@
+loadzone=nl
+defaultzone=nl
+# qozap span definitions
+# most of the values should be bogus because we are not really zaptel
+span=1,1,3,ccs,ami
+span=2,2,3,ccs,ami
+
+bchan=1,2
+dchan=3
+bchan=4,5
+dchan=6
Modified: zaptel/trunk/qozap/zaptel.conf.octoBRI
===================================================================
--- zaptel/trunk/qozap/zaptel.conf.octoBRI 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/qozap/zaptel.conf.octoBRI 2007-03-24 06:28:03 UTC (rev 3298)
@@ -3,13 +3,13 @@
# qozap span definitions
# most of the values should be bogus because we are not really zaptel
span=1,1,3,ccs,ami
-span=2,0,3,ccs,ami
-span=3,0,3,ccs,ami
-span=4,0,3,ccs,ami
-span=5,1,3,ccs,ami
-span=6,0,3,ccs,ami
-span=7,0,3,ccs,ami
-span=8,0,3,ccs,ami
+span=2,2,3,ccs,ami
+span=3,3,3,ccs,ami
+span=4,4,3,ccs,ami
+span=5,5,3,ccs,ami
+span=6,6,3,ccs,ami
+span=7,7,3,ccs,ami
+span=8,8,3,ccs,ami
bchan=1,2
dchan=3
Modified: zaptel/trunk/ztgsm/ztgsm.c
===================================================================
--- zaptel/trunk/ztgsm/ztgsm.c 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/ztgsm/ztgsm.c 2007-03-24 06:28:03 UTC (rev 3298)
@@ -40,53 +40,22 @@
}
void ztgsm_switch_on(struct ztgsm_card *gsmtmp, int span) {
- unsigned int dtr_on_off = 0;
- unsigned int rts_o = 0;
unsigned long flags;
printk(KERN_INFO "ztgsm: Powering up span %d ...", span);
spin_lock_irqsave(&(gsmtmp->lock),flags);
gsmtmp->gsmspan[span].led = 0xC1;
- dtr_on_off = ztgsm_indw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF);
- dtr_on_off |= (1 << span) | (1 << (span+4));
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, dtr_on_off);
-
- rts_o = ztgsm_indw_io(gsmtmp, ztgsm_SER_RTS_O);
- rts_o |= (1 << span);
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_RTS_O, rts_o);
+ gsmtmp->dtr_on_off &= ~ (1 << span);
+ ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, gsmtmp->dtr_on_off);
spin_unlock_irqrestore(&(gsmtmp->lock),flags);
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout((1000 * HZ) / 1000);
spin_lock_irqsave(&(gsmtmp->lock),flags);
- dtr_on_off = ztgsm_indw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF);
- dtr_on_off &= ~(1 << span);
- dtr_on_off |= 1 << (span+4);
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, dtr_on_off);
- spin_unlock_irqrestore(&(gsmtmp->lock),flags);
+ gsmtmp->dtr_on_off |= 1 << span;
+ ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, gsmtmp->dtr_on_off);
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout((800 * HZ) / 1000);
-
- spin_lock_irqsave(&(gsmtmp->lock),flags);
- dtr_on_off = ztgsm_indw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF);
- dtr_on_off |= (1 << span) | (1 << (span+4));
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, dtr_on_off);
- spin_unlock_irqrestore(&(gsmtmp->lock),flags);
-
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout((8000 * HZ) / 1000);
-
- spin_lock_irqsave(&(gsmtmp->lock),flags);
- dtr_on_off = ztgsm_indw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF);
- dtr_on_off &= ~(1 << (span+4));
- dtr_on_off |= (1 << span);
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, dtr_on_off);
-
- rts_o = ztgsm_indw_io(gsmtmp, ztgsm_SER_RTS_O);
- rts_o &= ~(1 << span);
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_RTS_O, 0x0);
gsmtmp->power[span] = 1;
gsmtmp->gsmspan[span].led = 0x81;
spin_unlock_irqrestore(&(gsmtmp->lock),flags);
@@ -97,27 +66,24 @@
}
void ztgsm_switch_off(struct ztgsm_card *gsmtmp, int span) {
- unsigned int dtr_on_off = 0;
unsigned long flags;
gsmtmp->gsmspan[span].span.alarms = ZT_ALARM_RED;
zt_alarm_notify(&gsmtmp->gsmspan[span].span);
spin_lock_irqsave(&(gsmtmp->lock),flags);
gsmtmp->gsmspan[span].led = 0xC0;
- dtr_on_off = ztgsm_indw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF);
- printk(KERN_INFO "ztgsm: Powering down span %d (SER_DTR_ON_OFF %x)...", span, dtr_on_off);
+ printk(KERN_INFO "ztgsm: Powering down span %d (SER_DTR_ON_OFF %x)...", span, gsmtmp->dtr_on_off);
- dtr_on_off &= ~ (1 << span);
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, dtr_on_off);
+ gsmtmp->dtr_on_off &= ~ (1 << span);
+ ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, gsmtmp->dtr_on_off);
spin_unlock_irqrestore(&(gsmtmp->lock),flags);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout((5000 * HZ) / 1000);
+ schedule_timeout((2500 * HZ) / 1000);
spin_lock_irqsave(&(gsmtmp->lock),flags);
- dtr_on_off = ztgsm_indw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF);
- dtr_on_off |= (1 << span);
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, dtr_on_off);
+ gsmtmp->dtr_on_off |= (1 << span);
+ ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, gsmtmp->dtr_on_off);
gsmtmp->power[span] = 0;
gsmtmp->gsmspan[span].led = 0x80;
spin_unlock_irqrestore(&(gsmtmp->lock),flags);
@@ -134,41 +100,16 @@
gsmtmp->gsmspan[2].led = 0xC1;
gsmtmp->gsmspan[3].led = 0xC1;
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, 0xff);
-
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_RTS_O, 0x0f);
+ ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, 0xf0);
spin_unlock_irqrestore(&(gsmtmp->lock),flags);
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout((1000 * HZ) / 1000);
spin_lock_irqsave(&(gsmtmp->lock),flags);
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, 0xf0);
- spin_unlock_irqrestore(&(gsmtmp->lock),flags);
-
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout((800 * HZ) / 1000);
-
- spin_lock_irqsave(&(gsmtmp->lock),flags);
ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, 0xff);
- spin_unlock_irqrestore(&(gsmtmp->lock),flags);
-
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout((8000 * HZ) / 1000);
-
- spin_lock_irqsave(&(gsmtmp->lock),flags);
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, 0xff);
ztgsm_outdw_io(gsmtmp, ztgsm_SER_RTS_O, 0x0); /* 1 == -12 v */
-
-/* new
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, 0x00);
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout((1000 * HZ) / 1000);
-
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, 0x0f);
-*/
-
gsmtmp->power[0] = 1;
gsmtmp->power[1] = 1;
gsmtmp->power[2] = 1;
@@ -200,10 +141,10 @@
spin_unlock_irqrestore(&(gsmtmp->lock),flags);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout((5000 * HZ) / 1000);
+ schedule_timeout((2500 * HZ) / 1000);
spin_lock_irqsave(&(gsmtmp->lock),flags);
- ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, 0xf);
+ ztgsm_outdw_io(gsmtmp, ztgsm_SER_DTR_ON_OFF, 0x0f);
gsmtmp->power[0] = 0;
gsmtmp->power[1] = 0;
@@ -234,11 +175,13 @@
printk(KERN_INFO "ztgsm: shutting down NULL card!\n");
return;
}
-
ztgsm_switch_off_all(gsmtmp, 1);
spin_lock_irqsave(&gsmtmp->lock,flags);
+ ztgsm_outdw_io(gsmtmp, ztgsm_SER_TX_EN, 0x0);
+ ztgsm_outdw_io(gsmtmp, ztgsm_SER_RX_EN, 0x0);
+
gsmtmp->dead = 1;
if ((!gsmtmp->pci_io) || (gsmtmp->ioport == 0)) {
@@ -380,6 +323,7 @@
ztgsm_outdw_io(gsmtmp, ztgsm_SER_TX_EN, 0x0F);
if (debug)
printk(KERN_INFO "ztgsm: SER_TX_EN %d SER_RX_EN %d \n", ztgsm_indw_io(gsmtmp, ztgsm_SER_TX_EN), ztgsm_indw_io(gsmtmp, ztgsm_SER_RX_EN));
+ gsmtmp->jitter_offset = 0;
spin_unlock_irqrestore(&(gsmtmp->lock),flags);
}
@@ -550,6 +494,10 @@
tx_wm_sen = (ztgsm_indw_io(gsmtmp, ztgsm_SER_TX_WM_SEN) & 0xF) | (1 << span);
ztgsm_outdw_io(gsmtmp, ztgsm_SER_TX_WM_SEN, tx_wm_sen);
// printk(KERN_INFO "ztgsm: span %d TX_IDX %d count %d tx_wm_send %d\n", span, gsmtmp->ser_tx_idx[span], count, tx_wm_sen);
+ } else {
+ if (debug) {
+ printk(KERN_INFO "ztgsm: span %d wanted to TX %d bytes but only %d bytes free fifo space\n", span, gsmtmp->ser_tx_idx[span], left);
+ }
}
}
return i;
@@ -616,7 +564,7 @@
// slot = span;
gsmspan = &gsmtmp->gsmspan[span];
if (gsmspan) {
- framecnt = gsmtmp->framecnt;
+ framecnt = gsmtmp->framecnt - gsmtmp->jitter_offset;
pcmframecnt = framecnt;
framecnt &= ztgsm_FRAMES - 1;
start = framecnt - 16;
@@ -630,7 +578,7 @@
}
if (fraddr & 3) {
- if (debug > 0)
+ if (debug > 1)
printk(KERN_INFO "ztgsm: RX span %d unaligned word address %#x (fraddr & 3 = %d)\n", span, fraddr, (fraddr & 3));
fraddr -= fraddr & 3; /* align */
}
@@ -649,7 +597,8 @@
*((unsigned int *)&gsmtmp->rxbuf[span][4]) = data;
// ztgsm_outdw_io(gsmtmp, ztgsm_LED_DUAL, 0xf);
} else {
- printk(KERN_INFO "ztgsm: dropped audio span %d fraddr %d addr %d\n", span, fraddr, addr);
+ if (debug > 2)
+ printk(KERN_INFO "ztgsm: dropped audio span %d fraddr %d addr %d\n", span, fraddr, addr);
}
if (!(gsmtmp->ticks % 1000) && (debug > 4)) {
printk(KERN_INFO "ztgsm: RX DATA:");
@@ -690,9 +639,9 @@
gsmspan = &gsmtmp->gsmspan[span];
if (gsmspan) {
- framecnt = gsmtmp->framecnt;
+ framecnt = gsmtmp->framecnt - gsmtmp->jitter_offset;
framecnt &= ztgsm_FRAMES - 1;
- start = framecnt + 16;
+ start = framecnt + ztgsm_MAX_FC_DIFF + ztgsm_FRAME_SIZE;
if (start < 0x0) {
len = -start;
@@ -702,11 +651,13 @@
len = ZT_CHUNKSIZE;
fraddr = start;
}
- fraddr -= fraddr & 3; /* align */
if (fraddr & 3) {
-// printk(KERN_EMERG "ztgsm: unaligned word address %#x\n", addr);
- } else if (len == ZT_CHUNKSIZE) {
+ if (debug > 2)
+ printk(KERN_INFO "ztgsm: span_tx unaligned word address %#x\n", fraddr);
+ fraddr -= fraddr & 3; /* align */
+ }
+ if (len == ZT_CHUNKSIZE) {
addr =(slot << 8 ) | fraddr;
// addr =( (span+1) << 8 ) | fraddr;
ztgsm_outdw(gsmtmp, addr, *((unsigned int*)&(gsmtmp->txbuf[span][0])));
@@ -743,14 +694,11 @@
static inline void ztgsm_run(struct ztgsm_card *gsmtmp) {
int s=0;
struct ztgsm_span *gsmspan = NULL;
+
+
for (s=0;s<gsmtmp->gsmspans;s++) {
gsmspan = &gsmtmp->gsmspan[s];
if (gsmspan) {
- if (!(gsmtmp->ticks % 1000)) {
- gsmtmp->ticks = 0;
- }
- if (gsmtmp->ticks % 300 == 0)
- ztgsm_leds(gsmtmp, gsmtmp->ticks);
if (gsmspan->span.flags & ZT_FLAG_RUNNING) {
/* oh zaptel! tell us what to transmit... */
zt_transmit(&gsmspan->span);
@@ -783,7 +731,8 @@
int s = 0;
int rx_count = 0;
unsigned long flags;
-
+ signed int jitter = 0;
+
if (!gsmtmp || gsmtmp->dead) {
#ifdef LINUX26
return IRQ_NONE;
@@ -808,21 +757,33 @@
ser_status = ztgsm_indw_io(gsmtmp, ztgsm_SER_STATUS);
if (ser_status) {
if (ser_status & 0x10000) {
- if (gsmtmp->framecnt - gsmtmp->last_framecnt != 8) {
-// printk(KERN_INFO "ztgsm: missed IRQ, framecnt %d last_framecnt %d (diff %d)\n", gsmtmp->framecnt, gsmtmp->last_framecnt, (gsmtmp->framecnt - gsmtmp->last_framecnt));
- }
gsmtmp->ticks++;
- if (!(gsmtmp->ticks % 1000)) {
-// printk(KERN_INFO "ztgsm: pcm framce counter %d\n", ztgsm_indw_io(gsmtmp, ztgsm_PCM_FRAME_CNT) & 0x1f);
- }
- if (!(gsmtmp->ticks % 300)) {
- for (s=0; s<gsmtmp->gsmspans; s++) {
- rx_count = ztgsm_ser_rx(gsmtmp, s);
- if (debug && rx_count)
- printk(KERN_INFO "ztgsm: RX %d bytes on span %d\n", rx_count, s);
+ jitter = gsmtmp->framecnt - gsmtmp->last_framecnt - ztgsm_FRAME_SIZE;
+ if (abs(gsmtmp->jitter_offset + jitter) > ztgsm_MAX_FC_DIFF) {
+ if (debug > 1)
+ printk(KERN_INFO "ztgsm: missed IRQ, framecnt %d last_framecnt %d (diff %d)\n", gsmtmp->framecnt, gsmtmp->last_framecnt, (gsmtmp->framecnt - gsmtmp->last_framecnt));
+ gsmtmp->jitter_offset = 0;
+ } else {
+ if (gsmtmp->jitter_offset > 0) {
+ gsmtmp->jitter_offset += jitter;
}
+ if ((debug > 1) && gsmtmp->jitter_offset)
+ printk(KERN_INFO "ztgsm: lagged IRQ, framecnt %d last_framecnt %d (offset %d)\n", gsmtmp->framecnt, gsmtmp->last_framecnt, gsmtmp->jitter_offset);
}
- ztgsm_run(gsmtmp);
+ if (gsmtmp->jitter_offset >= 0) {
+ ztgsm_run(gsmtmp);
+ }
+
+ for (s=0; s<gsmtmp->gsmspans; s++) {
+ rx_count = ztgsm_ser_rx(gsmtmp, s);
+ }
+ if (!(gsmtmp->ticks % 300))
+ ztgsm_leds(gsmtmp, gsmtmp->ticks);
+ if (!(gsmtmp->ticks % 1000)) {
+ if (debug > 2)
+ printk(KERN_INFO "ztgsm: TICK\n");
+ gsmtmp->ticks = 0;
+ }
} else if (ser_status & 0x0F) {
mods = (ser_status & 0x0F);
for (s=0; s<gsmtmp->gsmspans; s++) {
@@ -840,7 +801,7 @@
if (mods & (1 << s)) {
rx_count = ztgsm_ser_rx(gsmtmp, s);
if (debug)
- printk(KERN_INFO "ztgsm: RX %d bytes on span %d\n", rx_count, s);
+ printk(KERN_INFO "ztgsm: RX %d bytes on span %d.\n", rx_count, s);
}
}
} else if (ser_status & 0xF00) {
@@ -917,16 +878,15 @@
}
running = span->flags & ZT_FLAG_RUNNING;
- span->chans[1].flags &= ~ZT_FLAG_HDLC;
- span->chans[1].flags |= ZT_FLAG_BRIDCHAN;
if (!running) {
+ span->chans[1].flags &= ~ZT_FLAG_HDLC;
+ span->chans[1].flags |= ZT_FLAG_BRIDCHAN;
if (!gsmtmp->power[span->offset])
ztgsm_switch_on(gsmtmp, span->offset);
span->flags |= ZT_FLAG_RUNNING;
-
} else {
- printk(KERN_CRIT "already running\n");
+ printk(KERN_INFO "ztgsm: already running\n");
return 0;
}
return 0;
@@ -1157,6 +1117,7 @@
}
ztgsm_leds(gsmtmp, 0);
+ gsmtmp->dtr_on_off = 0x0f;
gsmtmp->version = ztgsm_indw_io(gsmtmp, ztgsm_VERS_A);
printk(KERN_INFO "ztgsm: VERSION %x\n", gsmtmp->version);
Modified: zaptel/trunk/ztgsm/ztgsm.h
===================================================================
--- zaptel/trunk/ztgsm/ztgsm.h 2007-03-24 05:40:14 UTC (rev 3297)
+++ zaptel/trunk/ztgsm/ztgsm.h 2007-03-24 06:28:03 UTC (rev 3298)
@@ -3,6 +3,8 @@
#define ztgsm_SPANS 4
#define ztgsm_SER_BUF_SIZE 1000
#define ztgsm_FRAMES 0x100
+#define ztgsm_MAX_FC_DIFF 32
+#define ztgsm_FRAME_SIZE ZT_CHUNKSIZE
typedef struct ztgsm_span {
int led; /* 0 == RED 1 == GREEN 0x80 == on 0x40 == blink */
@@ -20,6 +22,7 @@
typedef struct ztgsm_card {
spinlock_t lock;
unsigned char power[ztgsm_SPANS];
+ unsigned int dtr_on_off;
int cardID;
int dead;
unsigned char cardno;
@@ -28,6 +31,7 @@
void *pci_io;
unsigned int framecnt;
unsigned int last_framecnt;
+ signed int jitter_offset;
unsigned long pci_io_phys;
unsigned int version;
// unsigned char *pci_io;
More information about the Pkg-voip-commits
mailing list