[zaptel-commits] kpfleming: branch mogorman/zaptel-1.2-transcoder
r1906 - in /team/mogorman/za...
zaptel-commits at lists.digium.com
zaptel-commits at lists.digium.com
Mon Jan 22 15:57:14 MST 2007
Author: kpfleming
Date: Mon Jan 22 16:57:14 2007
New Revision: 1906
URL: http://svn.digium.com/view/zaptel?view=rev&rev=1906
Log:
various cleanups... still lots more to do
Modified:
team/mogorman/zaptel-1.2-transcoder/ (props changed)
team/mogorman/zaptel-1.2-transcoder/wctc4xxb/ (props changed)
team/mogorman/zaptel-1.2-transcoder/wctc4xxb/Makefile
team/mogorman/zaptel-1.2-transcoder/wctc4xxb/base.c
Propchange: team/mogorman/zaptel-1.2-transcoder/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jan 22 16:57:14 2007
@@ -1,1 +1,1 @@
-/branches/1.2:1-1880
+/branches/1.2:1-1893
Propchange: team/mogorman/zaptel-1.2-transcoder/wctc4xxb/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 22 16:57:14 2007
@@ -1,0 +1,3 @@
+*.cmd
+*.mod.c
+*.ko
Modified: team/mogorman/zaptel-1.2-transcoder/wctc4xxb/Makefile
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/wctc4xxb/Makefile?view=diff&rev=1906&r1=1905&r2=1906
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxb/Makefile (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxb/Makefile Mon Jan 22 16:57:14 2007
@@ -11,7 +11,6 @@
base.o: ../zaptel.h
-
firmware_wctc4xxb.o: wctc4xxb_firm.bin base.o
@echo Making firmware object file for $<
../build_tools/make_firmware_object $< $@ base.o
Modified: team/mogorman/zaptel-1.2-transcoder/wctc4xxb/base.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/wctc4xxb/base.c?view=diff&rev=1906&r1=1905&r2=1906
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxb/base.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxb/base.c Mon Jan 22 16:57:14 2007
@@ -1,5 +1,5 @@
/*
- * Wilcard TC400B Digium Transcoder Engine Interface Driver for Zapata Telephony interface
+ * Wildcard TC400B Interface Driver for Zapata Telephony interface
*
* Written by John Sloan <jsloan at digium.com>
*
@@ -54,10 +54,13 @@
#include <linux/firmware.h>
static const char *dte_firmware = "wctc4xxb_firm.bin";
#else
-extern const unsigned char _binary_wctc4xxb_firm_bin_start[];
-extern const unsigned int _binary_wctc4xxb_firm_bin_size;
+struct firmware {
+ size_t size;
+ u8 *data;
+};
+extern const u8 _binary_wctc4xxb_firm_bin_start[];
+extern const size_t _binary_wctc4xxb_firm_bin_size;
#endif
-
/* #define USE_TEST_HW */
#define USE_TDM_CONFIG
@@ -65,7 +68,6 @@
#define WC_MAX_IFACES 128
#define NUM_CARDS 24
-#define NUM_EC 4
/* NUM_CHANNELS must be checked if new firmware (dte_firm.h) is used */
#define NUM_CHANNELS 97
@@ -79,13 +81,11 @@
#define G729_LENGTH 20
#define G723_LENGTH 30
-#define G729_SAMPLES 160 /* g.729 */
-#define G723_SAMPLES 240 /* g.723 */
-
-#define G729_BYTES 20 /* g.729 */
-#define G723_BYTES 20 /* g.723 */
-
-
+#define G729_SAMPLES 160
+#define G723_SAMPLES 240
+
+#define G729_BYTES 20
+#define G723_BYTES 20
#define ACK_SPACE 20
@@ -253,7 +253,7 @@
0x80,p14, p15,p16, p17,p18,p19,p20, 0x12,0x34,0x56,0x78}
-#define zt_send_cmd(wc, command, length, hex) \
+#define send_cmd(wc, command, length, hex) \
({ \
int ret = 0; \
do { \
@@ -277,25 +277,11 @@
} \
__transmit_demand(wc); \
up(&wc->cmdqsem); \
- ret = wcdte_waitfor_csmencaps(wc, RCV_CSMENCAPS, 0); \
+ ret = waitfor_csmencaps(wc, RCV_CSMENCAPS, 0); \
if (ret == 1) \
- return(1); \
+ return 1; \
} while (ret == 2); \
})
-
-
-/* define NOT_BLI to use a faster but not bit-level identical version */
-/* #define NOT_BLI */
-
-#if defined(NOT_BLI)
-# if defined(_MSC_VER)
-typedef __int64 sint64;
-# elif defined(__GNUC__)
-typedef long long sint64;
-# else
-# error 64-bit integer type is not defined for your compiler/platform
-# endif
-#endif
struct cmdq {
@@ -364,17 +350,6 @@
static struct wcdte *ifaces[WC_MAX_IFACES];
-
-
-/*
- * The following is the definition of the state structure
- * used by the G.721/G.723 encoder and decoder to preserve their internal
- * state between successive calls. The meanings of the majority
- * of the state structure fields are explained in detail in the
- * CCITT Recommendation G.721. The field names are essentially indentical
- * to variable names in the bit level description of the coding algorithm
- * included in this Recommendation.
- */
struct dte_state {
int encoder; /* If we're an encoder */
struct wcdte *wc;
@@ -394,7 +369,6 @@
unsigned int last_dte_seqno;
unsigned int dte_seqno_rcv;
};
-
static struct zt_transcoder *uencode;
static struct zt_transcoder *udecode;
@@ -404,10 +378,8 @@
static char *mode;
int debug_packets = 0;
-
-static int wcdte_create_channel(struct wcdte *wc, int simple, int complicated, int part1_id, int part2_id, unsigned int *dte_chan1, unsigned int *dte_chan2);
-static int wcdte_destroy_channel(struct wcdte *wc, unsigned int chan1, unsigned int chan2);
-
+static int create_channel(struct wcdte *wc, int simple, int complicated, int part1_id, int part2_id, unsigned int *dte_chan1, unsigned int *dte_chan2);
+static int destroy_channel(struct wcdte *wc, unsigned int chan1, unsigned int chan2);
static void dte_init_state(struct dte_state *state_ptr, int encoder, unsigned int channel, struct wcdte *wc)
{
@@ -424,8 +396,7 @@
state_ptr->chan_in_num = 999;
state_ptr->chan_out_num = 999;
- if (encoder == 1)
- {
+ if (encoder) {
state_ptr->timeslot_in_num = channel * 2;
state_ptr->timeslot_out_num = channel * 2 + 1;
} else {
@@ -435,72 +406,63 @@
}
-static unsigned int wcdte_zapfmt_to_dtefmt(unsigned int fmt)
-{
- unsigned int pt;
-
- switch(fmt)
- {
- case ZT_FORMAT_G723_1:
- pt = DTE_FORMAT_G723_1;
- break;
- case ZT_FORMAT_ULAW:
- pt = DTE_FORMAT_ULAW;
- break;
- case ZT_FORMAT_ALAW:
- pt = DTE_FORMAT_ALAW;
- break;
- case ZT_FORMAT_G729A:
- pt = DTE_FORMAT_G729A;
- break;
- default:
- pt = DTE_FORMAT_UNDEF;
- }
-
- return(pt);
-}
-
-
-static inline void __wcdte_setctl(struct wcdte *wc, unsigned int addr, unsigned int val)
+static inline unsigned int zapfmt_to_dtefmt(unsigned int fmt)
+{
+ switch (fmt) {
+ case ZT_FORMAT_G723_1:
+ return DTE_FORMAT_G723_1;
+ case ZT_FORMAT_ULAW:
+ return DTE_FORMAT_ULAW;
+ case ZT_FORMAT_ALAW:
+ return DTE_FORMAT_ALAW;
+ case ZT_FORMAT_G729A:
+ return DTE_FORMAT_G729A;
+ default:
+ return DTE_FORMAT_UNDEF;
+ }
+}
+
+static inline void __setctl(struct wcdte *wc, unsigned int addr, unsigned int val)
{
outl(val, wc->iobase + addr);
}
-static inline unsigned int __wcdte_getctl(struct wcdte *wc, unsigned int addr)
+static inline unsigned int __getctl(struct wcdte *wc, unsigned int addr)
{
return inl(wc->iobase + addr);
}
-static inline void wcdte_setctl(struct wcdte *wc, unsigned int addr, unsigned int val)
+static inline void setctl(struct wcdte *wc, unsigned int addr, unsigned int val)
{
unsigned long flags;
+
spin_lock_irqsave(&wc->reglock, flags);
- __wcdte_setctl(wc, addr, val);
+ __setctl(wc, addr, val);
spin_unlock_irqrestore(&wc->reglock, flags);
}
-
-
-
-static inline void wcdte_reinit_descriptor(struct wcdte *wc, int tx, int dbl, char *s)
+static inline void reinit_descriptor(struct wcdte *wc, int tx, int dbl, char *s)
{
int o2 = 0;
+
o2 += dbl * 4;
if (!tx)
o2 += ERING_SIZE * 4;
wc->descripchunk[o2] = cpu_to_le32(0x80000000);
- wcdte_setctl(wc, 0x0008, 0x00000000);
-}
-
-static inline unsigned int wcdte_getctl(struct wcdte *wc, unsigned int addr)
+ setctl(wc, 0x0008, 0x00000000);
+}
+
+static inline unsigned int getctl(struct wcdte *wc, unsigned int addr)
{
unsigned long flags;
unsigned int val;
+
spin_lock_irqsave(&wc->reglock, flags);
- val = __wcdte_getctl(wc, addr);
+ val = __getctl(wc, addr);
spin_unlock_irqrestore(&wc->reglock, flags);
+
return val;
}
@@ -511,19 +473,19 @@
int o2,i,j;
unsigned int reg, xmt_length;
- reg = wcdte_getctl(wc, 0x0028) & 0x00700000;
+ reg = getctl(wc, 0x0028) & 0x00700000;
/* Already transmiting, no need to demand another */
if (!((reg == 0) || (reg = 6)))
- return(1);
+ return 1;
/* Nothing to transmit */
if (wc->cmdq_rndx == wc->cmdq_wndx)
- return(1);
+ return 1;
/* Nothing to transmit */
if (wc->cmdq[wc->cmdq_rndx].cmdlen == 0 )
- return(1);
+ return 1;
writechunk = (volatile unsigned char *)(wc->writechunk);
@@ -531,25 +493,22 @@
o2 = wc->tdbl * 4;
- do
- {
- } while ((le32_to_cpu(wc->descripchunk[o2]) & 0x80000000));
+ do {} while ((le32_to_cpu(wc->descripchunk[o2]) & 0x80000000));
xmt_length = wc->cmdq[wc->cmdq_rndx].cmdlen;
if (xmt_length < 64)
xmt_length = 64;
- wc->descripchunk[o2+1] = cpu_to_le32((le32_to_cpu(wc->descripchunk[o2+1]) & 0xFBFFF800) | xmt_length);
+ wc->descripchunk[o2 + 1] = cpu_to_le32((le32_to_cpu(wc->descripchunk[o2 + 1]) & 0xFBFFF800) | xmt_length);
- for(i = 0; i < wc->cmdq[wc->cmdq_rndx].cmdlen; i++)
+ for (i = 0; i < wc->cmdq[wc->cmdq_rndx].cmdlen; i++)
writechunk[i] = wc->cmdq[wc->cmdq_rndx].cmd[i];
for (j = i; j < xmt_length; j++)
writechunk[j] = 0;
- if (debug_packets && (writechunk[12] == 0x88) && (writechunk[13] == 0x9B))
- {
+ if (debug_packets && (writechunk[12] == 0x88) && (writechunk[13] == 0x9B)) {
printk("wcdte debug: TX: ");
- for (i=0; i<debug_packets; i++)
+ for (i = 0; i < debug_packets; i++)
printk("%02X ", writechunk[i]);
printk("\n");
}
@@ -557,21 +516,23 @@
wc->cmdq[wc->cmdq_rndx].cmdlen = 0;
wc->descripchunk[o2] = cpu_to_le32(0x80000000);
- wcdte_setctl(wc, 0x0008, 0x00000000); /* Transmit Poll Demand */
+ setctl(wc, 0x0008, 0x00000000); /* Transmit Poll Demand */
wc->tdbl = (wc->tdbl + 1) % ERING_SIZE;
wc->cmdq_rndx = (wc->cmdq_rndx + 1) % MAX_COMMANDS;
- return(0);
+ return 0;
}
static inline int transmit_demand(struct wcdte *wc)
{
int val;
+
down(&wc->cmdqsem);
val = __transmit_demand(wc);
up(&wc->cmdqsem);
+
return val;
}
@@ -580,18 +541,16 @@
unsigned int emc_errorcnt;
unsigned int emc_rcvd;
-
-static int wcdte_send_test_packet(struct wcdte *wc)
+static int send_test_packet(struct wcdte *wc)
{
unsigned int inbytes = 0;
unsigned int timestamp_inc = 0;
int i = 0;
unsigned long flags;
unsigned int ipchksum;
-
- inbytes = 160; /* 80; */
- timestamp_inc = 160; /* 80; */
+ inbytes = 160;
+ timestamp_inc = 160;
{
unsigned char fifo[300] = CMD_MSG_IP_UDP_RTP(
@@ -660,13 +619,14 @@
int i = 0, j = 0, reg = 0;
int res = 0;
unsigned int ipchksum, ndx;
+
switch(op) {
case ZT_TCOP_TEST:
printk("Starting EMC Loop test\n");
do {
- wcdte_send_test_packet(wc);
- if (j%50 == 0) {
- reg = wcdte_getctl(wc, 0x00fc);
+ send_test_packet(wc);
+ if ((j % 50) == 0) {
+ reg = getctl(wc, 0x00fc);
printk(KERN_EMERG "sent = %d, received = %d, bad = %d, reg 0xFC = %X\n", j, emc_rcvd, emc_errorcnt, reg);
}
j++;
@@ -675,13 +635,12 @@
break;
case ZT_TCOP_RESET:
down(&wc->chansem);
- if (ztc->chan_built == 0)
- {
- if (st->encoder == 1)
- wcdte_create_channel(wc, wcdte_zapfmt_to_dtefmt(zth->srcfmt), wcdte_zapfmt_to_dtefmt(zth->dstfmt),
+ if (ztc->chan_built == 0) {
+ if (st->encoder)
+ create_channel(wc, zapfmt_to_dtefmt(zth->srcfmt), zapfmt_to_dtefmt(zth->dstfmt),
st->timeslot_in_num, st->timeslot_out_num, &(st->chan_in_num), &(st->chan_out_num));
else
- wcdte_create_channel(wc, wcdte_zapfmt_to_dtefmt(zth->dstfmt), wcdte_zapfmt_to_dtefmt(zth->srcfmt),
+ create_channel(wc, zapfmt_to_dtefmt(zth->dstfmt), zapfmt_to_dtefmt(zth->srcfmt),
st->timeslot_out_num, st->timeslot_in_num, &(st->chan_out_num), &(st->chan_in_num));
/* Mark this channel as built */
ztc->chan_built = 1;
@@ -689,7 +648,7 @@
/* Mark the channel complement (other half of encoder/decoder pair) as built */
ndx = st->timeslot_in_num/2;
- if (st->encoder == 1)
+ if (st->encoder)
compl_ztc = &(wc->udecode->channels[ndx]);
else
compl_ztc = &(wc->uencode->channels[ndx]);
@@ -705,18 +664,17 @@
down(&wc->chansem);
ndx = st->timeslot_in_num/2;
- if (st->encoder == 1)
+ if (st->encoder)
compl_ztc = &(wc->udecode->channels[ndx]);
else
compl_ztc = &(wc->uencode->channels[ndx]);
/* If the channel complement (other half of the encoder/decoder pair) is not being used... */
- if ((compl_ztc->flags & ZT_TC_FLAG_BUSY) == 0)
- {
- if (st->encoder == 1)
- wcdte_destroy_channel(wc, st->chan_in_num, st->chan_out_num);
+ if ((compl_ztc->flags & ZT_TC_FLAG_BUSY) == 0) {
+ if (st->encoder)
+ destroy_channel(wc, st->chan_in_num, st->chan_out_num);
else
- wcdte_destroy_channel(wc, st->chan_out_num, st->chan_in_num);
+ destroy_channel(wc, st->chan_out_num, st->chan_in_num);
/* Mark this channel as not built */
ztc->chan_built = 0;
@@ -735,11 +693,11 @@
up(&wc->chansem);
break;
case ZT_TCOP_TRANSCODE:
-
- if ( (((zth->srcfmt == ZT_FORMAT_ULAW) || (zth->srcfmt == ZT_FORMAT_ALAW)) && ((zth->dstfmt == ZT_FORMAT_G729A && zth->srclen >= G729_SAMPLES) ||(zth->dstfmt == ZT_FORMAT_G723_1 && zth->srclen >= G723_SAMPLES)) )
- || ((zth->srcfmt == ZT_FORMAT_G729A) && (zth->srclen >= G729_BYTES))
- || ((zth->srcfmt == ZT_FORMAT_G723_1) && (zth->srclen >= G723_BYTES)) )
- {
+ if ((((zth->srcfmt == ZT_FORMAT_ULAW) || (zth->srcfmt == ZT_FORMAT_ALAW)) &&
+ ((zth->dstfmt == ZT_FORMAT_G729A && zth->srclen >= G729_SAMPLES) ||
+ (zth->dstfmt == ZT_FORMAT_G723_1 && zth->srclen >= G723_SAMPLES)))
+ || ((zth->srcfmt == ZT_FORMAT_G729A) && (zth->srclen >= G729_BYTES))
+ || ((zth->srcfmt == ZT_FORMAT_G723_1) && (zth->srclen >= G723_BYTES))) {
do
{
chars = (unsigned char *)(zth->srcdata + zth->srcoffset);
@@ -781,7 +739,7 @@
(inbytes+20) & 0xFF,
0x00,
0x00,
- wcdte_zapfmt_to_dtefmt(zth->srcfmt),
+ zapfmt_to_dtefmt(zth->srcfmt),
((st->seqno) >> 8) & 0xFF,
(st->seqno) & 0xFF,
((st->timestamp) >> 24) & 0xFF,
@@ -837,14 +795,13 @@
res = 0;
break;
}
+
return res;
}
-
-static void wcdte_stop_dma(struct wcdte *wc);
-
-
-static inline void wcdte_receiveprep(struct wcdte *wc, int dbl)
+static void stop_dma(struct wcdte *wc);
+
+static inline void receiveprep(struct wcdte *wc, int dbl)
{
volatile unsigned char *readchunk;
struct zt_transcoder_channel *ztc = NULL;
@@ -856,34 +813,30 @@
unsigned char *chars = NULL;
unsigned int ztc_ndx;
- readchunk = (volatile unsigned char *)wc->readchunk;
+ readchunk = (volatile unsigned char *) wc->readchunk;
readchunk += dbl * SFRAME_SIZE;
o2 = dbl * 4;
o2 += ERING_SIZE * 4;
- /* Control in packet */
- if ((readchunk[12] == 0x88) && (readchunk[13] == 0x9B))
- {
- if (debug_packets)
- {
+ if ((readchunk[12] == 0x88) && (readchunk[13] == 0x9B)) {
+ /* Control in packet */
+ if (debug_packets) {
printk("wcdte debug: RX: ");
- for (i=0; i<debug_packets; i++)
+ for (i = 0; i < debug_packets; i++)
printk("%02X ", readchunk[i]);
printk("\n");
}
/* See if message must be ACK'd */
- if ((readchunk[17] & 0xC0) == 0)
- {
+ if ((readchunk[17] & 0xC0) == 0) {
rcommand = readchunk[24] | (readchunk[25] << 8);
rchannel = readchunk[18] | (readchunk[19] << 8);
rseq = readchunk[16];
down(&wc->cmdqsem);
- if ( (((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx) && debug )
+ if ((((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx) && debug ) {
printk("wcdte error: cmdq is full (rndx = %d, wndx = %d).\n", wc->cmdq_rndx, wc->cmdq_wndx);
- else
- {
+ } else {
unsigned char fifo[OTHER_CMD_LEN] = CMD_MSG_ACK(rseq++, rchannel);
wc->cmdq[wc->cmdq_wndx].cmdlen = CMD_MSG_ACK_LEN;
@@ -893,25 +846,20 @@
}
__transmit_demand(wc);
-
wc->rcvflags = RCV_CSMENCAPS;
wc->last_rcommand = rcommand;
wc->last_rparm2 = readchunk[30] | (readchunk[31] << 8);
wake_up_interruptible(&wc->regq);
up(&wc->cmdqsem);
- }
- else
- {
+ } else {
wc->rcvflags = RCV_CSMENCAPS_ACK;
wake_up_interruptible(&wc->regq);
}
- }
-
- /* IP/UDP in packet */
- else if ((readchunk[12] == 0x08) && (readchunk[13] == 0x00)
- && (readchunk[50] == 0x12) && (readchunk[51] == 0x34) && (readchunk[52] = 0x56) && (readchunk[53] == 0x78))
- {
+ } else if ((readchunk[12] == 0x08) && (readchunk[13] == 0x00) &&
+ (readchunk[50] == 0x12) && (readchunk[51] == 0x34) &&
+ (readchunk[52] = 0x56) && (readchunk[53] == 0x78)) {
+ /* IP/UDP in packet */
rchannel = (readchunk[37] | (readchunk[36] << 8)) - 0x5000;
rlen = (readchunk[39] | (readchunk[38] << 8)) - 20;
rtp_rseq = (readchunk[45] | (readchunk[44] << 8));
@@ -919,21 +867,18 @@
ztc_ndx = rchannel/2;
- if (ztc_ndx >= wc->numchannels)
- {
+ if (ztc_ndx >= wc->numchannels) {
if (debug)
printk("wcdte error: Invalid channel number received (ztc_ndx = %d) (numchannels = %d)\n", ztc_ndx, wc->numchannels);
rcodec = DTE_FORMAT_UNDEF;
}
- if ((rcodec == 0x00) || (rcodec == 0x08)) /* ulaw or alaw (decoders) */
- {
+ if ((rcodec == 0x00) || (rcodec == 0x08)) { /* ulaw or alaw (decoders) */
ztc = &(wc->udecode->channels[ztc_ndx]);
zth = ztc->tch;
st = ztc->pvt;
- if (zth == NULL)
- {
+ if (zth == NULL) {
if (debug)
printk("wcdte error: Tried to put DTE data into a freed zth header!\n");
rcodec = DTE_FORMAT_UNDEF;
@@ -941,17 +886,14 @@
chars = (unsigned char *)(zth->dstdata + zth->dstoffset + zth->dstlen);
st->packets_received++;
}
-
}
- if ((rcodec == 0x04) || (rcodec == 0x12)) /* g.723 or g.729 (encoders) */
- {
+ if ((rcodec == 0x04) || (rcodec == 0x12)) { /* g.723 or g.729 (encoders) */
ztc = &(wc->uencode->channels[ztc_ndx]);
zth = ztc->tch;
st = ztc->pvt;
- if (zth == NULL)
- {
+ if (zth == NULL) {
if (debug)
printk("wcdte error: Tried to put DTE data into a freed zth header!\n");
rcodec = DTE_FORMAT_UNDEF;
@@ -962,8 +904,7 @@
}
- if (st->dte_seqno_rcv == 0)
- {
+ if (st->dte_seqno_rcv == 0) {
st->dte_seqno_rcv = 1;
st->last_dte_seqno = rtp_rseq;
} else {
@@ -974,9 +915,10 @@
st->last_dte_seqno = rtp_rseq;
}
- if (rcodec == 0x00) /* ulaw */
- {
- if (zt_tc_sanitycheck(zth, rlen) && ((zth->srcfmt == ZT_FORMAT_G729A && rlen == G729_SAMPLES) || (zth->srcfmt == ZT_FORMAT_G723_1 && rlen == G723_SAMPLES))) {
+ if (rcodec == 0x00) { /* ulaw */
+ if (zt_tc_sanitycheck(zth, rlen) &&
+ ((zth->srcfmt == ZT_FORMAT_G729A && rlen == G729_SAMPLES) ||
+ (zth->srcfmt == ZT_FORMAT_G723_1 && rlen == G723_SAMPLES))) {
for (i = 0; i < rlen; i++)
chars[i] = readchunk[i+54];
@@ -987,11 +929,10 @@
ztc->errorstatus = -EOVERFLOW;
}
zt_transcoder_alert(ztc);
- }
- else if (rcodec == 0x08) /* alaw */
- {
- if (zt_tc_sanitycheck(zth, rlen) && ((zth->srcfmt == ZT_FORMAT_G729A && rlen == G729_SAMPLES) || (zth->srcfmt == ZT_FORMAT_G723_1 && rlen == G723_SAMPLES))) {
-
+ } else if (rcodec == 0x08) { /* alaw */
+ if (zt_tc_sanitycheck(zth, rlen) &&
+ ((zth->srcfmt == ZT_FORMAT_G729A && rlen == G729_SAMPLES) ||
+ (zth->srcfmt == ZT_FORMAT_G723_1 && rlen == G723_SAMPLES))) {
for (i = 0; i < rlen; i++)
chars[i] = readchunk[i+54];
@@ -1002,54 +943,40 @@
ztc->errorstatus = -EOVERFLOW;
}
zt_transcoder_alert(ztc);
- }
- else if (rcodec == 0x04) /* g.723.1 */
- {
- if (zt_tc_sanitycheck(zth, rlen) && (rlen == G723_BYTES))
- {
+ } else if (rcodec == 0x04) { /* g.723.1 */
+ if (zt_tc_sanitycheck(zth, rlen) && (rlen == G723_BYTES)) {
for (i = 0; i < rlen; i++)
chars[i] = readchunk[i+54];
zth->dstlen += rlen;
zth->dstsamples = zth->dstlen * 12;
-
} else {
ztc->errorstatus = -EOVERFLOW;
}
- if (!(zth->dstsamples % G723_SAMPLES))
- {
+ if (!(zth->dstsamples % G723_SAMPLES)) {
+ zt_transcoder_alert(ztc);
+ }
+ } else if (rcodec == 0x12) { /* g.729a */
+ if (zt_tc_sanitycheck(zth, rlen) && (rlen == G729_BYTES)) {
+ for (i = 0; i < rlen; i++)
+ chars[i] = readchunk[i+54];
+
+ zth->dstlen += rlen;
+ zth->dstsamples = zth->dstlen * 8;
+ } else {
+ ztc->errorstatus = -EOVERFLOW;
+ }
+
+ if (!(zth->dstsamples % G729_SAMPLES)) {
zt_transcoder_alert(ztc);
}
}
- else if (rcodec == 0x12) /* g.729a */
- {
- if (zt_tc_sanitycheck(zth, rlen) && (rlen == G729_BYTES))
- {
- for (i = 0; i < rlen; i++)
- chars[i] = readchunk[i+54];
-
- zth->dstlen += rlen;
- zth->dstsamples = zth->dstlen * 8;
-
- } else {
- ztc->errorstatus = -EOVERFLOW;
- }
-
- if (!(zth->dstsamples % G729_SAMPLES))
- {
- zt_transcoder_alert(ztc);
- }
- }
- }
-}
-
-
-
-
-
-/* static inline int wcdte_check_descriptor(struct wcdte *wc) */
-static int wcdte_check_descriptor(struct wcdte *wc)
+ }
+}
+
+
+static int check_descriptor(struct wcdte *wc)
{
int o2 = 0;
@@ -1058,16 +985,17 @@
if (!(le32_to_cpu(wc->descripchunk[o2]) & 0x80000000)) {
wc->rxints++;
- wcdte_receiveprep(wc, wc->rdbl);
- wcdte_reinit_descriptor(wc, 0, wc->rdbl, "rxchk");
+ receiveprep(wc, wc->rdbl);
+ reinit_descriptor(wc, 0, wc->rdbl, "rxchk");
wc->rdbl = (wc->rdbl + 1) % ERING_SIZE;
return 1;
}
+
return 0;
}
-static void wcdte_init_descriptors(struct wcdte *wc)
+static void init_descriptors(struct wcdte *wc)
{
volatile unsigned int *descrip;
dma_addr_t descripdma;
@@ -1080,23 +1008,23 @@
writedma = wc->writedma;
readdma = wc->readdma;
- for (x=0;x<ERING_SIZE;x++) {
+ for (x = 0;x < ERING_SIZE; x++) {
if (x < ERING_SIZE - 1)
descripdma += 16;
else
descripdma = wc->descripdma;
/* Transmit descriptor */
- descrip[0 ] = cpu_to_le32(0x00000000);
- descrip[1 ] = cpu_to_le32(0xe5800000 | (SFRAME_SIZE));
- descrip[2 ] = cpu_to_le32(writedma + x*SFRAME_SIZE);
- descrip[3 ] = cpu_to_le32(descripdma);
+ descrip[0] = cpu_to_le32(0x00000000);
+ descrip[1] = cpu_to_le32(0xe5800000 | (SFRAME_SIZE));
+ descrip[2] = cpu_to_le32(writedma + x * SFRAME_SIZE);
+ descrip[3] = cpu_to_le32(descripdma);
/* Receive descriptor */
descrip[0 + ERING_SIZE * 4] = cpu_to_le32(0x80000000);
descrip[1 + ERING_SIZE * 4] = cpu_to_le32(0x01000000 | (SFRAME_SIZE));
- descrip[2 + ERING_SIZE * 4] = cpu_to_le32(readdma + x*SFRAME_SIZE);
- descrip[3 + ERING_SIZE * 4] = cpu_to_le32(descripdma + ERING_SIZE * 16);
+ descrip[2 + ERING_SIZE * 4] = cpu_to_le32(readdma + (x * SFRAME_SIZE));
+ descrip[3 + ERING_SIZE * 4] = cpu_to_le32(descripdma + (ERING_SIZE * 16));
/* Advance descriptor */
descrip += 4;
@@ -1109,28 +1037,25 @@
if (wc->wqueints & 0x00000040) {
/* Loop descriptors is available */
- do {
- res = wcdte_check_descriptor(wc);
- } while(res);
+ do {} while ((res = check_descriptor(wc)));
}
/* Handle TX interrupts */
- if (wc->wqueints & 0x00000001)
- {
+ if (wc->wqueints & 0x00000001) {
wc->txints++;
transmit_demand(wc);
wc->intcount++;
}
}
-static irqreturn_t wcdte_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+ZAP_IRQ_HANDLER(interrupt)
{
struct wcdte *wc = dev_id;
unsigned int ints;
/* Read and clear interrupts */
- ints = wcdte_getctl(wc, 0x0028);
- wcdte_setctl(wc, 0x0028, ints);
+ ints = getctl(wc, 0x0028);
+ setctl(wc, 0x0028, ints);
if (!ints)
return IRQ_NONE;
@@ -1142,122 +1067,118 @@
}
if ((ints & 0x00008000) && debug)
- printk("wcdte: Abnormal Interrupt: ");
+ printk("wctc4xxb: Abnormal Interrupt: ");
if ((ints & 0x00002000) && debug)
- printk("wcdte: Fatal Bus Error INT\n");
+ printk("wctc4xxb: Fatal Bus Error INT\n");
if ((ints & 0x00000100) && debug)
- printk("wcdte: Receive Stopped INT\n");
+ printk("wctc4xxb: Receive Stopped INT\n");
if ((ints & 0x00000080) && debug)
- printk("wcdte: Receive Desciptor Unavailable INT\n");
+ printk("wctc4xxb: Receive Desciptor Unavailable INT\n");
if ((ints & 0x00000020) && debug)
- printk("wcdte: Transmit Under-flow INT\n");
+ printk("wctc4xxb: Transmit Under-flow INT\n");
if ((ints & 0x00000008) && debug)
- printk("wcdte: Jabber Timer Time-out INT\n");
+ printk("wctc4xxb: Jabber Timer Time-out INT\n");
if ((ints & 0x00000004) && debug)
- printk("wcdte: Transmit Descriptor Unavailable INT\n");
+ printk("wctc4xxb: Transmit Descriptor Unavailable INT\n");
if ((ints & 0x00000002) && debug)
- printk("wcdte: Transmit Processor Stopped INT\n");
+ printk("wctc4xxb: Transmit Processor Stopped INT\n");
return IRQ_RETVAL(1);
-
-}
-
-
-static int wcdte_hardware_init(struct wcdte *wc)
+}
+
+
+static int hardware_init(struct wcdte *wc)
{
/* Hardware stuff */
unsigned int reg;
unsigned long newjiffies;
/* Initialize descriptors */
- wcdte_init_descriptors(wc);
+ init_descriptors(wc);
/* Enable I/O Access */
pci_read_config_dword(wc->dev, 0x0004, ®);
reg |= 0x00000007;
pci_write_config_dword(wc->dev, 0x0004, reg);
- wcdte_setctl(wc, 0x0000, 0xFFF88001);
+ setctl(wc, 0x0000, 0xFFF88001);
newjiffies = jiffies + HZ/10;
- while(((reg = wcdte_getctl(wc,0x0000)) & 0x00000001) && (newjiffies > jiffies));
-
+ while (((reg = getctl(wc,0x0000)) & 0x00000001) && (newjiffies > jiffies));
/* Configure watchdogs, access, etc */
- wcdte_setctl(wc, 0x0030, 0x00280048);
- wcdte_setctl(wc, 0x0078, 0x00000013 /* | (1 << 28) */);
-
- reg = wcdte_getctl(wc, 0x00fc);
- wcdte_setctl(wc, 0x00fc, (reg & ~0x7) | 0x7);
-
- reg = wcdte_getctl(wc, 0x00fc);
+ setctl(wc, 0x0030, 0x00280048);
+ setctl(wc, 0x0078, 0x00000013 /* | (1 << 28) */);
+
+ reg = getctl(wc, 0x00fc);
+ setctl(wc, 0x00fc, (reg & ~0x7) | 0x7);
+
+ reg = getctl(wc, 0x00fc);
return 0;
}
-static void wcdte_setintmask(struct wcdte *wc, unsigned int intmask)
+static inline void setintmask(struct wcdte *wc, unsigned int intmask)
{
wc->intmask = intmask;
- wcdte_setctl(wc, 0x0038, intmask);
-}
-
-static void wcdte_enable_interrupts(struct wcdte *wc)
+ setctl(wc, 0x0038, intmask);
+}
+
+static inline void enable_interrupts(struct wcdte *wc)
{
/* Enable interrupts */
if (!debug)
- wcdte_setintmask(wc, 0x00010041);
+ setintmask(wc, 0x00010041);
else
- wcdte_setintmask(wc, 0x0001A1EB);
-}
-
-
-static void wcdte_start_dma(struct wcdte *wc)
+ setintmask(wc, 0x0001A1EB);
+}
+
+static void start_dma(struct wcdte *wc)
{
unsigned int reg;
+
wmb();
- wcdte_setctl(wc, 0x0020, wc->descripdma);
- wcdte_setctl(wc, 0x0018, wc->descripdma + (16 * ERING_SIZE));
+ setctl(wc, 0x0020, wc->descripdma);
+ setctl(wc, 0x0018, wc->descripdma + (16 * ERING_SIZE));
/* Start receiver/transmitter */
- reg = wcdte_getctl(wc, 0x0030);
- wcdte_setctl(wc, 0x0030, reg | 0x00002002); /* Start XMT and RCD */
- wcdte_setctl(wc, 0x0010, 0x00000000); /* Receive Poll Demand */
- reg = wcdte_getctl(wc, 0x0028);
- wcdte_setctl(wc, 0x0028, reg);
-
-}
-
-static void wcdte_stop_dma(struct wcdte *wc)
-{
- /* Disable interrupts and reset */
+ reg = getctl(wc, 0x0030);
+ setctl(wc, 0x0030, reg | 0x00002002); /* Start XMT and RCD */
+ setctl(wc, 0x0010, 0x00000000); /* Receive Poll Demand */
+ reg = getctl(wc, 0x0028);
+ setctl(wc, 0x0028, reg);
+}
+
+static void stop_dma(struct wcdte *wc)
+{
unsigned int reg;
+
/* Disable interrupts */
- wcdte_setintmask(wc, 0x00000000);
- wcdte_setctl(wc, 0x0084, 0x00000000);
- wcdte_setctl(wc, 0x0048, 0x00000000);
+ setintmask(wc, 0x00000000);
+ setctl(wc, 0x0084, 0x00000000);
+ setctl(wc, 0x0048, 0x00000000);
/* Reset the part to be on the safe side */
- reg = wcdte_getctl(wc, 0x0000);
+ reg = getctl(wc, 0x0000);
reg |= 0x00000001;
- wcdte_setctl(wc, 0x0000, reg);
-}
-
-static void wcdte_disable_interrupts(struct wcdte *wc)
+ setctl(wc, 0x0000, reg);
+}
+
+static void disable_interrupts(struct wcdte *wc)
{
/* Disable interrupts */
- wcdte_setintmask(wc, 0x00000000);
- wcdte_setctl(wc, 0x0084, 0x00000000);
-}
-
-static int wcdte_waitfor_csmencaps(struct wcdte *wc, unsigned int mask, int use_mask)
+ setintmask(wc, 0x00000000);
+ setctl(wc, 0x0084, 0x00000000);
+}
+
+static int waitfor_csmencaps(struct wcdte *wc, unsigned int mask, int use_mask)
{
int ret;
-
if (use_mask)
ret = wait_event_interruptible_timeout(wc->regq, (wc->rcvflags == mask), wc->timeout);
@@ -1267,23 +1188,22 @@
wc->last_rcommand = 0;
wc->last_command_sent = 0;
- if (ret < 0)
- {
+ if (ret < 0) {
if (debug)
printk("wcdte error: Wait interrupted, need to stop boot (ret = %d)\n", ret);
- return(1);
- }
- if (ret == 0)
- {
+ return 1;
+ }
+
+ if (ret == 0) {
if (debug)
printk("wcdte error: Waitfor CSMENCAPS response timed out (ret = %d)\n", ret);
- return(2);
- }
- return(0);
-}
-
-
-static int wcdte_read_phy(struct wcdte *wc, int location)
+ return 2;
+ }
+
+ return 0;
+}
+
+static int read_phy(struct wcdte *wc, int location)
{
int i;
long mdio_addr = 0x0048;
@@ -1292,35 +1212,35 @@
/* Establish sync by sending at least 32 logic ones. */
for (i = 32; i >= 0; i--) {
- wcdte_setctl(wc, mdio_addr, MDIO_ENB | MDIO_DATA_WRITE1);
- wcdte_getctl(wc, mdio_addr);
- wcdte_setctl(wc, mdio_addr, MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK);
- wcdte_getctl(wc, mdio_addr);
+ setctl(wc, mdio_addr, MDIO_ENB | MDIO_DATA_WRITE1);
+ getctl(wc, mdio_addr);
+ setctl(wc, mdio_addr, MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK);
+ getctl(wc, mdio_addr);
}
/* Shift the read command bits out. */
for (i = 17; i >= 0; i--) {
int dataval = (read_cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
- wcdte_setctl(wc, mdio_addr, MDIO_ENB | dataval);
- wcdte_getctl(wc, mdio_addr);
- wcdte_setctl(wc, mdio_addr, MDIO_ENB | dataval | MDIO_SHIFT_CLK);
- wcdte_getctl(wc, mdio_addr);
+ setctl(wc, mdio_addr, MDIO_ENB | dataval);
+ getctl(wc, mdio_addr);
+ setctl(wc, mdio_addr, MDIO_ENB | dataval | MDIO_SHIFT_CLK);
+ getctl(wc, mdio_addr);
}
/* Read the two transition, 16 data, and wire-idle bits. */
for (i = 19; i > 0; i--) {
- wcdte_setctl(wc, mdio_addr, MDIO_ENB_IN);
- wcdte_getctl(wc, mdio_addr);
- retval = (retval << 1) | ((wcdte_getctl(wc, mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
- wcdte_setctl(wc, mdio_addr, MDIO_ENB_IN | MDIO_SHIFT_CLK);
- wcdte_getctl(wc, mdio_addr);
- }
- retval = (retval>>1) & 0xffff;
+ setctl(wc, mdio_addr, MDIO_ENB_IN);
+ getctl(wc, mdio_addr);
+ retval = (retval << 1) | ((getctl(wc, mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
+ setctl(wc, mdio_addr, MDIO_ENB_IN | MDIO_SHIFT_CLK);
+ getctl(wc, mdio_addr);
+ }
+ retval = (retval >> 1) & 0xffff;
+
return retval;
}
-
-void wcdte_write_phy(struct wcdte *wc, int location, int value)
+void write_phy(struct wcdte *wc, int location, int value)
{
int i;
int cmd = (0x5002 << 16) | (1 << 23) | (location<<18) | value;
@@ -1328,88 +1248,78 @@
/* Establish sync by sending 32 logic ones. */
for (i = 32; i >= 0; i--) {
- wcdte_setctl(wc, mdio_addr, MDIO_ENB | MDIO_DATA_WRITE1);
- wcdte_getctl(wc, mdio_addr);
- wcdte_setctl(wc, mdio_addr, MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK);
- wcdte_getctl(wc, mdio_addr);
+ setctl(wc, mdio_addr, MDIO_ENB | MDIO_DATA_WRITE1);
+ getctl(wc, mdio_addr);
+ setctl(wc, mdio_addr, MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK);
+ getctl(wc, mdio_addr);
}
/* Shift the command bits out. */
for (i = 31; i >= 0; i--) {
int dataval = (cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
- wcdte_setctl(wc, mdio_addr, MDIO_ENB | dataval);
- wcdte_getctl(wc, mdio_addr);
- wcdte_setctl(wc, mdio_addr, MDIO_ENB | dataval | MDIO_SHIFT_CLK);
- wcdte_getctl(wc, mdio_addr);
+ setctl(wc, mdio_addr, MDIO_ENB | dataval);
+ getctl(wc, mdio_addr);
+ setctl(wc, mdio_addr, MDIO_ENB | dataval | MDIO_SHIFT_CLK);
+ getctl(wc, mdio_addr);
}
/* Clear out extra bits. */
for (i = 2; i > 0; i--) {
- wcdte_setctl(wc, mdio_addr, MDIO_ENB_IN);
- wcdte_getctl(wc, mdio_addr);
- wcdte_setctl(wc, mdio_addr, MDIO_ENB_IN | MDIO_SHIFT_CLK);
- wcdte_getctl(wc, mdio_addr);
+ setctl(wc, mdio_addr, MDIO_ENB_IN);
+ getctl(wc, mdio_addr);
+ setctl(wc, mdio_addr, MDIO_ENB_IN | MDIO_SHIFT_CLK);
+ getctl(wc, mdio_addr);
}
return;
}
-#ifdef HOTPLUG_FIRMWARE
-static int wcdte_boot_processor(struct wcdte *wc, const struct firmware *firmware)
-#else
-static int wcdte_boot_processor(struct wcdte *wc)
-#endif
+static int boot_processor(struct wcdte *wc, const struct firmware *firmware)
{
int i, j, byteloc, last_byteloc, length, delay_count;
unsigned int reg, ret;
-#ifndef USE_TEST_HW
+#if !defined(USE_TEST_HW)
/* Turn off auto negotiation */
- wcdte_write_phy(wc, 0, 0x2100);
+ write_phy(wc, 0, 0x2100);
if (debug)
- printk("wcdte: PHY register 0 = %X", wcdte_read_phy(wc, 0));
+ printk("wctc4xxb: PHY register 0 = %X", read_phy(wc, 0));
/* Set reset */
- wcdte_setctl(wc, 0x00A0, 0x04000000);
+ setctl(wc, 0x00A0, 0x04000000);
/* Wait 1000msec to ensure processor reset */
mdelay(1000);
/* Clear reset */
- wcdte_setctl(wc, 0x00A0, 0x04080000);
+ setctl(wc, 0x00A0, 0x04080000);
/* Waitfor ethernet link */
delay_count = 0;
- do
- {
- reg = wcdte_getctl(wc, 0x00fc);
+ do {
+ reg = getctl(wc, 0x00fc);
mdelay(100);
delay_count++;
- if (delay_count >= 100)
- {
+ if (delay_count >= 100) {
printk("wcdte error: Failed to link to DTE processor!\n");
return(1);
}
} while ((reg & 0xE0000000) != 0xE0000000);
-
/* Turn off booted LED */
- wcdte_setctl(wc, 0x00A0, 0x04084000);
-
-
-#endif
-
- reg = wcdte_getctl(wc, 0x00fc);
+ setctl(wc, 0x00A0, 0x04084000);
+#endif /* !defined(USE_TEST_HW) */
+
+ reg = getctl(wc, 0x00fc);
if (debug)
- printk("wcdte: LINK STATUS: reg(0xfc) = %X\n", reg);
-
- reg = wcdte_getctl(wc, 0x00A0);
+ printk("wctc4xxb: LINK STATUS: reg(0xfc) = %X\n", reg);
+
+ reg = getctl(wc, 0x00A0);
byteloc = 17;
j = 0;
-#ifdef HOTPLUG_FIRMWARE
- do
- {
+
+ do {
last_byteloc = byteloc;
-
+
length = (firmware->data[byteloc] << 8) |firmware->data[byteloc+1];
byteloc += 2;
@@ -1423,91 +1333,63 @@
wc->cmdq[wc->cmdq_wndx].cmd[i] = firmware->data[byteloc++];
wc->cmdq_wndx = (wc->cmdq_wndx + 1) % MAX_COMMANDS;
}
-
+
__transmit_demand(wc);
- up(&wc->cmdqsem);
-
- ret = wcdte_waitfor_csmencaps(wc, RCV_CSMENCAPS_ACK, 1);
+ up(&wc->cmdqsem);
+
+ ret = waitfor_csmencaps(wc, RCV_CSMENCAPS_ACK, 1);
if (ret == 1)
return(1);
else if (ret == 2) /* Retransmit if dte processor times out */
byteloc = last_byteloc;
j++;
-
+
} while (byteloc < firmware->size-20);
-#else
- do
- {
- last_byteloc = byteloc;
-
- length = (_binary_wctc4xxb_firm_bin_start[byteloc] << 8) | _binary_dte_firm_ima_start[byteloc+1];
- byteloc += 2;
-
- down(&wc->cmdqsem);
- if ( (((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx) && debug )
- printk("wcdte error: cmdq is full.\n");
- else
- {
- wc->cmdq[wc->cmdq_wndx].cmdlen = length;
- for (i = 0; i < length; i++)
- wc->cmdq[wc->cmdq_wndx].cmd[i] = _binary_wctc4xxb_firm_bin_start[byteloc++];
- wc->cmdq_wndx = (wc->cmdq_wndx + 1) % MAX_COMMANDS;
- }
-
- __transmit_demand(wc);
- up(&wc->cmdqsem);
-
- ret = wcdte_waitfor_csmencaps(wc, RCV_CSMENCAPS_ACK, 1);
- if (ret == 1)
- return(1);
- else if (ret == 2) /* Retransmit if dte processor times out */
- byteloc = last_byteloc;
- j++;
-
- } while (byteloc < _binary_wctc4xxb_firm_bin_size-20);
-#endif
+
wc->timeout = 10 * HZ;
- if (wcdte_waitfor_csmencaps(wc, RCV_CSMENCAPS, 1))
- return(1);
+ if (waitfor_csmencaps(wc, RCV_CSMENCAPS, 1))
+ return 1;
/* Turn on booted LED */
- wcdte_setctl(wc, 0x00A0, 0x04080000);
- if(debug)
- printk("wcdte: Successfully booted DTE processor.\n");
+ setctl(wc, 0x00A0, 0x04080000);
+ if (debug)
+ printk("wctc4xxb: Successfully booted DTE processor.\n");
return(0);
}
-static int wcdte_create_channel(struct wcdte *wc, int simple, int complicated, int part1_id, int part2_id, unsigned int *dte_chan1, unsigned int *dte_chan2)
+static int create_channel(struct wcdte *wc, int simple, int complicated, int part1_id,
+ int part2_id, unsigned int *dte_chan1, unsigned int *dte_chan2)
{
int length = 0;
unsigned char chan1, chan2;
- if(complicated == DTE_FORMAT_G729A)
+
+ if (complicated == DTE_FORMAT_G729A)
length = G729_LENGTH;
else if (complicated == DTE_FORMAT_G723_1)
length = G723_LENGTH;
/* Create complex channel */
- zt_send_cmd(wc, CMD_MSG_CREATE_CHANNEL(wc->seq_num++, part1_id), CMD_MSG_CREATE_CHANNEL_LEN, 0x0010);
+ send_cmd(wc, CMD_MSG_CREATE_CHANNEL(wc->seq_num++, part1_id), CMD_MSG_CREATE_CHANNEL_LEN, 0x0010);
chan1 = wc->last_rparm2;
/* Create simple channel */
- zt_send_cmd(wc, CMD_MSG_CREATE_CHANNEL(wc->seq_num++, part2_id), CMD_MSG_CREATE_CHANNEL_LEN, 0x0010);
+ send_cmd(wc, CMD_MSG_CREATE_CHANNEL(wc->seq_num++, part2_id), CMD_MSG_CREATE_CHANNEL_LEN, 0x0010);
chan2 = wc->last_rparm2;
/* Configure complex channel */
- zt_send_cmd(wc, CMD_MSG_SET_IP_HDR_CHANNEL(wc->seq_num++, chan1, part2_id, part1_id), CMD_MSG_SET_IP_HDR_CHANNEL_LEN, 0x9000);
- zt_send_cmd(wc, CMD_MSG_VOIP_VCEOPT(wc->seq_num++, chan1, length, 0), CMD_MSG_VOIP_VCEOPT_LEN, 0x8001);
+ send_cmd(wc, CMD_MSG_SET_IP_HDR_CHANNEL(wc->seq_num++, chan1, part2_id, part1_id), CMD_MSG_SET_IP_HDR_CHANNEL_LEN, 0x9000);
+ send_cmd(wc, CMD_MSG_VOIP_VCEOPT(wc->seq_num++, chan1, length, 0), CMD_MSG_VOIP_VCEOPT_LEN, 0x8001);
/* Configure simple channel */
- zt_send_cmd(wc, CMD_MSG_SET_IP_HDR_CHANNEL(wc->seq_num++, chan2, part1_id, part2_id), CMD_MSG_SET_IP_HDR_CHANNEL_LEN, 0x9000);
- zt_send_cmd(wc, CMD_MSG_VOIP_VCEOPT(wc->seq_num++, chan2, length, 0), CMD_MSG_VOIP_VCEOPT_LEN, 0x8001);
-
- zt_send_cmd(wc, CMD_MSG_TRANS_CONNECT(wc->seq_num++, 1, chan1, chan2, complicated, simple), CMD_MSG_TRANS_CONNECT_LEN, 0x9322);
- zt_send_cmd(wc, CMD_MSG_VOIP_INDCTRL(wc->seq_num++, chan1), CMD_MSG_VOIP_INDCTRL_LEN, 0x8084);
- zt_send_cmd(wc, CMD_MSG_VOIP_INDCTRL(wc->seq_num++, chan2), CMD_MSG_VOIP_INDCTRL_LEN, 0x8084);
- zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA(wc->seq_num++, chan1, complicated), CMD_MSG_VOIP_VOPENA_LEN, 0x8000);
- zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA(wc->seq_num++, chan2, simple), CMD_MSG_VOIP_VOPENA_LEN, 0x8000);
+ send_cmd(wc, CMD_MSG_SET_IP_HDR_CHANNEL(wc->seq_num++, chan2, part1_id, part2_id), CMD_MSG_SET_IP_HDR_CHANNEL_LEN, 0x9000);
+ send_cmd(wc, CMD_MSG_VOIP_VCEOPT(wc->seq_num++, chan2, length, 0), CMD_MSG_VOIP_VCEOPT_LEN, 0x8001);
+
+ send_cmd(wc, CMD_MSG_TRANS_CONNECT(wc->seq_num++, 1, chan1, chan2, complicated, simple), CMD_MSG_TRANS_CONNECT_LEN, 0x9322);
+ send_cmd(wc, CMD_MSG_VOIP_INDCTRL(wc->seq_num++, chan1), CMD_MSG_VOIP_INDCTRL_LEN, 0x8084);
+ send_cmd(wc, CMD_MSG_VOIP_INDCTRL(wc->seq_num++, chan2), CMD_MSG_VOIP_INDCTRL_LEN, 0x8084);
+ send_cmd(wc, CMD_MSG_VOIP_VOPENA(wc->seq_num++, chan1, complicated), CMD_MSG_VOIP_VOPENA_LEN, 0x8000);
+ send_cmd(wc, CMD_MSG_VOIP_VOPENA(wc->seq_num++, chan2, simple), CMD_MSG_VOIP_VOPENA_LEN, 0x8000);
*dte_chan1 = chan1;
*dte_chan2 = chan2;
@@ -1515,379 +1397,345 @@
return 1;
}
-
-static int wcdte_destroy_channel(struct wcdte *wc, unsigned int chan1, unsigned int chan2)
-{
-
+static int destroy_channel(struct wcdte *wc, unsigned int chan1, unsigned int chan2)
+{
/* Turn off both channels */
- zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA_CLOSE(wc->seq_num++, chan1), CMD_MSG_VOIP_VOPENA_CLOSE_LEN, 0x8000);
- zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA_CLOSE(wc->seq_num++, chan2), CMD_MSG_VOIP_VOPENA_CLOSE_LEN, 0x8000);
+ send_cmd(wc, CMD_MSG_VOIP_VOPENA_CLOSE(wc->seq_num++, chan1), CMD_MSG_VOIP_VOPENA_CLOSE_LEN, 0x8000);
+ send_cmd(wc, CMD_MSG_VOIP_VOPENA_CLOSE(wc->seq_num++, chan2), CMD_MSG_VOIP_VOPENA_CLOSE_LEN, 0x8000);
/* Disconnect the channels */
[... 713 lines stripped ...]
More information about the zaptel-commits
mailing list