* Add USB MIDI descriptors that we must parse in usb_midi driver to support

multiple "jacks" devices.
* Add convention class-specific descriptor types
* Fix off-by-one capabilities bitmap values, that were severely broken before.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40429 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin 2011-02-10 19:35:40 +00:00
parent 45d9aa68ff
commit d136bfb173
3 changed files with 121 additions and 12 deletions

View File

@ -40,11 +40,17 @@
#define USB_REQUEST_SYNCH_FRAME 12 #define USB_REQUEST_SYNCH_FRAME 12
/* Used by {set|get}_descriptor() */ /* Used by {set|get}_descriptor() */
#define USB_DESCRIPTOR_DEVICE 1 #define USB_DESCRIPTOR_DEVICE 0x01
#define USB_DESCRIPTOR_CONFIGURATION 2 #define USB_DESCRIPTOR_CONFIGURATION 0x02
#define USB_DESCRIPTOR_STRING 3 #define USB_DESCRIPTOR_STRING 0x03
#define USB_DESCRIPTOR_INTERFACE 4 #define USB_DESCRIPTOR_INTERFACE 0x04
#define USB_DESCRIPTOR_ENDPOINT 5 #define USB_DESCRIPTOR_ENDPOINT 0x05
/* conventional class-specific descriptors */
#define USB_DESCRIPTOR_CS_DEVICE 0x21
#define USB_DESCRIPTOR_CS_CONFIGURATION 0x22
#define USB_DESCRIPTOR_CS_STRING 0x23
#define USB_DESCRIPTOR_CS_INTERFACE 0x24
#define USB_DESCRIPTOR_CS_ENDPOINT 0x25
/* Used by {set|clear}_feature() */ /* Used by {set|clear}_feature() */
#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 #define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1

View File

