1 /* $OpenBSD: uhidev.h,v 1.29 2021/03/18 09:21:53 anton 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 struct usbd_device *sc_udev; 43 struct usbd_interface *sc_iface;/* interface */ 44 int sc_ifaceno; /* interface number */ 45 struct usbd_pipe *sc_ipipe; /* input interrupt pipe */ 46 struct usbd_xfer *sc_ixfer; /* read request */ 47 int sc_iep_addr; 48 49 u_char *sc_ibuf; 50 u_int sc_isize; 51 52 struct usbd_pipe *sc_opipe; /* output interrupt pipe */ 53 struct usbd_xfer *sc_oxfer; /* write request */ 54 struct usbd_xfer *sc_owxfer; /* internal write request */ 55 int sc_oep_addr; 56 57 void *sc_repdesc; 58 int sc_repdesc_size; 59 60 u_int sc_nrepid; 61 struct uhidev **sc_subdevs; 62 63 int sc_refcnt; 64 }; 65 66 struct uhidev { 67 struct device sc_dev; /* base device */ 68 struct usbd_device *sc_udev; /* USB device */ 69 struct uhidev_softc *sc_parent; 70 uByte sc_report_id; 71 u_int8_t sc_state; 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 uint8_t reportid; 84 #define UHIDEV_CLAIM_MULTIPLE_REPORTID 255 85 uint8_t nreports; 86 uint8_t *claimed; 87 }; 88 89 int uhidev_report_type_conv(int); 90 void uhidev_get_report_desc(struct uhidev_softc *, void **, int *); 91 int uhidev_open(struct uhidev *); 92 void uhidev_close(struct uhidev *); 93 int uhidev_ioctl(struct uhidev *, u_long, caddr_t, int, struct proc *); 94 int uhidev_set_report(struct uhidev_softc *, int, int, void *, int); 95 int uhidev_set_report_async(struct uhidev_softc *, int, int, void *, int); 96 int uhidev_get_report(struct uhidev_softc *, int, int, void *, int); 97 int uhidev_get_report_async(struct uhidev_softc *, int, int, void *, int, 98 void *, void (*)(void *, int, void *, int)); 99 usbd_status uhidev_write(struct uhidev_softc *, void *, int); 100 int uhidev_set_report_dev(struct uhidev_softc *, struct uhidev *, int); 101