[svn-commits] tzafrir: branch 1.4 r2866 - in /branches/1.4: ./ xpp/ xpp/utils/ xpp/utils/zc...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Aug 16 16:10:06 CDT 2007


Author: tzafrir
Date: Thu Aug 16 16:10:05 2007
New Revision: 2866

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2866
Log:
xpp rev. 4515:
* BRI improvement: an 'nt_keepalive' parameter to xpd_bri forces
  a BRI_NT to retry a connection indefinitely (this is our default).
  When false it revert to the behaviour in changeset:4415 ("Bezeq like")
* Improvement in DBG macros. The print_dbg parameter is now set of
  flags to debug. They are defined in zap_debug.h
* Don't use Astribanks connected to USB1 interfaces
  Unless the user set the option usb1=1 for xpp_usb (r4504).
* And some more documentation...
* Include some of our variables in the default zaptel sample file.

Merged revisions 2860 via svnmerge from 
https://origsvn.digium.com/svn/zaptel/branches/1.2

Modified:
    branches/1.4/   (props changed)
    branches/1.4/xpp/.version
    branches/1.4/xpp/ChangeLog
    branches/1.4/xpp/README.Astribank
    branches/1.4/xpp/card_bri.c
    branches/1.4/xpp/card_fxo.c
    branches/1.4/xpp/card_fxs.c
    branches/1.4/xpp/card_global.c
    branches/1.4/xpp/utils/genzaptelconf
    branches/1.4/xpp/utils/zconf/Zaptel/Config/Defaults.pm
    branches/1.4/xpp/xbus-core.c
    branches/1.4/xpp/xbus-sysfs.c
    branches/1.4/xpp/xpd.h
    branches/1.4/xpp/xpp_usb.c
    branches/1.4/xpp/xpp_zap.c
    branches/1.4/xpp/xpp_zap.h
    branches/1.4/xpp/xproto.c
    branches/1.4/xpp/zap_debug.h
    branches/1.4/zaptel.sysconfig

Propchange: branches/1.4/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: branches/1.4/xpp/.version
URL: http://svn.digium.com/view/zaptel/branches/1.4/xpp/.version?view=diff&rev=2866&r1=2865&r2=2866
==============================================================================
--- branches/1.4/xpp/.version (original)
+++ branches/1.4/xpp/.version Thu Aug 16 16:10:05 2007
@@ -1,1 +1,1 @@
-trunk-r4416
+trunk-r4515

Modified: branches/1.4/xpp/ChangeLog
URL: http://svn.digium.com/view/zaptel/branches/1.4/xpp/ChangeLog?view=diff&rev=2866&r1=2865&r2=2866
==============================================================================
--- branches/1.4/xpp/ChangeLog (original)
+++ branches/1.4/xpp/ChangeLog Thu Aug 16 16:10:05 2007
@@ -1,11 +1,17 @@
-Tue Aug 14 2007 Tzafrir Cohen <tzafrir.cohen at xorcom.com> - xpp.r4416
-  * Marked with no. 4416, to note that major changes after 4415 were
-    note merged yet.
+Thu Aug 16 2007 Tzafrir Cohen <tzafrir.cohen at xorcom.com> - xpp.r4515
+  * Don't use Astribanks connected to USB1 interfaces
+    Unless the user set the option usb1=1 for xpp_usb (r4504).
   * Demote the messages about PCM in non-PCM from notice to debug (r4501).
   * Fix sample BRI zapata.conf: NT instead of TE (r4498).
   * Disable FXS hardware DTMF detection by default (r4492).
   * Extra Zaptel PCI IDs (from Philipp Kempgen) (r4466).
 
+Thu Aug  2 2007 Oron Peled <oron at actcom.co.il> - xpp.r4464
+  * BRI improvement: an 'nt_keepalive' parameter to xpd_bri forces
+    a BRI_NT to retry a connection indefinitely (this is our default).
+    When false it revert to the behaviour in changeset:4415 ("Bezeq like")
+  * Improvement in DBG macros. The print_dbg parameter is now set of
+    flags to debug. They are defined in zap_debug.h
 Thu Jul 30 2007 Oron Peled <oron at actcom.co.il> - xpp.r4415
   * Show Astribank 6+2 as 6/2 channels and not 8/8 channels.
     - Added as a "subtype" to the device type (r4391).

Modified: branches/1.4/xpp/README.Astribank
URL: http://svn.digium.com/view/zaptel/branches/1.4/xpp/README.Astribank?view=diff&rev=2866&r1=2865&r2=2866
==============================================================================
--- branches/1.4/xpp/README.Astribank (original)
+++ branches/1.4/xpp/README.Astribank Thu Aug 16 16:10:05 2007
@@ -322,6 +322,11 @@
 Astribank 8
 ^^^^^^^^^^^
     fxoks=1-14
+
+Astribank 6FXS/2FXO
+^^^^^^^^^^^^^^^^^^^^^^^
+    fxoks=1-12
+    fxsks=13-14
 
 Astribank 16: 8FXS/8FXO
 ^^^^^^^^^^^^^^^^^^^^^^^
@@ -355,9 +360,9 @@
     signalling=fxo_ks
     ; The real analog ports:
     context=from-internal
-    ; echocancel=yes
+    echocancel=yes
     ; echocancelwhenbriged=yes
-    ; echotraining=9
+    ; echotraining=no
     channel => 1-8
 
     ; output ports:
@@ -368,16 +373,42 @@
     context=astbank-input
     channel => 11-14
     immediate=no
-  
+
+Astribank 6FXS/2FXO
+^^^^^^^^^^^^^^^^^^^^^^^   
+    [channels]
+    signalling=fxo_ks
+    ; The real analog ports:
+    context=from-internal
+    echocancel=yes
+    ; echocancelwhenbriged=yes
+    ; echotraining=no
+    channel => 1-6
+
+    ; output ports:
+    context=astbank-output
+    channel => 7-8
+    ; input ports:
+    immediate=yes
+    context=astbank-input
+    channel => 9-12
+    immediate=no
+
+    ; FXO ports
+    signalling=fxs_ks
+    context=from-pstn
+    callerid=asreceived
+    channel => 13-14
+
 Astribank 16: 8FXS/8FXO
 ^^^^^^^^^^^^^^^^^^^^^^^   
     [channels]
     signalling=fxo_ks
     ; The real analog ports:
     context=from-internal
-    ; echocancel=yes
+    echocancel=yes
     ; echocancelwhenbriged=yes
-    ; echotraining=9
+    ; echotraining=no
     channel => 1-8
 
     ; output ports:
@@ -607,36 +638,165 @@
 Compile-time defaults of all modules can be shown as part of the
 description line for the parameter in the output of modinfo.
 
