[dahdi-commits] russell: linux/trunk r4679 - in /linux/trunk: drivers/dahdi/ drivers/dahdi/wc...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Sun Aug 3 10:42:46 CDT 2008
Author: russell
Date: Sun Aug 3 10:42:46 2008
New Revision: 4679
URL: http://svn.digium.com/view/dahdi?view=rev&rev=4679
Log:
Rework the table of signalling bits for signalling types and hook states
in dahdi_rbs_sethook() to a much more readable and less error prone format.
In passing, get rid of the dahdi_txsig_t typedef, and fix uses of it
throughout the tree.
Modified:
linux/trunk/drivers/dahdi/dahdi-base.c
linux/trunk/drivers/dahdi/pciradio.c
linux/trunk/drivers/dahdi/wcfxo.c
linux/trunk/drivers/dahdi/wctdm.c
linux/trunk/drivers/dahdi/wctdm24xxp/base.c
linux/trunk/drivers/dahdi/xpp/card_fxo.c
linux/trunk/drivers/dahdi/xpp/card_fxs.c
linux/trunk/drivers/dahdi/xpp/card_pri.c
linux/trunk/drivers/dahdi/xpp/dahdi_debug.h
linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c
linux/trunk/drivers/dahdi/xpp/xproto.h
linux/trunk/include/dahdi/kernel.h
linux/trunk/include/dahdi/user.h
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Sun Aug 3 10:42:46 2008
@@ -189,7 +189,9 @@
static int debug;
-/* states for transmit signalling */
+/*!
+ * \brief states for transmit signalling
+ */
enum dahdi_txstate {
DAHDI_TXSTATE_ONHOOK,
DAHDI_TXSTATE_OFFHOOK,
@@ -206,7 +208,7 @@
DAHDI_TXSTATE_AFTERKEWL,
DAHDI_TXSTATE_PULSEBREAK,
DAHDI_TXSTATE_PULSEMAKE,
- DAHDI_TXSTATE_PULSEAFTER
+ DAHDI_TXSTATE_PULSEAFTER,
};
typedef short sumtype[DAHDI_MAX_CHUNKSIZE];
@@ -2112,39 +2114,70 @@
return;
}
-static void dahdi_rbs_sethook(struct dahdi_chan *chan, int txsig, int txstate, int timeout)
-{
-static int outs[NUM_SIGS][5] = {
-/* We set the idle case of the DAHDI_SIG_NONE to this pattern to make idle E1 CAS
-channels happy. Should not matter with T1, since on an un-configured channel,
-who cares what the sig bits are as long as they are stable */
- { DAHDI_SIG_NONE, DAHDI_ABIT | DAHDI_CBIT | DAHDI_DBIT, 0, 0, 0 }, /* no signalling */
- { DAHDI_SIG_EM, 0, DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT,
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT, 0 }, /* E and M */
- { DAHDI_SIG_FXSLS, DAHDI_BBIT | DAHDI_DBIT,
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT,
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT, 0 }, /* FXS Loopstart */
- { DAHDI_SIG_FXSGS, DAHDI_BBIT | DAHDI_DBIT,
-#ifdef CONFIG_CAC_GROUNDSTART
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT, 0, 0 }, /* FXS Groundstart (CAC-style) */
-#else
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT, DAHDI_ABIT | DAHDI_CBIT, 0 }, /* FXS Groundstart (normal) */
-#endif
- { DAHDI_SIG_FXSKS, DAHDI_BBIT | DAHDI_DBIT,
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT,
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT, 0 }, /* FXS Kewlstart */
- { DAHDI_SIG_FXOLS, DAHDI_BBIT | DAHDI_DBIT, DAHDI_BBIT | DAHDI_DBIT, 0, 0 }, /* FXO Loopstart */
- { DAHDI_SIG_FXOGS, DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT,
- DAHDI_BBIT | DAHDI_DBIT, 0, 0 }, /* FXO Groundstart */
- { DAHDI_SIG_FXOKS, DAHDI_BBIT | DAHDI_DBIT, DAHDI_BBIT | DAHDI_DBIT, 0,
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT }, /* FXO Kewlstart */
- { DAHDI_SIG_SF, DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT,
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT,
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT,
- DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT }, /* no signalling */
- { DAHDI_SIG_EM_E1, DAHDI_DBIT, DAHDI_ABIT | DAHDI_BBIT | DAHDI_DBIT,
- DAHDI_ABIT | DAHDI_BBIT | DAHDI_DBIT, DAHDI_DBIT }, /* E and M E1 */
- } ;
+static void dahdi_rbs_sethook(struct dahdi_chan *chan, int txsig, int txstate,
+ int timeout)
+{
+ static const struct {
+ unsigned int sig_type;
+ /* Index is dahdi_txsig enum */
+ unsigned int bits[DAHDI_TXSIG_TOTAL];
+ } outs[NUM_SIGS] = {
+ {
+ /*
+ * We set the idle case of the DAHDI_SIG_NONE to this pattern to make idle E1 CAS
+ * channels happy. Should not matter with T1, since on an un-configured channel,
+ * who cares what the sig bits are as long as they are stable
+ */
+ .sig_type = DAHDI_SIG_NONE,
+ .bits[DAHDI_TXSIG_ONHOOK] = DAHDI_BITS_ACD,
+ }, {
+ .sig_type = DAHDI_SIG_EM,
+ .bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_ABCD,
+ .bits[DAHDI_TXSIG_START] = DAHDI_BITS_ABCD,
+ }, {
+ .sig_type = DAHDI_SIG_FXSLS,
+ .bits[DAHDI_TXSIG_ONHOOK] = DAHDI_BITS_BD,
+ .bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_ABCD,
+ .bits[DAHDI_TXSIG_START] = DAHDI_BITS_ABCD,
+ }, {
+ .sig_type = DAHDI_SIG_FXSGS,
+ .bits[DAHDI_TXSIG_ONHOOK] = DAHDI_BITS_BD,
+ .bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_ABCD,
+#ifndef CONFIG_CAC_GROUNDSTART
+ .bits[DAHDI_TXSIG_START] = DAHDI_BITS_AC,
+#endif
+ }, {
+ .sig_type = DAHDI_SIG_FXSKS,
+ .bits[DAHDI_TXSIG_ONHOOK] = DAHDI_BITS_BD,
+ .bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_ABCD,
+ .bits[DAHDI_TXSIG_START] = DAHDI_BITS_ABCD,
+ }, {
+ .sig_type = DAHDI_SIG_FXOLS,
+ .bits[DAHDI_TXSIG_ONHOOK] = DAHDI_BITS_BD,
+ .bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_BD,
+ }, {
+ .sig_type = DAHDI_SIG_FXOGS,
+ .bits[DAHDI_TXSIG_ONHOOK] = DAHDI_BITS_ABCD,
+ .bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_BD,
+ }, {
+ .sig_type = DAHDI_SIG_FXOKS,
+ .bits[DAHDI_TXSIG_ONHOOK] = DAHDI_BITS_BD,
+ .bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_BD,
+ .bits[DAHDI_TXSIG_KEWL] = DAHDI_BITS_ABCD,
+ }, {
+ .sig_type = DAHDI_SIG_SF,
+ .bits[DAHDI_TXSIG_ONHOOK] = DAHDI_BITS_BCD,
+ .bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_ABCD,
+ .bits[DAHDI_TXSIG_START] = DAHDI_BITS_ABCD,
+ .bits[DAHDI_TXSIG_KEWL] = DAHDI_BITS_BCD,
+ }, {
+ .sig_type = DAHDI_SIG_EM_E1,
+ .bits[DAHDI_TXSIG_ONHOOK] = DAHDI_DBIT,
+ .bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_ABD,
+ .bits[DAHDI_TXSIG_START] = DAHDI_BITS_ABD,
+ .bits[DAHDI_TXSIG_KEWL] = DAHDI_DBIT,
+ }
+ };
int x;
/* if no span, return doing nothing */
@@ -2192,12 +2225,12 @@
return;
} else {
for (x = 0; x < NUM_SIGS; x++) {
- if (outs[x][0] == chan->sig) {
+ if (outs[x].sig_type == chan->sig) {
#ifdef CONFIG_DAHDI_DEBUG
- module_printk(KERN_NOTICE, "Setting bits to %d for channel %s state %d in %d signalling\n", outs[x][txsig + 1], chan->name, txsig, chan->sig);
+ module_printk(KERN_NOTICE, "Setting bits to %d for channel %s state %d in %d signalling\n", outs[x].bits[txsig], chan->name, txsig, chan->sig);
#endif
chan->txhooksig = txsig;
- chan->txsig = outs[x][txsig+1];
+ chan->txsig = outs[x].bits[txsig];
chan->span->rbsbits(chan, chan->txsig);
chan->otimer = timeout * DAHDI_CHUNKSIZE; /* Otimer is timer in samples */
return;
Modified: linux/trunk/drivers/dahdi/pciradio.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/pciradio.c?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/pciradio.c (original)
+++ linux/trunk/drivers/dahdi/pciradio.c Sun Aug 3 10:42:46 2008
@@ -1441,7 +1441,7 @@
return 0;
}
-static int pciradio_hooksig(struct dahdi_chan *chan, dahdi_txsig_t txsig)
+static int pciradio_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig)
{
struct pciradio *rad = chan->pvt;
Modified: linux/trunk/drivers/dahdi/wcfxo.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/wcfxo.c?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/wcfxo.c (original)
+++ linux/trunk/drivers/dahdi/wcfxo.c Sun Aug 3 10:42:46 2008
@@ -591,7 +591,7 @@
return 0;
}
-static int wcfxo_hooksig(struct dahdi_chan *chan, dahdi_txsig_t txsig)
+static int wcfxo_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig)
{
struct wcfxo *wc = chan->pvt;
int reg=0;
Modified: linux/trunk/drivers/dahdi/wctdm.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/wctdm.c?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm.c (original)
+++ linux/trunk/drivers/dahdi/wctdm.c Sun Aug 3 10:42:46 2008
@@ -1945,7 +1945,7 @@
return 0;
}
-static int wctdm_hooksig(struct dahdi_chan *chan, dahdi_txsig_t txsig)
+static int wctdm_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig)
{
struct wctdm *wc = chan->pvt;
int reg=0;
Modified: linux/trunk/drivers/dahdi/wctdm24xxp/base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/base.c Sun Aug 3 10:42:46 2008
@@ -2646,7 +2646,7 @@
return 0;
}
-static int wctdm_hooksig(struct dahdi_chan *chan, dahdi_txsig_t txsig)
+static int wctdm_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig)
{
struct wctdm *wc = chan->pvt;
int reg=0,qrvcard;
Modified: linux/trunk/drivers/dahdi/xpp/card_fxo.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_fxo.c?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_fxo.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_fxo.c Sun Aug 3 10:42:46 2008
@@ -541,7 +541,7 @@
return 0;
}
-static int FXO_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, dahdi_txsig_t txsig)
+static int FXO_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig)
{
struct FXO_priv_data *priv;
int ret = 0;
Modified: linux/trunk/drivers/dahdi/xpp/card_fxs.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_fxs.c?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_fxs.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_fxs.c Sun Aug 3 10:42:46 2008
@@ -635,7 +635,7 @@
return ret;
}
-static int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, dahdi_txsig_t txsig)
+static int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig)
{
struct FXS_priv_data *priv;
int ret = 0;
Modified: linux/trunk/drivers/dahdi/xpp/card_pri.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_pri.c?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_pri.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_pri.c Sun Aug 3 10:42:46 2008
@@ -913,7 +913,7 @@
return(0);
}
-static int PRI_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, dahdi_txsig_t txsig)
+static int PRI_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig)
{
LINE_DBG(SIGNAL, xpd, pos, "%s\n", txsig2str(txsig));
return 0;
Modified: linux/trunk/drivers/dahdi/xpp/dahdi_debug.h
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/dahdi_debug.h?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/dahdi_debug.h (original)
+++ linux/trunk/drivers/dahdi/xpp/dahdi_debug.h Sun Aug 3 10:42:46 2008
@@ -104,13 +104,14 @@
return "Unknown rxsig";
}
-static inline char *txsig2str(dahdi_txsig_t sig)
+static inline char *txsig2str(enum dahdi_txsig sig)
{
switch(sig) {
case DAHDI_TXSIG_ONHOOK: return "TXSIG_ONHOOK";
case DAHDI_TXSIG_OFFHOOK: return "TXSIG_OFFHOOK";
case DAHDI_TXSIG_START: return "TXSIG_START";
case DAHDI_TXSIG_KEWL: return "TXSIG_KEWL"; /* Drop battery if possible */
+ case DAHDI_TXSIG_TOTAL: break;
}
return "Unknown txsig";
}
Modified: linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c Sun Aug 3 10:42:46 2008
@@ -770,7 +770,7 @@
return 0;
}
-static int xpp_hooksig(struct dahdi_chan *chan, dahdi_txsig_t txsig)
+static int xpp_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig)
{
xpd_t *xpd = chan->pvt;
xbus_t *xbus;
Modified: linux/trunk/drivers/dahdi/xpp/xproto.h
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/xproto.h?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xproto.h (original)
+++ linux/trunk/drivers/dahdi/xpp/xproto.h Sun Aug 3 10:42:46 2008
@@ -225,7 +225,7 @@
void (*card_pcm_tospan)(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack);
int (*card_dahdi_preregistration)(xpd_t *xpd, bool on);
int (*card_dahdi_postregistration)(xpd_t *xpd, bool on);
- int (*card_hooksig)(xbus_t *xbus, xpd_t *xpd, int pos, dahdi_txsig_t txsig);
+ int (*card_hooksig)(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig);
int (*card_ioctl)(xpd_t *xpd, int pos, unsigned int cmd, unsigned long arg);
int (*card_open)(xpd_t *xpd, lineno_t pos);
int (*card_close)(xpd_t *xpd, lineno_t pos);
Modified: linux/trunk/include/dahdi/kernel.h
URL: http://svn.digium.com/view/dahdi/linux/trunk/include/dahdi/kernel.h?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/include/dahdi/kernel.h (original)
+++ linux/trunk/include/dahdi/kernel.h Sun Aug 3 10:42:46 2008
@@ -419,12 +419,14 @@
int dahdi_unregister_chardev(struct dahdi_chardev *dev);
/*! \brief defines for transmit signalling */
-typedef enum {
+enum dahdi_txsig {
DAHDI_TXSIG_ONHOOK, /*!< On hook */
DAHDI_TXSIG_OFFHOOK, /*!< Off hook */
DAHDI_TXSIG_START, /*!< Start / Ring */
- DAHDI_TXSIG_KEWL /*!< Drop battery if possible */
-} dahdi_txsig_t;
+ DAHDI_TXSIG_KEWL, /*!< Drop battery if possible */
+ /*! Leave this as the last entry */
+ DAHDI_TXSIG_TOTAL,
+};
typedef enum {
DAHDI_RXSIG_ONHOOK,
@@ -575,7 +577,7 @@
generate ring, etc directly) then you can just specify a
sethook function, and we'll call you with appropriate hook states
to set. Still set the DAHDI_FLAG_RBS in this case as well */
- int (*hooksig)(struct dahdi_chan *chan, dahdi_txsig_t hookstate);
+ int (*hooksig)(struct dahdi_chan *chan, enum dahdi_txsig hookstate);
/*! Option 3: If you can't use sig bits, you can write a function
which handles the individual hook states */
Modified: linux/trunk/include/dahdi/user.h
URL: http://svn.digium.com/view/dahdi/linux/trunk/include/dahdi/user.h?view=diff&rev=4679&r1=4678&r2=4679
==============================================================================
--- linux/trunk/include/dahdi/user.h (original)
+++ linux/trunk/include/dahdi/user.h Sun Aug 3 10:42:46 2008
@@ -90,6 +90,13 @@
#define DAHDI_BBIT (1 << 2)
#define DAHDI_CBIT (1 << 1)
#define DAHDI_DBIT (1 << 0)
+
+#define DAHDI_BITS_ABCD (DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT)
+#define DAHDI_BITS_ABD (DAHDI_ABIT | DAHDI_BBIT | DAHDI_DBIT)
+#define DAHDI_BITS_ACD (DAHDI_ABIT | DAHDI_CBIT | DAHDI_DBIT)
+#define DAHDI_BITS_BCD (DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT)
+#define DAHDI_BITS_AC (DAHDI_ABIT | DAHDI_CBIT)
+#define DAHDI_BITS_BD (DAHDI_BBIT | DAHDI_DBIT)
#define DAHDI_MAJOR 196
More information about the dahdi-commits
mailing list