Index: build_tools/cflags.xml
===================================================================
--- build_tools/cflags.xml	(revision 94827)
+++ build_tools/cflags.xml	(working copy)
@@ -48,4 +48,23 @@
 		</member>
 		<member name="THREAD_CRASH" displayname="Crash on mutex errors">
 		</member>
+		<member name="BUSYDETECT_MARTIN" displayname="Default new busy detection routine">
+			<defaultenabled>yes</defaultenabled>
+			<conflict>BUSYDETECT</conflict>
+		</member>
+		<member name="BUSYDETECT" displayname="Old busy detection routine">
+			<conflict>BUSYDETECT_MARTIN</conflict>
+			<defaultenabled>no</defaultenabled>
+		</member>
+		<member name="BUSYDETECT_TONEONLY" displayname="Enable additional comparision of only the tone duration not the silence part">
+			<conflict>BUSYDETECT_COMPARE_TONE_AND_SILENCE</conflict>
+			<defaultenabled>no</defaultenabled>
+		</member>
+		<member name="BUSYDETECT_COMPARE_TONE_AND_SILENCE" displayname="Assume that tone and silence has the same duration">
+			<conflict>BUSYDETECT_TONEONLY</conflict>
+			<defaultenabled>no</defaultenabled>
+		</member>
+		<member name="BUSYDETECT_DEBUG" displayname="Allow additional WARNING for every time the busy detection routine is executed, enable only if you need to do some debugging">
+			<defaultenabled>no</defaultenabled>
+		</member>
 	</category>
Index: channels/chan_zap.c
===================================================================
--- channels/chan_zap.c	(revision 94827)
+++ channels/chan_zap.c	(working copy)
@@ -11630,6 +11630,28 @@
 			ast_cli(a->fd, "Propagated Conference: %d\n", tmp->propconfno);
 			ast_cli(a->fd, "Real in conference: %d\n", tmp->inconference);
 			ast_cli(a->fd, "DSP: %s\n", tmp->dsp ? "yes" : "no");
+			ast_cli(a->fd, "Busy Detection %s\n", tmp->busydetect ? "yes" : "no" );
+			if (tmp->busydetect) {
+				ast_cli(a->fd, "\tBusy Detector: ");
+#ifdef BUSYDETECT
+				ast_cli(a->fd, "BUSYDETECT ");
+#endif
+#ifdef BUSYDETECT_MARTIN
+				ast_cli(a->fd, "BUSYDETECT_MARTING ");
+#endif
+#ifdef BUSYDETECT_TONEONLY
+				ast_cli(a->fd, "BUSYDETECT_TONEONLY ");
+#endif
+#ifdef BUSYDETECT_COMPARE_TONE_AND_SILECE
+				ast_cli(a->fd, "BUSYDETECT_COMPARE_TONE_AND_SILECE ");
+#endif
+#ifdef BUSYDETECT_DEBUG
+				ast_cli(a->fd, "BUSYDETECT_DEBUG ");
+#endif
+				ast_cli(a->fd, "\n");
+				ast_cli(a->fd, "\tBusy Count: %d\n", tmp->busycount);
+				ast_cli(a->fd, "\tBusy Pattern: %d,%d\n", tmp->busy_tonelength, tmp->busy_quietlength);
+			}
 			ast_cli(a->fd, "TDD: %s\n", tmp->tdd ? "yes" : "no");
 			ast_cli(a->fd, "Relax DTMF: %s\n", tmp->dtmfrelax ? "yes" : "no");
 			ast_cli(a->fd, "Dialing/CallwaitCAS: %d/%d\n", tmp->dialing, tmp->callwaitcas);
Index: main/dsp.c
===================================================================
--- main/dsp.c	(revision 94827)
+++ main/dsp.c	(working copy)
@@ -52,6 +52,7 @@
 #include "asterisk/ulaw.h"
 #include "asterisk/alaw.h"
 #include "asterisk/utils.h"
+#include "asterisk/options.h"
 
 /*! Number of goertzels for progress detect */
 enum gsamp_size {
@@ -162,10 +163,15 @@
 #define BELL_MF_TWIST		4.0     /* 6dB */
 #define BELL_MF_RELATIVE_PEAK	12.6    /* 11dB */
 
-#if !defined(BUSYDETECT_MARTIN) && !defined(BUSYDETECT) && !defined(BUSYDETECT_TONEONLY) && !defined(BUSYDETECT_COMPARE_TONE_AND_SILENCE)
+#if !defined(BUSYDETECT_MARTIN) && !defined(BUSYDETECT)
 #define BUSYDETECT_MARTIN
+#warning You didn't selected BUSYDETECT_MARTIN or BUSYDETECT option via make menuselect
 #endif
 
+#if defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_COMPARE_TONE_AND_SILENCE)
+#error You cant use BUSYDETECT_TONEONLY together with BUSYDETECT_COMPARE_TONE_AND_SILENCE
+#endif
+
 typedef struct {
 	int v2;
 	int v3;
@@ -965,9 +971,11 @@
 	/* If we know the expected busy tone length, check we are in the range */
 	if (res && (dsp->busy_tonelength > 0)) {
 		if (abs(avgtone - dsp->busy_tonelength) > (dsp->busy_tonelength*BUSY_PAT_PERCENT/100)) {
-#if 0
-			ast_log(LOG_NOTICE, "busy detector: avgtone of %d not close enough to desired %d\n",
-						avgtone, dsp->busy_tonelength);
+#ifdef BUSYDETECT_DEBUG
+			if (option_debug > 5) {
+				ast_log(LOG_WARNING, "busy detector: avgtone of %d not close enough to desired %d\n",
+					avgtone, dsp->busy_tonelength);
+			}
 #endif
 			res = 0;
 		}
@@ -976,17 +984,27 @@
 	/* If we know the expected busy tone silent-period length, check we are in the range */
 	if (res && (dsp->busy_quietlength > 0)) {
 		if (abs(avgsilence - dsp->busy_quietlength) > (dsp->busy_quietlength*BUSY_PAT_PERCENT/100)) {
-#if 0
-			ast_log(LOG_NOTICE, "busy detector: avgsilence of %d not close enough to desired %d\n",
-						avgsilence, dsp->busy_quietlength);
+#ifdef BUSYDETECT_DEBUG
+		if (option_debug > 5) {
+			ast_log(LOG_WARNING, "busy detector: avgsilence of %d not close enough to desired %d\n",
+				avgsilence, dsp->busy_quietlength);
+		}
 #endif
 			res = 0;
 		}
 	}
 #endif
-#ifndef BUSYDETECT_TONEONLY
-	if (res) {
-		ast_debug(1, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
+#if !defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_DEBUG)
+	if (option_debug > 5) {
+		if (res) {
+			ast_log(LOG_WARNING, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
+		} else {
+			ast_log(LOG_WARNING, "busy detector: FAILED with avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
+		}
+	} else {
+		if (res) {
+			ast_log(LOG_DEBUG, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
+		}
 	}
 #endif
 	return res;
Index: configs/zapata.conf.sample
===================================================================
--- configs/zapata.conf.sample	(revision 94827)
+++ configs/zapata.conf.sample	(working copy)
@@ -588,6 +588,10 @@
 ; silence (as many countries do), consider defining the
 ; -DBUSYDETECT_COMPARE_TONE_AND_SILENCE option.
 ;
+; To further detect wich hangup tone is your telco provider sending is usefull
+; to use the ztmonitor utility to record the audio main/dsp.c is receiving
+; after the caller hangup
+;
 ; Use a polarity reversal to mark when a outgoing call is answered by the
 ; remote party.
 ;
