From 77cf7bdb28dd62199356bbcf3558f6c2281c80cf Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Wed, 3 Feb 2021 18:41:00 +0100 Subject: [PATCH] Added patch to Ravenna driver to fix a problem that leads to an initial playback buffer corruption in case the read/write interleaved mode is used. The problem arises from pre-buffering performed after ALSA prepare and before ALSA start trigger- The patch enables the early startup of the audio playback interrupt and disables the cleanup (mute) of the playback buffer. This issue can be reproduced using the test suite developed to investigate #17 and by removing the (-M) option from aplay in run_test.sh script. --- .../ravenna-alsa-fix-playback-rw-mode.patch | 26 +++++++++++++++++++ build.sh | 1 + 2 files changed, 27 insertions(+) create mode 100644 3rdparty/patches/ravenna-alsa-fix-playback-rw-mode.patch diff --git a/3rdparty/patches/ravenna-alsa-fix-playback-rw-mode.patch b/3rdparty/patches/ravenna-alsa-fix-playback-rw-mode.patch new file mode 100644 index 0000000..5961fbd --- /dev/null +++ b/3rdparty/patches/ravenna-alsa-fix-playback-rw-mode.patch @@ -0,0 +1,26 @@ +diff --git a/driver/audio_driver.c b/driver/audio_driver.c +index 3d9debd..cc6240e 100644 +--- a/driver/audio_driver.c ++++ b/driver/audio_driver.c +@@ -936,6 +936,8 @@ + chip->dma_playback_offset = 0; + chip->dma_playback_buffer = runtime->dma_area; + chip->pcm_playback_buffer_size = snd_pcm_lib_buffer_bytes(chip->playback_substream); ++ // early startup to fix problem with read-write interleaved mode pre-buffering ++ chip->mr_alsa_audio_ops->start_interrupts(chip->ravenna_peer, 1); + } + else if(substream->stream == SNDRV_PCM_STREAM_CAPTURE) + { +index 5a90eca..8023708 100644 +--- a/driver/manager.c ++++ b/driver/manager.c +@@ -279,7 +279,7 @@ + } + else { + printk(KERN_DEBUG "starting playback I/O\n"); +- MuteOutputBuffer(self); ++ //MuteOutputBuffer(self); + self->m_bIsPlaybackIO = true; + } + + diff --git a/build.sh b/build.sh index d68eeec..be3554a 100755 --- a/build.sh +++ b/build.sh @@ -25,6 +25,7 @@ if [ ! -d ravenna-alsa-lkm.git ]; then git apply ../patches/ravenna-alsa-lkm-direct-pcm-transfer.patch git apply ../patches/ravenna-alsa-lkm-enable-mono-channels.patch git apply ../patches/ravenna-alsa-lkm-init-play-capture-buffers.patch + git apply ../patches/ravenna-alsa-fix-playback-rw-mode.patch echo "Building ravenna-alsa-lkm kernel module ..." cd driver make