From ffb406f6c9e6d1e4c0abf9856fc91d146144ec02 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 23 Sep 2025 16:45:49 +0300 Subject: [PATCH] base_fw: Extend fw_config with information about the host buffer size The host buffer default or minimum size can be platform dependent and it is not know by the host. It is in sole discretion of the firmware and the hardware where it is running and can be changed by recompiling the firmware. Add new tlv item to fw_config with ID 33 and store the host DMA default period size, which is the indication of the default, minimum size of the host buffer in ms. Signed-off-by: Peter Ujfalusi --- src/audio/base_fw.c | 26 ++++++++++++++++++++++++++ src/include/ipc4/base_fw.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/src/audio/base_fw.c b/src/audio/base_fw.c index ed7f131d04e4..2d8655af163b 100644 --- a/src/audio/base_fw.c +++ b/src/audio/base_fw.c @@ -44,6 +44,27 @@ DECLARE_TR_CTX(basefw_comp_tr, SOF_UUID(basefw_uuid), LOG_LEVEL_INFO); static struct ipc4_system_time_info global_system_time_info; static uint64_t global_cycle_delta; +__cold static uint32_t get_host_buffer_size(void) +{ + struct sof_dma *dma_host; + uint32_t periods; + + assert_can_be_cold(); + + dma_host = sof_dma_get(SOF_DMA_DIR_HMEM_TO_LMEM, 0, SOF_DMA_DEV_HOST, + SOF_DMA_ACCESS_SHARED); + if (!dma_host) { + LOG_WRN("Failed to get host DMA channel"); + return 0; + } + + periods = dma_host->plat_data.period_count; + + sof_dma_put(dma_host); + + return periods; +} + __cold static int basefw_config(uint32_t *data_offset, char *data) { uint16_t version[4] = {SOF_MAJOR, SOF_MINOR, SOF_MICRO, SOF_BUILD}; @@ -124,6 +145,11 @@ __cold static int basefw_config(uint32_t *data_offset, char *data) tuple = tlv_next(tuple); + tlv_value_uint32_set(tuple, IPC4_FW_MIN_HOST_BUFFER_PERIODS, + get_host_buffer_size()); + + tuple = tlv_next(tuple); + /* add platform specific tuples */ basefw_vendor_fw_config(&plat_data_offset, (char *)tuple); diff --git a/src/include/ipc4/base_fw.h b/src/include/ipc4/base_fw.h index 25601b1209f0..86ee5f72a588 100644 --- a/src/include/ipc4/base_fw.h +++ b/src/include/ipc4/base_fw.h @@ -373,6 +373,8 @@ enum ipc4_fw_config_params { IPC4_DMI_FORCE_L1_EXIT = 28, /* FW context save on D3 entry */ IPC4_FW_CONTEXT_SAVE = 29, + /* Minimum size of host buffer in ms */ + IPC4_FW_MIN_HOST_BUFFER_PERIODS = 33, /* Total number of FW config parameters */ IPC4_FW_CFG_PARAMS_COUNT, /* Max config parameter id */