Skip to content

DVI audio uses a third of the RAM, so Fruit Jam has sound on by default - #11574

Open
mikeysklar wants to merge 8 commits into
adafruit:mainfrom
mikeysklar:fruitjam-dvi-audio-main
Open

mikeysklar wants to merge 8 commits into
adafruit:mainfrom
mikeysklar:fruitjam-dvi-audio-main

Conversation

@mikeysklar

Copy link
Copy Markdown
Collaborator

What

DVI audio now uses 37 KB of RAM instead of 118 KB.

That leaves room to turn sound on by default on Fruit Jam, as board.DVI_AUDIO.

Video: a tone, then a short tune, through the monitor speakers

Why

tannewt asked for sound on by default in #11510.

At 118 KB it did not fit next to the 8-bit boot display.

Audio RAM Before After
640 wide 118 KB 37 KB
320 wide 144 KB 50 KB
640x480 8-bit display plus audio MemoryError fits
Change Detail
board.DVI_AUDIO Set up with the boot display. None after release_displays()
Turn off CIRCUITPY_PICODVI_AUDIO = false in settings.toml
Boot display 640x480, 8-bit

Testing

Adafruit Fruit Jam, Linux host, monitor with speakers.

Test Result
board_audio.py, audioout_formats.py, audioout_bad_values.py, audioout_release.py pass
Cold boots 10/10
Playback rate error 0.03 to 0.1%
Python speed while playing 23% slower (20% before)
Also built Metro RP2350, Feather RP2040 DVI

AI assistance

Claude Code wrote the code and ran the tests.

Fruit Jam now sends sound through the DVI cable of its boot display, as
board.DVI_AUDIO. It is set up in board init, before the VM heap takes
internal RAM, and is skipped quietly if it doesn't fit. Set
CIRCUITPY_PICODVI_AUDIO = false in settings.toml to turn it off.

To make that fit next to the 640x480 8-bit boot display, AudioOut now
sends audio from a pool of 160 encoded packets referenced by 280 slots,
refilled from a 2.5 ms repeating timer, instead of encoding every line.
Audio RAM drops from 118 KB to 37 KB at 640 wide.

Packets are full 4-sample packets, and the ACR N is picked per pixel clock
so frames repeat exactly, so idle frames need no refill. Setup fails
cleanly if the refill timer can't be added, and after a long stall the
refill skips whole frames instead of walking every slot.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tannewt

tannewt commented Oct 13, 2026

Copy link
Copy Markdown
Member

DVI audio now uses 37 KB of RAM instead of 118 KB.

The title and message aren't very helpful. I'd really like to know how RAM use was dropped by a third.

@mikeysklar

Copy link
Copy Markdown
Collaborator Author

That is good feedback. Usually, I try to avoid the how as it is full of burdensome details.

I had been working on Arduino Audio DVI in parallel and noticed it was 4x smaller so wanted to shrink things down on the CP side.

  • Edit one frame in place, no double buffering (~44 KB)
  • Shared line prefix and suffix, 128 B islands only (~19 KB)
  • One DMA command list instead of three (~13 KB)
  • Only sample packets buffered, small 13 ms pool (~5 KB)

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be simplified a bit. Thanks for working to get it on by default!

Comment thread ports/raspberrypi/boards/adafruit_fruit_jam/mpconfigboard.h Outdated
Comment thread docs/environment.rst Outdated
Comment thread ports/raspberrypi/boards/adafruit_fruit_jam/pins.c Outdated
Comment thread ports/raspberrypi/common-hal/picodvi/AudioOut.c Outdated
mikeysklar and others added 4 commits October 13, 2026 12:17
Drop CIRCUITPY_BOARD_DVI_AUDIO. Boards that set DEFAULT_DVI_BUS_CLK_DP
now get board.DVI_AUDIO, turned off with CIRCUITPY_PICODVI_AUDIO.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mikeysklar

Copy link
Copy Markdown
Collaborator Author

Also tested on a Metro RP2350 with the boot display forced on: board.DVI_AUDIO comes up, the picodvi manual tests pass, and 10/10 cold boots. Fixed a leftover Fruit Jam only docstring in 80c405d.

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One switch about board. Maybe we also need a runtime attribute for audio out?

Comment thread ports/raspberrypi/boards/adafruit_fruit_jam/pins.c Outdated
Boards with a default DVI display have no board.DISPLAY, so the audio
output follows supervisor.runtime.display instead of being a board entry.
It is None on ports without DVI audio, when CIRCUITPY_PICODVI_AUDIO is
false, and after displayio.release_displays().

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sphinx cannot link it, so the docs build failed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mikeysklar

Copy link
Copy Markdown
Collaborator Author

@tannewt Ready for another look.

Removed the board.DVI_AUDIO entries and added a read-only supervisor.runtime.audio, like supervisor.runtime.display, in 6ad3d7f.

Fixed the broken docs reference in fd4d303.

Tested on a Feather RP2350: the picodvi manual test passes and a PicoTTS demo plays through it.

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment nit. Good otherwise. Thanks!

Comment thread shared-bindings/supervisor/Runtime.c Outdated
kk

Co-authored-by: Scott Shawcroft <scott@tannewt.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants