194773907SVladimir Kondratyev /*- 294773907SVladimir Kondratyev * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 394773907SVladimir Kondratyev * 494773907SVladimir Kondratyev * Copyright (c) 2020 Vladimir Kondratyev <wulf@FreeBSD.org> 594773907SVladimir Kondratyev * 694773907SVladimir Kondratyev * Redistribution and use in source and binary forms, with or without 794773907SVladimir Kondratyev * modification, are permitted provided that the following conditions 894773907SVladimir Kondratyev * are met: 994773907SVladimir Kondratyev * 1. Redistributions of source code must retain the above copyright 1094773907SVladimir Kondratyev * notice, this list of conditions and the following disclaimer. 1194773907SVladimir Kondratyev * 2. Redistributions in binary form must reproduce the above copyright 1294773907SVladimir Kondratyev * notice, this list of conditions and the following disclaimer in the 1394773907SVladimir Kondratyev * documentation and/or other materials provided with the distribution. 1494773907SVladimir Kondratyev * 1594773907SVladimir Kondratyev * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1694773907SVladimir Kondratyev * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1794773907SVladimir Kondratyev * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1894773907SVladimir Kondratyev * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1994773907SVladimir Kondratyev * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2094773907SVladimir Kondratyev * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2194773907SVladimir Kondratyev * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2294773907SVladimir Kondratyev * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2394773907SVladimir Kondratyev * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2494773907SVladimir Kondratyev * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2594773907SVladimir Kondratyev * SUCH DAMAGE. 2694773907SVladimir Kondratyev * 2794773907SVladimir Kondratyev * $FreeBSD$ 2894773907SVladimir Kondratyev */ 2994773907SVladimir Kondratyev 3094773907SVladimir Kondratyev #ifndef _HID_HIDRAW_H 3194773907SVladimir Kondratyev #define _HID_HIDRAW_H 3294773907SVladimir Kondratyev 3394773907SVladimir Kondratyev #include <sys/ioccom.h> 3494773907SVladimir Kondratyev 3594773907SVladimir Kondratyev #define HIDRAW_BUFFER_SIZE 64 /* number of input reports buffered */ 3694773907SVladimir Kondratyev #define HID_MAX_DESCRIPTOR_SIZE 4096 /* artificial limit taken from Linux */ 3794773907SVladimir Kondratyev 3894773907SVladimir Kondratyev /* Compatible with usb_gen_descriptor structure */ 3994773907SVladimir Kondratyev struct hidraw_gen_descriptor { 4094773907SVladimir Kondratyev void *hgd_data; 4194773907SVladimir Kondratyev uint16_t hgd_lang_id; 4294773907SVladimir Kondratyev uint16_t hgd_maxlen; 4394773907SVladimir Kondratyev uint16_t hgd_actlen; 4494773907SVladimir Kondratyev uint16_t hgd_offset; 4594773907SVladimir Kondratyev uint8_t hgd_config_index; 4694773907SVladimir Kondratyev uint8_t hgd_string_index; 4794773907SVladimir Kondratyev uint8_t hgd_iface_index; 4894773907SVladimir Kondratyev uint8_t hgd_altif_index; 4994773907SVladimir Kondratyev uint8_t hgd_endpt_index; 5094773907SVladimir Kondratyev uint8_t hgd_report_type; 5194773907SVladimir Kondratyev uint8_t reserved[8]; 52*ea972feeSBrooks Davis }; 5394773907SVladimir Kondratyev 5494773907SVladimir Kondratyev struct hidraw_report_descriptor { 5594773907SVladimir Kondratyev uint32_t size; 5694773907SVladimir Kondratyev uint8_t value[HID_MAX_DESCRIPTOR_SIZE]; 57*ea972feeSBrooks Davis }; 5894773907SVladimir Kondratyev 5994773907SVladimir Kondratyev struct hidraw_devinfo { 6094773907SVladimir Kondratyev uint32_t bustype; 6194773907SVladimir Kondratyev int16_t vendor; 6294773907SVladimir Kondratyev int16_t product; 63*ea972feeSBrooks Davis }; 6494773907SVladimir Kondratyev 6594773907SVladimir Kondratyev /* FreeBSD uhid(4)-compatible ioctl interface */ 6694773907SVladimir Kondratyev #define HIDRAW_GET_REPORT_DESC _IOWR('U', 21, struct hidraw_gen_descriptor) 6794773907SVladimir Kondratyev #define HIDRAW_SET_IMMED _IOW ('U', 22, int) 6894773907SVladimir Kondratyev #define HIDRAW_GET_REPORT _IOWR('U', 23, struct hidraw_gen_descriptor) 6994773907SVladimir Kondratyev #define HIDRAW_SET_REPORT _IOW ('U', 24, struct hidraw_gen_descriptor) 7094773907SVladimir Kondratyev #define HIDRAW_GET_REPORT_ID _IOR ('U', 25, int) 7194773907SVladimir Kondratyev #define HIDRAW_SET_REPORT_DESC _IOW ('U', 26, struct hidraw_gen_descriptor) 7294773907SVladimir Kondratyev 7394773907SVladimir Kondratyev /* Linux hidraw-compatible ioctl interface */ 7494773907SVladimir Kondratyev #define HIDIOCGRDESCSIZE _IOR('U', 30, int) 7594773907SVladimir Kondratyev #define HIDIOCGRDESC _IO ('U', 31) 7694773907SVladimir Kondratyev #define HIDIOCGRAWINFO _IOR('U', 32, struct hidraw_devinfo) 7794773907SVladimir Kondratyev #define HIDIOCGRAWNAME(len) _IOC(IOC_OUT, 'U', 33, len) 7894773907SVladimir Kondratyev #define HIDIOCGRAWPHYS(len) _IOC(IOC_OUT, 'U', 34, len) 7994773907SVladimir Kondratyev #define HIDIOCSFEATURE(len) _IOC(IOC_IN, 'U', 35, len) 8094773907SVladimir Kondratyev #define HIDIOCGFEATURE(len) _IOC(IOC_INOUT, 'U', 36, len) 8194773907SVladimir Kondratyev #define HIDIOCGRAWUNIQ(len) _IOC(IOC_OUT, 'U', 37, len) 8294773907SVladimir Kondratyev 8394773907SVladimir Kondratyev #endif /* _HID_HIDRAW_H */ 84