hda_jack.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Jack-detection handling for HD-audio
  3. *
  4. * Copyright (c) 2011 Takashi Iwai <tiwai@suse.de>
  5. *
  6. * This driver is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #ifndef __SOUND_HDA_JACK_H
  12. #define __SOUND_HDA_JACK_H
  13. struct hda_jack_tbl {
  14. hda_nid_t nid;
  15. unsigned int pin_sense; /* cached pin-sense value */
  16. unsigned int jack_dirty:1; /* needs to update? */
  17. };
  18. struct hda_jack_tbl *
  19. snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid);
  20. struct hda_jack_tbl *
  21. snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid);
  22. void snd_hda_jack_tbl_clear(struct hda_codec *codec);
  23. /**
  24. * snd_hda_jack_set_dirty - set the dirty flag for the given jack-entry
  25. *
  26. * Call this function when a pin-state may change, e.g. when the hardware
  27. * notifies via an unsolicited event.
  28. */
  29. static inline void snd_hda_jack_set_dirty(struct hda_codec *codec,
  30. hda_nid_t nid)
  31. {
  32. struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid);
  33. if (jack)
  34. jack->jack_dirty = 1;
  35. }
  36. void snd_hda_jack_set_dirty_all(struct hda_codec *codec);
  37. int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
  38. unsigned int tag);
  39. u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
  40. int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
  41. static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid)
  42. {
  43. if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT))
  44. return false;
  45. if (!codec->ignore_misc_bit &&
  46. (get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) &
  47. AC_DEFCFG_MISC_NO_PRESENCE))
  48. return false;
  49. if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
  50. return false;
  51. return true;
  52. }
  53. #endif /* __SOUND_HDA_JACK_H */