Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * <linux/usb/midi.h> -- USB MIDI definitions.
0004  *
0005  * Copyright (C) 2006 Thumtronics Pty Ltd.
0006  * Developed for Thumtronics by Grey Innovation
0007  * Ben Williamson <ben.williamson@greyinnovation.com>
0008  *
0009  * This software is distributed under the terms of the GNU General Public
0010  * License ("GPL") version 2, as published by the Free Software Foundation.
0011  *
0012  * This file holds USB constants and structures defined
0013  * by the USB Device Class Definition for MIDI Devices.
0014  * Comments below reference relevant sections of that document:
0015  *
0016  * http://www.usb.org/developers/devclass_docs/midi10.pdf
0017  */
0018 
0019 #ifndef __LINUX_USB_MIDI_H
0020 #define __LINUX_USB_MIDI_H
0021 
0022 #include <linux/types.h>
0023 
0024 /* A.1  MS Class-Specific Interface Descriptor Subtypes */
0025 #define USB_MS_HEADER       0x01
0026 #define USB_MS_MIDI_IN_JACK 0x02
0027 #define USB_MS_MIDI_OUT_JACK    0x03
0028 #define USB_MS_ELEMENT      0x04
0029 
0030 /* A.2  MS Class-Specific Endpoint Descriptor Subtypes */
0031 #define USB_MS_GENERAL      0x01
0032 
0033 /* A.3  MS MIDI IN and OUT Jack Types */
0034 #define USB_MS_EMBEDDED     0x01
0035 #define USB_MS_EXTERNAL     0x02
0036 
0037 /* 6.1.2.1  Class-Specific MS Interface Header Descriptor */
0038 struct usb_ms_header_descriptor {
0039     __u8  bLength;
0040     __u8  bDescriptorType;
0041     __u8  bDescriptorSubtype;
0042     __le16 bcdMSC;
0043     __le16 wTotalLength;
0044 } __attribute__ ((packed));
0045 
0046 #define USB_DT_MS_HEADER_SIZE   7
0047 
0048 /* 6.1.2.2  MIDI IN Jack Descriptor */
0049 struct usb_midi_in_jack_descriptor {
0050     __u8  bLength;
0051     __u8  bDescriptorType;      /* USB_DT_CS_INTERFACE */
0052     __u8  bDescriptorSubtype;   /* USB_MS_MIDI_IN_JACK */
0053     __u8  bJackType;        /* USB_MS_EMBEDDED/EXTERNAL */
0054     __u8  bJackID;
0055     __u8  iJack;
0056 } __attribute__ ((packed));
0057 
0058 #define USB_DT_MIDI_IN_SIZE 6
0059 
0060 struct usb_midi_source_pin {
0061     __u8  baSourceID;
0062     __u8  baSourcePin;
0063 } __attribute__ ((packed));
0064 
0065 /* 6.1.2.3  MIDI OUT Jack Descriptor */
0066 struct usb_midi_out_jack_descriptor {
0067     __u8  bLength;
0068     __u8  bDescriptorType;      /* USB_DT_CS_INTERFACE */
0069     __u8  bDescriptorSubtype;   /* USB_MS_MIDI_OUT_JACK */
0070     __u8  bJackType;        /* USB_MS_EMBEDDED/EXTERNAL */
0071     __u8  bJackID;
0072     __u8  bNrInputPins;     /* p */
0073     struct usb_midi_source_pin pins[]; /* [p] */
0074     /*__u8  iJack;  -- omitted due to variable-sized pins[] */
0075 } __attribute__ ((packed));
0076 
0077 #define USB_DT_MIDI_OUT_SIZE(p) (7 + 2 * (p))
0078 
0079 /* As above, but more useful for defining your own descriptors: */
0080 #define DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(p)         \
0081 struct usb_midi_out_jack_descriptor_##p {           \
0082     __u8  bLength;                      \
0083     __u8  bDescriptorType;                  \
0084     __u8  bDescriptorSubtype;               \
0085     __u8  bJackType;                    \
0086     __u8  bJackID;                      \
0087     __u8  bNrInputPins;                 \
0088     struct usb_midi_source_pin pins[p];         \
0089     __u8  iJack;                        \
0090 } __attribute__ ((packed))
0091 
0092 /* 6.2.2  Class-Specific MS Bulk Data Endpoint Descriptor */
0093 struct usb_ms_endpoint_descriptor {
0094     __u8  bLength;          /* 4+n */
0095     __u8  bDescriptorType;      /* USB_DT_CS_ENDPOINT */
0096     __u8  bDescriptorSubtype;   /* USB_MS_GENERAL */
0097     __u8  bNumEmbMIDIJack;      /* n */
0098     __u8  baAssocJackID[];      /* [n] */
0099 } __attribute__ ((packed));
0100 
0101 #define USB_DT_MS_ENDPOINT_SIZE(n)  (4 + (n))
0102 
0103 /* As above, but more useful for defining your own descriptors: */
0104 #define DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(n)           \
0105 struct usb_ms_endpoint_descriptor_##n {             \
0106     __u8  bLength;                      \
0107     __u8  bDescriptorType;                  \
0108     __u8  bDescriptorSubtype;               \
0109     __u8  bNumEmbMIDIJack;                  \
0110     __u8  baAssocJackID[n];                 \
0111 } __attribute__ ((packed))
0112 
0113 #endif /* __LINUX_USB_MIDI_H */