[svn-commits] kpfleming: branch mogorman/zaptel-1.2-transcoder r2035 - /team/mogorman/zapte...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Jan 30 18:16:41 MST 2007


Author: kpfleming
Date: Tue Jan 30 19:16:40 2007
New Revision: 2035

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2035
Log:
improve 'mode' parameter parsing

Modified:
    team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c
    team/mogorman/zaptel-1.2-transcoder/wctc4xxp/codec_test.c

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=2035&r1=2034&r2=2035
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c Tue Jan 30 19:16:40 2007
@@ -2,8 +2,9 @@
  * Wildcard TC400B Interface Driver for Zapata Telephony interface
  *
  * Written by John Sloan <jsloan at digium.com>
+ *        and Kevin P. Fleming <kpfleming at digium.com>
  *
- * Copyright (C) 2006, Digium, Inc.
+ * Copyright (C) 2006-2007, Digium, Inc.
  *
  * All rights reserved.
  *
@@ -307,7 +308,8 @@
 };
 
 static int debug = 0;
-static char *mode;
+static char *mode[2] = { "g729", "g723" };
+static int mode_count = 2;
 u32 debug_packets = 0;
 u32 debug_cmd_packets = 0;
 
@@ -1338,7 +1340,7 @@
 	struct wcdte_desc *d = (struct wcdte_desc *) ent->driver_data;
 	int x;
 	u8 g729_numchannels, g723_numchannels, min_numchannels, firmware_ver;
-	unsigned int complexfmts;
+	unsigned int complexfmts = 0;
 	struct firmware embedded_firmware;
 	const struct firmware *firmware = &embedded_firmware;
 	struct dte_state *encoders;
@@ -1403,7 +1405,7 @@
 
 #ifdef HOTPLUG_FIRMWARE
 	if ((request_firmware(&firmware, tc400m_firmware, &wc->dev->dev) != 0) || !firmware) {
-		module_printk("firmware %s not available from userspace\n", tc400m_firmware);
+		module_printk("Firmware %s not available from userspace\n", tc400m_firmware);
 		return -1;
 	}
 #else
@@ -1423,27 +1425,29 @@
 	
 	min_numchannels = min(g723_numchannels, g729_numchannels);
 	
-	/* Setup Encoders and Decoders */
-	/* TODO: parse this value properly */
-	
-	if (!mode || strlen(mode) < 4) {
-		sprintf(wc->complexname, "G.729A / G.723.1 5.3Kbps");
-		complexfmts = ZT_FORMAT_G729A | ZT_FORMAT_G723_1;
-		wc->numchannels = min_numchannels;
-	} else if (mode[3] == '9') {	/* "g729" */
-		sprintf(wc->complexname, "G.729A");
-		complexfmts = ZT_FORMAT_G729A;
-		wc->numchannels = g729_numchannels;
-	} else if (mode[3] == '3') {	/* "g723" */
-		sprintf(wc->complexname, "G.723.1 5.3Kbps");
-		complexfmts = ZT_FORMAT_G723_1;
-		wc->numchannels = g723_numchannels;
-	} else {
-		sprintf(wc->complexname, "G.729A / G.723.1 5.3Kbps");
-		complexfmts = ZT_FORMAT_G729A | ZT_FORMAT_G723_1;
-		wc->numchannels = min_numchannels;
-	}
-	
+	for (x = 0; x < mode_count; x++) {
+		if (!strcmp(mode[x], "g729") ||
+		    !strcmp(mode[x], "G729")) {
+			strcat(wc->complexname, "G.729A /");
+			complexfmts |= ZT_FORMAT_G729A;
+			wc->numchannels = min(wc->numchannels, g729_numchannels);
+		} else if (!strcmp(mode[x], "g723.1") ||
+			   !strcmp(mode[x], "G723.1")) {
+			strcat(wc->complexname, "G.723.1 5.3Kbps /");
+			complexfmts |= ZT_FORMAT_G723_1;
+			wc->numchannels = min(wc->numchannels, g723_numchannels);
+		} else {
+			module_printk("Invalid transcoder format specified: %s\n", mode[x]);
+		}
+	}
+
+	if (!complexfmts) {
+		module_printk("No valid transcoder formats specified; module will not be enabled.\n");
+		return -1;
+	}
+
+	wc->complexname[strlen(wc->complexname) - 2] = '\0';
+
 	wc->uencode = zt_transcoder_alloc(wc->numchannels);
 	wc->udecode = zt_transcoder_alloc(wc->numchannels);
 	encoders = kmalloc(sizeof(*encoders) * wc->numchannels, GFP_KERNEL);
@@ -1654,10 +1658,10 @@
 	pci_unregister_driver(&driver);
 }
 
-module_param(debug, int, 0600);
-module_param(mode, charp, 0600);
-module_param(debug_packets, uint, 0600);
-module_param(debug_cmd_packets, uint, 0600);
+module_param(debug, int, S_IRUGO | S_IWUSR);
+module_param_array(mode, charp, &mode_count, S_IRUGO | S_IWUSR);
+module_param(debug_packets, uint, S_IRUGO | S_IWUSR);
+module_param(debug_cmd_packets, uint, S_IRUGO | S_IWUSR);
 MODULE_DESCRIPTION("Wildcard TC400P+TC400M Transcoder");
 MODULE_AUTHOR("John Sloan <jsloan at digium.com>");
 MODULE_LICENSE("GPL");

Modified: team/mogorman/zaptel-1.2-transcoder/wctc4xxp/codec_test.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/wctc4xxp/codec_test.c?view=diff&rev=2035&r1=2034&r2=2035
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxp/codec_test.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxp/codec_test.c Tue Jan 30 19:16:40 2007
@@ -1,9 +1,9 @@
 /*
  * Wilcard TC400B Digium Transcoder Engine Interface Driver for Zapata Telephony interface test tool.
  *
- * Written by Matt O'Gorman <mogormandigium.com>
- *
- * Copyright (C) 2006, Digium, Inc.
+ * Written by Matt O'Gorman <mogorman at digium.com>
+ *
+ * Copyright (C) 2006-2007, Digium, Inc.
  *
  * All rights reserved.
  *



More information about the svn-commits mailing list