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 <[email protected]>
  • Loading branch information
kv2019i committed Apr 10, 2024
1 parent 6aabfc0 commit 1bdef88
Show file tree
Hide file tree
Showing 4 changed files with 54 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
19 changes: 19 additions & 0 deletions src/platform/intel/ace/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,22 @@ 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;
uint32_t value;

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;
}
20 changes: 20 additions & 0 deletions src/platform/intel/cavs/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,23 @@ 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;
uint32_t value;

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);
*data_offset = (int)((char *)tuple - data);

return 0;
}

0 comments on commit 1bdef88

Please sign in to comment.