xref: /openbsd-src/sys/dev/usb/uhidev.h (revision 898184e3e61f9129feb5978fad5a8c6865f00b92)
1 /*	$OpenBSD: uhidev.h,v 1.11 2010/08/02 23:17:34 miod 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  *
21  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #define UHIDBUSCF_REPORTID		0
35 #define UHIDBUSCF_REPORTID_DEFAULT	-1
36 
37 #define uhidevcf_reportid cf_loc[UHIDBUSCF_REPORTID]
38 #define UHIDEV_UNK_REPORTID UHIDBUSCF_REPORTID_DEFAULT
39 
40 struct uhidev_softc {
41 	struct device sc_dev;		/* base device */
42 	usbd_device_handle sc_udev;
43 	usbd_interface_handle sc_iface;	/* interface */
44 	usbd_pipe_handle sc_ipipe;	/* input interrupt pipe */
45 	usbd_xfer_handle sc_ixfer;	/* read request */
46 	int sc_iep_addr;
47 
48 	u_char *sc_ibuf;
49 	u_int sc_isize;
50 
51 	usbd_pipe_handle sc_opipe;	/* output interrupt pipe */
52 	usbd_xfer_handle sc_oxfer;	/* write request */
53 	usbd_xfer_handle sc_owxfer;	/* internal write request */
54 	int sc_oep_addr;
55 
56 	void *sc_repdesc;
57 	int sc_repdesc_size;
58 
59 	u_int sc_nrepid;
60 	struct uhidev **sc_subdevs;
61 
62 	int sc_refcnt;
63 	u_char sc_dying;
64 };
65 
66 struct uhidev {
67 	struct device sc_dev;		/* base device */
68 	struct uhidev_softc *sc_parent;
69 	uByte sc_report_id;
70 	u_int8_t sc_state;
71 	int sc_in_rep_size;
72 #define	UHIDEV_OPEN	0x01	/* device is open */
73 	void (*sc_intr)(struct uhidev *, void *, u_int);
74 
75 	int sc_isize;
76 	int sc_osize;
77 	int sc_fsize;
78 };
79 
80 struct uhidev_attach_arg {
81 	struct usb_attach_arg *uaa;
82 	struct uhidev_softc *parent;
83 	int reportid;
84 	int reportsize;
85 	int matchlvl;
86 };
87 
88 void uhidev_get_report_desc(struct uhidev_softc *, void **, int *);
89 int uhidev_open(struct uhidev *);
90 void uhidev_close(struct uhidev *);
91 int uhidev_ioctl(struct uhidev *, u_long, caddr_t, int, struct proc *);
92 usbd_status uhidev_set_report(struct uhidev *scd, int type, void *data,int len);
93 void uhidev_set_report_async(struct uhidev *scd, int type, void *data, int len);
94 usbd_status uhidev_get_report(struct uhidev *scd, int type, void *data,int len);
95 usbd_status uhidev_write(struct uhidev_softc *, void *, int);
96