aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-05-15 03:11:36 -0400
committerTakashi Iwai <tiwai@suse.de>2012-05-15 03:12:12 -0400
commitc882246d840073a3dd0533ca164dfcbd7f6bd207 (patch)
treea9a2f79462fd8bdebf16d09aa2955b07ea520cbf /sound/pci/hda
parentbfc89dec97a3db0f14393a86b2fc3d8e13b33c86 (diff)
ALSA: hda/idt - Cache the power-map bits
For avoiding unnecessary codec read/write verbs at each jack detection. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda')
-rw-r--r--sound/pci/hda/patch_sigmatel.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 1f6f5202e7b1..7db8228f1b88 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -222,6 +222,7 @@ struct sigmatel_spec {
222 unsigned char aloopback_shift; 222 unsigned char aloopback_shift;
223 223
224 /* power management */ 224 /* power management */
225 unsigned int power_map_bits;
225 unsigned int num_pwrs; 226 unsigned int num_pwrs;
226 const hda_nid_t *pwr_nids; 227 const hda_nid_t *pwr_nids;
227 const hda_nid_t *dac_list; 228 const hda_nid_t *dac_list;
@@ -315,6 +316,9 @@ struct sigmatel_spec {
315 struct hda_vmaster_mute_hook vmaster_mute; 316 struct hda_vmaster_mute_hook vmaster_mute;
316}; 317};
317 318
319#define AC_VERB_IDT_SET_POWER_MAP 0x7ec
320#define AC_VERB_IDT_GET_POWER_MAP 0xfec
321
318static const hda_nid_t stac9200_adc_nids[1] = { 322static const hda_nid_t stac9200_adc_nids[1] = {
319 0x03, 323 0x03,
320}; 324};
@@ -4406,6 +4410,12 @@ static int stac92xx_init(struct hda_codec *codec)
4406 4410
4407 /* sync mute LED */ 4411 /* sync mute LED */
4408 snd_hda_sync_vmaster_hook(&spec->vmaster_mute); 4412 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
4413
4414 /* sync the power-map */
4415 if (spec->num_pwrs)
4416 snd_hda_codec_write(codec, codec->afg, 0,
4417 AC_VERB_IDT_SET_POWER_MAP,
4418 spec->power_map_bits);
4409 if (spec->dac_list) 4419 if (spec->dac_list)
4410 stac92xx_power_down(codec); 4420 stac92xx_power_down(codec);
4411 return 0; 4421 return 0;
@@ -4651,14 +4661,18 @@ static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4651 4661
4652 idx = 1 << idx; 4662 idx = 1 << idx;
4653 4663
4654 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; 4664 val = spec->power_map_bits;
4655 if (enable) 4665 if (enable)
4656 val &= ~idx; 4666 val &= ~idx;
4657 else 4667 else
4658 val |= idx; 4668 val |= idx;
4659 4669
4660 /* power down unused output ports */ 4670 /* power down unused output ports */
4661 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); 4671 if (val != spec->power_map_bits) {
4672 spec->power_map_bits = val;
4673 snd_hda_codec_write(codec, codec->afg, 0,
4674 AC_VERB_IDT_SET_POWER_MAP, val);
4675 }
4662} 4676}
4663 4677
4664static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) 4678static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
@@ -4926,7 +4940,8 @@ static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4926{ 4940{
4927 if (nid == codec->afg) 4941 if (nid == codec->afg)
4928 snd_iprintf(buffer, "Power-Map: 0x%02x\n", 4942 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4929 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); 4943 snd_hda_codec_read(codec, nid, 0,
4944 AC_VERB_IDT_GET_POWER_MAP, 0));
4930} 4945}
4931 4946
4932static void analog_loop_proc_hook(struct snd_info_buffer *buffer, 4947static void analog_loop_proc_hook(struct snd_info_buffer *buffer,