From 1327a32b878b5ed2113c63557b6f4f949f821857 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 23 Mar 2009 13:07:47 +0100 Subject: ALSA: hda - Cache pin-cap values Added snd_hda_query_pin_caps() to read and cache pin-cap values to avoid too frequently issuing the same verbs. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sound/pci/hda/hda_codec.c') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 1b5575ecb0a..0f70d2d102e 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1052,6 +1052,7 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream); /* FIXME: more better hash key? */ #define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) +#define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24)) #define INFO_AMP_CAPS (1<<0) #define INFO_AMP_VOL(ch) (1 << (1 + (ch))) @@ -1142,6 +1143,21 @@ int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, } EXPORT_SYMBOL_HDA(snd_hda_override_amp_caps); +u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid) +{ + struct hda_amp_info *info; + + info = get_alloc_amp_hash(codec, HDA_HASH_PINCAP_KEY(nid)); + if (!info) + return 0; + if (!info->head.val) { + info->amp_caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); + info->head.val |= INFO_AMP_CAPS; + } + return info->amp_caps; +} +EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); + /* * read the current volume to info * if the cache exists, read the cache value. -- cgit v1.2.3