diff options
Diffstat (limited to 'kernel/xpp/card_fxs.c')
-rw-r--r-- | kernel/xpp/card_fxs.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/kernel/xpp/card_fxs.c b/kernel/xpp/card_fxs.c index 47688ef..b7bcdd2 100644 --- a/kernel/xpp/card_fxs.c +++ b/kernel/xpp/card_fxs.c @@ -100,6 +100,7 @@ enum fxs_state { #define REG_BATTERY_BATSL BIT(1) /* Battery Feed Select */ #define REG_LOOPCLOSURE 0x44 /* 68 - Loop Closure/Ring Trip Detect Status */ +#define REG_LOOPCLOSURE_ZERO 0xF8 /* Loop Closure zero bits. */ #define REG_LOOPCLOSURE_LCR BIT(0) /* Loop Closure Detect Indicator. */ /*---------------- FXS Protocol Commands ----------------------------------*/ @@ -376,7 +377,8 @@ err: return -EINVAL; } -static xpd_t *FXS_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table, byte subtype, int subunits, bool to_phone) +static xpd_t *FXS_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table, + byte subtype, int subunits, int subunit_ports, bool to_phone) { xpd_t *xpd = NULL; int channels; @@ -391,9 +393,9 @@ static xpd_t *FXS_card_new(xbus_t *xbus, int unit, int subunit, const xproto_tab return NULL; } if(subtype == 2) - regular_channels = min(6, CHANNELS_PERXPD); + regular_channels = min(6, subunit_ports); else - regular_channels = min(8, CHANNELS_PERXPD); + regular_channels = min(8, subunit_ports); channels = regular_channels; if(unit == 0) channels += 6; /* 2 DIGITAL OUTPUTS, 4 DIGITAL INPUTS */ @@ -569,7 +571,6 @@ static int set_vm_led_mode(xbus_t *xbus, xpd_t *xpd, int pos, bool msg_waiting) ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x15, 0xEF, 0x7B); ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x14, 0x9F, 0x00); ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x22, 0x19); - ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x4A, 0x34); ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x30, 0xE0); ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x31, 0x01); ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x32, 0xF0); @@ -578,11 +579,12 @@ static int set_vm_led_mode(xbus_t *xbus, xpd_t *xpd, int pos, bool msg_waiting) } else { /* A write to register 0x40 will now turn on/off the ringer */ LINE_DBG(SIGNAL, xpd, pos, "RINGER\n"); + ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x16, 0x00, 0x00); - ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x15, 0x60, 0x01); - ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x14, 0xF0, 0x7E); + ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x15, 0x77, 0x01); + ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x14, 0xFD, 0x7E); + ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x22, 0x00); - ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x4A, 0x34); ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x30, 0x00); ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x31, 0x00); ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x32, 0x00); @@ -873,7 +875,11 @@ static int FXS_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a if (get_user(val, (int __user *)arg)) return -EFAULT; if(!vmwi_ioctl) { - LINE_NOTICE(xpd, pos, "Got ZT_VMWI notification but vmwi_ioctl parameter is off. Ignoring.\n"); + static bool notified = 0; + + if(!notified++) + LINE_NOTICE(xpd, pos, + "Got ZT_VMWI notification but vmwi_ioctl parameter is off. Ignoring.\n"); return 0; } /* Digital inputs/outputs don't have VM leds */ @@ -1309,11 +1315,17 @@ static int FXS_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info) xpp_line_t mask = BIT(info->portnum); xpp_line_t offhook; - offhook = (val & REG_LOOPCLOSURE_LCR) ? mask : 0; - LINE_DBG(SIGNAL, xpd, info->portnum, - "REG_LOOPCLOSURE: dataL=0x%X (offhook=0x%X mask=0x%X\n", - val, offhook, mask); - process_hookstate(xpd, offhook, mask); + /* + * Validate reply. Non-existing/disabled ports + * will reply with 0xFF. Ignore these. + */ + if((val & REG_LOOPCLOSURE_ZERO) == 0) { + offhook = (val & REG_LOOPCLOSURE_LCR) ? mask : 0; + LINE_DBG(SIGNAL, xpd, info->portnum, + "REG_LOOPCLOSURE: dataL=0x%X (offhook=0x%X mask=0x%X\n", + val, offhook, mask); + process_hookstate(xpd, offhook, mask); + } } else { #if 0 XPD_NOTICE(xpd, "Spurious register reply(ignored): %s reg_num=0x%X, dataL=0x%X dataH=0x%X\n", |