Commit c4476369 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown

ASoC: SOF: ipc4-topology: Correct data structures for the SRC module

Separate the IPC message part as struct sof_ipc4_src_data. This struct
describes the message payload passed to the firmware via the mailbox.

It is not wise to be 'clever' and try to use the first part of a struct
as IPC message without marking the message section as packed and aligned.
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20231129131411.27516-2-peter.ujfalusi@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a0575b4a
...@@ -141,7 +141,7 @@ static const struct sof_topology_token gain_tokens[] = { ...@@ -141,7 +141,7 @@ static const struct sof_topology_token gain_tokens[] = {
/* SRC */ /* SRC */
static const struct sof_topology_token src_tokens[] = { static const struct sof_topology_token src_tokens[] = {
{SOF_TKN_SRC_RATE_OUT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, {SOF_TKN_SRC_RATE_OUT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
offsetof(struct sof_ipc4_src, sink_rate)}, offsetof(struct sof_ipc4_src_data, sink_rate)},
}; };
static const struct sof_token_info ipc4_token_list[SOF_TOKEN_COUNT] = { static const struct sof_token_info ipc4_token_list[SOF_TOKEN_COUNT] = {
...@@ -811,11 +811,12 @@ static int sof_ipc4_widget_setup_comp_src(struct snd_sof_widget *swidget) ...@@ -811,11 +811,12 @@ static int sof_ipc4_widget_setup_comp_src(struct snd_sof_widget *swidget)
swidget->private = src; swidget->private = src;
ret = sof_ipc4_get_audio_fmt(scomp, swidget, &src->available_fmt, &src->base_config); ret = sof_ipc4_get_audio_fmt(scomp, swidget, &src->available_fmt,
&src->data.base_config);
if (ret) if (ret)
goto err; goto err;
ret = sof_update_ipc_object(scomp, src, SOF_SRC_TOKENS, swidget->tuples, ret = sof_update_ipc_object(scomp, &src->data, SOF_SRC_TOKENS, swidget->tuples,
swidget->num_tuples, sizeof(*src), 1); swidget->num_tuples, sizeof(*src), 1);
if (ret) { if (ret) {
dev_err(scomp->dev, "Parsing SRC tokens failed\n"); dev_err(scomp->dev, "Parsing SRC tokens failed\n");
...@@ -824,7 +825,7 @@ static int sof_ipc4_widget_setup_comp_src(struct snd_sof_widget *swidget) ...@@ -824,7 +825,7 @@ static int sof_ipc4_widget_setup_comp_src(struct snd_sof_widget *swidget)
spipe->core_mask |= BIT(swidget->core); spipe->core_mask |= BIT(swidget->core);
dev_dbg(scomp->dev, "SRC sink rate %d\n", src->sink_rate); dev_dbg(scomp->dev, "SRC sink rate %d\n", src->data.sink_rate);
ret = sof_ipc4_widget_setup_msg(swidget, &src->msg); ret = sof_ipc4_widget_setup_msg(swidget, &src->msg);
if (ret) if (ret)
...@@ -1900,7 +1901,7 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget, ...@@ -1900,7 +1901,7 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
u32 out_ref_rate, out_ref_channels, out_ref_valid_bits; u32 out_ref_rate, out_ref_channels, out_ref_valid_bits;
int output_format_index, input_format_index; int output_format_index, input_format_index;
input_format_index = sof_ipc4_init_input_audio_fmt(sdev, swidget, &src->base_config, input_format_index = sof_ipc4_init_input_audio_fmt(sdev, swidget, &src->data.base_config,
pipeline_params, available_fmt); pipeline_params, available_fmt);
if (input_format_index < 0) if (input_format_index < 0)
return input_format_index; return input_format_index;
...@@ -1930,7 +1931,7 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget, ...@@ -1930,7 +1931,7 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
*/ */
out_ref_rate = params_rate(fe_params); out_ref_rate = params_rate(fe_params);
output_format_index = sof_ipc4_init_output_audio_fmt(sdev, &src->base_config, output_format_index = sof_ipc4_init_output_audio_fmt(sdev, &src->data.base_config,
available_fmt, out_ref_rate, available_fmt, out_ref_rate,
out_ref_channels, out_ref_valid_bits); out_ref_channels, out_ref_valid_bits);
if (output_format_index < 0) { if (output_format_index < 0) {
...@@ -1940,10 +1941,10 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget, ...@@ -1940,10 +1941,10 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
} }
/* update pipeline memory usage */ /* update pipeline memory usage */
sof_ipc4_update_resource_usage(sdev, swidget, &src->base_config); sof_ipc4_update_resource_usage(sdev, swidget, &src->data.base_config);
out_audio_fmt = &available_fmt->output_pin_fmts[output_format_index].audio_fmt; out_audio_fmt = &available_fmt->output_pin_fmts[output_format_index].audio_fmt;
src->sink_rate = out_audio_fmt->sampling_frequency; src->data.sink_rate = out_audio_fmt->sampling_frequency;
/* update pipeline_params for sink widgets */ /* update pipeline_params for sink widgets */
return sof_ipc4_update_hw_params(sdev, pipeline_params, out_audio_fmt); return sof_ipc4_update_hw_params(sdev, pipeline_params, out_audio_fmt);
...@@ -2344,8 +2345,8 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget ...@@ -2344,8 +2345,8 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget
{ {
struct sof_ipc4_src *src = swidget->private; struct sof_ipc4_src *src = swidget->private;
ipc_size = sizeof(struct sof_ipc4_base_module_cfg) + sizeof(src->sink_rate); ipc_size = sizeof(src->data);
ipc_data = src; ipc_data = &src->data;
msg = &src->msg; msg = &src->msg;
break; break;
......
...@@ -404,16 +404,24 @@ struct sof_ipc4_mixer { ...@@ -404,16 +404,24 @@ struct sof_ipc4_mixer {
struct sof_ipc4_msg msg; struct sof_ipc4_msg msg;
}; };
/** /*
* struct sof_ipc4_src SRC config data * struct sof_ipc4_src_data - IPC data for SRC
* @base_config: IPC base config data * @base_config: IPC base config data
* @sink_rate: Output rate for sink module * @sink_rate: Output rate for sink module
*/
struct sof_ipc4_src_data {
struct sof_ipc4_base_module_cfg base_config;
uint32_t sink_rate;
} __packed __aligned(4);
/**
* struct sof_ipc4_src - SRC config data
* @data: IPC base config data
* @available_fmt: Available audio format * @available_fmt: Available audio format
* @msg: IPC4 message struct containing header and data info * @msg: IPC4 message struct containing header and data info
*/ */
struct sof_ipc4_src { struct sof_ipc4_src {
struct sof_ipc4_base_module_cfg base_config; struct sof_ipc4_src_data data;
uint32_t sink_rate;
struct sof_ipc4_available_audio_format available_fmt; struct sof_ipc4_available_audio_format available_fmt;
struct sof_ipc4_msg msg; struct sof_ipc4_msg msg;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment