]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ALSA: hda - Apply codec power_filter to FG nodes
authorTakashi Iwai <tiwai@suse.de>
Mon, 13 Jan 2014 15:09:57 +0000 (16:09 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 13 Jan 2014 15:30:15 +0000 (16:30 +0100)
Apply the codec->power_filter to the FG nodes in general for reducing
hackish set_power_state ops override in patch_sigmatel.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_generic.c
sound/pci/hda/hda_generic.h
sound/pci/hda/patch_sigmatel.c

index ab2a991d916f567431df4a194139591f88b52466..ec4536c8d8d43c0987d43fd0ef9d07fe9a417ef4 100644 (file)
@@ -3927,6 +3927,8 @@ unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec,
                                             hda_nid_t nid,
                                             unsigned int power_state)
 {
+       if (nid == codec->afg || nid == codec->mfg)
+               return power_state;
        if (power_state == AC_PWRST_D3 &&
            get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_PIN &&
            (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) {
@@ -3965,9 +3967,13 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,
                        codec->patch_ops.set_power_state(codec, fg,
                                                         power_state);
                else {
-                       snd_hda_codec_read(codec, fg, flags,
-                                          AC_VERB_SET_POWER_STATE,
-                                          power_state);
+                       state = power_state;
+                       if (codec->power_filter)
+                               state = codec->power_filter(codec, fg, state);
+                       if (state == power_state || power_state != AC_PWRST_D3)
+                               snd_hda_codec_read(codec, fg, flags,
+                                                  AC_VERB_SET_POWER_STATE,
+                                                  state);
                        snd_hda_codec_set_power_to_all(codec, fg, power_state);
                }
                state = hda_sync_power_state(codec, fg, power_state);
index 7513089c8985ca97bcbf81de911b6bfd7420bfd0..8321a97d5c05047ab2312f8c62603826041a1897 100644 (file)
@@ -4312,11 +4312,11 @@ static int check_auto_mic_availability(struct hda_codec *codec)
 }
 
 /* power_filter hook; make inactive widgets into power down */
-static unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec,
+unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec,
                                                  hda_nid_t nid,
                                                  unsigned int power_state)
 {
-       if (power_state != AC_PWRST_D0)
+       if (power_state != AC_PWRST_D0 || nid == codec->afg)
                return power_state;
        if (get_wcaps_type(get_wcaps(codec, nid)) >= AC_WID_POWER)
                return power_state;
@@ -4324,6 +4324,7 @@ static unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec,
                return power_state;
        return AC_PWRST_D3;
 }
+EXPORT_SYMBOL_GPL(snd_hda_gen_path_power_filter);
 
 /* mute all aamix inputs initially; parse up to the first leaves */
 static void mute_all_mixer_nid(struct hda_codec *codec, hda_nid_t mix)
index 0929a06df8128495f5e717768fcfa28eaed7360d..07f767231c9f439bef66a950f6a5cab3ce957156 100644 (file)
@@ -335,5 +335,8 @@ void snd_hda_gen_update_outputs(struct hda_codec *codec);
 #ifdef CONFIG_PM
 int snd_hda_gen_check_power_status(struct hda_codec *codec, hda_nid_t nid);
 #endif
+unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec,
+                                          hda_nid_t nid,
+                                          unsigned int power_state);
 
 #endif /* __SOUND_HDA_GENERIC_H */
index 088a5afbd1b94846462cc290b7ca0eceab5ffaa7..6998cf29b9bc34016e2d2ee1574b6b3d02ce8ef2 100644 (file)
@@ -368,6 +368,17 @@ static int stac_vrefout_set(struct hda_codec *codec,
        return 1;
 }
 
+/* prevent codec AFG to D3 state when vref-out pin is used for mute LED */
+/* this hook is set in stac_setup_gpio() */
+static unsigned int stac_vref_led_power_filter(struct hda_codec *codec,
+                                              hda_nid_t nid,
+                                              unsigned int power_state)
+{
+       if (nid == codec->afg && power_state == AC_PWRST_D3)
+               return AC_PWRST_D1;
+       return snd_hda_gen_path_power_filter(codec, nid, power_state);
+}
+
 /* update mute-LED accoring to the master switch */
 static void stac_update_led_status(struct hda_codec *codec, int enabled)
 {
@@ -4260,30 +4271,8 @@ static int stac_suspend(struct hda_codec *codec)
        stac_shutup(codec);
        return 0;
 }
-
-static void stac_set_power_state(struct hda_codec *codec, hda_nid_t fg,
-                                unsigned int power_state)
-{
-       unsigned int afg_power_state = power_state;
-       struct sigmatel_spec *spec = codec->spec;
-
-       if (power_state == AC_PWRST_D3) {
-               if (spec->vref_mute_led_nid) {
-                       /* with vref-out pin used for mute led control
-                        * codec AFG is prevented from D3 state
-                        */
-                       afg_power_state = AC_PWRST_D1;
-               }
-               /* this delay seems necessary to avoid click noise at power-down */
-               msleep(100);
-       }
-       snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
-                       afg_power_state);
-       snd_hda_codec_set_power_to_all(codec, fg, power_state);
-}
 #else
 #define stac_suspend           NULL
-#define stac_set_power_state   NULL
 #endif /* CONFIG_PM */
 
 static const struct hda_codec_ops stac_patch_ops = {
@@ -4466,8 +4455,7 @@ static void stac_setup_gpio(struct hda_codec *codec)
                        spec->gpio_dir |= spec->gpio_led;
                        spec->gpio_data |= spec->gpio_led;
                } else {
-                       codec->patch_ops.set_power_state =
-                                       stac_set_power_state;
+                       codec->power_filter = stac_vref_led_power_filter;
                }
        }