summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2009-05-05 17:32:29 +0000
committerShaun Ruffell <sruffell@digium.com>2009-05-05 17:32:29 +0000
commit68f1c21760ec8ff62c2b9e7ba126ac6522871942 (patch)
tree5ca1e8f572dc50bee2de866fa6b842f26e9f12d7
parent8cde4916b6b140ec3f6803d9fce6175d80523ffa (diff)
voicebus: Use the companding type on the span when enabling echocan.
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@6564 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/voicebus/GpakCust.c58
1 files changed, 45 insertions, 13 deletions
diff --git a/drivers/dahdi/voicebus/GpakCust.c b/drivers/dahdi/voicebus/GpakCust.c
index c1f3c94..76a9b41 100644
--- a/drivers/dahdi/voicebus/GpakCust.c
+++ b/drivers/dahdi/voicebus/GpakCust.c
@@ -212,6 +212,47 @@ static int vpmadt032_setreg(struct vpmadt032 *vpm, unsigned int addr, u16 data)
return res;
}
+static int vpmadt032_enable_ec(struct vpmadt032 *vpm, int channel)
+{
+ int res;
+ GPAK_AlgControlStat_t pstatus;
+ GpakAlgCtrl_t control;
+
+ if (vpm->span) {
+ control = (DAHDI_LAW_ALAW == vpm->span->deflaw) ?
+ EnableALawSwCompanding :
+ EnableMuLawSwCompanding;
+ } else {
+ control = EnableMuLawSwCompanding;
+ }
+ printk(KERN_DEBUG "Enabling ecan on channel: %d (%s)\n", channel,
+ ((control == EnableMuLawSwCompanding) ?
+ "MuLaw" : "ALaw"));
+ res = gpakAlgControl(vpm->dspid, channel, control, &pstatus);
+ if (res) {
+ printk(KERN_WARNING "Unable to set SW Companding on " \
+ "channel %d (reason %d)\n", channel, res);
+ }
+ res = gpakAlgControl(vpm->dspid, channel, EnableEcanA, &pstatus);
+ return res;
+}
+
+static int vpmadt032_disable_ec(struct vpmadt032 *vpm, int channel)
+{
+ int res;
+ GPAK_AlgControlStat_t pstatus;
+
+ printk(KERN_DEBUG "Disabling ecan on channel: %d\n", channel);
+ res = gpakAlgControl(vpm->dspid, channel, BypassSwCompanding, &pstatus);
+ if (res) {
+ printk(KERN_WARNING "Unable to disable sw companding on " \
+ "echo cancellation channel %d (reason %d)\n",
+ channel, res);
+ }
+ res = gpakAlgControl(vpm->dspid, channel, BypassEcanA, &pstatus);
+ return res;
+}
+
/**
* vpmadt032_bh - Changes the echocan parameters on the vpmadt032 module.
*
@@ -272,19 +313,10 @@ static void vpmadt032_bh(struct work_struct *data)
}
} else if (desiredstate->tap_length != curstate->tap_length) {
- if (desiredstate->tap_length) {
- printk(KERN_DEBUG "Enabling ecan on channel: %d\n", channel);
- res = gpakAlgControl(vpm->dspid, channel, EnableMuLawSwCompanding, &pstatus);
- if (res)
- printk("Unable to set SW Companding on channel %d (reason %d)\n", channel, res);
- res = gpakAlgControl(vpm->dspid, channel, EnableEcanA, &pstatus);
- } else {
- printk(KERN_DEBUG "Disabling ecan on channel: %d\n", channel);
- res = gpakAlgControl(vpm->dspid, channel, BypassSwCompanding, &pstatus);
- if (res)
- printk("Unable to disable sw companding on echo cancellation channel %d (reason %d)\n", channel, res);
- res = gpakAlgControl(vpm->dspid, channel, BypassEcanA, &pstatus);
- }
+ if (desiredstate->tap_length)
+ res = vpmadt032_enable_ec(vpm, channel);
+ else
+ res = vpmadt032_disable_ec(vpm, channel);
}
vpm_bh_out:
if (!res)