[zaptel-commits] kpfleming: branch 1.2 r2057 - in /branches/1.2: ./ build_tools/ wctc4xxp/ xpp...

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Wed Jan 31 10:27:31 MST 2007


Author: kpfleming
Date: Wed Jan 31 11:27:30 2007
New Revision: 2057

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2057
Log:
merge support for the Digium TC400B hardware transcoder

Added:
    branches/1.2/wctc4xxp/   (props changed)
      - copied from r2056, team/mogorman/zaptel-1.2-transcoder/wctc4xxp/
    branches/1.2/wctc4xxp/Kbuild
      - copied unchanged from r2056, team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Kbuild
    branches/1.2/wctc4xxp/Makefile
      - copied unchanged from r2056, team/mogorman/zaptel-1.2-transcoder/wctc4xxp/Makefile
    branches/1.2/wctc4xxp/base.c
      - copied, changed from r2056, team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c
    branches/1.2/wctc4xxp/codec_test.c
      - copied unchanged from r2056, team/mogorman/zaptel-1.2-transcoder/wctc4xxp/codec_test.c
    branches/1.2/wctc4xxp/tc400m-firmware.bin
      - copied unchanged from r2056, team/mogorman/zaptel-1.2-transcoder/wctc4xxp/tc400m-firmware.bin
    branches/1.2/xpp/utils/adj_clock.8
      - copied unchanged from r2056, team/mogorman/zaptel-1.2-transcoder/xpp/utils/adj_clock.8
    branches/1.2/xpp/utils/adj_clock.c
      - copied unchanged from r2056, team/mogorman/zaptel-1.2-transcoder/xpp/utils/adj_clock.c
    branches/1.2/zttranscode.c
      - copied unchanged from r2056, team/mogorman/zaptel-1.2-transcoder/zttranscode.c
Modified:
    branches/1.2/Makefile
    branches/1.2/build_tools/genudevrules
    branches/1.2/fxotune.c
    branches/1.2/fxstest.c
    branches/1.2/hdlcstress.c
    branches/1.2/hdlctest.c
    branches/1.2/patgen.c
    branches/1.2/patlooptest.c
    branches/1.2/pattest.c
    branches/1.2/timertest.c
    branches/1.2/tonezone.c
    branches/1.2/torisatool.c
    branches/1.2/usbfxstest.c
    branches/1.2/zaptel.c
    branches/1.2/zaptel.h
    branches/1.2/zonedata.c
    branches/1.2/ztcfg.c
    branches/1.2/ztd-eth.c
    branches/1.2/ztd-loc.c
    branches/1.2/ztdiag.c
    branches/1.2/ztdummy.c
    branches/1.2/ztdynamic.c
    branches/1.2/ztmonitor.c
    branches/1.2/zttool.c

Modified: branches/1.2/Makefile
URL: http://svn.digium.com/view/zaptel/branches/1.2/Makefile?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/Makefile (original)
+++ branches/1.2/Makefile Wed Jan 31 11:27:30 2007
@@ -107,9 +107,8 @@
 	 ztdynamic ztd-eth wct1xxp wcte11xp pciradio \
          ztd-loc # ztdummy
 #MODULES+=wcfxsusb
-# build ztdummy by default for 2.6 kernels
 ifeq ($(BUILDVER),linux26)
-MODULES+=ztdummy
+MODULES+=ztdummy zttranscode
 endif
 MODULE_ALIASES=wcfxs wctdm8xxp wct2xxp
 
@@ -119,8 +118,8 @@
 MOD_DESTDIR:=zaptel
 
 obj-m:=$(MODULESO)
-obj-m+=wct4xxp/
-MODULES+=wct4xxp
+obj-m+=wct4xxp/ wctc4xxp/
+MODULES+=wct4xxp wctc4xxp
 
 # Also build xpp in the subdirectory xpp/ . But only for >=2.6.10 and only 
 # for i386. On other archs the module will probably build but panic.
