From 68f1c21760ec8ff62c2b9e7ba126ac6522871942 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Tue, 5 May 2009 17:32:29 +0000 Subject: 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 --- drivers/dahdi/voicebus/GpakCust.c | 58 ++++++++++++++++++++++++++++++--------- 1 file 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) -- cgit v1.2.3