summaryrefslogtreecommitdiff
path: root/xpp/card_global.c
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/card_global.c
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/card_global.c')
-rw-r--r--xpp/card_global.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/xpp/card_global.c b/xpp/card_global.c
index 0f81f2c..dda4480 100644
--- a/xpp/card_global.c
+++ b/xpp/card_global.c
@@ -62,13 +62,10 @@ static void global_packet_dump(xpacket_t *pack);
byte *pcm;
byte *start_pcm;
int i;
- extern ulong pcm_gen;
BUG_ON(!xbus);
BUG_ON(!xpd);
- lines &= (xpd->enabled_chans | ~xpd->no_pcm);
- if(pcm_gen != 0)
- return 0;
+ lines &= ~xpd->no_pcm;
// if(lines == 0)
// return 0;
@@ -117,32 +114,44 @@ static void global_packet_dump(xpacket_t *pack);
/*---------------- GLOBAL: Astribank Reply Handlers -----------------------*/
+HANDLER_DEF(GLOBAL, NULL_REPLY)
+{
+ DBG("got len=%d\n", pack->datalen);
+ return 0;
+}
+
HANDLER_DEF(GLOBAL, DEV_DESC)
{
byte rev = RPACKET_FIELD(pack, GLOBAL, DEV_DESC, rev);
byte type = RPACKET_FIELD(pack, GLOBAL, DEV_DESC, type);
xpp_line_t line_status = RPACKET_FIELD(pack, GLOBAL, DEV_DESC, line_status);
- int xpd_num = XPD_NUM(pack->content.addr);
+ xpd_addr_t xpd_addr = RPACKET_FIELD(pack, GLOBAL, DEV_DESC, addr);
struct card_desc_struct *card_desc;
+ unsigned long flags;
- DBG("xpd=%d type=%d rev=%d line_status=0x%04X\n",
- xpd_num, type, rev, line_status);
+ BUG_ON(!xbus);
if((card_desc = kmalloc(sizeof(struct card_desc_struct), GFP_ATOMIC)) == NULL) {
ERR("%s: Card description allocation failed.\n", __FUNCTION__);
return -ENOMEM;
}
memset(card_desc, 0, sizeof(struct card_desc_struct));
card_desc->magic = CARD_DESC_MAGIC;
+ INIT_LIST_HEAD(&card_desc->card_list);
card_desc->xbus = xbus;
card_desc->type = type;
card_desc->rev = rev;
- card_desc->xpd_num = xpd_num;
- INIT_WORK(&card_desc->work, card_detected, card_desc);
- DBG("Queueing xpp_worker for xpd %d\n", xpd_num);
- if(!queue_work(xpp_worker, &card_desc->work)) {
- ERR("Failed to queue card description work\n");
- return -EINVAL;
- }
+ card_desc->xpd_addr = xpd_addr;
+ spin_lock_irqsave(&xbus->lock, flags);
+ DBG("xpd=%d-%d type=%d rev=%d line_status=0x%04X\n",
+ xpd_addr.unit, xpd_addr.subunit, type, rev, line_status);
+ if(type == XPD_TYPE_NOMODULE)
+ XBUS_COUNTER(xbus, DEV_DESC_EMPTY)++;
+ else
+ XBUS_COUNTER(xbus, DEV_DESC_FULL)++;
+ atomic_inc(&xbus->count_poll_answers);
+ wake_up(&xbus->wait_for_polls);
+ list_add_tail(&card_desc->card_list, &xbus->poll_results);
+ spin_unlock_irqrestore(&xbus->lock, flags);
return 0;
}
@@ -156,6 +165,7 @@ HANDLER_DEF(GLOBAL, PCM_READ)
unsigned long flags;
int i;
+ BUG_ON(!xbus);
if(!xpd) {
#if 0
int xpd_num = XPD_NUM(pack->content.addr);
@@ -199,6 +209,7 @@ HANDLER_DEF(GLOBAL, SYNC_REPLY)
byte mask = RPACKET_FIELD(pack, GLOBAL, SYNC_REPLY, mask);
bool setit = mask & 0x01;
+ BUG_ON(!xbus);
if(!xpd) {
int xpd_num = XPD_NUM(pack->content.addr);
NOTICE("%s: received %s for non-existing xpd: %d\n", __FUNCTION__, cmd->name, xpd_num);
@@ -215,6 +226,7 @@ HANDLER_DEF(GLOBAL, SYNC_REPLY)
xproto_table_t PROTO_TABLE(GLOBAL) = {
.entries = {
/* Card Opcode */
+ XENTRY( GLOBAL, NULL_REPLY ),
XENTRY( GLOBAL, DEV_DESC ),
XENTRY( GLOBAL, PCM_READ ),
XENTRY( GLOBAL, SYNC_REPLY ),