From 29e5853d618282d8277ce8a8304f7424eb60deb5 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Mon, 12 Mar 2012 12:25:03 +0100
Subject: [PATCH] ALSA: hda - Return the created kcontrol in __snd_hda_add_vmaster()
Git-commit: 29e5853d618282d8277ce8a8304f7424eb60deb5
Patch-mainline: 3.4-rc3
References: FATE#313695

It'll be used for adding hooks in later patches.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 sound/pci/hda/hda_codec.c    |    9 ++++++++-
 sound/pci/hda/hda_local.h    |    7 ++++---
 sound/pci/hda/patch_analog.c |    2 +-
 3 files changed, 13 insertions(+), 5 deletions(-)

--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2398,6 +2398,7 @@ static int init_slave_unmute(void *data,
  * @slaves: slave control names (optional)
  * @suffix: suffix string to each slave name (optional)
  * @init_slave_vol: initialize slaves to unmute/0dB
+ * @ctl_ret: store the vmaster kcontrol in return
  *
  * Create a virtual master control with the given name.  The TLV data
  * must be either NULL or a valid data.
@@ -2410,11 +2411,15 @@ static int init_slave_unmute(void *data,
  */
 int __snd_hda_add_vmaster(struct hda_codec *codec, char *name,
 			unsigned int *tlv, const char * const *slaves,
-			const char *suffix, bool init_slave_vol)
+			  const char *suffix, bool init_slave_vol,
+			  struct snd_kcontrol **ctl_ret)
 {
 	struct snd_kcontrol *kctl;
 	int err;
 
+	if (ctl_ret)
+		*ctl_ret = NULL;
+
 	err = map_slaves(codec, slaves, suffix, check_slave_present, NULL);
 	if (err != 1) {
 		snd_printdd("No slave found for %s\n", name);
@@ -2438,6 +2443,8 @@ int __snd_hda_add_vmaster(struct hda_cod
 		map_slaves(codec, slaves, suffix,
 			   tlv ? init_slave_0dB : init_slave_unmute, kctl);
 
+	if (ctl_ret)
+		*ctl_ret = kctl;
 	return 0;
 }
 EXPORT_SYMBOL_HDA(__snd_hda_add_vmaster);
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -140,10 +140,11 @@ void snd_hda_set_vmaster_tlv(struct hda_
 struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
 					    const char *name);
 int __snd_hda_add_vmaster(struct hda_codec *codec, char *name,
-			unsigned int *tlv, const char * const *slaves,
-			const char *suffix, bool init_slave_vol);
+			  unsigned int *tlv, const char * const *slaves,
+			  const char *suffix, bool init_slave_vol,
+			  struct snd_kcontrol **ctl_ret);
 #define snd_hda_add_vmaster(codec, name, tlv, slaves, suffix) \
-	__snd_hda_add_vmaster(codec, name, tlv, slaves, suffix, true)
+	__snd_hda_add_vmaster(codec, name, tlv, slaves, suffix, true, NULL)
 int snd_hda_codec_reset(struct hda_codec *codec);
 
 /* amp value bits */
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -228,7 +228,7 @@ static int ad198x_build_controls(struct
 					  (spec->slave_vols ?
 					   spec->slave_vols : ad_slave_pfxs),
 					  "Playback Volume",
-					  !spec->avoid_init_slave_vol);
+					  !spec->avoid_init_slave_vol, NULL);
 		if (err < 0)
 			return err;
 	}
