Skip to content

Commit

Permalink
audio: base_fw: add platform layer to hw_config data
Browse files Browse the repository at this point in the history
Some of the HW_CONFIG fields are platform specific and cannot be
filled with generic means in generic code.

Handle this data via a simple platform abstraction to hook
platform specific code to HW_CONFIG handling. Move out existing
code for Intel cAVS and ACE platforms.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
  • Loading branch information
kv2019i committed Apr 9, 2024
1 parent f77bdfb commit 3a658e0
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/audio/base_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static int basefw_config(uint32_t *data_offset, char *data)
static int basefw_hw_config(uint32_t *data_offset, char *data)
{
struct sof_tlv *tuple = (struct sof_tlv *)data;
uint32_t plat_data_offset = 0;
uint32_t value;

tlv_value_uint32_set(tuple, IPC4_CAVS_VER_HW_CFG, HW_CFG_VERSION);
Expand All @@ -147,19 +148,11 @@ static int basefw_hw_config(uint32_t *data_offset, char *data)
tlv_value_uint32_set(tuple, IPC4_TOTAL_PHYS_MEM_PAGES_HW_CFG, value);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_HP_EBB_COUNT_HW_CFG, PLATFORM_HPSRAM_EBB_COUNT);

tuple = tlv_next(tuple);
/* 2 DMIC dais */
value = DAI_NUM_SSP_BASE + DAI_NUM_HDA_IN + DAI_NUM_HDA_OUT +
DAI_NUM_ALH_BI_DIR_LINKS + 2;
tlv_value_uint32_set(tuple, IPC4_GATEWAY_COUNT_HW_CFG, value);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_LP_EBB_COUNT_HW_CFG, PLATFORM_LPSRAM_EBB_COUNT);
/* add platform specific tuples */
platform_basefw_hw_config(&plat_data_offset, (char *)tuple);

tuple = tlv_next(tuple);
*data_offset = (int)((char *)tuple - data);
*data_offset = (int)((char *)tuple - data) + plat_data_offset;

return 0;
}
Expand Down
10 changes: 10 additions & 0 deletions src/include/sof/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ int platform_init(struct sof *sof);
*/
int platform_context_save(struct sof *sof);

/**
* \brief Platform specific routine to add data tuples to HW_CONFIG
* structure sent to host via IPC.
* \param[out] data_offset data offset after tuples added
* \parma[in] data pointer where to add new entries
* \return 0 if successful, error code otherwise.
*/
int platform_basefw_hw_config(uint32_t *data_offset, char *data);


/** @}*/

#endif
Expand Down
28 changes: 28 additions & 0 deletions src/platform/intel/ace/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@
#include <sof/schedule/dp_schedule.h>
#include <sof/schedule/ll_schedule.h>
#include <sof/schedule/ll_schedule_domain.h>
#include <sof/tlv.h>
#include <sof/trace/trace.h>
#include <ipc/header.h>
#include <ipc/info.h>
#include <kernel/abi.h>
#include <rtos/clk.h>
#include <sof/lib/cpu.h>

#if defined(CONFIG_IPC_MAJOR_4)
#include <ipc4/base_fw.h>
#endif

#include <sof_versions.h>
#include <stdint.h>

Expand Down Expand Up @@ -140,3 +145,26 @@ int platform_context_save(struct sof *sof)
{
return 0;
}

int platform_basefw_hw_config(uint32_t *data_offset, char *data)
{
struct sof_tlv *tuple = (struct sof_tlv *)data;
uint32_t value;

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_HP_EBB_COUNT_HW_CFG, PLATFORM_HPSRAM_EBB_COUNT);

tuple = tlv_next(tuple);
/* 2 DMIC dais */
value = DAI_NUM_SSP_BASE + DAI_NUM_HDA_IN + DAI_NUM_HDA_OUT +
DAI_NUM_ALH_BI_DIR_LINKS + 2;
tlv_value_uint32_set(tuple, IPC4_GATEWAY_COUNT_HW_CFG, value);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_LP_EBB_COUNT_HW_CFG, PLATFORM_LPSRAM_EBB_COUNT);

tuple = tlv_next(tuple);
*data_offset = (int)((char *)tuple - data);

return 0;
}
28 changes: 28 additions & 0 deletions src/platform/intel/cavs/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@
#include <sof/schedule/ll_schedule.h>
#include <sof/schedule/ll_schedule_domain.h>
#include <sof/trace/trace.h>
#include <sof/tlv.h>
#include <ipc/header.h>
#include <ipc/info.h>
#include <kernel/abi.h>
#include <kernel/ext_manifest.h>

#if defined(CONFIG_IPC_MAJOR_4)
#include <ipc4/base_fw.h>
#endif

#include <sof_versions.h>
#include <errno.h>
#include <stdint.h>
Expand Down Expand Up @@ -239,3 +244,26 @@ int platform_context_save(struct sof *sof)
#endif
return 0;
}

int platform_basefw_hw_config(uint32_t *data_offset, char *data)
{
struct sof_tlv *tuple = (struct sof_tlv *)data;
uint32_t value;

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_HP_EBB_COUNT_HW_CFG, PLATFORM_HPSRAM_EBB_COUNT);

tuple = tlv_next(tuple);
/* 2 DMIC dais */
value = DAI_NUM_SSP_BASE + DAI_NUM_HDA_IN + DAI_NUM_HDA_OUT +
DAI_NUM_ALH_BI_DIR_LINKS + 2;
tlv_value_uint32_set(tuple, IPC4_GATEWAY_COUNT_HW_CFG, value);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_LP_EBB_COUNT_HW_CFG, PLATFORM_LPSRAM_EBB_COUNT);

tuple = tlv_next(tuple);
*data_offset = (int)((char *)tuple - data);

return 0;
}

0 comments on commit 3a658e0

Please sign in to comment.