SAMA SSC: Add bufffer dump debug instrumentation

This commit is contained in:
Gregory Nutt
2013-11-12 16:22:05 -06:00
parent dc5d404fb4
commit 8e1abbc561
2 changed files with 30 additions and 9 deletions
+7
View File
@@ -1682,6 +1682,13 @@ config SAMA5_SSC_QDEBUG
---help--- ---help---
Enable instrumentation to debug audio buffer queue logic. Enable instrumentation to debug audio buffer queue logic.
config SAMA5_SSC_DUMPBUFFERS
bool "Dump Buffers"
depends on DEBUG_I2S
default n
---help---
Enable instrumentation to dump TX and RX buffers.
endmenu # SSC Configuration endmenu # SSC Configuration
endif # SAMA5_SSC0 || SAMA5_SSC1 endif # SAMA5_SSC0 || SAMA5_SSC1
+23 -9
View File
@@ -241,15 +241,13 @@
#ifndef CONFIG_DEBUG #ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_VERBOSE # undef CONFIG_DEBUG_VERBOSE
# undef CONFIG_DEBUG_I2S # undef CONFIG_DEBUG_I2S
# undef CONFIG_SAMA5_SSC_DMADEBUG
# undef CONFIG_SAMA5_SSC_REGDEBUG
# undef CONFIG_SAMA5_SSC_QDEBUG
#endif #endif
#if !defined(CONFIG_DEBUG_I2S) #ifndef CONFIG_DEBUG_I2S
# undef CONFIG_SAMA5_SSC_DMADEBUG # undef CONFIG_SAMA5_SSC_DMADEBUG
# undef CONFIG_SAMA5_SSC_REGDEBUG # undef CONFIG_SAMA5_SSC_REGDEBUG
# undef CONFIG_SAMA5_SSC_QDEBUG # undef CONFIG_SAMA5_SSC_QDEBUG
# undef CONFIG_SAMA5_SSC_DUMPBUFFERS
#endif #endif
#ifndef CONFIG_DEBUG_DMA #ifndef CONFIG_DEBUG_DMA
@@ -390,6 +388,14 @@ static void ssc_dump_queues(struct sam_transport_s *xpt,
# define ssc_dump_txqueues(s,m) # define ssc_dump_txqueues(s,m)
#endif #endif
#ifdef CONFIG_SAMA5_SSC_DUMPBUFFERS
# define ssc_init_buffer(b,s) memset(b, 0x55, s);
# define ssc_dump_buffer(m,b,s) lib_dumpbuffer(m,b,s)
#else
# define ssc_init_buffer(b,s)
# define ssc_dump_buffer(m,b,s)
#endif
/* Semaphore helpers */ /* Semaphore helpers */
static void ssc_exclsem_take(struct sam_ssc_s *priv); static void ssc_exclsem_take(struct sam_ssc_s *priv);
@@ -1250,6 +1256,7 @@ static void ssc_rx_worker(void *arg)
{ {
struct sam_ssc_s *priv = (struct sam_ssc_s *)arg; struct sam_ssc_s *priv = (struct sam_ssc_s *)arg;
struct sam_buffer_s *bfcontainer; struct sam_buffer_s *bfcontainer;
struct ap_buffer_s *apb;
irqstate_t flags; irqstate_t flags;
DEBUGASSERT(priv); DEBUGASSERT(priv);
@@ -1310,7 +1317,8 @@ static void ssc_rx_worker(void *arg)
bfcontainer = (struct sam_buffer_s *)sq_remfirst(&priv->rx.done); bfcontainer = (struct sam_buffer_s *)sq_remfirst(&priv->rx.done);
irqrestore(flags); irqrestore(flags);
DEBUGASSERT(bfcontainer && bfcontainer->callback); DEBUGASSERT(bfcontainer && bfcontainer->apb && bfcontainer->callback);
apb = bfcontainer->apb;
/* If the DMA was successful, then update the number of valid bytes in /* If the DMA was successful, then update the number of valid bytes in
* the audio buffer. * the audio buffer.
@@ -1318,19 +1326,21 @@ static void ssc_rx_worker(void *arg)
if (bfcontainer->result == OK) if (bfcontainer->result == OK)
{ {
bfcontainer->apb->nbytes = bfcontainer->apb->nmaxbytes; apb->nbytes = apb->nmaxbytes;
} }
ssc_dump_buffer("Received", apb->samp, apb->nbytes);
/* Perform the RX transfer done callback */ /* Perform the RX transfer done callback */
bfcontainer->callback(&priv->dev, bfcontainer->apb, bfcontainer->callback(&priv->dev, apb, bfcontainer->arg,
bfcontainer->arg, bfcontainer->result); bfcontainer->result);
/* Release our reference on the audio buffer. This may very likely /* Release our reference on the audio buffer. This may very likely
* cause the audio buffer to be freed. * cause the audio buffer to be freed.
*/ */
apb_free(bfcontainer->apb); apb_free(apb);
/* And release the buffer container */ /* And release the buffer container */
@@ -1992,6 +2002,8 @@ static int ssc_receive(struct i2s_dev_s *dev, struct ap_buffer_s *apb,
i2svdbg("apb=%p nmaxbytes=%d arg=%p timeout=%d\n", i2svdbg("apb=%p nmaxbytes=%d arg=%p timeout=%d\n",
apb, apb->nmaxbytes, arg, timeout); apb, apb->nmaxbytes, arg, timeout);
ssc_init_buffer(apb->samp, apb->nmaxbytes);
#ifdef SSC_HAVE_RX #ifdef SSC_HAVE_RX
/* Allocate a buffer container in advance */ /* Allocate a buffer container in advance */
@@ -2193,6 +2205,8 @@ static int ssc_send(struct i2s_dev_s *dev, struct ap_buffer_s *apb,
i2svdbg("apb=%p nbytes=%d arg=%p timeout=%d\n", i2svdbg("apb=%p nbytes=%d arg=%p timeout=%d\n",
apb, apb->nbytes, arg, timeout); apb, apb->nbytes, arg, timeout);
ssc_dump_buffer("Sending", apb->samp, apb->nbytes);
#ifdef SSC_HAVE_TX #ifdef SSC_HAVE_TX
/* Allocate a buffer container in advance */ /* Allocate a buffer container in advance */