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

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Tue Jan 23 20:26:38 MST 2007


Author: kpfleming
Date: Tue Jan 23 21:26:37 2007
New Revision: 1951

URL: http://svn.digium.com/view/zaptel?view=rev&rev=1951
Log:
remove kernel 2.4 support (which could not have worked anyway)
add module_printk and debug_printk macros
incorporate interrupt acknowledge fix
use proper firmware filename and fix up non-hotplug firmware loading case

Added:
    team/mogorman/zaptel-1.2-transcoder/wctc4xxp/tc400m-firmware.bin
      - copied unchanged from r1935, team/mogorman/zaptel-1.2-transcoder/wctc4xxp/wctc4xxb_firm.bin
Removed:
    team/mogorman/zaptel-1.2-transcoder/wctc4xxp/wctc4xxb_firm.bin
Modified:
    team/mogorman/zaptel-1.2-transcoder/Makefile
    team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Kbuild
    team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Makefile
    team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c

Modified: team/mogorman/zaptel-1.2-transcoder/Makefile
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/Makefile?view=diff&rev=1951&r1=1950&r2=1951
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/Makefile (original)
+++ team/mogorman/zaptel-1.2-transcoder/Makefile Tue Jan 23 21:26:37 2007
@@ -137,7 +137,7 @@
 
 all: $(BUILDVER) $(LIBTONEZONE_SO)
 
-linux24: prereq $(MODULESO) wct4xxp/wct4xxp.o wctc4xxp/wctc4xxp.o $(BINS)
+linux24: prereq $(MODULESO) wct4xxp/wct4xxp.o $(BINS)
 
 linux26: prereq $(BINS)
 	@echo $(KSRC)
@@ -153,9 +153,6 @@
 
 wct4xxp/wct4xxp.o:
 	$(MAKE) -C wct4xxp KFLAGS="$(KFLAGS) -I.." CFLAGS="$(CFLAGS) -I.."
-
-wctc4xxp/wctc4xxp.o:
-	$(MAKE) -C wctc4xxp KFLAGS="$(KFLAGS) -I.." CFLAGS="$(CFLAGS) -I.."
 
 devel: tor2ee 
 
@@ -332,7 +329,7 @@
 	done; \
 	$(KMAKE_INST);
 else
-	for x in $(MODULESO) wct4xxp/wct4xxp.o wctc4xxp/wctc4xxp.o; do \
+	for x in $(MODULESO) wct4xxp/wct4xxp.o; do \
 		install -D -m 644 $$x $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/$$x ; \
 	done;
 

