1 /* $OpenBSD: umidi_quirks.h,v 1.4 2008/06/26 05:42:19 ray Exp $ */ 2 /* $NetBSD: umidi_quirks.h,v 1.2 2001/09/29 22:00:47 tshiozak Exp $ */ 3 4 /* 5 * Copyright (c) 2001 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Takuya SHIOZAKI (tshiozak@netbsd.org). 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 34 /* 35 * quirk code for UMIDI 36 */ 37 38 #ifndef _DEV_USB_UMIDI_QUIRKS_H_ 39 #define _DEV_USB_UMIDI_QUIRKS_H_ 40 41 struct umq_data { 42 int type; 43 #define UMQ_TYPE_FIXED_EP 1 44 #define UMQ_TYPE_YAMAHA 2 45 void *data; 46 }; 47 48 struct umidi_quirk { 49 int vendor; 50 int product; 51 int iface; 52 struct umq_data *quirks; 53 u_int32_t type_mask; 54 }; 55 #define UMQ_ISTYPE(q, type) \ 56 ((q)->sc_quirk && ((q)->sc_quirk->type_mask & (1<<((type)-1)))) 57 58 #define UMQ_TERMINATOR { 0, } 59 #define UMQ_DEF(v, p, i) \ 60 static struct umq_data umq_##v##_##p##_##i[] 61 #define UMQ_REG(v, p, i) \ 62 { USB_VENDOR_##v, USB_PRODUCT_##p, i, \ 63 umq_##v##_##p##_##i, 0 } 64 #define ANYIFACE -1 65 #define ANYVENDOR -1 66 #define USB_VENDOR_ANYVENDOR ANYVENDOR 67 #define ANYPRODUCT -1 68 #define USB_PRODUCT_ANYPRODUCT ANYPRODUCT 69 70 /* 71 * quirk - fixed port 72 */ 73 74 struct umq_fixed_ep_endpoint { 75 int ep; 76 int num_jacks; 77 }; 78 struct umq_fixed_ep_desc { 79 int num_out_ep; 80 int num_in_ep; 81 struct umq_fixed_ep_endpoint *out_ep; 82 struct umq_fixed_ep_endpoint *in_ep; 83 }; 84 85 #define UMQ_FIXED_EP_DEF(v, p, i, noep, niep) \ 86 static struct umq_fixed_ep_endpoint \ 87 umq_##v##_##p##_##i##_fixed_ep_endpoints[noep+niep]; \ 88 static struct umq_fixed_ep_desc \ 89 umq_##v##_##p##_##i##_fixed_ep_desc = { \ 90 noep, niep, \ 91 &umq_##v##_##p##_##i##_fixed_ep_endpoints[0], \ 92 &umq_##v##_##p##_##i##_fixed_ep_endpoints[noep], \ 93 }; \ 94 static struct umq_fixed_ep_endpoint \ 95 umq_##v##_##p##_##i##_fixed_ep_endpoints[noep+niep] 96 97 #define UMQ_FIXED_EP_REG(v, p, i) \ 98 { UMQ_TYPE_FIXED_EP, (void *)&umq_##v##_##p##_##i##_fixed_ep_desc } 99 100 101 /* 102 * quirk - yamaha style midi I/F 103 */ 104 #define UMQ_YAMAHA_REG(v, p, i) \ 105 { UMQ_TYPE_YAMAHA, NULL } 106 107 108 /* extern struct umidi_quirk umidi_quirklist[]; */ 109 struct umidi_quirk *umidi_search_quirk(int, int, int); 110 void umidi_print_quirk(struct umidi_quirk *); 111 void *umidi_get_quirk_data_from_type(struct umidi_quirk *, u_int32_t); 112 113 #endif 114