Skip to content

Commit

Permalink
audio: base_fw: add platform layer to fw_config data
Browse files Browse the repository at this point in the history
Some of the FW_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 FW_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 12, 2024
1 parent 8791479 commit 0319566
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/audio/base_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static int basefw_config(uint32_t *data_offset, char *data)
uint16_t version[4] = {SOF_MAJOR, SOF_MINOR, SOF_MICRO, SOF_BUILD};
struct sof_tlv *tuple = (struct sof_tlv *)data;
struct ipc4_scheduler_config sche_cfg;
uint32_t plat_data_offset = 0;
uint32_t log_bytes_size = 0;

tlv_value_set(tuple, IPC4_FW_VERSION_FW_CFG, sizeof(version), version);
Expand All @@ -58,15 +59,6 @@ static int basefw_config(uint32_t *data_offset, char *data)
IPC4_SLOW_CLOCK_FREQ_HZ_FW_CFG,
clock_get_freq(CPU_LOWEST_FREQ_IDX));

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_SLOW_CLOCK_FREQ_HZ_FW_CFG, IPC4_ALH_CAVS_1_8);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_UAOL_SUPPORT, 0);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_ALH_SUPPORT_LEVEL_FW_CFG, IPC4_ALH_CAVS_1_8);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_DL_MAILBOX_BYTES_FW_CFG, MAILBOX_HOSTBOX_SIZE);

Expand Down Expand Up @@ -121,7 +113,11 @@ static int basefw_config(uint32_t *data_offset, char *data)
IS_ENABLED(CONFIG_ADSP_IMR_CONTEXT_SAVE));

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

/* add platform specific tuples */
platform_basefw_fw_config(&plat_data_offset, (char *)tuple);

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

return 0;
}
Expand Down
9 changes: 9 additions & 0 deletions src/include/sof/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ int platform_context_save(struct sof *sof);
*/
int platform_basefw_hw_config(uint32_t *data_offset, char *data);

/**
* \brief Platform specific routine to add data tuples to FW_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_fw_config(uint32_t *data_offset, char *data);

/** @}*/

#endif
Expand Down
18 changes: 18 additions & 0 deletions src/platform/intel/ace/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,21 @@ int platform_basefw_hw_config(uint32_t *data_offset, char *data)

return 0;
}

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

tlv_value_uint32_set(tuple, IPC4_SLOW_CLOCK_FREQ_HZ_FW_CFG, IPC4_ALH_CAVS_1_8);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_UAOL_SUPPORT, 0);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_ALH_SUPPORT_LEVEL_FW_CFG, IPC4_ALH_CAVS_1_8);

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

return 0;
}
18 changes: 18 additions & 0 deletions src/platform/intel/cavs/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,21 @@ int platform_basefw_hw_config(uint32_t *data_offset, char *data)

return 0;
}

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

tlv_value_uint32_set(tuple, IPC4_SLOW_CLOCK_FREQ_HZ_FW_CFG, IPC4_ALH_CAVS_1_8);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_UAOL_SUPPORT, 0);

tuple = tlv_next(tuple);
tlv_value_uint32_set(tuple, IPC4_ALH_SUPPORT_LEVEL_FW_CFG, IPC4_ALH_CAVS_1_8);

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

return 0;
}
7 changes: 7 additions & 0 deletions src/platform/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ int platform_basefw_hw_config(uint32_t *data_offset, char *data)

return 0;
}

int platform_basefw_fw_config(uint32_t *data_offset, char *data)
{
*data_offset = 0;

return 0;
}

0 comments on commit 0319566

Please sign in to comment.