[svn-commits] kpfleming: branch mogorman/zaptel-1.2-transcoder r1919 - in /team/mogorman/za...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon Jan 22 21:59:40 MST 2007


Author: kpfleming
Date: Mon Jan 22 22:59:39 2007
New Revision: 1919

URL: http://svn.digium.com/view/zaptel?view=rev&rev=1919
Log:
various fixups... use kernel types, no need to support more than 8 devices in a single system, etc.

Modified:
    team/mogorman/zaptel-1.2-transcoder/wctc4xxb/base.c
    team/mogorman/zaptel-1.2-transcoder/zaptel.h

Modified: team/mogorman/zaptel-1.2-transcoder/wctc4xxb/base.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/wctc4xxb/base.c?view=diff&rev=1919&r1=1918&r2=1919
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxb/base.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxb/base.c Mon Jan 22 22:59:39 2007
@@ -65,7 +65,7 @@
 /* #define USE_TEST_HW */
 #define USE_TDM_CONFIG
 
-#define WC_MAX_IFACES 128
+#define WC_MAX_IFACES 8
 
 /* NUM_CHANNELS must be checked if new firmware (dte_firm.h) is used */
 #define NUM_CHANNELS 97
@@ -286,13 +286,13 @@
 
 
 struct cmdq {
-	unsigned int cmdlen;
-	unsigned char cmd[MAX_COMMAND_LEN];
+	u32 cmdlen;
+	u8 cmd[MAX_COMMAND_LEN];
 };
 
 struct wcdte {
 	struct pci_dev *dev;
-	char *variety;
+	const char *variety;
 	unsigned int intcount;
 	unsigned int rxints;
 	unsigned int txints;
@@ -324,12 +324,12 @@
 	unsigned char complexname[40];
 
 	unsigned long iobase;
-	dma_addr_t 	readdma;
-	dma_addr_t	writedma;
-	dma_addr_t	descripdma;
-	volatile unsigned int *writechunk;					/* Double-word aligned write memory */
-	volatile unsigned int *readchunk;					/* Double-word aligned read memory */
-	volatile unsigned int *descripchunk;					/* Descriptors */
+	dma_addr_t readdma;
+	dma_addr_t writedma;
+	dma_addr_t descripdma;
+	volatile u32 *writechunk;					/* Double-word aligned write memory */
+	volatile u32 *readchunk;					/* Double-word aligned read memory */
+	volatile u32 *descripchunk;					/* Descriptors */
 	
 	int wqueints;
 	struct workqueue_struct *dte_wq;
@@ -339,14 +339,12 @@
 	struct zt_transcoder *udecode;
 };
 
-static void dte_wque_run(struct wcdte *wc);
-
 struct wcdte_desc {
-	char *name;
+	const char *name;
 	int flags;
 };
 
-static struct wcdte_desc wcdte = { "Wildcard TC400B", 0 };
+static const struct wcdte_desc wcdte = { "Wildcard TC400B", 0 };
 
 static struct wcdte *ifaces[WC_MAX_IFACES];
 
