[dahdi-commits] kpfleming: branch linux/kpfleming/echocan_work r6374 - in /linux/team/kpflemi...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Wed Apr 15 17:39:37 CDT 2009
Author: kpfleming
Date: Wed Apr 15 17:39:31 2009
New Revision: 6374
URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=6374
Log:
move the remaining echocan state variables from 'struct dahdi_chan' to 'struct dahdi_echocan_state'
Modified:
linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c
linux/team/kpfleming/echocan_work/include/dahdi/kernel.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=6374&r1=6373&r2=6374
==============================================================================
--- linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/kpfleming/echocan_work/drivers/dahdi/dahdi-base.c Wed Apr 15 17:39:31 2009
@@ -65,14 +65,6 @@
#ifndef CONFIG_OLD_HDLC_API
#define NEW_HDLC_INTERFACE
#endif
-
-#define __ECHO_STATE_MUTE (1 << 8)
-#define ECHO_STATE_IDLE (0)
-#define ECHO_STATE_PRETRAINING (1 | (__ECHO_STATE_MUTE))
-#define ECHO_STATE_STARTTRAINING (2 | (__ECHO_STATE_MUTE))
-#define ECHO_STATE_AWAITINGECHO (3 | (__ECHO_STATE_MUTE))
-#define ECHO_STATE_TRAINING (4 | (__ECHO_STATE_MUTE))
-#define ECHO_STATE_ACTIVE (5)
/* #define BUF_MUNGE */
@@ -2463,10 +2455,6 @@
chan->ec_state = NULL;
ec_current = chan->ec_current;
chan->ec_current = NULL;
- chan->echocancel = 0;
- chan->echostate = ECHO_STATE_IDLE;
- chan->echolastupdate = 0;
- chan->echotimer = 0;
chan->txdisable = 0;
chan->rxdisable = 0;
@@ -3716,10 +3704,12 @@
mychan->afterdialingtimer, mychan->cadencepos);
module_printk(KERN_INFO, "confna: %d, confn: %d, confmode: %d, confmute: %d\n",
mychan->confna, mychan->_confn, mychan->confmode, mychan->confmute);
- module_printk(KERN_INFO, "ec: %08lx, echocancel: %d, deflaw: %d, xlaw: %08lx\n",
- (long) mychan->ec_state, mychan->echocancel, mychan->deflaw, (long) mychan->xlaw);
- module_printk(KERN_INFO, "echostate: %02x, echotimer: %d, echolastupdate: %d\n",
- (int) mychan->echostate, mychan->echotimer, mychan->echolastupdate);
+ module_printk(KERN_INFO, "ec: %08lx, deflaw: %d, xlaw: %08lx\n",
+ (long) mychan->ec_state, mychan->deflaw, (long) mychan->xlaw);
+ if (mychan->ec_state) {
+ module_printk(KERN_INFO, "echostate: %02x, echotimer: %d, echolastupdate: %d\n",
+ (int) mychan->ec_state->status.mode, mychan->ec_state->status.pretrain_timer, mychan->ec_state->status.last_train_tap);
+ }
module_printk(KERN_INFO, "itimer: %d, otimer: %d, ringdebtimer: %d\n\n",
mychan->itimer, mychan->otimer, mychan->ringdebtimer);
#if 0
@@ -4869,10 +4859,6 @@
chan->ec_state = NULL;
ec_current = chan->ec_current;
chan->ec_current = NULL;
- chan->echocancel = 0;
- chan->echostate = ECHO_STATE_IDLE;
- chan->echolastupdate = 0;
- chan->echotimer = 0;
spin_unlock_irqrestore(&chan->lock, flags);
if (ec_state) {
ec_state->ops->echocan_free(ec_state);
@@ -4957,12 +4943,8 @@
}
spin_lock_irqsave(&chan->lock, flags);
- chan->echocancel = ecp->tap_length;
chan->ec_current = ec_current;
chan->ec_state = ec;
- chan->echostate = ECHO_STATE_IDLE;
- chan->echolastupdate = 0;
- chan->echotimer = 0;
if (!ec->features.CED_tx_detect) {
echo_can_disable_detector_init(&chan->ec_state->txecdis);
}
@@ -4987,10 +4969,6 @@
} 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->echocancel = 0;
- chan->echostate = ECHO_STATE_IDLE;
- chan->echolastupdate = 0;
- chan->echotimer = 0;
chan->ec_state->ops->echocan_free(chan->ec_state);
chan->ec_state = NULL;
release_echocan(chan->ec_current);
@@ -5125,7 +5103,7 @@
ec_current = chan->ec_current;
chan->ec_current = NULL;
chan->echocancel = 0;
- chan->echostate = ECHO_STATE_IDLE;
+ chan->echostate = ECHO_MODE_IDLE;
chan->echolastupdate = 0;
chan->echotimer = 0;
/* Make sure there's no gain */
@@ -5226,8 +5204,8 @@
if (chan->ec_state) {
/* Start pretraining stage */
spin_lock_irqsave(&chan->lock, flags);
- chan->echostate = ECHO_STATE_PRETRAINING;
- chan->echotimer = j;
+ chan->ec_state->status.mode = ECHO_MODE_PRETRAINING;
+ chan->ec_state->status.pretrain_timer = j;
spin_unlock_irqrestore(&chan->lock, flags);
} else
return -EINVAL;
@@ -5967,13 +5945,13 @@
break;
}
}
- if (ms->confmute || (ms->echostate & __ECHO_STATE_MUTE)) {
+ if (ms->confmute || (ms->ec_state && (ms->ec_state->status.mode) & __ECHO_MODE_MUTE)) {
txb[0] = DAHDI_LIN2X(0, ms);
memset(txb + 1, txb[0], DAHDI_CHUNKSIZE - 1);
- if (ms->echostate == ECHO_STATE_STARTTRAINING) {
+ if (ms->ec_state && (ms->ec_state->status.mode == ECHO_MODE_STARTTRAINING)) {
/* Transmit impulse now */
txb[0] = DAHDI_LIN2X(16384, ms);
- ms->echostate = ECHO_STATE_AWAITINGECHO;
+ ms->ec_state->status.mode = ECHO_MODE_AWAITINGECHO;
}
}
/* save value from last chunk */
@@ -6630,27 +6608,27 @@
#if defined(CONFIG_DAHDI_MMX) || defined(ECHO_CAN_FP)
dahdi_kernel_fpu_begin();
#endif
- if (ss->echostate & __ECHO_STATE_MUTE) {
+ if (ss->ec_state->status.mode & __ECHO_MODE_MUTE) {
/* Special stuff for training the echo can */
for (x=0;x<DAHDI_CHUNKSIZE;x++) {
rxlin = DAHDI_XLAW(rxchunk[x], ss);
txlin = DAHDI_XLAW(txchunk[x], ss);
- if (ss->echostate == ECHO_STATE_PRETRAINING) {
- if (--ss->echotimer <= 0) {
- ss->echotimer = 0;
- ss->echostate = ECHO_STATE_STARTTRAINING;
+ if (ss->ec_state->status.mode == ECHO_MODE_PRETRAINING) {
+ if (--ss->ec_state->status.pretrain_timer <= 0) {
+ ss->ec_state->status.pretrain_timer = 0;
+ ss->ec_state->status.mode = ECHO_MODE_STARTTRAINING;
}
}
- if ((ss->echostate == ECHO_STATE_AWAITINGECHO) && (txlin > 8000)) {
- ss->echolastupdate = 0;
- ss->echostate = ECHO_STATE_TRAINING;
+ if ((ss->ec_state->status.mode == ECHO_MODE_AWAITINGECHO) && (txlin > 8000)) {
+ ss->ec_state->status.last_train_tap = 0;
+ ss->ec_state->status.mode = ECHO_MODE_TRAINING;
}
- if (ss->echostate == ECHO_STATE_TRAINING) {
- if (ss->ec_state->ops->echocan_traintap(ss->ec_state, ss->echolastupdate++, rxlin)) {
+ if (ss->ec_state->status.mode == ECHO_MODE_TRAINING) {
+ if (ss->ec_state->ops->echocan_traintap(ss->ec_state, ss->ec_state->status.last_train_tap++, rxlin)) {
#if 0
- module_printk(KERN_NOTICE, "Finished training (%d taps trained)!\n", ss->echolastupdate);
-#endif
- ss->echostate = ECHO_STATE_ACTIVE;
+ module_printk(KERN_NOTICE, "Finished training (%d taps trained)!\n", ss->ec_state->status.last_train_tap);
+#endif
+ ss->ec_state->status.mode = ECHO_MODE_ACTIVE;
}
}
rxlin = 0;
Modified: linux/team/kpfleming/echocan_work/include/dahdi/kernel.h
URL: http://svn.digium.com/svn-view/dahdi/linux/team/kpfleming/echocan_work/include/dahdi/kernel.h?view=diff&rev=6374&r1=6373&r2=6374
==============================================================================
--- linux/team/kpfleming/echocan_work/include/dahdi/kernel.h (original)
+++ linux/team/kpfleming/echocan_work/include/dahdi/kernel.h Wed Apr 15 17:39:31 2009
@@ -271,6 +271,16 @@
*/
void dahdi_unregister_echocan_factory(const struct dahdi_echocan_factory *ec);
+enum dahdi_echocan_mode {
+ __ECHO_MODE_MUTE = 1 << 8,
+ ECHO_MODE_IDLE = 0,
+ ECHO_MODE_PRETRAINING = 1 | __ECHO_MODE_MUTE,
+ ECHO_MODE_STARTTRAINING = 2 | __ECHO_MODE_MUTE,
+ ECHO_MODE_AWAITINGECHO = 3 | __ECHO_MODE_MUTE,
+ ECHO_MODE_TRAINING = 4 | __ECHO_MODE_MUTE,
+ ECHO_MODE_ACTIVE = 5,
+};
+
/*! An instance of a DAHDI echo canceler (software or hardware). */
struct dahdi_echocan_state {
@@ -295,6 +305,15 @@
struct {
/*! Whether the echocan's NLP is currently enabled or disabled. */
u32 NLP_enabled:1;
+
+ /*! The mode the echocan is currently in. */
+ enum dahdi_echocan_mode mode;
+
+ /*! The last tap position that was fed to the echocan's training function. */
+ u32 last_train_tap;
+
+ /*! How many samples to wait before beginning the training operation. */
+ u32 pretrain_timer;
} status;
/*! This structure contains event flags, allowing the echocan to report
@@ -492,8 +511,6 @@
short conflast2[DAHDI_MAX_CHUNKSIZE]; /*!< Previous last conference sample -- pseudo part of channel */
- /*! Is echo cancellation enabled or disabled */
- int echocancel;
/*! The echo canceler module that should be used to create an
instance when this channel needs one */
const struct dahdi_echocan_factory *ec_factory;
@@ -502,10 +519,6 @@
const struct dahdi_echocan_factory *ec_current;
/*! The state data of the echo canceler instance in use */
struct dahdi_echocan_state *ec_state;
-
- int echostate; /*!< State of echo canceller */
- int echolastupdate; /*!< Last echo can update pos */
- int echotimer; /*!< Timer for echo update */
/* RBS timings */
int prewinktime; /*!< pre-wink time (ms) */
More information about the dahdi-commits
mailing list