jack.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef __SOUND_JACK_H
  3. #define __SOUND_JACK_H
  4. /*
  5. * Jack abstraction layer
  6. *
  7. * Copyright 2008 Wolfson Microelectronics plc
  8. */
  9. #include <sound/core.h>
  10. #include <linux/android_kabi.h>
  11. struct input_dev;
  12. /**
  13. * enum snd_jack_types - Jack types which can be reported
  14. * @SND_JACK_HEADPHONE: Headphone
  15. * @SND_JACK_MICROPHONE: Microphone
  16. * @SND_JACK_HEADSET: Headset
  17. * @SND_JACK_LINEOUT: Line out
  18. * @SND_JACK_MECHANICAL: Mechanical switch
  19. * @SND_JACK_VIDEOOUT: Video out
  20. * @SND_JACK_AVOUT: AV (Audio Video) out
  21. * @SND_JACK_LINEIN: Line in
  22. * @SND_JACK_BTN_0: Button 0
  23. * @SND_JACK_BTN_1: Button 1
  24. * @SND_JACK_BTN_2: Button 2
  25. * @SND_JACK_BTN_3: Button 3
  26. * @SND_JACK_BTN_4: Button 4
  27. * @SND_JACK_BTN_5: Button 5
  28. *
  29. * These values are used as a bitmask.
  30. *
  31. * Note that this must be kept in sync with the lookup table in
  32. * sound/core/jack.c.
  33. */
  34. enum snd_jack_types {
  35. SND_JACK_HEADPHONE = 0x0001,
  36. SND_JACK_MICROPHONE = 0x0002,
  37. SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE,
  38. SND_JACK_LINEOUT = 0x0004,
  39. SND_JACK_MECHANICAL = 0x0008, /* If detected separately */
  40. SND_JACK_VIDEOOUT = 0x0010,
  41. SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT,
  42. SND_JACK_LINEIN = 0x0020,
  43. /* Kept separate from switches to facilitate implementation */
  44. SND_JACK_BTN_0 = 0x4000,
  45. SND_JACK_BTN_1 = 0x2000,
  46. SND_JACK_BTN_2 = 0x1000,
  47. SND_JACK_BTN_3 = 0x0800,
  48. SND_JACK_BTN_4 = 0x0400,
  49. SND_JACK_BTN_5 = 0x0200,
  50. };
  51. /* Keep in sync with definitions above */
  52. #define SND_JACK_SWITCH_TYPES 6
  53. struct snd_jack {
  54. struct list_head kctl_list;
  55. struct snd_card *card;
  56. const char *id;
  57. #ifdef CONFIG_SND_JACK_INPUT_DEV
  58. struct input_dev *input_dev;
  59. struct mutex input_dev_lock;
  60. int registered;
  61. int type;
  62. char name[100];
  63. unsigned int key[6]; /* Keep in sync with definitions above */
  64. #endif /* CONFIG_SND_JACK_INPUT_DEV */
  65. int hw_status_cache;
  66. void *private_data;
  67. void (*private_free)(struct snd_jack *);
  68. ANDROID_KABI_RESERVE(1);
  69. };
  70. #ifdef CONFIG_SND_JACK
  71. int snd_jack_new(struct snd_card *card, const char *id, int type,
  72. struct snd_jack **jack, bool initial_kctl, bool phantom_jack);
  73. int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask);
  74. #ifdef CONFIG_SND_JACK_INPUT_DEV
  75. void snd_jack_set_parent(struct snd_jack *jack, struct device *parent);
  76. int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
  77. int keytype);
  78. #endif
  79. void snd_jack_report(struct snd_jack *jack, int status);
  80. #else
  81. static inline int snd_jack_new(struct snd_card *card, const char *id, int type,
  82. struct snd_jack **jack, bool initial_kctl, bool phantom_jack)
  83. {
  84. return 0;
  85. }
  86. static inline int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
  87. {
  88. return 0;
  89. }
  90. static inline void snd_jack_report(struct snd_jack *jack, int status)
  91. {
  92. }
  93. #endif
  94. #if !defined(CONFIG_SND_JACK) || !defined(CONFIG_SND_JACK_INPUT_DEV)
  95. static inline void snd_jack_set_parent(struct snd_jack *jack,
  96. struct device *parent)
  97. {
  98. }
  99. static inline int snd_jack_set_key(struct snd_jack *jack,
  100. enum snd_jack_types type,
  101. int keytype)
  102. {
  103. return 0;
  104. }
  105. #endif /* !CONFIG_SND_JACK || !CONFIG_SND_JACK_INPUT_DEV */
  106. #endif