Modified: team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Kbuild
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Kbuild?view=diff&rev=1951&r1=1950&r2=1951
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Kbuild (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Kbuild Tue Jan 23 21:26:37 2007
@@ -5,11 +5,11 @@
 wctc4xxp-objs := base.o 
 
 ifneq ($(HOTPLUG_FIRMWARE),yes)
-wctc4xxp-objs += firmware_wctc4xxp.o
+wctc4xxp-objs += firmware_tc400m.o
 endif
 
 $(obj)/base.o: $(src)/../zaptel.h
 
-$(obj)/firmware_wctc4xxp.o: $(src)/wctc4xxp_firm.bin $(obj)/base.o
+$(obj)/firmware_tc400m.o: $(src)/tc400m-firmware.bin $(obj)/base.o
 	@echo Making firmware object file for $(notdir $<)
 	@cd $(src) && ../build_tools/make_firmware_object $(notdir $<) $@ $(obj)/base.o

Modified: team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Makefile
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Makefile?view=diff&rev=1951&r1=1950&r2=1951
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Makefile (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Makefile Tue Jan 23 21:26:37 2007
@@ -2,23 +2,4 @@
 
 include $(obj)/Kbuild
 
-else
-
-all: wctc4xxp.o
-
-%.o: %.c
-	$(CC) $(KFLAGS) -o $@ -c $<
-
-base.o: ../zaptel.h 
-
-firmware_wctc4xxp.o: wctc4xxp_firm.bin base.o
-	@echo Making firmware object file for $<
-	../build_tools/make_firmware_object $< $@ base.o
-
-wctc4xxp.o: base.o firmware_wctc4xxp.o
-	$(LD) -r -o $@ $^
-
-clean:
-	rm -f *.o
-
 endif

Modified: team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c?view=diff&rev=1951&r1=1950&r2=1951
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c Tue Jan 23 21:26:37 2007
@@ -50,17 +50,25 @@
 #include <linux/zaptel.h>
 #endif
 #include <linux/moduleparam.h>
-#ifdef HOTPLUG_FIRMWARE
+#if defined(LINUX26)
 #include <linux/firmware.h>
-static const char *dte_firmware = "tc400m-firmware.bin";
 #else
-struct firmware {
+ostruct firmware {
 	size_t size;
 	u8 *data;
 };
-extern const u8 _binary_tc400m_firmware_bin_start[];
+#endif
+#if defined(HOTPLUG_FIRMWARE)
+static const char *tc400m_firmware = "tc400m-firmware.bin";
+#else
+extern u8 _binary_tc400m_firmware_bin_start[];
 extern const size_t _binary_tc400m_firmware_bin_size;
 #endif
+
+static struct pci_driver driver;
+
+#define module_printk(fmt, args...) printk("%s: " fmt, driver.name, ## args)
+#define debug_printk(test, fmt, args...) if (debug && (test)) printk("%s (%s): " fmt, driver.name, __FUNCTION__, ## args)
 
 /* #define USE_TEST_HW */
 #define USE_TDM_CONFIG
@@ -267,7 +275,7 @@
 			down(&wc->cmdqsem); \
 	 		wc->last_command_sent = hex; \
 			if ( (((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx) && debug ) \
-				printk("wcdte error: cmdq is full.\n"); \
+				module_printk("cmdq is full\n"); \
 			else { \
 				unsigned char fifo[OTHER_CMD_LEN] = command; \
 				int i; \
@@ -503,14 +511,14 @@
 		writechunk[j] = 0;
 
 	if (debug_packets) {
-		printk("wcdte debug: TX: ");
+		module_printk("TX: ");
 		for (i = 0; i < debug_packets; i++)
 			printk("%02X ", writechunk[i]);
 		printk("\n");
 	}
 
 	if (debug_cmd_packets && (writechunk[12] == 0x88) && (writechunk[13] == 0x9B)) {
-		printk("wcdte debug: TX: ");
+		module_printk("wcdte debug: TX: ");
 		for (i = 0; i < debug_cmd_packets; i++)
 			printk("%02X ", writechunk[i]);
 		printk("\n");
@@ -679,10 +687,10 @@
 
 					down(&wc->cmdqsem);
 		
-					if ( (((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx) && debug ) {
-						printk("wcdte error: cmdq is full.\n");
+					if (((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx) {
+						debug_printk(1, "cmdq is full\n");
 					} else {
-						wc->cmdq[wc->cmdq_wndx].cmdlen = CMD_MSG_IP_UDP_RTP_LEN+inbytes;
+						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];
 						wc->cmdq_wndx = (wc->cmdq_wndx + 1) % MAX_COMMANDS;
@@ -731,7 +739,7 @@
 	o2 += ERING_SIZE * 4;
 	
 	if (debug_packets) {
-		printk("wctc4xxp: RX: ");
+		debug_printk(1, "RX: ");
 		for (i = 0; i < debug_packets; i++)
 			printk("%02X", readchunk[i]);
 		printk("\n");
@@ -740,7 +748,7 @@
 	if ((readchunk[12] == 0x88) && (readchunk[13] == 0x9B)) {
 		/* Control in packet */
 		if (debug_cmd_packets) {
-			printk("wcdte debug: RX: ");
+			debug_printk(1, "RX: ");
 			for (i = 0; i < debug_cmd_packets; i++)
 				printk("%02X ", readchunk[i]);
 			printk("\n");
@@ -752,8 +760,8 @@
 			rseq = readchunk[16];
 			
 			down(&wc->cmdqsem);
-			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);
+			if ((((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx)) {
+				debug_printk(1, "cmdq is full\n");
 			} else {
 				u8 fifo[OTHER_CMD_LEN] = CMD_MSG_ACK(rseq++, rchannel);
 
@@ -786,8 +794,7 @@
 		ztc_ndx = rchannel >> 1;
 
 		if (ztc_ndx >= wc->numchannels) {
-			if (debug)
-				printk("wcdte error: Invalid channel number received (ztc_ndx = %d) (numchannels = %d)\n", ztc_ndx, wc->numchannels);
+			debug_printk(1, "Invalid channel number received (ztc_ndx = %d) (numchannels = %d)\n", ztc_ndx, wc->numchannels);
 			rcodec = DTE_FORMAT_UNDEF;
 		}
 
@@ -797,8 +804,7 @@
 			st = ztc->pvt;
 
 			if (zth == NULL) {
-				if (debug)
-					printk("wcdte error: Tried to put DTE data into a freed zth header!\n");
+				debug_printk(1, "Tried to put data into a freed zth header\n");
 				rcodec = DTE_FORMAT_UNDEF;
 			} else {
 				chars = (u8 *)(zth->dstdata + zth->dstoffset + zth->dstlen);
@@ -812,8 +818,7 @@
 			st = ztc->pvt;
 
 			if (zth == NULL) {
-				if (debug)
-					printk("wcdte error: Tried to put DTE data into a freed zth header!\n");
+				debug_printk(1, "Tried to put data into a freed zth header\n");
 				rcodec = DTE_FORMAT_UNDEF;
 			} else {
 				chars = (u8 *)(zth->dstdata + zth->dstoffset + zth->dstlen);
@@ -827,9 +832,7 @@
 			st->last_dte_seqno = rtp_rseq;
 		} else {
 			rtp_eseq = (st->last_dte_seqno + 1) & 0xFFFF;
-			if ( (rtp_rseq != rtp_eseq) && debug )
-				printk("wcdte error: Bad seqno from DTE! [%d][%d][%d]\n", rchannel, rtp_rseq, st->last_dte_seqno);
-
+			debug_printk(rtp_rseq != rtp_eseq, "Bad seqno from module [%d][%d][%d]\n", rchannel, rtp_rseq, st->last_dte_seqno);
 			st->last_dte_seqno = rtp_rseq;
 		}
 
@@ -970,12 +973,11 @@
 	struct wcdte *wc = dev_id;
 	unsigned int ints;
 
-	/* Read and clear interrupts */
-	ints = getctl(wc, 0x0028);
+	if (!(ints = getctl(wc, 0x0028)))
+		return IRQ_NONE;
+
 	setctl(wc, 0x0028, ints);
 
-	if (!ints)
-		return IRQ_NONE;
 	ints &= wc->intmask;
 
 	if (ints & 0x00000041) {
@@ -983,29 +985,17 @@
 		queue_work(wc->dte_wq, &wc->dte_work);
 	}
 		
-	if ((ints & 0x00008000) && debug)
-		printk("wctc4xxp: Abnormal Interrupt: ");
-
-	if ((ints & 0x00002000) && debug)
-		printk("wctc4xxp: Fatal Bus Error INT\n");
-
-	if ((ints & 0x00000100) && debug)
-		printk("wctc4xxp: Receive Stopped INT\n");
-
-	if ((ints & 0x00000080) && debug)
-		printk("wctc4xxp: Receive Desciptor Unavailable INT\n");
-
-	if ((ints & 0x00000020) && debug)
-		printk("wctc4xxp: Transmit Under-flow INT\n");
-
-	if ((ints & 0x00000008) && debug)
-		printk("wctc4xxp: Jabber Timer Time-out INT\n");
-
-	if ((ints & 0x00000004) && debug)
-		printk("wctc4xxp: Transmit Descriptor Unavailable INT\n");
-
-	if ((ints & 0x00000002) && debug)
-		printk("wctc4xxp: Transmit Processor Stopped INT\n");
+	if (!debug)
+		return IRQ_RETVAL(1);
+
+	debug_printk(ints & 0x00008000, "Abnormal Interrupt\n");
+	debug_printk(ints & 0x00002000, "Fatal Bus Error\n");
+	debug_printk(ints & 0x00000100, "Receive Stopped\n");
+	debug_printk(ints & 0x00000080, "Receive Desciptor Unavailable\n");
+	debug_printk(ints & 0x00000020, "Transmit Under-flow\n");
+	debug_printk(ints & 0x00000008, "Jabber Timer Time-out\n");
+	debug_printk(ints & 0x00000004, "Transmit Descriptor Unavailable\n");
+	debug_printk(ints & 0x00000002, "Transmit Processor Stopped\n");
 
 	return IRQ_RETVAL(1);
 }
@@ -1107,13 +1097,13 @@
 
 	if (ret < 0) {
 		if (debug)
-			printk("wcdte error: Wait interrupted, need to stop boot (ret = %d)\n", ret);
+			module_printk("wcdte error: Wait interrupted, need to stop boot (ret = %d)\n", ret);
 		return 1;
 	}
 
 	if (ret == 0) {
 		if (debug)
-			printk("wcdte error: Waitfor CSMENCAPS response timed out (ret = %d)\n", ret);
+			module_printk("wcdte error: Waitfor CSMENCAPS response timed out (ret = %d)\n", ret);
 		return 2;
 	}
 
@@ -1197,7 +1187,7 @@
 	/* Turn off auto negotiation */
 	write_phy(wc, 0, 0x2100);
 	if (debug)
-		printk("wctc4xxp: PHY register 0 = %X", read_phy(wc, 0));
+		module_printk("wctc4xxp: PHY register 0 = %X", read_phy(wc, 0));
 	
 	/* Set reset */
 	setctl(wc, 0x00A0, 0x04000000);
@@ -1216,7 +1206,7 @@
 		delay_count++;
 
 		if (delay_count >= 100) {
-			printk("wcdte error: Failed to link to DTE processor!\n");
+			module_printk("wcdte error: Failed to link to DTE processor!\n");
 			return(1);
 		}
 	} while ((reg & 0xE0000000) != 0xE0000000);
@@ -1227,7 +1217,7 @@
 
 	reg = getctl(wc, 0x00fc);
 	if (debug)
-		printk("wctc4xxp: LINK STATUS: reg(0xfc) = %X\n", reg);
+		module_printk("wctc4xxp: LINK STATUS: reg(0xfc) = %X\n", reg);
 
 	reg = getctl(wc, 0x00A0);
 
@@ -1242,7 +1232,7 @@
 		
 		down(&wc->cmdqsem);
 		if ( (((wc->cmdq_wndx + 1) % MAX_COMMANDS) == wc->cmdq_rndx) && debug )
-			printk("wcdte error: cmdq is full.\n");
+			module_printk("wcdte error: cmdq is full.\n");
 		else
 		{
 			wc->cmdq[wc->cmdq_wndx].cmdlen = length;
@@ -1270,7 +1260,7 @@
 	/* Turn on booted LED */
 	setctl(wc, 0x00A0, 0x04080000);
 	if (debug)
-		printk("wctc4xxp: Successfully booted DTE processor.\n");
+		module_printk("wctc4xxp: Successfully booted DTE processor.\n");
 
 	return(0);
 }
@@ -1374,20 +1364,16 @@
 	struct wcdte *wc;
 	struct wcdte_desc *d = (struct wcdte_desc *) ent->driver_data;
 	int x;
-	u8 g729_numchannels, g723_numchannels, min_numchannels, dte_firmware_ver;
+	u8 g729_numchannels, g723_numchannels, min_numchannels, firmware_ver;
 	unsigned int complexfmts;
 	struct firmware embedded_firmware;
 	const struct firmware *firmware = &embedded_firmware;
-#if !defined(HOTPLUG_FIRMWARE)
-	extern const u8 _binary_wctc4xxp_firm_bin_start[];
-	extern const size_t _binary_wctc4xxp_firm_bin_size;
-#endif
 
 	for (x = 0; x < (sizeof(ifaces) / sizeof(ifaces[0])); x++)
 		if (!ifaces[x]) break;
 
 	if (x >= WC_MAX_IFACES) {
-		printk("wctc4xxp: Too many interfaces\n");
+		module_printk("wctc4xxp: Too many interfaces\n");
 		return -EIO;
 	}
 
@@ -1417,7 +1403,7 @@
 	/* 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("wctc4xxp: Unable to allocate DMA-able memory\n");
+		module_printk("wctc4xxp: Unable to allocate DMA-able memory\n");
 		if (wc->freeregion)
 			release_region(wc->iobase, 0xff);
 
@@ -1431,7 +1417,7 @@
 	wc->descripdma = wc->readdma + (SFRAME_SIZE * ERING_SIZE);		/* in bytes */
 	
 	/* Initialize Write/Buffers to all blank data */
-	memset((void *) wc->writechunk,0x00, SFRAME_SIZE * 2);
+	memset((void *) wc->writechunk, 0x00, SFRAME_SIZE * 2);
 	memset((void *) wc->readchunk, 0x00, SFRAME_SIZE * 2);
 	
 	init_waitqueue_head(&wc->regq);
@@ -1439,19 +1425,19 @@
 	/* Initialize the work queue */
 	wc->dte_wq = create_workqueue("wctc4xxp");
 
-	INIT_WORK(&wc->dte_work, (void (*)(void *))dte_wque_run, wc);
+	INIT_WORK(&wc->dte_work, (void (*)(void *)) dte_wque_run, wc);
 
 #ifdef HOTPLUG_FIRMWARE
-	if ((request_firmware(&firmware, dte_firmware, &wc->dev->dev) != 0) || !firmware) {
-		printk("wctc4xxp: firmware %s not available from userspace\n", dte_firmware);
+	if ((request_firmware(&firmware, tc400m_firmware, &wc->dev->dev) != 0) || !firmware) {
+		module_printk("wctc4xxp: firmware %s not available from userspace\n", dte_firmware);
 		return -1;
 	}
 #else
-	embedded_firmware.data = _binary_wctc4xxp_firm_bin_start;
-	embedded_firmware.size = _binary_wctc4xxp_firm_bin_size;
+	embedded_firmware.data = _binary_tc400m_firmware_bin_start;
+	embedded_firmware.size = _binary_tc400m_firmware_bin_size;
 #endif
 
-	dte_firmware_ver = firmware->data[0];
+	firmware_ver = firmware->data[0];
 	g729_numchannels = firmware->data[1];
 	g723_numchannels = firmware->data[2];
 	
@@ -1526,7 +1512,7 @@
 	pci_set_drvdata(pdev, wc);
 	
 	if (request_irq(pdev->irq, interrupt_handler, SA_SHIRQ, "tc400b", wc)) {
-		printk("wctc4xxp: Unable to request IRQ %d\n", pdev->irq);
+		module_printk("wctc4xxp: Unable to request IRQ %d\n", pdev->irq);
 		if (wc->freeregion)
 			release_region(wc->iobase, 0xFF);
 		pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *) wc->writechunk, wc->writedma);
@@ -1583,9 +1569,9 @@
 		
 	reg = getctl(wc, 0x00fc);
 	if (debug)
-		printk("wcdte debug: (post-boot) Reg fc is %08x\n", reg);
-	
- 	printk("wctc4xxp: %s supporting '%s' with firmware version '%d'\n", wc->variety, wc->complexname, dte_firmware_ver);
+		module_printk("wcdte debug: (post-boot) Reg fc is %08x\n", reg);
+	
+ 	module_printk("wctc4xxp: %s supporting '%s' with firmware version '%d'\n", wc->variety, wc->complexname, firmware_ver);
 	
 	res = 0;
 
@@ -1610,8 +1596,8 @@
 		return;
 
 	if (debug) {
-		printk("wctc4xxp debug: wc->ztsnd_rtx = %d\n", wc->ztsnd_rtx);
-		printk("wctc4xxp debug: wc->ztsnd_0010_rtx = %d\n", wc->ztsnd_0010_rtx);
+		module_printk("wctc4xxp debug: wc->ztsnd_rtx = %d\n", wc->ztsnd_rtx);
+		module_printk("wctc4xxp debug: wc->ztsnd_0010_rtx = %d\n", wc->ztsnd_0010_rtx);
 		
 		for(i = 0; i < wc->numchannels; i++) {
 			ztc_en = &(wc->uencode->channels[i]);
@@ -1620,8 +1606,8 @@
 			ztc_de = &(wc->udecode->channels[i]);
 			st_de = ztc_de->pvt;
 			
-			printk("wctc4xxp debug: en[%d] snt = %d, rcv = %d [%d]\n", i, st_en->packets_sent, st_en->packets_received, st_en->packets_sent - st_en->packets_received);
-			printk("wctc4xxp debug: de[%d] snt = %d, rcv = %d [%d]\n", i, st_de->packets_sent, st_de->packets_received, st_de->packets_sent - st_de->packets_received);
+			module_printk("wctc4xxp debug: en[%d] snt = %d, rcv = %d [%d]\n", i, st_en->packets_sent, st_en->packets_received, st_en->packets_sent - st_en->packets_received);
+			module_printk("wctc4xxp debug: de[%d] snt = %d, rcv = %d [%d]\n", i, st_de->packets_sent, st_de->packets_received, st_de->packets_sent - st_de->packets_received);
 		}
 	}
 	



More information about the zaptel-commits mailing list