[zaptel-commits] tzafrir: branch tzafrir/kernelmove r2314 - in /team/tzafrir/kernelmove: ./ bu...

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Fri Mar 16 16:36:21 MST 2007


Author: tzafrir
Date: Fri Mar 16 18:36:20 2007
New Revision: 2314

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2314
Log:
 * synced to a more recent version of trunk
 * A minimal kernel/Makefile for building on 2.6.8
 * Fix hos programs building hon kernel/2.6.8

Added:
    team/tzafrir/kernelmove/kernel/xpp/.version   (props changed)
      - copied unchanged from r2295, trunk/xpp/.version
    team/tzafrir/kernelmove/kernel/xpp/card_bri.c   (props changed)
      - copied unchanged from r2295, trunk/xpp/card_bri.c
    team/tzafrir/kernelmove/kernel/xpp/card_bri.h   (props changed)
      - copied unchanged from r2295, trunk/xpp/card_bri.h
    team/tzafrir/kernelmove/kernel/xpp/utils/lszaptel   (props changed)
      - copied unchanged from r2295, trunk/xpp/utils/lszaptel
    team/tzafrir/kernelmove/kernel/xpp/utils/xpp_sync   (props changed)
      - copied unchanged from r2295, trunk/xpp/utils/xpp_sync
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/
      - copied from r2295, trunk/xpp/utils/zconf/
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/
      - copied from r2295, trunk/xpp/utils/zconf/Zaptel/
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel.pm   (props changed)
      - copied unchanged from r2295, trunk/xpp/utils/zconf/Zaptel.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Chans.pm   (props changed)
      - copied unchanged from r2295, trunk/xpp/utils/zconf/Zaptel/Chans.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Span.pm   (props changed)
      - copied unchanged from r2295, trunk/xpp/utils/zconf/Zaptel/Span.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Xpp/
      - copied from r2295, trunk/xpp/utils/zconf/Zaptel/Xpp/
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Xpp.pm   (props changed)
      - copied unchanged from r2295, trunk/xpp/utils/zconf/Zaptel/Xpp.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm   (props changed)
      - copied unchanged from r2295, trunk/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm   (props changed)
      - copied unchanged from r2295, trunk/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zt_registration   (props changed)
      - copied unchanged from r2295, trunk/xpp/utils/zt_registration
Modified:
    team/tzafrir/kernelmove/Makefile
    team/tzafrir/kernelmove/build_tools/make_firmware_object
    team/tzafrir/kernelmove/build_tools/make_svn_branch_name
    team/tzafrir/kernelmove/firmware/Makefile
    team/tzafrir/kernelmove/kernel/   (props changed)
    team/tzafrir/kernelmove/kernel/Kbuild
    team/tzafrir/kernelmove/kernel/Makefile
    team/tzafrir/kernelmove/kernel/wct4xxp/base.c
    team/tzafrir/kernelmove/kernel/wct4xxp/vpm450m.c
    team/tzafrir/kernelmove/kernel/wctdm24xxp.c
    team/tzafrir/kernelmove/kernel/xpp/Makefile
    team/tzafrir/kernelmove/kernel/xpp/card_fxo.c
    team/tzafrir/kernelmove/kernel/xpp/card_fxs.c
    team/tzafrir/kernelmove/kernel/xpp/card_global.c
    team/tzafrir/kernelmove/kernel/xpp/firmwares/FPGA_1141.hex
    team/tzafrir/kernelmove/kernel/xpp/firmwares/FPGA_1151.hex
    team/tzafrir/kernelmove/kernel/xpp/firmwares/FPGA_FXS.hex
    team/tzafrir/kernelmove/kernel/xpp/firmwares/USB_1140.hex
    team/tzafrir/kernelmove/kernel/xpp/firmwares/USB_1150.hex
    team/tzafrir/kernelmove/kernel/xpp/utils/Makefile
    team/tzafrir/kernelmove/kernel/xpp/utils/fpga_load.c
    team/tzafrir/kernelmove/kernel/xpp/utils/genzaptelconf
    team/tzafrir/kernelmove/kernel/xpp/utils/hexfile.c
    team/tzafrir/kernelmove/kernel/xpp/utils/hexfile.h
    team/tzafrir/kernelmove/kernel/xpp/utils/test_parse.c
    team/tzafrir/kernelmove/kernel/xpp/utils/xpp_fxloader
    team/tzafrir/kernelmove/kernel/xpp/xbus-core.c
    team/tzafrir/kernelmove/kernel/xpp/xbus-core.h
    team/tzafrir/kernelmove/kernel/xpp/xpd.h
    team/tzafrir/kernelmove/kernel/xpp/xpp_usb.c
    team/tzafrir/kernelmove/kernel/xpp/xpp_zap.c
    team/tzafrir/kernelmove/kernel/xpp/xpp_zap.h
    team/tzafrir/kernelmove/kernel/xpp/xproto.c
    team/tzafrir/kernelmove/kernel/xpp/xproto.h
    team/tzafrir/kernelmove/kernel/zaptel.c
    team/tzafrir/kernelmove/kernel/zaptel.h
    team/tzafrir/kernelmove/kernel/zconfig.h
    team/tzafrir/kernelmove/kernel/ztcodec_dte/   (props changed)
    team/tzafrir/kernelmove/zaptel.init

Modified: team/tzafrir/kernelmove/Makefile
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/Makefile?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/Makefile (original)
+++ team/tzafrir/kernelmove/Makefile Fri Mar 16 18:36:20 2007
@@ -7,7 +7,7 @@
 
 .EXPORT_ALL_VARIABLES:
 
-.PHONY: menuselect distclean dist-clean clean version.h all _all install b410p devices programs modules linux24 linux26 xpp tests devel data stackcheck install-udev config update install-programs install-modules install-linux24 install-linux26 firmware install-include install-libs xpp-install
+.PHONY: menuselect distclean dist-clean clean version.h all _all install b410p devices programs modules linux24 linux26 xpp tests devel data stackcheck install-udev config update install-programs install-modules install-linux24 install-linux26 firmware install-include install-libs xpp-install xpp-utils
 
 PWD=$(shell pwd)
 
@@ -35,27 +35,6 @@
 CFLAGS+=-Ikernel # FIXME: we can't really need everything from there.
 LCFLAGS=-fPIC $(CFLAGS) -DBUILDING_TONEZONE
 
