diff options
author | Russell Bryant <russell@digium.com> | 2008-08-03 15:42:46 +0000 |
---|---|---|
committer | Russell Bryant <russell@digium.com> | 2008-08-03 15:42:46 +0000 |
commit | 99bb77154edc3511ce751829fcc948de59793dc4 (patch) | |
tree | 295a3ecde4aed3fb7e28470efa4ec8c9f1e85187 /drivers/dahdi | |
parent | 210e1ee25783d7be083220b0690bd37c4a7a99c0 (diff) |
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.
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@4679 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi')
-rw-r--r-- | drivers/dahdi/dahdi-base.c | 107 | ||||
-rw-r--r-- | drivers/dahdi/pciradio.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/wcfxo.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/wctdm.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/wctdm24xxp/base.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/xpp/card_fxo.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/xpp/card_fxs.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/xpp/card_pri.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/xpp/dahdi_debug.h | 3 | ||||
-rw-r--r-- | drivers/dahdi/xpp/xpp_dahdi.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/xpp/xproto.h | 2 |
11 files changed, 81 insertions, 47 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index c518338..bb92967 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -189,7 +189,9 @@ static int deftaps = 64; 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 @@ enum dahdi_txstate { 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 @@ static void set_txtone(struct dahdi_chan *ss, int fac, int init_v2, int init_v3) 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) */ +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 - { 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 */ - } ; + }, { + .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 @@ who cares what the sig bits are as long as they are stable */ 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; diff --git a/drivers/dahdi/pciradio.c b/drivers/dahdi/pciradio.c index c3eee66..03ff4a8 100644 --- a/drivers/dahdi/pciradio.c +++ b/drivers/dahdi/pciradio.c @@ -1441,7 +1441,7 @@ static int pciradio_close(struct dahdi_chan *chan) 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; diff --git a/drivers/dahdi/wcfxo.c b/drivers/dahdi/wcfxo.c index 9d93784..466b9e0 100644 --- a/drivers/dahdi/wcfxo.c +++ b/drivers/dahdi/wcfxo.c @@ -591,7 +591,7 @@ static int wcfxo_close(struct dahdi_chan *chan) 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; diff --git a/drivers/dahdi/wctdm.c b/drivers/dahdi/wctdm.c index b575b98..ad2cbb1 100644 --- a/drivers/dahdi/wctdm.c +++ b/drivers/dahdi/wctdm.c @@ -1945,7 +1945,7 @@ static int wctdm_close(struct dahdi_chan *chan) 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; diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index a2bca60..b827f95 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -2646,7 +2646,7 @@ static int wctdm_close(struct dahdi_chan *chan) 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; diff --git a/drivers/dahdi/xpp/card_fxo.c b/drivers/dahdi/xpp/card_fxo.c index 4d9dec5..b7c8154 100644 --- a/drivers/dahdi/xpp/card_fxo.c +++ b/drivers/dahdi/xpp/card_fxo.c @@ -541,7 +541,7 @@ static int FXO_card_dahdi_postregistration(xpd_t *xpd, bool on) 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; diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c index cabda03..8110fa2 100644 --- a/drivers/dahdi/xpp/card_fxs.c +++ b/drivers/dahdi/xpp/card_fxs.c @@ -635,7 +635,7 @@ static int send_ring(xpd_t *xpd, lineno_t chan, bool on) 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; diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c index 12f91da..e83044d 100644 --- a/drivers/dahdi/xpp/card_pri.c +++ b/drivers/dahdi/xpp/card_pri.c @@ -913,7 +913,7 @@ static int PRI_card_dahdi_postregistration(xpd_t *xpd, bool on) 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; diff --git a/drivers/dahdi/xpp/dahdi_debug.h b/drivers/dahdi/xpp/dahdi_debug.h index 753fa1a..a2cd242 100644 --- a/drivers/dahdi/xpp/dahdi_debug.h +++ b/drivers/dahdi/xpp/dahdi_debug.h @@ -104,13 +104,14 @@ static inline char *rxsig2str(dahdi_rxsig_t sig) 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"; } diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c index 49153bc..9c5ebd2 100644 --- a/drivers/dahdi/xpp/xpp_dahdi.c +++ b/drivers/dahdi/xpp/xpp_dahdi.c @@ -770,7 +770,7 @@ int xpp_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long arg) 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; diff --git a/drivers/dahdi/xpp/xproto.h b/drivers/dahdi/xpp/xproto.h index 9a0726e..c58f36d 100644 --- a/drivers/dahdi/xpp/xproto.h +++ b/drivers/dahdi/xpp/xproto.h @@ -225,7 +225,7 @@ struct xops { 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); |