xref: /onnv-gate/usr/src/uts/common/sys/usb/clients/hid/hid.h (revision 10153:2d84bf0e724b)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52278Sgc161489  * Common Development and Distribution License (the "License").
62278Sgc161489  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*10153SAaron.Zang@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_USB_HID_H
270Sstevel@tonic-gate #define	_SYS_USB_HID_H
280Sstevel@tonic-gate 
29*10153SAaron.Zang@Sun.COM #include <sys/note.h>
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef __cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #define	USB_DESCR_TYPE_HID	0x21
360Sstevel@tonic-gate #define	USB_HID_DESCR_SIZE	10	/* Hid descriptor length */
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * HID : This header file defines the interface between the hid
400Sstevel@tonic-gate  * module and the hid driver.
410Sstevel@tonic-gate  */
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  * There is an M_CTL command per class specific HID command defined in
450Sstevel@tonic-gate  * section 7.2 of the specification.
460Sstevel@tonic-gate  */
470Sstevel@tonic-gate 
480Sstevel@tonic-gate #define	HID_GET_REPORT		0x0001		/* receive report */
490Sstevel@tonic-gate #define	HID_GET_IDLE		0x0002		/* find the idle value */
500Sstevel@tonic-gate #define	HID_GET_PROTOCOL	0x0003		/* get the protocol */
510Sstevel@tonic-gate #define	HID_SET_REPORT		0x0009		/* send a report to device */
520Sstevel@tonic-gate #define	HID_SET_IDLE		0x000a		/* set the idle value */
530Sstevel@tonic-gate #define	HID_SET_PROTOCOL	0x000b		/* set the protocol */
540Sstevel@tonic-gate 
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate  * Hid descriptor
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate typedef struct usb_hid_descr {
590Sstevel@tonic-gate 	uchar_t		bLength;		/* Size of this descriptor */
600Sstevel@tonic-gate 	uchar_t		bDescriptorType;	/* HID descriptor */
610Sstevel@tonic-gate 	ushort_t	bcdHID;			/* HID spec release */
620Sstevel@tonic-gate 	uchar_t		bCountryCode;		/* Country code */
630Sstevel@tonic-gate 	uchar_t		bNumDescriptors;	/* No. class descriptors */
640Sstevel@tonic-gate 	uchar_t		bReportDescriptorType;	/* Class descr. type */
650Sstevel@tonic-gate 	ushort_t	wReportDescriptorLength; /* size of report descr */
660Sstevel@tonic-gate } usb_hid_descr_t;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate /*
69918Sqz150045  * Hid device information
70918Sqz150045  */
71918Sqz150045 typedef struct hid_vid_pid {
72918Sqz150045 	uint16_t	VendorId;		/* vendor ID */
73918Sqz150045 	uint16_t	ProductId;		/* product ID */
74918Sqz150045 } hid_vid_pid_t;
75918Sqz150045 
76918Sqz150045 /*
770Sstevel@tonic-gate  * Hid will turn the M_CTL request into a request control request on the
780Sstevel@tonic-gate  * default pipe.  Hid needs the following information in the hid_req_t
790Sstevel@tonic-gate  * structure.  See the details below for specific values for each command.
802278Sgc161489  * hid_req_data is a 256-byte buffer, which is used to transfer input, output
812278Sgc161489  * and feature report(hid specification 6.2.2.3 long items).
820Sstevel@tonic-gate  */
832278Sgc161489 
842278Sgc161489 #define	MAX_REPORT_DATA 256
852278Sgc161489 
860Sstevel@tonic-gate typedef struct hid_req_struct {
870Sstevel@tonic-gate 	uint16_t	hid_req_version_no;	/* Version number */
880Sstevel@tonic-gate 	uint16_t	hid_req_wValue;		/* wValue field of request */
890Sstevel@tonic-gate 	uint16_t	hid_req_wLength;	/* wLength of request */
902278Sgc161489 	uchar_t		hid_req_data[MAX_REPORT_DATA];	/* data for send case */
910Sstevel@tonic-gate } hid_req_t;
920Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", hid_req_t))
930Sstevel@tonic-gate 
940Sstevel@tonic-gate /*
950Sstevel@tonic-gate  * hid_req_wValue values HID_GET_REPORT and HID_SET_REPORT
960Sstevel@tonic-gate  */
970Sstevel@tonic-gate #define	REPORT_TYPE_INPUT	0x0100			/* Input report */
980Sstevel@tonic-gate #define	REPORT_TYPE_OUTPUT	0x0200			/* Output report */
990Sstevel@tonic-gate #define	REPORT_TYPE_FEATURE	0x0300			/* Feature report */
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate /*
1030Sstevel@tonic-gate  * hid_req_wLength value for HID_GET_IDLE and HID_SET_IDLE
1040Sstevel@tonic-gate  */
1050Sstevel@tonic-gate #define	GET_IDLE_LENGTH		0x0001
1060Sstevel@tonic-gate #define	SET_IDLE_LENGTH		0x0000
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate /*
1090Sstevel@tonic-gate  * hid_req_wValue values for SET_PROTOCOL
1100Sstevel@tonic-gate  */
1110Sstevel@tonic-gate #define	SET_BOOT_PROTOCOL	0x0000			/* Boot protocol */
1120Sstevel@tonic-gate #define	SET_REPORT_PROTOCOL	0x0001			/* Report protocol */
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate /*
1150Sstevel@tonic-gate  * return values for GET_PROTOCOL
1160Sstevel@tonic-gate  */
1170Sstevel@tonic-gate #define	BOOT_PROTOCOL		0x00		/* Returned boot protocol */
1180Sstevel@tonic-gate #define	REPORT_PROTOCOL		0x01		/* Returned report protocol */
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate /*
1210Sstevel@tonic-gate  * There is an additional M_CTL command for obtaining the
1220Sstevel@tonic-gate  * hid parser handle.  This M_CTL returns a pointer to  the handle.
1230Sstevel@tonic-gate  * The type of the pointer is intpr_t because this type is large enough to
1240Sstevel@tonic-gate  * hold any data pointer.
1250Sstevel@tonic-gate  */
1260Sstevel@tonic-gate #define	HID_GET_PARSER_HANDLE	0x0100		/* obtain parser handle */
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate /*
129918Sqz150045  * The M_CTL command is to get the device vendor ID and product ID.
130918Sqz150045  */
131918Sqz150045 #define	HID_GET_VID_PID		0x0200		/* obtain device info */
132918Sqz150045 
133918Sqz150045 /*
1340Sstevel@tonic-gate  * M_CTL commands for event notifications
1350Sstevel@tonic-gate  */
1360Sstevel@tonic-gate #define	HID_POWER_OFF		0x00DC
1370Sstevel@tonic-gate #define	HID_FULL_POWER		0x00DD
1380Sstevel@tonic-gate #define	HID_DISCONNECT_EVENT	0x00DE
1390Sstevel@tonic-gate #define	HID_CONNECT_EVENT	0x00DF
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate /*
1420Sstevel@tonic-gate  * To get the report descriptor,
1430Sstevel@tonic-gate  * This is the wValue
1440Sstevel@tonic-gate  */
1450Sstevel@tonic-gate #define	USB_CLASS_DESCR_TYPE_REPORT	0x2200
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate /* Version numbers */
1490Sstevel@tonic-gate #define	HID_VERSION_V_0		0
1500Sstevel@tonic-gate 
151*10153SAaron.Zang@Sun.COM /*
152*10153SAaron.Zang@Sun.COM  * HID IOCTLS
153*10153SAaron.Zang@Sun.COM  */
154*10153SAaron.Zang@Sun.COM #define	HIDIOC	('h'<<8)
155*10153SAaron.Zang@Sun.COM 
156*10153SAaron.Zang@Sun.COM /*
157*10153SAaron.Zang@Sun.COM  * Each hid keyboard/mouse device instance has two streams (internal/external).
158*10153SAaron.Zang@Sun.COM  * This pair of ioctls is used to get/set which stream the input data should
159*10153SAaron.Zang@Sun.COM  * be sent to.
160*10153SAaron.Zang@Sun.COM  */
161*10153SAaron.Zang@Sun.COM #define	HIDIOCKMGDIRECT	(HIDIOC | 0)
162*10153SAaron.Zang@Sun.COM #define	HIDIOCKMSDIRECT	(HIDIOC | 1)
163*10153SAaron.Zang@Sun.COM 
1640Sstevel@tonic-gate #ifdef __cplusplus
1650Sstevel@tonic-gate }
1660Sstevel@tonic-gate #endif
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate #endif	/* _SYS_USB_HID_H */
169