Skip to content

Commit

Permalink
ALSA: hda - Fix yet remaining issue with vmaster 0dB initialization
Browse files Browse the repository at this point in the history
The previous fix for addressing the breakage in vmaster slave
initialization, commit a91d661 ("ALSA: hda - Fix incorrect TLV
callback check introduced during set_fs() removal"), introduced a new
helper to process over each slave kctl.  However, this helper passes
only the original kctl, not the virtual slave kctl.  As a result,
HD-audio driver (which is the only user so far) couldn't initialize
the slave correctly because it's trying to update the value directly
with the original kctl, not with the mapped kctl.

This patch fixes the situation again by passing both the mapped slaved
and original slave kctls to the function.  Luckily there is a single
caller as of now, so changing the call signature is no big matter.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=197959
Fixes: a91d661 ("ALSA: hda - Fix incorrect TLV callback check introduced during set_fs() removal")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
tiwai committed Nov 22, 2017
1 parent 0a62d6c commit d6c0615
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion include/sound/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ int snd_ctl_add_vmaster_hook(struct snd_kcontrol *kctl,
void snd_ctl_sync_vmaster(struct snd_kcontrol *kctl, bool hook_only);
#define snd_ctl_sync_vmaster_hook(kctl) snd_ctl_sync_vmaster(kctl, true)
int snd_ctl_apply_vmaster_slaves(struct snd_kcontrol *kctl,
int (*func)(struct snd_kcontrol *, void *),
int (*func)(struct snd_kcontrol *vslave,
struct snd_kcontrol *slave,
void *arg),
void *arg);

/*
Expand Down
6 changes: 4 additions & 2 deletions sound/core/vmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,9 @@ EXPORT_SYMBOL_GPL(snd_ctl_sync_vmaster);
* Returns 0 if successful, or a negative error code.
*/
int snd_ctl_apply_vmaster_slaves(struct snd_kcontrol *kctl,
int (*func)(struct snd_kcontrol *, void *),
int (*func)(struct snd_kcontrol *vslave,
struct snd_kcontrol *slave,
void *arg),
void *arg)
{
struct link_master *master;
Expand All @@ -507,7 +509,7 @@ int snd_ctl_apply_vmaster_slaves(struct snd_kcontrol *kctl,
if (err < 0)
return err;
list_for_each_entry(slave, &master->slaves, list) {
err = func(&slave->slave, arg);
err = func(slave->kctl, &slave->slave, arg);
if (err < 0)
return err;
}
Expand Down
10 changes: 7 additions & 3 deletions sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,9 @@ struct slave_init_arg {
};

/* initialize the slave volume with 0dB via snd_ctl_apply_vmaster_slaves() */
static int init_slave_0dB(struct snd_kcontrol *kctl, void *_arg)
static int init_slave_0dB(struct snd_kcontrol *slave,
struct snd_kcontrol *kctl,
void *_arg)
{
struct slave_init_arg *arg = _arg;
int _tlv[4];
Expand Down Expand Up @@ -1860,15 +1862,17 @@ static int init_slave_0dB(struct snd_kcontrol *kctl, void *_arg)
arg->step = step;
val = -tlv[2] / step;
if (val > 0) {
put_kctl_with_value(kctl, val);
put_kctl_with_value(slave, val);
return val;
}

return 0;
}

/* unmute the slave via snd_ctl_apply_vmaster_slaves() */
static int init_slave_unmute(struct snd_kcontrol *slave, void *_arg)
static int init_slave_unmute(struct snd_kcontrol *slave,
struct snd_kcontrol *kctl,
void *_arg)
{
return put_kctl_with_value(slave, 1);
}
Expand Down

0 comments on commit d6c0615

Please sign in to comment.