xref: /openbsd/sys/dev/usb/umidireg.h (revision ab0b1be7)
1 /*	$OpenBSD: umidireg.h,v 1.8 2013/04/15 09:23:02 mglocker Exp $	*/
2 /*	$NetBSD: umidireg.h,v 1.3 2003/12/04 13:57:31 keihan Exp $	*/
3 /*
4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Takuya SHIOZAKI (tshiozak@NetBSD.org).
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /* Jack Descriptor */
33 #define UMIDI_MS_HEADER	0x01
34 #define UMIDI_IN_JACK	0x02
35 #define UMIDI_OUT_JACK	0x03
36 
37 /* Jack Type */
38 #define UMIDI_EMBEDDED	0x01
39 #define UMIDI_EXTERNAL	0x02
40 
41 struct umidi_cs_interface_descriptor {
42 	uByte		bLength;
43 	uByte		bDescriptorType;
44 	uByte		bDescriptorSubtype;
45 	uWord		bcdMSC;
46 	uWord		wTotalLength;
47 } __packed;
48 #define UMIDI_CS_INTERFACE_DESCRIPTOR_SIZE 7
49 
50 struct umidi_cs_endpoint_descriptor {
51 	uByte		bLength;
52 	uByte		bDescriptorType;
53 	uByte		bDescriptorSubType;
54 	uByte		bNumEmbMIDIJack;
55 } __packed;
56 #define UMIDI_CS_ENDPOINT_DESCRIPTOR_SIZE 4
57 
58 struct umidi_jack_descriptor {
59 	uByte		bLength;
60 	uByte		bDescriptorType;
61 	uByte		bDescriptorSubtype;
62 	uByte		bJackType;
63 	uByte		bJackID;
64 } __packed;
65 #define	UMIDI_JACK_DESCRIPTOR_SIZE	5
66 
67 
68 #define TO_D(p) ((usb_descriptor_t *)(p))
69 #define NEXT_D(desc) TO_D((caddr_t)(desc)+(desc)->bLength)
70 #define TO_IFD(desc) ((usb_interface_descriptor_t *)(desc))
71 #define TO_CSIFD(desc) ((struct umidi_cs_interface_descriptor *)(desc))
72 #define TO_EPD(desc) ((usb_endpoint_descriptor_t *)(desc))
73 #define TO_CSEPD(desc) ((struct umidi_cs_endpoint_descriptor *)(desc))
74