From acb7444dd7e5b951169967232fa3a02c949b51a7 Mon Sep 17 00:00:00 2001 From: tzafrir Date: Sat, 9 Sep 2006 15:24:12 +0000 Subject: Latest xpp driver. Backported from trunk (r1455, Xorcom r2157) git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@1457 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- xpp/card_fxs.c | 126 ++++++--------------------------------------------------- 1 file changed, 13 insertions(+), 113 deletions(-) (limited to 'xpp/card_fxs.c') diff --git a/xpp/card_fxs.c b/xpp/card_fxs.c index 094ed71..9aaef63 100644 --- a/xpp/card_fxs.c +++ b/xpp/card_fxs.c @@ -77,7 +77,6 @@ static int SLIC_DIRECT_REQUEST(xbus_t *xbus, xpd_t *xpd, xpp_line_t lines, byte static /* 0x0F */ DECLARE_CMD(FXS, CHAN_ENABLE, xpp_line_t lines, bool on); static /* 0x0F */ DECLARE_CMD(FXS, CHAN_CID, int pos); static /* 0x0F */ DECLARE_CMD(FXS, RING, int pos, bool on); -static /* 0x0F */ DECLARE_CMD(FXS, SETHOOK, int pos, bool offhook); static /* 0x0F */ DECLARE_CMD(FXS, RELAY_OUT, byte which, bool on); static /* 0x0F */ DECLARE_CMD(FXS, SLIC_QUERY, int pos, byte reg_num); @@ -326,17 +325,8 @@ static int FXS_card_init(xbus_t *xbus, xpd_t *xpd) /* * Setup ring timers */ -#ifdef WITH_RBS /* Software controled ringing (for CID) */ ret = SLIC_DIRECT_REQUEST(xbus, xpd, ALL_LINES, 0x22, 0x00); /* Ringing Oscilator Control */ -#else - /* Hardware controled ringing (no CID) */ - ret += SLIC_DIRECT_REQUEST(xbus, xpd, ALL_LINES, 0x30, 0x80); /* Active timer low byte */ - ret += SLIC_DIRECT_REQUEST(xbus, xpd, ALL_LINES, 0x31, 0x3E); /* Active timer high byte */ - ret += SLIC_DIRECT_REQUEST(xbus, xpd, ALL_LINES, 0x32, 0x80); /* Inactive timer low byte */ - ret += SLIC_DIRECT_REQUEST(xbus, xpd, ALL_LINES, 0x33, 0x3E); /* Inactive timer high byte */ - ret += SLIC_DIRECT_REQUEST(xbus, xpd, ALL_LINES, 0x22, 0x18); /* Ringing Oscilator Control */ -#endif if(ret < 0) goto err; DBG("%s/%s: done\n", xbus->busname, xpd->xpdname); @@ -418,7 +408,6 @@ static int FXS_card_zaptel_postregistration(xpd_t *xpd, bool on) return 0; } -#ifdef WITH_RBS int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, zt_txsig_t txsig) { int ret = 0; @@ -490,74 +479,6 @@ int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, zt_txsig_t txsig) return ret; } -#else -int FXS_card_sethook(xbus_t *xbus, xpd_t *xpd, int pos, int hookstate) -{ - int ret = 0; - - DBG("%s/%s/%d: %s\n", xbus->busname, xpd->xpdname, pos, hookstate2str(hookstate)); - switch(hookstate) { - /* On-hook, off-hook: The PBX is playing a phone on an FXO line. - * Can be ignored for an FXS line - */ - case ZT_ONHOOK: - if(IS_SET(xpd->digital_inputs, pos)) { - NOTICE("%s: Trying to ONHOOK a digital input channel %d. Ignoring\n", __FUNCTION__, pos); - ret = -EINVAL; - break; - } - if(IS_SET(xpd->digital_outputs, pos)) { - DBG("%s/%s/%d: digital output OFF\n", xbus->busname, xpd->xpdname, pos); - ret = CALL_XMETHOD(RELAY_OUT, xpd->xbus, xpd, pos-8, 0); - break; - } - xpd->ringing[pos] = 0; - DBG("%s/%s/%d: stop ringing\n", xbus->busname, xpd->xpdname, pos); -#if 1 // FIXME: Not needed -- verify - ret = CALL_XMETHOD(RING, xbus, xpd, pos, 0); // RING off -#endif - if(ret) { - DBG("ZT_ONHOOK(stop ring) Failed: ret=0x%02X\n", ret); - break; - } - break; - case ZT_START: - DBG("%s/%s/%d: fall through ZT_OFFHOOK\n", xbus->busname, xpd->xpdname, pos); - // Fall through - case ZT_OFFHOOK: - DBG("%s/%s/%d: ZT_OFFHOOK (ignoring for PHONES)\n", xbus->busname, xpd->xpdname, pos); - break; - case ZT_WINK: - WARN("No code yet\n"); - break; - case ZT_FLASH: - WARN("No code yet\n"); - break; - case ZT_RING: - DBG("%s/%s/%d: ZT_RING: %d\n", xbus->busname, xpd->xpdname, pos, xpd->ringing[pos]); - if(IS_SET(xpd->digital_inputs, pos)) { - NOTICE("%s: Trying to RING a digital input channel %d. Ignoring\n", __FUNCTION__, pos); - return -EINVAL; - } - if(IS_SET(xpd->digital_outputs, pos)) { - DBG("%s/%s/%d: digital output ON\n", xbus->busname, xpd->xpdname, pos); - ret = CALL_XMETHOD(RELAY_OUT, xpd->xbus, xpd, pos-8, 1); - return ret; - } - xpd->ringing[pos] = 1; - ret = CALL_XMETHOD(RING, xbus, xpd, pos, 1); // RING on - if(ret) { - DBG("ZT_RING Failed: ret=0x%02X\n", ret); - } - break; - case ZT_RINGOFF: - WARN("No code yet\n"); - break; - } - return ret; -} -#endif - /* * INPUT polling is done via SLIC register 0x06 (same as LEDS): * 7 6 5 4 3 2 1 0 @@ -698,12 +619,6 @@ static /* 0x0F */ HOSTCMD(FXS, RING, int pos, bool on) return ret; } -static /* 0x0F */ HOSTCMD(FXS, SETHOOK, int pos, bool offhook) -{ - BUG(); // Should never be called - return 0; -} - static /* 0x0F */ HOSTCMD(FXS, RELAY_OUT, byte which, bool on) { int ret = 0; @@ -775,21 +690,17 @@ HANDLER_DEF(FXS, SIG_CHANGED) if(IS_SET(xpd->digital_outputs, i) || IS_SET(xpd->digital_inputs, i)) continue; if(IS_SET(sig_toggles, i)) { - struct zt_chan *chan = &xpd->span.chans[i]; - xpd->ringing[i] = 0; // No more ringing... do_chan_power(xpd->xbus, xpd, BIT(i), 0); // When not ringing, VBAT is always Low MARK_BLINK(priv,i,LED_GREEN,0); if(IS_SET(sig_status, i)) { - DBG("OFFHOOK: channo=%d\n", chan->channo); + DBG("%s/%s/%d: OFFHOOK\n", xbus->busname, xpd->xpdname, i); MARK_LED(priv,i,LED_GREEN,LED_ON); - BIT_SET(xpd->hookstate, i); - zt_hooksig(chan, ZT_RXSIG_OFFHOOK); + update_line_status(xpd, i, 1); } else { - DBG("ONHOOK channo=%d\n", chan->channo); + DBG("%s/%s/%d: ONHOOK\n", xbus->busname, xpd->xpdname, i); MARK_LED(priv,i,LED_GREEN,LED_OFF); - BIT_CLR(xpd->hookstate, i); - zt_hooksig(chan, ZT_RXSIG_ONHOOK); + update_line_status(xpd, i, 0); } } } @@ -824,27 +735,22 @@ HANDLER_DEF(FXS, SLIC_REPLY) for(i = 0; i < ARRAY_SIZE(input_channels); i++) { int channo = input_channels[i]; int newchanno; - struct zt_chan *chan; if(IS_SET(lines, channo)) { newchanno = LINES_REGULAR + LINES_DIGI_OUT + i; BIT_CLR(lines, channo); BIT_SET(lines, newchanno); - chan = &xpd->span.chans[newchanno]; xpd->ringing[newchanno] = 0; // Stop ringing. No leds for digital inputs. - if(offhook && !IS_SET(xpd->hookstate, newchanno)) { // OFFHOOK - DBG("OFFHOOK: channo=%d\n", chan->channo); - BIT_SET(xpd->hookstate, newchanno); - zt_hooksig(chan, ZT_RXSIG_OFFHOOK); - } else if(!offhook && IS_SET(xpd->hookstate, newchanno)) { // ONHOOK - DBG("ONHOOK channo=%d\n", chan->channo); - BIT_CLR(xpd->hookstate, newchanno); - zt_hooksig(chan, ZT_RXSIG_ONHOOK); + if(offhook && !IS_SET(xpd->offhook, newchanno)) { // OFFHOOK + DBG("%s/%s/%d: OFFHOOK\n", xbus->busname, xpd->xpdname, newchanno); + update_line_status(xpd, newchanno, 1); + } else if(!offhook && IS_SET(xpd->offhook, newchanno)) { // ONHOOK + DBG("%s/%s/%d: ONHOOK\n", xbus->busname, xpd->xpdname, newchanno); + update_line_status(xpd, newchanno, 0); } } } } - /* Update /proc info only if reply relate to the last slic read request */ if(priv->requested_reply.indirect == info->indirect && priv->requested_reply.reg_num == info->reg_num) { @@ -869,15 +775,10 @@ xproto_table_t PROTO_TABLE(FXS) = { .card_remove = FXS_card_remove, .card_zaptel_preregistration = FXS_card_zaptel_preregistration, .card_zaptel_postregistration = FXS_card_zaptel_postregistration, -#ifdef WITH_RBS .card_hooksig = FXS_card_hooksig, -#else - .card_sethook = FXS_card_sethook, -#endif .card_tick = FXS_card_tick, .RING = XPROTO_CALLER(FXS, RING), - .SETHOOK = XPROTO_CALLER(FXS, SETHOOK), .RELAY_OUT = XPROTO_CALLER(FXS, RELAY_OUT), .CHAN_ENABLE = XPROTO_CALLER(FXS, CHAN_ENABLE), .CHAN_CID = XPROTO_CALLER(FXS, CHAN_CID), @@ -1088,8 +989,7 @@ static int process_slic_cmdline(xpd_t *xpd, char *cmdline) static int proc_xpd_slic_write(struct file *file, const char __user *buffer, unsigned long count, void *data) { xpd_t *xpd = data; - const int LINE_LEN = 500; - char buf[LINE_LEN]; + char buf[MAX_PROC_WRITE]; char *p; int i; int ret; @@ -1097,7 +997,7 @@ static int proc_xpd_slic_write(struct file *file, const char __user *buffer, uns if(!xpd) return -ENODEV; for(i = 0; i < count; /* noop */) { - for(p = buf; p < buf + LINE_LEN; p++) { /* read a line */ + for(p = buf; p < buf + MAX_PROC_WRITE; p++) { /* read a line */ if(i >= count) break; if(get_user(*p, buffer + i)) @@ -1106,7 +1006,7 @@ static int proc_xpd_slic_write(struct file *file, const char __user *buffer, uns if(*p == '\n' || *p == '\r') /* whatever */ break; } - if(p >= buf + LINE_LEN) + if(p >= buf + MAX_PROC_WRITE) return -E2BIG; *p = '\0'; ret = process_slic_cmdline(xpd, buf); -- cgit v1.2.3