From 92712eff220eeec96f1d541b06ec3f6396c26e50 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Thu, 8 Nov 2018 16:22:51 +0200 Subject: [PATCH] ASoC: SOF: topology: set default values to volume control Currently volume control doesn't have any default values when it is created. This will cause an issue when PM kicks in and in resume the non-existing values are set to firmware. Signed-off-by: Jaska Uimonen --- sound/soc/sof/topology.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 02ef68d64a8092..51d7294b974654 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -33,9 +33,12 @@ /* 40th root of 10 in Q1.16 fixed-point notation*/ #define VOL_FORTIETH_ROOT_OF_TEN 69419 /* Volume fractional word length */ +/* Define to 16 sets the volume linear gain value to use Qx.16 format */ #define VOLUME_FWL 16 /* 0.5 dB step value in topology TLV */ #define VOL_HALF_DB_STEP 50 +/* Full volume for default values */ +#define VOL_ZERO_DB BIT(VOLUME_FWL) /* TLV data items */ #define TLV_ITEMS 3 @@ -1193,8 +1196,10 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index, const struct snd_kcontrol_new *kc = NULL; struct soc_mixer_control *sm; struct snd_sof_control *scontrol; + struct sof_ipc_ctrl_data *cdata; const unsigned int *p; int ret, tlv[TLV_ITEMS]; + unsigned int i; volume = kzalloc(sizeof(*volume), GFP_KERNEL); if (!volume) @@ -1258,6 +1263,13 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index, goto err; } + /* set default volume values to 0dB in control */ + cdata = scontrol->control_data; + for (i = 0; i < scontrol->num_channels; i++) { + cdata->chanv[i].channel = i; + cdata->chanv[i].value = VOL_ZERO_DB; + } + sof_dbg_comp_config(scomp, &volume->config); swidget->private = (void *)volume;