-# If the file .zaptel.makeopts is present in your home directory, you can
-# include all of your favorite menuselect options so that every time you download
-# a new version of Asterisk, you don't have to run menuselect to set them.
-# The file /etc/zaptel.makeopts will also be included but can be overridden
-# by the file in your home directory.
-
-GLOBAL_MAKEOPTS=$(wildcard /etc/zaptel.makeopts)
-USER_MAKEOPTS=$(wildcard ~/.zaptel.makeopts)
-
-ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
- ifneq ($(wildcard menuselect.makeopts),)
-  include menuselect.makeopts
- endif
-endif
-
-ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
- ifneq ($(wildcard makeopts),)
-  include makeopts
- endif
-endif
-
 CHECK_SELINUX	= [ -x /usr/sbin/sestatus ] && (/usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled")
 
 #
@@ -112,6 +91,27 @@
 LTZ_SO_MINOR_VER:= 0
 LTZ_SO		:= $(LTZ_SO_BASE).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER)
 
+# If the file .zaptel.makeopts is present in your home directory, you can
+# include all of your favorite menuselect options so that every time you download
+# a new version of Asterisk, you don't have to run menuselect to set them.
+# The file /etc/zaptel.makeopts will also be included but can be overridden
+# by the file in your home directory.
+
+GLOBAL_MAKEOPTS=$(wildcard /etc/zaptel.makeopts)
+USER_MAKEOPTS=$(wildcard ~/.zaptel.makeopts)
+
+ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
+ ifneq ($(wildcard menuselect.makeopts),)
+  include menuselect.makeopts
+ endif
+endif
+
+ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
+ ifneq ($(wildcard makeopts),)
+  include makeopts
+ endif
+endif
+
 MODULES:=pciradio tor2 torisa wcfxo wct1xxp wctdm wctdm24xxp wcte11xp wcusb zaptel ztd-eth ztd-loc ztdummy ztdynamic zttranscode
 #ZAP_SUBDIRS:=wct4xxp ztcodec_dte xpp datamods
 MODULES:=$(filter-out $(MENUSELECT_MODULES),$(MODULES))
@@ -121,6 +121,8 @@
 MODULESKO:=$(MODULES:%=%.ko)
 ifeq ($(BUILDVER),linux26)
 HOTPLUG_FIRMWARE:=$(shell if grep CONFIG_FW_LOADER $(KINCLUDES)/linux/autoconf.h | grep -q undef; then echo "no"; else echo "yes"; fi)
+else
+HOTPLUG_FIRMWARE:=no
 endif
 
 BIN_DIR:=$(INSTALL_PREFIX)/sbin
@@ -161,6 +163,8 @@
 all: menuselect.makeopts modules programs
 
 programs: $(BINS) $(LTZ_SO) $(LTZ_A)
+
+programs: $(BINS) xpp-utils
 
 modules: $(BUILDVER)
 
@@ -392,6 +396,7 @@
 	$(MAKE) -C kernel clean
 endif
 	$(MAKE) -C firmware clean
+	-@$(MAKE) -C xpp/utils clean
 	rm -f xpp/*.ko xpp/*.mod.c xpp/.*o.cmd
 	rm -f xpp/*.o xpp/*.mod.o
 	rm -rf .tmp_versions
@@ -420,8 +425,10 @@
 	@echo "****"
 	@exit 1
 
-menuselect.makeopts: menuselect/menuselect menuselect-tree
-	@menuselect/menuselect --check-deps ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} $@
+#menuselect.makeopts: menuselect/menuselect menuselect-tree
+menuselect.makeopts: 
+	#@menuselect/menuselect --check-deps ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} $@
+	touch $@
 
 menuconfig: menuselect
 

Modified: team/tzafrir/kernelmove/build_tools/make_firmware_object
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/build_tools/make_firmware_object?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/build_tools/make_firmware_object (original)
+++ team/tzafrir/kernelmove/build_tools/make_firmware_object Fri Mar 16 18:36:20 2007
@@ -6,7 +6,7 @@
 #   2 - output file
 #   3 - template output file (used to learn desired format)
 
-bfdname=`objdump -f ${3} | grep -e "${3}:" | sed "s/.*file format \(.*\)/\1/"`
-bfdarch=`objdump -f ${3} | grep -e "architecture:" | sed "s/.*ture: \(.*\),.*/\1/"`
+bfdname=`LANG=C objdump -f ${3} | grep -e "${3}:" | sed "s/.*file format \(.*\)/\1/"`
+bfdarch=`LANG=C objdump -f ${3} | grep -e "architecture:" | sed "s/.*ture: \(.*\),.*/\1/"`
 
 objcopy -I binary ${1} -B ${bfdarch} -O ${bfdname} ${2} --rename-section .data=.rodata,alloc,load,data,contents,readonly

Modified: team/tzafrir/kernelmove/build_tools/make_svn_branch_name
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/build_tools/make_svn_branch_name?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/build_tools/make_svn_branch_name (original)
+++ team/tzafrir/kernelmove/build_tools/make_svn_branch_name Fri Mar 16 18:36:20 2007
@@ -3,6 +3,7 @@
 PARTS=`LANG=C svn info | grep URL | awk '{print $2;}' | sed -e s:^.*/svn/zaptel/:: | sed -e 's:/: :g'`
 BRANCH=0
 TEAM=0
+TAG=0
 
 REV=`svnversion -c . | cut -d: -f2`
 
@@ -14,6 +15,12 @@
 
 for PART in $PARTS
 do
+  if [ ${TAG} != 0 ]
+  then
+      RESULT="${PART}"
+      break
+  fi
+
   if [ ${BRANCH} != 0 ]
   then
       RESULT="${RESULT}-${PART}"
@@ -35,8 +42,7 @@
 
   if [ "${PART}" = "tags" ]
   then
-      BRANCH=1
-      RESULT="tag"
+      TAG=1
       continue
   fi
 
@@ -47,4 +53,9 @@
   fi
 done
 
