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