-zap_autoreg: (xpp)
-Register spans automatically (1) or not (0). Default: 1. 
-Unsetting this could be useful if you have several Astribanks and you 
-want to set their registration order manually using zt_registration in 
-the /proc interface.
-
-initdir: (xpp)
-This is the directory containing the initialization scripts.
-The default is /usr/share/zaptel .
-Setting this value could be useful if that location is inconvenient for you.
-
-print_dbg: (all modules)
+zap_autoreg (xpp)::
+  Register spans automatically (1) or not (0). Default: 1. 
+  Unsetting this could be useful if you have several Astribanks and you 
+  want to set their registration order manually using zt_registration in 
+  the /proc interface.
+
+initdir (xpp)::
+  This is the directory containing the initialization scripts.
+  The default is /usr/share/zaptel .
+  Setting this value could be useful if that location is inconvenient for you.
+
+print_dbg (all modules)::
 It will make the driver print tons of debugging messages. Can be sometime 
 even handy, but overly-verbose in the case of xpp_usb. Can be safely 
 set/unset at run-time using /sys/modules .
 
-vmwineon: (xpd_fxs)
-Enable (1) or disable (0) sending voicemail message waiting indication
-to phones with a neon lamp. Disabled by default as it requires extra
-work of the driver even without such a phone and may potentially have
-some strange sideeffects with some phones.
-
-poll intervals: (various)
-There are various values which the driver occasionally polls the device
-for. For instance ,the parameter poll_battery_interval for xpd_fxo
-to poll the battery (if the telco is actually connected).
-
-The value of those parameters is typically a number in milliseconds or 0
-to disable. Under normal operation there should be no reason to play
-with such parameters.
+The value is a bitmask of several values. The value of 0 thus means "no
+debug". The different bits are (as defined in xpp/zap_debug.h) - 
+
+  * 1: GENERAL - General debug comments.
+  * 2: PCM - PCM-related messages. Tend to flood logs.
+  * 4: LEDS - Anything related to blinking leds. When they appear, there
+    are many of them.
+  * 8: SYNC - Synchronization messages. Annoy as they happen regularily.
+  * 16: SIGNAL - Zaptel signalling and such.
+  * 32: PROC - procfs interface.
+  * 64: REGS - Reading and writing to regiaters. Tends to flood logs.
+
+Thus: 
+
+  echo 33 >/sys/modules/xpp/parameters/print_dbg 
+
+sets the module xpp to print general debugging messages (1) and procfs
+debuggingmessages (32).
+
+vmwineon (xpd_fxs)::
+  Enable (1) or disable (0) sending voicemail message waiting indication
+  to phones with a neon lamp. Disabled by default as it requires extra
+  work of the driver even without such a phone and may potentially have
+  some strange sideeffects with some phones.
+
+usb1 (xpp_usb)::
+  Enable (1) or disable (0) support of USB1 devices. Disabled by default.
+  +
+  +
+  USB1 devices are not well-tested. It seems that they don't work at all
+  for Astribank BRI. Generally they should work with the current code, but
+  we expect quality issues. Hence we would like to make it very clear that
+  you if you have a USB1 port (rather than a USB2 one, as recommended) you
+  will have to take an action to enable the device.
+
+poll intervals (various)::
+  There are various values which the driver occasionally polls the device
+  for. For instance ,the parameter poll_battery_interval for xpd_fxo
+  to poll the battery (if the telco is actually connected).
+  +
+  +
+  The value of those parameters is typically a number in milliseconds or 0
+  to disable. Under normal operation there should be no reason to play
+  with such parameters.
+
+dtmf_detection (xpd_fxs)::
+  enable (1) or disable (0) support of DTMF detection by the Astribank.
+  Disabled by defualt and curently buggy. On some earlier versions (4372 -
+  4415) it was enabled by default, and disabling it there may help.
+
+
+TROUBLSHOOTING
+--------------
+The following commands provide useful input for debugging:
+
+* USB level listing: one of the following:
+
+  zaptel_hardware 
+
+  lsusb | grep e4e4
+
+  - Look for the USB product ID (the second number after e4e4).
+  - If you see *11x2* (e.g: 1152)- the FPGA firmware has been loaded. 
+    Move on.
+    zaptel_hardware will also show you some more details if the driver
+    is loaded. lsusb will just list the device.
+  - If it shows something as product ID *11x0* - the USB firmware is not
+    loaded. Maybe you need fxload. Or maybe just unplug and replug the
+    device.
+  - If it shows a product ID of *11x1* - only the USB firmware is loaded 
+    and not the FPGA firmware is loaded. If this is still the case after 
+    a while - either the firmware loading has failed or you don't have
+    fpga_load - make sure you have libusb-dev(el) installed when
+    building Zaptel.
+  - It should list all of your Astribank devices. If it doesn't (for
+    more than a temporary while it takes for the initial firmware
+    loading) - Check that the Astribank is indeed connected. 
+
+* Are Astribank spans registered?
+
+  zt_registration
+  
+  - This should give useful results after the drivers have identified
+    and initialized your devices.
+  - It should list all Astribank XPDs. for each of them it should write
+    "on" or "off". If it is "off", the span has not been registered with
+    Zaptel and thus cannot yet be used.
+  - Registration is normally done as part of `/etc/init.d/zaptel start` .
+    To run it manually use the command:  `zt_registration on` .
+  - Recall that we do not register Astribank spans automaitcally to give
+    you full control on the order of Zaptel spans. See the module
+    parameter **zap_autoreg** above to change that.
+
+* Zaptel-level listing:
+
+  lszaptel
+
+  cat /proc/zaptel/*
+
+  - Those two are almost the same. lszaptel sorts more correctly if you
+    have more than 10 spans, and formats the output slightly nicer.
+  - Here you can see if your Zaptel spans and channels were loaded, if
+    they were configired by ztcfg and if they are in use (typically by
+    Asterisk).
+    - The fact that a file for a span is show whos that it has been
+      registered with Zaptel. A n example non-configured channel
+      (Astribank FXS):
+
+       42 FXS
+
+    - When a channel has been configured with *ztcfg* (that applies
+      /etc/zaptel.conf), you will see an extra column for the signalling
+      of the channel. The same channel after it has been configured:
+
+       42 FXS        FXOKS
+
+    - If a program (which is typically asterisk uses it, you'll see:
+
+       42 FXS        FXOKS      (In use)
+
+* Information from Asterisk
+
+  asterisk -rx 'zap show channels'
+
+  - If you get the error connecting to asterisk.ctl: Asterisk is not
+    running. Maybe it has failed to load. This may be due to
+    misconfigured zapata.conf or whatever reason. Check
+    /var/log/asterisk/messages or /var/log/asterisk/full .
+  - If you get the error that "there is no such command": chan_zap.so is
+    not loaded. This can be one of two cases:
+    - chan_zap.so is not even built. To see that it is available run:
+
+      ls -l /usr/lib/asterisk/modules/chan_zap.so
+
+    - Your Asterisk has chan_zap.so but it is not loaded. Try loading
+      it:
+      
+      asterisk -rx 'load module chan_zap.so'
+
+  - You see only "pseudo": in this case you have not configured any
+    channels. If you have configured channels in zapata.conf, you may
+    need to restart asterisk (or: `unload chan_zap.so` and 
+    `load chan_zap.so`) to apply those changes.
 
 
 NOTE: XPP here does not stand for X Printing Panel, XML Pull Parser, 

Modified: branches/1.4/xpp/card_bri.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/xpp/card_bri.c?view=diff&rev=2866&r1=2865&r2=2866
==============================================================================
--- branches/1.4/xpp/card_bri.c (original)
+++ branches/1.4/xpp/card_bri.c Thu Aug 16 16:10:05 2007
@@ -42,6 +42,7 @@
 
 DEF_PARM(int, print_dbg, 0, 0644, "Print DBG statements");	/* must be before zap_debug.h */
 DEF_PARM(uint, poll_interval, 500, 0644, "Poll channel state interval in milliseconds (0 - disable)");
