midi.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * <linux/usb/midi.h> -- USB MIDI definitions.
  4. *
  5. * Copyright (C) 2006 Thumtronics Pty Ltd.
  6. * Developed for Thumtronics by Grey Innovation
  7. * Ben Williamson <[email protected]>
  8. *
  9. * This software is distributed under the terms of the GNU General Public
  10. * License ("GPL") version 2, as published by the Free Software Foundation.
  11. *
  12. * This file holds USB constants and structures defined
  13. * by the USB Device Class Definition for MIDI Devices.
  14. * Comments below reference relevant sections of that document:
  15. *
  16. * http://www.usb.org/developers/devclass_docs/midi10.pdf
  17. */
  18. #ifndef __LINUX_USB_MIDI_H
  19. #define __LINUX_USB_MIDI_H
  20. #include <linux/types.h>
  21. /* A.1 MS Class-Specific Interface Descriptor Subtypes */
  22. #define USB_MS_HEADER 0x01
  23. #define USB_MS_MIDI_IN_JACK 0x02
  24. #define USB_MS_MIDI_OUT_JACK 0x03
  25. #define USB_MS_ELEMENT 0x04
  26. /* A.2 MS Class-Specific Endpoint Descriptor Subtypes */
  27. #define USB_MS_GENERAL 0x01
  28. /* A.3 MS MIDI IN and OUT Jack Types */
  29. #define USB_MS_EMBEDDED 0x01
  30. #define USB_MS_EXTERNAL 0x02
  31. /* 6.1.2.1 Class-Specific MS Interface Header Descriptor */
  32. struct usb_ms_header_descriptor {
  33. __u8 bLength;
  34. __u8 bDescriptorType;
  35. __u8 bDescriptorSubtype;
  36. __le16 bcdMSC;
  37. __le16 wTotalLength;
  38. } __attribute__ ((packed));
  39. #define USB_DT_MS_HEADER_SIZE 7
  40. /* 6.1.2.2 MIDI IN Jack Descriptor */
  41. struct usb_midi_in_jack_descriptor {
  42. __u8 bLength;
  43. __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
  44. __u8 bDescriptorSubtype; /* USB_MS_MIDI_IN_JACK */
  45. __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */
  46. __u8 bJackID;
  47. __u8 iJack;
  48. } __attribute__ ((packed));
  49. #define USB_DT_MIDI_IN_SIZE 6
  50. struct usb_midi_source_pin {
  51. __u8 baSourceID;
  52. __u8 baSourcePin;
  53. } __attribute__ ((packed));
  54. /* 6.1.2.3 MIDI OUT Jack Descriptor */
  55. struct usb_midi_out_jack_descriptor {
  56. __u8 bLength;
  57. __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
  58. __u8 bDescriptorSubtype; /* USB_MS_MIDI_OUT_JACK */
  59. __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */
  60. __u8 bJackID;
  61. __u8 bNrInputPins; /* p */
  62. struct usb_midi_source_pin pins[]; /* [p] */
  63. /*__u8 iJack; -- omitted due to variable-sized pins[] */
  64. } __attribute__ ((packed));
  65. #define USB_DT_MIDI_OUT_SIZE(p) (7 + 2 * (p))
  66. /* As above, but more useful for defining your own descriptors: */
  67. #define DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(p) \
  68. struct usb_midi_out_jack_descriptor_##p { \
  69. __u8 bLength; \
  70. __u8 bDescriptorType; \
  71. __u8 bDescriptorSubtype; \
  72. __u8 bJackType; \
  73. __u8 bJackID; \
  74. __u8 bNrInputPins; \
  75. struct usb_midi_source_pin pins[p]; \
  76. __u8 iJack; \
  77. } __attribute__ ((packed))
  78. /* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */
  79. struct usb_ms_endpoint_descriptor {
  80. __u8 bLength; /* 4+n */
  81. __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
  82. __u8 bDescriptorSubtype; /* USB_MS_GENERAL */
  83. __u8 bNumEmbMIDIJack; /* n */
  84. __u8 baAssocJackID[]; /* [n] */
  85. } __attribute__ ((packed));
  86. #define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n))
  87. /* As above, but more useful for defining your own descriptors: */
  88. #define DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(n) \
  89. struct usb_ms_endpoint_descriptor_##n { \
  90. __u8 bLength; \
  91. __u8 bDescriptorType; \
  92. __u8 bDescriptorSubtype; \
  93. __u8 bNumEmbMIDIJack; \
  94. __u8 baAssocJackID[n]; \
  95. } __attribute__ ((packed))
  96. #endif /* __LINUX_USB_MIDI_H */