Skip to content

Conversation

@singalsu
Copy link

This patch lets a capture PCM to operate with deep buffer by taking dsp_max_burst_size_in_ms from topology if it is defined. Earlier the value from topology was omitted for capture.

If not defined, the maximum burst size for capture is set similarly as before to one millisecond.

@singalsu
Copy link
Author

This needs thesofproject/sof#10393 . Still it looks like DMA transfers are 48 frames / 1 ms, so more work needed. Also seems playback DMA transfers are the same, so I'm not sure I'm looking the right thing.

@singalsu singalsu force-pushed the capture_deep_buffer_enable branch from 7526ff1 to e3a9b28 Compare November 27, 2025 11:48
@singalsu
Copy link
Author

This needs thesofproject/sof#10393 . Still it looks like DMA transfers are 48 frames / 1 ms, so more work needed. Also seems playback DMA transfers are the same, so I'm not sure I'm looking the right thing.

The update patch works, in FW the DMA reload now happens at about every 10th host copier copy. But there are in captured audio small glitches every few tens of ms, that is likely a FW issue.

kv2019i
kv2019i previously approved these changes Dec 12, 2025
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

I think @singalsu you can push this for review and merge. This works for me (I don't get the same problem on a SDW setup as you did with one HDA), and this does not depend on the FW part. The kernel part can go in whenever and the deepbuffer capability is just not enabled if topology doesn't support.

swidget->widget->name,
deep_buffer_dma_ms ? " (using Deep Buffer)" : "",
max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms),
copier_data->gtw_cfg.dma_buffer_size);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a helpful new dev_dbg()!

@singalsu singalsu marked this pull request as ready for review December 12, 2025 17:32
bardliao
bardliao previously approved these changes Dec 15, 2025
case snd_soc_dapm_aif_out:
copier_data->gtw_cfg.dma_buffer_size =
SOF_IPC4_MIN_DMA_BUFFER_SIZE * copier_data->base_config.obs;
max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms) *
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you sure about this?
should not we have similar configuration as with playback that the DAI has different buffer size?

case snd_soc_dapm_dai_out:
	copier_data->gtw_cfg.dma_buffer_size =
			SOF_IPC4_MIN_DMA_BUFFER_SIZE * copier_data->base_config.obs;
	break;
case snd_soc_dapm_aif_out:
	copier_data->gtw_cfg.dma_buffer_size =
		SOF_IPC4_MIN_DMA_BUFFER_SIZE * copier_data->base_config.obs;
		max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms) *
		copier_data->base_config.obs;
	dev_dbg(sdev->dev, "copier %s, dma buffer%s: %u ms (%u bytes)",
		swidget->widget->name,
		deep_buffer_dma_ms ? " (using Deep Buffer)" : "",
		max((u32)SOF_IPC4_MIN_DMA_BUFFER_SIZE, deep_buffer_dma_ms),
		copier_data->gtw_cfg.dma_buffer_size);
	break;

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah the DAI doesnt operate with deep buffer dma sizes and it will be ignored but best to seprate the DAI and aif widgets here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

good catch @ujfalusi , this does work, but will add to the latency. add not caught by our latency test as that doesn't cover the deepbuffer PCMs (at least yet).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or on second look, I don't think this has material impact as the deep-buffer token is not set unless type is aif_in/out. Test confirms this:

[  509.183219] snd_sof:sof_ipc4_prepare_copier_module: sof-audio-pci-intel-mtl 0000:00:1f.3: copier dai-copier.DMIC.dmic01.capture, dma buffer: 4 ms (3072 bytes)
[  509.183276] snd_sof:sof_ipc4_prepare_copier_module: sof-audio-pci-intel-mtl 0000:00:1f.3: copier host-copier.46.capture, dma buffer (using Deep Buffer): 10 ms (7680 bytes)

... but agreed, probably for maintainability, better to keep code aligned with capture+playback here if they should be behaving the same (and not have two different looking pieces of code that in the end do the same thing).

spcm->stream[dir].dsp_max_burst_size_in_ms = 1;
else
/* Capture data is copied from DSP to host in 1ms bursts */
sps->dsp_max_burst_size_in_ms = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we still need this? Won't this negate the benefits of deep buffering for capture?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought this was only for the "!sps->dsp_max_burst_size_in_ms" case where a larger value is not specific in topoligy. Then we default to 1ms (as we did before). Right @singalsu ?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that's correct. If there is no value from topology, the dsp_max_burst_size_in_ms is set to 1 (millisecond) just like it was always for capture before this patch.

Copy link
Member

Choose a reason for hiding this comment

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

Do we call this out via dev_warn() ? We should.

This patch lets a capture PCM to operate with deep buffer
by taking dsp_max_burst_size_in_ms from topology if it is
defined. Earlier the value from topology was omitted for
capture.

If not defined, the maximum burst size for capture is set
similarly as before to one millisecond.

The dma_buffer_size is set similarly as for playback from
largest of deep_buffer_dma_ms or SOF_IPC4_MIN_DMA_BUFFER_SIZE
times OBS.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu dismissed stale reviews from bardliao and kv2019i via c365ecd December 15, 2025 18:01
@singalsu singalsu force-pushed the capture_deep_buffer_enable branch from e3a9b28 to c365ecd Compare December 15, 2025 18:01
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.

6 participants