summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-03-15 12:51:22 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-03-15 12:51:22 +0000
commitaeeeb37290bfd09c9705833550ee771aaead1d52 (patch)
tree1fc8d4181f869b6ecc3202718000ef83dd49496f
parente044e5ea5ac7709bdac5d84cb48173513ad04b99 (diff)
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
-rw-r--r--drivers/dahdi/xpp/card_bri.c29
-rw-r--r--drivers/dahdi/xpp/card_pri.c61
2 files changed, 82 insertions, 8 deletions
diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c
index c7d4ff1..69b8031 100644
--- a/drivers/dahdi/xpp/card_bri.c
+++ b/drivers/dahdi/xpp/card_bri.c
@@ -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;
}
diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index 8e37da9..0dbdecb 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -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,
};