+DEF_PARM_BOOL(nt_keepalive, 1, 0644, "Force BRI_NT to keep trying connection");
 #ifdef	DEBUG_PCMTX
 DEF_PARM(int, pcmtx, -1, 0644, "Forced PCM value to transmit (negative to disable)");
 DEF_PARM(int, pcmtx_chan, 0, 0644, "channel to force PCM value");
@@ -262,7 +263,7 @@
 	debug_buf[0] = '\0';
 	for(i = 0; i < len && n < DEBUG_BUF_SIZE; i++)
 		n += snprintf(&debug_buf[n], DEBUG_BUF_SIZE - n, "%02X ", buf[i]);
-	XPD_DBG(xpd, "%s[0..%d]: %s%s\n", msg, len-1, debug_buf,
+	XPD_DBG(GENERAL, xpd, "%s[0..%d]: %s%s\n", msg, len-1, debug_buf,
 			(n >= DEBUG_BUF_SIZE)?"...":"");
 }
 
@@ -310,7 +311,7 @@
 	if(priv->layer1_up == up)
 		return;
 	priv->layer1_up = up;
-	XPD_DBG(xpd, "STATE CHANGE: Layer1 %s\n", (up)?"UP":"DOWN");
+	XPD_DBG(SIGNAL, xpd, "STATE CHANGE: Layer1 %s\n", (up)?"UP":"DOWN");
 }
 
 static void dchan_state(xpd_t *xpd, bool up)
@@ -323,10 +324,10 @@
 	if(priv->dchan_alive == up)
 		return;
 	if(up) {
-		XPD_DBG(xpd, "STATE CHANGE: D-Channel RUNNING\n");
+		XPD_DBG(SIGNAL, xpd, "STATE CHANGE: D-Channel RUNNING\n");
 		priv->dchan_alive = 1;
 	} else {
-		XPD_DBG(xpd, "STATE CHANGE: D-Channel STOPPED\n");
+		XPD_DBG(SIGNAL, xpd, "STATE CHANGE: D-Channel STOPPED\n");
 		priv->dchan_rx_counter = priv->dchan_tx_counter = priv->dchan_rx_drops = 0;
 		priv->dchan_alive = 0;
 		priv->dchan_alive_ticks = 0;
@@ -342,27 +343,27 @@
 	priv = xpd->priv;
 	BUG_ON(!priv);
 	xbus = xpd->xbus;
-	XPD_DBG(xpd, "%s\n", (on)?"ON":"OFF");
+	XPD_DBG(SIGNAL, xpd, "%s\n", (on)?"ON":"OFF");
 	switch(xpd->type) {
 		case XPD_TYPE_BRI_TE:
 			if(on) {
-				XPD_DBG(xpd, "HFC_L1_ACTIVATE_TE\n");
+				XPD_DBG(SIGNAL, xpd, "HFC_L1_ACTIVATE_TE\n");
 				set_bit(HFC_L1_ACTIVATING, &priv->l1_flags);
 				write_state_register(xpd, STA_ACTIVATE);
 				priv->t3 = HFC_TIMER_T3;
 			} else {
-				XPD_DBG(xpd, "HFC_L1_FORCE_DEACTIVATE_TE\n");
+				XPD_DBG(SIGNAL, xpd, "HFC_L1_FORCE_DEACTIVATE_TE\n");
 				write_state_register(xpd, STA_DEACTIVATE);
 			}
 			break;
 		case XPD_TYPE_BRI_NT:
 			if(on) {
-				XPD_DBG(xpd, "HFC_L1_ACTIVATE_NT\n");
+				XPD_DBG(SIGNAL, xpd, "HFC_L1_ACTIVATE_NT\n");
 				priv->t1 = TIMER_T1_MAX;
 				set_bit(HFC_L1_ACTIVATING, &priv->l1_flags);
 				write_state_register(xpd, STA_ACTIVATE | V_SU_SET_G2_G3);
 			} else {
-				XPD_DBG(xpd, "HFC_L1_DEACTIVATE_NT\n");
+				XPD_DBG(SIGNAL, xpd, "HFC_L1_DEACTIVATE_NT\n");
 				write_state_register(xpd, STA_DEACTIVATE);
 			}
 			break;
@@ -408,7 +409,7 @@
 		static int rate_limit;
 
 		if((rate_limit++ % 1000) == 0)
-			XPD_DBG(xpd, "D-Chan unused\n");
+			XPD_DBG(SIGNAL, xpd, "D-Chan unused\n");
 		dchan->bytes2receive = 0;
 		dchan->bytes2transmit = 0;
 		goto out;
@@ -489,7 +490,7 @@
 	if(len > 0) {
 		memcpy(REG_XDATA(reg_cmd), (byte *)buf, len);
 	} else {
-		XPD_DBG(xpd, "Magic Packet (eoftx=%d)\n", eoftx);
+		XPD_DBG(REGS, xpd, "Magic Packet (eoftx=%d)\n", eoftx);
 	}
 #ifdef XPP_DEBUGFS
 	xbus_log(xbus, xpd, 1, reg_cmd, sizeof(reg_cmd_t));	/* 1 = TX */
@@ -523,7 +524,7 @@
 			/* timer expired ? */
 			if (--priv->t3 == 0) {
 				if ((rate_limit % 1003) >= 5)
-					XPD_DBG(xpd, "T3 expired\n");
+					XPD_DBG(SIGNAL, xpd, "T3 expired\n");
 				priv->t3 = HFC_TIMER_OFF;
 				clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags);
 				xpd_activation(xpd, 0);		/* Deactivate TE */
@@ -533,7 +534,7 @@
 			/* timer expired ? */
 			if (--priv->t4 == 0) {
 				if ((rate_limit % 1003) >= 5)
-					XPD_DBG(xpd, "T4 expired\n");
+					XPD_DBG(SIGNAL, xpd, "T4 expired\n");
 				priv->t4 = HFC_TIMER_OFF;
 			}
 		}
@@ -555,7 +556,7 @@
 		return -EINVAL;
 	}
 	if(!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags) && !test_bit(HFC_L1_ACTIVATING, &priv->l1_flags)) {
-		XPD_DBG(xpd, "Kick D-Channel transmiter\n");
+		XPD_DBG(SIGNAL, xpd, "Want to transmit: Kick D-Channel transmiter\n");
 		xpd_activation(xpd, 1);
 		return 0;
 	}
@@ -581,7 +582,7 @@
 	xpd_t		*xpd = NULL;
 	int		channels = min(3, CHANNELS_PERXPD);
 
-	XBUS_DBG(xbus, "\n");
+	XBUS_DBG(GENERAL, xbus, "\n");
 	xpd = xpd_alloc(sizeof(struct BRI_priv_data), proto_table, channels);
 	if(!xpd)
 		return NULL;