@ -53,8 +53,8 @@ typedef struct usb_cdc_cm_functional_descriptor {
} _PACKED usb_cdc_cm_functional_descriptor; } _PACKED usb_cdc_cm_functional_descriptor;
enum { // Call Management Functional Descriptor capabilities bitmap enum { // Call Management Functional Descriptor capabilities bitmap
USB_CDC_CM_DOES_CALL_MANAGEMENT = 0x00, USB_CDC_CM_DOES_CALL_MANAGEMENT = 0x01,
USB_CDC_CM_OVER_DATA_INTERFACE = 0x01 USB_CDC_CM_OVER_DATA_INTERFACE = 0x02
}; };
typedef struct usb_cdc_acm_functional_descriptor { typedef struct usb_cdc_acm_functional_descriptor {
@ -64,11 +64,11 @@ typedef struct usb_cdc_acm_functional_descriptor {
uint8 capabilities; uint8 capabilities;
} _PACKED usb_cdc_acm_functional_descriptor; } _PACKED usb_cdc_acm_functional_descriptor;
enum { // Abstract Control Model Functional Descriptor capabilities bitmap enum { // Abstract Control Model Functional Descriptor capabilities bitmap (p36)
USB_CDC_ACM_HAS_COMM_FEATURES = 0x00, USB_CDC_ACM_HAS_COMM_FEATURES = 0x01,
USB_CDC_ACM_HAS_LINE_CONTROL = 0x01, USB_CDC_ACM_HAS_LINE_CONTROL = 0x02,
USB_CDC_ACM_HAS_SEND_BREAK = 0x02, USB_CDC_ACM_HAS_SEND_BREAK = 0x04,
USB_CDC_ACM_HAS_NETWORK_CONNECTION = 0x04 USB_CDC_ACM_HAS_NETWORK_CONNECTION = 0x08
}; };
typedef struct usb_cdc_union_functional_descriptor { typedef struct usb_cdc_union_functional_descriptor {

View File

@ -17,4 +17,107 @@ typedef struct { // USB MIDI Event Packet
uint8 midi[3]; uint8 midi[3];
} _PACKED usb_midi_event_packet; } _PACKED usb_midi_event_packet;
// MIDIStreaming (ms) insterface descriptors (p20)
enum { // MIDI Streaming descriptors subtypes
USB_MS_HEADER_DESCRIPTOR = 0x01,
USB_MS_MIDI_IN_JACK_DESCRIPTOR,
USB_MS_MIDI_OUT_JACK_DESCRIPTOR,
USB_MS_ELEMENT_DESCRIPTOR
};
typedef struct usb_midi_interface_header_descriptor {
uint8 length;
uint8 descriptor_type;
uint8 descriptor_subtype; // USB_MS_HEADER_DESCRIPTOR
uint16 ms_version;
uint16 total_length;
} _PACKED usb_midi_interface_header_descriptor;
enum {
USB_MIDI_EMBEDDED_JACK = 0x01,
USB_MIDI_EXTERNAL_JACK
};
typedef struct usb_midi_in_jack_descriptor {
uint8 length;
uint8 descriptor_type;
uint8 descriptor_subtype; // USB_MS_MIDI_IN_JACK_DESCRIPTOR
uint8 type; // USB_MIDI_{EMBEDDED | EXTERNAL}_JACK
uint8 id;
uint8 string_descriptor;
} _PACKED usb_ms_midi_in_jack_descriptor;
typedef struct usb_midi_source {
uint8 source_id;
uint8 source_pin;
} _PACKED usb_midi_source;
typedef struct usb_midi_out_jack_descriptor {
uint8 length;
uint8 descriptor_type;
uint8 descriptor_subtype; // USB_MS_MIDI_OUT_JACK_DESCRIPTOR
uint8 type; // USB_MIDI_{EMBEDDED | EXTERNAL}_JACK
uint8 id;
uint8 inputs_count;
usb_midi_source input_source[0]; // inputs_count times
// uint8 string_descriptor;
} _PACKED usb_midi_out_jack_descriptor;
enum { // USB Element Capabilities bitmap (p23,25)
USB_MS_ELEMENT_CUSTOM_UNDEFINED = 0x0001,
USB_MS_ELEMENT_MIDI_CLOCK = 0x0002,
USB_MS_ELEMENT_MIDI_TIME_CODE = 0x0004,
USB_MS_ELEMENT_MTC = USB_MS_ELEMENT_MIDI_TIME_CODE,
USB_MS_ELEMENT_MIDI_MACHINE_CONTROL = 0x0008,
USB_MS_ELEMENT_MMC = USB_MS_ELEMENT_MIDI_MACHINE_CONTROL,
// General MIDI System Level 1 compatible
USB_MS_ELEMENT_GM1 = 0x0010,
// General MIDI System Level 2 compatible
USB_MS_ELEMENT_GM2 = 0x0020,
// GS Format compatible (Roland)
USB_MS_ELEMENT_GS = 0x0040,
// XG compatibily (Yamaha)
USB_MS_ELEMENT_XG = 0x0080,
USB_MS_ELEMENT_EFX = 0x0100,
// internal MIDI Patcher or Router
USB_MS_ELEMENT_MIDI_PATCH_BAY = 0x0200,
// Downloadable Sounds Standards Level 1 compatible
USB_MS_ELEMENT_DLS1 = 0x0400,
// Downloadable Sounds Standards Level 2 compatible
USB_MS_ELEMENT_DLS2 = 0x0800
};
typedef struct usb_midi_element_descriptor {
uint8 length;
uint8 descriptor_type;
uint8 descriptor_subtype; // USB_MS_ELEMENT_DESCRIPTOR
uint8 id;
uint8 inputs_count;
usb_midi_source input_source[0]; // inputs_count times
// uint8 outputs_count;
// uint8 input_terminal_id;
// uint8 output_terminal_id;
// uint8 capabilities_size;
// uint8 capabilities[0]; // capabilities_size bytes
// uint8 string_descriptor; // see USB_MS_ELEMENT_* enum above
} _PACKED usb_midi_element_descriptor;
// Class-Specific MIDIStream Bulk Data Endpoint descriptor (p26)
#define USB_MS_GENERAL_DESCRIPTOR 0x01
typedef struct usb_midi_endpoint_descriptor {
uint8 length;
uint8 descriptor_type; // USB_DESCRIPTOR_CS_ENDPOINT
uint8 descriptor_subtype; // USB_MS_GENERAL_DESCRIPTOR
uint8 jacks_count;
uint8 jacks_id[0]; // jacks_count times
} _PACKED usb_midi_endpoint_descriptor;
#endif // USB_MIDI_H #endif // USB_MIDI_H