ALSA: hda - Add helper functions to cache the current pinctl target
authorTakashi Iwai <tiwai@suse.de>
Thu, 10 Jan 2013 07:38:04 +0000 (08:38 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sat, 12 Jan 2013 07:44:25 +0000 (08:44 +0100)
We already have the list of whole pin widgets and there is an unused
space in the list; let's use it for caching the current pinctl value.

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

index 733bce62670c070df696e964310ebd641225dd9d..505cb72e4ee7e432fa5dea56ff8a430464e5b4be 100644 (file)
@@ -1100,6 +1100,32 @@ unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid)
 }
 EXPORT_SYMBOL_HDA(snd_hda_codec_get_pincfg);
 
+/* remember the current pinctl target value */
+int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid,
+                                unsigned int val)
+{
+       struct hda_pincfg *pin;
+
+       pin = look_up_pincfg(codec, &codec->init_pins, nid);
+       if (!pin)
+               return -EINVAL;
+       pin->target = val;
+       return 0;
+}
+EXPORT_SYMBOL_HDA(snd_hda_codec_set_pin_target);
+
+/* return the current pinctl target value */
+int snd_hda_codec_get_pin_target(struct hda_codec *codec, hda_nid_t nid)
+{
+       struct hda_pincfg *pin;
+
+       pin = look_up_pincfg(codec, &codec->init_pins, nid);
+       if (!pin)
+               return 0;
+       return pin->target;
+}
+EXPORT_SYMBOL_HDA(snd_hda_codec_get_pin_target);
+
 /**
  * snd_hda_shutup_pins - Shut up all pins
  * @codec: the HDA codec
@@ -5266,6 +5292,7 @@ int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin,
                                val &= ~(AC_PINCTL_IN_EN | AC_PINCTL_VREFEN);
                }
        }
+       snd_hda_codec_set_pin_target(codec, pin, val);
        if (cached)
                return snd_hda_codec_update_cache(codec, pin, 0,
                                AC_VERB_SET_PIN_WIDGET_CONTROL, val);
index 93ec747ce904df67a9c94dac1b7377e5e13cab21..4c4f1660e6548f344d2f6d36d88fac6b6aecfd5d 100644 (file)
@@ -981,8 +981,8 @@ void snd_hda_codec_resume_cache(struct hda_codec *codec);
 /* the struct for codec->pin_configs */
 struct hda_pincfg {
        hda_nid_t nid;
-       unsigned char ctrl;     /* current pin control value */
-       unsigned char pad;      /* reserved */
+       unsigned char ctrl;     /* original pin control value */
+       unsigned char target;   /* target pin control value */
        unsigned int cfg;       /* default configuration */
 };
 
index fec0e2d72894235fc93de0703aaa13780be79d77..655a40f9302085528a3ea2f094a6c5466f54acec 100644 (file)
@@ -529,6 +529,10 @@ snd_hda_set_pin_ctl_cache(struct hda_codec *codec, hda_nid_t pin,
        return _snd_hda_set_pin_ctl(codec, pin, val, true);
 }
 
+int snd_hda_codec_get_pin_target(struct hda_codec *codec, hda_nid_t nid);
+int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid,
+                                unsigned int val);
+
 /*
  * get widget capabilities
  */
This page took 0.0295339999999999 seconds and 5 git commands to generate.