From 633f3880024a2f83a21dd96368aa397940bc9ad6 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 7 Mar 2007 06:23:02 +0000 Subject: Coldfire targets: Shuffle IRQ levels around to have all interaction between low level audio function calls and DMA be atomic. Make recording and playback independently startable and stoppable so one can be running and not interfere with the other. All tests I can do at the moment check out ok (play, record, play+record, FM radio on iRivers, S/PDIF on H120 (w/running optical on/off), and on-the-fly samplerate changes). Recording tested for well over an hour run and no problems. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12658 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/coldfire/iriver/h100/spdif-h100.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'firmware/target/coldfire/iriver/h100/spdif-h100.c') diff --git a/firmware/target/coldfire/iriver/h100/spdif-h100.c b/firmware/target/coldfire/iriver/h100/spdif-h100.c index 35508d10e8..ee4a9402ea 100644 --- a/firmware/target/coldfire/iriver/h100/spdif-h100.c +++ b/firmware/target/coldfire/iriver/h100/spdif-h100.c @@ -63,30 +63,42 @@ void spdif_set_output_source(int source, bool src_on) }; bool kick; + int level; + int iis2config = 0; if ((unsigned)source >= ARRAYLEN(ebu1_config)) source = AUDIO_SRC_PLAYBACK; spdif_source = source; spdif_on = spdif_powered() && src_on; - kick = spdif_on && source == AUDIO_SRC_PLAYBACK; + + /* Keep a DMA interrupt initiated stop from changing play state */ + level = set_irq_level(DMA_IRQ_LEVEL); + + kick = spdif_on && source == AUDIO_SRC_PLAYBACK + && (DCR0 & DMA_EEXT); /* FIFO must be in reset condition to reprogram bits 15-12 */ or_l(0x800, &EBU1CONFIG); if (kick) + { + iis2config = IIS2CONFIG; or_l(0x800, &IIS2CONFIG); /* Have to resync IIS2 TXSRC */ + } /* Tranceiver must be powered or else monitoring will be disabled. CLOCKSEL bits only have relevance to normal operation so just set them always. */ EBU1CONFIG = (spdif_on ? ebu1_config[source + 1] : 0) | (7 << 12); - if (kick && (DCR0 & DMA_EEXT)) /* only if still playing */ + if (kick) { - and_l(~0x800, &IIS2CONFIG); + IIS2CONFIG = iis2config; PDOR3 = 0; /* A write to the FIFO kick-starts playback */ } + + set_irq_level(level); } /* spdif_set_output_source */ /* Return the last set S/PDIF audio source */ -- cgit v1.2.3