1 /* $OpenBSD: uhidev.h,v 1.41 2022/03/21 12:18:52 thfr 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 struct uhidev_softc { 35 struct device sc_dev; /* base device */ 36 struct usbd_device *sc_udev; 37 struct usbd_interface *sc_iface;/* interface */ 38 int sc_ifaceno; /* interface number */ 39 struct usbd_pipe *sc_ipipe; /* input interrupt pipe */ 40 struct usbd_xfer *sc_ixfer; /* read request */ 41 int sc_iep_addr; 42 43 u_char *sc_ibuf; 44 u_int sc_isize; 45 46 struct usbd_pipe *sc_opipe; /* output interrupt pipe */ 47 struct usbd_xfer *sc_oxfer; /* write request */ 48 struct usbd_xfer *sc_owxfer; /* internal write request */ 49 int sc_oep_addr; 50 51 void *sc_repdesc; 52 int sc_repdesc_size; 53 54 u_int sc_nrepid; 55 struct uhidev **sc_subdevs; 56 57 int sc_refcnt; 58 59 u_int sc_flags; 60 #define UHIDEV_F_XB1 0x0001 /* Xbox One controller */ 61 }; 62 63 struct uhidev { 64 struct device sc_dev; /* base device */ 65 struct usbd_device *sc_udev; /* USB device */ 66 struct uhidev_softc *sc_parent; 67 uByte sc_report_id; 68 u_int8_t sc_state; 69 #define UHIDEV_OPEN 0x01 /* device is open */ 70 void (*sc_intr)(struct uhidev *, void *, u_int); 71 72 int sc_isize; 73 int sc_osize; 74 int sc_fsize; 75 }; 76 77 struct uhidev_attach_arg { 78 struct usb_attach_arg *uaa; 79 struct uhidev_softc *parent; 80 uint8_t reportid; 81 u_int nreports; 82 uint8_t *claimed; 83 }; 84 85 #define UHIDEV_CLAIM_MULTIPLE_REPORTID(u) ((u)->claimed != NULL) 86 87 int uhidev_report_type_conv(int); 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 int uhidev_set_report(struct uhidev_softc *, int, int, void *, int); 93 int uhidev_set_report_async(struct uhidev_softc *, int, int, void *, int); 94 int uhidev_get_report(struct uhidev_softc *, int, int, void *, int); 95 int uhidev_get_report_async(struct uhidev_softc *, int, int, void *, int, 96 void *, void (*)(void *, int, void *, int)); 97 usbd_status uhidev_write(struct uhidev_softc *, void *, int); 98 int uhidev_set_report_dev(struct uhidev_softc *, struct uhidev *, int); 99