-echo ${RESULT##-}-r${REV}
+if [ ${TAG} != 0 ]
+then
+    echo ${RESULT}
+else
+    echo ${RESULT##-}-r${REV}
+fi

Modified: team/tzafrir/kernelmove/firmware/Makefile
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/firmware/Makefile?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/firmware/Makefile (original)
+++ team/tzafrir/kernelmove/firmware/Makefile Fri Mar 16 18:36:20 2007
@@ -58,11 +58,75 @@
 		exit 1; \
 	fi
 
-# Download and extract firmware tarball
-zaptel-fw-%.tar.gz: have_download
-	@if test ! -f $@; then $(DOWNLOAD) $(WGET_ARGS) $(FIRMWARE_URL)/$@; fi;	
+# Download and extract firmware tarballs
+zaptel-fw-oct6114-064-%.tar.gz: have_download
+ifeq ($(shell if ( [ "$(HOTPLUG_FIRMWARE)" == "no" ] ) || ( [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ] && ! [ -f $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/.zaptel-fw-oct6114-064-$(OCT6114_064_VERSION) ] ) || ( [ -d $(INSTALL_PREFIX)/lib/firmware ] && ! [ -f $(INSTALL_PREFIX)/lib/firmware/.zaptel-fw-oct6114-064-$(OCT6114_064_VERSION) ] ); then echo "yes"; else echo "no"; fi),yes)
+	@echo "Attempting to download $@"
+	@if test ! -f $@; then $(DOWNLOAD) $(WGET_ARGS) $(FIRMWARE_URL)/$@; fi;
 	if test ! -f $@; then exit 1; fi; \
 	(cat $@ | gzip -d | tar -xf -)
+ifeq ($(HOTPLUG_FIRMWARE),yes)
+	@echo "Installing zaptel-fw-oct6114-064.bin to hotplug firmware directories"
+	if [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ]; then \
+		$(INSTALL) -m 644 zaptel-fw-oct6114-064.bin $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \
+		rm -rf $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/.zaptel-fw-oct6114-064-*; \
+		touch $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/.zaptel-fw-oct6114-064-$(OCT6114_064_VERSION); \
+	fi
+	if [ -d $(INSTALL_PREFIX)/lib/firmware ]; then \
+		$(INSTALL) -m 644 zaptel-fw-oct6114-064.bin $(INSTALL_PREFIX)/lib/firmware; \
+		rm -rf $(INSTALL_PREFIX)/lib/firmware/.zaptel-fw-oct6114-064-*; \
+		touch $(INSTALL_PREFIX)/lib/firmware/.zaptel-fw-oct6114-064-$(OCT6114_064_VERSION); \
+	fi
+endif
+else
+	@echo "Firmware zaptel-fw-oct6114-064.bin is already installed with latest version $(OCT6114_064_VERSION)"
+endif
+
+zaptel-fw-oct6114-128-%.tar.gz: have_download
+ifeq ($(shell if ( [ "$(HOTPLUG_FIRMWARE)" == "no" ] ) || ( [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ] && ! [ -f $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/.zaptel-fw-oct6114-128-$(OCT6114_128_VERSION) ] ) || ( [ -d $(INSTALL_PREFIX)/lib/firmware ] && ! [ -f $(INSTALL_PREFIX)/lib/firmware/.zaptel-fw-oct6114-128-$(OCT6114_128_VERSION) ] ); then echo "yes"; else echo "no"; fi),yes)
+	@echo "Attempting to download $@"
+	@if test ! -f $@; then $(DOWNLOAD) $(WGET_ARGS) $(FIRMWARE_URL)/$@; fi;
+	if test ! -f $@; then exit 1; fi; \
+	(cat $@ | gzip -d | tar -xf -)
+ifeq ($(HOTPLUG_FIRMWARE),yes)
+	@echo "Installing zaptel-fw-oct6114-128.bin to hotplug firmware directories"
+	if [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ]; then \
+		$(INSTALL) -m 644 zaptel-fw-oct6114-128.bin $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \
+		rm -rf $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/.zaptel-fw-oct6114-128-*; \
+		touch $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/.zaptel-fw-oct6114-128-$(OCT6114_128_VERSION); \
+	fi
+	if [ -d $(INSTALL_PREFIX)/lib/firmware ]; then \
+		$(INSTALL) -m 644 zaptel-fw-oct6114-128.bin $(INSTALL_PREFIX)/lib/firmware; \
+		rm -rf $(INSTALL_PREFIX)/lib/firmware/.zaptel-fw-oct6114-128-*; \
+		touch $(INSTALL_PREFIX)/lib/firmware/.zaptel-fw-oct6114-128-$(OCT6114_128_VERSION); \
+	fi
+endif
+else
+	@echo "Firmware zaptel-fw-oct6114-128.bin is already installed with latest version $(OCT6114_128_VERSION)"
+endif
+
+zaptel-fw-tc400m-%.tar.gz: have_download
+ifeq ($(shell if ( [ "$(HOTPLUG_FIRMWARE)" == "no" ] ) || ( [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ] && ! [ -f $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/.zaptel-fw-tc400m-$(TC400M_VERSION) ] ) || ( [ -d $(INSTALL_PREFIX)/lib/firmware ] && ! [ -f $(INSTALL_PREFIX)/lib/firmware/.zaptel-fw-tc400m-$(TC400M_VERSION) ] ); then echo "yes"; else echo "no"; fi),yes)
+	@echo "Attempting to download $@"
+	@if test ! -f $@; then $(DOWNLOAD) $(WGET_ARGS) $(FIRMWARE_URL)/$@; fi;
+	if test ! -f $@; then exit 1; fi; \
+	(cat $@ | gzip -d | tar -xf -)
+ifeq ($(HOTPLUG_FIRMWARE),yes)
+	@echo "Installing zaptel-fw-tc400m.bin to hotplug firmware directories"
+	if [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ]; then \
+		$(INSTALL) -m 644 zaptel-fw-tc400m.bin $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \
+		rm -rf $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/.zaptel-fw-tc400m-*; \
+		touch $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/.zaptel-fw-tc400m-$(TC400M_VERSION); \
+	fi
+	if [ -d $(INSTALL_PREFIX)/lib/firmware ]; then \
+		$(INSTALL) -m 644 zaptel-fw-tc400m.bin $(INSTALL_PREFIX)/lib/firmware; \
+		rm -rf $(INSTALL_PREFIX)/lib/firmware/.zaptel-fw-tc400m-*; \
+		touch $(INSTALL_PREFIX)/lib/firmware/.zaptel-fw-tc400m-$(TC400M_VERSION); \
+	fi
+endif
+else
+	@echo "Firmware zaptel-fw-tc400m.bin is already installed with latest version $(TC400M_VERSION)"
+endif
 
 # Clean up any downloaded/extracted firmware packages
 dist-clean: clean
@@ -78,22 +142,16 @@
 
 # Install all downloaded firmware images for hotplug usage and build headers for inclusion
 hotplug-install: $(FIRMWARE)
-ifneq (,$(FIRMWARE))
-	if [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ]; then \
-		$(INSTALL) -m 644 zaptel-fw-*.bin $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \
-	fi
-	if [ -d $(INSTALL_PREFIX)/lib/firmware ]; then \
-		$(INSTALL) -m 644 zaptel-fw-*.bin $(INSTALL_PREFIX)/lib/firmware; \
-	fi
-endif
 
 # Uninstall any installed zaptel firmware images from hotplug firmware directories
 hotplug-uninstall:
 	if [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ]; then \
 		rm -f $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/zaptel-fw-*.bin; \
+		rm -f $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/.zaptel-fw*; \
 	fi
 	if [ -d $(INSTALL_PREFIX)/lib/firmware ]; then \
 		rm -f $(INSTALL_PREFIX)/lib/firmware/zaptel-fw-*.bin; \
+		rm -f $(INSTALL_PREFIX)/lib/firmware/.zaptel-fw*; \
 	fi
 
 # Build object file of an oct6114 064 firmware image for linking

Propchange: team/tzafrir/kernelmove/kernel/
------------------------------------------------------------------------------
--- branch-1.4-blocked (added)
+++ branch-1.4-blocked Fri Mar 16 18:36:20 2007
@@ -1,0 +1,1 @@
+/branches/1.4:1889,2271

Propchange: team/tzafrir/kernelmove/kernel/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: team/tzafrir/kernelmove/kernel/Kbuild
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/Kbuild?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/kernel/Kbuild (original)
+++ team/tzafrir/kernelmove/kernel/Kbuild Fri Mar 16 18:36:20 2007
@@ -6,9 +6,11 @@
 
 obj-m := $(MODULES:%=%.o) $(ZAP_SUBDIRS:%=%/)
 
-hostprogs-y := gendigits makefw
+host-progs := gendigits makefw
 
-HOSTLOADLIBES_gendigits += -lm
+# FIXME: use the more specific one:
+#HOSTLOADLIBES_gendigits += -lm
+HOST_LOADLIBES		+= -lm
 
 $(obj)/zaptel.o: $(obj)/tones.h
 $(obj)/pciradio.o: $(obj)/radfw.h
@@ -17,9 +19,9 @@
 $(obj)/tones.h: $(obj)/gendigits
 	$^ > $@
 
-$(obj)/tor2fw.h: $(src)/tormenta2.rbt makefw 
+$(obj)/tor2fw.h: $(src)/tormenta2.rbt $(obj)/makefw 
 	$(obj)/makefw $< tor2fw > $@
 
-$(obj)/radfw.h: $(src)/pciradio.rbt makefw
+$(obj)/radfw.h: $(src)/pciradio.rbt $(obj)/makefw
 	$(obj)/makefw $< radfw > $@
 

Modified: team/tzafrir/kernelmove/kernel/Makefile
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/Makefile?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/kernel/Makefile (original)
+++ team/tzafrir/kernelmove/kernel/Makefile Fri Mar 16 18:36:20 2007
@@ -1,2 +1,9 @@
 # needed solely for kernel 2.6.x <= 2.6.8 , that does not support Kbuild
-include Kbuild
+include $(src)/Kbuild
+
+# if you get an error for "missing /Kbuild", you're trying to run 'make'
+# directly in this directory. This will not work. Use:
+#
+#   make modules
+#
+# in the top-evel directory.

Modified: team/tzafrir/kernelmove/kernel/wct4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/wct4xxp/base.c?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/kernel/wct4xxp/base.c (original)
+++ team/tzafrir/kernelmove/kernel/wct4xxp/base.c Fri Mar 16 18:36:20 2007
@@ -2732,8 +2732,6 @@
 	inirq = 1;
 	/* Make sure it's really for us */
 	status = t4_pci_in(wc, WC_INTR);
-	t4_pci_out(wc, WC_INTR, 0);
-
 	/* Process framer interrupts */
 	status2 = t4_framer_in(wc, 0, FRMR_CIS);
 	if (status2 & 0x0f) {
@@ -2752,6 +2750,8 @@
 #else
 		return;
 #endif		
+
+	t4_pci_out(wc, WC_INTR, 0);
 
 	if (!wc->spansstarted) {
 		printk("Not prepped yet!\n");

Modified: team/tzafrir/kernelmove/kernel/wct4xxp/vpm450m.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/wct4xxp/vpm450m.c?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/kernel/wct4xxp/vpm450m.c (original)
+++ team/tzafrir/kernelmove/kernel/wct4xxp/vpm450m.c Fri Mar 16 18:36:20 2007
@@ -204,15 +204,20 @@
 
 static void vpm450m_setecmode(struct vpm450m *vpm450m, int channel, int mode)
 {
-	tOCT6100_CHANNEL_MODIFY modify;
+	tOCT6100_CHANNEL_MODIFY *modify;
 	UINT32 ulResult;
 
 	if (vpm450m->ecmode[channel] == mode)
 		return;
-	Oct6100ChannelModifyDef(&modify);
-	modify.ulEchoOperationMode = mode;
-	modify.ulChannelHndl = vpm450m->aulEchoChanHndl[channel];
-	ulResult = Oct6100ChannelModify(vpm450m->pApiInstance, &modify);
+	modify = kmalloc(sizeof(tOCT6100_CHANNEL_MODIFY), GFP_KERNEL);
+	if (!modify) {
+		printk("wct4xxp: Unable to allocate memory for setec!\n");
+		return;
+	}
+	Oct6100ChannelModifyDef(modify);
+	modify->ulEchoOperationMode = mode;
+	modify->ulChannelHndl = vpm450m->aulEchoChanHndl[channel];
+	ulResult = Oct6100ChannelModify(vpm450m->pApiInstance, modify);
 	if (ulResult != GENERIC_OK) {
 		printk("Failed to apply echo can changes on channel %d!\n", channel);
 	} else {
@@ -221,21 +226,27 @@
 #endif
 		vpm450m->ecmode[channel] = mode;
 	}
+	kfree(modify);
 }
 
 void vpm450m_setdtmf(struct vpm450m *vpm450m, int channel, int detect, int mute)
 {
-	tOCT6100_CHANNEL_MODIFY modify;
+	tOCT6100_CHANNEL_MODIFY *modify;
 	UINT32 ulResult;
 
-	Oct6100ChannelModifyDef(&modify);
-	modify.ulChannelHndl = vpm450m->aulEchoChanHndl[channel];
+	modify = kmalloc(sizeof(tOCT6100_CHANNEL_MODIFY), GFP_KERNEL);
+	if (!modify) {
+		printk("wct4xxp: Unable to allocate memory for setdtmf!\n");
+		return;
+	}
+	Oct6100ChannelModifyDef(modify);
+	modify->ulChannelHndl = vpm450m->aulEchoChanHndl[channel];
 	if (mute) {
 		vpm450m->chanflags[channel] |= FLAG_MUTE;
-		modify.VqeConfig.fDtmfToneRemoval = TRUE;
+		modify->VqeConfig.fDtmfToneRemoval = TRUE;
 	} else {
 		vpm450m->chanflags[channel] &= ~FLAG_MUTE;
-		modify.VqeConfig.fDtmfToneRemoval = FALSE;
+		modify->VqeConfig.fDtmfToneRemoval = FALSE;
 	}
 	if (detect)
 		vpm450m->chanflags[channel] |= FLAG_DTMF;
@@ -251,11 +262,12 @@
 			vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_DIGITAL);
 	}
 
-	ulResult = Oct6100ChannelModify(vpm450m->pApiInstance, &modify);
+	ulResult = Oct6100ChannelModify(vpm450m->pApiInstance, modify);
 	if (ulResult != GENERIC_OK) {
 		printk("Failed to apply dtmf mute changes on channel %d!\n", channel);
 	}
 /*	printk("VPM450m: Setting DTMF on channel %d: %s / %s\n", channel, (detect ? "DETECT" : "NO DETECT"), (mute ? "MUTE" : "NO MUTE")); */
+	kfree(modify);
 }
 
 void vpm450m_setec(struct vpm450m *vpm450m, int channel, int eclen)
@@ -352,7 +364,9 @@
 				*tone = 'f';
 				break;
 			default:
+#ifdef OCTASIC_DEBUG
 				printk("Unknown tone value %08x\n", tonefound.ulToneDetected);
+#endif
 				*tone = 'u';
 				break;
 			}

Modified: team/tzafrir/kernelmove/kernel/wctdm24xxp.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/wctdm24xxp.c?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/kernel/wctdm24xxp.c (original)
+++ team/tzafrir/kernelmove/kernel/wctdm24xxp.c Fri Mar 16 18:36:20 2007
@@ -696,11 +696,12 @@
 
 	for (x=0;x<ZT_CHUNKSIZE;x++) {
 		/* Send a sample, as a 32-bit word */
-		for (y=0;y < wc->type;y++) {
+		for (y=0;y < wc->cards;y++) {
 			if (!x)
 				cmd_checkisr(wc, y);
 
-			writechunk[y] = wc->chans[y].writechunk[x];
+			if (y < wc->type)
+				writechunk[y] = wc->chans[y].writechunk[x];
 			cmd_dequeue(wc, writechunk, y, x);
 		}
 #ifdef VPM_SUPPORT
@@ -962,8 +963,9 @@
 				cmd_retransmit(wc);
 			}
 		}
-		for (y=0;y < wc->type;y++) {
-			wc->chans[y].readchunk[x] = readchunk[y];
+		for (y=0;y < wc->cards;y++) {
+			if (y < wc->type)
+				wc->chans[y].readchunk[x] = readchunk[y];
 			cmd_decifer(wc, readchunk, y);
 		}
 #ifdef VPM_SUPPORT

Propchange: team/tzafrir/kernelmove/kernel/xpp/.version
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/tzafrir/kernelmove/kernel/xpp/.version
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/tzafrir/kernelmove/kernel/xpp/.version
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/tzafrir/kernelmove/kernel/xpp/Makefile
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/xpp/Makefile?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/kernel/xpp/Makefile (original)
+++ team/tzafrir/kernelmove/kernel/xpp/Makefile Fri Mar 16 18:36:20 2007
@@ -1,5 +1,7 @@
+ZAPTEL_DIR	= $(SUBDIRS)
+
 EXTRA_CFLAGS	=	$(XPP_LOCAL_CFLAGS)	\
-			-g3 -I$(SUBDIRS)	\
+			-g3 -I$(ZAPTEL_DIR)	\
 			-DDEBUG			\
 			-DPOLL_DIGITAL_INPUTS	\
 			-DWITH_ECHO_SUPPRESSION	\
@@ -8,9 +10,6 @@
 ifneq	(,$(filter y m,$(CONFIG_DEBUG_FS)))
 EXTRA_CFLAGS	+=	-DXPP_DEBUGFS
 endif
-
-ZAPTEL_DIR	= $(SUBDIRS)
-
 ifneq	(,$(shell grep -w echo_can_state_t $(ZAPTEL_DIR)/zaptel.h))
 EXTRA_CFLAGS	+=	-DZAPTEL_EC_TYPEDEF
 endif
@@ -42,6 +41,7 @@
 $(obj)/card_fxs.o $(obj)/card_fxo.o $(obj)/card_bri.o $(obj)/xpp_usb.o $(obj)/xpp.o: $(obj)/xpp_version.h
 
 $(obj)/xpp_version.h: FORCE
+	$(Q)echo "Compile xpp (version $(XPP_VERSION_STR))"
 	$(Q)echo '#define	XPP_VERSION	$(XPP_VERSION_STR)' > $@.tmp
 	$(Q)if cmp -s $@.tmp $@ ; then echo; else \
 		mv $@.tmp $@ ; \

Propchange: team/tzafrir/kernelmove/kernel/xpp/card_bri.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/tzafrir/kernelmove/kernel/xpp/card_bri.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/tzafrir/kernelmove/kernel/xpp/card_bri.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: team/tzafrir/kernelmove/kernel/xpp/card_bri.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/tzafrir/kernelmove/kernel/xpp/card_bri.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/tzafrir/kernelmove/kernel/xpp/card_bri.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/tzafrir/kernelmove/kernel/xpp/card_fxo.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/xpp/card_fxo.c?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/kernel/xpp/card_fxo.c (original)
+++ team/tzafrir/kernelmove/kernel/xpp/card_fxo.c Fri Mar 16 18:36:20 2007
@@ -417,6 +417,23 @@
 	return 0;
 }
 
+static int FXO_card_open(xpd_t *xpd, lineno_t chan)
+{
+	struct FXO_priv_data	*priv;
+
+	BUG_ON(!xpd);
+	priv = xpd->priv;
+	/*
+	 * We pretend to have battery. If this is really the case
+	 * than next calls to update_battery_status() won't change it.
+	 * If we don't have battery, than on the next calls to
+	 * update_battery_status() a battery_debounce[] cycle would start.
+	 * Than, if no-battery is persistent, asterisk would be notified.
+	 */
+	BIT_SET(priv->battery, chan);
+	return 0;
+}
+
 static void poll_battery(xbus_t *xbus, xpd_t *xpd)
 {
 	int	i;
@@ -634,13 +651,17 @@
 		if(IS_SET(priv->battery, chipsel) && priv->battery_debounce[chipsel]++ > BAT_DEBOUNCE) {
 			DBG("%s/%s/%d: BATTERY OFF voltage=%d\n", xpd->xbus->busname, xpd->xpdname, chipsel, bat);
 			BIT_CLR(priv->battery, chipsel);
-			update_line_status(xpd, chipsel, 0);
+			if(SPAN_REGISTERED(xpd))
+				zt_qevent_lock(&xpd->chans[chipsel], ZT_EVENT_ALARM);
+
 		}
 	} else {
 		priv->battery_debounce[chipsel] = 0;
 		if(!IS_SET(priv->battery, chipsel)) {
 			DBG("%s/%s/%d: BATTERY ON voltage=%d\n", xpd->xbus->busname, xpd->xpdname, chipsel, bat);
 			BIT_SET(priv->battery, chipsel);
+			if(SPAN_REGISTERED(xpd))
+				zt_qevent_lock(&xpd->chans[chipsel], ZT_EVENT_NOALARM);
 		}
 	}
 	/*
@@ -700,7 +721,6 @@
 HANDLER_DEF(FXO, DAA_REPLY)
 {
 	reg_cmd_t		*info = &RPACKET_FIELD(pack, FXO, DAA_REPLY, regcmd);
-	unsigned long		flags;
 	struct FXO_priv_data	*priv;
 	lineno_t		chipsel;
 
@@ -709,7 +729,6 @@
 				__FUNCTION__, cmd->name, XPD_NUM(pack->addr));
 		return -EPROTO;
 	}
-	spin_lock_irqsave(&xpd->lock, flags);
 	priv = xpd->priv;
 	BUG_ON(!priv);
 	chipsel = REG_FIELD(info, chipsel);
@@ -734,7 +753,6 @@
 			REG_FIELD(&xpd->requested_reply, subreg) == REG_FIELD(info, subreg)) {
 		xpd->last_reply = *info;
 	}
-	spin_unlock_irqrestore(&xpd->lock, flags);
 	return 0;
 }
 
@@ -757,12 +775,11 @@
 		.card_hooksig	= FXO_card_hooksig,
 		.card_tick	= FXO_card_tick,
 		.card_ioctl	= FXO_card_ioctl,
+		.card_open	= FXO_card_open,
 
 		.RING		= XPROTO_CALLER(FXO, RING),
 		.RELAY_OUT	= XPROTO_CALLER(FXO, RELAY_OUT),
 		.XPD_STATE	= XPROTO_CALLER(FXO, XPD_STATE),
-
-		.SYNC_SOURCE	= XPROTO_CALLER(GLOBAL, SYNC_SOURCE),
 	},
 	.packet_is_valid = fxo_packet_is_valid,
 	.packet_dump = fxo_packet_dump,

Modified: team/tzafrir/kernelmove/kernel/xpp/card_fxs.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/xpp/card_fxs.c?view=diff&rev=2314&r1=2313&r2=2314
==============================================================================
--- team/tzafrir/kernelmove/kernel/xpp/card_fxs.c (original)
+++ team/tzafrir/kernelmove/kernel/xpp/card_fxs.c Fri Mar 16 18:36:20 2007
@@ -34,7 +34,8 @@
 static const char rcsid[] = "$Id$";
 
 DEF_PARM(int, print_dbg, 0, 0600, "Print DBG statements");	/* must be before zap_debug.h */
-DEF_PARM_BOOL(poll_digital_inputs, 1, 0600, "Poll Digital Inputs");	/* must be before zap_debug.h */
+DEF_PARM_BOOL(poll_digital_inputs, 1, 0600, "Poll Digital Inputs");
+DEF_PARM_BOOL(reversepolarity, 0, 0600, "Reverse Line Polarity");
 
 /* Signaling is opposite (fxo signalling for fxs card) */
 #if 1
@@ -69,6 +70,22 @@
 
 #define	VALID_CHIPSEL(x)	(((chipsel) >= 0 && (chipsel) <= 7) || (chipsel) == ALL_CHANS)
 
+/* Values of SLIC linefeed control register (0x40) */
+enum fxs_state {
+	FXS_LINE_OPEN		= 0x00,	/* Open */
+	FXS_LINE_ACTIVE		= 0x01,	/* Forward active */
+	FXS_LINE_OHTRANS	= 0x02,	/* Forward on-hook transmission */
+	FXS_LINE_TIPOPEN	= 0x03,	/* TIP open */
+	FXS_LINE_RING		= 0x04,	/* Ringing */
+	FXS_LINE_REV_ACTIVE	= 0x05,	/* Reverse active */
+	FXS_LINE_REV_OHTRANS	= 0x06,	/* Reverse on-hook transmission */
+	FXS_LINE_RING_OPEN	= 0x07	/* RING open */
+};
+
+#define	FXS_LINE_POL_ACTIVE	((reversepolarity) ? FXS_LINE_REV_ACTIVE : FXS_LINE_ACTIVE)
+#define	FXS_LINE_POL_OHTRANS	((reversepolarity) ? FXS_LINE_REV_OHTRANS : FXS_LINE_OHTRANS)
+
+
 /*---------------- FXS Protocol Commands ----------------------------------*/
 
 static /* 0x0F */ DECLARE_CMD(FXS, XPD_STATE, bool on);
@@ -86,13 +103,18 @@
 #define	PROC_FXS_INFO_FNAME	"fxs_info"
 
 struct FXS_priv_data {
-	struct proc_dir_entry		*regfile;
-	struct proc_dir_entry		*fxs_info;
-	xpp_line_t			ledstate[NUM_LEDS];	/* 0 - OFF, 1 - ON */
-	xpp_line_t			ledcontrol[NUM_LEDS];	/* 0 - OFF, 1 - ON */
-	xpp_line_t			found_fsk_pattern;
-	xpp_line_t			msg_waiting;
-	int				led_counter[NUM_LEDS][CHANNELS_PERXPD];
+	struct proc_dir_entry	*regfile;
+	struct proc_dir_entry	*fxs_info;
+	xpp_line_t		ledstate[NUM_LEDS];	/* 0 - OFF, 1 - ON */
+	xpp_line_t		ledcontrol[NUM_LEDS];	/* 0 - OFF, 1 - ON */
+	xpp_line_t		found_fsk_pattern;
+	xpp_line_t		msg_waiting;
+	xpp_line_t		update_offhook_state;
+	int			led_counter[NUM_LEDS][CHANNELS_PERXPD];
+	int			ohttimer[CHANNELS_PERXPD];
+#define OHT_TIMER		6000	/* How long after RING to retain OHT */
+	enum fxs_state		idletxhookstate[CHANNELS_PERXPD];	/* IDLE changing hook state */
+	enum fxs_state		lasttxhook[CHANNELS_PERXPD];
 };
 
 /*
@@ -108,6 +130,16 @@
 #define	LED_BLINK_RING			(1000/8)	/* in ticks */
 
 /*---------------- FXS: Static functions ----------------------------------*/
+static int linefeed_control(xbus_t *xbus, xpd_t *xpd, lineno_t chan, enum fxs_state value)
+{
+	struct FXS_priv_data	*priv;
+
+	priv = xpd->priv;
+	DBG("%s/%s/%d: value=0x%02X\n", xbus->busname, xpd->xpdname, chan, value);
+	priv->lasttxhook[chan] = value;
+	return SLIC_DIRECT_REQUEST(xbus, xpd, chan, SLIC_WRITE, 0x40, value);
+}
+
 static int do_chan_power(xbus_t *xbus, xpd_t *xpd, lineno_t chan, bool on)
 {
 	int		value = (on) ? 0x06 : 0x00;
@@ -223,20 +255,19 @@
 	}
 }
 
