[dahdi-commits] kpfleming: branch linux/kpfleming/echocan_work r6440 - in /linux/team/kpflemi...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Tue Apr 21 18:26:12 CDT 2009
Author: kpfleming
Date: Tue Apr 21 18:26:09 2009
New Revision: 6440
URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=6440
Log:
add ability to put a channel's echo canceller into and back out of FAX mode
Modified:
linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c
linux/team/kpfleming/echocan_work/include/dahdi/user.h
Modified: linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c?view=diff&rev=6440&r1=6439&r2=6440
==============================================================================
--- linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c Tue Apr 21 18:26:09 2009
@@ -4970,20 +4970,41 @@
return ret;
}
-static void set_echocan_fax_mode(struct dahdi_chan *chan, unsigned int channo, const char *reason)
-{
- if (chan->ec_state->features.NLP_toggle) {
- module_printk(KERN_NOTICE, "Disabled echo canceller NLP because of %s on channel %d\n", reason, channo);
- dahdi_qevent_nolock(chan, DAHDI_EVENT_EC_NLP_DISABLED);
- chan->ec_state->ops->echocan_NLP_toggle(chan->ec_state, 0);
- chan->ec_state->status.mode = ECHO_MODE_FAX;
+static void set_echocan_fax_mode(struct dahdi_chan *chan, unsigned int channo, const char *reason, unsigned int enable)
+{
+ if (enable) {
+ if (!chan->ec_state)
+ module_printk(KERN_NOTICE, "Ignoring FAX mode request because of %s for channel %d with no echo canceller\n", reason, channo);
+ else if (chan->ec_state->status.mode == ECHO_MODE_FAX)
+ module_printk(KERN_NOTICE, "Ignoring FAX mode request because of %s for echo canceller already in FAX mode on channel %d\n", reason, channo);
+ else if (chan->ec_state->status.mode != ECHO_MODE_ACTIVE)
+ module_printk(KERN_NOTICE, "Ignoring FAX mode request because of %s for echo canceller not in active mode on channel %d\n", reason, channo);
+ else if (chan->ec_state->features.NLP_toggle) {
+ module_printk(KERN_NOTICE, "Disabled echo canceller NLP because of %s on channel %d\n", reason, channo);
+ dahdi_qevent_nolock(chan, DAHDI_EVENT_EC_NLP_DISABLED);
+ chan->ec_state->ops->echocan_NLP_toggle(chan->ec_state, 0);
+ chan->ec_state->status.mode = ECHO_MODE_FAX;
+ } else {
+ module_printk(KERN_NOTICE, "Idled echo canceller because of %s on channel %d\n", reason, channo);
+ chan->ec_state->status.mode = ECHO_MODE_IDLE;
+ }
} else {
- module_printk(KERN_NOTICE, "Disabled echo canceller because of %s on channel %d\n", reason, channo);
- dahdi_qevent_nolock(chan, DAHDI_EVENT_EC_DISABLED);
- chan->ec_state->ops->echocan_free(chan->ec_state);
- chan->ec_state = NULL;
- release_echocan(chan->ec_current);
- chan->ec_current = NULL;
+ if (!chan->ec_state)
+ module_printk(KERN_NOTICE, "Ignoring voice mode request because of %s for channel %d with no echo canceller\n", reason, channo);
+ else if (chan->ec_state->status.mode == ECHO_MODE_ACTIVE)
+ module_printk(KERN_NOTICE, "Ignoring voice mode request because of %s for echo canceller already in voice mode on channel %d\n", reason, channo);
+ else if ((chan->ec_state->status.mode != ECHO_MODE_FAX) &&
+ (chan->ec_state->status.mode != ECHO_MODE_IDLE))
+ module_printk(KERN_NOTICE, "Ignoring voice mode request because of %s for echo canceller not in FAX or idle mode on channel %d\n", reason, channo);
+ else if (chan->ec_state->features.NLP_toggle) {
+ module_printk(KERN_NOTICE, "Enabled echo canceller NLP because of %s on channel %d\n", reason, channo);
+ dahdi_qevent_nolock(chan, DAHDI_EVENT_EC_NLP_ENABLED);
+ chan->ec_state->ops->echocan_NLP_toggle(chan->ec_state, 1);
+ chan->ec_state->status.mode = ECHO_MODE_ACTIVE;
+ } else {
+ module_printk(KERN_NOTICE, "Activated echo canceller because of %s on channel %d\n", reason, channo);
+ chan->ec_state->status.mode = ECHO_MODE_ACTIVE;
+ }
}
}
@@ -5221,8 +5242,9 @@
if (!chan->ec_state) {
return -EINVAL;
} else {
+ get_user(j, (int *) data);
spin_lock_irqsave(&chan->lock, flags);
- set_echocan_fax_mode(chan, chan->channo, "ioctl");
+ set_echocan_fax_mode(chan, chan->channo, "ioctl", j ? 1 : 0);
spin_unlock_irqrestore(&chan->lock, flags);
}
break;
@@ -5761,7 +5783,7 @@
if (ms->ec_state && (ms->ec_state->status.mode == ECHO_MODE_ACTIVE) && !ms->ec_state->features.CED_tx_detect) {
for (x = 0; x < DAHDI_CHUNKSIZE; x++) {
if (echo_can_disable_detector_update(&ms->ec_state->txecdis, getlin[x])) {
- set_echocan_fax_mode(ms, ss->channo, "CED tx detected");
+ set_echocan_fax_mode(ms, ss->channo, "CED tx detected", 1);
dahdi_qevent_nolock(ms, DAHDI_EVENT_TX_CED_DETECTED);
break;
}
@@ -6559,32 +6581,28 @@
if (events.CED_tx_detected) {
dahdi_qevent_nolock(chan, DAHDI_EVENT_TX_CED_DETECTED);
if (chan->ec_state) {
- if (chan->ec_state->status.mode == ECHO_MODE_ACTIVE) {
- set_echocan_fax_mode(chan, chan->channo, "CED tx detected");
- } else {
+ if (chan->ec_state->status.mode == ECHO_MODE_ACTIVE)
+ set_echocan_fax_mode(chan, chan->channo, "CED tx detected", 1);
+ else
module_printk(KERN_NOTICE, "Detected CED tone (tx) on channel %d\n", chan->channo);
- }
}
}
if (events.CED_rx_detected) {
dahdi_qevent_nolock(chan, DAHDI_EVENT_RX_CED_DETECTED);
if (chan->ec_state) {
- if (chan->ec_state->status.mode == ECHO_MODE_ACTIVE) {
- set_echocan_fax_mode(chan, chan->channo, "CED rx detected");
- } else {
+ if (chan->ec_state->status.mode == ECHO_MODE_ACTIVE)
+ set_echocan_fax_mode(chan, chan->channo, "CED rx detected", 1);
+ else
module_printk(KERN_NOTICE, "Detected CED tone (rx) on channel %d\n", chan->channo);
- }
- }
- }
-
- if (events.CNG_tx_detected) {
+ }
+ }
+
+ if (events.CNG_tx_detected)
dahdi_qevent_nolock(chan, DAHDI_EVENT_TX_CNG_DETECTED);
- }
-
- if (events.CNG_rx_detected) {
+
+ if (events.CNG_rx_detected)
dahdi_qevent_nolock(chan, DAHDI_EVENT_RX_CNG_DETECTED);
- }
if (events.NLP_auto_disabled) {
dahdi_qevent_nolock(chan, DAHDI_EVENT_EC_NLP_DISABLED);
@@ -6643,8 +6661,9 @@
rxlin = 0;
rxchunk[x] = DAHDI_LIN2X((int)rxlin, ss);
}
- } else {
+ } else if (ss->ec_state->status.mode != ECHO_MODE_IDLE) {
short rxlins[DAHDI_CHUNKSIZE], txlins[DAHDI_CHUNKSIZE];
+
for (x = 0; x < DAHDI_CHUNKSIZE; x++) {
rxlins[x] = DAHDI_XLAW(rxchunk[x], ss);
txlins[x] = DAHDI_XLAW(txchunk[x], ss);
@@ -6751,7 +6770,7 @@
if (ms->ec_state && (ms->ec_state->status.mode == ECHO_MODE_ACTIVE) && !ms->ec_state->features.CED_rx_detect) {
for (x = 0; x < DAHDI_CHUNKSIZE; x++) {
if (echo_can_disable_detector_update(&ms->ec_state->rxecdis, putlin[x])) {
- set_echocan_fax_mode(ms, ss->channo, "CED rx detected");
+ set_echocan_fax_mode(ms, ss->channo, "CED rx detected", 1);
dahdi_qevent_nolock(ms, DAHDI_EVENT_RX_CED_DETECTED);
break;
}
Modified: linux/team/kpfleming/echocan_work/include/dahdi/user.h
URL: http://svn.digium.com/svn-view/dahdi/linux/team/kpfleming/echocan_work/include/dahdi/user.h?view=diff&rev=6440&r1=6439&r2=6440
==============================================================================
--- linux/team/kpfleming/echocan_work/include/dahdi/user.h (original)
+++ linux/team/kpfleming/echocan_work/include/dahdi/user.h Tue Apr 21 18:26:09 2009
@@ -1024,7 +1024,7 @@
/* Put a channel's echo canceller into 'FAX mode' if possible */
-#define DAHDI_ECHOCANCEL_FAX_MODE _IO(DAHDI_CODE, 102)
+#define DAHDI_ECHOCANCEL_FAX_MODE _IOW(DAHDI_CODE, 102, int)
struct torisa_debug {
unsigned int txerrors;
More information about the dahdi-commits
mailing list