summaryrefslogtreecommitdiff
path: root/wct4xxp/vpm450m.c
diff options
context:
space:
mode:
authormattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-11-05 06:44:13 +0000
committermattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-11-05 06:44:13 +0000
commit085c150989f1202fe3321e39803fae633de66ca5 (patch)
treec2c574f91e63928d4f098bfb3c4b78ea66bb532a /wct4xxp/vpm450m.c
parentdc8b376b4caffcbe301f11c2ce67159781d2a279 (diff)
Add support for VPMOCT64 module
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@1556 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'wct4xxp/vpm450m.c')
-rw-r--r--wct4xxp/vpm450m.c107
1 files changed, 61 insertions, 46 deletions
diff --git a/wct4xxp/vpm450m.c b/wct4xxp/vpm450m.c
index 5e52b79..2771837 100644
--- a/wct4xxp/vpm450m.c
+++ b/wct4xxp/vpm450m.c
@@ -13,7 +13,8 @@
#ifdef HOTPLUG_FIRMWARE
#include <linux/firmware.h>
#else
-#include "vpm450m_fw.h"
+#include "vpmoct128_fw.h"
+#include "vpmoct064_fw.h"
#endif
#include "oct6100api/oct6100_api.h"
@@ -162,6 +163,7 @@ struct vpm450m {
UINT32 aulEchoChanHndl[ 128 ];
int chanflags[128];
int ecmode[128];
+ int numchans;
};
#define FLAG_DTMF (1 << 0)
@@ -372,9 +374,9 @@ int vpm450m_getdtmf(struct vpm450m *vpm450m, int *channel, int *tone, int *start
}
#ifdef HOTPLUG_FIRMWARE
-struct vpm450m *init_vpm450m(void *wc, int *isalaw, const struct firmware *firmware)
+struct vpm450m *init_vpm450m(void *wc, int *isalaw, int numspans, const struct firmware *firmware)
#else
-struct vpm450m *init_vpm450m(void *wc, int *isalaw)
+struct vpm450m *init_vpm450m(void *wc, int *isalaw, int numspans)
#endif
{
tOCT6100_CHIP_OPEN ChipOpen;
@@ -390,6 +392,9 @@ struct vpm450m *init_vpm450m(void *wc, int *isalaw)
memset(vpm450m, 0, sizeof(struct vpm450m));
for (x=0;x<128;x++)
vpm450m->ecmode[x] = -1;
+
+ vpm450m->numchans = numspans * 32;
+ printk("VPM450: echo cancellation for %d channels\n", vpm450m->numchans);
Oct6100ChipOpenDef(&ChipOpen);
@@ -402,12 +407,17 @@ struct vpm450m *init_vpm450m(void *wc, int *isalaw)
ChipOpen.pbyImageFile = firmware->data;
ChipOpen.ulImageSize = firmware->size;
#else
- ChipOpen.pbyImageFile = vpm450m_fw;
- ChipOpen.ulImageSize = sizeof(vpm450m_fw);
+ if (vpm450m->numchans > 64) {
+ ChipOpen.pbyImageFile = vpmoct128_fw;
+ ChipOpen.ulImageSize = sizeof(vpmoct128_fw);
+ } else {
+ ChipOpen.pbyImageFile = vpmoct064_fw;
+ ChipOpen.ulImageSize = sizeof(vpmoct064_fw);
+ }
#endif
ChipOpen.fEnableMemClkOut = TRUE;
ChipOpen.ulMemClkFreq = cOCT6100_MCLK_FREQ_133_MHZ;
- ChipOpen.ulMaxChannels = 128;
+ ChipOpen.ulMaxChannels = vpm450m->numchans;
ChipOpen.ulMemoryType = cOCT6100_MEM_TYPE_DDR;
ChipOpen.ulMemoryChipSize = cOCT6100_MEMORY_CHIP_SIZE_32MB;
ChipOpen.ulNumMemoryChips = 1;
@@ -442,46 +452,51 @@ struct vpm450m *init_vpm450m(void *wc, int *isalaw)
return NULL;
}
for (x=0;x<128;x++) {
- /* span timeslots are interleaved 12341234...
- * therefore, the lower 2 bits tell us which span this timeslot/channel
- */
- if (isalaw[x & 0x03])
- law = cOCT6100_PCM_A_LAW;
- else
- law = cOCT6100_PCM_U_LAW;
- Oct6100ChannelOpenDef(&ChannelOpen);
- ChannelOpen.pulChannelHndl = &vpm450m->aulEchoChanHndl[x];
- ChannelOpen.ulUserChanId = x;
- ChannelOpen.TdmConfig.ulRinPcmLaw = law;
- ChannelOpen.TdmConfig.ulRinStream = 0;
- ChannelOpen.TdmConfig.ulRinTimeslot = x;
- ChannelOpen.TdmConfig.ulSinPcmLaw = law;
- ChannelOpen.TdmConfig.ulSinStream = 1;
- ChannelOpen.TdmConfig.ulSinTimeslot = x;
- ChannelOpen.TdmConfig.ulSoutPcmLaw = law;
- ChannelOpen.TdmConfig.ulSoutStream = 2;
- ChannelOpen.TdmConfig.ulSoutTimeslot = x;
- ChannelOpen.TdmConfig.ulRoutPcmLaw = law;
- ChannelOpen.TdmConfig.ulRoutStream = 3;
- ChannelOpen.TdmConfig.ulRoutTimeslot = x;
- ChannelOpen.VqeConfig.fEnableNlp = TRUE;
- ChannelOpen.VqeConfig.fRinDcOffsetRemoval = TRUE;
- ChannelOpen.VqeConfig.fSinDcOffsetRemoval = TRUE;
-
- ChannelOpen.fEnableToneDisabler = TRUE;
- ChannelOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_DIGITAL;
-
- ulResult = Oct6100ChannelOpen(vpm450m->pApiInstance, &ChannelOpen);
- if (ulResult != GENERIC_OK) {
- printk("Failed to open channel %d!\n", x);
- }
- for (y=0;y<sizeof(tones) / sizeof(tones[0]); y++) {
- tOCT6100_TONE_DETECTION_ENABLE enable;
- Oct6100ToneDetectionEnableDef(&enable);
- enable.ulChannelHndl = vpm450m->aulEchoChanHndl[x];
- enable.ulToneNumber = tones[y];
- if (Oct6100ToneDetectionEnable(vpm450m->pApiInstance, &enable) != GENERIC_OK)
- printk("Failed to enable tone detection on channel %d for tone %d!\n", x, y);
+ /* execute this loop always on 4 span cards but
+ * on 2 span cards only execute for the channels related to our spans */
+ if (( numspans > 2) || ((x & 0x03) <2)) {
+ /* span timeslots are interleaved 12341234...
+ * therefore, the lower 2 bits tell us which span this
+ * timeslot/channel
+ */
+ if (isalaw[x & 0x03])
+ law = cOCT6100_PCM_A_LAW;
+ else
+ law = cOCT6100_PCM_U_LAW;
+ Oct6100ChannelOpenDef(&ChannelOpen);
+ ChannelOpen.pulChannelHndl = &vpm450m->aulEchoChanHndl[x];
+ ChannelOpen.ulUserChanId = x;
+ ChannelOpen.TdmConfig.ulRinPcmLaw = law;
+ ChannelOpen.TdmConfig.ulRinStream = 0;
+ ChannelOpen.TdmConfig.ulRinTimeslot = x;
+ ChannelOpen.TdmConfig.ulSinPcmLaw = law;
+ ChannelOpen.TdmConfig.ulSinStream = 1;
+ ChannelOpen.TdmConfig.ulSinTimeslot = x;
+ ChannelOpen.TdmConfig.ulSoutPcmLaw = law;
+ ChannelOpen.TdmConfig.ulSoutStream = 2;
+ ChannelOpen.TdmConfig.ulSoutTimeslot = x;
+ ChannelOpen.TdmConfig.ulRoutPcmLaw = law;
+ ChannelOpen.TdmConfig.ulRoutStream = 3;
+ ChannelOpen.TdmConfig.ulRoutTimeslot = x;
+ ChannelOpen.VqeConfig.fEnableNlp = TRUE;
+ ChannelOpen.VqeConfig.fRinDcOffsetRemoval = TRUE;
+ ChannelOpen.VqeConfig.fSinDcOffsetRemoval = TRUE;
+
+ ChannelOpen.fEnableToneDisabler = TRUE;
+ ChannelOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_DIGITAL;
+
+ ulResult = Oct6100ChannelOpen(vpm450m->pApiInstance, &ChannelOpen);
+ if (ulResult != GENERIC_OK) {
+ printk("Failed to open channel %d!\n", x);
+ }
+ for (y=0;y<sizeof(tones) / sizeof(tones[0]); y++) {
+ tOCT6100_TONE_DETECTION_ENABLE enable;
+ Oct6100ToneDetectionEnableDef(&enable);
+ enable.ulChannelHndl = vpm450m->aulEchoChanHndl[x];
+ enable.ulToneNumber = tones[y];
+ if (Oct6100ToneDetectionEnable(vpm450m->pApiInstance, &enable) != GENERIC_OK)
+ printk("Failed to enable tone detection on channel %d for tone %d!\n", x, y);
+ }
}
}
return vpm450m;