summaryrefslogtreecommitdiff
path: root/drivers/dahdi/voicebus
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2009-11-07 00:35:41 +0000
committerShaun Ruffell <sruffell@digium.com>2009-11-07 00:35:41 +0000
commitc175ccff7514f76a885bb0b9b63433e18f80d8db (patch)
treef801efa43a8380b99548462527e9a8813e6e1a62 /drivers/dahdi/voicebus
parent9138db7368bd8f37ed7aa822a3fb41c31d6f41d9 (diff)
voicebus: Add function to lock the latency.
Now that increases in the latency produce less undefined behavior on the SPI busses, provide an interface for client drivers to inform the voicebus library to not increase the latency if underruns are detected. This can speed up loads of the driver since latency bumps do not trigger a restart of the driver initialization. DAHDI-278. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@7518 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/voicebus')
-rw-r--r--drivers/dahdi/voicebus/voicebus.c39
-rw-r--r--drivers/dahdi/voicebus/voicebus.h5
2 files changed, 40 insertions, 4 deletions
diff --git a/drivers/dahdi/voicebus/voicebus.c b/drivers/dahdi/voicebus/voicebus.c
index 3764b4c..7e037ff 100644
--- a/drivers/dahdi/voicebus/voicebus.c
+++ b/drivers/dahdi/voicebus/voicebus.c
@@ -234,6 +234,7 @@ static inline void handle_transmit(struct voicebus *vb, void *vbb)
#define IN_DEFERRED_PROCESSING 3
#define STOP 4
#define STOPPED 5
+#define LATENCY_LOCKED 6
#if VOICEBUS_DEFERRED == WORKQUEUE
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
@@ -466,6 +467,36 @@ voicebus_current_latency(struct voicebus *vb)
}
EXPORT_SYMBOL(voicebus_current_latency);
+/**
+ * voicebus_lock_latency() - Do not increase the latency during underruns.
+ *
+ */
+void voicebus_lock_latency(struct voicebus *vb)
+{
+ set_bit(LATENCY_LOCKED, &vb->flags);
+}
+EXPORT_SYMBOL(voicebus_lock_latency);
+
+/**
+ * voicebus_unlock_latency() - Bump up the latency during underruns.
+ *
+ */
+void voicebus_unlock_latency(struct voicebus *vb)
+{
+ clear_bit(LATENCY_LOCKED, &vb->flags);
+}
+EXPORT_SYMBOL(voicebus_unlock_latency);
+
+/**
+ * voicebus_is_latency_locked() - Return 1 if latency is currently locked.
+ *
+ */
+int voicebus_is_latency_locked(const struct voicebus *vb)
+{
+ return test_bit(LATENCY_LOCKED, &vb->flags);
+}
+EXPORT_SYMBOL(voicebus_is_latency_locked);
+
/*!
* \brief Read one of the hardware control registers without acquiring locks.
*/
@@ -1225,6 +1256,9 @@ vb_increase_latency(struct voicebus *vb, unsigned int increase)
if (0 == increase)
return;
+ if (test_bit(LATENCY_LOCKED, &vb->flags))
+ return;
+
if (unlikely(increase > VOICEBUS_MAXLATENCY_BUMP))
increase = VOICEBUS_MAXLATENCY_BUMP;
@@ -1385,7 +1419,6 @@ static void vb_deferred(struct voicebus *vb)
unsigned int i;
unsigned int idle_buffers;
int softunderrun;
- unsigned int starting_latency;
int underrun = test_bit(TX_UNDERRUN, &vb->flags);
@@ -1448,7 +1481,6 @@ static void vb_deferred(struct voicebus *vb)
} else {
softunderrun = 0;
idle_buffers = 0;
- starting_latency = 0;
}
/* Now we can process the completed non-idle buffers since we know at
@@ -1478,7 +1510,8 @@ static void vb_deferred(struct voicebus *vb)
* descriptor ring. Otherwise it's possible to take so much time
* printing the dmesg output that we lose the lead that we got on the
* hardware, resulting in a hard underrun condition. */
- if (unlikely(softunderrun) && printk_ratelimit()) {
+ if (unlikely(softunderrun &&
+ !test_bit(LATENCY_LOCKED, &vb->flags) && printk_ratelimit())) {
if (vb->max_latency != vb->min_tx_buffer_count) {
dev_info(&vb->pdev->dev, "Missed interrupt. "
"Increasing latency to %d ms in order to "
diff --git a/drivers/dahdi/voicebus/voicebus.h b/drivers/dahdi/voicebus/voicebus.h
index 8c26149..18c37e0 100644
--- a/drivers/dahdi/voicebus/voicebus.h
+++ b/drivers/dahdi/voicebus/voicebus.h
@@ -58,6 +58,9 @@ void * voicebus_alloc(struct voicebus* vb);
void voicebus_free(struct voicebus *vb, void *vbb);
int voicebus_transmit(struct voicebus *vb, void *vbb);
int voicebus_set_minlatency(struct voicebus *vb, unsigned int milliseconds);
-int voicebus_current_latency(struct voicebus *vb) ;
+int voicebus_current_latency(struct voicebus *vb);
+void voicebus_lock_latency(struct voicebus *vb);
+void voicebus_unlock_latency(struct voicebus *vb);
+int voicebus_is_latency_locked(const struct voicebus *vb);
#endif /* __VOICEBUS_H__ */