[dahdi-commits] tzafrir: linux/trunk r10476 - /linux/trunk/drivers/dahdi/xpp/
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Thu Mar 15 07:51:26 CDT 2012
Author: tzafrir
Date: Thu Mar 15 07:51:22 2012
New Revision: 10476
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10476
Log:
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 at xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Modified:
linux/trunk/drivers/dahdi/xpp/card_bri.c
linux/trunk/drivers/dahdi/xpp/card_pri.c
Modified: linux/trunk/drivers/dahdi/xpp/card_bri.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/card_bri.c?view=diff&rev=10476&r1=10475&r2=10476
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_bri.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_bri.c Thu Mar 15 07:51:22 2012
@@ -200,6 +200,7 @@
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;
@@ -735,6 +736,19 @@
bri_proc_remove(xbus, 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,
@@ -756,6 +770,10 @@
#endif
#ifdef CONFIG_DAHDI_WATCHDOG
.watchdog = xpp_watchdog,
+#endif
+
+#ifdef DAHDI_AUDIO_NOTIFY
+ .audio_notify = bri_audio_notify,
#endif
};
@@ -1021,8 +1039,12 @@
static int BRI_card_open(xpd_t *xpd, lineno_t pos)
{
- BUG_ON(!xpd);
+ 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_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 @@
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;
}
Modified: linux/trunk/drivers/dahdi/xpp/card_pri.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/card_pri.c?view=diff&rev=10476&r1=10475&r2=10476
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_pri.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_pri.c Thu Mar 15 07:51:22 2012
@@ -75,6 +75,7 @@
/*---------------- 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 @@
int deflaw;
unsigned int dchan_num;
bool initialized;
+ bool dchan_is_open;
int is_cas;
unsigned int chanconfig_dchan;
@@ -1086,6 +1088,56 @@
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 @@
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 @@
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 @@
.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,
};
More information about the dahdi-commits
mailing list