jack.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #ifndef __SOUND_JACK_H
  2. #define __SOUND_JACK_H
  3. /*
  4. * Jack abstraction layer
  5. *
  6. * Copyright 2008 Wolfson Microelectronics plc
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #include <sound/core.h>
  25. struct input_dev;
  26. /**
  27. * Jack types which can be reported. These values are used as a
  28. * bitmask.
  29. *
  30. * Note that this must be kept in sync with the lookup table in
  31. * sound/core/jack.c.
  32. */
  33. enum snd_jack_types {
  34. SND_JACK_HEADPHONE = 0x0000001,
  35. SND_JACK_MICROPHONE = 0x0000002,
  36. SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE,
  37. SND_JACK_LINEOUT = 0x0000004,
  38. SND_JACK_MECHANICAL = 0x0000008, /* If detected separately */
  39. SND_JACK_VIDEOOUT = 0x0000010,
  40. SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT,
  41. /* */
  42. SND_JACK_LINEIN = 0x0000020,
  43. SND_JACK_OC_HPHL = 0x0000040,
  44. SND_JACK_OC_HPHR = 0x0000080,
  45. SND_JACK_UNSUPPORTED = 0x0000100,
  46. SND_JACK_MICROPHONE2 = 0x0000200,
  47. SND_JACK_ANC_HEADPHONE = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
  48. SND_JACK_MICROPHONE2,
  49. /* Kept separate from switches to facilitate implementation */
  50. SND_JACK_BTN_0 = 0x4000000,
  51. SND_JACK_BTN_1 = 0x2000000,
  52. SND_JACK_BTN_2 = 0x1000000,
  53. SND_JACK_BTN_3 = 0x0800000,
  54. SND_JACK_BTN_4 = 0x0400000,
  55. SND_JACK_BTN_5 = 0x0200000,
  56. SND_JACK_BTN_6 = 0x0100000,
  57. SND_JACK_BTN_7 = 0x0080000,
  58. };
  59. struct snd_jack {
  60. struct input_dev *input_dev;
  61. int registered;
  62. int type;
  63. const char *id;
  64. char name[100];
  65. unsigned int key[8]; /* Keep in sync with definitions above */
  66. void *private_data;
  67. void (*private_free)(struct snd_jack *);
  68. };
  69. #ifdef CONFIG_SND_JACK
  70. int snd_jack_new(struct snd_card *card, const char *id, int type,
  71. struct snd_jack **jack);
  72. void snd_jack_set_parent(struct snd_jack *jack, struct device *parent);
  73. int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
  74. int keytype);
  75. void snd_jack_report(struct snd_jack *jack, int status);
  76. #else
  77. static inline int snd_jack_new(struct snd_card *card, const char *id, int type,
  78. struct snd_jack **jack)
  79. {
  80. return 0;
  81. }
  82. static inline void snd_jack_set_parent(struct snd_jack *jack,
  83. struct device *parent)
  84. {
  85. }
  86. static inline void snd_jack_report(struct snd_jack *jack, int status)
  87. {
  88. }
  89. #endif
  90. #endif