xref: /illumos-gate/usr/src/uts/common/sys/usb/clients/hid/hid.h (revision 88f8b78a88cbdc6d8c1af5c3e54bc49d25095c98)
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 2004 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 will turn the M_CTL request into a request control request on the
71  * default pipe.  Hid needs the following information in the hid_req_t
72  * structure.  See the details below for specific values for each command.
73  */
74 typedef struct hid_req_struct {
75 	uint16_t	hid_req_version_no;	/* Version number */
76 	uint16_t	hid_req_wValue;		/* wValue field of request */
77 	uint16_t	hid_req_wLength;	/* wLength of request */
78 	mblk_t		*hid_req_data;		/* data for send case */
79 } hid_req_t;
80 _NOTE(SCHEME_PROTECTS_DATA("unique per call", hid_req_t))
81 
82 /*
83  * hid_req_wValue values HID_GET_REPORT and HID_SET_REPORT
84  */
85 #define	REPORT_TYPE_INPUT	0x0100			/* Input report */
86 #define	REPORT_TYPE_OUTPUT	0x0200			/* Output report */
87 #define	REPORT_TYPE_FEATURE	0x0300			/* Feature report */
88 
89 
90 /*
91  * hid_req_wLength value for HID_GET_IDLE and HID_SET_IDLE
92  */
93 #define	GET_IDLE_LENGTH		0x0001
94 #define	SET_IDLE_LENGTH		0x0000
95 
96 /*
97  * hid_req_wValue values for SET_PROTOCOL
98  */
99 #define	SET_BOOT_PROTOCOL	0x0000			/* Boot protocol */
100 #define	SET_REPORT_PROTOCOL	0x0001			/* Report protocol */
101 
102 /*
103  * return values for GET_PROTOCOL
104  */
105 #define	BOOT_PROTOCOL		0x00		/* Returned boot protocol */
106 #define	REPORT_PROTOCOL		0x01		/* Returned report protocol */
107 
108 /*
109  * There is an additional M_CTL command for obtaining the
110  * hid parser handle.  This M_CTL returns a pointer to  the handle.
111  * The type of the pointer is intpr_t because this type is large enough to
112  * hold any data pointer.
113  */
114 #define	HID_GET_PARSER_HANDLE	0x0100		/* obtain parser handle */
115 
116 /*
117  * M_CTL commands for event notifications
118  */
119 #define	HID_POWER_OFF		0x00DC
120 #define	HID_FULL_POWER		0x00DD
121 #define	HID_DISCONNECT_EVENT	0x00DE
122 #define	HID_CONNECT_EVENT	0x00DF
123 
124 /*
125  * To get the report descriptor,
126  * This is the wValue
127  */
128 #define	USB_CLASS_DESCR_TYPE_REPORT	0x2200
129 
130 
131 /* Version numbers */
132 #define	HID_VERSION_V_0		0
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif	/* _SYS_USB_HID_H */
139