1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_USB_HID_H 27 #define _SYS_USB_HID_H 28 29 #include <sys/note.h> 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #define USB_DESCR_TYPE_HID 0x21 36 #define USB_HID_DESCR_SIZE 10 /* Hid descriptor length */ 37 38 /* 39 * HID : This header file defines the interface between the hid 40 * module and the hid driver. 41 */ 42 43 /* 44 * There is an M_CTL command per class specific HID command defined in 45 * section 7.2 of the specification. 46 */ 47 48 #define HID_GET_REPORT 0x0001 /* receive report */ 49 #define HID_GET_IDLE 0x0002 /* find the idle value */ 50 #define HID_GET_PROTOCOL 0x0003 /* get the protocol */ 51 #define HID_SET_REPORT 0x0009 /* send a report to device */ 52 #define HID_SET_IDLE 0x000a /* set the idle value */ 53 #define HID_SET_PROTOCOL 0x000b /* set the protocol */ 54 55 /* 56 * Hid descriptor 57 */ 58 typedef struct usb_hid_descr { 59 uchar_t bLength; /* Size of this descriptor */ 60 uchar_t bDescriptorType; /* HID descriptor */ 61 ushort_t bcdHID; /* HID spec release */ 62 uchar_t bCountryCode; /* Country code */ 63 uchar_t bNumDescriptors; /* No. class descriptors */ 64 uchar_t bReportDescriptorType; /* Class descr. type */ 65 ushort_t wReportDescriptorLength; /* size of report descr */ 66 } usb_hid_descr_t; 67 68 /* 69 * Hid device information 70 */ 71 typedef struct hid_vid_pid { 72 uint16_t VendorId; /* vendor ID */ 73 uint16_t ProductId; /* product ID */ 74 } hid_vid_pid_t; 75 76 /* 77 * Hid will turn the M_CTL request into a request control request on the 78 * default pipe. Hid needs the following information in the hid_req_t 79 * structure. See the details below for specific values for each command. 80 * hid_req_data is a 256-byte buffer, which is used to transfer input, output 81 * and feature report(hid specification 6.2.2.3 long items). 82 */ 83 84 #define MAX_REPORT_DATA 256 85 86 typedef struct hid_req_struct { 87 uint16_t hid_req_version_no; /* Version number */ 88 uint16_t hid_req_wValue; /* wValue field of request */ 89 uint16_t hid_req_wLength; /* wLength of request */ 90 uchar_t hid_req_data[MAX_REPORT_DATA]; /* data for send case */ 91 } hid_req_t; 92 _NOTE(SCHEME_PROTECTS_DATA("unique per call", hid_req_t)) 93 94 /* 95 * hid_req_wValue values HID_GET_REPORT and HID_SET_REPORT 96 */ 97 #define REPORT_TYPE_INPUT 0x0100 /* Input report */ 98 #define REPORT_TYPE_OUTPUT 0x0200 /* Output report */ 99 #define REPORT_TYPE_FEATURE 0x0300 /* Feature report */ 100 101 102 /* 103 * hid_req_wLength value for HID_GET_IDLE and HID_SET_IDLE 104 */ 105 #define GET_IDLE_LENGTH 0x0001 106 #define SET_IDLE_LENGTH 0x0000 107 108 /* 109 * hid_req_wValue values for SET_PROTOCOL 110 */ 111 #define SET_BOOT_PROTOCOL 0x0000 /* Boot protocol */ 112 #define SET_REPORT_PROTOCOL 0x0001 /* Report protocol */ 113 114 /* 115 * return values for GET_PROTOCOL 116 */ 117 #define BOOT_PROTOCOL 0x00 /* Returned boot protocol */ 118 #define REPORT_PROTOCOL 0x01 /* Returned report protocol */ 119 120 /* 121 * There is an additional M_CTL command for obtaining the 122 * hid parser handle. This M_CTL returns a pointer to the handle. 123 * The type of the pointer is intpr_t because this type is large enough to 124 * hold any data pointer. 125 */ 126 #define HID_GET_PARSER_HANDLE 0x0100 /* obtain parser handle */ 127 128 /* 129 * The M_CTL command is to get the device vendor ID and product ID. 130 */ 131 #define HID_GET_VID_PID 0x0200 /* obtain device info */ 132 133 /* 134 * M_CTL commands for event notifications 135 */ 136 #define HID_POWER_OFF 0x00DC 137 #define HID_FULL_POWER 0x00DD 138 #define HID_DISCONNECT_EVENT 0x00DE 139 #define HID_CONNECT_EVENT 0x00DF 140 141 /* 142 * To get the report descriptor, 143 * This is the wValue 144 */ 145 #define USB_CLASS_DESCR_TYPE_REPORT 0x2200 146 147 148 /* Version numbers */ 149 #define HID_VERSION_V_0 0 150 151 /* 152 * HID IOCTLS 153 */ 154 #define HIDIOC ('h'<<8) 155 156 /* 157 * Each hid keyboard/mouse device instance has two streams (internal/external). 158 * This pair of ioctls is used to get/set which stream the input data should 159 * be sent to. 160 */ 161 #define HIDIOCKMGDIRECT (HIDIOC | 0) 162 #define HIDIOCKMSDIRECT (HIDIOC | 1) 163 164 #ifdef __cplusplus 165 } 166 #endif 167 168 #endif /* _SYS_USB_HID_H */ 169