diff options
author | Noe Rubinstein <nrubinstein@proformatique.com> | 2010-12-24 15:42:56 +0100 |
---|---|---|
committer | Noe Rubinstein <nrubinstein@proformatique.com> | 2010-12-24 15:42:56 +0100 |
commit | 34424143c85035c0def14d69e1a7ddb1ddf0743b (patch) | |
tree | 42c23f38c1d1e0630c4f7c1042af037747d74663 /xhfc | |
parent | 7dc99874732a1336f62025cdfa8649b1c381b111 (diff) |
merge xhfc with xilun's changes
Diffstat (limited to 'xhfc')
-rw-r--r-- | xhfc/base.c | 133 | ||||
-rw-r--r-- | xhfc/xhfc.h | 9 |
2 files changed, 83 insertions, 59 deletions
diff --git a/xhfc/base.c b/xhfc/base.c index 30c9fd2..7bb3538 100644 --- a/xhfc/base.c +++ b/xhfc/base.c @@ -77,11 +77,6 @@ MODULE_PARM_DESC(reset_gpio, "Reset the XHFC using this GPIO"); #endif MODULE_PARM_DESC(exit_after_reset, "Exit after hard reset"); -#ifdef AUDIO -#define RX_HISTO_NB 16 -static int rx_histo[RX_HISTO_NB]; -#endif - void xhfc_waitbusy(struct xhfc *xhfc) { while (read_xhfc(xhfc, R_STATUS) & M_BUSY) @@ -603,48 +598,61 @@ irqreturn_t xhfc_interrupt(int irq, void *dev_id, struct pt_regs* ptregs) if (atomic_read(&s->hdlc_pending)) hdlc_tx_frame(s); -#ifdef AUDIO - /* Put in readchunk chunk _previously_ retrieved - * from icp soft. - * We can't update it at icp level right now, - * because it has been written by trippy monkeys - * and it would probably be a very bad idea to - * try to call it from hardirq context. - * (look at ixOsalMutexLock ... :/ ) - */ - xivo_tdm_receive(pi->tdm_port, i*2 + 0, - s->chans[0]->readchunk); - xivo_tdm_receive(pi->tdm_port, i*2 + 1, - s->chans[1]->readchunk); - - dahdi_receive(&s->span); - dahdi_transmit(&s->span); - dahdi_ec_span(&s->span); - - xivo_tdm_transmit(pi->tdm_port, i*2 + 0, - s->chans[0]->writechunk); - xivo_tdm_transmit(pi->tdm_port, i*2 + 1, - s->chans[1]->writechunk); -#endif } } -#ifdef AUDIO - xivo_tdm_tick(pi->tdm_port); -#endif - - r_su_irq = read_xhfc(xhfc, R_SU_IRQ); + r_su_irq = read_xhfc(xhfc, R_SU_IRQ); for (i = 0; i < SPANS_PER_CHIP; i++) { handle_st_timers(&xhfc->spans[i]); if (r_su_irq & (1 << i) || 2 == xhfc->ticks /* bootstrap XXX WTF*/) handle_state_change(&xhfc->spans[i]); } - } + } return IRQ_HANDLED; } +static int dbg_rxtx; +module_param(dbg_rxtx, int, 0666); +MODULE_PARM_DESC(dbg_rxtx, "number of calls to xhfc_rxtx to trace"); + +#ifdef AUDIO +/* hardirq */ +static void xhfc_rxtx(void *data) +{ + struct xhfc *xhfc = data; + int i; + for (i = 0; i < SPANS_PER_CHIP; i++) { + struct xhfc_span* s = &xhfc->spans[i]; + + if (dbg_rxtx) + printk(KERN_ERR "%d -- R0:%p W0:%p R1:%p W1:%p\n", + i, + s->_chans[0].readchunk, + s->_chans[0].writechunk, + s->_chans[1].readchunk, + s->_chans[1].writechunk); + + if ((s->span.flags & DAHDI_FLAG_RUNNING) && s->sigchan) { // XXX s->sigchan? + dahdi_receive(&s->span); + dahdi_transmit(&s->span); + dahdi_ec_span(&s->span); + } + + if (dbg_rxtx) + printk(KERN_ERR "%d -- R0:%p W0:%p R1:%p W1:%p\n", + i, + s->_chans[0].readchunk, + s->_chans[0].writechunk, + s->_chans[1].readchunk, + s->_chans[1].writechunk); + } + + if (dbg_rxtx) + --dbg_rxtx; +} +#endif /*****************************************************/ /* disable all interrupts by disabling M_GLOB_IRQ_EN */ @@ -902,7 +910,6 @@ void init_spans(struct xhfc* x) struct dahdi_span *dahdi_span; struct dahdi_chan *chan; -/* for each span on the card */ for (i = 0; i < SPANS_PER_CHIP; i++) { xhfc_span = &x->spans[i]; @@ -968,19 +975,13 @@ void release_card_irq(struct xhfc_pi * pi) free_irq(pi->irq, pi); } -static const struct pci_device_id tlp_leb_pci_tbl[] = { - { 0x8086, 0x503d, PCI_ANY_ID, PCI_ANY_ID, }, /* Intel Tolapai LEB controler */ - { } -}; -MODULE_DEVICE_TABLE(pci, tlp_leb_pci_tbl); - -static struct pci_driver xhfc_driver = { - .name = DRIVER_NAME, - .id_table = tlp_leb_pci_tbl, - .probe = xhfc_init_one, - .remove = __devexit_p(xhfc_remove_one), -// .shutdown = xhfc_shutdown, -}; +static void xhfc_shutdown(struct pci_dev *pdev) +{ + (void) pdev; +#ifdef AUDIO + xivo_tdm_shutdown(); +#endif +} /* pci.txt: called from process context */ int __devinit xhfc_init_one(struct pci_dev *pdev, @@ -990,6 +991,11 @@ int __devinit xhfc_init_one(struct pci_dev *pdev, struct xhfc_pi * pi; unsigned long base, size; int rc = -ENOMEM; +#ifdef AUDIO + int ts; + u8 **readchunk_ptrs[XIVO_TDM_TS_NUM] = { 0 }; + u8 **writechunk_ptrs[XIVO_TDM_TS_NUM] = { 0 }; +#endif if(DBG) printk(KERN_DEBUG "entering xhfc_init_one\n"); @@ -1122,7 +1128,7 @@ int __devinit xhfc_init_one(struct pci_dev *pdev, #endif for (span = 0; span < SPANS_PER_CHIP; span++) - if ((rc = dahdi_register(&pi->xhfc.spans[span].span, /*prefmaster*/ 1)) < 0) { + if ((rc = dahdi_register(&pi->xhfc.spans[span].span, /*prefmaster*/ 0)) < 0) { printk(KERN_WARNING "%s %s: couldn't register spans\n", pi->name, __func__); goto err_in_dahdi_register; } @@ -1130,9 +1136,20 @@ int __devinit xhfc_init_one(struct pci_dev *pdev, enable_interrupts(&pi->xhfc); #ifdef AUDIO + ts = 0; + for (span = 0; span < SPANS_PER_CHIP; span++) { + readchunk_ptrs[ts] = &pi->xhfc.spans[span].chans[0]->readchunk; + writechunk_ptrs[ts] = &pi->xhfc.spans[span].chans[0]->writechunk; + ts++; + readchunk_ptrs[ts] = &pi->xhfc.spans[span].chans[1]->readchunk; + writechunk_ptrs[ts] = &pi->xhfc.spans[span].chans[1]->writechunk; + ts++; + } xivo_tdm_start_chans(pi->tdm_port, - /* timeslots 0->7 */ 0xFF, - NULL); + readchunk_ptrs, + writechunk_ptrs, + xhfc_rxtx, + &pi->xhfc); #endif return 0; @@ -1198,6 +1215,20 @@ void __devexit xhfc_remove_one(struct pci_dev *pdev) printk(KERN_DEBUG "%s: bye-bye\n", __func__); } +static const struct pci_device_id tlp_leb_pci_tbl[] = { + { 0x8086, 0x503d, PCI_ANY_ID, PCI_ANY_ID, }, /* Intel Tolapai LEB controler */ + { } +}; +MODULE_DEVICE_TABLE(pci, tlp_leb_pci_tbl); + +static struct pci_driver xhfc_driver = { + .name = DRIVER_NAME, + .id_table = tlp_leb_pci_tbl, + .probe = xhfc_init_one, + .remove = __devexit_p(xhfc_remove_one), + .shutdown = xhfc_shutdown, +}; + /***************/ /* Module init */ /***************/ diff --git a/xhfc/xhfc.h b/xhfc/xhfc.h index 6b465f1..d20cb46 100644 --- a/xhfc/xhfc.h +++ b/xhfc/xhfc.h @@ -126,18 +126,15 @@ struct xhfc_span { /* Same as in DAHDI's for sameness reasons XXX which are??? */ struct dahdi_span span; + struct dahdi_chan* sigchan; atomic_t hdlc_pending; /* read and dec'd in interrupt context * inc'd in xhfc_hdlc_hard_xmit called by DAHDI * in user context */ int port; /* (physical) S/T port number */ int nt; /* 1 if the port is nt, 0 if it's TE */ - - /* Got the following from DAHDI */ u8 state, prev_state; - - struct dahdi_chan* sigchan; unsigned long activation_timer, f6_f7_transition; // timers; 0 when deactivated }; @@ -186,10 +183,6 @@ void deactivate_request(struct xhfc_span* s); void handle_state_change(struct xhfc_span* s); void handle_st_timers(struct xhfc_span* s); -int __devinit xhfc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); -void __devexit xhfc_remove_one(struct pci_dev *pdev); -void xhfc_shutdown(struct pci_dev *pdev); - extern uint debug; extern uint dbg_spanfilter; |