diff options
Diffstat (limited to 'xhfc/xhfc.h')
-rw-r--r-- | xhfc/xhfc.h | 129 |
1 files changed, 90 insertions, 39 deletions
diff --git a/xhfc/xhfc.h b/xhfc/xhfc.h index 9e119d7..410fa73 100644 --- a/xhfc/xhfc.h +++ b/xhfc/xhfc.h @@ -2,6 +2,8 @@ #define __XHFC_HWTD_H__ #include <linux/interrupt.h> +#include <linux/pci.h> +#include <dahdi/kernel.h> #include "xhfc24sucd.h" #define DRIVER_NAME "xhfc" @@ -32,15 +34,50 @@ #define XHFC_T3 2 #define XHFC_T4 3 -enum data_dir { TRANSMIT = 0; RECEIVE = 1 }; +#if (DAHDI_CHUNKSIZE != 8) +#error Sorry, the XHFC driver module does not support chunksize != 8 +#endif -#define dbg(code) do { \ - printk(KERN_DEBUG __FILE__ ":%s:%d: " #code "\n", \ - __FUNCTION__, __LINE__); code; \ - } while (0) +/* general debug messages */ +#define DEBUG_GENERAL (1 << 0) +/* emit DTMF detector messages */ +#define DEBUG_DTMF (1 << 1) //XXX not used +/* emit register read/write, but only if the kernel's DEBUG is defined */ +#define DEBUG_REGS (1 << 2) //XXX wut +/* emit file operation messages */ +#define DEBUG_FOPS (1 << 3) +#define DEBUG_ECHOCAN (1 << 4) +/* S/T state machine */ +#define DEBUG_ST_STATE (1 << 5) //XXX not used? +/* HDLC controller */ +#define DEBUG_HDLC (1 << 6) +/* alarm changes */ +#define DEBUG_ALARM (1 << 7) //XXX not used? +/* Timing related changes */ +#define DEBUG_TIMING (1 << 8) //XXX not used? + +#define DBG (debug & DEBUG_GENERAL) +#define DBG_DTMF (debug & DEBUG_DTMF) +#define DBG_REGS (debug & DEBUG_REGS) +#define DBG_FOPS (debug & DEBUG_FOPS) +#define DBG_EC (debug & DEBUG_ECHOCAN) +#define DBG_ST (debug & DEBUG_ST_STATE) +#define DBG_HDLC (debug & DEBUG_HDLC) +#define DBG_ALARM (debug & DEBUG_ALARM) +#define DBG_TIMING (debug & DEBUG_TIMING) + +#define DBG_SPANFILTER ((1 << xhfc_span->port) & dbg_spanfilter) + +#define CORRUPTED_FRAME (-1) +#define USE_FIFO_IRQ 0 + +#define HDLC_BUF_LEN 128 /* "arbitrary", or so say DAHDI's drivers */ + +enum data_dir { TRANSMIT = 0, RECEIVE = 1 }; + +#define xhfc_info(x, format, arg...) \ + dev_info(&(x)->pi->pci_dev->dev, format, ## arg) -#define dbg_d(code) printk(KERN_DEBUG __FILE__ ":%s:%d: " #code " => %d\n", \ - __FUNCTION__, __LINE__, code); enum { XHFC_PCM_MASTER = 1, XHFC_PCM_SLAVE = 0 }; /* some forward declaration */ @@ -48,6 +85,39 @@ struct xhfc_pi; struct xhfc_span; struct xhfc; +struct xhfc_span { + + struct xhfc* xhfc; + + struct dahdi_chan* chans[CHANS_PER_SPAN]; /* B1, B2, D, E */ + struct dahdi_chan _chans[CHANS_PER_SPAN]; /* B1, B2, D, E */ + unsigned char writechunk[CHANS_PER_SPAN * DAHDI_CHUNKSIZE]; + unsigned char readchunk[CHANS_PER_SPAN * DAHDI_CHUNKSIZE]; + // Same as in DAHDI's for sameness reasons + + struct dahdi_span span; + + int ts; /* PCM timeslot */ + + atomic_t hdlc_pending; + + int port; /* (physical) S/T port number */ + int nt; /* 1 if the port is nt, 0 if it's TE */ + + int rcv; /* number of received frames */ + int crpt; /* number of corrupted reveived frames */ + + int shutdown; + + /* Got the following from DAHDI */ + int oldstate; + int newalarm; + unsigned long alarmtimer; + int hfc_timer_on[CHANS_PER_SPAN]; /* 1=timer active */ + struct dahdi_chan* sigchan; + int sigactive; +}; + struct xhfc { char *name; __u8 chipidx; /* index in pi->xhfcs[NUM_XHFCS] */ @@ -61,8 +131,13 @@ struct xhfc { int irq_cnt; struct xhfc_test* testdata; - struct xhfc_span* spans[SPANS_PER_CHIP]; + struct xhfc_span spans[SPANS_PER_CHIP]; + + struct semaphore fifosem; + int running; + + u8 r_pcm_md0; }; struct xhfc_pi { @@ -77,38 +152,14 @@ struct xhfc_pi { struct pci_dev *pci_dev; }; -struct xhfc_span { - - struct xhfc* xhfc; - - stuct xhfc_chan* channels[CHANS_PER_SPAN]; /* B1, B2, D, E */ - - struct dahdi_span* span; - - uint dchan; /* FIFO and HFC chan number */ - uint b1, b2; - int ts; /* PCM timeslot */ - - atomic_t hdlc_pending; - - int port; /* (physical) S/T port number */ - int nt; /* 1 if the port is nt, 0 if it's TE */ - - int rcv; /* number of received frames */ - int crpt; /* number of corrupted reveived frames */ - - int shutdown; - - - u8 r_pcm_md0; - - /* Got the following from DAHDI */ - int oldstate; - int newalarm; - unsigned long alarmtimer; - int hfc_timer_on[CHANS_PER_SPAN]; /* 1=timer active */ -}; +#define dchan_fifo(span) (span->port * SPANS_PER_CHIP + 2) +void xhfc_config_d_chan_on_fifo(struct xhfc_span*); +//void xhfc_hdlc_write_buf(struct xhfc* x, int fifo, u8* buf, int len); +//int xhfc_hdlc_read_buf(struct xhfc* x, int fifo, u8* buf, int *len); +void xhfc_flush_fifo(struct xhfc* x, int fifo); +int xhfc_hdlc_init(struct xhfc* x); +int xhfc_hdlc_interrupt(struct xhfc* x); void xhfc_waitbusy(struct xhfc * xhfc); void xhfc_selfifo(struct xhfc * xhfc, int fifo, int receive); |