summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zaptel-base.c51
-rw-r--r--zaptel.h92
2 files changed, 102 insertions, 41 deletions
diff --git a/zaptel-base.c b/zaptel-base.c
index 1e9f707..7f48105 100644
--- a/zaptel-base.c
+++ b/zaptel-base.c
@@ -142,6 +142,7 @@ EXPORT_SYMBOL(zt_hdlc_abort);
EXPORT_SYMBOL(zt_hdlc_finish);
EXPORT_SYMBOL(zt_hdlc_getbuf);
EXPORT_SYMBOL(zt_hdlc_putbuf);
+EXPORT_SYMBOL(zt_alarm_channel);
#ifdef CONFIG_PROC_FS
static struct proc_dir_entry *proc_entries[ZT_MAX_SPANS];
@@ -2872,9 +2873,20 @@ static int zt_release(struct inode *inode, struct file *file)
}
#endif
+
+void zt_alarm_channel(struct zt_chan *chan, int alarms)
+{
+ if (debug)
+ printk(KERN_DEBUG "%s: Channel %s, alarms: %x, current: %x\n",
+ __FUNCTION__, chan->name, alarms, chan->chan_alarms);
+ if (chan->chan_alarms != alarms) {
+ chan->chan_alarms = alarms;
+ zt_qevent_lock(chan, alarms ? ZT_EVENT_ALARM : ZT_EVENT_NOALARM);
+ }
+}
+
void zt_alarm_notify(struct zt_span *span)
{
- int j;
int x;
span->alarms &= ~ZT_ALARM_LOOPBACK;
@@ -2886,13 +2898,9 @@ void zt_alarm_notify(struct zt_span *span)
as ((!a) != (!b)) */
/* if change in general state */
if ((!span->alarms) != (!span->lastalarms)) {
- if (span->alarms)
- j = ZT_EVENT_ALARM;
- else
- j = ZT_EVENT_NOALARM;
span->lastalarms = span->alarms;
- for (x=0;x < span->channels;x++)
- zt_qevent_lock(&span->chans[x], j);
+ for (x = 0; x < span->channels; x++)
+ zt_alarm_channel(&span->chans[x], span->alarms);
/* Switch to other master if current master in alarm */
for (x=1; x<maxspans; x++) {
if (spans[x] && !spans[x]->alarms && (spans[x]->flags & ZT_FLAG_RUNNING)) {
@@ -2991,8 +2999,12 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c
size_t size_to_copy;
switch(cmd) {
- case ZT_GET_PARAMS: /* get channel timing parameters */
- if (copy_from_user(&stack.param,(struct zt_params *)data,sizeof(stack.param)))
+ /* get channel parameters */
+ case ZT_GET_PARAMS_V1:
+ case ZT_GET_PARAMS:
+ size_to_copy = (cmd == ZT_GET_PARAMS_V1) ? sizeof(struct zt_params_v1) :
+ sizeof(struct zt_params);
+ if (copy_from_user(&stack.param, (struct zt_params *) data, size_to_copy))
return -EFAULT;
/* check to see if the caller wants to receive our master channel number */
@@ -3050,6 +3062,7 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c
stack.param.rxflashtime = chan->rxflashtime;
stack.param.debouncetime = chan->debouncetime;
stack.param.channo = chan->channo;
+ stack.param.chan_alarms = chan->chan_alarms;
/* if requested, put the master channel number in the top 16 bits of the result */
if (return_master)
@@ -3068,12 +3081,26 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c
stack.param.curlaw = ZT_LAW_ALAW;
else
stack.param.curlaw = ZT_LAW_MULAW;
- if (copy_to_user((struct zt_params *)data,&stack.param,sizeof(stack.param)))
+
+ if (debug)
+ printk(KERN_DEBUG "%s: ZT_GET_PARAMS_V1, Channel %s.\n",
+ __FUNCTION__, chan->name);
+ if (copy_to_user((struct zt_params *) data, &stack.param, size_to_copy))
return -EFAULT;
+
break;
- case ZT_SET_PARAMS: /* set channel timing stack.paramters */
- if (copy_from_user(&stack.param,(struct zt_params *)data,sizeof(stack.param)))
+ /* set channel parameters */
+ case ZT_SET_PARAMS_V1:
+ case ZT_SET_PARAMS:
+ /* The difference between zt_params and zt_params_v1 is just the
+ * last field, which is read-only anyway. Thus we just read the
+ * size of the older struct.
+ */
+ if (copy_from_user(&stack.param, (struct zt_params *) data, sizeof(struct zt_params_v1)))
return -EFAULT;
+
+ stack.param.chan_alarms = 0; /* be explicit about the above */
+
/* Pick the right channo's */
if (!stack.param.channo || unit) {
stack.param.channo = unit;
diff --git a/zaptel.h b/zaptel.h
index 7a059c6..02e8a4e 100644
--- a/zaptel.h
+++ b/zaptel.h
@@ -185,32 +185,61 @@
#define ZT_SPANINFO_HAS_LINECONFIG
#define ZT_SPANINFO_HAS_LBONAME
+struct zt_params_v1
+{
+ int channo; /* Channel number */
+ int spanno; /* Span itself */
+ int chanpos; /* Channel number in span */
+ int sigtype; /* read-only */
+ int sigcap; /* read-only */
+ int rxisoffhook; /* read-only */
+ int rxbits; /* read-only */
+ int txbits; /* read-only */
+ int txhooksig; /* read-only */
+ int rxhooksig; /* read-only */
+ int curlaw; /* read-only -- one of ZT_LAW_MULAW or ZT_LAW_ALAW */
+ int idlebits; /* read-only -- What is considered the idle state */
+ char name[40]; /* Name of channel */
+ int prewinktime;
+ int preflashtime;
+ int winktime;
+ int flashtime;
+ int starttime;
+ int rxwinktime;
+ int rxflashtime;
+ int debouncetime;
+ int pulsebreaktime;
+ int pulsemaketime;
+ int pulseaftertime;
+};
+
typedef struct zt_params
{
-int channo; /* Channel number */
-int spanno; /* Span itself */
-int chanpos; /* Channel number in span */
-int sigtype; /* read-only */
-int sigcap; /* read-only */
-int rxisoffhook; /* read-only */
-int rxbits; /* read-only */
-int txbits; /* read-only */
-int txhooksig; /* read-only */
-int rxhooksig; /* read-only */
-int curlaw; /* read-only -- one of ZT_LAW_MULAW or ZT_LAW_ALAW */
-int idlebits; /* read-only -- What is considered the idle state */
-char name[40]; /* Name of channel */
-int prewinktime;
-int preflashtime;
-int winktime;
-int flashtime;
-int starttime;
-int rxwinktime;
-int rxflashtime;
-int debouncetime;
-int pulsebreaktime;
-int pulsemaketime;
-int pulseaftertime;
+ int channo; /* Channel number */
+ int spanno; /* Span itself */
+ int chanpos; /* Channel number in span */
+ int sigtype; /* read-only */
+ int sigcap; /* read-only */
+ int rxisoffhook; /* read-only */
+ int rxbits; /* read-only */
+ int txbits; /* read-only */
+ int txhooksig; /* read-only */
+ int rxhooksig; /* read-only */
+ int curlaw; /* read-only -- one of ZT_LAW_MULAW or ZT_LAW_ALAW */
+ int idlebits; /* read-only -- What is considered the idle state */
+ char name[40]; /* Name of channel */
+ int prewinktime;
+ int preflashtime;
+ int winktime;
+ int flashtime;
+ int starttime;
+ int rxwinktime;
+ int rxflashtime;
+ int debouncetime;
+ int pulsebreaktime;
+ int pulsemaketime;
+ int pulseaftertime;
+ __u32 chan_alarms; /* alarms on this channel */
} ZT_PARAMS;
struct zt_spaninfo_v1 {
@@ -420,11 +449,13 @@ struct zt_hwgain{
/*
* Get channel parameters
*/
+#define ZT_GET_PARAMS_V1 _IOR (ZT_CODE, 5, struct zt_params_v1)
#define ZT_GET_PARAMS _IOR (ZT_CODE, 5, struct zt_params)
/*
* Get channel parameters
*/
+#define ZT_SET_PARAMS_V1 _IOW (ZT_CODE, 6, struct zt_params_v1)
#define ZT_SET_PARAMS _IOW (ZT_CODE, 6, struct zt_params)
/*
@@ -1264,10 +1295,10 @@ struct zt_chan {
struct file *file; /* File structure */
- struct zt_span *span; /* Span we're a member of */
- int sig; /* Signalling */
- int sigcap; /* Capability for signalling */
-
+ struct zt_span *span; /* Span we're a member of */
+ int sig; /* Signalling */
+ int sigcap; /* Capability for signalling */
+ __u32 chan_alarms; /* alarms status */
/* Used only by zaptel -- NO DRIVER SERVICEABLE PARTS BELOW */
/* Buffer declarations */
@@ -1709,7 +1740,10 @@ void zt_qevent_nolock(struct zt_chan *chan, int event);
/* Queue an event on a channel, locking it first */
void zt_qevent_lock(struct zt_chan *chan, int event);
-/* Notify a change possible change in alarm status */
+/* Notify a change possible change in alarm status on a channel */
+void zt_alarm_channel(struct zt_chan *chan, int alarms);
+
+/* Notify a change possible change in alarm status on a span */
void zt_alarm_notify(struct zt_span *span);
/* Initialize a tone state */