diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-07-08 00:43:31 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-07-08 00:43:31 +0000 |
commit | ec6b220aa7a334ccbd0fcb41d35c66560fc78a11 (patch) | |
tree | 8ee3f2338f95b3fa67f8512adb8fe4842643c391 /xpp/xproto.h | |
parent | 4e4b79bf56f6477b65973c869e5a8936aea27864 (diff) |
xpp Release 1.1.0 :
* FPGA firmware now loaded from PC (for newer models)
* Driver for the FXO module (xpd_fxo.ko)
* Moved most userspace files to the subdirectory utils (see also next commit)
* Explicit license for firmware files
* Optionally avoid auto-registration
* Registers initializations code is done by a userspace script.
* 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/branches/1.2@1212 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/xproto.h')
-rw-r--r-- | xpp/xproto.h | 97 |
1 files changed, 51 insertions, 46 deletions
diff --git a/xpp/xproto.h b/xpp/xproto.h index a369a6b..4fcc81a 100644 --- a/xpp/xproto.h +++ b/xpp/xproto.h @@ -2,7 +2,7 @@ #define XPROTO_H /* * Written by Oron Peled <oron@actcom.co.il> - * Copyright (C) 2004-2005, Xorcom + * Copyright (C) 2004-2006, Xorcom * * All rights reserved. * @@ -26,31 +26,39 @@ #ifdef __KERNEL__ #include <linux/list.h> +#include <zaptel.h> #endif -#define XPD_TYPE(n) XPD_TYPE_ ## n #define PROTO_TABLE(n) n ## _protocol_table -typedef enum xpd_type { - XPD_TYPE(FXO) = 0x02, - XPD_TYPE(FXS) = 0x03, - XPD_TYPE(NOMODULE) = 0x0F, -} xpd_type_t; +/* + * 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; + +#define XPD_TYPE_PREFIX "xpd-type-" + +#define MODULE_ALIAS_XPD(type) \ + MODULE_ALIAS(XPD_TYPE_PREFIX __stringify(type)) -#define LINE_BITS (sizeof(xpp_line_t)*8) #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 @@ -82,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) @@ -94,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) \ } @@ -103,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) \ @@ -112,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; @@ -124,14 +133,13 @@ typedef int (*xproto_handler_t)( const xproto_entry_t *cmd, xpacket_t *pack); -const xproto_entry_t *find_xproto_entry(xpd_t *xpd, byte opcode); - -const xproto_table_t *get_xproto_table(xpd_type_t cardtype); +const xproto_table_t *xproto_get(xpd_type_t cardtype); +void xproto_put(const xproto_table_t *xtable); const xproto_entry_t *xproto_card_entry(const xproto_table_t *table, byte opcode); -const xproto_handler_t xproto_card_handler(const xproto_table_t *table, byte opcode); +xproto_handler_t xproto_card_handler(const xproto_table_t *table, byte opcode); const xproto_entry_t *xproto_global_entry(byte opcode); -const xproto_handler_t xproto_global_handler(byte opcode); +xproto_handler_t xproto_global_handler(byte opcode); #define CALL_XMETHOD(name, xbus, xpd, ...) \ (xpd)->xops->name(xbus, xpd, ## __VA_ARGS__ ) @@ -141,23 +149,25 @@ 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_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_POWER)(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, xpp_line_t hook_status); - int (*LED)(xbus_t *xbus, xpd_t *xpd, xpp_line_t lines, byte which, 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); }; -const xops_t *get_xops(xpd_type_t xpd_type); - -#undef XMETHOD - struct xproto_entry { xproto_handler_t handler; int datalen; @@ -166,6 +176,7 @@ struct xproto_entry { }; struct xproto_table { + struct module *owner; xproto_entry_t entries[255]; /* Indexed by opcode */ xops_t xops; xpd_type_t type; @@ -176,8 +187,10 @@ struct xproto_table { #include "card_global.h" #include "card_fxs.h" +#include "card_fxo.h" enum opcodes { + XPROTO_NAME(GLOBAL, NULL_REPLY) = 0xFE, XPROTO_NAME(GLOBAL, DESC_REQ) = 0x04, XPROTO_NAME(GLOBAL, DEV_DESC) = 0x05, /**/ @@ -186,21 +199,6 @@ enum opcodes { /**/ XPROTO_NAME(GLOBAL, SYNC_SOURCE) = 0x19, XPROTO_NAME(GLOBAL, SYNC_REPLY) = 0x1A, - - XPROTO_NAME(FXS, SIG_CHANGED) = 0x06, -/**/ - XPROTO_NAME(FXS, SLIC_WRITE) = 0x0F, /* Write to SLIC */ - XPROTO_NAME(FXS, CHAN_ENABLE) = 0x0F, /* Write to SLIC */ - XPROTO_NAME(FXS, CHAN_POWER) = 0x0F, /* Write to SLIC */ - XPROTO_NAME(FXS, CHAN_CID) = 0x0F, /* Write to SLIC */ - XPROTO_NAME(FXS, RING) = 0x0F, /* Write to SLIC */ - XPROTO_NAME(FXS, SETHOOK) = 0x0F, /* Write to SLIC */ - XPROTO_NAME(FXS, LED) = 0x0F, /* Write to SLIC */ - XPROTO_NAME(FXS, RELAY_OUT) = 0x0F, /* Write to SLIC */ - XPROTO_NAME(FXS, SLIC_INIT) = 0x0F, /* Write to SLIC */ - XPROTO_NAME(FXS, SLIC_QUERY) = 0x0F, /* Write to SLIC */ -/**/ - XPROTO_NAME(FXS, SLIC_REPLY) = 0x10, }; @@ -210,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); @@ -218,15 +217,21 @@ struct xpacket_raw { MEMBER(FXS, SIG_CHANGED); MEMBER(FXS, SLIC_REPLY); + MEMBER(FXS, SLIC_WRITE); + + MEMBER(FXO, SIG_CHANGED); + MEMBER(FXO, DAA_REPLY); + MEMBER(FXO, DAA_WRITE); byte data[0]; }; -} __attribute__((packed)); +} PACKED; struct xpacket { xpacket_raw_t content; - size_t datalen; + int datalen; struct list_head list; + void *packet_priv; }; void dump_packet(const char *msg, xpacket_t *packet, bool print_dbg); |