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