diff --git a/src/audio/host-zephyr.c b/src/audio/host-zephyr.c index 30449f3c0edf..de55b8d073ac 100644 --- a/src/audio/host-zephyr.c +++ b/src/audio/host-zephyr.c @@ -957,6 +957,9 @@ static int host_verify_params(struct comp_dev *dev, #endif /* configure the DMA params and descriptors for host buffer IO */ +/** + * @brief Configure host DMA, limiting HDA buffers to the 16-bit DGMBS range. + */ int host_common_params(struct host_data *hd, struct comp_dev *dev, struct sof_ipc_stream_params *params, notifier_callback_t cb) { @@ -1046,6 +1049,18 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev, if (hd->ipc_host.dma_buffer_size != 0) buffer_size_preferred = ROUND_UP(hd->ipc_host.dma_buffer_size, buffer_size); + /* Keep deep buffers within the 16-bit HDA DGMBS limit and whole allocation units. */ + if (hd->dma->plat_data.caps & SOF_DMA_CAP_HDA) { + uint32_t max_buffer_size = ROUND_DOWN(UINT16_MAX, buffer_size); + + if (!max_buffer_size) { + comp_err(dev, "HDA DMA minimum buffer size %u exceeds 16-bit limit", + buffer_size); + return -EINVAL; + } + buffer_size_preferred = MIN(buffer_size_preferred, max_buffer_size); + } + /* alloc DMA buffer or change its size if exists */ /* * Host DMA buffer cannot be shared. So we actually don't need to lock, diff --git a/tools/topology/topology2/platform/intel/uaol-deep-buffer.conf b/tools/topology/topology2/platform/intel/uaol-deep-buffer.conf index 572c9fc57a78..1d2f6cc83d14 100644 --- a/tools/topology/topology2/platform/intel/uaol-deep-buffer.conf +++ b/tools/topology/topology2/platform/intel/uaol-deep-buffer.conf @@ -15,11 +15,19 @@ Object.Pipeline.deepbuffer-playback [ Object.Widget.host-copier.1 { stream_name $UAOL_DB_PCM_NAME pcm_id $UAOL_DB_PCM_ID + + } Object.Widget.gain.1 { Object.Control.mixer.1 { name 'Pre Mixer $UAOL_DB_PCM_NAME Volume' } + + + } + Object.Widget.mixin.1 { + + } } ] @@ -37,14 +45,19 @@ Object.PCM.pcm [ Object.PCM.pcm_caps.1 { name $UAOL_DB_PCM_NAME formats 'S16_LE,S24_LE,S32_LE' + channels_min $UAOL_CHANNELS_MIN + channels_max $UAOL_CHANNELS_MAX + rates $UAOL_RATES + rate_min $UAOL_RATE_MIN + rate_max $UAOL_RATE_MAX # To avoid DMA spinning on a buffer we need bigger # buffer than the host buffer size, let's say twice as # big - # (S16_LE, Stereo, 48KHz, DEEPBUFFER_FW_DMA_MS) * 2 + # (S16_LE, minimum channels/rate, DEEPBUFFER_FW_DMA_MS) * 2 # # Note: The lower limit for the buffer size is rate # dependent - buffer_size_min "$[(((2 * $channels_min) * 48) * $DEEPBUFFER_FW_DMA_MS) * 2]" + buffer_size_min "$[(((((2 * $channels_min) * $rate_min) * $DEEPBUFFER_FW_DMA_MS) * 2) / 1000)]" } } ] diff --git a/tools/topology/topology2/platform/intel/uaol-deep-buffer1.conf b/tools/topology/topology2/platform/intel/uaol-deep-buffer1.conf index 242912325a5f..61c3ca3d3da9 100644 --- a/tools/topology/topology2/platform/intel/uaol-deep-buffer1.conf +++ b/tools/topology/topology2/platform/intel/uaol-deep-buffer1.conf @@ -11,11 +11,19 @@ Object.Pipeline.deepbuffer-playback [ Object.Widget.host-copier.1 { stream_name $UAOL_DB1_PCM_NAME pcm_id $UAOL_DB1_PCM_ID + + } Object.Widget.gain.1 { Object.Control.mixer.1 { name 'Pre Mixer $UAOL_DB1_PCM_NAME Volume' } + + + } + Object.Widget.mixin.1 { + + } } ] @@ -33,14 +41,19 @@ Object.PCM.pcm [ Object.PCM.pcm_caps.1 { name $UAOL_DB1_PCM_NAME formats 'S16_LE,S24_LE,S32_LE' + channels_min $UAOL_CHANNELS_MIN + channels_max $UAOL_CHANNELS_MAX + rates $UAOL_RATES + rate_min $UAOL_RATE_MIN + rate_max $UAOL_RATE_MAX # To avoid DMA spinning on a buffer we need bigger # buffer than the host buffer size, let's say twice as # big - # (S16_LE, Stereo, 48KHz, DEEPBUFFER_FW_DMA_MS) * 2 + # (S16_LE, minimum channels/rate, DEEPBUFFER_FW_DMA_MS) * 2 # # Note: The lower limit for the buffer size is rate # dependent - buffer_size_min "$[(((2 * $channels_min) * 48) * $DEEPBUFFER_FW_DMA_MS) * 2]" + buffer_size_min "$[(((((2 * $channels_min) * $rate_min) * $DEEPBUFFER_FW_DMA_MS) * 2) / 1000)]" } } ] diff --git a/tools/topology/topology2/platform/intel/uaol-generic.conf b/tools/topology/topology2/platform/intel/uaol-generic.conf index 41816ca3e369..378ce324d903 100644 --- a/tools/topology/topology2/platform/intel/uaol-generic.conf +++ b/tools/topology/topology2/platform/intel/uaol-generic.conf @@ -28,9 +28,8 @@ # goes. The kernel narrows the PCM down to what the connected device actually # supports. # -# The deep buffer PCM is left at 48 kHz stereo, the default of the -# deepbuffer-playback pipeline. It can only join the mixer while the normal -# playback PCM runs at that format, or is not running at all. +# The deep buffer PCM carries the same formats as normal playback. Both PCMs +# can join the mixer when their rates and channel counts match. # Deep buffer playback, included when UAOL_DEEP_BUFFER is true and the DMA # buffer is 1 - 1000 ms. The deep buffers of the UAOL streams are instances of