-static int do_callerid(xbus_t *xbus, xpd_t *xpd, lineno_t chan)
-{
-	int		ret = 0;
-	int		i;
-
-	BUG_ON(!xbus);
-	BUG_ON(!xpd);
-	DBG("%s/%s/%d:\n", xbus->busname, xpd->xpdname, chan);
-	ret = SLIC_DIRECT_REQUEST(xbus, xpd, chan, SLIC_WRITE, 0x40, FXS_LINE_CID);
-	for_each_line(xpd, i)
-		xpd->lasttxhook[i] = FXS_LINE_CID;
-	return ret;
-}
-
+static void restore_leds(xpd_t *xpd)
+{
+	struct FXS_priv_data	*priv;
+	int			i;
+
+	priv = xpd->priv;
+	for_each_line(xpd, i) {
+		if(IS_SET(xpd->offhook, i))
+			MARK_ON(priv, i, LED_GREEN);
+		else
+			MARK_OFF(priv, i, LED_GREEN);
+	}
+}
 
 /*---------------- FXS: Methods -------------------------------------------*/
 
@@ -310,6 +341,9 @@
 	priv->regfile->read_proc = proc_xpd_register_read;
 	priv->regfile->data = xpd;
 #endif
+	for_each_line(xpd, i) {
+		priv->idletxhookstate[i] = FXS_LINE_POL_ACTIVE;
+	}
 	ret = run_initialize_registers(xpd);
 	if(ret < 0)
 		goto err;