@@ -597,15 +598,15 @@
 
 	BUG_ON(!xpd);
 	priv = xpd->priv;
-	XPD_DBG(xpd, "\n");
+	XPD_DBG(PROC, xpd, "\n");
 #ifdef	CONFIG_PROC_FS
 	if(priv->regfile) {
-		XPD_DBG(xpd, "Removing registers file\n");
+		XPD_DBG(PROC, xpd, "Removing registers file\n");
 		priv->regfile->data = NULL;
 		remove_proc_entry(PROC_REGISTER_FNAME, xpd->proc_xpd_dir);
 	}
 	if(priv->bri_info) {
-		XPD_DBG(xpd, "Removing xpd BRI_INFO file\n");
+		XPD_DBG(PROC, xpd, "Removing xpd BRI_INFO file\n");
 		remove_proc_entry(PROC_BRI_INFO_FNAME, xpd->proc_xpd_dir);
 	}
 #endif
@@ -617,10 +618,10 @@
 	int			ret = 0;
 
 	BUG_ON(!xpd);
-	XPD_DBG(xpd, "\n");
+	XPD_DBG(GENERAL, xpd, "\n");
 	priv = xpd->priv;
 #ifdef	CONFIG_PROC_FS
-	XPD_DBG(xpd, "Creating BRI_INFO file\n");
+	XPD_DBG(PROC, xpd, "Creating BRI_INFO file\n");
 	priv->bri_info = create_proc_read_entry(PROC_BRI_INFO_FNAME, 0444, xpd->proc_xpd_dir, proc_bri_info_read, xpd);
 	if(!priv->bri_info) {
 		XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_BRI_INFO_FNAME);
@@ -628,7 +629,7 @@
 		goto err;
 	}
 	priv->bri_info->owner = THIS_MODULE;
-	XPD_DBG(xpd, "Creating registers file\n");
+	XPD_DBG(PROC, xpd, "Creating registers file\n");
 	priv->regfile = create_proc_entry(PROC_REGISTER_FNAME, 0644, xpd->proc_xpd_dir);
 	if(!priv->regfile) {
 		XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_REGISTER_FNAME);
@@ -648,7 +649,7 @@
 	 *     Force HOST sync *before* sending PCM
 	 */
 	CALL_PROTO(GLOBAL, SYNC_SOURCE, xbus, NULL, SYNC_MODE_HOST, 0);
-	XPD_DBG(xpd, "done\n");
+	XPD_DBG(PROC, xpd, "done\n");
 	priv->initialized = 1;
 	return 0;
 err:
@@ -663,7 +664,7 @@
 
 	BUG_ON(!xpd);
 	priv = xpd->priv;
-	XPD_DBG(xpd, "\n");
+	XPD_DBG(GENERAL, xpd, "\n");
 	clean_proc(xbus, xpd);
 	return 0;
 }
@@ -681,7 +682,7 @@
 	xbus = xpd->xbus;
 	priv = xpd->priv;
 	BUG_ON(!xbus);
-	XPD_DBG(xpd, "%s\n", (on)?"on":"off");
+	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off");
 	if(!on) {
 		/* Nothing to do yet */
 		return 0;
@@ -692,7 +693,7 @@
 	for_each_line(xpd, i) {
 		struct zt_chan	*cur_chan = &xpd->chans[i];
 
-		XPD_DBG(xpd, "setting BRI channel %d\n", i);
+		XPD_DBG(GENERAL, xpd, "setting BRI channel %d\n", i);
 		snprintf(cur_chan->name, MAX_CHANNAME, "XPP_%s/%02d/%1d%1d/%d",
 				xpd->xproto->name, xbus->num,
 				xpd->addr.unit, xpd->addr.subunit, i);
@@ -756,13 +757,13 @@
 	xbus = xpd->xbus;
 	priv = xpd->priv;
 	BUG_ON(!xbus);
-	XPD_DBG(xpd, "%s\n", (on)?"on":"off");
+	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off");
 	return(0);
 }
 
 int BRI_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, zt_txsig_t txsig)
 {
-	LINE_DBG(xpd, pos, "%s\n", txsig2str(txsig));
+	LINE_DBG(SIGNAL, xpd, pos, "%s\n", txsig2str(txsig));
 	return 0;
 }
 
@@ -847,9 +848,16 @@
 	if(!priv->initialized)
 		return 0;
 	if(poll_interval != 0 && (priv->tick_counter % poll_interval) == 0) {
-		// XPD_DBG(xpd, "%d\n", priv->tick_counter);
+		// XPD_DBG(GENERAL, xpd, "%d\n", priv->tick_counter);
 		priv->poll_counter++;
 		CALL_PROTO(BRI, REGISTER_REQUEST, xbus, xpd, 0, 0, 0, A_SU_RD_STA, 0, 0, 0);
+
+		if(IS_NT(xpd) && nt_keepalive &&
+			!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags) &&
+			!test_bit(HFC_L1_ACTIVATING, &priv->l1_flags)) {
+			XPD_DBG(SIGNAL, xpd, "Kick NT D-Channel\n");
+			xpd_activation(xpd, 1);
+		}
 	}
 	/* Detect D-Channel disconnect heuristic */
 	priv->dchan_notx_ticks++;
@@ -876,10 +884,10 @@
 	handle_leds(xbus, xpd);
 	tx_dchan(xpd);
 	/* Detect T1 timer expiry on NT */
