mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-05 12:24:42 +01:00
CPU5 USB1: reduce multichannel USB copy workload and identify the beta build
This commit is contained in:
1 parent
009faf9776
commit
6cb8561fa9
7 files changed
+70
-15
No files matched your search
@@ -0,0 +1,9 @@
|
||||
# 0.9.9 cpu5usb1: USB multichannel trial
|
||||
|
||||
Based on CPU5 (009faf97764cf872fd5f392155d944a684127132). The USB copy loops snapshot the volatile mode once and walk ring slots instead of recalculating them for every sample/channel. Rates, timing, interpolation and DSP remain unchanged; uint32 rollover is preserved.
|
||||
|
||||
Validation passed for the target layout/instruction budgets, 157 golden audio renders, audio/concurrency, USB/stems, drift/starvation and Android core checks. In a 10-second simulation, mode reads fall from 6,270,730 to 74,930 (8 channels) and 7,155,100 to 76,772 (10 channels), with identical delivered frame counts and zero lost/repeated/moved samples. These are operation counts, not measured hardware CPU savings. Hardware confirmation of CPU reduction and resolution of recorded glitches is still pending.
|
||||
|
||||
The complete host suite retains a preexisting DJ centre golden mismatch against its historical 0.9.0 reference. Original CPU5 and this USB trial produce identical complete DJ output and the same sole legacy failure (894b0fcf vs 8b898fe6); the golden was preserved. An offline Gradle cache miss was resolved by rerunning with dependencies available. Optional valgrind, Emscripten and official V15 restore checks were unavailable.
|
||||
|
||||
Default package identity is FM-1_909 and version is v0.9.9-cpu5usb1, matching the validated --release build. Validated package SHA256: daac8c63762e483be36167db560fdcd117816392376b35854b57ab2d49a57037. Test with the same phone APK/song first to isolate the firmware change.
|
||||
@@ -38,7 +38,7 @@
|
||||
#define FELUCCA_ID "FM-1_900" /* package identity (build.py: the .fwsc marker string) */
|
||||
#endif
|
||||
#ifndef FELUCCA_VERSION
|
||||
#define FELUCCA_VERSION "v0.9.9-cpu5" /* CPU fixes preview, based on stable JIANT 0.9.9 */
|
||||
#define FELUCCA_VERSION "v0.9.9-cpu5usb1" /* CPU fixes preview, based on stable JIANT 0.9.9 */
|
||||
#endif
|
||||
#if FELUCCA_OTA && !FELUCCA_FLASH
|
||||
#error "FELUCCA_OTA needs FELUCCA_FLASH"
|
||||
|
||||
+28
-12
@@ -1453,21 +1453,28 @@ static __attribute__((noinline)) void uac_tap(const int32_t *out, uint32_t n)
|
||||
* reference the host finds its latency against) */
|
||||
static __attribute__((noinline)) void uac_tap8(uint32_t n)
|
||||
{
|
||||
uint32_t w = ua_w, i, k;
|
||||
/* USB mode changes stop/re-enumerate the stream outside the audio IRQ.
|
||||
* Snapshot it once: UA_FW reads volatile fx_stems, not a loop constant.
|
||||
* Walk slots rather than recomputing the 409-frame modulo for each sample. */
|
||||
uint32_t w = ua_w, i, k, fw = UA_FW;
|
||||
uint32_t nf = fw == 5u ? UA_NF10 : UA_N;
|
||||
uint32_t slot = fw == 5u ? w % UA_NF10 : w & (UA_N - 1u);
|
||||
if (!uac.feed)
|
||||
return;
|
||||
if (UA_NF - (w - ua_r) < n) {
|
||||
if (nf - (w - ua_r) < n) {
|
||||
uac.overruns++;
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
uint32_t *f = &ua_ring[ua_slot(w + i) * UA_FW];
|
||||
if ((uint32_t)(w + i) == 0u) slot = 0; /* preserve the free-running index's uint32 wrap */
|
||||
uint32_t *f = &ua_ring[slot * fw];
|
||||
for (k = 0; k < 3u; k++)
|
||||
f[k] = (uint32_t)(uint16_t)uac_s16(stem_buf[2u * k][i]) | (uint32_t)(uint16_t)uac_s16(stem_buf[2u * k + 1u][i]) << 16;
|
||||
f[3] = (uint32_t)(uint16_t)uac_s16(stem_fx[0][i]) | (uint32_t)(uint16_t)uac_s16(stem_fx[1][i]) << 16;
|
||||
if (UA_FW == 5u)
|
||||
if (fw == 5u)
|
||||
f[4] = (uint32_t)(uint16_t)uac_s16(stem_buf[6][i]) |
|
||||
(uint32_t)(uint16_t)(uin_on ? (int16_t)((uin_l[i] + uin_r[i]) >> 1) : 0) << 16;
|
||||
if (++slot == nf) slot = 0;
|
||||
}
|
||||
RING_PUBLISH();
|
||||
ua_w = w + n;
|
||||
@@ -1481,8 +1488,11 @@ static __attribute__((noinline)) void uac_tap8(uint32_t n)
|
||||
static __attribute__((noinline)) void uac_squeeze(uint32_t *d, uint32_t r, uint32_t n)
|
||||
{
|
||||
uint32_t i, j, fw = UA_FW, st = (16384u << 8) / (n + 1u), q = st;
|
||||
uint32_t nf = fw == 5u ? UA_NF10 : UA_N;
|
||||
uint32_t slot = fw == 5u ? r % UA_NF10 : r & (UA_N - 1u);
|
||||
for (i = 0; i < n; i++, q += st) {
|
||||
const uint32_t *a = &ua_ring[ua_slot(r + i) * fw], *b = &ua_ring[ua_slot(r + i + 1u) * fw];
|
||||
uint32_t next = (uint32_t)(r + i + 1u) == 0u || slot + 1u == nf ? 0u : slot + 1u;
|
||||
const uint32_t *a = &ua_ring[slot * fw], *b = &ua_ring[next * fw];
|
||||
int32_t w = (int32_t)(q >> 8); /* (i + 1) / (n + 1), Q14 */
|
||||
for (j = 0; j < fw; j++) {
|
||||
int32_t al = (int16_t)a[j], ah = (int16_t)(a[j] >> 16);
|
||||
@@ -1490,6 +1500,7 @@ static __attribute__((noinline)) void uac_squeeze(uint32_t *d, uint32_t r, uint3
|
||||
int32_t h = ah + ((((int32_t)(int16_t)(b[j] >> 16) - ah) * w + 8192) >> 14);
|
||||
d[i * fw + j] = (uint32_t)(uint16_t)l | (uint32_t)(uint16_t)h << 16;
|
||||
}
|
||||
slot = next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1497,7 +1508,8 @@ static __attribute__((noinline)) void uac_squeeze(uint32_t *d, uint32_t r, uint3
|
||||
* primed, silence. An empty ring repeats the last frame. Returns the frame count. */
|
||||
static uint32_t uac_packet(uint32_t *d)
|
||||
{
|
||||
uint32_t n = 44u, r, fill, k, i, pad = UA_FW > 1u ? UA_PAD_STEMS : 0u, lo = UA_LO + pad, hi = UA_HI + pad;
|
||||
uint32_t fw = UA_FW, n = 44u, r, fill, k, i;
|
||||
uint32_t pad = fw > 1u ? UA_PAD_STEMS : 0u, lo = UA_LO + pad, hi = UA_HI + pad;
|
||||
#if FELUCCA_UAC_48K
|
||||
if (uac.r48) { /* 48 frames a ms, no pattern */
|
||||
n = 48u;
|
||||
@@ -1513,7 +1525,7 @@ static uint32_t uac_packet(uint32_t *d)
|
||||
}
|
||||
}
|
||||
if (!uac.go || uac.ring48 != uac.r48) { /* not primed (at this rate) yet */
|
||||
for (i = 0; i < n * UA_FW; i++)
|
||||
for (i = 0; i < n * fw; i++)
|
||||
d[i] = 0;
|
||||
return n;
|
||||
}
|
||||
@@ -1535,16 +1547,20 @@ static uint32_t uac_packet(uint32_t *d)
|
||||
ua_r = r + n + 1u;
|
||||
uac.pkts++;
|
||||
uac.frames += n;
|
||||
for (i = 0; i < UA_FW; i++)
|
||||
uac.last[i] = d[(n - 1u) * UA_FW + i];
|
||||
for (i = 0; i < fw; i++)
|
||||
uac.last[i] = d[(n - 1u) * fw + i];
|
||||
return n;
|
||||
}
|
||||
k = fill < n ? fill : n;
|
||||
{
|
||||
uint32_t fw = UA_FW, j;
|
||||
for (i = 0; i < k; i++)
|
||||
uint32_t j, nf = fw == 5u ? UA_NF10 : UA_N;
|
||||
uint32_t slot = fw == 5u ? r % UA_NF10 : r & (UA_N - 1u);
|
||||
for (i = 0; i < k; i++) {
|
||||
if ((uint32_t)(r + i) == 0u) slot = 0;
|
||||
for (j = 0; j < fw; j++)
|
||||
d[i * fw + j] = ua_ring[ua_slot(r + i) * fw + j];
|
||||
d[i * fw + j] = ua_ring[slot * fw + j];
|
||||
if (++slot == nf) slot = 0;
|
||||
}
|
||||
if (k < n) {
|
||||
uac.underruns++;
|
||||
uac.owe += n - k;
|
||||
|
||||
@@ -31,8 +31,10 @@
|
||||
#define FELUCCA_UAC 1
|
||||
static void fm1_delay_ms(uint32_t ms) { (void)ms; }
|
||||
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
|
||||
static uint8_t t_stems; /* fx.c's fx_stems: 1 the 8 channels, 2 the 10 */
|
||||
static volatile uint8_t t_stems; /* match fx.c: the render must read the current USB mode */
|
||||
#ifndef UAC_STEMS
|
||||
#define UAC_STEMS() t_stems
|
||||
#endif
|
||||
#define UAC_STEMS_SRC 1
|
||||
static int32_t stem_buf[7][32], stem_fx[2][32];
|
||||
static int32_t uin_l[64], uin_r[64];
|
||||
|
||||
@@ -107,6 +107,8 @@ static void lcd_blit(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const uint1
|
||||
for (j = 0; j < h && y + j < 240u; j++)
|
||||
for (i = 0; i < w && x + i < 240u; i++) host_screen[(y + j) * 240u + x + i] = p[j * w + i];
|
||||
}
|
||||
/* audio.c counters read by CPU5's ABOUT page; no audio IRQ in this host harness. */
|
||||
static uint32_t shed_count, audio_halves;
|
||||
static struct { uint32_t stage; } felucca_dbg;
|
||||
#define FELUCCA_FLASH 0
|
||||
#ifndef FELUCCA_VERSION
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only
|
||||
* USB workload regression: use the real firmware stream, count mode reads as
|
||||
* well as checking delivered frames. This is an operation budget, not measured
|
||||
* hardware CPU usage. The old loops exceed 600 reads per packet. */
|
||||
#include <stdint.h>
|
||||
static uint64_t mode_reads;
|
||||
#define UAC_STEMS() (mode_reads++, t_stems)
|
||||
#define main stems_usb_suite_main
|
||||
#include "stems_usb_test.c"
|
||||
#undef main
|
||||
|
||||
int main(void)
|
||||
{
|
||||
for (uint32_t ch = 8; ch <= 10; ch += 2) {
|
||||
double now = 0;
|
||||
M.fs = 44117.6; M.load = .70; M.p_late = .043; M.late_max = 1.31;
|
||||
reset(ch, 0, 0);
|
||||
mode_reads = 0;
|
||||
sim(10.0, &now);
|
||||
printf("%u channels: %llu mode reads, %llu packets, %llu frames\n", ch,
|
||||
(unsigned long long)mode_reads, (unsigned long long)R.pkts, (unsigned long long)R.got);
|
||||
check("mode lookup bounded per packet/block, independent of frames/channels", mode_reads < R.pkts * 16u);
|
||||
check("each sample arrives once in its own channel", R.got > 440000u && !R.lost && !R.repeats && !R.moved && !R.partial);
|
||||
}
|
||||
return fails != 0;
|
||||
}
|
||||
Executable → Regular
+1
-1
@@ -51,7 +51,7 @@ SDK_SHA256 = {
|
||||
"cfg/eq_cfg_hw.bin": "41167491bffed4651750719c973d2758adeb9021a5670d02d6a53c85ed80ea7d",
|
||||
}
|
||||
|
||||
PRODUCT = "FM-1_900" # package identity; release builds are FM-1_9XY
|
||||
PRODUCT = "FM-1_909" # package identity; release builds are FM-1_9XY
|
||||
VERSION = None # FELUCCA_VERSION for release builds (default: firmware/src/felucca.c)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user