Skip to content

Commit

Permalink
ASoC: SOF: IPC4: update gain ipc msg definition to align with fw
Browse files Browse the repository at this point in the history
BugLink: https://bugs.launchpad.net/bugs/2016878

[ Upstream commit e45cd86c3a78bfb9875a5eb8ab5dab459b59bbe2 ]

Recent firmware changes modified the curve duration from 32 to 64 bits,
which breaks volume ramps. A simple solution would be to change the
definition, but unfortunately the ASoC topology framework only supports
up to 32 bit tokens.

This patch suggests breaking the 64 bit value in low and high parts, with
only the low-part extracted from topology and high-part only zeroes. Since
the curve duration is represented in hundred of nanoseconds, we can still
represent a 400s ramp, which is just fine. The defacto ABI change has no
effect on existing users since the IPC4 firmware has not been released just
yet.

Link: thesofproject/linux#4026

Signed-off-by: Rander Wang <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Reviewed-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Bard Liao <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Signed-off-by: Peter Ujfalusi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Paolo Pisati <[email protected]>
  • Loading branch information
RanderWang authored and roxanan1996 committed May 17, 2023
1 parent 5e660e6 commit 8c37d02
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion sound/soc/sof/ipc4-control.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ sof_ipc4_set_volume_data(struct snd_sof_dev *sdev, struct snd_sof_widget *swidge
}

/* set curve type and duration from topology */
data.curve_duration = gain->data.curve_duration;
data.curve_duration_l = gain->data.curve_duration_l;
data.curve_duration_h = gain->data.curve_duration_h;
data.curve_type = gain->data.curve_type;

msg->data_ptr = &data;
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/sof/ipc4-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static const struct sof_topology_token gain_tokens[] = {
get_token_u32, offsetof(struct sof_ipc4_gain_data, curve_type)},
{SOF_TKN_GAIN_RAMP_DURATION,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
offsetof(struct sof_ipc4_gain_data, curve_duration)},
offsetof(struct sof_ipc4_gain_data, curve_duration_l)},
{SOF_TKN_GAIN_VAL, SND_SOC_TPLG_TUPLE_TYPE_WORD,
get_token_u32, offsetof(struct sof_ipc4_gain_data, init_val)},
};
Expand Down Expand Up @@ -670,7 +670,7 @@ static int sof_ipc4_widget_setup_comp_pga(struct snd_sof_widget *swidget)

dev_dbg(scomp->dev,
"pga widget %s: ramp type: %d, ramp duration %d, initial gain value: %#x, cpc %d\n",
swidget->widget->name, gain->data.curve_type, gain->data.curve_duration,
swidget->widget->name, gain->data.curve_type, gain->data.curve_duration_l,
gain->data.init_val, gain->base_config.cpc);

ret = sof_ipc4_widget_setup_msg(swidget, &gain->msg);
Expand Down
6 changes: 4 additions & 2 deletions sound/soc/sof/ipc4-topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,16 @@ struct sof_ipc4_control_data {
* @init_val: Initial value
* @curve_type: Curve type
* @reserved: reserved for future use
* @curve_duration: Curve duration
* @curve_duration_l: Curve duration low part
* @curve_duration_h: Curve duration high part
*/
struct sof_ipc4_gain_data {
uint32_t channels;
uint32_t init_val;
uint32_t curve_type;
uint32_t reserved;
uint32_t curve_duration;
uint32_t curve_duration_l;
uint32_t curve_duration_h;
} __aligned(8);

/**
Expand Down

0 comments on commit 8c37d02

Please sign in to comment.