midi.h 3.3 KB

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