[aadk-commits] dbailey: uClinux/trunk r554 - in /uClinux/trunk/uClinux-dist: linux-2.6.x/dri...

SVN commits to the AADK repository aadk-commits at lists.digium.com
Wed Aug 8 14:25:47 CDT 2007


Author: dbailey
Date: Wed Aug  8 14:25:46 2007
New Revision: 554

URL: http://svn.digium.com/view/aadk?view=rev&rev=554
Log:
Added the ability to adjust fxo driver rx/tx gains via IOCTL call

Modified:
    uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/zaptel/sx00i.c
    uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/zaptel/zaptel.h
    uClinux/trunk/uClinux-dist/linux-2.6.x/include/zaptel/zaptel.h
    uClinux/trunk/uClinux-dist/uClibc/include/zaptel/zaptel.h

Modified: uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/zaptel/sx00i.c
URL: http://svn.digium.com/view/aadk/uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/zaptel/sx00i.c?view=diff&rev=554&r1=553&r2=554
==============================================================================
--- uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/zaptel/sx00i.c (original)
+++ uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/zaptel/sx00i.c Wed Aug  8 14:25:46 2007
@@ -1655,6 +1655,59 @@
 	while(jiffies < newjiffies);
 }
 
+/*********************************************************************
+ * Set the hwgain on the analog modules
+ *
+ * card = the card position for this module (0-23)
+ * gain = gain in dB x10 (e.g. -3.5dB  would be gain=-35)
+ * tx = (0 for rx; 1 for tx)
+ *
+ *******************************************************************/
+static int sx00_set_hwgain(struct sx00 *wc, int card, int gain, int tx)
+{
+	if (!(wc->modtype[card] == MOD_TYPE_FXO)) {
+		printk("Cannot adjust gain.  Unsupported module type!\n");
+		return -1;
+	}
+	if (tx) {
+		if (debug)
+			printk("setting FXO tx gain for card=%d to %d\n", card, gain);
+		if (gain >=  -150 && gain <= 0) {
+			sx00_setreg(wc, card, 38, 16 + (gain/-10));
+			if(gain % 10) {
+				sx00_setreg(wc, card, 40, 16 + (-gain%10));
+			}
+		} else if (gain <= 120 && gain > 0) {
+			sx00_setreg(wc, card, 38, gain/10);
+			if(gain % 10) {
+				sx00_setreg(wc, card, 40, (gain%10));
+			}
+		} else {
+			printk("FXO tx gain is out of range (%d)\n", gain);
+			return -1;
+		}
+	} else { /* rx */
+		if (debug)
+			printk("setting FXO rx gain for card=%d to %d\n", card, gain);
+		if (gain >=  -150 && gain <= 0) {
+			sx00_setreg(wc, card, 39, 16+ (gain/-10));
+			if(gain % 10) {
+				sx00_setreg(wc, card, 41, 16 + (-gain%10));
+			}
+		} else if (gain <= 120 && gain > 0) {
+			sx00_setreg(wc, card, 39, gain/10);
+			if(gain % 10) {
+				sx00_setreg(wc, card, 41, (gain%10));
+			}
+		} else {
+			printk("FXO rx gain is out of range (%d)\n", gain);
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
 static int sx00_init_voicedaa(struct sx00 *wc, int card, int fast, int manual, int sane)
 {
 	unsigned char reg16=0, reg26=0, reg30=0, reg31=0;
@@ -1730,22 +1783,8 @@
 	sx00_setreg(wc, card, 5, 0x08);
 
 	/* Take values for fxotxgain and fxorxgain and apply them to module */
-	if (fxotxgain >=  -150 && fxotxgain < 0) {
-		sx00_setreg(wc, card, 38, 16 + (fxotxgain/-10));
-		sx00_setreg(wc, card, 40, 16 + (-fxotxgain%10));
-	}
-	else if (fxotxgain <= 120 && fxotxgain >= 0) {
-		sx00_setreg(wc, card, 38, fxotxgain/10);
-		sx00_setreg(wc, card, 40, (fxotxgain%10));
-	}
-	if (fxorxgain >=  -150 && fxorxgain < 0) {
-		sx00_setreg(wc, card, 39, 16+ (fxorxgain/-10));
-		sx00_setreg(wc, card, 41, 16 + (-fxorxgain%10));
-	}
-	else if (fxorxgain <= 120 && fxorxgain >= 0) {
-		sx00_setreg(wc, card, 39, fxorxgain/10);
-		sx00_setreg(wc, card, 41, (fxorxgain%10));
-	}
+	sx00_set_hwgain(wc, card, fxorxgain, 0);
+	sx00_set_hwgain(wc, card, fxotxgain, 1);
 
 	return 0;
 		
@@ -1969,6 +2008,7 @@
 	struct wctdm_regs regs;
 	struct wctdm_regop regop;
 	struct wctdm_echo_coefs echoregs;
+	struct zt_hwgain hwgain;
 	struct sx00 *wc = chan->pvt;
 	int x,j;
 #if 0
@@ -2053,6 +2093,16 @@
 			printk("Setting direct %d to %04x on %d\n", regop.reg, regop.val, chan->chanpos);
 			sx00_setreg(wc, chan->chanpos - 1, regop.reg, regop.val);
 		}
+		break;
+	case ZT_SET_HWGAIN:
+		if (copy_from_user(&hwgain, (struct zt_hwgain*)data, sizeof(hwgain)))
+			return -EFAULT;
+
+		sx00_set_hwgain(wc, chan->chanpos-1, hwgain.newgain, hwgain.tx);
+
+		if (debug)
+			printk("Setting hwgain on channel %d to %d for %s direction\n", 
+				chan->chanpos-1, hwgain.newgain, hwgain.tx ? "tx" : "rx");
 		break;
 	case WCTDM_SET_ECHOTUNE:
 		if (debug)

Modified: uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/zaptel/zaptel.h
URL: http://svn.digium.com/view/aadk/uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/zaptel/zaptel.h?view=diff&rev=554&r1=553&r2=554
==============================================================================
--- uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/zaptel/zaptel.h (original)
+++ uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/zaptel/zaptel.h Wed Aug  8 14:25:46 2007
@@ -327,6 +327,10 @@
 	char echo_canceller[80];
 };
 
+struct zt_hwgain{
+	int newgain; /* desired gain in dB but x10.  -3.5dB would be -35 */
+	int tx:1; /* 0=rx; 1=tx */
+};
 
 /* ioctl definitions */
 #define ZT_CODE	'J'
@@ -630,6 +634,11 @@
  * transmitted back on the interface)
  */
 #define ZT_LOOPBACK _IOW(ZT_CODE, 58, int)
+
+/*
+ * Set the HW gain for a device
+ */
+#define ZT_SET_HWGAIN   _IOW (ZT_CODE, 86, struct zt_hwgain)
 
 /*
  *  60-80 are reserved for private drivers

Modified: uClinux/trunk/uClinux-dist/linux-2.6.x/include/zaptel/zaptel.h
URL: http://svn.digium.com/view/aadk/uClinux/trunk/uClinux-dist/linux-2.6.x/include/zaptel/zaptel.h?view=diff&rev=554&r1=553&r2=554
==============================================================================
--- uClinux/trunk/uClinux-dist/linux-2.6.x/include/zaptel/zaptel.h (original)
+++ uClinux/trunk/uClinux-dist/linux-2.6.x/include/zaptel/zaptel.h Wed Aug  8 14:25:46 2007
@@ -327,6 +327,10 @@
 	char echo_canceller[80];
 };
 
+struct zt_hwgain{
+	int newgain; /* desired gain in dB but x10.  -3.5dB would be -35 */
+	int tx:1; /* 0=rx; 1=tx */
+};
 
 /* ioctl definitions */
 #define ZT_CODE	'J'
