* Rewrote USB_rle.h, USB_spec.h, and midi_driver.h. I did not reproduce the

documentation found in those headers - this stuff should go into the Haiku
  Book instead (although I'm not even sure the USB_rle.h, and midi_driver.h
  are really needed any longer).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32901 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-09-02 12:04:00 +00:00
parent 44fbca2790
commit 47000651b5
3 changed files with 145 additions and 267 deletions
+10 -66
View File
@@ -1,82 +1,30 @@
/*
** USB_rle.h
**
** Copyright 1999, Be Incorporated. All Rights Reserved.
**
*/
/*
* Copyright 2009, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _USB_RLE_H
#define _USB_RLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <SupportDefs.h>
struct _usbd_param_hdr;
/*
Run Length encoding records for isochronous IN transfers.
Run Length encoding records are used to identify which samples in
the buffer are good which are bad and which are missing.
Bad bytes are not extracted from the buffer, but are padded to next
nearest sample boundary. The ultimate consumer of the buffer
should also receive the RLE array.
RLE records are constructed based on the following rules:
1. an RLE record contains a sample count and a status
(good, bad, missing or unknown). A buffer has
associated with it an array of rle records. The number of
rle records available is specified in the RLE header. The
number used is also in the RLE header.
2. Within the scope of a buffer, successive packets with the
same completion status are represented with (1) rle record.
For example, after three transactions which have completion
status of success, the byte count in the rle record for this
position in the data stream represents the bytes received in
all three packets.
3. New rle records are initialized each time the status for a
given packet differs from that of the previous packet.
*/
/* Run length encoding for isochronous in transfers */
#define RLE_GOOD 1
#define RLE_BAD 2
#define RLE_MISSING 3
#define RLE_UNKNOWN 4
/*
Name: rle
Purpose: used to represent the state of a portion of a data buffer
Fields:
rle_status will contain only the values: RLE_GOOD, RLE_BAD, RLE_MISSING
sample_count the number of usb samples in the buffer associated with this rle
record.
Notes:
If the buffer length field in queue_buffer_single structure changes to an
uint32 from uin16, then the sample_count data type must
track this change.
*/
/* data buffer state */
typedef struct rle {
uint16 rle_status;
uint16 sample_count;
} rle;
/*
Name: rlea
Purpose: used as the primary rle information data structure between the
USB driver stack and a consuming client.
Fields:
length the number of rle records available in this structure.
num_valid filled in by the USB driver. indicates the number of valid
records filled.
rles[] unconstrained array of rle records.
*/
typedef struct rlea {
uint16 length;
uint16 num_valid;
@@ -84,8 +32,4 @@ typedef struct rlea {
} rlea;
#ifdef __cplusplus
}
#endif
#endif
#endif /* _USB_RLE_H */
+105 -123
View File
@@ -1,152 +1,134 @@
/*
** USB_spec.h
**
** Copyright 1999, Be Incorporated. All Rights Reserved.
**
** This file contains structures and constants based on the USB Specification 1.1
**
*/
/*
* Copyright 2009, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _USB_SPEC_H
#define _USB_SPEC_H
#ifdef __cplusplus
extern "C" {
#endif
/* request types (target & direction) for send_request() */
/* cf USB Spec Rev 1.1, table 9-2, p 183 */
#define USB_REQTYPE_DEVICE_IN 0x80
#define USB_REQTYPE_DEVICE_OUT 0x00
#define USB_REQTYPE_INTERFACE_IN 0x81
#define USB_REQTYPE_INTERFACE_OUT 0x01
#define USB_REQTYPE_ENDPOINT_IN 0x82
#define USB_REQTYPE_ENDPOINT_OUT 0x02
#define USB_REQTYPE_OTHER_OUT 0x03
#define USB_REQTYPE_OTHER_IN 0x83
#include <SupportDefs.h>
/* request types for send_request() */
/* cf USB Spec Rev 1.1, table 9-2, p 183 */
#define USB_REQTYPE_STANDARD 0x00
#define USB_REQTYPE_CLASS 0x20
#define USB_REQTYPE_VENDOR 0x40
#define USB_REQTYPE_RESERVED 0x60
#define USB_REQTYPE_MASK 0x9F
/* standard request values for send_request() */
/* cf USB Spec Rev 1.1, table 9-4, p 187 */
#define USB_REQUEST_GET_STATUS 0
#define USB_REQUEST_CLEAR_FEATURE 1
#define USB_REQUEST_SET_FEATURE 3
#define USB_REQUEST_SET_ADDRESS 5
#define USB_REQUEST_GET_DESCRIPTOR 6
#define USB_REQUEST_SET_DESCRIPTOR 7
#define USB_REQUEST_GET_CONFIGURATION 8
#define USB_REQUEST_SET_CONFIGURATION 9
#define USB_REQUEST_GET_INTERFACE 10
#define USB_REQUEST_SET_INTERFACE 11
#define USB_REQUEST_SYNCH_FRAME 12
/* Request types (target/direction) for send_request() */
#define USB_REQTYPE_DEVICE_IN 0x80
#define USB_REQTYPE_DEVICE_OUT 0x00
#define USB_REQTYPE_INTERFACE_IN 0x81
#define USB_REQTYPE_INTERFACE_OUT 0x01
#define USB_REQTYPE_ENDPOINT_IN 0x82
#define USB_REQTYPE_ENDPOINT_OUT 0x02
#define USB_REQTYPE_OTHER_OUT 0x03
#define USB_REQTYPE_OTHER_IN 0x83
/* used by {set,get}_descriptor() */
/* cf USB Spec Rev 1.1, table 9-5, p 187 */
#define USB_DESCRIPTOR_DEVICE 1
#define USB_DESCRIPTOR_CONFIGURATION 2
#define USB_DESCRIPTOR_STRING 3
#define USB_DESCRIPTOR_INTERFACE 4
#define USB_DESCRIPTOR_ENDPOINT 5
/* Request types for send_request() */
#define USB_REQTYPE_STANDARD 0x00
#define USB_REQTYPE_CLASS 0x20
#define USB_REQTYPE_VENDOR 0x40
#define USB_REQTYPE_RESERVED 0x60
#define USB_REQTYPE_MASK 0x9f
/* used by {set,clear}_feature() */
/* cf USB Spec Rev 1.1, table 9-6, p 188 */
/* Standard request values for send_request() */
#define USB_REQUEST_GET_STATUS 0
#define USB_REQUEST_CLEAR_FEATURE 1
#define USB_REQUEST_SET_FEATURE 3
#define USB_REQUEST_SET_ADDRESS 5
#define USB_REQUEST_GET_DESCRIPTOR 6
#define USB_REQUEST_SET_DESCRIPTOR 7
#define USB_REQUEST_GET_CONFIGURATION 8
#define USB_REQUEST_SET_CONFIGURATION 9
#define USB_REQUEST_GET_INTERFACE 10
#define USB_REQUEST_SET_INTERFACE 11
#define USB_REQUEST_SYNCH_FRAME 12
/* Used by {set|get}_descriptor() */
#define USB_DESCRIPTOR_DEVICE 1
#define USB_DESCRIPTOR_CONFIGURATION 2
#define USB_DESCRIPTOR_STRING 3
#define USB_DESCRIPTOR_INTERFACE 4
#define USB_DESCRIPTOR_ENDPOINT 5
/* Used by {set|clear}_feature() */
#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1
#define USB_FEATURE_ENDPOINT_HALT 0
#define USB_ENDPOINT_ATTR_CONTROL 0x00
#define USB_ENDPOINT_ATTR_ISOCHRONOUS 0x01
#define USB_ENDPOINT_ATTR_BULK 0x02
#define USB_ENDPOINT_ATTR_INTERRUPT 0x03
#define USB_ENDPOINT_ATTR_MASK 0x03
#define USB_ENDPOINT_ATTR_CONTROL 0x00
#define USB_ENDPOINT_ATTR_ISOCHRONOUS 0x01
#define USB_ENDPOINT_ATTR_BULK 0x02
#define USB_ENDPOINT_ATTR_INTERRUPT 0x03
#define USB_ENDPOINT_ATTR_MASK 0x03
#define USB_ENDPOINT_ADDR_DIR_IN 0x80
#define USB_ENDPOINT_ADDR_DIR_OUT 0x00
#define USB_ENDPOINT_ADDR_DIR_IN 0x80
#define USB_ENDPOINT_ADDR_DIR_OUT 0x00
typedef struct {
/* cf USB Spec Rev 1.1, table 9-7, p 197 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_DEVICE */
uint16 usb_version; /* USB_DESCRIPTOR_DEVICE_LENGTH */
uint8 device_class;
uint8 device_subclass;
uint8 device_protocol;
uint8 max_packet_size_0;
uint16 vendor_id;
uint16 product_id;
uint16 device_version;
uint8 manufacturer;
uint8 product;
uint8 serial_number;
uint8 num_configurations;
typedef struct usb_device_descriptor {
uint8 length;
uint8 descriptor_type;
uint16 usb_version;
uint8 device_class;
uint8 device_subclass;
uint8 device_protocol;
uint8 max_packet_size_0;
uint16 vendor_id;
uint16 product_id;
uint16 device_version;
uint8 manufacturer;
uint8 product;
uint8 serial_number;
uint8 num_configurations;
} _PACKED usb_device_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-8, p 199 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_CONFIGURATION */
uint16 total_length; /* USB_DESCRIPTOR_CONFIGURATION_LENGTH */
uint8 number_interfaces;
uint8 configuration_value;
uint8 configuration;
uint8 attributes;
uint8 max_power;
typedef struct usb_configuration_descriptor {
uint8 length;
uint8 descriptor_type;
uint16 total_length;
uint8 number_interfaces;
uint8 configuration_value;
uint8 configuration;
uint8 attributes;
uint8 max_power;
} _PACKED usb_configuration_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-9, p 202 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_INTERFACE */
uint8 interface_number; /* USB_DESCRIPTOR_INTERFACE_LENGTH */
uint8 alternate_setting;
uint8 num_endpoints;
uint8 interface_class;
uint8 interface_subclass;
uint8 interface_protocol;
uint8 interface;
typedef struct usb_interface_descriptor {
uint8 length;
uint8 descriptor_type;
uint8 interface_number;
uint8 alternate_setting;
uint8 num_endpoints;
uint8 interface_class;
uint8 interface_subclass;
uint8 interface_protocol;
uint8 interface;
} _PACKED usb_interface_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-10, p 203 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_ENDPOINT */
uint8 endpoint_address; /* USB_DESCRIPTOR_ENDPOINT_LENGTH */
uint8 attributes;
uint16 max_packet_size;
uint8 interval;
typedef struct usb_endpoint_descriptor {
uint8 length;
uint8 descriptor_type;
uint8 endpoint_address;
uint8 attributes;
uint16 max_packet_size;
uint8 interval;
} _PACKED usb_endpoint_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-12, p 205 */
uint8 length; /* USB_DESCRIPTOR_STRING */
uint8 descriptor_type;
uchar string[1];
typedef struct usb_string_descriptor {
uint8 length;
uint8 descriptor_type;
uchar string[1];
} _PACKED usb_string_descriptor;
typedef struct {
uint8 length;
uint8 descriptor_type;
uint8 data[1];
typedef struct usb_generic_descriptor {
uint8 length;
uint8 descriptor_type;
uint8 data[1];
} _PACKED usb_generic_descriptor;
typedef union {
usb_generic_descriptor generic;
usb_device_descriptor device;
usb_interface_descriptor interface;
usb_endpoint_descriptor endpoint;
usb_configuration_descriptor configuration;
usb_string_descriptor string;
typedef union usb_descriptor {
usb_generic_descriptor generic;
usb_device_descriptor device;
usb_interface_descriptor interface;
usb_endpoint_descriptor endpoint;
usb_configuration_descriptor configuration;
usb_string_descriptor string;
} usb_descriptor;
#ifdef __cplusplus
}
#endif
#endif
#endif /* _USB_SPEC_H */
+30 -78
View File
@@ -1,28 +1,16 @@
/* ++++++++++
FILE: midi_driver.h
REVS: $Revision: 1.1 $
NAME: herold
DATE: Tue Jun 4 15:23:29 PDT 1996
Interface to /dev/midi, the midi driver
+++++ */
/*
Copyright 1999, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License.
*/
* Copyright 2009, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _MIDI_DRIVER_H
#define _MIDI_DRIVER_H
#include <Drivers.h>
#include <module.h>
/* -----
ioctl codes
----- */
/* the old opcodes are deprecated, and may or may not work
in newer drivers */
/* deprecated interface */
enum {
B_MIDI_GET_READ_TIMEOUT = B_MIDI_DRIVER_BASE,
B_MIDI_SET_READ_TIMEOUT,
@@ -34,85 +22,49 @@ enum {
B_MIDI_SET_READ_TIMEOUT_OLD
};
/* the default timeout when you open a midi driver */
#define B_MIDI_DEFAULT_TIMEOUT 1000000000000000LL
/* Usage:
To read, set "data" to a pointer to your buffer, and "size" to the
maximum size of this buffer. On return, "when" will contain the time
at which the data was received (first byte) and "size" will contain
the actual amount of data read.
Call ioctl(fd, B_MIDI_TIMED_READ, &midi_timed_data, sizeof(midi_timed_data));
To write, set "when" to when you want the first byte to go out the
wire, set "data" to point to your data, and set "size" to the size
of your data.
Call ioctl(fd, B_MIDI_TIMED_WRITE, &midi_timed_data, sizeof(midi_timed_data));
*/
typedef struct {
bigtime_t when;
size_t size;
unsigned char * data;
bigtime_t when;
size_t size;
uint8* data;
} midi_timed_data;
/* The MIDI parser returns the number of bytes that a message contains, given the */
/* initial byte. For some messages, this is not known until the second byte is seen. */
/* For such messages, a state > 0 is returned as well as some count > 0. When state */
/* is > 0, you should call (*parse) for the next byte as well, which might modify */
/* the returned message size. Message size will always be returned with the current */
/* byte being counted as byte 1. A return of 0 means that the byte initiates a new */
/* message. SysX is handled by returning max_size until the end or next initial message */
/* is seen. So your loop looks something like: */
/*
uint32 state = 0; // Only set this to 0 the first time you call the parser.
// preserve the 'state' between invocations of your read() hook.
int todo = 0;
unsigned char * end = in_buf+buf_size
unsigned char * out_buf = in_buf;
while (true) {
uchar byte = read_midi();
if (!todo || state) {
todo = (*parser->parse)(&state, byte, end-out_buf);
}
if (todo < 1) {
unput_midi(byte);
} else {
*(out_buf++) = byte;
todo--;
}
if (todo < 1 || out_buf >= end) {
received_midi_message(in_buf, out_buf-in_buf);
todo = 0;
}
}
*/
#define B_MIDI_PARSER_MODULE_NAME "media/midiparser/v1"
typedef struct _midi_parser_module_info {
module_info minfo;
int (*parse)(uint32 * state, uchar byte, size_t max_size);
int _reserved_;
int (*parse)(uint32* state, uchar byte, size_t maxSize);
int _reserved_;
} midi_parser_module_info;
#define B_MPU_401_MODULE_NAME "generic/mpu401/v1"
enum {
B_MPU_401_ENABLE_CARD_INT = 1,
B_MPU_401_DISABLE_CARD_INT
};
typedef struct _generic_mpu401_module {
module_info minfo;
status_t (*create_device)(int port, void ** out_storage, uint32 workarounds, void (*interrupt_op)(int32 op, void * card), void * card);
status_t (*delete_device)(void * storage);
status_t (*open_hook)(void * storage, uint32 flags, void ** out_cookie);
status_t (*close_hook)(void * cookie);
status_t (*free_hook)(void * cookie);
status_t (*control_hook)(void * cookie, uint32 op, void * data, size_t len);
status_t (*read_hook)(void * cookie, off_t pos, void * data, size_t * len);
status_t (*write_hook)(void * cookie, off_t pos, const void * data, size_t * len);
bool (*interrupt_hook)(void * cookie);
int _reserved_;
module_info minfo;
status_t (*create_device)(int port, void** _handle, uint32 workArounds,
void (*interruptOp)(int32 op, void* card), void* card);
status_t (*delete_device)(void* handle);
status_t (*open_hook)(void* storage, uint32 flags, void** _cookie);
status_t (*close_hook)(void* cookie);
status_t (*free_hook)(void* cookie);
status_t (*control_hook)(void* cookie, uint32 op, void* data,
size_t length);
status_t (*read_hook)(void* cookie, off_t pos, void* data,
size_t* _length);
status_t (*write_hook)(void* cookie, off_t pos, const void* data,
size_t* _length);
bool (*interrupt_hook)(void* cookie);
int _reserved_;
} generic_mpu401_module;
#endif
#endif /* _MIDI_DRIVER_H */