@@ -333,6 +367,7 @@
 		do_led(xpd, i, LED_GREEN, 0);
 		msleep(50);
 	}
+	restore_leds(xpd);
 	return 0;
 err:
 	clean_proc(xbus, xpd);
@@ -404,19 +439,26 @@
 		MARK_OFF(priv, i, LED_RED);
 		msleep(2);
 	}
+	restore_leds(xpd);
 	return 0;
 }
 
 int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, zt_txsig_t txsig)
 {
-	int		ret = 0;
+	struct FXS_priv_data	*priv;
+	int			ret = 0;
+	struct zt_chan		*chan = NULL;
+	enum fxs_state		txhook;
 
 	DBG("%s/%s/%d: %s\n", xbus->busname, xpd->xpdname, pos, txsig2str(txsig));
+	priv = xpd->priv;
 	BUG_ON(xpd->direction != TO_PHONE);
 	if (IS_SET(xpd->digital_inputs, pos)) {
 		DBG("Ignoring signal sent to digital input line\n");
 		return 0;
 	}
+	if(SPAN_REGISTERED(xpd))
+		chan = &xpd->span.chans[pos];
 	switch(txsig) {
 		case ZT_TXSIG_ONHOOK:
 			xpd->ringing[pos] = 0;
@@ -426,41 +468,54 @@
 				ret = CALL_XMETHOD(RELAY_OUT, xpd->xbus, xpd, pos-8, 0);
 				return ret;
 			}
+			if (priv->lasttxhook[pos] == FXS_LINE_OPEN) {
+				/*
+				 * Restore state after KEWL hangup.
+				 */
+				DBG("%s/%s/%d: KEWL STOP\n",
+						xbus->busname, xpd->xpdname, pos);
+				linefeed_control(xbus, xpd, pos, FXS_LINE_POL_ACTIVE);
+				if(IS_SET(xpd->offhook, pos))
+					MARK_ON(priv, pos, LED_GREEN);
+			}
 			ret = CALL_XMETHOD(RING, xbus, xpd, pos, 0);			// RING off
 			if (!IS_SET(xpd->offhook, pos))
 				start_stop_vm_led(xbus, xpd, pos);
-#if 0
-			switch(chan->sig) {
-				case ZT_SIG_EM:
-				case ZT_SIG_FXOKS:
-				case ZT_SIG_FXOLS:
-					xpd->lasttxhook[pos] = xpd->idletxhookstate[pos];
-					break;
-				case ZT_SIG_FXOGS:
-					xpd->lasttxhook[pos] = FXS_LINE_TIPOPEN;
-					break;
+			txhook = priv->lasttxhook[pos];
+			if(chan) {
+				switch(chan->sig) {
+					case ZT_SIG_EM:
+					case ZT_SIG_FXOKS:
+					case ZT_SIG_FXOLS:
+						txhook = priv->idletxhookstate[pos];
+						break;
+					case ZT_SIG_FXOGS:
+						txhook = FXS_LINE_TIPOPEN;
+						break;
+				}
 			}
-#endif
+			ret = linefeed_control(xbus, xpd, pos, txhook);
 			break;
 		case ZT_TXSIG_OFFHOOK:
+			txhook = priv->lasttxhook[pos];
 			if(xpd->ringing[pos]) {
 				BIT_SET(xpd->cid_on, pos);
-				ret = do_callerid(xpd->xbus, xpd, pos);		// CALLER ID
+				txhook = FXS_LINE_OHTRANS;
 			}
 			xpd->ringing[pos] = 0;
-#if 0
-			switch(chan->sig) {
-				case ZT_SIG_EM:
-					xpd->lasttxhook[pos] = FXS_LINE_REV_ACTIVE;
-					break;
-				default:
-					xpd->lasttxhook[pos] = xpd->idletxhookstate[pos];
-					break;
+			if(chan) {
+				switch(chan->sig) {
+					case ZT_SIG_EM:
+						txhook = FXS_LINE_POL_ACTIVE;
+						break;
+					default:
+						txhook = priv->idletxhookstate[pos];
+						break;
+				}
 			}
-#endif
+			ret = linefeed_control(xbus, xpd, pos, txhook);
 			break;
 		case ZT_TXSIG_START:
-			xpd->lasttxhook[pos] = FXS_LINE_RING;
 			xpd->ringing[pos] = 1;
 			BIT_CLR(xpd->cid_on, pos);
 			if(IS_SET(xpd->digital_outputs, pos)) {
@@ -471,7 +526,9 @@
 			ret = CALL_XMETHOD(RING, xbus, xpd, pos, 1);			// RING on
 			break;
 		case ZT_TXSIG_KEWL:
-			xpd->lasttxhook[pos] = FXS_LINE_DISABLED;
+			DBG("%s/%s/%d: KEWL START\n", xbus->busname, xpd->xpdname, pos);
+			linefeed_control(xbus, xpd, pos, FXS_LINE_OPEN);
+			MARK_OFF(priv, pos, LED_GREEN);
 			break;
 		default:
 			NOTICE("%s: Can't set tx state to %s (%d)\n", __FUNCTION__, txsig2str(txsig), txsig);
@@ -553,32 +610,63 @@
 
 static void start_stop_vm_led(xbus_t *xbus, xpd_t *xpd, lineno_t pos)
 {
+	struct FXS_priv_data	*priv;
 	bool		on;
 
+	BUG_ON(!xpd);
 	if (IS_SET(xpd->digital_outputs | xpd->digital_inputs, pos))
 		return;
+	priv = xpd->priv;
 	on = IS_SET(((struct FXS_priv_data *)xpd->priv)->msg_waiting, pos);
 	DBG("%s/%s/%d %s\n", xbus->busname, xpd->xpdname, pos, (on)?"ON":"OFF");
 	set_vm_led_mode(xbus, xpd, pos, on);
 	do_chan_power(xbus, xpd, pos, on);
-	SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x40, (on) ? 0x04 : 0x01);
+	linefeed_control(xbus, xpd, pos, (on) ? FXS_LINE_RING : priv->idletxhookstate[pos]);
 }
 
 static int FXS_chan_onhooktransfer(xbus_t *xbus, xpd_t *xpd, lineno_t chan, int millies)
 {
-	int	ret = 0;
-
-	BUG_ON(!xpd);
+	struct FXS_priv_data	*priv;
+	int			ret = 0;
+
+	BUG_ON(!xpd);
+	priv = xpd->priv;
 	BUG_ON(chan == ALL_CHANS);
 	DBG("%s/%s/%d: (%d millies)\n", xbus->busname, xpd->xpdname, chan, millies);
-	xpd->ohttimer[chan] = millies << 3;
-	xpd->idletxhookstate[chan] = FXS_LINE_CID;	/* OHT mode when idle */
-	if (xpd->lasttxhook[chan] == FXS_LINE_ENABLED) {
-		/* Apply the change if appropriate */
-		ret = do_callerid(xpd->xbus, xpd, chan);		// CALLER ID
-	}
-	start_stop_vm_led(xbus, xpd, chan);
+	if(!IS_SET(xpd->offhook, chan))
+		start_stop_vm_led(xbus, xpd, chan);
 	return ret;
+}
+
+static int FXS_card_open(xpd_t *xpd, lineno_t chan)
+{
+	struct FXS_priv_data	*priv;
+	bool			is_offhook;
+
+	BUG_ON(!xpd);
+	priv = xpd->priv;
+	is_offhook = IS_SET(xpd->offhook, chan);
+	DBG("%s/%s:%d (is %shook)\n", xpd->xbus->busname, xpd->xpdname,
+			chan, (is_offhook)?"off":"on");
+	/*
+	 * Delegate updating zaptel to FXS_card_tick():
+	 *   The problem is that zt_hooksig() is spinlocking the channel and
+	 *   we are called by zaptel with the spinlock already held on the
+	 *   same channel.
+	 */
+	BIT_SET(priv->update_offhook_state, chan);
+	return 0;
+}
+
+static int FXS_card_close(xpd_t *xpd, lineno_t chan)
+{
+	struct FXS_priv_data	*priv;
+
+	BUG_ON(!xpd);
+	DBG("%s/%s:%d\n", xpd->xbus->busname, xpd->xpdname, chan);
+	priv = xpd->priv;
+	priv->idletxhookstate[chan] = FXS_LINE_POL_ACTIVE;
+	return 0;
 }
 
 /*
@@ -600,6 +688,36 @@
 		byte	pos = input_channels[i];
 
 		SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_READ, 0x06, 0);
+	}
+}
+
+void handle_linefeed(xpd_t *xpd)
+{
+	struct FXS_priv_data	*priv;
+	int			i;
+
+	BUG_ON(!xpd);
+	priv = xpd->priv;
+	BUG_ON(!priv);
+	for_each_line(xpd, i) {
+		if (priv->lasttxhook[i] == FXS_LINE_RING) {
+			/* RINGing, prepare for OHT */
+			priv->ohttimer[i] = OHT_TIMER;
+			priv->idletxhookstate[i] = FXS_LINE_POL_OHTRANS;
+		} else {
+			if (priv->ohttimer[i]) {
+				priv->ohttimer[i]--;
+				if (!priv->ohttimer[i]) {
+					priv->idletxhookstate[i] = FXS_LINE_POL_ACTIVE;
+					if (priv->lasttxhook[i] == FXS_LINE_POL_OHTRANS) {
+						enum fxs_state	txhook = FXS_LINE_POL_ACTIVE;
+						/* Apply the change if appropriate */
+						BIT_CLR(xpd->cid_on, i);
+						linefeed_control(xpd->xbus, xpd, i, txhook);
+					}
+				}
+			}
+		}
 	}
 }
 

[... 6093 lines stripped ...]


More information about the zaptel-commits mailing list