summaryrefslogtreecommitdiff
path: root/wctc4xxp
diff options
context:
space:
mode:
authormattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-11-21 22:45:32 +0000
committermattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-11-21 22:45:32 +0000
commit54a03c0ce0a011b0f7d942b0f609304976b49def (patch)
treed1a9b6a57c17d4aee29fcab9fbe8bed0dd3a19be /wctc4xxp
parent6e984ea25619a9abf5400c8aa38b5105d3b0a039 (diff)
Transcoder driver updates. Fixes G.723 no audio issues with latest drivers
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@3241 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'wctc4xxp')
-rw-r--r--wctc4xxp/base.c120
1 files changed, 47 insertions, 73 deletions
diff --git a/wctc4xxp/base.c b/wctc4xxp/base.c
index 0bb4be2..2f20623 100644
--- a/wctc4xxp/base.c
+++ b/wctc4xxp/base.c
@@ -313,12 +313,7 @@ extern void _binary_tc400m_firmware_bin_size;
else { \
ret = wcdte_waitfor_csmencaps(wc, RCV_CSMENCAPS, 0); \
if (wc->dsp_crashed) \
- { \
- printk("Aborting zt_send_cmd()\n"); \
return 1; \
- } \
- if ((ret == 2) && (wc->last_command_sent == 0x0010)) \
- printk("Detected timeout on 0x0010\n"); \
} \
if (ret == 1) \
return(1); \
@@ -444,12 +439,9 @@ static int debug_notimeout = 0;
static char *mode;
static int debug_packets = 0;
-static int wcdte_create_channel(struct wcdte *wc, int part1_id, int part2_id, unsigned int *dte_chan1, unsigned int *dte_chan2);
-static int wcdte_open_channel(struct wcdte *wc, int simple, int complicated, int part1_id, int part2_id, int chan1, int chan2);
+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 wcdte_close_channel(struct wcdte *wc, unsigned int chan1, unsigned int chan2);
static int __wcdte_setup_channels(struct wcdte *wc);
-static void wcdte_release(struct wcdte *wc);
static int __dump_descriptors(struct wcdte *wc)
{
@@ -702,34 +694,17 @@ static int dte_operation(struct zt_transcoder_channel *ztc, int op)
int i = 0;
int res = 0;
unsigned int ipchksum, ndx;
-
switch(op) {
- case ZT_TCOP_ALLOCATE:
+ case ZT_TCOP_ALLOCATE:
down(&wc->chansem);
- if (ztc->chan_built == 0) {
- if (ztc->built_fmts == (zth->dstfmt | zth->srcfmt)) {
- ztc->chan_built = 1;
- st->ssrc += 1;
- } else {
- /* If channel is built for the wrong codecs, teardown and rebuild */
- if (st->encoder == 1) {
- if (st->chan_in_num != 999) {
- wcdte_close_channel(wc, st->chan_in_num, st->chan_out_num);
- wcdte_destroy_channel(wc, st->chan_in_num, st->chan_out_num);
- }
- wcdte_create_channel(wc, st->timeslot_in_num, st->timeslot_out_num, &(st->chan_in_num), &(st->chan_out_num));
- wcdte_open_channel(wc, wcdte_zapfmt_to_dtefmt(zth->srcfmt), wcdte_zapfmt_to_dtefmt(zth->dstfmt),
- st->timeslot_in_num, st->timeslot_out_num, st->chan_in_num, st->chan_out_num);
- } else {
- if (st->chan_in_num != 999) {
- wcdte_close_channel(wc, st->chan_out_num, st->chan_in_num);
- wcdte_destroy_channel(wc, st->chan_out_num, st->chan_in_num);
- }
- wcdte_create_channel(wc, st->timeslot_out_num, st->timeslot_in_num, &(st->chan_out_num), &(st->chan_in_num));
- wcdte_open_channel(wc, wcdte_zapfmt_to_dtefmt(zth->srcfmt), wcdte_zapfmt_to_dtefmt(zth->dstfmt),
- st->timeslot_out_num, st->timeslot_in_num, st->chan_out_num, st->chan_in_num);
- }
- }
+ 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),
+ 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),
+ 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;
ztc->built_fmts = zth->dstfmt | zth->srcfmt;
@@ -740,9 +715,9 @@ static int dte_operation(struct zt_transcoder_channel *ztc, int op)
compl_ztc = &(wc->udecode->channels[ndx]);
else
compl_ztc = &(wc->uencode->channels[ndx]);
- compl_st = compl_ztc->pvt;
compl_ztc->chan_built = 1;
compl_ztc->built_fmts = zth->dstfmt | zth->srcfmt;
+ compl_st = compl_ztc->pvt;
compl_st->chan_in_num = st->chan_out_num;
compl_st->chan_out_num = st->chan_in_num;
}
@@ -757,15 +732,28 @@ static int dte_operation(struct zt_transcoder_channel *ztc, int op)
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);
+ else
+ wcdte_destroy_channel(wc, st->chan_out_num, st->chan_in_num);
+
/* Mark this channel as not built */
ztc->chan_built = 0;
-
+ ztc->built_fmts = 0;
+ st->chan_in_num = 999;
+ st->chan_out_num = 999;
+
/* Mark the channel complement as not built */
compl_ztc->chan_built = 0;
+ compl_ztc->built_fmts = 0;
+ compl_st = compl_ztc->pvt;
+ compl_st->chan_in_num = 999;
+ compl_st->chan_out_num = 999;
}
-
+ st->dte_seqno_rcv = 0;
up(&wc->chansem);
break;
case ZT_TCOP_TRANSCODE:
@@ -1114,6 +1102,9 @@ static inline void wcdte_receiveprep(struct wcdte *wc, int dbl)
}
+
+
+
/* static inline int wcdte_check_descriptor(struct wcdte *wc) */
static int wcdte_check_descriptor(struct wcdte *wc)
{
@@ -1529,10 +1520,16 @@ static int wcdte_boot_processor(struct wcdte *wc, const struct firmware *firmwar
return(0);
}
-
-static int wcdte_create_channel(struct wcdte *wc, int part1_id, int part2_id, unsigned int *dte_chan1, unsigned int *dte_chan2)
+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)
{
+ int length = 0;
unsigned char chan1, chan2;
+ struct zt_transcoder_channel *ztc1, *ztc2;
+ struct dte_state *st1, *st2;
+ 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);
@@ -1544,32 +1541,11 @@ static int wcdte_create_channel(struct wcdte *wc, int part1_id, int part2_id, un
zt_send_cmd(wc, CMD_MSG_QUERY_CHANNEL(wc->seq_num++, part2_id), CMD_MSG_QUERY_CHANNEL_LEN, 0x0010);
chan2 = wc->last_rparm1;
- *dte_chan1 = chan1;
- *dte_chan2 = chan2;
-
- return 0;
-}
-
-static int wcdte_open_channel(struct wcdte *wc, int simple, int complicated, int part1_id, int part2_id, int chan1, int chan2)
-{
- int length = 0;
- struct zt_transcoder_channel *ztc1, *ztc2;
- struct dte_state *st1, *st2;
- if(complicated == DTE_FORMAT_G729A)
- length = G729_LENGTH;
- else if (complicated == DTE_FORMAT_G723_1)
- length = G723_LENGTH;
-
ztc1 = &(wc->uencode->channels[part1_id/2]);
ztc2 = &(wc->udecode->channels[part2_id/2]);
st1 = ztc1->pvt;
st2 = ztc2->pvt;
- if (force_alert) {
- printk("Sending FORCE ALERT\n");
- zt_send_cmd(wc, CMD_MSG_FORCE_ALERT(wc->seq_num++), CMD_MSG_FORCE_ALERT_LEN, 0xFFFF);
- }
-
/* Configure complex channel */
zt_send_cmd(wc, CMD_MSG_SET_IP_HDR_CHANNEL(st1->cmd_seqno++, chan1, part2_id, part1_id), CMD_MSG_SET_IP_HDR_CHANNEL_LEN, 0x9000);
zt_send_cmd(wc, CMD_MSG_VOIP_VCEOPT(st1->cmd_seqno++, chan1, length, 0), CMD_MSG_VOIP_VCEOPT_LEN, 0x8001);
@@ -1591,19 +1567,13 @@ static int wcdte_open_channel(struct wcdte *wc, int simple, int complicated, int
zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA(st1->cmd_seqno++, chan1, complicated), CMD_MSG_VOIP_VOPENA_LEN, 0x8000);
zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA(st2->cmd_seqno++, chan2, simple), CMD_MSG_VOIP_VOPENA_LEN, 0x8000);
- return 0;
-}
-
-static int wcdte_destroy_channel(struct wcdte *wc, unsigned int chan1, unsigned int chan2)
-{
- /* Remove the channels */
- zt_send_cmd(wc, CMD_MSG_DESTROY_CHANNEL(wc->seq_num++, chan1), CMD_MSG_DESTROY_CHANNEL_LEN, 0x0011);
- zt_send_cmd(wc, CMD_MSG_DESTROY_CHANNEL(wc->seq_num++, chan2), CMD_MSG_DESTROY_CHANNEL_LEN, 0x0011);
+ *dte_chan1 = chan1;
+ *dte_chan2 = chan2;
- return 0;
+ return 1;
}
-static int wcdte_close_channel(struct wcdte *wc, unsigned int chan1, unsigned int chan2)
+static int wcdte_destroy_channel(struct wcdte *wc, unsigned int chan1, unsigned int chan2)
{
struct zt_transcoder_channel *ztc1, *ztc2;
struct dte_state *st1, *st2;
@@ -1620,7 +1590,11 @@ static int wcdte_close_channel(struct wcdte *wc, unsigned int chan1, unsigned in
/* Disconnect the channels */
zt_send_cmd(wc, CMD_MSG_TRANS_CONNECT(wc->seq_num++, 0, chan1, chan2, 0, 0), CMD_MSG_TRANS_CONNECT_LEN, 0x9322);
- return 0;
+ /* Remove the channels */
+ zt_send_cmd(wc, CMD_MSG_DESTROY_CHANNEL(wc->seq_num++, chan1), CMD_MSG_DESTROY_CHANNEL_LEN, 0x0011);
+ zt_send_cmd(wc, CMD_MSG_DESTROY_CHANNEL(wc->seq_num++, chan2), CMD_MSG_DESTROY_CHANNEL_LEN, 0x0011);
+
+ return 1;
}