@@ -444,7 +442,7 @@
 
 static inline void reinit_descriptor(struct wcdte *wc, int tx, int dbl, char *s)
 {
-	int o2;
+	unsigned int o2;
 
 	o2 = dbl * 4;
 
@@ -469,7 +467,7 @@
 
 static inline int __transmit_demand(struct wcdte *wc)
 {
-	volatile unsigned char *writechunk;
+	volatile u8 *writechunk;
 	int o2, i, j;
 	unsigned int reg, xmt_length;
 
@@ -487,7 +485,7 @@
 	if (!wc->cmdq[wc->cmdq_rndx].cmdlen)
 		return 1;
 
-	writechunk = (volatile unsigned char *)(wc->writechunk);
+	writechunk = (volatile u8 *)(wc->writechunk);
 
 	writechunk += wc->tdbl * SFRAME_SIZE;
 
@@ -552,7 +550,7 @@
 	unsigned int timestamp_inc = 0;
 	int i = 0;
 	int res = 0;
-	unsigned int ipchksum;
+	u32 ipchksum;
 
 	switch(op) {
 	case ZT_TCOP_RESET:
@@ -621,10 +619,9 @@
 		    ((zth->srcfmt == ZT_FORMAT_G729A) && (zth->srclen >= G729_BYTES)) ||
 		    ((zth->srcfmt == ZT_FORMAT_G723_1) && (zth->srclen >= G723_BYTES))) {
 			do {
-				chars = (unsigned char *)(zth->srcdata + zth->srcoffset);
+				chars = (u8 *)(zth->srcdata + zth->srcoffset);
 				
-				if ((zth->srcfmt == ZT_FORMAT_ULAW) || (zth->srcfmt == ZT_FORMAT_ALAW))
-				{
+				if ((zth->srcfmt == ZT_FORMAT_ULAW) || (zth->srcfmt == ZT_FORMAT_ALAW)) {
 					if (zth->dstfmt == ZT_FORMAT_G729A) {
 						inbytes = G729_SAMPLES; 
 						timestamp_inc = G729_SAMPLES; 
@@ -643,7 +640,7 @@
 				zth->srclen -= inbytes;
 			
 				{
-					unsigned char fifo[OTHER_CMD_LEN] = CMD_MSG_IP_UDP_RTP(
+					u8 fifo[OTHER_CMD_LEN] = CMD_MSG_IP_UDP_RTP(
 						((inbytes+40) >> 8)                 & 0xFF,
 						(inbytes+40)                       & 0xFF,
 						st->seqno                         & 0xFF,
@@ -665,8 +662,8 @@
 						((st->timestamp) >> 8)              & 0xFF,
 						(st->timestamp)                    & 0xFF);
 
-					ipchksum = 0x9869 + (fifo[16] << 8) + fifo[17]
-						+ (fifo[18] << 8) + fifo[19];
+					ipchksum = 0x9869 + (fifo[16] << 8) + fifo[17] +
+						(fifo[18] << 8) + fifo[19];
 					while (ipchksum >> 16)
 						ipchksum = (ipchksum & 0xFFFF) + (ipchksum >> 16);
 					ipchksum = (~ipchksum) & 0xFFFF;
@@ -682,10 +679,9 @@
 
 					down(&wc->cmdqsem);
 		
-					if ( (((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx) && debug )
+					if ( (((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx) && debug ) {
 						printk("wcdte error: cmdq is full.\n");
-					else
-					{
+					} else {
 						wc->cmdq[wc->cmdq_wndx].cmdlen = CMD_MSG_IP_UDP_RTP_LEN+inbytes;
 						for (i = 0; i < CMD_MSG_IP_UDP_RTP_LEN+inbytes; i++)
 							wc->cmdq[wc->cmdq_wndx].cmd[i] = fifo[i];
@@ -718,17 +714,17 @@
 
 static inline void receiveprep(struct wcdte *wc, int dbl)
 {
-	volatile unsigned char *readchunk;
+	volatile u8 *readchunk;
 	struct zt_transcoder_channel *ztc = NULL;
 	struct zt_transcode_header *zth = NULL;
 	struct dte_state *st = NULL;
 	int o2,i;
 	unsigned char rseq, rcodec;
 	unsigned int rcommand, rchannel, rlen, rtp_rseq, rtp_eseq;
-	unsigned char *chars = NULL;
+	u8 *chars = NULL;
 	unsigned int ztc_ndx;
 
-	readchunk = (volatile unsigned char *) wc->readchunk;
+	readchunk = (volatile u8 *) wc->readchunk;
 	readchunk += dbl * SFRAME_SIZE;
 
 	o2 = dbl * 4;
@@ -759,7 +755,7 @@
 			if ((((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx) && debug ) {
 				printk("wcdte error: cmdq is full (rndx = %d, wndx = %d).\n", wc->cmdq_rndx, wc->cmdq_wndx);
 			} else {
-				unsigned char fifo[OTHER_CMD_LEN] = CMD_MSG_ACK(rseq++, rchannel);
+				u8 fifo[OTHER_CMD_LEN] = CMD_MSG_ACK(rseq++, rchannel);
 
 				wc->cmdq[wc->cmdq_wndx].cmdlen = CMD_MSG_ACK_LEN;
 				for (i = 0; i < wc->cmdq[wc->cmdq_wndx].cmdlen; i++)
@@ -787,7 +783,7 @@
 		rtp_rseq = (readchunk[45] | (readchunk[44] << 8));
 		rcodec = readchunk[43];
 
-		ztc_ndx = rchannel/2;
+		ztc_ndx = rchannel >> 1;
 
 		if (ztc_ndx >= wc->numchannels) {
 			if (debug)
@@ -805,7 +801,7 @@
 					printk("wcdte error: Tried to put DTE data into a freed zth header!\n");
 				rcodec = DTE_FORMAT_UNDEF;
 			} else {
-				chars = (unsigned char *)(zth->dstdata + zth->dstoffset + zth->dstlen);
+				chars = (u8 *)(zth->dstdata + zth->dstoffset + zth->dstlen);
 				st->packets_received++;
 			}
 		}
@@ -820,7 +816,7 @@
 					printk("wcdte error: Tried to put DTE data into a freed zth header!\n");
 				rcodec = DTE_FORMAT_UNDEF;
 			} else {
-				chars = (unsigned char *)(zth->dstdata + zth->dstoffset + zth->dstlen);
+				chars = (u8 *)(zth->dstdata + zth->dstoffset + zth->dstlen);
 				st->packets_received++;
 			}
 
@@ -900,10 +896,9 @@
 
 static int check_descriptor(struct wcdte *wc)
 {
-	int o2 = 0;
-
-	o2 += ERING_SIZE * 4;
-	o2 += wc->rdbl * 4;
+	int o2;
+
+	o2 = (ERING_SIZE * 4) + (wc->rdbl * 4);
 
 	if (!(le32_to_cpu(wc->descripchunk[o2]) & 0x80000000)) {
 		wc->rxints++;
@@ -919,7 +914,7 @@
 
 static void init_descriptors(struct wcdte *wc)
 {
-	volatile unsigned int *descrip;
+	volatile u32 *descrip;
 	dma_addr_t descripdma;
 	dma_addr_t writedma;
 	dma_addr_t readdma;
@@ -930,7 +925,7 @@
 	writedma = wc->writedma;
 	readdma = wc->readdma;
 
-	for (x = 0;x < ERING_SIZE; x++) {
+	for (x = 0; x < ERING_SIZE; x++) {
 		if (x < ERING_SIZE - 1)
 			descripdma += 16;
 		else
@@ -1033,7 +1028,7 @@
 	setctl(wc, 0x0000, 0xFFF88001);
 
 	newjiffies = jiffies + HZ/10;
-	while (((reg = getctl(wc,0x0000)) & 0x00000001) && (newjiffies > jiffies));
+	while (((reg = getctl(wc, 0x0000)) & 0x00000001) && (newjiffies > jiffies));
 	
 	/* Configure watchdogs, access, etc */
 	setctl(wc, 0x0030, 0x00280048);
@@ -1379,7 +1374,7 @@
 	struct wcdte *wc;
 	struct wcdte_desc *d = (struct wcdte_desc *) ent->driver_data;
 	int x;
-	unsigned char g729_numchannels, g723_numchannels, min_numchannels, dte_firmware_ver;
+	u8 g729_numchannels, g723_numchannels, min_numchannels, dte_firmware_ver;
 	unsigned int complexfmts;
 	struct firmware embedded_firmware;
 	const struct firmware *firmware = &embedded_firmware;
@@ -1388,7 +1383,7 @@
 	extern const size_t _binary_wctc4xxb_firm_bin_size;
 #endif
 
-	for (x = 0;x < (sizeof(ifaces) / sizeof(ifaces[0])); x++)
+	for (x = 0; x < (sizeof(ifaces) / sizeof(ifaces[0])); x++)
 		if (!ifaces[x]) break;
 
 	if (x >= WC_MAX_IFACES) {
@@ -1419,7 +1414,7 @@
 	if (request_region(wc->iobase, 0xff, "wctc4xxb")) 
 		wc->freeregion = 1;
 	
-	/* Allocate enought memory for all TX buffers, RX buffers, and descriptors */
+	/* Allocate enough memory for all TX buffers, RX buffers, and descriptors */
 	wc->writechunk = (int *) pci_alloc_consistent(pdev, PCI_WINDOW_SIZE, &wc->writedma);
 	if (!wc->writechunk) {
 		printk("wctc4xxb: Unable to allocate DMA-able memory\n");
@@ -1569,7 +1564,7 @@
 		free_irq(pdev->irq, wc);
 		if (wc->freeregion)
 			release_region(wc->iobase, 0xff);
-		pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
+		pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *) wc->writechunk, wc->writedma);
 		pci_set_drvdata(pdev, NULL);
 		vfree(wc);
 		return -EIO;
@@ -1582,7 +1577,7 @@
 		free_irq(pdev->irq, wc);
 		if (wc->freeregion)
 			release_region(wc->iobase, 0xff);
-		pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
+		pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *) wc->writechunk, wc->writedma);
 		pci_set_drvdata(pdev, NULL);
 		vfree(wc);
 		return -EIO;
@@ -1592,7 +1587,7 @@
 	if (debug)
 		printk("wcdte debug: (post-boot) Reg fc is %08x\n", reg);
 	
-	printk("Found and successfully installed a Wildcard TC: %s \n", wc->variety);
+	printk("Found and successfully installed a Wildcard TC: %s\n", wc->variety);
 	res = 0;
 
 	return res;

Modified: team/mogorman/zaptel-1.2-transcoder/zaptel.h
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/zaptel.h?view=diff&rev=1919&r1=1918&r2=1919
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/zaptel.h (original)
+++ team/mogorman/zaptel-1.2-transcoder/zaptel.h Mon Jan 22 22:59:39 2007
@@ -1417,7 +1417,6 @@
 
 #define ZT_TC_FLAG_BUSY       (1 << 0)
 #define ZT_TC_FLAG_TRANSIENT  (1 << 1)
-
 
 struct zt_transcoder {
 	struct zt_transcoder *next;



More information about the svn-commits mailing list