jack.h 3.1 KB

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