[zaptel-commits] tzafrir: branch 1.4 r3679 - /branches/1.4/wcfxo.c

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Sat Jan 12 09:30:45 CST 2008


Author: tzafrir
Date: Sat Jan 12 09:30:42 2008
New Revision: 3679

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3679
Log:
Detect cards that do not support international settings:

Cards based on si3035 can not be set with international settings.
This can be tested using REVB (reg. 13, bits 2:5). This commit tests for 
that value.

It also adds some debugging macros, based on xpp/zap_debug.h , those
maybe those macros should be moved to a more common place.

Modified:
    branches/1.4/wcfxo.c

Modified: branches/1.4/wcfxo.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wcfxo.c?view=diff&rev=3679&r1=3678&r2=3679
==============================================================================
--- branches/1.4/wcfxo.c (original)
+++ branches/1.4/wcfxo.c Sat Jan 12 09:30:42 2008
@@ -94,6 +94,17 @@
 #define PEGTIME		50 * 8		/* 50ms peak to peak gets us rings of 10 Hz or more */
 #define PEGCOUNT	5		/* 5 cycles of pegging means RING */
 
+#define	wcfxo_printk(level, span, fmt, ...)	\
+	printk(KERN_ ## level "%s-%s: %s: " fmt, #level,	\
+		THIS_MODULE->name, (span).name, ## __VA_ARGS__)
+
+#define wcfxo_notice(span, fmt, ...) \
+	wcfxo_printk(NOTICE, span, fmt, ## __VA_ARGS__)
+
+#define wcfxo_dbg(span, fmt, ...) \
+	((void)((debug) && wcfxo_printk(DEBUG, span, "%s: " fmt, \
+			__FUNCTION__, ## __VA_ARGS__) ) )
+
 struct reg {
 	unsigned long flags;
 	unsigned char index;
@@ -163,6 +174,7 @@
 #define FLAG_USE_XTAL		(1 << 1)
 #define FLAG_DOUBLE_CLOCK	(1 << 2)
 #define FLAG_RESET_ON_AUX5	(1 << 3)
+#define FLAG_NO_I18N_REGS	(1 << 4) /*!< Uses si3035, rather si3034 */
 
 struct wcfxo_desc {
 	char *name;
@@ -749,7 +761,7 @@
 	outb(0x00, wc->ioaddr + WC_MASK1);
 }
 
-static int wcfxo_set_daa_mode(struct wcfxo *wc)
+static void wcfxo_set_daa_mode(struct wcfxo *wc)
 {
 	/* Set country specific parameters (OHS, ACT, DCT, RZ, RT, LIM, VOL) */
 	int reg16 = ((fxo_modes[opermode].ohs & 0x1) << 6) |
@@ -760,6 +772,11 @@
 	int reg17 = ((fxo_modes[opermode].lim & 0x3) << 3);
 	int reg18 = ((fxo_modes[opermode].vol & 0x3) << 3);
 
+	if (wc->flags & FLAG_NO_I18N_REGS) {
+		wcfxo_dbg(wc->span, "This card does not support international settings.\n");
+		return;
+	}
+
 	wcfxo_setreg(wc, 0x16, reg16);
 	wcfxo_setreg(wc, 0x17, reg17);
 	wcfxo_setreg(wc, 0x18, reg18);
@@ -770,7 +787,6 @@
 	schedule_timeout(1 + (ZT_CHUNKSIZE * HZ) / 800);
 
 	printk("wcfxo: DAA mode is '%s'\n", fxo_modes[opermode].name);
-	return 0;
 }
 
 static int wcfxo_init_daa(struct wcfxo *wc)
@@ -778,6 +794,7 @@
 	/* This must not be called in an interrupt */
 	/* We let things settle for a bit */
 	unsigned char reg15;
+	int chip_revb;
 //	set_current_state(TASK_INTERRUPTIBLE);
 //	schedule_timeout(10);
 
@@ -825,6 +842,22 @@
 		reg15 |= (boost & 0x3);
 	}
 	wcfxo_setreg(wc, 0xf, reg15);
+
+	chip_revb = (wc->readregs[13] >> 2) & 0xF; /* REVB: reg. 13, bits 5:2 */ 
+	wcfxo_dbg(wc->span, "DAA chip REVB is %x\n", chip_revb);
+	switch(chip_revb) {
+		case 1: case 2: case 3:
+			/* This is a si3034. Nothing to do */
+			break;
+		case 4: case 5: case 7:
+			/* This is 3035. Has no support for international registers */
+			wc->flags |= FLAG_NO_I18N_REGS;
+			break;
+		default:
+			wcfxo_notice(wc->span, "Unknown DAA chip revision: REVB=%d\n",
+					chip_revb);
+	}
+
 	/* Didn't get it right.  Register 9 is still garbage */
 	if (wc->readregs[0x9] != 0x89)
 		return -1;




More information about the zaptel-commits mailing list