-	if(IS_NT(xpd)) {
+	if(IS_NT(xpd) && !nt_keepalive) {
 		if (priv->t1 > HFC_TIMER_OFF) {
 			if (--priv->t1 == 0) {
-				XPD_DBG(xpd, "T1 Expired. Kick NT\n");
+				XPD_DBG(SIGNAL, xpd, "T1 Expired. Deactivate NT\n");
 				priv->t1 = HFC_TIMER_OFF;
 				clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags);
 				write_state_register(xpd, STA_DEACTIVATE);
@@ -930,7 +938,7 @@
 	/* E1's can enable CRC checking */
 	if (lc->lineconfig & ZT_CONFIG_CRC4)
 		crcstr = "CRC4";
-	XPD_DBG(xpd, "[%s]: span=%d (%s) lbo=%d lineconfig=%s/%s/%s (0x%X) sync=%d\n",
+	XPD_DBG(GENERAL, xpd, "[%s]: span=%d (%s) lbo=%d lineconfig=%s/%s/%s (0x%X) sync=%d\n",
 		IS_NT(xpd)?"NT":"TE",
 		lc->span,
 		lc->name,
@@ -952,7 +960,7 @@
  */
 static int bri_chanconfig(struct zt_chan *chan, int sigtype)
 {
-	DBG("channel %d (%s) -> %s\n", chan->channo, chan->name, sig2str(sigtype));
+	DBG(GENERAL, "channel %d (%s) -> %s\n", chan->channo, chan->name, sig2str(sigtype));
 	// FIXME: sanity checks:
 	// - should be supported (within the sigcap)
 	// - should not replace fxs <->fxo ??? (covered by previous?)
@@ -972,10 +980,10 @@
 	priv = xpd->priv;
 	BUG_ON(!priv);
 	if(!xpd->xbus->hardware_exists) {
-		XPD_DBG(xpd, "Startup called by zaptel. No Hardware. Ignored\n");
+		XPD_DBG(GENERAL, xpd, "Startup called by zaptel. No Hardware. Ignored\n");
 		return -ENODEV;
 	}
-	XPD_DBG(xpd, "STARTUP\n");
+	XPD_DBG(GENERAL, xpd, "STARTUP\n");
 	// Turn on all channels
 	CALL_XMETHOD(XPD_STATE, xpd->xbus, xpd, 1);
 	write_state_register(xpd, 0);	/* Enable L1 state machine */
@@ -1007,10 +1015,10 @@
 	priv = xpd->priv;
 	BUG_ON(!priv);
 	if(!xpd->xbus->hardware_exists) {
-		XPD_DBG(xpd, "Shutdown called by zaptel. No Hardware. Ignored\n");
+		XPD_DBG(GENERAL, xpd, "Shutdown called by zaptel. No Hardware. Ignored\n");
 		return -ENODEV;
 	}
-	XPD_DBG(xpd, "SHUTDOWN\n");
+	XPD_DBG(GENERAL, xpd, "SHUTDOWN\n");
 	// Turn off all channels
 	CALL_XMETHOD(XPD_STATE, xpd->xbus, xpd, 0);
 	if(IS_NT(xpd))
@@ -1118,16 +1126,14 @@
 	reg_cmd_t	*reg_cmd;
 
 	if(!xbus) {
-		DBG("NO XBUS\n");
+		DBG(GENERAL, "NO XBUS\n");
 		return -EINVAL;
 	}
 	XFRAME_NEW(xframe, pack, xbus, BRI, REGISTER_REQUEST, xpd->xbus_idx);
-#if 0
-	LINE_DBG(xpd, chipsel, "%c%c R%02X S%02X %02X %02X\n",
+	LINE_DBG(REGS, xpd, chipsel, "%c%c R%02X S%02X %02X %02X\n",
 			(writing)?'W':'R',
 			(do_subreg)?'S':'D',
 			regnum, subreg, data_low, data_high);
-#endif
 	reg_cmd = &RPACKET_FIELD(pack, BRI, REGISTER_REQUEST, reg_cmd);
 	reg_cmd->bytes = sizeof(*reg_cmd) - 1;	// do not count the 'bytes' field
 	REG_FIELD(reg_cmd, chipsel) = chipsel;
@@ -1144,7 +1150,7 @@
 /* 0x0F */ HOSTCMD(BRI, XPD_STATE, bool on)
 {
 	BUG_ON(!xpd);
-	XPD_DBG(xpd, "%s\n", (on)?"ON":"OFF");
+	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF");
 	xpd_activation(xpd, on);
 	return 0;
 }
@@ -1172,11 +1178,9 @@
 	BUG_ON(!xbus);
 	priv = xpd->priv;
 	BUG_ON(!priv);
-#if 0
-	XPD_DBG(xpd, "%s -> %d\n",
+	XPD_DBG(LEDS, xpd, "%s -> %d\n",
 		(which_led)?"RED":"GREEN",
 		to_led_state);
-#endif
 	XFRAME_NEW(xframe, pack, xbus, BRI, SET_LED, xpd->xbus_idx);
 	bri_leds = &RPACKET_FIELD(pack, BRI, SET_LED, bri_leds);
 	bri_leds->state = to_led_state;
@@ -1191,7 +1195,7 @@
 {
 	int	ret;
 
-	XPD_DBG(xpd, "value = 0x%02X\n", value);
+	XPD_DBG(REGS, xpd, "value = 0x%02X\n", value);
 	ret = CALL_PROTO(BRI, REGISTER_REQUEST, xpd->xbus, xpd,
 			0,		/* chipsel	*/
 			1,		/* writing	*/
@@ -1250,32 +1254,32 @@
 	}
 	if (priv->state_register.bits.v_su_sta == new_state.bits.v_su_sta)
 		return;	/* same same */
-	DBG("%02X ---> %02X\n", priv->state_register.reg, reg_x30);
-	XPD_DBG(xpd, "%s%i\n", IS_NT(xpd)?"G":"F", new_state.bits.v_su_sta);
+	DBG(SIGNAL, "%02X ---> %02X\n", priv->state_register.reg, reg_x30);
+	XPD_DBG(SIGNAL, xpd, "%s%i\n", IS_NT(xpd)?"G":"F", new_state.bits.v_su_sta);
 
 	if(!IS_NT(xpd)) {
 		/* disable T3 ? */
 		if ((new_state.bits.v_su_sta <= ST_TE_DEACTIVATED) || (new_state.bits.v_su_sta >= ST_TE_ACTIVATED)) {
-			XPD_DBG(xpd, "Disable T3 ?\n");
+			XPD_DBG(SIGNAL, xpd, "Disable T3 ?\n");
 			priv->t3 = HFC_TIMER_OFF;
 		}
 		switch (new_state.bits.v_su_sta) {
 			case ST_TE_DEACTIVATED:		/* F3 */
-				XPD_DBG(xpd, "State ST_TE_DEACTIVATED (F3)\n");
+				XPD_DBG(SIGNAL, xpd, "State ST_TE_DEACTIVATED (F3)\n");
 				if (test_and_clear_bit(HFC_L1_ACTIVATED, &priv->l1_flags))
 					priv->t4 = HFC_TIMER_T4;
 				break;
 			case ST_TE_SIGWAIT:		/* F4	*/
-				XPD_DBG(xpd, "State ST_TE_SIGWAIT (F4)\n");
+				XPD_DBG(SIGNAL, xpd, "State ST_TE_SIGWAIT (F4)\n");
 				break;
 			case ST_TE_IDENT:		/* F5	*/
-				XPD_DBG(xpd, "State ST_TE_IDENT (F5)\n");
+				XPD_DBG(SIGNAL, xpd, "State ST_TE_IDENT (F5)\n");
 				break;
 			case ST_TE_SYNCED:		/* F6	*/
-				XPD_DBG(xpd, "State ST_TE_SYNCED (F6)\n");
+				XPD_DBG(SIGNAL, xpd, "State ST_TE_SYNCED (F6)\n");
 				break;
 			case ST_TE_ACTIVATED:		/* F7 */
-				XPD_DBG(xpd, "State ST_TE_ACTIVATED (F7)\n");
+				XPD_DBG(SIGNAL, xpd, "State ST_TE_ACTIVATED (F7)\n");
 				if (priv->t4 > HFC_TIMER_OFF)
 					priv->t4 = HFC_TIMER_OFF;
 				clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags);
@@ -1284,7 +1288,7 @@
 				break;
 
 			case ST_TE_LOST_FRAMING:	/* F8 */
-				XPD_DBG(xpd, "State ST_TE_LOST_FRAMING (F8)\n");
+				XPD_DBG(SIGNAL, xpd, "State ST_TE_LOST_FRAMING (F8)\n");
 				priv->t4 = HFC_TIMER_OFF;
 				break;
 			default:
@@ -1295,22 +1299,22 @@
 	} else if(IS_NT(xpd)) {
 		switch (new_state.bits.v_su_sta) {
 			case ST_NT_DEACTIVATED:		/* G1 */
-				XPD_DBG(xpd, "State ST_NT_DEACTIVATED (G1)\n");
+				XPD_DBG(SIGNAL, xpd, "State ST_NT_DEACTIVATED (G1)\n");
 				clear_bit(HFC_L1_ACTIVATED, &priv->l1_flags);
 				priv->t1 = HFC_TIMER_OFF;
 				break;
 			case ST_NT_ACTIVATING:		/* G2 */
-				XPD_DBG(xpd, "State ST_NT_ACTIVATING (G2)\n");
+				XPD_DBG(SIGNAL, xpd, "State ST_NT_ACTIVATING (G2)\n");
 				xpd_activation(xpd, 1);
 				break;
 			case ST_NT_ACTIVATED:		/* G3 */
-				XPD_DBG(xpd, "State ST_NT_ACTIVATED (G3)\n");
+				XPD_DBG(SIGNAL, xpd, "State ST_NT_ACTIVATED (G3)\n");
 				clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags);
 				set_bit(HFC_L1_ACTIVATED, &priv->l1_flags);
 				priv->t1 = HFC_TIMER_OFF;
 				break;
 			case ST_NT_DEACTIVTING:		/* G4 */
-				XPD_DBG(xpd, "State ST_NT_DEACTIVTING (G4)\n");
+				XPD_DBG(SIGNAL, xpd, "State ST_NT_DEACTIVTING (G4)\n");
 				priv->t1 = HFC_TIMER_OFF;
 				break;
 			default:
@@ -1338,21 +1342,17 @@
 	spin_lock_irqsave(&xpd->lock, flags);
 	priv = xpd->priv;
 	BUG_ON(!priv);
-#if 0
 	if(REG_FIELD(info, do_subreg)) {
-		XPD_DBG(xpd, "REGISTER_REPLY: RS %02X %02X %02X\n",
+		XPD_DBG(REGS, xpd, "REGISTER_REPLY: RS %02X %02X %02X\n",
 				REG_FIELD(info, regnum), REG_FIELD(info, subreg), REG_FIELD(info, data_low));
 	} else {
 		if (REG_FIELD(info, regnum) != A_SU_RD_STA)
-			XPD_DBG(xpd, "REGISTER_REPLY: RD %02X %02X\n",
+			XPD_DBG(REGS, xpd, "REGISTER_REPLY: RD %02X %02X\n",
 					REG_FIELD(info, regnum), REG_FIELD(info, data_low));
 	}
-#endif
 	if(info->multibyte) {
-#if 0
-		XPD_DBG(xpd, "Got Multibyte: %d bytes, eoframe: %d\n",
+		XPD_DBG(REGS, xpd, "Got Multibyte: %d bytes, eoframe: %d\n",
 				info->bytes, info->eoframe);
-#endif
 		ret = rx_dchan(xpd, info);
 		if (ret < 0) {
 			priv->dchan_rx_drops++;
@@ -1437,7 +1437,7 @@
 {
 	const xproto_entry_t	*xe_nt = NULL;
 	const xproto_entry_t	*xe_te = NULL;
-	// DBG("\n");
+	// DBG(GENERAL, "\n");
 	xe_nt = xproto_card_entry(&PROTO_TABLE(BRI_NT), pack->opcode);
 	xe_te = xproto_card_entry(&PROTO_TABLE(BRI_TE), pack->opcode);
 	return xe_nt != NULL || xe_te != NULL;
@@ -1445,7 +1445,7 @@
 
 static void bri_packet_dump(const char *msg, xpacket_t *pack)
 {
-	DBG("%s\n", msg);
+	DBG(GENERAL, "%s\n", msg);
 }
 /*------------------------- REGISTER Handling --------------------------*/
 
@@ -1456,7 +1456,7 @@
 	xpd_t			*xpd = data;
 	struct BRI_priv_data	*priv;
 
-	DBG("\n");
+	DBG(PROC, "\n");
 	if(!xpd)
 		return -ENODEV;
 	spin_lock_irqsave(&xpd->lock, flags);
@@ -1543,6 +1543,10 @@
 	struct BRI_priv_data	*priv;
 	byte			buf[MAX_PROC_WRITE];
 
+	BUG_ON(!xpd);
+	xbus = xpd->xbus;
+	priv = xpd->priv;
+	BUG_ON(!priv);
 	if((p = strchr(cmdline, '#')) != NULL)	/* Truncate comments */
 		*p = '\0';
 	if((p = strchr(cmdline, ';')) != NULL)	/* Truncate comments */
@@ -1558,7 +1562,7 @@
 			&op, &reg_type, &reg_num,
 			&subreg,
 			&data, &xdata1, &xdata2);
-	// DBG("'%s': %d %c%c %02X %02X %02X\n", cmdline, chipsel, op, reg_type, reg_num, subreg, data);
+	XPD_DBG(PROC, xpd, "'%s': %d %c%c %02X %02X %02X\n", cmdline, chipsel, op, reg_type, reg_num, subreg, data);
 	if(elements < 3) {	// At least: chipsel, op, reg_type, reg_num
 		ERR("Not enough arguments: (%d args) '%s'\n", elements, cmdline);
 		return -EINVAL;
@@ -1623,14 +1627,10 @@
 	regcmd.bytes = sizeof(regcmd) - 1;
 	REG_FIELD(&regcmd, read_request) = writing;
 	REG_FIELD(&regcmd, data_high) = 0;
-	BUG_ON(!xpd);
-	xbus = xpd->xbus;
 	if(!down_read_trylock(&xbus->in_use)) {
-		XBUS_DBG(xbus, "Dropped packet. Is in_use\n");
+		XBUS_DBG(GENERAL, xbus, "Dropped packet. Is in_use\n");
 		return -EBUSY;
 	}
-	priv = xpd->priv;
-	BUG_ON(!priv);
 	priv->requested_reply = regcmd;
 	if(print_dbg)
 		dump_reg_cmd("BRI", &regcmd, 1);
@@ -1720,7 +1720,7 @@
 
 int __init card_bri_startup(void)
 {
-	DBG("\n");
+	DBG(GENERAL, "\n");
 
 	INFO("revision %s\n", XPP_VERSION);
 	xproto_register(&PROTO_TABLE(BRI_NT));
@@ -1730,7 +1730,7 @@
 
 void __exit card_bri_cleanup(void)
 {
-	DBG("\n");
+	DBG(GENERAL, "\n");
 	xproto_unregister(&PROTO_TABLE(BRI_NT));
 	xproto_unregister(&PROTO_TABLE(BRI_TE));
 }

Modified: branches/1.4/xpp/card_fxo.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/xpp/card_fxo.c?view=diff&rev=2866&r1=2865&r2=2866
==============================================================================
--- branches/1.4/xpp/card_fxo.c (original)
+++ branches/1.4/xpp/card_fxo.c Thu Aug 16 16:10:05 2007
@@ -156,7 +156,7 @@
 			BIT_CLR(priv->ledstate[which], chan);
 		}
 	}
-	LINE_DBG(xpd, chan, "LED: which=%d -- %s\n", which, (on) ? "on" : "off");
+	LINE_DBG(LEDS, xpd, chan, "LED: which=%d -- %s\n", which, (on) ? "on" : "off");
 	ret = DAA_DIRECT_REQUEST(xbus, xpd, chan, DAA_WRITE, 0x20, on);
 out:
 	return ret;
@@ -184,7 +184,7 @@
 				mod_value = DEFAULT_LED_PERIOD;		/* safety value */
 			// led state is toggled
 			if((timer_count % mod_value) == 0) {
-				LINE_DBG(xpd, i, "ledstate=%s\n", (IS_SET(priv->ledstate[color], i))?"ON":"OFF");
+				LINE_DBG(LEDS, xpd, i, "ledstate=%s\n", (IS_SET(priv->ledstate[color], i))?"ON":"OFF");
 				if(!IS_SET(priv->ledstate[color], i)) {
 					do_led(xpd, i, color, 1);
 				} else {
@@ -230,13 +230,13 @@
 	BUG_ON(!priv);
 	atomic_set(&priv->ring_debounce[pos], 0);	/* Stop debouncing */
 	if(on && !xpd->ringing[pos]) {
-		LINE_DBG(xpd, pos, "START\n");
+		LINE_DBG(SIGNAL, xpd, pos, "START\n");
 		xpd->ringing[pos] = 1;
 		MARK_BLINK(priv, pos, LED_GREEN, LED_BLINK_RING);
 		if(update_zap)
 			update_zap_ring(xpd, pos, on);
 	} else if(!on && xpd->ringing[pos]) {
-		LINE_DBG(xpd, pos, "STOP\n");
+		LINE_DBG(SIGNAL, xpd, pos, "STOP\n");
 		xpd->ringing[pos] = 0;
 		if(IS_BLINKING(priv, pos, LED_GREEN))
 			MARK_BLINK(priv, pos, LED_GREEN, 0);
@@ -259,12 +259,12 @@
 	priv = xpd->priv;
 	BUG_ON(!priv);
 	if(!IS_SET(priv->battery, pos)) {
-		LINE_DBG(xpd, pos, "WARNING: called while battery is off\n");
+		LINE_DBG(SIGNAL, xpd, pos, "WARNING: called while battery is off\n");
 	}
 	spin_lock_irqsave(&xpd->lock, flags);
 	mark_ring(xpd, pos, 0, 0);				// No more rings
 	value = (to_offhook) ? 0x09 : 0x08;	/* Bit 3 is for CID */
-	LINE_DBG(xpd, pos, "SETHOOK: value=0x%02X %s\n", value, (to_offhook)?"OFFHOOK":"ONHOOK");
+	LINE_DBG(SIGNAL, xpd, pos, "SETHOOK: value=0x%02X %s\n", value, (to_offhook)?"OFFHOOK":"ONHOOK");
 	if(to_offhook)
 		MARK_ON(priv, pos, LED_GREEN);
 	else
@@ -312,23 +312,23 @@
 
 	BUG_ON(!xpd);
 	priv = xpd->priv;
-	XPD_DBG(xpd, "\n");
+	XPD_DBG(PROC, xpd, "\n");
 #ifdef	CONFIG_PROC_FS
 	if(priv->regfile) {
-		XPD_DBG(xpd, "Removing xpd DAA file\n");
+		XPD_DBG(PROC, xpd, "Removing xpd DAA file\n");
 		remove_proc_entry(PROC_REGISTER_FNAME, xpd->proc_xpd_dir);
 		priv->regfile->data = NULL;
 	}
 #ifdef	WITH_METERING
 	if(priv->meteringfile) {
-		XPD_DBG(xpd, "Removing xpd metering tone file\n");
+		XPD_DBG(PROC, xpd, "Removing xpd metering tone file\n");
 		priv->meteringfile->data = NULL;
 		remove_proc_entry(PROC_METERING_FNAME, xpd->proc_xpd_dir);
 		priv->meteringfile = NULL;
 	}
 #endif
 	if(priv->fxo_info) {
-		XPD_DBG(xpd, "Removing xpd FXO_INFO file\n");
+		XPD_DBG(PROC, xpd, "Removing xpd FXO_INFO file\n");
 		remove_proc_entry(PROC_FXO_INFO_FNAME, xpd->proc_xpd_dir);
 		priv->fxo_info = NULL;
 	}
@@ -344,7 +344,7 @@
 	BUG_ON(!xpd);
 	priv = xpd->priv;
 #ifdef	CONFIG_PROC_FS
-	XPD_DBG(xpd, "Creating FXO_INFO file\n");
+	XPD_DBG(PROC, xpd, "Creating FXO_INFO file\n");
 	priv->fxo_info = create_proc_read_entry(PROC_FXO_INFO_FNAME, 0444, xpd->proc_xpd_dir, proc_fxo_info_read, xpd);
 	if(!priv->fxo_info) {
 		XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_FXO_INFO_FNAME);
@@ -353,7 +353,7 @@
 	}
 	priv->fxo_info->owner = THIS_MODULE;
 #ifdef	WITH_METERING
-	XPD_DBG(xpd, "Creating Metering tone file\n");
+	XPD_DBG(PROC, xpd, "Creating Metering tone file\n");
 	priv->meteringfile = create_proc_read_entry(PROC_METERING_FNAME, 0444, xpd->proc_xpd_dir,
 			proc_xpd_metering_read, xpd);
 	if(!priv->meteringfile) {
@@ -363,7 +363,7 @@
 	}
 	priv->meteringfile->owner = THIS_MODULE;
 #endif
-	XPD_DBG(xpd, "Creating DAAs file\n");
+	XPD_DBG(PROC, xpd, "Creating DAAs file\n");
 	priv->regfile = create_proc_entry(PROC_REGISTER_FNAME, 0644, xpd->proc_xpd_dir);
 	if(!priv->regfile) {
 		XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_REGISTER_FNAME);
@@ -382,7 +382,7 @@
 	for_each_line(xpd, i) {
 		do_sethook(xpd, i, 0);
 	}
-	XPD_DBG(xpd, "done\n");
+	XPD_DBG(GENERAL, xpd, "done\n");
 	for_each_line(xpd, i) {
 		do_led(xpd, i, LED_GREEN, 0);
 	}
@@ -408,7 +408,7 @@
 
 	BUG_ON(!xpd);
 	priv = xpd->priv;
-	XPD_DBG(xpd, "\n");
+	XPD_DBG(GENERAL, xpd, "\n");
 	clean_proc(xbus, xpd);
 	return 0;
 }
@@ -424,11 +424,11 @@
 	BUG_ON(!xbus);
 	priv = xpd->priv;
 	BUG_ON(!priv);
-	XPD_DBG(xpd, "%s\n", (on)?"ON":"OFF");
+	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF");
 	for_each_line(xpd, i) {
 		struct zt_chan	*cur_chan = &xpd->chans[i];
 
-		XPD_DBG(xpd, "setting FXO channel %d\n", i);
+		XPD_DBG(GENERAL, xpd, "setting FXO channel %d\n", i);
 		snprintf(cur_chan->name, MAX_CHANNAME, "XPP_FXO/%02d/%1d%1d/%d",
 			xbus->num, xpd->addr.unit, xpd->addr.subunit, i);
 		cur_chan->chanpos = i + 1;
@@ -453,7 +453,7 @@
 	BUG_ON(!xbus);
 	priv = xpd->priv;
 	BUG_ON(!priv);
-	XPD_DBG(xpd, "%s\n", (on)?"ON":"OFF");
+	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF");
 	for_each_line(xpd, i) {
 		MARK_OFF(priv, i, LED_GREEN);
 		msleep(2);
@@ -469,7 +469,7 @@
 
 	priv = xpd->priv;
 	BUG_ON(!priv);
-	LINE_DBG(xpd, pos, "%s\n", txsig2str(txsig));
+	LINE_DBG(SIGNAL, xpd, pos, "%s\n", txsig2str(txsig));
 	BUG_ON(xpd->direction != TO_PSTN);
 	/* XXX Enable hooksig for FXO XXX */
 	switch(txsig) {
@@ -595,13 +595,13 @@
 	BUG_ON(!xpd);
 	switch (cmd) {
 		case WCTDM_SET_ECHOTUNE:
-			XPD_DBG(xpd, "-- Setting echo registers: \n");
+			XPD_DBG(GENERAL, xpd, "-- Setting echo registers: \n");
 			/* first off: check if this span is fxs. If not: -EINVALID */
 			if (copy_from_user(&echotune_data, (void __user *)arg, sizeof(echotune_data)))
 				return -EFAULT;
 
 			for (i = 0; i < ARRAY_SIZE(echotune_regs); i++) {
-				XPD_DBG(xpd, "Reg=0x%02X, data=0x%02X\n", echotune_regs[i], echotune_data[i]);
+				XPD_DBG(REGS, xpd, "Reg=0x%02X, data=0x%02X\n", echotune_regs[i], echotune_data[i]);
 				ret = DAA_DIRECT_REQUEST(xpd->xbus, xpd, pos, DAA_WRITE, echotune_regs[i], echotune_data[i]);
 				if (ret < 0) {
 					LINE_NOTICE(xpd, pos, "Couldn't write %0x02X to register %0x02X\n",
@@ -611,10 +611,10 @@
 				msleep(1);
 			}
 
-			XPD_DBG(xpd, "-- Set echo registers successfully\n");
+			XPD_DBG(GENERAL, xpd, "-- Set echo registers successfully\n");
 			break;
 		default:
-			LINE_DBG(xpd, pos, "Unknown command 0x%X.\n", cmd);
+			LINE_DBG(GENERAL, xpd, pos, "Unknown command 0x%X.\n", cmd);
 			return -ENOTTY;
 	}
 	return 0;
@@ -630,16 +630,14 @@
 	reg_cmd_t	*reg_cmd;
 
 	if(!xbus) {
-		DBG("NO XBUS\n");
+		DBG(REGS, "NO XBUS\n");
 		return -EINVAL;
 	}
 	XFRAME_NEW(xframe, pack, xbus, GLOBAL, REGISTER_REQUEST, xpd->xbus_idx);
-#if 0
-	LINE_DBG(xpd, chisel, "%c%c R%02X S%02X %02X %02X\n",
+	LINE_DBG(REGS, xpd, chipsel, "%c%c R%02X S%02X %02X %02X\n",
 			(writing)?'W':'R',
 			(do_subreg)?'S':'D',
 			regnum, subreg, data_low, data_high);
-#endif
 	reg_cmd = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REQUEST, reg_cmd);
 	reg_cmd->bytes = sizeof(*reg_cmd) - 1;	// do not count the 'bytes' field
 	REG_FIELD(reg_cmd, chipsel) = chipsel;
@@ -662,7 +660,7 @@
 	BUG_ON(!xpd);
 	priv = xpd->priv;
 	BUG_ON(!priv);
-	XPD_DBG(xpd, "%s\n", (on) ? "on" : "off");
+	XPD_DBG(GENERAL, xpd, "%s\n", (on) ? "on" : "off");
 	return ret;
 }
 
@@ -670,7 +668,7 @@
 {
 	BUG_ON(!xbus);
 	BUG_ON(!xpd);
-	LINE_DBG(xpd, chan, "%s\n", (on) ? "on" : "off");
+	LINE_DBG(SIGNAL, xpd, chan, "%s\n", (on) ? "on" : "off");
 	return DAA_DIRECT_REQUEST(xbus, xpd, chan, DAA_WRITE, 0x40, (on)?0x04:0x01);
 }
 
@@ -695,14 +693,14 @@
 	}
 	priv = xpd->priv;
 	BUG_ON(!priv);
-	XPD_DBG(xpd, "(PSTN) sig_toggles=0x%04X sig_status=0x%04X\n", sig_toggles, sig_status);
+	XPD_DBG(SIGNAL, xpd, "(PSTN) sig_toggles=0x%04X sig_status=0x%04X\n", sig_toggles, sig_status);
 	spin_lock_irqsave(&xpd->lock, flags);
 	for_each_line(xpd, i) {
 		int	debounce;
 
 		if(IS_SET(sig_toggles, i)) {
 			if(!IS_SET(priv->battery, i)) {
-				LINE_DBG(xpd, i, "SIG_CHANGED while battery is off.\n");
+				LINE_DBG(SIGNAL, xpd, i, "SIG_CHANGED while battery is off.\n");
 				// FIXME: allow dialing without battery polling...
 				// continue;
 			}
@@ -735,7 +733,7 @@
 		 * Check for battery voltage fluctuations
 		 */
 		if(IS_SET(priv->battery, chipsel) && priv->battery_debounce[chipsel]++ > BAT_DEBOUNCE) {
-			LINE_DBG(xpd, chipsel, "BATTERY OFF voltage=%d\n", bat);
+			LINE_DBG(SIGNAL, xpd, chipsel, "BATTERY OFF voltage=%d\n", bat);
 			BIT_CLR(priv->battery, chipsel);
 			if(SPAN_REGISTERED(xpd))
 				zt_qevent_lock(&xpd->chans[chipsel], ZT_EVENT_ALARM);
@@ -744,7 +742,7 @@
 	} else {
 		priv->battery_debounce[chipsel] = 0;
 		if(!IS_SET(priv->battery, chipsel)) {
-			LINE_DBG(xpd, chipsel, "BATTERY ON voltage=%d\n", bat);
+			LINE_DBG(SIGNAL, xpd, chipsel, "BATTERY ON voltage=%d\n", bat);
 			BIT_SET(priv->battery, chipsel);
 			if(SPAN_REGISTERED(xpd))
 				zt_qevent_lock(&xpd->chans[chipsel], ZT_EVENT_NOALARM);
@@ -770,7 +768,7 @@
 					BIT_CLR(priv->polarity, chipsel);
 				priv->polarity_counter[chipsel] = 0;
 				/* Inform Zaptel */
-				LINE_DBG(xpd, chipsel, "Send ZT_EVENT_POLARITY\n");

[... 2047 lines stripped ...]



More information about the svn-commits mailing list