feat(d211-linux): audio and backlight host modules - #417
Draft
boa-z wants to merge 7 commits into
Draft
Conversation
ui_render, ui_render_scaled, and ui_render_incremental_scaled are exported C ABI functions the raster implementation already provides; the public header only declared the unscaled incremental form.
The D211DBV runs Luban Linux 5.10 on RISC-V with an 800x480 32bpp panel and a GT911 touchscreen. The host presents the software raster surface through /dev/fb0, probes the framebuffer geometry and channel bitfields with FBIOGET_VSCREENINFO/FBIOGET_FSCREENINFO, fixes the visible page with FBIOPAN_DISPLAY, and finds the touch device by capability instead of eventN. The build runs on a canonical Ubuntu builder with the Luban Xuantie GCC wrapper and sysroot; D211_LUBAN_SDK selects the SDK root. The final link uses LLVM LLD from the pinned Rust nightly because binutils 2.35 rejects modern RISC-V ELF attributes. The private d211-linux-dev target (host ABI 11) renders the full 800x480 panel at raster density 1, and tools/d211-linux/remote-build.sh wraps sync, build, and artifact fetch with the builder taken from D211_REMOTE.
The touch backend now runs the protocol-B slot state machine (ABS_MT_SLOT, ABS_MT_TRACKING_ID, per-slot positions) and delivers every live contact through pocket_runtime_tick_contacts(), with the bounds hit resolved once at each contact's own down edge. Single-touch devices still map to one id-0 contact, and the host tracks up to D211_MAX_CONTACTS (8). Validated against the panel with a local probe: five simultaneous contacts, each id keeping its own coordinates and down-edge hit. stop-ui now sends SIGKILL because test_lvgl ignores SIGTERM and keeps the panel.
The C runtime could install only the ui surface; native hosts had no way to
expose device services to the guest. Add two optional host op tables:
- PocketAudioOps installs globalThis.audio with the method set the audio spec
already pins (contracts/spec/audio.ts); hosts fill the table before boot and
leave it absent otherwise (the framework player stays a no-op).
- PocketBacklightOps installs globalThis.backlight { get, set(percent) } —
pinned here until a display spec lands.
Both follow the existing ui-module installation shape; no wire changes, no
behavior change for hosts that pass no tables.
boa-z
force-pushed
the
feat/d211-host-modules
branch
from
September 12, 2026 06:49
0aea628 to
f61457f
Compare
Author
|
Validation update (d211, ALSA): the credit queue originally reported one event per fed chunk, which flooded the 32-slot queue and dropped the |
Wire two host modules into the d211 runtime:
- audio: PocketAudioOps on top of one `aplay -t raw` child per stream and a
feeder thread over a frame ring; credits follow consumption, starvation is
edge-reported as underrun, endStream drains then reports ended; volume is a
soft gain. Matches contracts/spec/audio.ts; the framework player now works
unchanged (load("btn") -> createStream -> writePcm -> play -> credit).
- backlight: PocketBacklightOps over /sys/class/backlight (percent 0-100).
main.c sets both tables before boot; build-runtime.sh compiles the two new
sources and links -lpthread. The runtime-side hook is the quickjs-c commit
below (stacked PR).
boa-z
force-pushed
the
feat/d211-host-modules
branch
from
September 12, 2026 17:04
f61457f to
ae01c71
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked / draft: do not review before #407 (d211 host) and #416 (quickjs-c host-module hook) merge. This branch carries both until then; after they land it rebases to the single audio/backlight commit.
What
hosts/d211-linux/audio.c|h:PocketAudioOpson oneaplay -t rawchild per stream plus a feeder thread over a 16384-frame ring — credits follow consumption, starvation is edge-reported asunderrun,endStreamdrains then reportsended, volume is a soft gain.hosts/d211-linux/backlight.c|h:PocketBacklightOpsover/sys/class/backlight/<name>/brightness, percent 0-100.main.cinstalls both tables before boot;build-runtime.shcompiles the new sources and links-lpthread.Validation (device)
host modules: audio + backlight,audio createStream handle=0 rate=22050 ch=2(framework player loadedaudio:wav.btnfrom the pak).writePcm→play(aplay child) → poll{"t":"credit",...}→endStreamwhen the 4984-frame clip drains.