diff options
author | Wu Fengguang <fengguang.wu@intel.com> | 2009-11-17 23:38:02 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-11-18 01:40:57 -0500 |
commit | 864f92be7e8d4a0ba11d912e3f03d1a92a031dee (patch) | |
tree | 95de58c8f304024b99da8707df77264f644d14b4 /sound/pci/hda/hda_codec.c | |
parent | 23ccc2bd246a5bdb1ac03dc9040a0585c1890ef3 (diff) |
ALSA: hda - introduce snd_hda_jack_detect() and snd_hda_pin_sense()
This helps merge duplicate code.
v2: add snd_hda_jack_detect() and comments recommended by Takashi.
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 2be61b31fb3c..9cfdb771928c 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -1317,6 +1317,40 @@ u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid) | |||
1317 | } | 1317 | } |
1318 | EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); | 1318 | EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); |
1319 | 1319 | ||
1320 | /** | ||
1321 | * snd_hda_pin_sense - execute pin sense measurement | ||
1322 | * @codec: the CODEC to sense | ||
1323 | * @nid: the pin NID to sense | ||
1324 | * | ||
1325 | * Execute necessary pin sense measurement and return its Presence Detect, | ||
1326 | * Impedance, ELD Valid etc. status bits. | ||
1327 | */ | ||
1328 | u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid) | ||
1329 | { | ||
1330 | u32 pincap = snd_hda_query_pin_caps(codec, nid); | ||
1331 | |||
1332 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ | ||
1333 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
1334 | |||
1335 | return snd_hda_codec_read(codec, nid, 0, | ||
1336 | AC_VERB_GET_PIN_SENSE, 0); | ||
1337 | } | ||
1338 | EXPORT_SYMBOL_HDA(snd_hda_pin_sense); | ||
1339 | |||
1340 | /** | ||
1341 | * snd_hda_jack_detect - query pin Presence Detect status | ||
1342 | * @codec: the CODEC to sense | ||
1343 | * @nid: the pin NID to sense | ||
1344 | * | ||
1345 | * Query and return the pin's Presence Detect status. | ||
1346 | */ | ||
1347 | int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid) | ||
1348 | { | ||
1349 | u32 sense = snd_hda_pin_sense(codec, nid); | ||
1350 | return !!(sense & AC_PINSENSE_PRESENCE); | ||
1351 | } | ||
1352 | EXPORT_SYMBOL_HDA(snd_hda_jack_detect); | ||
1353 | |||
1320 | /* | 1354 | /* |
1321 | * read the current volume to info | 1355 | * read the current volume to info |
1322 | * if the cache exists, read the cache value. | 1356 | * if the cache exists, read the cache value. |