From 0b32bee3aa58705f7dc3c10486e8c7f1db7a9365 Mon Sep 17 00:00:00 2001 From: Ed Date: Tue, 1 Sep 2020 09:55:53 +0100 Subject: [PATCH 1/4] Handle case at startup where decouple ISR gets stuck for several hundred cycles at startup, pushing out I2S timing --- lib_xua/src/core/buffer/decouple/decouple.xc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_xua/src/core/buffer/decouple/decouple.xc b/lib_xua/src/core/buffer/decouple/decouple.xc index 4e631dfb..f07f9411 100644 --- a/lib_xua/src/core/buffer/decouple/decouple.xc +++ b/lib_xua/src/core/buffer/decouple/decouple.xc @@ -523,6 +523,9 @@ __builtin_unreachable(); GET_SHARED_GLOBAL(rdPtr, g_aud_to_host_rdptr); asm volatile("ldw %0, %1[0]":"=r"(datalength):"r"(rdPtr)); + /* Handle startup case where zero length packets exist */ + if(!datalength) break; + /* Round up datalength */ datalength = ((datalength+3) & ~0x3) + 4; From 2e8e57d5fa82476df304f6d0fe3809133e222f4d Mon Sep 17 00:00:00 2001 From: Ed Date: Tue, 1 Sep 2020 17:48:38 +0100 Subject: [PATCH 2/4] Revert "Handle case at startup where decouple ISR gets stuck for several hundred cycles at startup, pushing out I2S timing" This reverts commit 0b32bee3aa58705f7dc3c10486e8c7f1db7a9365. --- lib_xua/src/core/buffer/decouple/decouple.xc | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib_xua/src/core/buffer/decouple/decouple.xc b/lib_xua/src/core/buffer/decouple/decouple.xc index f07f9411..4e631dfb 100644 --- a/lib_xua/src/core/buffer/decouple/decouple.xc +++ b/lib_xua/src/core/buffer/decouple/decouple.xc @@ -523,9 +523,6 @@ __builtin_unreachable(); GET_SHARED_GLOBAL(rdPtr, g_aud_to_host_rdptr); asm volatile("ldw %0, %1[0]":"=r"(datalength):"r"(rdPtr)); - /* Handle startup case where zero length packets exist */ - if(!datalength) break; - /* Round up datalength */ datalength = ((datalength+3) & ~0x3) + 4; From 0286ca093dc68052f65872e2070bc3fb71be24e5 Mon Sep 17 00:00:00 2001 From: Ed Date: Tue, 1 Sep 2020 17:53:03 +0100 Subject: [PATCH 3/4] Better fix to avoid zero length packets being added to input buffer before SoF case starts working --- lib_xua/src/core/buffer/ep/ep_buffer.xc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_xua/src/core/buffer/ep/ep_buffer.xc b/lib_xua/src/core/buffer/ep/ep_buffer.xc index 2c4698c0..27308aa1 100644 --- a/lib_xua/src/core/buffer/ep/ep_buffer.xc +++ b/lib_xua/src/core/buffer/ep/ep_buffer.xc @@ -38,8 +38,9 @@ extern unsigned int g_curSamFreqMultiplier; #endif -/* Global var for speed. Related to feedback. Used by input stream to determine IN packet size */ -unsigned g_speed; +/* Initialise so we get a sensible packet size until we start properly calculating feedback in the SoF case */ +/* Without this, zero size packets fill the input FIFO and take time to clear out when feedback starts */ +unsigned g_speed = (AUDIO_CLASS == 2) ? (DEFAULT_FREQ/8000) << 16 : (DEFAULT_FREQ/1000) << 16; unsigned g_freqChange = 0; unsigned feedbackValid = 0; From acd5e5f951a3119fba0cf505dd5cd5f4713ccc44 Mon Sep 17 00:00:00 2001 From: Ed Date: Wed, 2 Sep 2020 08:37:39 +0100 Subject: [PATCH 4/4] Version bump, changelog and source --- CHANGELOG.rst | 6 ++++++ lib_xua/module_build_info | 2 +- lib_xua/src/core/buffer/ep/ep_buffer.xc | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 211bf644..4a20b566 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ lib_xua Change Log ================== +0.1.3 +----- + + * RESOLVED: Zero length input packets generated before enumeration causing + I2S timing pushout at startup + 0.1.2 ----- diff --git a/lib_xua/module_build_info b/lib_xua/module_build_info index fca1e1f9..d7c76ec1 100644 --- a/lib_xua/module_build_info +++ b/lib_xua/module_build_info @@ -13,7 +13,7 @@ MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3 -DREF_CLK_FREQ=100 -fasm-linenum -fcomment-a OPTIONAL_HEADERS += xua_conf.h -VERSION = 0.1.2 +VERSION = 0.1.3 DEPENDENT_MODULES = lib_logging(>=2.1.0) lib_xud(>=0.1.0) diff --git a/lib_xua/src/core/buffer/ep/ep_buffer.xc b/lib_xua/src/core/buffer/ep/ep_buffer.xc index 27308aa1..433fc475 100644 --- a/lib_xua/src/core/buffer/ep/ep_buffer.xc +++ b/lib_xua/src/core/buffer/ep/ep_buffer.xc @@ -1,4 +1,4 @@ -// Copyright (c) 2011-2018, XMOS Ltd, All rights reserved +// Copyright (c) 2011-2020, XMOS Ltd, All rights reserved #ifndef NO_USB #include #include