xpp: PRI/BRI: fix channels opening/closing:

* If a DAHDI_AUDIO_NOTIFY is issued, offhook the channel
   (added to BRI).

 * If D-channel is closed, onhook all channels (added to PRI)

 * If a clear channel is closed and the D-Channel is not
   open (e.g: with patgen/pattest), onhook this channel
   (added to both BRI and PRI)

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10476 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
Oron Peled
2012-03-15 12:51:22 +00:00
committed by Tzafrir Cohen
parent 40d3c42686
commit bb63d03bba
2 changed files with 82 additions and 8 deletions

View File

@@ -200,6 +200,7 @@ struct BRI_priv_data {
struct proc_dir_entry *bri_info;
su_rd_sta_t state_register;
bool initialized;
bool dchan_is_open;
int t1; /* timer 1 for NT deactivation */
int t3; /* timer 3 for TE activation */
ulong l1_flags;
@@ -736,6 +737,19 @@ static int BRI_card_remove(xbus_t *xbus, xpd_t *xpd)
return 0;
}
#ifdef DAHDI_AUDIO_NOTIFY
static int bri_audio_notify(struct dahdi_chan *chan, int on)
{
xpd_t *xpd = chan->pvt;
int pos = chan->chanpos - 1;
BUG_ON(!xpd);
LINE_DBG(SIGNAL, xpd, pos, "BRI-AUDIO: %s\n", (on) ? "on" : "off");
mark_offhook(xpd, pos, on);
return 0;
}
#endif
static const struct dahdi_span_ops BRI_span_ops = {
.owner = THIS_MODULE,
.spanconfig = bri_spanconfig,
@@ -757,6 +771,10 @@ static const struct dahdi_span_ops BRI_span_ops = {
#ifdef CONFIG_DAHDI_WATCHDOG
.watchdog = xpp_watchdog,
#endif
#ifdef DAHDI_AUDIO_NOTIFY
.audio_notify = bri_audio_notify,
#endif
};
static int BRI_card_dahdi_preregistration(xpd_t *xpd, bool on)
@@ -1021,8 +1039,12 @@ static int BRI_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd,
static int BRI_card_open(xpd_t *xpd, lineno_t pos)
{
struct BRI_priv_data *priv;
BUG_ON(!xpd);
priv = xpd->priv;
if (pos == 2) {
priv->dchan_is_open = 1;
LINE_DBG(SIGNAL, xpd, pos, "OFFHOOK the whole span\n");
BIT_SET(PHONEDEV(xpd).offhook_state, 0);
BIT_SET(PHONEDEV(xpd).offhook_state, 1);
@@ -1034,6 +1056,9 @@ static int BRI_card_open(xpd_t *xpd, lineno_t pos)
static int BRI_card_close(xpd_t *xpd, lineno_t pos)
{
struct BRI_priv_data *priv;
priv = xpd->priv;
/* Clear D-Channel pending data */
if (pos == 2) {
LINE_DBG(SIGNAL, xpd, pos, "ONHOOK the whole span\n");
@@ -1041,7 +1066,9 @@ static int BRI_card_close(xpd_t *xpd, lineno_t pos)
BIT_CLR(PHONEDEV(xpd).offhook_state, 1);
BIT_CLR(PHONEDEV(xpd).offhook_state, 2);
CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
}
priv->dchan_is_open = 0;
} else if (!priv->dchan_is_open)
mark_offhook(xpd, pos, 0); /* e.g: patgen/pattest */
return 0;
}

View File

@@ -75,6 +75,7 @@ static bool is_sigtype_dchan(int sigtype)
/*---------------- PRI Protocol Commands ----------------------------------*/
static void dchan_state(xpd_t *xpd, bool up);
static bool pri_packet_is_valid(xpacket_t *pack);
static void pri_packet_dump(const char *msg, xpacket_t *pack);
static int pri_startup(struct file *file, struct dahdi_span *span);
@@ -336,6 +337,7 @@ struct PRI_priv_data {
int deflaw;
unsigned int dchan_num;
bool initialized;
bool dchan_is_open;
int is_cas;
unsigned int chanconfig_dchan;
@@ -1086,6 +1088,56 @@ static int pri_set_spantype(struct dahdi_span *span, const char *spantype)
return set_pri_proto(xpd, set_proto);
}
static int PRI_card_open(xpd_t *xpd, lineno_t pos)
{
struct PRI_priv_data *priv;
int d;
/*
* DAHDI without AUDIO_NOTIFY.
* Need to offhook all channels when D-Chan is up
*/
priv = xpd->priv;
d = PRI_DCHAN_IDX(priv);
BUG_ON(!xpd);
if (pos == d) {
#ifndef DAHDI_AUDIO_NOTIFY
int i;
LINE_DBG(SIGNAL, xpd, pos, "OFFHOOK the whole span\n");
for_each_line(xpd, i) {
if (i != d)
BIT_SET(PHONEDEV(xpd).offhook_state, i);
}
CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
#endif
priv->dchan_is_open = 1;
}
return 0;
}
static int PRI_card_close(xpd_t *xpd, lineno_t pos)
{
struct PRI_priv_data *priv;
int d, i;
priv = xpd->priv;
d = PRI_DCHAN_IDX(priv);
BUG_ON(!xpd);
if (pos == d) {
LINE_DBG(SIGNAL, xpd, pos, "OFFHOOK the whole span\n");
for_each_line(xpd, i) {
if (i != d)
BIT_CLR(PHONEDEV(xpd).offhook_state, i);
}
CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
dchan_state(xpd, 0);
priv->dchan_is_open = 0;
} else if (!priv->dchan_is_open)
mark_offhook(xpd, pos, 0); /* e.g: patgen/pattest */
return 0;
}
/*
* Called only for 'span' keyword in /etc/dahdi/system.conf
*/
@@ -1244,6 +1296,7 @@ static int PRI_card_init(xbus_t *xbus, xpd_t *xpd)
DO_LED(xpd, ret, PRI_LED_OFF);
}
priv->initialized = 1;
priv->dchan_is_open = 0;
return 0;
err:
XPD_ERR(xpd, "Failed initializing registers (%d)\n", ret);
@@ -1540,13 +1593,6 @@ static int PRI_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd,
return 0;
}
static int PRI_card_close(xpd_t *xpd, lineno_t pos)
{
//struct dahdi_chan *chan = XPD_CHAN(xpd, pos);
dchan_state(xpd, 0);
return 0;
}
/*
* Called only for 'span' keyword in /etc/dahdi/system.conf
*/
@@ -2254,6 +2300,7 @@ static const struct phoneops pri_phoneops = {
.echocancel_setmask = PRI_echocancel_setmask,
.card_timing_priority = PRI_timing_priority,
.card_ioctl = PRI_card_ioctl,
.card_open = PRI_card_open,
.card_close = PRI_card_close,
.card_state = PRI_card_state,
};