summaryrefslogtreecommitdiff
path: root/xpp/xproto.h
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-07-06 13:47:05 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-07-06 13:47:05 +0000
commit39a1812c1ef76b6a792f00087f1e507616bbbb25 (patch)
treee50633c999779c514ef16f4a2ce7a70fc7511c9e /xpp/xproto.h
parent70ef1183eba2d2fe4f00668fd3438b7f1c842c94 (diff)
Tons of updates to the Astribank (xpp) driver:
* xpd_fxo.ko (FXO span) is now operational * Remove obsolete .inc initialization files (we use user-space init) * Added an install target to the utils dir. * Updated README.Astribank accordingly. * Using RBS signalling, as caller ID did not work well otherwise. * Better handling of USB protocol errors. * Fixed some procfs-related races. * per-card-module ioctls. * fxotune support. * opermode support (set through /etc/default/zaptel for now) * Userspace initialization script can also read registers. * Power calibration works (and implemented in perl) * some fine-tuning to the regster initialization parameters. * Leds turn on before registration and turn off after it. git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1204 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/xproto.h')
-rw-r--r--xpp/xproto.h42
1 files changed, 27 insertions, 15 deletions
diff --git a/xpp/xproto.h b/xpp/xproto.h
index 0cae398..4fcc81a 100644
--- a/xpp/xproto.h
+++ b/xpp/xproto.h
@@ -26,12 +26,18 @@
#ifdef __KERNEL__
#include <linux/list.h>
+#include <zaptel.h>
#endif
#define PROTO_TABLE(n) n ## _protocol_table
-#define XPD_TYPE_FXS 3
-#define XPD_TYPE_FXO 4
+/*
+ * The LSB of the type number signifies:
+ * 0 - TO_PSTN
+ * 1 - TO_PHONE
+ */
+#define XPD_TYPE_FXS 3 // TO_PHONE
+#define XPD_TYPE_FXO 4 // TO_PSTN
#define XPD_TYPE_NOMODULE 15
typedef byte xpd_type_t;
@@ -44,16 +50,15 @@ typedef byte xpd_type_t;
#define PCM_CHUNKSIZE (CHANNELS_PERXPD * 8) /* samples of 8 bytes */
typedef struct xpd_addr {
- byte card_id:4;
- byte bank_num:4;
-} __attribute__((packed)) xpd_addr_t;
+ byte unit:UNIT_BITS;
+ byte subunit:SUBUNIT_BITS;
+} PACKED xpd_addr_t;
bool valid_xpd_addr(const xpd_addr_t *addr);
int xpd_addr2num(const xpd_addr_t *addr);
void xpd_set_addr(xpd_addr_t *addr, int xpd_num);
#define XPD_NUM(x) xpd_addr2num(&x)
-#define XPD_ADDR_SET(x,val) xpd_set_addr(&x, val)
#define MAX_XPACKET_DATALEN 100
#define XPROTO_NAME(card,op) card ## _ ## op
@@ -85,11 +90,12 @@ void xpd_set_addr(xpd_addr_t *addr, int xpd_num);
byte opcode; \
xpd_addr_t addr; \
__VA_ARGS__ \
- } __attribute__((packed))
+ } PACKED
#define RPACKET_CAST(p,card,op) ((RPACKET_TYPE(card,op) *)p)
#define RPACKET_FIELD(p,card,op,field) (RPACKET_CAST(p,card,op)->field)
#define RPACKET_SIZE(card,op) sizeof(RPACKET_TYPE(card,op))
+#define RPACKET_DATALEN(card,op) (RPACKET_SIZE(card,op) - sizeof(xpd_addr_t) - 1)
#define PACKET_LEN(p) \
((p)->datalen + sizeof(xpd_addr_t) + 1)
@@ -97,7 +103,7 @@ void xpd_set_addr(xpd_addr_t *addr, int xpd_num);
#define XENTRY(card,op) \
[ XPROTO_NAME(card,op) ] { \
.handler = XPROTO_HANDLER(card,op), \
- .datalen = RPACKET_SIZE(card,op), \
+ .datalen = RPACKET_DATALEN(card,op), \
.name = #op, \
.table = &PROTO_TABLE(card) \
}
@@ -106,7 +112,7 @@ void xpd_set_addr(xpd_addr_t *addr, int xpd_num);
#define XPACKET_INIT(p, card, op) \
do { \
p->content.opcode = XPROTO_NAME(card,op); \
- p->datalen = RPACKET_SIZE(card,op); \
+ p->datalen = RPACKET_DATALEN(card,op); \
} while(0)
#define XPACKET_NEW(p, xbus, card, op, to) \
@@ -115,7 +121,7 @@ void xpd_set_addr(xpd_addr_t *addr, int xpd_num);
if(!p) \
return -ENOMEM; \
XPACKET_INIT(p, card, op); \
- XPD_ADDR_SET(p->content.addr, to); \
+ xpd_set_addr(&p->content.addr, to); \
} while(0);
typedef struct xproto_entry xproto_entry_t;
@@ -143,14 +149,20 @@ struct xops {
int (*card_init)(xbus_t *xbus, xpd_t *xpd);
int (*card_remove)(xbus_t *xbus, xpd_t *xpd);
int (*card_tick)(xbus_t *xbus, xpd_t *xpd);
- int (*card_zaptel_registration)(xpd_t *xpd, bool on);
+ int (*card_zaptel_preregistration)(xpd_t *xpd, bool on);
+ int (*card_zaptel_postregistration)(xpd_t *xpd, bool on);
+#ifdef WITH_RBS
+ int (*card_hooksig)(xbus_t *xbus, xpd_t *xpd, int pos, zt_txsig_t txsig);
+#else
int (*card_sethook)(xbus_t *xbus, xpd_t *xpd, int pos, int hookstate);
+#endif
+ int (*card_ioctl)(xpd_t *xpd, int pos, unsigned int cmd, unsigned long arg);
int (*SYNC_SOURCE)(xbus_t *xbus, xpd_t *xpd, bool setit, bool is_master);
int (*PCM_WRITE)(xbus_t *xbus, xpd_t *xpd, xpp_line_t hookstate, volatile byte *buf);
int (*CHAN_ENABLE)(xbus_t *xbus, xpd_t *xpd, xpp_line_t lines, bool on);
- int (*CHAN_CID)(xbus_t *xbus, xpd_t *xpd, xpp_line_t lines);
+ int (*CHAN_CID)(xbus_t *xbus, xpd_t *xpd, int pos);
int (*RING)(xbus_t *xbus, xpd_t *xpd, int pos, bool on);
int (*SETHOOK)(xbus_t *xbus, xpd_t *xpd, int pos, bool offhook);
int (*RELAY_OUT)(xbus_t *xbus, xpd_t *xpd, byte which, bool on);
@@ -178,6 +190,7 @@ struct xproto_table {
#include "card_fxo.h"
enum opcodes {
+ XPROTO_NAME(GLOBAL, NULL_REPLY) = 0xFE,
XPROTO_NAME(GLOBAL, DESC_REQ) = 0x04,
XPROTO_NAME(GLOBAL, DEV_DESC) = 0x05,
/**/
@@ -195,6 +208,7 @@ struct xpacket_raw {
byte opcode;
xpd_addr_t addr;
union {
+ MEMBER(GLOBAL, NULL_REPLY);
MEMBER(GLOBAL, DESC_REQ);
MEMBER(GLOBAL, DEV_DESC);
MEMBER(GLOBAL, PCM_WRITE);
@@ -203,17 +217,15 @@ struct xpacket_raw {
MEMBER(FXS, SIG_CHANGED);
MEMBER(FXS, SLIC_REPLY);
- MEMBER(FXS, SLIC_INIT);
MEMBER(FXS, SLIC_WRITE);
MEMBER(FXO, SIG_CHANGED);
MEMBER(FXO, DAA_REPLY);
- MEMBER(FXO, DAA_INIT);
MEMBER(FXO, DAA_WRITE);
byte data[0];
};
-} __attribute__((packed));
+} PACKED;
struct xpacket {
xpacket_raw_t content;