From a15d05db41b1d5c9f2c3af11dfbfd46818cc64ba Mon Sep 17 00:00:00 2001
From: Mengdong Lin <mengdong.lin@intel.com>
Date: Fri, 8 Feb 2013 17:09:31 -0500
Subject: [PATCH] ALSA: hda - Support rereading widgets under the function group
Git-commit: a15d05db41b1d5c9f2c3af11dfbfd46818cc64ba
Patch-mainline: v3.9-rc1
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
References: bnc#801713

A codec may allow software to hide some unused pin/cvt widgets.

Sometimes BIOS does not enable the hidden widgets properly although they are
needed for the board. Thus the driver need to enable them as a board-specific
fixup and the whole tree will change.

This patch implements a common code for rereading codec widgets. So the fixup
code can call it after enabling the hidden widgets.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 sound/pci/hda/hda_codec.c |   24 ++++++++++++++++++++++++
 sound/pci/hda/hda_codec.h |    1 +
 2 files changed, 25 insertions(+)

--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1362,6 +1362,30 @@ int /*__devinit*/ snd_hda_codec_new(stru
 }
 EXPORT_SYMBOL_HDA(snd_hda_codec_new);
 
+int snd_hda_codec_update_widgets(struct hda_codec *codec)
+{
+	hda_nid_t fg;
+	int err;
+
+	/* Assume the function group node does not change,
+	 * only the widget nodes may change.
+	 */
+	kfree(codec->wcaps);
+	fg = codec->afg ? codec->afg : codec->mfg;
+	err = read_widget_caps(codec, fg);
+	if (err < 0) {
+		snd_printk(KERN_ERR "hda_codec: cannot malloc\n");
+		return err;
+	}
+
+	snd_array_free(&codec->init_pins);
+	err = read_pin_defaults(codec);
+
+	return err;
+}
+EXPORT_SYMBOL_HDA(snd_hda_codec_update_widgets);
+
+
 /**
  * snd_hda_codec_configure - (Re-)configure the HD-audio codec
  * @codec: the HDA codec
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -906,6 +906,7 @@ int snd_hda_bus_new(struct snd_card *car
 int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
 		      struct hda_codec **codecp);
 int snd_hda_codec_configure(struct hda_codec *codec);
+int snd_hda_codec_update_widgets(struct hda_codec *codec);
 
 /*
  * low level functions