@@ -630,6 +634,11 @@
  * transmitted back on the interface)
  */
 #define ZT_LOOPBACK _IOW(ZT_CODE, 58, int)
+
+/*
+ * Set the HW gain for a device
+ */
+#define ZT_SET_HWGAIN   _IOW (ZT_CODE, 86, struct zt_hwgain)
 
 /*
  *  60-80 are reserved for private drivers

Modified: uClinux/trunk/uClinux-dist/uClibc/include/zaptel/zaptel.h
URL: http://svn.digium.com/view/aadk/uClinux/trunk/uClinux-dist/uClibc/include/zaptel/zaptel.h?view=diff&rev=554&r1=553&r2=554
==============================================================================
--- uClinux/trunk/uClinux-dist/uClibc/include/zaptel/zaptel.h (original)
+++ uClinux/trunk/uClinux-dist/uClibc/include/zaptel/zaptel.h Wed Aug  8 14:25:46 2007
@@ -327,6 +327,10 @@
 	char echo_canceller[80];
 };
 
+struct zt_hwgain{
+	int newgain; /* desired gain in dB but x10.  -3.5dB would be -35 */
+	int tx:1; /* 0=rx; 1=tx */
+};
 
 /* ioctl definitions */
 #define ZT_CODE	'J'
@@ -630,6 +634,11 @@
  * transmitted back on the interface)
  */
 #define ZT_LOOPBACK _IOW(ZT_CODE, 58, int)
+
+/*
+ * Set the HW gain for a device
+ */
+#define ZT_SET_HWGAIN   _IOW (ZT_CODE, 86, struct zt_hwgain)
 
 /*
  *  60-80 are reserved for private drivers




More information about the aadk-commits mailing list