[zaptel-commits] mattf: branch 1.4 r2532 - /branches/1.4/wct4xxp/vpm450m.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Thu May 17 13:35:57 MST 2007


Author: mattf
Date: Thu May 17 15:35:57 2007
New Revision: 2532

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2532
Log:
Reduce stack usage of VPM450M.  Fix for FC6 module load problems

Modified:
    branches/1.4/wct4xxp/vpm450m.c

Modified: branches/1.4/wct4xxp/vpm450m.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wct4xxp/vpm450m.c?view=diff&rev=2532&r1=2531&r2=2532
==============================================================================
--- branches/1.4/wct4xxp/vpm450m.c (original)
+++ branches/1.4/wct4xxp/vpm450m.c Thu May 17 15:35:57 2007
@@ -401,9 +401,9 @@
 
 struct vpm450m *init_vpm450m(void *wc, int *isalaw, int numspans, const struct firmware *firmware)
 {
-	tOCT6100_CHIP_OPEN ChipOpen;
+	tOCT6100_CHIP_OPEN *ChipOpen;
 	tOCT6100_GET_INSTANCE_SIZE InstanceSize;
-	tOCT6100_CHANNEL_OPEN ChannelOpen;
+	tOCT6100_CHANNEL_OPEN *ChannelOpen;
 	UINT32 ulResult;
 	struct vpm450m *vpm450m;
 	int x,y,law;
@@ -412,39 +412,57 @@
 		return NULL;
 
 	memset(vpm450m, 0, sizeof(struct vpm450m));
+
+	if (!(ChipOpen = kmalloc(sizeof(tOCT6100_CHIP_OPEN), GFP_KERNEL))) {
+		kfree(vpm450m);
+		return NULL;
+	}
+
+	memset(ChipOpen, 0, sizeof(tOCT6100_CHIP_OPEN));
+
+	if (!(ChannelOpen = kmalloc(sizeof(tOCT6100_CHANNEL_OPEN), GFP_KERNEL))) {
+		kfree(vpm450m);
+		kfree(ChipOpen);
+		return NULL;
+	}
+
+	memset(ChannelOpen, 0, sizeof(tOCT6100_CHANNEL_OPEN));
+
 	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);
+	Oct6100ChipOpenDef(ChipOpen);
 
 	/* Setup Chip Open Parameters */
-	ChipOpen.ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ;
+	ChipOpen->ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ;
 	Oct6100GetInstanceSizeDef(&InstanceSize);
 
-	ChipOpen.pProcessContext = wc;
-
-	ChipOpen.pbyImageFile = firmware->data;
-	ChipOpen.ulImageSize = firmware->size;
-	ChipOpen.fEnableMemClkOut = TRUE;
-	ChipOpen.ulMemClkFreq = cOCT6100_MCLK_FREQ_133_MHZ;
-	ChipOpen.ulMaxChannels = vpm450m->numchans;
-	ChipOpen.ulMemoryType = cOCT6100_MEM_TYPE_DDR;
-	ChipOpen.ulMemoryChipSize = cOCT6100_MEMORY_CHIP_SIZE_32MB;
-	ChipOpen.ulNumMemoryChips = 1;
-	ChipOpen.ulMaxTdmStreams = 4;
-	ChipOpen.aulTdmStreamFreqs[0] = cOCT6100_TDM_STREAM_FREQ_8MHZ;
-	ChipOpen.ulTdmSampling = cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE;
+	ChipOpen->pProcessContext = wc;
+
+	ChipOpen->pbyImageFile = firmware->data;
+	ChipOpen->ulImageSize = firmware->size;
+	ChipOpen->fEnableMemClkOut = TRUE;
+	ChipOpen->ulMemClkFreq = cOCT6100_MCLK_FREQ_133_MHZ;
+	ChipOpen->ulMaxChannels = vpm450m->numchans;
+	ChipOpen->ulMemoryType = cOCT6100_MEM_TYPE_DDR;
+	ChipOpen->ulMemoryChipSize = cOCT6100_MEMORY_CHIP_SIZE_32MB;
+	ChipOpen->ulNumMemoryChips = 1;
+	ChipOpen->ulMaxTdmStreams = 4;
+	ChipOpen->aulTdmStreamFreqs[0] = cOCT6100_TDM_STREAM_FREQ_8MHZ;
+	ChipOpen->ulTdmSampling = cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE;
 #if 0
-	ChipOpen.fEnableAcousticEcho = TRUE;
+	ChipOpen->fEnableAcousticEcho = TRUE;
 #endif		
 
-	ulResult = Oct6100GetInstanceSize(&ChipOpen, &InstanceSize);
+	ulResult = Oct6100GetInstanceSize(ChipOpen, &InstanceSize);
 	if (ulResult != cOCT6100_ERR_OK) {
 		printk("Failed to get instance size, code %08x!\n", ulResult);
 		kfree(vpm450m);
+		kfree(ChipOpen);
+		kfree(ChannelOpen);
 		return NULL;
 	}
 	
@@ -453,13 +471,17 @@
 	if (!vpm450m->pApiInstance) {
 		printk("Out of memory (can't allocate %d bytes)!\n", InstanceSize.ulApiInstanceSize);
 		kfree(vpm450m);
+		kfree(ChipOpen);
+		kfree(ChannelOpen);
 		return NULL;
 	}
 
-	ulResult = Oct6100ChipOpen(vpm450m->pApiInstance, &ChipOpen);
+	ulResult = Oct6100ChipOpen(vpm450m->pApiInstance, ChipOpen);
 	if (ulResult != cOCT6100_ERR_OK) {
 		printk("Failed to open chip, code %08x!\n", ulResult);
 		kfree(vpm450m);
+		kfree(ChipOpen);
+		kfree(ChannelOpen);
 		return NULL;
 	}
 	for (x=0;x<128;x++) {
@@ -474,29 +496,29 @@
 				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;
+			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;
+			ChannelOpen->fEnableToneDisabler = TRUE;
+			ChannelOpen->ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_DIGITAL;
 			
-			ulResult = Oct6100ChannelOpen(vpm450m->pApiInstance, &ChannelOpen);
+			ulResult = Oct6100ChannelOpen(vpm450m->pApiInstance, ChannelOpen);
 			if (ulResult != GENERIC_OK) {
 				printk("Failed to open channel %d!\n", x);
 			}
@@ -511,6 +533,8 @@
 		}
 	}
 
+	kfree(ChipOpen);
+	kfree(ChannelOpen);
 	return vpm450m;
 }
 



More information about the zaptel-commits mailing list