xref: /illumos-gate/usr/src/uts/common/sys/usb/clients/hid/hid.h (revision b31b5de1357c915fe7dab4d9646d9d84f9fe69bc)
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 2008 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 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define	USB_DESCR_TYPE_HID	0x21
35 #define	USB_HID_DESCR_SIZE	10	/* Hid descriptor length */
36 
37 /*
38  * HID : This header file defines the interface between the hid
39  * module and the hid driver.
40  */
41 
42 /*
43  * There is an M_CTL command per class specific HID command defined in
44  * section 7.2 of the specification.
45  */
46 
47 #define	HID_GET_REPORT		0x0001		/* receive report */
48 #define	HID_GET_IDLE		0x0002		/* find the idle value */
49 #define	HID_GET_PROTOCOL	0x0003		/* get the protocol */
50 #define	HID_SET_REPORT		0x0009		/* send a report to device */
51 #define	HID_SET_IDLE		0x000a		/* set the idle value */
52 #define	HID_SET_PROTOCOL	0x000b		/* set the protocol */
53 
54 /*
55  * Hid descriptor
56  */
57 typedef struct usb_hid_descr {
58 	uchar_t		bLength;		/* Size of this descriptor */
59 	uchar_t		bDescriptorType;	/* HID descriptor */
60 	ushort_t	bcdHID;			/* HID spec release */
61 	uchar_t		bCountryCode;		/* Country code */
62 	uchar_t		bNumDescriptors;	/* No. class descriptors */
63 	uchar_t		bReportDescriptorType;	/* Class descr. type */
64 	ushort_t	wReportDescriptorLength; /* size of report descr */
65 } usb_hid_descr_t;
66 
67 /*
68  * Hid device information
69  */
70 typedef struct hid_vid_pid {
71 	uint16_t	VendorId;		/* vendor ID */
72 	uint16_t	ProductId;		/* product ID */
73 } hid_vid_pid_t;
74 
75 /*
76  * Hid will turn the M_CTL request into a request control request on the
77  * default pipe.  Hid needs the following information in the hid_req_t
78  * structure.  See the details below for specific values for each command.
79  * hid_req_data is a 256-byte buffer, which is used to transfer input, output
80  * and feature report(hid specification 6.2.2.3 long items).
81  */
82 
83 #define	MAX_REPORT_DATA 256
84 
85 typedef struct hid_req_struct {
86 	uint16_t	hid_req_version_no;	/* Version number */
87 	uint16_t	hid_req_wValue;		/* wValue field of request */
88 	uint16_t	hid_req_wLength;	/* wLength of request */
89 	uchar_t		hid_req_data[MAX_REPORT_DATA];	/* data for send case */
90 } hid_req_t;
91 _NOTE(SCHEME_PROTECTS_DATA("unique per call", hid_req_t))
92 
93 /*
94  * hid_req_wValue values HID_GET_REPORT and HID_SET_REPORT
95  */
96 #define	REPORT_TYPE_INPUT	0x0100			/* Input report */
97 #define	REPORT_TYPE_OUTPUT	0x0200			/* Output report */
98 #define	REPORT_TYPE_FEATURE	0x0300			/* Feature report */
99 
100 
101 /*
102  * hid_req_wLength value for HID_GET_IDLE and HID_SET_IDLE
103  */
104 #define	GET_IDLE_LENGTH		0x0001
105 #define	SET_IDLE_LENGTH		0x0000
106 
107 /*
108  * hid_req_wValue values for SET_PROTOCOL
109  */
110 #define	SET_BOOT_PROTOCOL	0x0000			/* Boot protocol */
111 #define	SET_REPORT_PROTOCOL	0x0001			/* Report protocol */
112 
113 /*
114  * return values for GET_PROTOCOL
115  */
116 #define	BOOT_PROTOCOL		0x00		/* Returned boot protocol */
117 #define	REPORT_PROTOCOL		0x01		/* Returned report protocol */
118 
119 /*
120  * There is an additional M_CTL command for obtaining the
121  * hid parser handle.  This M_CTL returns a pointer to  the handle.
122  * The type of the pointer is intpr_t because this type is large enough to
123  * hold any data pointer.
124  */
125 #define	HID_GET_PARSER_HANDLE	0x0100		/* obtain parser handle */
126 
127 /*
128  * The M_CTL command is to get the device vendor ID and product ID.
129  */
130 #define	HID_GET_VID_PID		0x0200		/* obtain device info */
131 
132 /*
133  * M_CTL commands for event notifications
134  */
135 #define	HID_POWER_OFF		0x00DC
136 #define	HID_FULL_POWER		0x00DD
137 #define	HID_DISCONNECT_EVENT	0x00DE
138 #define	HID_CONNECT_EVENT	0x00DF
139 
140 /*
141  * To get the report descriptor,
142  * This is the wValue
143  */
144 #define	USB_CLASS_DESCR_TYPE_REPORT	0x2200
145 
146 
147 /* Version numbers */
148 #define	HID_VERSION_V_0		0
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif	/* _SYS_USB_HID_H */
155