summaryrefslogtreecommitdiff
path: root/xpp/card_pri.c
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-09-14 22:29:36 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-09-14 22:29:36 +0000
commitc91b2cd29653da525d1a37cf680f4a75b2d3b208 (patch)
treef26185291a7ebb24902a2737d6e5b1fed75bb8c1 /xpp/card_pri.c
parent236601045ee0a95930414d8d5f822d9a61054aae (diff)
New xpp release (Xorcom rev 4648):
* New firmware protocol version: 2.8 . * New firmwares fix input ports offhook. * Cleanup INFO() messages during module loading. * USB: Receive queue with TASKLETS [r4600]. Controlled by rx_tasklet parameter to xpp_usb module (can be changed in runtime). * The pcm_tasklet parameter in xpp module is deprecated: - Does not actually do anything. - If set during module loading, shows an ERR() message. - Also appears in /proc/xpp/sync * FXS: Hardware DTMF detection by default, can be disabled by setting dtmf_detection=0 parameter to xpd_fxs. PCM is muted when DTMF key is pressed. * zapconf: - Can now generate users.conf compatible with asterisk-gui. - Optional command-line arguments denoting which files to generate. Possible values are 'zaptel', 'zapata' and 'users'. - Defaults to creating zaptel and zapata. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@3019 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/card_pri.c')
-rw-r--r--xpp/card_pri.c77
1 files changed, 20 insertions, 57 deletions
diff --git a/xpp/card_pri.c b/xpp/card_pri.c
index 8ac2c44..b290a93 100644
--- a/xpp/card_pri.c
+++ b/xpp/card_pri.c
@@ -174,7 +174,7 @@ struct PRI_priv_data {
enum pri_led_state ledstate[NUM_LEDS];
};
-xproto_table_t PROTO_TABLE(PRI);
+static xproto_table_t PROTO_TABLE(PRI);
DEF_RPACKET_DATA(PRI, SET_LED, /* Set one of the LED's */
struct pri_leds pri_leds;
@@ -182,7 +182,6 @@ DEF_RPACKET_DATA(PRI, SET_LED, /* Set one of the LED's */
static /* 0x33 */ DECLARE_CMD(PRI, SET_LED, enum pri_led_selectors led_sel, enum pri_led_state to_led_state);
-static /* 0x0F */ DECLARE_CMD(PRI, REGISTER_REQUEST, byte chipsel, bool writing, bool do_subreg, byte regnum, byte subreg, byte data_low, byte data_high);
#define DO_LED(xpd, which, tostate) \
CALL_PROTO(PRI, SET_LED, (xpd)->xbus, (xpd), (which), (tostate))
@@ -196,7 +195,7 @@ static int query_subunit(xpd_t *xpd, byte regnum)
xpd->addr.unit, xpd->addr.subunit,
regnum);
#endif
- return CALL_PROTO(PRI, REGISTER_REQUEST,
+ return xpp_register_request(
xpd->xbus, xpd,
0, /* chipsel */
0, /* writing */
@@ -213,7 +212,7 @@ static int write_subunit(xpd_t *xpd, byte regnum, byte val)
XPD_DBG(REGS, xpd, "(%d%d): REG=0x%02X dataL=0x%02X\n",
xpd->addr.unit, xpd->addr.subunit,
regnum, val);
- return CALL_PROTO(PRI, REGISTER_REQUEST,
+ return xpp_register_request(
xpd->xbus, xpd,
0, /* chipsel */
1, /* writing */
@@ -312,7 +311,7 @@ static int set_pri_proto(const char *msg, xpd_t *xpd, enum pri_protocol set_prot
return -EINVAL;
}
priv->pri_protocol = set_proto;
- XPD_INFO(xpd, "%s(%s): %s\n", __FUNCTION__, msg, pri_protocol_name[set_proto]);
+ XPD_DBG(SIGNAL, xpd, "%s(%s): %s\n", __FUNCTION__, msg, pri_protocol_name[set_proto]);
write_subunit(xpd, REG_FMR1, fmr1);
#ifdef JAPANEZE_SUPPORT
if(rc0)
@@ -342,7 +341,7 @@ static int set_master_mode(const char *msg, xpd_t *xpd, bool is_master_mode)
lim0 |= 0x01;
else
lim0 &= ~0x01;
- XPD_INFO(xpd, "%s(%s): %s\n", __FUNCTION__, msg, (is_master_mode) ? "MASTER" : "SLAVE");
+ XPD_DBG(SIGNAL, xpd, "%s(%s): %s\n", __FUNCTION__, msg, (is_master_mode) ? "MASTER" : "SLAVE");
write_subunit(xpd, REG_LIM0, lim0);
return 0;
}
@@ -361,7 +360,7 @@ static int set_nt(const char *msg, xpd_t *xpd, bool is_nt)
priv->is_nt = is_nt;
xpd->type_name = (is_nt) ? pri_name_nt : pri_name_te;
xpd->direction = (is_nt) ? TO_PHONE : TO_PSTN;
- XPD_INFO(xpd, "%s(%s): %s\n", __FUNCTION__, msg, (is_nt) ? "NT" : "TE");
+ XPD_DBG(SIGNAL, xpd, "%s(%s): %s\n", __FUNCTION__, msg, (is_nt) ? "NT" : "TE");
set_master_mode(msg, xpd, is_nt); /* by default set master-mode from NT/TE */
return 0;
}
@@ -384,7 +383,7 @@ static int set_localloop(const char *msg, xpd_t *xpd, bool localloop)
else
lim0 &= ~0x01;
priv->local_loopback = localloop;
- XPD_INFO(xpd, "%s(%s): %s\n", __FUNCTION__, msg, (localloop) ? "LOCALLOOP" : "NO");
+ XPD_DBG(SIGNAL, xpd, "%s(%s): %s\n", __FUNCTION__, msg, (localloop) ? "LOCALLOOP" : "NO");
write_subunit(xpd, REG_LIM0, lim0);
return 0;
}
@@ -529,11 +528,13 @@ static int PRI_card_init(xbus_t *xbus, xpd_t *xpd)
}
/* FIXME: now we need to fix channel number (E1/T1/J1) */
+#if 0
/*
* FPGA firmware limitation:
* Force HOST sync *before* sending PCM
*/
CALL_PROTO(GLOBAL, SYNC_SOURCE, xbus, NULL, SYNC_MODE_HOST, 0);
+#endif
XPD_DBG(GENERAL, xpd, "done\n");
for(ret = 0; ret < NUM_LEDS; ret++) {
DO_LED(xpd, ret, PRI_LED_ON);
@@ -614,7 +615,7 @@ static int PRI_card_zaptel_postregistration(xpd_t *xpd, bool on)
return(0);
}
-int PRI_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, zt_txsig_t txsig)
+static int PRI_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, zt_txsig_t txsig)
{
LINE_DBG(SIGNAL, xpd, pos, "%s\n", txsig2str(txsig));
return 0;
@@ -904,53 +905,20 @@ static void PRI_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
/*---------------- PRI: HOST COMMANDS -------------------------------------*/
-/* 0x0F */ HOSTCMD(PRI, REGISTER_REQUEST, byte chipsel, bool writing, bool do_subreg, byte regnum, byte subreg, byte data_low, byte data_high)
-{
- int ret = 0;
- xframe_t *xframe;
- xpacket_t *pack;
- reg_cmd_t *reg_cmd;
-
- if(!xbus) {
- DBG(GENERAL, "NO XBUS\n");
- return -EINVAL;
- }
- XFRAME_NEW(xframe, pack, xbus, PRI, REGISTER_REQUEST, xpd->xbus_idx);
- LINE_DBG(REGS, xpd, chipsel, "%c%c R%02X S%02X %02X %02X\n",
- (writing)?'W':'R',
- (do_subreg)?'S':'D',
- regnum, subreg, data_low, data_high);
- reg_cmd = &RPACKET_FIELD(pack, PRI, REGISTER_REQUEST, reg_cmd);
- reg_cmd->bytes = sizeof(*reg_cmd) - 1; // do not count the 'bytes' field
- REG_FIELD(reg_cmd, chipsel) = chipsel;
- REG_FIELD(reg_cmd, read_request) = (writing) ? 0 : 1;
- REG_FIELD(reg_cmd, do_subreg) = do_subreg;
- REG_FIELD(reg_cmd, regnum) = regnum;
- REG_FIELD(reg_cmd, subreg) = subreg;
- REG_FIELD(reg_cmd, data_low) = data_low;
- REG_FIELD(reg_cmd, data_high) = data_high;
-#if 0
- if(regnum == 0x4C)
- dump_xframe("POLL", xbus, xframe);
-#endif
- ret = send_cmd_frame(xbus, xframe);
- return ret;
-}
-
-/* 0x0F */ HOSTCMD(PRI, XPD_STATE, bool on)
+static /* 0x0F */ HOSTCMD(PRI, XPD_STATE, bool on)
{
BUG_ON(!xpd);
XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off");
return 0;
}
-/* 0x0F */ HOSTCMD(PRI, RING, lineno_t chan, bool on)
+static /* 0x0F */ HOSTCMD(PRI, RING, lineno_t chan, bool on)
{
XPD_ERR(xpd, "%s: Unsupported\n", __FUNCTION__);
return -ENOSYS;
}
-/* 0x0F */ HOSTCMD(PRI, RELAY_OUT, byte which, bool on)
+static /* 0x0F */ HOSTCMD(PRI, RELAY_OUT, byte which, bool on)
{
XPD_ERR(xpd, "%s: Unsupported\n", __FUNCTION__);
return -ENOSYS;
@@ -973,7 +941,7 @@ static void PRI_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
pri_leds = &RPACKET_FIELD(pack, PRI, SET_LED, pri_leds);
pri_leds->state = to_led_state;
pri_leds->led_sel = led_sel;
- pack->datalen = RPACKET_SIZE(PRI, SET_LED);
+ XPACKET_LEN(pack) = RPACKET_SIZE(PRI, SET_LED);
ret = send_cmd_frame(xbus, xframe);
priv->ledstate[led_sel] = to_led_state;
return ret;
@@ -1011,16 +979,11 @@ static void layer1_state(xpd_t *xpd, byte subunit, byte data_low)
XPD_DBG(REGS, xpd, "subunit=%d data_low=0x%02X\n", subunit, data_low);
}
-HANDLER_DEF(PRI, REGISTER_REPLY)
+static int PRI_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
{
- reg_cmd_t *info = &RPACKET_FIELD(pack, PRI, REGISTER_REPLY, regcmd);
unsigned long flags;
struct PRI_priv_data *priv;
- if(!xpd) {
- notify_bad_xpd(__FUNCTION__, xbus, pack->addr, cmd->name);
- return -EPROTO;
- }
spin_lock_irqsave(&xpd->lock, flags);
priv = xpd->priv;
BUG_ON(!priv);
@@ -1050,13 +1013,12 @@ end:
return 0;
}
-xproto_table_t PROTO_TABLE(PRI) = {
+static xproto_table_t PROTO_TABLE(PRI) = {
.owner = THIS_MODULE,
.entries = {
/* Table Card Opcode */
- XENTRY( PRI, PRI, REGISTER_REPLY ),
},
- .name = "PRI_??", /* xpd->type_name is set in set_nt() */
+ .name = "PRI_xx", /* xpd->type_name is set in set_nt() */
.type = XPD_TYPE_PRI,
.xops = {
.card_new = PRI_card_new,
@@ -1069,6 +1031,7 @@ xproto_table_t PROTO_TABLE(PRI) = {
.card_pcm_fromspan = PRI_card_pcm_fromspan,
.card_pcm_tospan = PRI_card_pcm_tospan,
.card_close = PRI_card_close,
+ .card_register_reply = PRI_card_register_reply,
.RING = XPROTO_CALLER(PRI, RING),
.RELAY_OUT = XPROTO_CALLER(PRI, RELAY_OUT),
@@ -1083,7 +1046,7 @@ static bool pri_packet_is_valid(xpacket_t *pack)
const xproto_entry_t *xe_nt = NULL;
const xproto_entry_t *xe_te = NULL;
// DBG(GENERAL, "\n");
- xe_nt = xproto_card_entry(&PROTO_TABLE(PRI), pack->opcode);
+ xe_nt = xproto_card_entry(&PROTO_TABLE(PRI), XPACKET_OP(pack));
return xe_nt != NULL || xe_te != NULL;
}
@@ -1319,7 +1282,7 @@ static int handle_register_command(xpd_t *xpd, char *cmdline)
priv->requested_reply = regcmd;
if(print_dbg)
dump_reg_cmd("PRI", &regcmd, 1);
- ret = CALL_PROTO(PRI, REGISTER_REQUEST, xpd->xbus, xpd,
+ ret = xpp_register_request(xpd->xbus, xpd,
REG_FIELD(&regcmd, chipsel),
writing,
REG_FIELD(&regcmd, do_subreg),