@@ -158,6 +157,7 @@
 devel: tor2ee 
 
 tests: patgen pattest patlooptest hdlcstress hdlctest hdlcgen hdlcverify timertest
+	$(MAKE) -C wctc4xxp tests CFLAGS="$(CFLAGS) -I.."
 
 tor2.o: tor2-hw.h tor2fw.h
 
@@ -333,6 +333,7 @@
 	for x in $(MODULESO) wct4xxp/wct4xxp.o; do \
 		install -D -m 644 $$x $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/$$x ; \
 	done;
+
 endif
 	if ! [ -f wcfxsusb.o ]; then \
 		rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/wcfxsusb.o; \
@@ -353,7 +354,7 @@
 	install -m 644 doc/zttool.8 $(INSTALL_PREFIX)/usr/share/man/man8
 	[ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
 	[ -f $(CONFIG_FILE) ] || install -D -m 644 zaptel.conf.sample $(CONFIG_FILE)
-	build_tools/genmodconf $(BUILDVER) "$(INSTALL_PREFIX)" "$(filter-out zaptel,$(MODULES)) $(MODULE_ALIASES)"
+	build_tools/genmodconf $(BUILDVER) "$(INSTALL_PREFIX)" "$(filter-out zaptel ztdummy zttranscode wctc4xxp,$(MODULES)) $(MODULE_ALIASES)"
 	@if [ -d /etc/modutils ]; then \
 		/sbin/update-modules ; \
 	fi
@@ -364,9 +365,11 @@
 ifeq ($(HOTPLUG_FIRMWARE),yes)
 	if [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ]; then \
 		install -m 644 wct4xxp/*.ima $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \
+		install -m 644 wctc4xxp/*.bin $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \
 	fi
 	if [ -d $(INSTALL_PREFIX)/lib/firmware ]; then \
 		install -m 644 wct4xxp/*.ima $(INSTALL_PREFIX)/lib/firmware; \
+		install -m 644 wctc4xxp/*.bin $(INSTALL_PREFIX)/lib/firmware; \
 	fi
 	@echo "Installed firmware"
 else
@@ -408,12 +411,14 @@
 clean:
 	rm -f torisatool makefw tor2fw.h radfw.h
 	rm -f $(BINS)
+	rm -f patgen pattest patlooptest hdlcstress hdlctest hdlcgen hdlcverify timertest
 	rm -f *.o ztcfg tzdriver sethdlc sethdlc-new
 	rm -f $(TZOBJS) $(LIBTONEZONE_SO) *.lo
 ifeq ($(BUILDVER),linux26)
 	$(MAKE) -C $(KSRC) SUBDIRS=$(PWD) clean
 else
 	$(MAKE) -C wct4xxp clean
+	$(MAKE) -C wctc4xxp clean
 endif
 	rm -rf .tmp_versions
 	rm -f gendigits tones.h

Modified: branches/1.2/build_tools/genudevrules
URL: http://svn.digium.com/view/zaptel/branches/1.2/build_tools/genudevrules?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/build_tools/genudevrules (original)
+++ branches/1.2/build_tools/genudevrules Wed Jan 31 11:27:30 2007
@@ -26,5 +26,6 @@
 KERNEL${match}"zaptimer", NAME="zap/timer", OWNER="asterisk", GROUP="asterisk", MODE="0660"
 KERNEL${match}"zapchannel", NAME="zap/channel", OWNER="asterisk", GROUP="asterisk", MODE="0660"
 KERNEL${match}"zappseudo", NAME="zap/pseudo", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+KERNEL${match}"zaptranscode", NAME="zap/transcode", OWNER="asterisk", GROUP="asterisk", MODE="0660"
 KERNEL${match}"zap[0-9]*", NAME="zap/%n", OWNER="asterisk", GROUP="asterisk", MODE="0660"
 EOF

Modified: branches/1.2/fxotune.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/fxotune.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/fxotune.c (original)
+++ branches/1.2/fxotune.c Wed Jan 31 11:27:30 2007
@@ -22,6 +22,7 @@
 #include <fcntl.h>
 #include <math.h>
 
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else

Modified: branches/1.2/fxstest.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/fxstest.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/fxstest.c (original)
+++ branches/1.2/fxstest.c Wed Jan 31 11:27:30 2007
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
+#include <linux/types.h>
 #include "zaptel.h"
 #include "tonezone.h"
 #include "wctdm.h"

Modified: branches/1.2/hdlcstress.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/hdlcstress.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/hdlcstress.c (original)
+++ branches/1.2/hdlcstress.c Wed Jan 31 11:27:30 2007
@@ -2,6 +2,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
+#include <linux/types.h>
 #include <linux/zaptel.h>
 #include <stdio.h>
 #include <linux/types.h>

Modified: branches/1.2/hdlctest.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/hdlctest.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/hdlctest.c (original)
+++ branches/1.2/hdlctest.c Wed Jan 31 11:27:30 2007
@@ -2,6 +2,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
+#include <linux/types.h>
 #include <linux/zaptel.h>
 #include <stdio.h>
 #include <linux/types.h>

Modified: branches/1.2/patgen.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/patgen.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/patgen.c (original)
+++ branches/1.2/patgen.c Wed Jan 31 11:27:30 2007
@@ -10,6 +10,7 @@
 #include <stdlib.h>
 #include "bittest.h"
 
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else

Modified: branches/1.2/patlooptest.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/patlooptest.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/patlooptest.c (original)
+++ branches/1.2/patlooptest.c Wed Jan 31 11:27:30 2007
@@ -10,6 +10,7 @@
 #include <stdlib.h>
 #include <time.h>
 
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else

Modified: branches/1.2/pattest.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/pattest.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/pattest.c (original)
+++ branches/1.2/pattest.c Wed Jan 31 11:27:30 2007
@@ -10,6 +10,7 @@
 #include <stdlib.h>
 #include "bittest.h"
 
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else

Modified: branches/1.2/timertest.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/timertest.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/timertest.c (original)
+++ branches/1.2/timertest.c Wed Jan 31 11:27:30 2007
@@ -8,6 +8,7 @@
 #include <sys/time.h>
 #include <errno.h>
 
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else

Modified: branches/1.2/tonezone.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/tonezone.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/tonezone.c (original)
+++ branches/1.2/tonezone.c Wed Jan 31 11:27:30 2007
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
+#include <linux/types.h>
 #include "tonezone.h"
 
 #define DEFAULT_ZT_DEV "/dev/zap/ctl"

Modified: branches/1.2/torisatool.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/torisatool.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/torisatool.c (original)
+++ branches/1.2/torisatool.c Wed Jan 31 11:27:30 2007
@@ -28,6 +28,7 @@
 #include <sys/ioctl.h>
 #include <string.h>
 #include <errno.h>
+#include <linux/types.h>
 #include "zaptel.h"
 #include "torisa.h"
 

Modified: branches/1.2/usbfxstest.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/usbfxstest.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/usbfxstest.c (original)
+++ branches/1.2/usbfxstest.c Wed Jan 31 11:27:30 2007
@@ -6,6 +6,7 @@
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include "zap.h"
+#include <linux/types.h>
 #include <linux/zaptel.h>
 
 int main(int argc, char *argv[])

Propchange: branches/1.2/wctc4xxp/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan 31 11:27:30 2007
@@ -1,0 +1,4 @@
+*.cmd
+*.mod.c
+*.ko
+codec_test

Copied: branches/1.2/wctc4xxp/base.c (from r2056, team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c)
URL: http://svn.digium.com/view/zaptel/branches/1.2/wctc4xxp/base.c?view=diff&rev=2057&p1=team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c&r1=2056&p2=branches/1.2/wctc4xxp/base.c&r2=2057
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c (original)
+++ branches/1.2/wctc4xxp/base.c Wed Jan 31 11:27:30 2007
@@ -315,6 +315,26 @@
 
 static int create_channel(struct wcdte *wc, int simple, int complicated, int part1_id, int part2_id, unsigned int *dte_chan1, unsigned int *dte_chan2);
 static int destroy_channel(struct wcdte *wc, unsigned int chan1, unsigned int chan2);
+
+/* Sanity check values */
+static inline int sanitycheck(struct zt_transcode_header *zth, unsigned int outbytes)
+{
+	if (zth->dstoffset >= sizeof(zth->dstdata))
+		return 0;
+	if (zth->dstlen >= sizeof(zth->dstdata))
+		return 0;
+	if (outbytes >= sizeof(zth->dstdata))
+		return 0;
+	if ((zth->dstoffset + zth->dstlen + outbytes) >= sizeof(zth->dstdata))
+		return 0;
+	if (zth->srcoffset >= sizeof(zth->srcdata))
+		return 0;
+	if (zth->srclen >= sizeof(zth->srcdata))
+		return 0;
+	if ((zth->srcoffset + zth->srclen) > sizeof(zth->srcdata))
+		return 0;
+	return 1;
+}
 
 static void dump_cmdq(struct wcdte *wc)
 {
@@ -871,7 +891,7 @@
 		switch (rcodec) {
 		case 0x00:		/* ulaw */
 		case 0x08:		/* alaw */
-			if (zt_tc_sanitycheck(zth, rlen) &&
+			if (sanitycheck(zth, rlen) &&
 			    ((zth->srcfmt == ZT_FORMAT_G729A && rlen == G729_SAMPLES) ||
 			     (zth->srcfmt == ZT_FORMAT_G723_1 && rlen == G723_SAMPLES))) {
 				memcpy(chars, (void *) readchunk + 54, rlen);
@@ -883,7 +903,7 @@
 			zt_transcoder_alert(ztc);
 			break;
 		case 0x04:		/* g.723.1 */
-			if (zt_tc_sanitycheck(zth, rlen) && (rlen == G723_BYTES)) {
+			if (sanitycheck(zth, rlen) && (rlen == G723_BYTES)) {
 				memcpy(chars, (void *) readchunk + 54, rlen);
 				zth->dstlen += rlen;
 				zth->dstsamples = zth->dstlen * 12;
@@ -894,7 +914,7 @@
 				zt_transcoder_alert(ztc);
 			break;
 		case 0x12:		/* g.729 */
-			if (zt_tc_sanitycheck(zth, rlen) && (rlen == G729_BYTES)) {
+			if (sanitycheck(zth, rlen) && (rlen == G729_BYTES)) {
 				memcpy(chars, (void *) readchunk + 54, rlen);
 				zth->dstlen += rlen;
 				zth->dstsamples = zth->dstlen * 8;

Modified: branches/1.2/zaptel.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/zaptel.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/zaptel.c (original)
+++ branches/1.2/zaptel.c Wed Jan 31 11:27:30 2007
@@ -79,6 +79,7 @@
 #define FAST_HDLC_NEED_TABLES
 #include "fasthdlc.h"
 
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else
@@ -118,6 +119,7 @@
 "-22.5db (CSU)"
 } ;
 
+EXPORT_SYMBOL(zt_transcode_fops);
 EXPORT_SYMBOL(zt_init_tone_state);
 EXPORT_SYMBOL(zt_dtmf_tone);
 EXPORT_SYMBOL(zt_register);
@@ -154,6 +156,7 @@
 static devfs_handle_t pseudo;
 static devfs_handle_t ctl;
 static devfs_handle_t timer;
+static devfs_handle_t transcode;
 #endif
 
 /* udev necessary data structures.  Yeah! */
@@ -249,6 +252,7 @@
 
 static struct zt_span *master;
 static struct file_operations zt_fops;
+struct file_operations *zt_transcode_fops = NULL;
 
 static struct
 {
@@ -2316,10 +2320,26 @@
 static int zt_open(struct inode *inode, struct file *file)
 {
 	int unit = UNIT(file);
+	int ret = -ENXIO;
 	struct zt_chan *chan;
 	/* Minor 0: Special "control" descriptor */
 	if (!unit) 
 		return zt_ctl_open(inode, file);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+	if (unit == 250) {
+		if (!zt_transcode_fops)
+			request_module("zttranscode");
+		if (zt_transcode_fops && zt_transcode_fops->open) {
+			if (try_module_get(zt_transcode_fops->owner)) {
+				ret = zt_transcode_fops->open(inode, file);
+				if (ret)
+					module_put(zt_transcode_fops->owner);
+			}
+			return ret;
+		}
+		return -ENXIO;
+	}
+#endif
 	if (unit == 253) {
 		if (maxspans) {
 			return zt_timing_open(inode, file);
@@ -2644,6 +2664,13 @@
 	if (unit == 253) {
 		return zt_timer_release(inode, file);
 	}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+	if (unit == 250) {
+		res = zt_transcode_fops->release(inode, file);
+		module_put(zt_transcode_fops->owner);
+		return res;
+	}
+#endif
 	if (unit == 254) {
 		chan = file->private_data;
 		if (!chan)
@@ -4395,6 +4422,10 @@
 
 	if (!unit)
 		return zt_ctl_ioctl(inode, file, cmd, data);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+	if (unit == 250)
+		return zt_transcode_fops->ioctl(inode, file, cmd, data);
+#endif
 	if (unit == 253) {
 		timer = file->private_data;
 		if (timer)
@@ -6097,6 +6128,16 @@
 	return(ret);  /* return what we found */
 }
 
+static int zt_mmap(struct file *file, struct vm_area_struct *vm)
+{
+	int unit = UNIT(file);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+	if (unit == 250)
+		return zt_transcode_fops->mmap(file, vm);
+#endif
+	return -ENOSYS;
+}
+
 static unsigned int zt_poll(struct file *file, struct poll_table_struct *wait_table)
 {
 	int unit = UNIT(file);
@@ -6104,7 +6145,10 @@
 
 	if (!unit)
 		return -EINVAL;
-
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+	if (unit == 250)
+		return zt_transcode_fops->poll(file, wait_table);
+#endif
 	if (unit == 253)
 		return zt_timer_poll(file, wait_table);
 		
@@ -6480,7 +6524,7 @@
 	read: zt_read,
 	write: zt_write,
 	poll: zt_poll,
-	mmap: NULL,
+	mmap: zt_mmap,
 	flush: NULL,
 	fsync: NULL,
 	fasync: NULL,
@@ -6555,6 +6599,7 @@
 
 #ifdef CONFIG_ZAP_UDEV /* udev support functions */
 	zap_class = class_create(THIS_MODULE, "zaptel");
+	CLASS_DEV_CREATE(zap_class, MKDEV(ZT_MAJOR, 250), NULL, "zaptranscode");
 	CLASS_DEV_CREATE(zap_class, MKDEV(ZT_MAJOR, 253), NULL, "zaptimer");
 	CLASS_DEV_CREATE(zap_class, MKDEV(ZT_MAJOR, 254), NULL, "zapchannel");
 	CLASS_DEV_CREATE(zap_class, MKDEV(ZT_MAJOR, 255), NULL, "zappseudo");
@@ -6567,6 +6612,7 @@
 	devfs_register_chrdev(ZT_MAJOR, "zaptel", &zt_fops);
 	zaptel_devfs_dir = devfs_mk_dir(NULL, "zap", NULL);
 	if (!zaptel_devfs_dir) return -EBUSY; /* This would be bad */
+	transcode = devfs_register(zaptel_devfs_dir, "transcode", DEVFS_FL_DEFAULT, ZT_MAJOR, 250, mode, &zt_fops, NULL);
 	timer = devfs_register(zaptel_devfs_dir, "timer", DEVFS_FL_DEFAULT, ZT_MAJOR, 253, mode, &zt_fops, NULL);
 	channel = devfs_register(zaptel_devfs_dir, "channel", DEVFS_FL_DEFAULT, ZT_MAJOR, 254, mode, &zt_fops, NULL);
 	pseudo = devfs_register(zaptel_devfs_dir, "pseudo", DEVFS_FL_DEFAULT, ZT_MAJOR, 255, mode, &zt_fops, NULL);
@@ -6606,6 +6652,7 @@
 			kfree(tone_zones[x]);
 #ifdef CONFIG_DEVFS_FS
 	devfs_unregister(timer);
+	devfs_unregister(transcode);
 	devfs_unregister(channel);
 	devfs_unregister(pseudo);
 	devfs_unregister(ctl);
@@ -6614,6 +6661,7 @@
 #else
 #ifdef CONFIG_ZAP_UDEV
 	class_device_destroy(zap_class, MKDEV(ZT_MAJOR, 253)); /* timer */
+	class_device_destroy(zap_class, MKDEV(ZT_MAJOR, 250)); /* transcode */
 	class_device_destroy(zap_class, MKDEV(ZT_MAJOR, 254)); /* channel */
 	class_device_destroy(zap_class, MKDEV(ZT_MAJOR, 255)); /* pseudo */
 	class_device_destroy(zap_class, MKDEV(ZT_MAJOR, 0)); /* ctl */

Modified: branches/1.2/zaptel.h
URL: http://svn.digium.com/view/zaptel/branches/1.2/zaptel.h?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/zaptel.h (original)
+++ branches/1.2/zaptel.h Wed Jan 31 11:27:30 2007
@@ -45,6 +45,7 @@
 #include <linux/interrupt.h>
 #endif
 #include <linux/fs.h>
+#include <linux/list.h>
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 #define LINUX26
@@ -666,6 +667,11 @@
  */
 #define	ZT_SETPOLARITY		_IOW (ZT_CODE, 92, int)
 
+/*
+* Transcoder operations
+*/
+#define ZT_TRANSCODE_OP		_IOWR(ZT_CODE, 93, int)
+
 /* 
  * Startup or Shutdown a span
  */
@@ -694,6 +700,47 @@
 
 #define ZT_TONEDETECT_ON	(1 << 0)		/* Detect tones */
 #define ZT_TONEDETECT_MUTE	(1 << 1)		/* Mute audio in received channel */
+
+#define ZT_TRANSCODE_MAGIC 0x74a9c0de
+
+/* Operations */
+#define ZT_TCOP_ALLOCATE	1			/* Allocate DTE channel */
+#define ZT_TCOP_TRANSCODE	2			/* Begin transcoding a block */
+#define ZT_TCOP_GETINFO		3			/* Get information (use zt_transcode_info) */
+#define ZT_TCOP_RELEASE         4                       /* Release DTE channel */
+#define ZT_TCOP_TEST            5                       /* test DTE device */
+struct zt_transcode_info {
+	__u32 op;
+	__u32 tcnum;
+	__u8 name[80];
+	__u32 numchannels;
+	__u32 srcfmts;
+	__u32 dstfmts;
+};
+
+#define __ZT_TRANSCODE_BUFSIZ	16384
+#define ZT_TRANSCODE_HDRLEN	256
+#define ZT_TRANSCODE_BUFSIZ	((__ZT_TRANSCODE_BUFSIZ) - (ZT_TRANSCODE_HDRLEN))
+#define ZT_TRANSCODE_DSTOFFSET	(((ZT_TRANSCODE_BUFSIZ) / 2) + ZT_TRANSCODE_HDRLEN)
+#define ZT_TRANSCODE_SRCOFFSET	(((ZT_TRANSCODE_BUFSIZ) / 2) + ZT_TRANSCODE_HDRLEN)
+
+struct zt_transcode_header {
+	__u32 srcfmt;		/* See formats.h -- use TCOP_RESET when you change */
+	__u32 srcoffset; 	/* In bytes -- written by user */
+	__u32 srclen;		/* In bytes -- written by user */
+
+	__u32 dstfmt;		/* See formats.h -- use TCOP_RESET when you change */
+	__u32 dstoffset;  	/* In bytes -- written by user */
+	__u32 dstlen;  		/* In bytes -- read by user */
+	__u32 dstsamples;	/* In timestamp units -- read by user */
+
+	__u32 magic;		/* Magic value -- ZT_TRANSCODE_MAGIC, read by user */
+	__u32 config;		/* Read/write by user */
+	__u32 busy:1;		/* Read/write by user */
+	__u8 userhdr[ZT_TRANSCODE_HDRLEN - (sizeof(__u32) * 14)];	/* Storage for user parameters */
+	__u8 srcdata[ZT_TRANSCODE_BUFSIZ / 2];	/* Storage of source data */
+	__u8 dstdata[ZT_TRANSCODE_BUFSIZ / 2];	/* Storage of destination data */
+};
 
 struct zt_ring_cadence {
 	int ringcadence [ZT_MAX_CADENCE];
@@ -1345,6 +1392,35 @@
 #endif	
 };
 
+struct zt_transcoder_channel {
+	void *pvt;
+	struct zt_transcoder *parent;
+	wait_queue_head_t ready;
+	int errorstatus;
+	int offset;
+	unsigned int chan_built:1;
+	unsigned int have_reference:1;
+	unsigned int busy:1;
+	unsigned int transient:1;
+	unsigned int built_fmts;
+	unsigned int flags;
+	unsigned int srcfmt;
+	unsigned int dstfmt;
+	struct zt_transcode_header *tch;
+};
+
+struct zt_transcoder {
+	struct list_head list;
+	struct module *owner;
+	char name[80];
+	int numchannels;
+	unsigned int srcfmts;
+	unsigned int dstfmts;
+	int (*operation)(struct zt_transcoder_channel *channel, int op);
+	/* Transcoder channels */
+	struct zt_transcoder_channel channels[0];
+};
+
 #define ZT_WATCHDOG_NOINTS		(1 << 0)
 
 #define ZT_WATCHDOG_INIT			1000
@@ -1390,10 +1466,23 @@
 /* Prepare writechunk buffers on all channels for this span */
 extern int zt_transmit(struct zt_span *span);
 
-
 /* Register a span.  Returns 0 on success, -1 on failure.  Pref-master is non-zero if
    we should have preference in being the master device */
 extern int zt_register(struct zt_span *span, int prefmaster);
+ 
+/* Allocate / free memory for a transcoder */
+struct zt_transcoder *zt_transcoder_alloc(int numchans);
+void zt_transcoder_free(struct zt_transcoder *ztc);
+
+/* Register a transcoder */
+int zt_transcoder_register(struct zt_transcoder *tc, struct module *owner);
+
+/* Unregister a transcoder */
+int zt_transcoder_unregister(struct zt_transcoder *tc);
+
+/* Alert a transcoder */
+int zt_transcoder_alert(struct zt_transcoder_channel *ztc);
+
 
 /* Unregister a span */
 extern int zt_unregister(struct zt_span *span);
@@ -1431,6 +1520,8 @@
 
 extern void zt_ec_chunk(struct zt_chan *chan, unsigned char *rxchunk, const unsigned char *txchunk);
 extern void zt_ec_span(struct zt_span *span);
+
+extern struct file_operations *zt_transcode_fops;
 
 /* Don't use these directly -- they're not guaranteed to
    be there. */
@@ -1611,5 +1702,32 @@
 
 #define	ZT_RADPAR_REMCOMMAND 17	/* Remote conrtol write data block & do cmd */
 
+/* Data formats for capabilities and frames alike (from Asterisk) */
+/*! G.723.1 compression */
+#define ZT_FORMAT_G723_1	(1 << 0)
+/*! GSM compression */
+#define ZT_FORMAT_GSM		(1 << 1)
+/*! Raw mu-law data (G.711) */
+#define ZT_FORMAT_ULAW		(1 << 2)
+/*! Raw A-law data (G.711) */
+#define ZT_FORMAT_ALAW		(1 << 3)
+/*! ADPCM (G.726, 32kbps) */
+#define ZT_FORMAT_G726		(1 << 4)
+/*! ADPCM (IMA) */
+#define ZT_FORMAT_ADPCM		(1 << 5)
+/*! Raw 16-bit Signed Linear (8000 Hz) PCM */
+#define ZT_FORMAT_SLINEAR	(1 << 6)
+/*! LPC10, 180 samples/frame */
+#define ZT_FORMAT_LPC10		(1 << 7)
+/*! G.729A audio */
+#define ZT_FORMAT_G729A		(1 << 8)
+/*! SpeeX Free Compression */
+#define ZT_FORMAT_SPEEX		(1 << 9)
+/*! iLBC Free Compression */
+#define ZT_FORMAT_ILBC		(1 << 10)
+/*! Maximum audio format */
+#define ZT_FORMAT_MAX_AUDIO	(1 << 15)
+/*! Maximum audio mask */
+#define ZT_FORMAT_AUDIO_MASK	((1 << 16) - 1)
 
 #endif /* _LINUX_ZAPTEL_H */

Modified: branches/1.2/zonedata.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/zonedata.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/zonedata.c (original)
+++ branches/1.2/zonedata.c Wed Jan 31 11:27:30 2007
@@ -23,6 +23,7 @@
  * UK information from BT SIN 350 Issue 1.1
  * Helpful reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf
  */
+#include <linux/types.h>
 #include "tonezone.h"
 
 struct tone_zone builtin_zones[]  =

Modified: branches/1.2/ztcfg.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/ztcfg.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/ztcfg.c (original)
+++ branches/1.2/ztcfg.c Wed Jan 31 11:27:30 2007
@@ -38,6 +38,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include "ztcfg.h"
+#include <linux/types.h>
 #include "tonezone.h"
 #include "zaptel.h"
 

Modified: branches/1.2/ztd-eth.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/ztd-eth.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/ztd-eth.c (original)
+++ branches/1.2/ztd-eth.c Wed Jan 31 11:27:30 2007
@@ -36,6 +36,7 @@
 #ifdef CONFIG_DEVFS_FS
 #include <linux/devfs_fs_kernel.h>
 #endif
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else

Modified: branches/1.2/ztd-loc.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/ztd-loc.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/ztd-loc.c (original)
+++ branches/1.2/ztd-loc.c Wed Jan 31 11:27:30 2007
@@ -60,6 +60,7 @@
 #ifdef CONFIG_DEVFS_FS
 #include <linux/devfs_fs_kernel.h>
 #endif
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else

Modified: branches/1.2/ztdiag.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/ztdiag.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/ztdiag.c (original)
+++ branches/1.2/ztdiag.c Wed Jan 31 11:27:30 2007
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else

Modified: branches/1.2/ztdummy.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/ztdummy.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/ztdummy.c (original)
+++ branches/1.2/ztdummy.c Wed Jan 31 11:27:30 2007
@@ -59,6 +59,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/errno.h>
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else

Modified: branches/1.2/ztdynamic.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/ztdynamic.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/ztdynamic.c (original)
+++ branches/1.2/ztdynamic.c Wed Jan 31 11:27:30 2007
@@ -36,6 +36,7 @@
 #ifdef CONFIG_DEVFS_FS
 #include <linux/devfs_fs_kernel.h>
 #endif
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else

Modified: branches/1.2/ztmonitor.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/ztmonitor.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/ztmonitor.c (original)
+++ branches/1.2/ztmonitor.c Wed Jan 31 11:27:30 2007
@@ -38,6 +38,7 @@
 #include <sys/time.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #include "tonezone.h"

Modified: branches/1.2/zttool.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/zttool.c?view=diff&rev=2057&r1=2056&r2=2057
==============================================================================
--- branches/1.2/zttool.c (original)
+++ branches/1.2/zttool.c Wed Jan 31 11:27:30 2007
@@ -38,6 +38,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <newt.h>
+#include <linux/types.h>
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #include "tonezone.h"



More information about the zaptel-commits mailing list