[svn-commits] sruffell: branch sruffell/voicebus r4093 - /team/sruffell/voicebus/kernel/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Mar 27 14:07:38 CDT 2008
Author: sruffell
Date: Thu Mar 27 14:07:38 2008
New Revision: 4093
URL: http://svn.digium.com/view/zaptel?view=rev&rev=4093
Log:
Moving a few functions around in the source file so that I do not need to use
forward declarations.
Modified:
team/sruffell/voicebus/kernel/voicebus.c
Modified: team/sruffell/voicebus/kernel/voicebus.c
URL: http://svn.digium.com/view/zaptel/team/sruffell/voicebus/kernel/voicebus.c?view=diff&rev=4093&r1=4092&r2=4093
==============================================================================
--- team/sruffell/voicebus/kernel/voicebus.c (original)
+++ team/sruffell/voicebus/kernel/voicebus.c Thu Mar 27 14:07:38 2008
@@ -106,11 +106,6 @@
#define CSR9_MDO 0x00020000
#define CSR9_MMC 0x00040000
#define CSR9_MDI 0x00080000
-
-/* Forward declarations */
-static inline int vb_submit_rxb(struct voicebus *vb, void* vbb);
-static inline void vb_deferred(struct voicebus *vb);
-static int vb_is_stopped(struct voicebus *vb);
#define OWN_BIT (1 << 31)
@@ -389,6 +384,46 @@
return latency;
}
+/*!
+ * \brief Read one of the hardware control registers without acquiring locks.
+ */
+static inline u32
+__vb_getctl(struct voicebus *vb, u32 addr)
+{
+ return le32_to_cpu(inl(vb->iobase + addr));
+}
+
+/*!
+ * \brief Read one of the hardware control registers with locks held.
+ */
+static inline u32
+vb_getctl(struct voicebus *vb, u32 addr)
+{
+ LOCKS_VOICEBUS;
+ u32 val;
+ VBLOCK(vb);
+ val = __vb_getctl(vb, addr);
+ VBUNLOCK(vb);
+ return val;
+}
+
+/*!
+ * \brief Returns whether or not the interface is running.
+ *
+ * NOTE: Running in this case means whether or not the hardware reports the
+ * transmit processor in any state but stopped.
+ *
+ * \return 1 of the process is stopped, 0 if running.
+ */
+static int
+vb_is_stopped(struct voicebus *vb)
+{
+ u32 reg;
+ reg = vb_getctl(vb, SR_CSR5);
+ reg = (reg >> 17)&0x38;
+ return (0 == reg) ? 1 : 0;
+}
+
static void
vb_cleanup_descriptors(struct voicebus *vb, struct voicebus_descriptor_list *dl)
{
@@ -424,29 +459,6 @@
vb->pdev,
(sizeof(struct voicebus_descriptor)+dl->padding)*DRING_SIZE,
dl->desc, dl->desc_dma);
-}
-
-/*!
- * \brief Read one of the hardware control registers without acquiring locks.
- */
-static inline u32
-__vb_getctl(struct voicebus *vb, u32 addr)
-{
- return le32_to_cpu(inl(vb->iobase + addr));
-}
-
-/*!
- * \brief Read one of the hardware control registers with locks held.
- */
-static inline u32
-vb_getctl(struct voicebus *vb, u32 addr)
-{
- LOCKS_VOICEBUS;
- u32 val;
- VBLOCK(vb);
- val = __vb_getctl(vb, addr);
- VBUNLOCK(vb);
- return val;
}
/*!
@@ -782,23 +794,6 @@
}
/*!
- * \brief Returns whether or not the interface is running.
- *
- * NOTE: Running in this case means whether or not the hardware reports the
- * transmit processor in any state but stopped.
- *
- * \return 1 of the process is stopped, 0 if running.
- */
-static int
-vb_is_stopped(struct voicebus *vb)
-{
- u32 reg;
- reg = vb_getctl(vb, SR_CSR5);
- reg = (reg >> 17)&0x38;
- return (0 == reg) ? 1 : 0;
-}
-
-/*!
* \brief Instruct the hardware to check for a new tx descriptor.
*/
inline static void
@@ -1064,6 +1059,115 @@
release_region(vb->iobase, 0xff);
pci_disable_device(vb->pdev);
kfree(vb);
+}
+
+void
+__vb_increase_latency(struct voicebus *vb)
+{
+ static int __warn_once = 1;
+ void *vbb;
+ int latency;
+
+ assert_in_vb_deferred(vb);
+
+ latency = atomic_read(&vb->txd.count);
+ if (DRING_SIZE == latency) {
+ if (__warn_once) {
+ /* We must subtract two from this number since there
+ * are always two buffers in the TX FIFO.
+ */
+ VB_PRINTK(vb,ERR,
+ "ERROR: Unable to service card within %d ms "\
+ "and unable to further increase latency.\n",
+ DRING_SIZE-2);
+ __warn_once = 0;
+ }
+ } else {
+ /* Because there are 2 buffers in the transmit FIFO on the
+ * hardware, setting 3 ms of latency means that the host needs
+ * to be able to service the cards within 1ms. This is because
+ * the interface will load up 2 buffers into the TX FIFO then
+ * attempt to read the 3rd descriptor. If the OWN bit isn't
+ * set, then the hardware will set the TX descriptor not
+ * available interrupt.
+ */
+ VB_PRINTK(vb, INFO, "Missed interrupt. " \
+ "Increasing latency to %d ms in order to compensate.\n",
+ latency+1);
+ /* Set the minimum latency in case we're restarted...we don't
+ * want to wait for the buffer to grow to this depth again in
+ * that case.
+ */
+ voicebus_set_minlatency(vb, latency+1);
+ vbb = voicebus_alloc(vb);
+ if (unlikely(NULL == vbb)) {
+ BUG_ON(1);
+ } else {
+ vb->handle_transmit(vbb, vb->context);
+ }
+ }
+}
+
+/*!
+ * \brief Actually process the completed transmit and receive buffers.
+ *
+ * NOTE: This function may be called either from a tasklet, workqueue, or
+ * directly in the interrupt service routine depending on
+ * VOICEBUS_DEFERRED.
+ */
+static inline void
+vb_deferred(struct voicebus *vb)
+{
+ void *vbb;
+#ifdef DBG
+ static int count = 0;
+#endif
+ int stopping = test_bit(STOP, &vb->flags);
+ int underrun = test_bit(TX_UNDERRUN, &vb->flags);
+
+
+ start_vb_deferred(vb);
+ if (unlikely(stopping)) {
+ while((vbb = vb_get_completed_txb(vb))) {
+ voicebus_free(vb, vbb);
+ }
+ while((vbb = vb_get_completed_rxb(vb))) {
+ voicebus_free(vb, vbb);
+ }
+ stop_vb_deferred(vb);
+ return;
+ }
+
+ if (unlikely(underrun)) {
+ /* When we've underrun our FIFO, for some reason we're not
+ * able to keep enough transmit descriptors pending. This can
+ * happen if either interrupts or this deferred processing
+ * function is not run soon enough (within 1ms when using the
+ * default 3 transmit buffers to start). In this case, we'll
+ * insert an additional transmit buffer onto the descriptor
+ * list which decreases the sensitivity to latency, but also
+ * adds more delay to the TDM and SPI data.
+ */
+ __vb_increase_latency(vb);
+ }
+
+ /* Always handle the transmit buffers first. */
+ while ((vbb = vb_get_completed_txb(vb))) {
+ vb->handle_transmit(vbb, vb->context);
+ }
+
+ if (unlikely(underrun)) {
+ vb_rx_demand_poll(vb);
+ vb_tx_demand_poll(vb);
+ clear_bit(TX_UNDERRUN, &vb->flags);
+ }
+
+ while ((vbb = vb_get_completed_rxb(vb))) {
+ vb->handle_receive(vbb, vb->context);
+ vb_submit_rxb(vb, vbb);
+ }
+
+ stop_vb_deferred(vb);
}
@@ -1178,115 +1282,6 @@
}
#endif
-void
-__vb_increase_latency(struct voicebus *vb)
-{
- static int __warn_once = 1;
- void *vbb;
- int latency;
-
- assert_in_vb_deferred(vb);
-
- latency = atomic_read(&vb->txd.count);
- if (DRING_SIZE == latency) {
- if (__warn_once) {
- /* We must subtract two from this number since there
- * are always two buffers in the TX FIFO.
- */
- VB_PRINTK(vb,ERR,
- "ERROR: Unable to service card within %d ms "\
- "and unable to further increase latency.\n",
- DRING_SIZE-2);
- __warn_once = 0;
- }
- } else {
- /* Because there are 2 buffers in the transmit FIFO on the
- * hardware, setting 3 ms of latency means that the host needs
- * to be able to service the cards within 1ms. This is because
- * the interface will load up 2 buffers into the TX FIFO then
- * attempt to read the 3rd descriptor. If the OWN bit isn't
- * set, then the hardware will set the TX descriptor not
- * available interrupt.
- */
- VB_PRINTK(vb, INFO, "Missed interrupt. " \
- "Increasing latency to %d ms in order to compensate.\n",
- latency+1);
- /* Set the minimum latency in case we're restarted...we don't
- * want to wait for the buffer to grow to this depth again in
- * that case.
- */
- voicebus_set_minlatency(vb, latency+1);
- vbb = voicebus_alloc(vb);
- if (unlikely(NULL == vbb)) {
- BUG_ON(1);
- } else {
- vb->handle_transmit(vbb, vb->context);
- }
- }
-}
-
-/*!
- * \brief Actually process the completed transmit and receive buffers.
- *
- * NOTE: This function may be called either from a tasklet, workqueue, or
- * directly in the interrupt service routine depending on
- * VOICEBUS_DEFERRED.
- */
-static inline void
-vb_deferred(struct voicebus *vb)
-{
- void *vbb;
-#ifdef DBG
- static int count = 0;
-#endif
- int stopping = test_bit(STOP, &vb->flags);
- int underrun = test_bit(TX_UNDERRUN, &vb->flags);
-
-
- start_vb_deferred(vb);
- if (unlikely(stopping)) {
- while((vbb = vb_get_completed_txb(vb))) {
- voicebus_free(vb, vbb);
- }
- while((vbb = vb_get_completed_rxb(vb))) {
- voicebus_free(vb, vbb);
- }
- stop_vb_deferred(vb);
- return;
- }
-
- if (unlikely(underrun)) {
- /* When we've underrun our FIFO, for some reason we're not
- * able to keep enough transmit descriptors pending. This can
- * happen if either interrupts or this deferred processing
- * function is not run soon enough (within 1ms when using the
- * default 3 transmit buffers to start). In this case, we'll
- * insert an additional transmit buffer onto the descriptor
- * list which decreases the sensitivity to latency, but also
- * adds more delay to the TDM and SPI data.
- */
- __vb_increase_latency(vb);
- }
-
- /* Always handle the transmit buffers first. */
- while ((vbb = vb_get_completed_txb(vb))) {
- vb->handle_transmit(vbb, vb->context);
- }
-
- if (unlikely(underrun)) {
- vb_rx_demand_poll(vb);
- vb_tx_demand_poll(vb);
- clear_bit(TX_UNDERRUN, &vb->flags);
- }
-
- while ((vbb = vb_get_completed_rxb(vb))) {
- vb->handle_receive(vbb, vb->context);
- vb_submit_rxb(vb, vbb);
- }
-
- stop_vb_deferred(vb);
-}
-
#if VOICEBUS_DEFERRED == WORKQUEUE
static void
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
More information about the svn-commits
mailing list