Skip to contentSkip to conversation

ASoC: davinci-mcasp: Add overrun/underrun event handling

PATCH Superseded Peter Ujfalusi 2 participants 2 messages Nov 12, 2014

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ASoC: davinci-mcasp: Add overrun/underrun event handling

From: Misael Lopez Cruz <[email protected]>

An underrun (playback) event occurs when the serializer transfer data from the XRBUF buffer to the XRSR shift register, but the XRBUF hasn't been filled. Similarly, the overrun (capture) event occurs when data from the XRSR shift register is transferred to the XRBUF but it hasn't been read yet.

These events are handled as XRUN events that cause the pcm to stop. The stream has to be explicitly restarted by the userspace which ensures that after stopping/starting McASP the data transfer is aligned with DMA. The other possibility was to internally stop and start McASP without DMA even knowing about it.

---
Hi,

Changes since v1:
- only ack handled interrupt (over/underflow at the moment)
- Use variable to keep track of requested irq sources for future use
- print warning in case of not handled interrupt.

Regards,
Peter

 .../bindings/sound/davinci-mcasp-audio.txt         |   2 +-
 sound/soc/davinci/davinci-mcasp.c                  | 124 +++++++++++++++++++++
 sound/soc/davinci/davinci-mcasp.h                  |  11 ++
 3 files changed, 136 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt +1 -1
index 60ca07996458..46bc9829c71a 100644
@@ -32,7 +32,7 @@ Optional properties:
 - rx-num-evt : FIFO levels.
 - sram-size-playback : size of sram to be allocated during playback
 - sram-size-capture  : size of sram to be allocated during capture
-- interrupts : Interrupt numbers for McASP, currently not used by the driver
+- interrupts : Interrupt numbers for McASP
 - interrupt-names : Known interrupt names are "tx" and "rx"
 - pinctrl-0: Should specify pin control group used for this controller.
 - pinctrl-names: Should contain only one value - "default", for more details
sound/soc/davinci/davinci-mcasp.c +124 -0

190 lines not on this page · raw message

sound/soc/davinci/davinci-mcasp.h +11 -0
index 9737108f0305..79dc511180bf 100644
@@ -256,6 +256,7 @@
  * DAVINCI_MCASP_TXSTAT_REG - Transmitter Status Register Bits
  * DAVINCI_MCASP_RXSTAT_REG - Receiver Status Register Bits
  */
+#define XRERR		BIT(8) /* Transmit/Receive error */
 #define XRDATA		BIT(5) /* Transmit/Receive data ready */
 
 /*
@@ -285,6 +286,16 @@
 #define TXDATADMADIS	BIT(0)
 
 /*
+ * DAVINCI_MCASP_EVTCTLR_REG - Receiver Interrupt Control Register Bits
+ */
+#define ROVRN		BIT(0)
+
+/*
+ * DAVINCI_MCASP_EVTCTLX_REG - Transmitter Interrupt Control Register Bits
+ */
+#define XUNDRN		BIT(0)
+
+/*
  * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits
  */
 #define FIFO_ENABLE	BIT(16)
Signature · 1 line
2.1.3
maintainer
#1 lore raw

sound/soc/davinci/davinci-mcasp.c static void davinci_mcasp_stop(struct davinci_mcasp *mcasp, int stream) · line 329

Quoted 11 lines · Peter Ujfalusi
sound/soc/davinci/davinci-mcasp.c +11 -0
+	if (!handled_mask)
+		dev_warn(mcasp->dev, "unhandled tx event. txstat: 0x%08x\n",
+			 stat);
+
+	if (stat & XRERR)
+		handled_mask |= XRERR;
+
+	/* Ack the handled event only */
+	mcasp_set_reg(mcasp, DAVINCI_MCASP_TXSTAT_REG, handled_mask);
+
+	return IRQ_HANDLED;

If nothing was handled the driver should be returning IRQ_NONE (I guess saying we handled XRERR is OK, looks like it's an or of the other sources). Either unconditionally ack everything or return IRQ_NONE if the driver doesn't handle anything - the latter option is better and closer to what you have here.