Repository navigation
zephyr: buffer streaming over RTIO - #1631
Open
MaureenHelm wants to merge 9 commits into
Open
MaureenHelm wants to merge 9 commits into
MaureenHelm wants to merge 9 commits into
Conversation
The thread, mutex and condvar pool defaults only covered the network transport, so a USB build fell back to the single-interpreter sizes and had too few threads for its pipes. Give USB the network defaults. Assisted-by: Claude:claude-opus-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Port the attribute path from sensor_sample_fetch()/sensor_channel_get() to sensor_read() and the sensor decoder API. Channels are tracked by struct sensor_chan_spec, which also keys the cached value so two channels of the same type no longer alias. Decoders that only answer for SENSOR_CHAN_ACCEL_XYZ, such as the ADXL345's, fall back to decoding XYZ and picking out the requested axis. Give the read's RTIO context two SQEs: the executor posts a completion before it frees the SQE, so a reader that outranks the completing thread would otherwise find none free on its next read. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Register an input buffer for every device that has scan elements, so the context XML describes the buffer explicitly. The first scan element decides its direction. Opening the buffer still fails with -ENOSYS until the buffer ops are implemented. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Check that the backend gives a buffer only to a device with scan elements, and that the first scan element sets the buffer's direction. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Implement the buffer and block ops behind a new LIBIIO_STREAMING option, default n, for iio_device drivers that return streaming resources from a new get_stream op. Implement it, with submit_read, frame_count and decode, for the sensor class. Blocks come from a per-device k_mem_slab sized at build time by the new buffer-block-count and buffer-block-size-max devicetree properties, and buffer descriptors from a system-wide slab, so a client cannot make the device allocate more than was budgeted. Devices that cannot stream reserve nothing. Each dequeue submits reads until the block is full, packing every enabled channel in milli-units at the offset libiio's iio_block_first() expects, saturated to the channel's width. Sensor channels become 32 bits wide so full-scale readings fit. Frames a capture holds past the end of the block are kept for the next dequeue. A capture that does not arrive within a new Kconfig timeout fails the dequeue, and cancelling or disabling the buffer wakes a blocked dequeue and waits for it. Captures use a mempool RTIO context of their own, so an attribute read cannot take one. That context allows one open buffer per device; a second open fails with -EBUSY. The thread, mutex and condvar pool defaults grow to cover an open buffer. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Add the libiio.stream ztest with a fixture sensor whose decoder only answers for the combined XYZ channel and yields known frames. Cover the block budget, sample packing, scan offsets against libiio's iio_block_first(), and one-shot capture including its refusals, cancellation and timeout. Before each test, check that no block or device is still held, so a leak fails the next test by name. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Devices that list stream-triggers in devicetree are armed with a multishot RTIO request on the first dequeue, so samples arrive at the device's own trigger rate instead of the client's dequeue rate. Stopping the stream waits, within a new Kconfig timeout, for the cancelled request to complete. A stream the device ends on a full mempool is re-armed once, so the overrun shows as a gap in the samples. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Configure the accelerometers on iio_pmod_acl, iio_eval_adxl362_ardz and iio_x_nucleo_iks4a1 to stream on their FIFO watermark. The lsm6dsv16x interrupt is wired to INT1 on D5, not INT2 on D4 as the upstream shield overlay describes, so override int1-gpios and drdy-pin. Assisted-by: Claude:claude-opus-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Add a pytest suite that streams each supported accelerometer shield, alone and two at once, through the Python bindings over IIOD USB, and checks the sample rate and magnitude. Captured samples are logged to a CSV file in the build directory. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
MaureenHelm
force-pushed
the
zephyr-streaming
branch
from
November 30, 2026 20:07
92a1102 to
f18cc2b
Compare
This branch has not been deployed
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.
PR Description
Adds buffer support to the Zephyr backend, so clients can stream samples from Zephyr devices through the standard libiio block API. Sensors are the first device class. It is gated by
CONFIG_LIBIIO_STREAMING(default n).Zephyr's sensor streaming is built on RTIO, which works much like io_uring:
The libiio backend uses this model directly:
Design decisions
stream-triggersis armed with a multishot request. A device without them is filled by on-demand reads.iio_deviceops. RTIO and the buffer lifecycle live instream.c.Future work
PR Type
PR Checklist