1 /* $OpenBSD: umidivar.h,v 1.8 2004/06/27 19:44:48 deraadt Exp $ */ 2 /* $NetBSD: umidivar.h,v 1.5 2002/09/12 21:00:42 augustss 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 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #define UMIDI_PACKET_SIZE 4 40 struct umidi_packet { 41 unsigned status; 42 unsigned index; 43 unsigned char buffer[UMIDI_PACKET_SIZE]; 44 }; 45 46 /* 47 * hierarchie 48 * 49 * <-- parent child --> 50 * 51 * umidi(sc) -> endpoint -> jack <- (dynamically assignable) - mididev 52 * ^ | ^ | 53 * +-----+ +-----+ 54 */ 55 56 /* midi device */ 57 struct umidi_mididev { 58 struct umidi_softc *sc; 59 struct device *mdev; 60 /* */ 61 struct umidi_jack *in_jack; 62 struct umidi_jack *out_jack; 63 /* */ 64 int opened; 65 int flags; 66 }; 67 68 /* Jack Information */ 69 struct umidi_jack { 70 struct umidi_endpoint *endpoint; 71 /* */ 72 int cable_number; 73 struct umidi_packet packet; 74 void *arg; 75 int binded; 76 int opened; 77 union { 78 struct { 79 void (*intr)(void *); 80 TAILQ_ENTRY(umidi_jack) queue_entry; 81 } out; 82 struct { 83 void (*intr)(void *, int); 84 } in; 85 } u; 86 }; 87 88 #define UMIDI_MAX_EPJACKS 16 89 /* endpoint data */ 90 struct umidi_endpoint { 91 struct umidi_softc *sc; 92 /* */ 93 int addr; 94 usbd_pipe_handle pipe; 95 usbd_xfer_handle xfer; 96 unsigned char *buffer; 97 unsigned packetsize; 98 int num_open; 99 int num_jacks; 100 struct umidi_jack *jacks[UMIDI_MAX_EPJACKS]; 101 TAILQ_HEAD(, umidi_jack) queue_head; 102 }; 103 104 /* software context */ 105 struct umidi_softc { 106 USBBASEDEVICE sc_dev; 107 usbd_device_handle sc_udev; 108 usbd_interface_handle sc_iface; 109 struct umidi_quirk *sc_quirk; 110 111 int sc_dying; 112 113 int sc_out_num_jacks; 114 struct umidi_jack *sc_out_jacks; 115 int sc_in_num_jacks; 116 struct umidi_jack *sc_in_jacks; 117 struct umidi_jack *sc_jacks; 118 119 int sc_num_mididevs; 120 struct umidi_mididev *sc_mididevs; 121 122 int sc_out_num_endpoints; 123 struct umidi_endpoint *sc_out_ep; 124 int sc_in_num_endpoints; 125 struct umidi_endpoint *sc_in_ep; 126 struct umidi_endpoint *sc_endpoints; 127 }; 128