usb_endpoints.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // Copyright 2023 Stefan Kerkmann (@KarlK90)
  2. // SPDX-License-Identifier: GPL-3.0-or-later
  3. #pragma once
  4. #include "usb_descriptor.h"
  5. #if !defined(USB_DEFAULT_BUFFER_CAPACITY)
  6. # define USB_DEFAULT_BUFFER_CAPACITY 4
  7. #endif
  8. #if !defined(KEYBOARD_IN_CAPACITY)
  9. # define KEYBOARD_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  10. #endif
  11. #if !defined(SHARED_IN_CAPACITY)
  12. # define SHARED_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  13. #endif
  14. #if !defined(MOUSE_IN_CAPACITY)
  15. # define MOUSE_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  16. #endif
  17. #if !defined(JOYSTICK_IN_CAPACITY)
  18. # define JOYSTICK_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  19. #endif
  20. #if !defined(DIGITIZER_IN_CAPACITY)
  21. # define DIGITIZER_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  22. #endif
  23. #if !defined(CONSOLE_IN_CAPACITY)
  24. # define CONSOLE_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  25. #endif
  26. #if !defined(CONSOLE_OUT_CAPACITY)
  27. # define CONSOLE_OUT_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  28. #endif
  29. #if !defined(RAW_IN_CAPACITY)
  30. # define RAW_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  31. #endif
  32. #if !defined(RAW_OUT_CAPACITY)
  33. # define RAW_OUT_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  34. #endif
  35. #if !defined(PLOVER_HID_IN_CAPACITY)
  36. # define PLOVER_HID_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  37. #endif
  38. #if !defined(MIDI_STREAM_IN_CAPACITY)
  39. # define MIDI_STREAM_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  40. #endif
  41. #if !defined(MIDI_STREAM_OUT_CAPACITY)
  42. # define MIDI_STREAM_OUT_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  43. #endif
  44. #if !defined(CDC_IN_CAPACITY)
  45. # define CDC_IN_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  46. #endif
  47. #if !defined(CDC_OUT_CAPACITY)
  48. # define CDC_OUT_CAPACITY USB_DEFAULT_BUFFER_CAPACITY
  49. #endif
  50. #define CDC_SIGNALING_DUMMY_CAPACITY 1
  51. typedef enum {
  52. #if defined(SHARED_EP_ENABLE)
  53. USB_ENDPOINT_IN_SHARED,
  54. #endif
  55. #if !defined(KEYBOARD_SHARED_EP)
  56. USB_ENDPOINT_IN_KEYBOARD,
  57. #endif
  58. #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
  59. USB_ENDPOINT_IN_MOUSE,
  60. #endif
  61. #if defined(JOYSTICK_ENABLE) && !defined(JOYSTICK_SHARED_EP)
  62. USB_ENDPOINT_IN_JOYSTICK,
  63. #endif
  64. #if defined(DIGITIZER_ENABLE) && !defined(DIGITIZER_SHARED_EP)
  65. USB_ENDPOINT_IN_DIGITIZER,
  66. #endif
  67. #if defined(CONSOLE_ENABLE)
  68. USB_ENDPOINT_IN_CONSOLE,
  69. #endif
  70. #if defined(RAW_ENABLE)
  71. USB_ENDPOINT_IN_RAW,
  72. #endif
  73. #if defined(PLOVER_HID_ENABLE)
  74. USB_ENDPOINT_IN_PLOVER_HID,
  75. #endif
  76. #if defined(MIDI_ENABLE)
  77. USB_ENDPOINT_IN_MIDI,
  78. #endif
  79. #if defined(VIRTSER_ENABLE)
  80. USB_ENDPOINT_IN_CDC_DATA,
  81. USB_ENDPOINT_IN_CDC_SIGNALING,
  82. #endif
  83. USB_ENDPOINT_IN_COUNT,
  84. /* All non shared endpoints have to be consequtive numbers starting from 0, so
  85. * that they can be used as array indices. The shared endpoints all point to
  86. * the same endpoint so they have to be defined last to not reset the enum
  87. * counter. */
  88. #if defined(SHARED_EP_ENABLE)
  89. # if defined(KEYBOARD_SHARED_EP)
  90. USB_ENDPOINT_IN_KEYBOARD = USB_ENDPOINT_IN_SHARED,
  91. # endif
  92. # if defined(MOUSE_SHARED_EP)
  93. USB_ENDPOINT_IN_MOUSE = USB_ENDPOINT_IN_SHARED,
  94. # endif
  95. # if defined(JOYSTICK_SHARED_EP)
  96. USB_ENDPOINT_IN_JOYSTICK = USB_ENDPOINT_IN_SHARED,
  97. # endif
  98. # if defined(DIGITIZER_SHARED_EP)
  99. USB_ENDPOINT_IN_DIGITIZER = USB_ENDPOINT_IN_SHARED,
  100. # endif
  101. #endif
  102. } usb_endpoint_in_lut_t;
  103. #define IS_VALID_USB_ENDPOINT_IN_LUT(i) ((i) >= 0 && (i) < USB_ENDPOINT_IN_COUNT)
  104. extern usb_endpoint_in_lut_t usb_endpoint_interface_lut[TOTAL_INTERFACES];
  105. typedef enum {
  106. #if defined(RAW_ENABLE)
  107. USB_ENDPOINT_OUT_RAW,
  108. #endif
  109. #if defined(MIDI_ENABLE)
  110. USB_ENDPOINT_OUT_MIDI,
  111. #endif
  112. #if defined(VIRTSER_ENABLE)
  113. USB_ENDPOINT_OUT_CDC_DATA,
  114. #endif
  115. USB_ENDPOINT_OUT_COUNT,
  116. } usb_endpoint_out_lut_t;