jack.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. * enum snd_jack_types - Jack types which can be reported
  28. * @SND_JACK_HEADPHONE: Headphone
  29. * @SND_JACK_MICROPHONE: Microphone
  30. * @SND_JACK_HEADSET: Headset
  31. * @SND_JACK_LINEOUT: Line out
  32. * @SND_JACK_MECHANICAL: Mechanical switch
  33. * @SND_JACK_VIDEOOUT: Video out
  34. * @SND_JACK_AVOUT: AV (Audio Video) out
  35. * @SND_JACK_LINEIN: Line in
  36. * @SND_JACK_BTN_0: Button 0
  37. * @SND_JACK_BTN_1: Button 1
  38. * @SND_JACK_BTN_2: Button 2
  39. * @SND_JACK_BTN_3: Button 3
  40. * @SND_JACK_BTN_4: Button 4
  41. * @SND_JACK_BTN_5: Button 5
  42. *
  43. * These values are used as a bitmask.
  44. *
  45. * Note that this must be kept in sync with the lookup table in
  46. * sound/core/jack.c.
  47. */
  48. enum snd_jack_types {
  49. SND_JACK_HEADPHONE = 0x0001,
  50. SND_JACK_MICROPHONE = 0x0002,
  51. SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE,
  52. SND_JACK_LINEOUT = 0x0004,
  53. SND_JACK_MECHANICAL = 0x0008, /* If detected separately */
  54. SND_JACK_VIDEOOUT = 0x0010,
  55. SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT,
  56. SND_JACK_LINEIN = 0x0020,
  57. /* Kept separate from switches to facilitate implementation */
  58. SND_JACK_BTN_0 = 0x4000,
  59. SND_JACK_BTN_1 = 0x2000,
  60. SND_JACK_BTN_2 = 0x1000,
  61. SND_JACK_BTN_3 = 0x0800,
  62. SND_JACK_BTN_4 = 0x0400,
  63. SND_JACK_BTN_5 = 0x0200,
  64. };
  65. /* Keep in sync with definitions above */
  66. #define SND_JACK_SWITCH_TYPES 6
  67. struct snd_jack {
  68. struct list_head kctl_list;
  69. struct snd_card *card;
  70. const char *id;
  71. #ifdef CONFIG_SND_JACK_INPUT_DEV
  72. struct input_dev *input_dev;
  73. int registered;
  74. int type;
  75. char name[100];
  76. unsigned int key[6]; /* Keep in sync with definitions above */
  77. #endif /* CONFIG_SND_JACK_INPUT_DEV */
  78. void *private_data;
  79. void (*private_free)(struct snd_jack *);
  80. };
  81. #ifdef CONFIG_SND_JACK
  82. int snd_jack_new(struct snd_card *card, const char *id, int type,
  83. struct snd_jack **jack, bool initial_kctl, bool phantom_jack);
  84. int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask);
  85. #ifdef CONFIG_SND_JACK_INPUT_DEV
  86. void snd_jack_set_parent(struct snd_jack *jack, struct device *parent);
  87. int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
  88. int keytype);
  89. #endif
  90. void snd_jack_report(struct snd_jack *jack, int status);
  91. #else
  92. static inline int snd_jack_new(struct snd_card *card, const char *id, int type,
  93. struct snd_jack **jack, bool initial_kctl, bool phantom_jack)
  94. {
  95. return 0;
  96. }
  97. static inline int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
  98. {
  99. return 0;
  100. }
  101. static inline void snd_jack_report(struct snd_jack *jack, int status)
  102. {
  103. }
  104. #endif
  105. #if !defined(CONFIG_SND_JACK) || !defined(CONFIG_SND_JACK_INPUT_DEV)
  106. static inline void snd_jack_set_parent(struct snd_jack *jack,
  107. struct device *parent)
  108. {
  109. }
  110. static inline int snd_jack_set_key(struct snd_jack *jack,
  111. enum snd_jack_types type,
  112. int keytype)
  113. {
  114. return 0;
  115. }
  116. #endif /* !CONFIG_SND_JACK || !CONFIG_SND_JACK_INPUT_DEV */
  117. #endif