Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


midi.h
001: /*
002:  * <linux/usb/midi.h> -- USB MIDI definitions.
003:  *
004:  * Copyright (C) 2006 Thumtronics Pty Ltd.
005:  * Developed for Thumtronics by Grey Innovation
006:  * Ben Williamson <ben.williamson@greyinnovation.com>
007:  *
008:  * This software is distributed under the terms of the GNU General Public
009:  * License ("GPL") version 2, as published by the Free Software Foundation.
010:  *
011:  * This file holds USB constants and structures defined
012:  * by the USB Device Class Definition for MIDI Devices.
013:  * Comments below reference relevant sections of that document:
014:  *
015:  * http://www.usb.org/developers/devclass_docs/midi10.pdf
016:  */
017: 
018: #ifndef __LINUX_USB_MIDI_H
019: #define __LINUX_USB_MIDI_H
020: 
021: #include <linux/types.h>
022: 
023: /* A.1  MS Class-Specific Interface Descriptor Subtypes */
024: #define USB_MS_HEADER           0x01
025: #define USB_MS_MIDI_IN_JACK     0x02
026: #define USB_MS_MIDI_OUT_JACK    0x03
027: #define USB_MS_ELEMENT          0x04
028: 
029: /* A.2  MS Class-Specific Endpoint Descriptor Subtypes */
030: #define USB_MS_GENERAL          0x01
031: 
032: /* A.3  MS MIDI IN and OUT Jack Types */
033: #define USB_MS_EMBEDDED         0x01
034: #define USB_MS_EXTERNAL         0x02
035: 
036: /* 6.1.2.1  Class-Specific MS Interface Header Descriptor */
037: struct usb_ms_header_descriptor {
038:         __u8  bLength;
039:         __u8  bDescriptorType;
040:         __u8  bDescriptorSubtype;
041:         __le16 bcdMSC;
042:         __le16 wTotalLength;
043: } __attribute__ ((packed));
044: 
045: #define USB_DT_MS_HEADER_SIZE   7
046: 
047: /* 6.1.2.2  MIDI IN Jack Descriptor */
048: struct usb_midi_in_jack_descriptor {
049:         __u8  bLength;
050:         __u8  bDescriptorType;          /* USB_DT_CS_INTERFACE */
051:         __u8  bDescriptorSubtype;       /* USB_MS_MIDI_IN_JACK */
052:         __u8  bJackType;                /* USB_MS_EMBEDDED/EXTERNAL */
053:         __u8  bJackID;
054:         __u8  iJack;
055: } __attribute__ ((packed));
056: 
057: #define USB_DT_MIDI_IN_SIZE     6
058: 
059: struct usb_midi_source_pin {
060:         __u8  baSourceID;
061:         __u8  baSourcePin;
062: } __attribute__ ((packed));
063: 
064: /* 6.1.2.3  MIDI OUT Jack Descriptor */
065: struct usb_midi_out_jack_descriptor {
066:         __u8  bLength;
067:         __u8  bDescriptorType;          /* USB_DT_CS_INTERFACE */
068:         __u8  bDescriptorSubtype;       /* USB_MS_MIDI_OUT_JACK */
069:         __u8  bJackType;                /* USB_MS_EMBEDDED/EXTERNAL */
070:         __u8  bJackID;
071:         __u8  bNrInputPins;             /* p */
072:         struct usb_midi_source_pin pins[]; /* [p] */
073:         /*__u8  iJack;  -- omitted due to variable-sized pins[] */
074: } __attribute__ ((packed));
075: 
076: #define USB_DT_MIDI_OUT_SIZE(p) (7 + 2 * (p))
077: 
078: /* As above, but more useful for defining your own descriptors: */
079: #define DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(p)                 \
080: struct usb_midi_out_jack_descriptor_##p {                       \
081:         __u8  bLength;                                          \
082:         __u8  bDescriptorType;                                  \
083:         __u8  bDescriptorSubtype;                               \
084:         __u8  bJackType;                                        \
085:         __u8  bJackID;                                          \
086:         __u8  bNrInputPins;                                     \
087:         struct usb_midi_source_pin pins[p];                     \
088:         __u8  iJack;                                            \
089: } __attribute__ ((packed))
090: 
091: /* 6.2.2  Class-Specific MS Bulk Data Endpoint Descriptor */
092: struct usb_ms_endpoint_descriptor {
093:         __u8  bLength;                  /* 4+n */
094:         __u8  bDescriptorType;          /* USB_DT_CS_ENDPOINT */
095:         __u8  bDescriptorSubtype;       /* USB_MS_GENERAL */
096:         __u8  bNumEmbMIDIJack;          /* n */
097:         __u8  baAssocJackID[];          /* [n] */
098: } __attribute__ ((packed));
099: 
100: #define USB_DT_MS_ENDPOINT_SIZE(n)      (4 + (n))
101: 
102: /* As above, but more useful for defining your own descriptors: */
103: #define DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(n)                   \
104: struct usb_ms_endpoint_descriptor_##n {                         \
105:         __u8  bLength;                                          \
106:         __u8  bDescriptorType;                                  \
107:         __u8  bDescriptorSubtype;                               \
108:         __u8  bNumEmbMIDIJack;                                  \
109:         __u8  baAssocJackID[n];                                 \
110: } __attribute__ ((packed))
111: 
112: #endif /* __LINUX_USB_MIDI_H */
113: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/