Skip to content

Commit

Permalink
ASoC: wm_adsp: Ensure set controls are synced on each boot
Browse files Browse the repository at this point in the history
Rename `dirty' to `set' as it is a bit more descriptive.  A set
control is any control that has been set by the user.  We need to ensure
that everytime we boot the DSP we sync out any controls that were
set.

We could at some point start keeping track of the default values of
the controls to suppress some of the device I/O.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Dimitris Papastamos authored and Mark Brown committed May 28, 2013
1 parent 9dbce04 commit 0c2e3f3
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions sound/soc/codecs/wm_adsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ struct wm_coeff_ctl {
struct list_head list;
void *cache;
size_t len;
unsigned int dirty:1;
unsigned int set:1;
struct snd_kcontrol *kcontrol;
};

Expand Down Expand Up @@ -424,7 +424,7 @@ static int wm_coeff_put(struct snd_kcontrol *kcontrol,
memcpy(ctl->cache, p, ctl->len);

if (!ctl->enabled) {
ctl->dirty = 1;
ctl->set = 1;
return 0;
}

Expand Down Expand Up @@ -760,7 +760,7 @@ static int wm_coeff_init_control_caches(struct wm_coeff *wm_coeff)

list_for_each_entry(ctl, &wm_coeff->ctl_list,
list) {
if (!ctl->enabled || ctl->dirty)
if (!ctl->enabled || ctl->set)
continue;
ret = wm_coeff_read_control(ctl->kcontrol,
ctl->cache,
Expand All @@ -781,13 +781,12 @@ static int wm_coeff_sync_controls(struct wm_coeff *wm_coeff)
list) {
if (!ctl->enabled)
continue;
if (ctl->dirty) {
if (ctl->set) {
ret = wm_coeff_write_control(ctl->kcontrol,
ctl->cache,
ctl->len);
if (ret < 0)
return ret;
ctl->dirty = 0;
}
}

Expand Down Expand Up @@ -864,7 +863,7 @@ static int wm_adsp_create_control(struct snd_soc_codec *codec,
goto err_ctl;
}
ctl->enabled = 1;
ctl->dirty = 0;
ctl->set = 0;
ctl->ops.xget = wm_coeff_get;
ctl->ops.xput = wm_coeff_put;
ctl->card = codec->card->snd_card;
Expand Down Expand Up @@ -1434,12 +1433,12 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w,
if (ret != 0)
goto err;

/* Initialize caches for enabled and non-dirty controls */
/* Initialize caches for enabled and unset controls */
ret = wm_coeff_init_control_caches(dsp->wm_coeff);
if (ret != 0)
goto err;

/* Sync dirty controls */
/* Sync set controls */
ret = wm_coeff_sync_controls(dsp->wm_coeff);
if (ret != 0)
goto err;
Expand Down Expand Up @@ -1591,12 +1590,12 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,
if (ret != 0)
goto err;

/* Initialize caches for enabled and non-dirty controls */
/* Initialize caches for enabled and unset controls */
ret = wm_coeff_init_control_caches(dsp->wm_coeff);
if (ret != 0)
goto err;

/* Sync dirty controls */
/* Sync set controls */
ret = wm_coeff_sync_controls(dsp->wm_coeff);
if (ret != 0)
goto err;
Expand Down

0 comments on commit 0c2e3f3

Please sign in to comment.