jack.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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_USB: USB audio device
  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. SND_JACK_USB = 0x0040,
  44. /* Kept separate from switches to facilitate implementation */
  45. SND_JACK_BTN_0 = 0x4000,
  46. SND_JACK_BTN_1 = 0x2000,
  47. SND_JACK_BTN_2 = 0x1000,
  48. SND_JACK_BTN_3 = 0x0800,
  49. SND_JACK_BTN_4 = 0x0400,
  50. SND_JACK_BTN_5 = 0x0200,
  51. };
  52. /* Keep in sync with definitions above */
  53. #define SND_JACK_SWITCH_TYPES 7
  54. struct snd_jack {
  55. struct list_head kctl_list;
  56. struct snd_card *card;
  57. const char *id;
  58. #ifdef CONFIG_SND_JACK_INPUT_DEV
  59. struct input_dev *input_dev;
  60. struct mutex input_dev_lock;
  61. int registered;
  62. int type;
  63. char name[100];
  64. unsigned int key[6]; /* Keep in sync with definitions above */
  65. #endif /* CONFIG_SND_JACK_INPUT_DEV */
  66. int hw_status_cache;
  67. void *private_data;
  68. void (*private_free)(struct snd_jack *);
  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. int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
  76. int keytype);
  77. #endif
  78. void snd_jack_report(struct snd_jack *jack, int status);
  79. #else
  80. static inline int snd_jack_new(struct snd_card *card, const char *id, int type,
  81. struct snd_jack **jack, bool initial_kctl, bool phantom_jack)
  82. {
  83. return 0;
  84. }
  85. static inline int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
  86. {
  87. return 0;
  88. }
  89. static inline void snd_jack_report(struct snd_jack *jack, int status)
  90. {
  91. }
  92. #endif
  93. #if !defined(CONFIG_SND_JACK) || !defined(CONFIG_SND_JACK_INPUT_DEV)
  94. static inline int snd_jack_set_key(struct snd_jack *jack,
  95. enum snd_jack_types type,
  96. int keytype)
  97. {
  98. return 0;
  99. }
  100. #endif /* !CONFIG_SND_JACK || !CONFIG_SND_JACK_INPUT_DEV */
  101. #endif