From 87963845a1bdb22e2ae6a74465a5a6408b1c0b0d Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Mon, 1 Mar 2010 23:15:49 +0000 Subject: wctdm24xxp, wcte12xp: Add optional module parameter to set the maximum latency. Setting the maximum latency can be useful if you have a system event that normally causes a latency increase, but you would rather have a break in the audio or frame slip, then let the latency grow to the current default maximum which is 25ms. DAHDI-278. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8198 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/voicebus/voicebus.h | 21 +++++++++++++++++---- drivers/dahdi/wctdm24xxp/base.c | 4 ++++ drivers/dahdi/wcte12xp/base.c | 3 +++ include/dahdi/kernel.h | 3 +++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/drivers/dahdi/voicebus/voicebus.h b/drivers/dahdi/voicebus/voicebus.h index ed7b590..553d6e6 100644 --- a/drivers/dahdi/voicebus/voicebus.h +++ b/drivers/dahdi/voicebus/voicebus.h @@ -37,11 +37,11 @@ #include #endif -#define VOICEBUS_DEFAULT_LATENCY 3 -#define VOICEBUS_DEFAULT_MAXLATENCY 25 -#define VOICEBUS_MAXLATENCY_BUMP 6 +#define VOICEBUS_DEFAULT_LATENCY 3U +#define VOICEBUS_DEFAULT_MAXLATENCY 25U +#define VOICEBUS_MAXLATENCY_BUMP 6U -#define VOICEBUS_SFRAME_SIZE 1004 +#define VOICEBUS_SFRAME_SIZE 1004U /*! The number of descriptors in both the tx and rx descriptor ring. */ #define DRING_SIZE (1 << 7) /* Must be a power of 2 */ @@ -189,4 +189,17 @@ static inline void voicebus_set_normal_mode(struct voicebus *vb) { set_bit(VOICEBUS_NORMAL_MODE, &vb->flags); } + +/** + * voicebus_set_max_latency() - Set the maximum number of milliseconds the latency will be able to grow to. + */ +static inline void +voicebus_set_maxlatency(struct voicebus *vb, unsigned int max_latency) +{ + spin_lock_bh(&vb->lock); + vb->max_latency = clamp(max_latency, + vb->min_tx_buffer_count, + VOICEBUS_DEFAULT_MAXLATENCY); + spin_unlock_bh(&vb->lock); +} #endif /* __VOICEBUS_H__ */ diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index 191d2ef..ff330aa 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -237,6 +237,7 @@ static int nativebridge = 0; static int ringdebounce = DEFAULT_RING_DEBOUNCE; static int fwringdetect = 0; static int latency = VOICEBUS_DEFAULT_LATENCY; +static unsigned int max_latency = VOICEBUS_DEFAULT_MAXLATENCY; static int forceload; #define MS_PER_HOOKCHECK (1) @@ -4670,6 +4671,7 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) wc->vb.ops = &voicebus_operations; ret = voicebus_init(&wc->vb, wc->board_name); voicebus_set_minlatency(&wc->vb, latency); + voicebus_set_maxlatency(&wc->vb, max_latency); } if (ret) { @@ -4716,6 +4718,7 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) voicebus_stop(&wc->vb); wc->vb.ops = &voicebus_operations; voicebus_set_minlatency(&wc->vb, latency); + voicebus_set_maxlatency(&wc->vb, max_latency); voicebus_set_normal_mode(&wc->vb); if (voicebus_start(&wc->vb)) BUG_ON(1); @@ -5036,6 +5039,7 @@ module_param(fxsrxgain, int, 0600); module_param(ringdebounce, int, 0600); module_param(fwringdetect, int, 0600); module_param(latency, int, 0400); +module_param(max_latency, int, 0400); module_param(neonmwi_monitor, int, 0600); module_param(neonmwi_level, int, 0600); module_param(neonmwi_envelope, int, 0600); diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index d38d513..58bdede 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -40,6 +40,7 @@ #include #include +#include #include #include "wct4xxp/wct4xxp.h" /* For certain definitions */ @@ -64,6 +65,7 @@ static int loopback = 0; static int t1e1override = -1; static int unchannelized = 0; static int latency = VOICEBUS_DEFAULT_LATENCY; +static unsigned int max_latency = VOICEBUS_DEFAULT_MAXLATENCY; static int vpmsupport = 1; static int vpmtsisupport = 0; @@ -1880,6 +1882,7 @@ static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_devi if (VOICEBUS_DEFAULT_LATENCY != latency) { voicebus_set_minlatency(&wc->vb, latency); + voicebus_set_maxlatency(&wc->vb, max_latency); } voicebus_lock_latency(&wc->vb); diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index 3f1bc54..0e98819 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -1185,6 +1185,8 @@ static inline short dahdi_txtone_nextsample(struct dahdi_chan *ss) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) #define KERN_CONT "" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) +#define clamp(x, low, high) min (max (low, x), high) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) /* Some distributions backported fatal_signal_pending so we'll use a macro to @@ -1222,6 +1224,7 @@ wait_for_completion_timeout(struct completion *x, unsigned long timeout) #endif /* 2.6.14 */ #endif /* 2.6.18 */ #endif /* 2.6.25 */ +#endif /* 2.6.26 */ #endif /* 2.6.31 */ #ifndef DMA_BIT_MASK -- cgit v1.2.3