17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 559c81845Sgc161489 * Common Development and Distribution License (the "License"). 659c81845Sgc161489 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*ddee57faSrui zang - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_USB_HID_H 277c478bd9Sstevel@tonic-gate #define _SYS_USB_HID_H 287c478bd9Sstevel@tonic-gate 29*ddee57faSrui zang - Sun Microsystems - Beijing China #include <sys/note.h> 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #define USB_DESCR_TYPE_HID 0x21 367c478bd9Sstevel@tonic-gate #define USB_HID_DESCR_SIZE 10 /* Hid descriptor length */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * HID : This header file defines the interface between the hid 407c478bd9Sstevel@tonic-gate * module and the hid driver. 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * There is an M_CTL command per class specific HID command defined in 457c478bd9Sstevel@tonic-gate * section 7.2 of the specification. 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate #define HID_GET_REPORT 0x0001 /* receive report */ 497c478bd9Sstevel@tonic-gate #define HID_GET_IDLE 0x0002 /* find the idle value */ 507c478bd9Sstevel@tonic-gate #define HID_GET_PROTOCOL 0x0003 /* get the protocol */ 517c478bd9Sstevel@tonic-gate #define HID_SET_REPORT 0x0009 /* send a report to device */ 527c478bd9Sstevel@tonic-gate #define HID_SET_IDLE 0x000a /* set the idle value */ 537c478bd9Sstevel@tonic-gate #define HID_SET_PROTOCOL 0x000b /* set the protocol */ 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * Hid descriptor 577c478bd9Sstevel@tonic-gate */ 587c478bd9Sstevel@tonic-gate typedef struct usb_hid_descr { 597c478bd9Sstevel@tonic-gate uchar_t bLength; /* Size of this descriptor */ 607c478bd9Sstevel@tonic-gate uchar_t bDescriptorType; /* HID descriptor */ 617c478bd9Sstevel@tonic-gate ushort_t bcdHID; /* HID spec release */ 627c478bd9Sstevel@tonic-gate uchar_t bCountryCode; /* Country code */ 637c478bd9Sstevel@tonic-gate uchar_t bNumDescriptors; /* No. class descriptors */ 647c478bd9Sstevel@tonic-gate uchar_t bReportDescriptorType; /* Class descr. type */ 657c478bd9Sstevel@tonic-gate ushort_t wReportDescriptorLength; /* size of report descr */ 667c478bd9Sstevel@tonic-gate } usb_hid_descr_t; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 696d9a41ffSqz150045 * Hid device information 706d9a41ffSqz150045 */ 716d9a41ffSqz150045 typedef struct hid_vid_pid { 726d9a41ffSqz150045 uint16_t VendorId; /* vendor ID */ 736d9a41ffSqz150045 uint16_t ProductId; /* product ID */ 746d9a41ffSqz150045 } hid_vid_pid_t; 756d9a41ffSqz150045 766d9a41ffSqz150045 /* 777c478bd9Sstevel@tonic-gate * Hid will turn the M_CTL request into a request control request on the 787c478bd9Sstevel@tonic-gate * default pipe. Hid needs the following information in the hid_req_t 797c478bd9Sstevel@tonic-gate * structure. See the details below for specific values for each command. 8059c81845Sgc161489 * hid_req_data is a 256-byte buffer, which is used to transfer input, output 8159c81845Sgc161489 * and feature report(hid specification 6.2.2.3 long items). 827c478bd9Sstevel@tonic-gate */ 8359c81845Sgc161489 8459c81845Sgc161489 #define MAX_REPORT_DATA 256 8559c81845Sgc161489 867c478bd9Sstevel@tonic-gate typedef struct hid_req_struct { 877c478bd9Sstevel@tonic-gate uint16_t hid_req_version_no; /* Version number */ 887c478bd9Sstevel@tonic-gate uint16_t hid_req_wValue; /* wValue field of request */ 897c478bd9Sstevel@tonic-gate uint16_t hid_req_wLength; /* wLength of request */ 9059c81845Sgc161489 uchar_t hid_req_data[MAX_REPORT_DATA]; /* data for send case */ 917c478bd9Sstevel@tonic-gate } hid_req_t; 927c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", hid_req_t)) 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* 957c478bd9Sstevel@tonic-gate * hid_req_wValue values HID_GET_REPORT and HID_SET_REPORT 967c478bd9Sstevel@tonic-gate */ 977c478bd9Sstevel@tonic-gate #define REPORT_TYPE_INPUT 0x0100 /* Input report */ 987c478bd9Sstevel@tonic-gate #define REPORT_TYPE_OUTPUT 0x0200 /* Output report */ 997c478bd9Sstevel@tonic-gate #define REPORT_TYPE_FEATURE 0x0300 /* Feature report */ 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* 1037c478bd9Sstevel@tonic-gate * hid_req_wLength value for HID_GET_IDLE and HID_SET_IDLE 1047c478bd9Sstevel@tonic-gate */ 1057c478bd9Sstevel@tonic-gate #define GET_IDLE_LENGTH 0x0001 1067c478bd9Sstevel@tonic-gate #define SET_IDLE_LENGTH 0x0000 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* 1097c478bd9Sstevel@tonic-gate * hid_req_wValue values for SET_PROTOCOL 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate #define SET_BOOT_PROTOCOL 0x0000 /* Boot protocol */ 1127c478bd9Sstevel@tonic-gate #define SET_REPORT_PROTOCOL 0x0001 /* Report protocol */ 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate /* 1157c478bd9Sstevel@tonic-gate * return values for GET_PROTOCOL 1167c478bd9Sstevel@tonic-gate */ 1177c478bd9Sstevel@tonic-gate #define BOOT_PROTOCOL 0x00 /* Returned boot protocol */ 1187c478bd9Sstevel@tonic-gate #define REPORT_PROTOCOL 0x01 /* Returned report protocol */ 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* 1217c478bd9Sstevel@tonic-gate * There is an additional M_CTL command for obtaining the 1227c478bd9Sstevel@tonic-gate * hid parser handle. This M_CTL returns a pointer to the handle. 1237c478bd9Sstevel@tonic-gate * The type of the pointer is intpr_t because this type is large enough to 1247c478bd9Sstevel@tonic-gate * hold any data pointer. 1257c478bd9Sstevel@tonic-gate */ 1267c478bd9Sstevel@tonic-gate #define HID_GET_PARSER_HANDLE 0x0100 /* obtain parser handle */ 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate /* 1296d9a41ffSqz150045 * The M_CTL command is to get the device vendor ID and product ID. 1306d9a41ffSqz150045 */ 1316d9a41ffSqz150045 #define HID_GET_VID_PID 0x0200 /* obtain device info */ 1326d9a41ffSqz150045 1336d9a41ffSqz150045 /* 1347c478bd9Sstevel@tonic-gate * M_CTL commands for event notifications 1357c478bd9Sstevel@tonic-gate */ 1367c478bd9Sstevel@tonic-gate #define HID_POWER_OFF 0x00DC 1377c478bd9Sstevel@tonic-gate #define HID_FULL_POWER 0x00DD 1387c478bd9Sstevel@tonic-gate #define HID_DISCONNECT_EVENT 0x00DE 1397c478bd9Sstevel@tonic-gate #define HID_CONNECT_EVENT 0x00DF 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate /* 1427c478bd9Sstevel@tonic-gate * To get the report descriptor, 1437c478bd9Sstevel@tonic-gate * This is the wValue 1447c478bd9Sstevel@tonic-gate */ 1457c478bd9Sstevel@tonic-gate #define USB_CLASS_DESCR_TYPE_REPORT 0x2200 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* Version numbers */ 1497c478bd9Sstevel@tonic-gate #define HID_VERSION_V_0 0 1507c478bd9Sstevel@tonic-gate 151*ddee57faSrui zang - Sun Microsystems - Beijing China /* 152*ddee57faSrui zang - Sun Microsystems - Beijing China * HID IOCTLS 153*ddee57faSrui zang - Sun Microsystems - Beijing China */ 154*ddee57faSrui zang - Sun Microsystems - Beijing China #define HIDIOC ('h'<<8) 155*ddee57faSrui zang - Sun Microsystems - Beijing China 156*ddee57faSrui zang - Sun Microsystems - Beijing China /* 157*ddee57faSrui zang - Sun Microsystems - Beijing China * Each hid keyboard/mouse device instance has two streams (internal/external). 158*ddee57faSrui zang - Sun Microsystems - Beijing China * This pair of ioctls is used to get/set which stream the input data should 159*ddee57faSrui zang - Sun Microsystems - Beijing China * be sent to. 160*ddee57faSrui zang - Sun Microsystems - Beijing China */ 161*ddee57faSrui zang - Sun Microsystems - Beijing China #define HIDIOCKMGDIRECT (HIDIOC | 0) 162*ddee57faSrui zang - Sun Microsystems - Beijing China #define HIDIOCKMSDIRECT (HIDIOC | 1) 163*ddee57faSrui zang - Sun Microsystems - Beijing China 1647c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate #endif 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_HID_H */ 169