Repository navigation
Conversation
lgirdwood
force-pushed
the
topic/compress-mmap
branch
2 times, most recently
from
October 4, 2026 18:56
aca652d to
0846e93
Compare
Support mapping the compressed DMA buffer to user space by implementing
snd_compr_mmap(). If the driver provides stream->ops->mmap, delegate to
it; otherwise fallback to snd_dma_buffer_mmap() on runtime->dma_buffer_p.
Introduce the SNDRV_COMPRESS_ACK ioctl (_IOW('C', 0x24, __u64)) to allow
user space to acknowledge written bytes when operating in mmap mode.
This callback directly mirrors the regular ALSA PCM mmap flow: in ALSA
PCM, user space writes to the mmap buffer and commits frames via
snd_pcm_mmap_commit(), which advances appl_ptr and invokes
substream->ops->ack(substream) via pcm_lib_apply_appl_ptr().
Similarly, for compressed streams, SNDRV_COMPRESS_ACK informs the driver
of committed bytes, validates the byte count against available buffer space,
updates runtime->total_bytes_available (analogous to advancing appl_ptr),
invokes the optional stream->ops->ack(stream, bytes) driver hook,
transitions state from SETUP to PREPARED on initial commit, and wakes up
waiters on runtime->sleep.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add snd_soc_component_compr_mmap() to iterate over runtime components and invoke component->driver->compress_ops->mmap() when defined. Hook up soc_compr_mmap() in soc_compr_ops and soc_compr_dyn_ops so that user-space mmap requests on compressed ALSA devices are routed to the underlying ASoC component drivers. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Implement sof_ipc4_compr_mmap() to map the runtime DMA buffer (runtime->dma_buffer_p or &stream->dma_buffer) into user space via snd_dma_buffer_mmap(). Implement sof_ipc4_compr_ack() callback and align SOF_IPC4_COMPR_MIN_FRAGMENT_SIZE to 128 bytes to match Intel HDA/ACE DMA burst hardware boundaries. For SOF on Intel HDA and ACE platforms, the host-to-DSP transfer is driven autonomously by hardware DMA stream descriptors from host DRAM without requiring per-block register writes or mailbox doorbells, exactly as in standard SOF PCM where ops->ack is a no-op / NULL. The callback is implemented as a no-op here to fulfill the struct snd_compress_ops interface, maintain symmetry with platforms requiring doorbells/cache flushing, and permit future platform-specific notifications. Register .mmap and .ack in sof_ipc4_compressed_ops. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
lgirdwood
force-pushed
the
topic/compress-mmap
branch
from
October 4, 2026 19:01
0846e93 to
6a16d6e
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.
Overview
This series adds memory-mapped (MMAP) buffer support to the ALSA compress-offload subsystem and implements the corresponding callbacks for ASoC and the Sound Open Firmware (SOF) IPC4 driver.
Currently, ALSA compressed streams only support copy-based data transfer (
snd_compr_write_data()/snd_compr_read()), andsnd_compr_mmap()unconditionally returns-ENXIO. For high-throughput, low-latency audio offload engines (such as hardware DSP spatial audio, voice processing, and adjacent metadata/PCM streaming in Steam Audio offload), user space needs direct, zero-copy MMAP access to the DMA buffer ring.Alignment with Regular ALSA PCM Flow
This implementation directly mirrors the established ALSA PCM MMAP architectural pattern:
Commit / Progress Notification:
pcm_lib_apply_appl_ptr()), when user space writes to the mapped buffer and callssnd_pcm_mmap_commit(), the core advancesappl_ptrand invokes the optional driver callbacksubstream->ops->ack(substream).SNDRV_COMPRESS_ACKserves the exact same role: user space commits written bytes, the core advancesruntime->total_bytes_available(the compress equivalent ofappl_ptr), and callsstream->ops->ack(stream, bytes).Why SOF's
ackis a No-Op:ops->ackis unused / NULL).struct snd_compress_ops, preserve subsystem symmetry with doorbell-driven platforms, and provide a hook for future platform tracing.Summary of Changes
ALSA Compress Core & UAPI (
sound/core/compress_offload.c,include/uapi/sound/compress_offload.h):snd_compr_mmap():stream->ops->mmap(stream, vma)when supported by the driver.snd_dma_buffer_mmap(runtime->dma_buffer_p, vma)if available.SNDRV_COMPRESS_ACKioctl (_IOW('C', 0x24, __u64)):stream->ops->ack(stream, bytes).runtime->total_bytes_available.SNDRV_PCM_STATE_SETUPtoSNDRV_PCM_STATE_PREPAREDon initial commit.&runtime->sleep).ASoC Compress Layer (
include/sound/soc-component.h,sound/soc/soc-component.c,sound/soc/soc-compress.c):snd_soc_component_compr_mmap()to iterate over runtime components and callcomponent->driver->compress_ops->mmap()..mmap = soc_compr_mmapin bothsoc_compr_opsandsoc_compr_dyn_ops.SOF IPC4 Compressed Driver (
sound/soc/sof/ipc4-compress.c):sof_ipc4_compr_mmap()to map the runtime DMA buffer directly usingsnd_dma_buffer_mmap().sof_ipc4_compr_ack()callback (no-op for autonomous HDA/ACE DMA).SOF_IPC4_COMPR_MIN_FRAGMENT_SIZEto 128 bytes to match Intel HDA / ACE DMA burst hardware constraints..mmapand.ackinsof_ipc4_compressed_ops.Testing & Verification
sound/core/compress_offload.o,sound/soc/soc-component.o,sound/soc/soc-compress.o,sound/soc/sof/ipc4-compress.o).Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com