xref: /openbsd-src/sys/dev/usb/uhidev.h (revision 8500990981f885cbe5e6a4958549cacc238b5ae6)
1 /*	$OpenBSD: uhidev.h,v 1.4 2002/11/11 02:32:32 nate Exp $	*/
2 /*	$NetBSD: uhidev.h,v 1.3 2002/10/08 09:56:17 dan 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 Lennart Augustsson (lennart@augustsson.net) at
10  * Carlstedt Research & Technology.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. All advertising materials mentioning features or use of this software
21  *    must display the following acknowledgement:
22  *        This product includes software developed by the NetBSD
23  *        Foundation, Inc. and its contributors.
24  * 4. Neither the name of The NetBSD Foundation nor the names of its
25  *    contributors may be used to endorse or promote products derived
26  *    from this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  * POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #if defined(__NetBSD__)
42 #include "locators.h"
43 #include "rnd.h"
44 
45 #if NRND > 0
46 #include <sys/rnd.h>
47 #endif
48 #endif
49 
50 #define uhidevcf_reportid cf_loc[UHIDBUSCF_REPORTID]
51 #define UHIDEV_UNK_REPORTID UHIDBUSCF_REPORTID_DEFAULT
52 
53 struct uhidev_softc {
54 	USBBASEDEVICE sc_dev;		/* base device */
55 	usbd_device_handle sc_udev;
56 	usbd_interface_handle sc_iface;	/* interface */
57 	usbd_pipe_handle sc_intrpipe;	/* interrupt pipe */
58 	int sc_ep_addr;
59 
60 	u_char *sc_ibuf;
61 	u_int sc_isize;
62 
63 	void *sc_repdesc;
64 	int sc_repdesc_size;
65 
66 	u_int sc_nrepid;
67 	struct uhidev **sc_subdevs;
68 
69 	int sc_refcnt;
70 	u_char sc_dying;
71 };
72 
73 struct uhidev {
74 	USBBASEDEVICE sc_dev;		/* base device */
75 	struct uhidev_softc *sc_parent;
76 	uByte sc_report_id;
77 	u_int8_t sc_state;
78 	int sc_in_rep_size;
79 #define	UHIDEV_OPEN	0x01	/* device is open */
80 	void (*sc_intr)(struct uhidev *, void *, u_int);
81 #if defined(__NetBSD__) && NRND > 0
82         rndsource_element_t     rnd_source;
83 #endif
84 };
85 
86 struct uhidev_attach_arg {
87 	struct usb_attach_arg *uaa;
88 	struct uhidev_softc *parent;
89 	int reportid;
90 	int reportsize;
91 	int matchlvl;
92 };
93 
94 void uhidev_get_report_desc(struct uhidev_softc *, void **, int *);
95 int uhidev_open(struct uhidev *);
96 void uhidev_close(struct uhidev *);
97 usbd_status uhidev_set_report(struct uhidev *scd, int type, void *data,int len);
98 void uhidev_set_report_async(struct uhidev *scd, int type, void *data, int len);
99 usbd_status uhidev_get_report(struct uhidev *scd, int type, void *data,int len);
100