Skip to content

Commit

Permalink
ASoC: SOF: topology: set default values to volume control
Browse files Browse the repository at this point in the history
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 <jaska.uimonen@intel.com>
  • Loading branch information
Jaska Uimonen authored and plbossart committed Nov 8, 2018
1 parent 6ff8e4d commit 4badf19
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sound/soc/sof/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4badf19

Please sign in to comment.