diff options
author | Shaun Ruffell <sruffell@digium.com> | 2010-01-08 20:48:02 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2010-01-08 20:48:02 +0000 |
commit | 4d3c52e9fa00c3f18744a08a15df24907129effb (patch) | |
tree | d11dd39820dea77726af5f860967e904c8cf7b5d /drivers/dahdi/voicebus/voicebus.h | |
parent | 6fb9c465e19b1eba4aa300de3f1e4902c2fb82b6 (diff) |
voicebus: Make 'struct voicebus' embeddable by the client driver strutures.
In addition to making 'struct voicebus' embeddable, also add an
'voicebus_operations' structure. This was done so that a) remove the "context"
pointer from struct voicebus, and also to show that handle_recieve/transmit are
to be managed together.
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@7778 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/voicebus/voicebus.h')
-rw-r--r-- | drivers/dahdi/voicebus/voicebus.h | 97 |
1 files changed, 77 insertions, 20 deletions
diff --git a/drivers/dahdi/voicebus/voicebus.h b/drivers/dahdi/voicebus/voicebus.h index 16768df..9cbacee 100644 --- a/drivers/dahdi/voicebus/voicebus.h +++ b/drivers/dahdi/voicebus/voicebus.h @@ -29,29 +29,86 @@ #ifndef __VOICEBUS_H__ #define __VOICEBUS_H__ +#define VOICEBUS_DEFAULT_LATENCY 3 +#define VOICEBUS_DEFAULT_MAXLATENCY 25 +#define VOICEBUS_MAXLATENCY_BUMP 6 + +/*! The number of descriptors in both the tx and rx descriptor ring. */ +#define DRING_SIZE (1 << 7) /* Must be a power of 2 */ +#define DRING_MASK (DRING_SIZE-1) + +/* Define CONFIG_VOICEBUS_SYSFS to create some attributes under the pci device. + * This is disabled by default because it hasn't been tested on the full range + * of supported kernels. */ +#undef CONFIG_VOICEBUS_SYSFS + +#define INTERRUPT 0 /* Run the deferred processing in the ISR. */ +#define TASKLET 1 /* Run in a tasklet. */ +#define TIMER 2 /* Run in a system timer. */ +#define WORKQUEUE 3 /* Run in a workqueue. */ + +#ifndef VOICEBUS_DEFERRED +#define VOICEBUS_DEFERRED INTERRUPT +#endif + struct voicebus; -#define VOICEBUS_DEFAULT_LATENCY 3 -#define VOICEBUS_DEFAULT_MAXLATENCY 25 -#define VOICEBUS_MAXLATENCY_BUMP 6 +struct voicebus_operations { + void (*handle_receive)(struct voicebus *vb, void *vbb); + void (*handle_transmit)(struct voicebus *vb, void *vbb); +}; + +/** + * struct voicebus_descriptor_list - A single descriptor list. + */ +struct voicebus_descriptor_list { + struct voicebus_descriptor *desc; + unsigned int head; + unsigned int tail; + void *pending[DRING_SIZE]; + dma_addr_t desc_dma; + atomic_t count; + unsigned int padding; +}; + +/** + * struct voicebus - Represents physical interface to voicebus card. + * + */ +struct voicebus { + struct pci_dev *pdev; + spinlock_t lock; + u32 framesize; + u8 cache_line_size; + struct voicebus_descriptor_list rxd; + struct voicebus_descriptor_list txd; + void *idle_vbb; + dma_addr_t idle_vbb_dma_addr; + const int *debug; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) + kmem_cache_t *buffer_cache; +#else + struct kmem_cache *buffer_cache; +#endif + u32 iobase; +#if VOICEBUS_DEFERRED == WORKQUEUE + struct workqueue_struct *workqueue; + struct work_struct workitem; +#elif VOICEBUS_DEFERRED == TASKLET + struct tasklet_struct tasklet; +#elif VOICEBUS_DEFERRED == TIMER + struct timer_list timer; +#endif + const struct voicebus_operations *ops; + struct completion stopped_completion; + unsigned long flags; + unsigned int min_tx_buffer_count; + unsigned int max_latency; + void *vbb_stash[DRING_SIZE]; + unsigned int count; +}; -void voicebus_setdebuglevel(struct voicebus *vb, u32 level); -int voicebus_getdebuglevel(struct voicebus *vb); -struct pci_dev *voicebus_get_pci_dev(struct voicebus *vb); -void *voicebus_pci_dev_to_context(struct pci_dev *pdev); -int voicebus_init(struct pci_dev* pdev, u32 framesize, - const char *board_name, - void (*handle_receive)(void *buffer, void *context), - void (*handle_transmit)(void *buffer, void *context), - void *context, - u32 debuglevel, - struct voicebus **vb_p); -void voicebus_get_handlers(struct voicebus *vb, void **handle_receive, - void **handle_transmit, void **context); -void voicebus_set_handlers(struct voicebus *vb, - void (*handle_receive)(void *buffer, void *context), - void (*handle_transmit)(void *buffer, void *context), - void *context); +int voicebus_init(struct voicebus *vb, const char *board_name); void voicebus_release(struct voicebus *vb); int voicebus_start(struct voicebus *vb); int voicebus_stop(struct voicebus *vb); |