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
5e26dc4c8Ssetje  * Common Development and Distribution License (the "License").
6e26dc4c8Ssetje  * 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*827f5d6bSStrony Zhang - Solaris China Team  * 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_HIDPARSER_H
277c478bd9Sstevel@tonic-gate #define	_SYS_USB_HIDPARSER_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifdef __cplusplus
317c478bd9Sstevel@tonic-gate extern "C" {
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <sys/usb/usbai.h>
357c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usbai_private.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * This file contains interfaces accessible by both the hid driver and
397c478bd9Sstevel@tonic-gate  * a hid module.
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * HID parser handle
447c478bd9Sstevel@tonic-gate  *	The handle is opaque to the hid driver as well as the hid streams
457c478bd9Sstevel@tonic-gate  *	modules.
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate typedef struct hidparser_handle_impl *hidparser_handle_t;
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #define	HID_REPORT_ID_UNDEFINED	0
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate 
52*827f5d6bSStrony Zhang - Solaris China Team #define	USAGE_MAX	100	/* Max no. of usages in a report */
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate typedef struct hidparser_usage_info {
557c478bd9Sstevel@tonic-gate 	uint16_t	usage_page;
567c478bd9Sstevel@tonic-gate 	uint16_t	usage_id;
577c478bd9Sstevel@tonic-gate 	uint32_t	usage_min;
587c478bd9Sstevel@tonic-gate 	uint32_t	usage_max;
597c478bd9Sstevel@tonic-gate 	uint32_t	collection_usage;
607c478bd9Sstevel@tonic-gate 	int32_t		lmax;
617c478bd9Sstevel@tonic-gate 	int32_t		lmin;
627c478bd9Sstevel@tonic-gate 	uint32_t	rptcnt;
637c478bd9Sstevel@tonic-gate 	uint32_t	rptsz;
647c478bd9Sstevel@tonic-gate } hidparser_usage_info_t;
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /*
677c478bd9Sstevel@tonic-gate  * structure for each report type, INPUT, OUTPUT or FEATURE
687c478bd9Sstevel@tonic-gate  * Note report id 0 and only one collection is handled
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate typedef struct hidparser_rpt {
717c478bd9Sstevel@tonic-gate 	uint_t		report_id;
727c478bd9Sstevel@tonic-gate 	uint_t		main_item_value;
737c478bd9Sstevel@tonic-gate 	uint_t		no_of_usages;
747c478bd9Sstevel@tonic-gate 	hidparser_usage_info_t	usage_descr[USAGE_MAX];
757c478bd9Sstevel@tonic-gate } hidparser_rpt_t;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate  * structure to return a list of report id used for a report
797c478bd9Sstevel@tonic-gate  * type, INPUT, OUTPUT or FEATURE.
807c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate #define	REPORT_ID_MAX	10	/* Max no. of report ids supported per type */
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate typedef struct hidparser_report_id_list {
847c478bd9Sstevel@tonic-gate 	uint_t		main_item_value;
857c478bd9Sstevel@tonic-gate 	uint_t		no_of_report_ids;
867c478bd9Sstevel@tonic-gate 	uint_t		report_id[REPORT_ID_MAX];
877c478bd9Sstevel@tonic-gate } hidparser_report_id_list_t;
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate typedef struct hidparser_packet_info {
907c478bd9Sstevel@tonic-gate 	uint_t		max_packet_size;
917c478bd9Sstevel@tonic-gate 	uint_t		report_id;
927c478bd9Sstevel@tonic-gate } hidparser_packet_info_t;
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * hidparser_get_country_code():
967c478bd9Sstevel@tonic-gate  *	Obtain the country code value that was returned in the hid descriptor
977c478bd9Sstevel@tonic-gate  *	Fill in the country_code argument
987c478bd9Sstevel@tonic-gate  *
997c478bd9Sstevel@tonic-gate  * Arguments:
1007c478bd9Sstevel@tonic-gate  *	parser_handle:
1017c478bd9Sstevel@tonic-gate  *		hid parser handle
1027c478bd9Sstevel@tonic-gate  *	country code
1037c478bd9Sstevel@tonic-gate  *		filled in with the country code value, upon success
1047c478bd9Sstevel@tonic-gate  *
1057c478bd9Sstevel@tonic-gate  * Return values:
1067c478bd9Sstevel@tonic-gate  *	HIDPARSER_SUCCESS - returned on success
1077c478bd9Sstevel@tonic-gate  *	HIDPARSER_FAILURE - returned on an unspecified error
1087c478bd9Sstevel@tonic-gate  */
1097c478bd9Sstevel@tonic-gate int hidparser_get_country_code(hidparser_handle_t parser_handle,
1107c478bd9Sstevel@tonic-gate 				uint16_t *country_code);
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate /*
1147c478bd9Sstevel@tonic-gate  * hidparser_get_packet_size():
1157c478bd9Sstevel@tonic-gate  *	Obtain the size(no. of bits) for a particular packet type. Note
1167c478bd9Sstevel@tonic-gate  *	that a hid transfer may span more than one USB transaction.
1177c478bd9Sstevel@tonic-gate  *
1187c478bd9Sstevel@tonic-gate  * Arguments:
1197c478bd9Sstevel@tonic-gate  *	parser_handle:
1207c478bd9Sstevel@tonic-gate  *		hid parser handle
1217c478bd9Sstevel@tonic-gate  *	report_id:
1227c478bd9Sstevel@tonic-gate  *		report id
1237c478bd9Sstevel@tonic-gate  *	main_item_type:
1247c478bd9Sstevel@tonic-gate  *		type of report, either Input, Output, or Feature
1257c478bd9Sstevel@tonic-gate  *	size:
1267c478bd9Sstevel@tonic-gate  *		the size if filled in upon success
1277c478bd9Sstevel@tonic-gate  * Return values:
1287c478bd9Sstevel@tonic-gate  *	HIDPARSER_SUCCESS - returned success
1297c478bd9Sstevel@tonic-gate  *	HIDPARSER_FAILURE - returned failure
1307c478bd9Sstevel@tonic-gate  */
1317c478bd9Sstevel@tonic-gate int hidparser_get_packet_size(hidparser_handle_t parser_handle,
1327c478bd9Sstevel@tonic-gate 				uint_t report_id,
1337c478bd9Sstevel@tonic-gate 				uint_t main_item_type,
1347c478bd9Sstevel@tonic-gate 				uint_t *size);
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate /*
1377c478bd9Sstevel@tonic-gate  * hidparser_get_usage_attribute()
1387c478bd9Sstevel@tonic-gate  *	Find the specified local item associated with the given usage. For
1397c478bd9Sstevel@tonic-gate  *	example, this function may be used to find the logical minimum for
1407c478bd9Sstevel@tonic-gate  *	an X usage.  Note that only short items are supported.
1417c478bd9Sstevel@tonic-gate  *
1427c478bd9Sstevel@tonic-gate  *
1437c478bd9Sstevel@tonic-gate  * Arguments:
1447c478bd9Sstevel@tonic-gate  *	parser_handle:
1457c478bd9Sstevel@tonic-gate  *		hid parser handle
1467c478bd9Sstevel@tonic-gate  *	report id:
1477c478bd9Sstevel@tonic-gate  *		report id of the particular report that the usage may be
1487c478bd9Sstevel@tonic-gate  *		found in.
1497c478bd9Sstevel@tonic-gate  *	main_item_type:
1507c478bd9Sstevel@tonic-gate  *		type of report, either Input, Output, or Feature
1517c478bd9Sstevel@tonic-gate  *	usage_page:
1527c478bd9Sstevel@tonic-gate  *		usage page that the Usage may be found on.
1537c478bd9Sstevel@tonic-gate  *	usage:
1547c478bd9Sstevel@tonic-gate  *		the Usage for which the local item will be found
1557c478bd9Sstevel@tonic-gate  *	usage_attribute:
1567c478bd9Sstevel@tonic-gate  *		type of local item to be found. Possible local and global
1577c478bd9Sstevel@tonic-gate  *		items are given below.
1587c478bd9Sstevel@tonic-gate  *
1597c478bd9Sstevel@tonic-gate  *	usage_attribute_value:
1607c478bd9Sstevel@tonic-gate  *		filled in with the value of the attribute upon return
1617c478bd9Sstevel@tonic-gate  *
1627c478bd9Sstevel@tonic-gate  * Return values:
1637c478bd9Sstevel@tonic-gate  *	HIDPARSER_SUCCESS - returned success
1647c478bd9Sstevel@tonic-gate  *	HIDPARSER_NOT_FOUND - usage specified by the parameters was not found
1657c478bd9Sstevel@tonic-gate  *	HIDPARSER_FAILURE - unspecified failure
1667c478bd9Sstevel@tonic-gate  *
1677c478bd9Sstevel@tonic-gate  */
1687c478bd9Sstevel@tonic-gate int hidparser_get_usage_attribute(hidparser_handle_t parser_handle,
1697c478bd9Sstevel@tonic-gate 					uint_t report_id,
1707c478bd9Sstevel@tonic-gate 					uint_t main_item_type,
1717c478bd9Sstevel@tonic-gate 					uint_t usage_page,
1727c478bd9Sstevel@tonic-gate 					uint_t usage,
1737c478bd9Sstevel@tonic-gate 					uint_t usage_attribute,
1747c478bd9Sstevel@tonic-gate 					int *usage_attribute_value);
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate /*
1777c478bd9Sstevel@tonic-gate  * hidparser_get_main_item_data_descr()
1787c478bd9Sstevel@tonic-gate  *
1797c478bd9Sstevel@tonic-gate  * Description:
1807c478bd9Sstevel@tonic-gate  *	Query the parser to find the data description of the main item.
1817c478bd9Sstevel@tonic-gate  *	Section 6.2.2.5 of the HID 1.0 specification gives details
1827c478bd9Sstevel@tonic-gate  *	about the data descriptions. For example, this function may be
1837c478bd9Sstevel@tonic-gate  *	used to find out if an X value sent by the a USB mouse is an
1847c478bd9Sstevel@tonic-gate  *	absolute or relative value.
1857c478bd9Sstevel@tonic-gate  *
1867c478bd9Sstevel@tonic-gate  * Parameters:
1877c478bd9Sstevel@tonic-gate  *	parser_handle		parser handle
1887c478bd9Sstevel@tonic-gate  *	report_id		report id of the particular report that the
1897c478bd9Sstevel@tonic-gate  *				usage may be found in
1907c478bd9Sstevel@tonic-gate  *	main_item_type		type of report - either Input, Output, Feature,
1917c478bd9Sstevel@tonic-gate  *				or Collection
1927c478bd9Sstevel@tonic-gate  *	usage_page		usage page that the usage may be found on
1937c478bd9Sstevel@tonic-gate  *	usage			type of local item to be found
1947c478bd9Sstevel@tonic-gate  *	main_item_descr_value	filled in with the data description
1957c478bd9Sstevel@tonic-gate  *
1967c478bd9Sstevel@tonic-gate  * Return values:
1977c478bd9Sstevel@tonic-gate  *	HIDPARSER_SUCCESS	attribute found successfully
1987c478bd9Sstevel@tonic-gate  *	HIDPARSER_NOT_FOUND	usage specified by the parameters was not found
1997c478bd9Sstevel@tonic-gate  *	HIDPARSER_FAILURE	unspecified failure
2007c478bd9Sstevel@tonic-gate  */
2017c478bd9Sstevel@tonic-gate int
2027c478bd9Sstevel@tonic-gate hidparser_get_main_item_data_descr(
2037c478bd9Sstevel@tonic-gate 			hidparser_handle_t	parser_handle,
2047c478bd9Sstevel@tonic-gate 			uint_t		report_id,
2057c478bd9Sstevel@tonic-gate 			uint_t		main_item_type,
2067c478bd9Sstevel@tonic-gate 			uint_t		usage_page,
2077c478bd9Sstevel@tonic-gate 			uint_t		usage,
2087c478bd9Sstevel@tonic-gate 			uint_t		*main_item_descr_value);
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate /*
2127c478bd9Sstevel@tonic-gate  * hidparser_get_usage_list_in_order()
2137c478bd9Sstevel@tonic-gate  *	Find all the usages corresponding to a main item, report id and
2147c478bd9Sstevel@tonic-gate  *	a particular usage page.
2157c478bd9Sstevel@tonic-gate  *	Note that only short items and 0 report id is supported.
2167c478bd9Sstevel@tonic-gate  *
2177c478bd9Sstevel@tonic-gate  * Arguments:
2187c478bd9Sstevel@tonic-gate  *	parser_handle:
2197c478bd9Sstevel@tonic-gate  *		hid parser handle
2207c478bd9Sstevel@tonic-gate  *	report id:
2217c478bd9Sstevel@tonic-gate  *		report id of the particular report where the usages belong to
2227c478bd9Sstevel@tonic-gate  *	main_item_type:
2237c478bd9Sstevel@tonic-gate  *		type of report, either Input, Output, or Feature
2247c478bd9Sstevel@tonic-gate  *	usage_list:
2257c478bd9Sstevel@tonic-gate  *		Filled in with the pointer to the first element of the
2267c478bd9Sstevel@tonic-gate  *		usage list
2277c478bd9Sstevel@tonic-gate  *
2287c478bd9Sstevel@tonic-gate  * Return values:
2297c478bd9Sstevel@tonic-gate  *	HIDPARSER_SUCCESS - returned success
2307c478bd9Sstevel@tonic-gate  *	HIDPARSER_NOT_FOUND - usage specified by the parameters was not found
2317c478bd9Sstevel@tonic-gate  *	HIDPARSER_FAILURE - unspecified failure
2327c478bd9Sstevel@tonic-gate  */
2337c478bd9Sstevel@tonic-gate int
2347c478bd9Sstevel@tonic-gate hidparser_get_usage_list_in_order(hidparser_handle_t parse_handle,
2357c478bd9Sstevel@tonic-gate 				uint_t report_id,
2367c478bd9Sstevel@tonic-gate 				uint_t main_item_type,
2377c478bd9Sstevel@tonic-gate 				hidparser_rpt_t *rpt);
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate /*
2417c478bd9Sstevel@tonic-gate  * hidparser_get_report_id_list()
2427c478bd9Sstevel@tonic-gate  *	Return a list of all report ids used for descriptor items
2437c478bd9Sstevel@tonic-gate  *	corresponding to a main item.
2447c478bd9Sstevel@tonic-gate  *
2457c478bd9Sstevel@tonic-gate  * Arguments:
2467c478bd9Sstevel@tonic-gate  *	parser_handle:
2477c478bd9Sstevel@tonic-gate  *		hid parser handle
2487c478bd9Sstevel@tonic-gate  *	main_item_type:
2497c478bd9Sstevel@tonic-gate  *		type of report, either Input, Output, or Feature
2507c478bd9Sstevel@tonic-gate  *	report_id_list:
2517c478bd9Sstevel@tonic-gate  *		Filled in with a list of report ids found in the descriptor
2527c478bd9Sstevel@tonic-gate  *
2537c478bd9Sstevel@tonic-gate  * Return values:
2547c478bd9Sstevel@tonic-gate  *	HIDPARSER_SUCCESS - returned success
2557c478bd9Sstevel@tonic-gate  *	HIDPARSER_FAILURE - unspecified failure
2567c478bd9Sstevel@tonic-gate  */
2577c478bd9Sstevel@tonic-gate int
2587c478bd9Sstevel@tonic-gate hidparser_get_report_id_list(hidparser_handle_t parser_handle,
2597c478bd9Sstevel@tonic-gate     uint_t main_item_type, hidparser_report_id_list_t *report_id_list);
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate /*
2627c478bd9Sstevel@tonic-gate  * hidparser_find_max_packet_size_from_report_descriptor()
2637c478bd9Sstevel@tonic-gate  *	Returns the packet size of the largest report in the complete
2647c478bd9Sstevel@tonic-gate  *	report descriptor.
2657c478bd9Sstevel@tonic-gate  *
2667c478bd9Sstevel@tonic-gate  * Arguments
2677c478bd9Sstevel@tonic-gate  *	parser_handle:
2687c478bd9Sstevel@tonic-gate  *		hidparser_handle_t
2697c478bd9Sstevel@tonic-gate  *	packet_info:
2707c478bd9Sstevel@tonic-gate  *		hidparser_packet_info_t *
2717c478bd9Sstevel@tonic-gate  */
2727c478bd9Sstevel@tonic-gate void
2737c478bd9Sstevel@tonic-gate hidparser_find_max_packet_size_from_report_descriptor(
2747c478bd9Sstevel@tonic-gate     hidparser_handle_t parser_handle, hidparser_packet_info_t *hpack);
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate /*
2797c478bd9Sstevel@tonic-gate  * Local Items
2807c478bd9Sstevel@tonic-gate  *	See section 6.2.2.8 of the HID 1.0 specification for
2817c478bd9Sstevel@tonic-gate  *	more details.
2827c478bd9Sstevel@tonic-gate  */
2837c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_USAGE		0x08
2847c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_USAGE_MIN	0x18
2857c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_USAGE_MAX	0x28
2867c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_DESIGNATOR_INDEX	0x38
2877c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_DESIGNATOR_MIN	0x48
2887c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_DESIGNATOR_MAX	0x58
2897c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_STRING_INDEX	0x78
2907c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_STRING_MIN	0x88
2917c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_STRING_MAX	0x98
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate /*
2947c478bd9Sstevel@tonic-gate  * Global Items
2957c478bd9Sstevel@tonic-gate  *	See section 6.2.2.7 of the HID 1.0 specifations for
2967c478bd9Sstevel@tonic-gate  *	more details.
2977c478bd9Sstevel@tonic-gate  */
2987c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_LOGICAL_MINIMUM	0x14
2997c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_LOGICAL_MAXIMUM	0x24
3007c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_PHYSICAL_MINIMUM	0x34
3017c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_PHYSICAL_MAXIMUM	0x44
3027c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_EXPONENT		0x54
3037c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_UNIT		0x64
3047c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_REPORT_SIZE	0x74
3057c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_REPORT_ID	0x84
3067c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_REPORT_COUNT	0x94
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate /*
3097c478bd9Sstevel@tonic-gate  * Main Items
3107c478bd9Sstevel@tonic-gate  *	See section 6.2.2.5 of the HID 1.0 specification for
3117c478bd9Sstevel@tonic-gate  *	more details.
3127c478bd9Sstevel@tonic-gate  */
3137c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_INPUT		0x80
3147c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_OUTPUT		0x90
3157c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_FEATURE		0xB0
3167c478bd9Sstevel@tonic-gate #define	HIDPARSER_ITEM_COLLECTION	0xA0
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate /*
3207c478bd9Sstevel@tonic-gate  * Macros to extract the usage page and usage id from a 32 bit usage
3217c478bd9Sstevel@tonic-gate  * value.
3227c478bd9Sstevel@tonic-gate  */
3237c478bd9Sstevel@tonic-gate #define	HID_USAGE_ID(usage)		((usage) & 0xffff)
3247c478bd9Sstevel@tonic-gate #define	HID_USAGE_PAGE(usage)		((usage)>>16 & 0xffff)
3257c478bd9Sstevel@tonic-gate #define	HID_BUILD_USAGE(page, id)	(((page) & 0xffff) << 16 | \
3267c478bd9Sstevel@tonic-gate 					((id) & 0xffff))
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate /*
3297c478bd9Sstevel@tonic-gate  * Usage Pages
3307c478bd9Sstevel@tonic-gate  *	See the "Universal Serial Bus HID Usages Table"
3317c478bd9Sstevel@tonic-gate  *	specification for more information
3327c478bd9Sstevel@tonic-gate  */
3337c478bd9Sstevel@tonic-gate #define	HID_GENERIC_DESKTOP		0x01
3347c478bd9Sstevel@tonic-gate #define	HID_KEYBOARD_KEYPAD_KEYS	0x07
3357c478bd9Sstevel@tonic-gate #define	HID_LEDS			0x08
3367c478bd9Sstevel@tonic-gate #define	HID_CONSUMER			0x0C
3377c478bd9Sstevel@tonic-gate #define	HID_BUTTON_PAGE			0x09
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate /*
3407c478bd9Sstevel@tonic-gate  * Any Usage Page
3417c478bd9Sstevel@tonic-gate  *	See the "Universal Serial Bus HID Usages Table"
3427c478bd9Sstevel@tonic-gate  *	specification for more information
3437c478bd9Sstevel@tonic-gate  */
3447c478bd9Sstevel@tonic-gate #define	HID_USAGE_UNDEFINED	0x00
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate /*
3477c478bd9Sstevel@tonic-gate  * Generic Desktop Page (0x01)
3487c478bd9Sstevel@tonic-gate  *	See the "Universal Serial Bus HID Usages Table"
3497c478bd9Sstevel@tonic-gate  *	specification for more information
3507c478bd9Sstevel@tonic-gate  */
3517c478bd9Sstevel@tonic-gate #define	HID_GD_POINTER		0x01
3527c478bd9Sstevel@tonic-gate #define	HID_GD_MOUSE		0x02
3537c478bd9Sstevel@tonic-gate #define	HID_GD_KEYBOARD		0x06
3547c478bd9Sstevel@tonic-gate #define	HID_GD_X		0x30
3557c478bd9Sstevel@tonic-gate #define	HID_GD_Y		0x31
356e26dc4c8Ssetje #define	HID_GD_Z		0x32
3577c478bd9Sstevel@tonic-gate #define	HID_GD_WHEEL		0x38
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate /*
3607c478bd9Sstevel@tonic-gate  * LED Page (0x08)
3617c478bd9Sstevel@tonic-gate  *	See the "Universal Serial Bus HID Usages Table"
3627c478bd9Sstevel@tonic-gate  *	specification for more information
3637c478bd9Sstevel@tonic-gate  */
3647c478bd9Sstevel@tonic-gate #define	HID_LED_NUM_LOCK	0x01
3657c478bd9Sstevel@tonic-gate #define	HID_LED_CAPS_LOCK	0x02
3667c478bd9Sstevel@tonic-gate #define	HID_LED_SCROLL_LOCK	0x03
3677c478bd9Sstevel@tonic-gate #define	HID_LED_COMPOSE		0x04
3687c478bd9Sstevel@tonic-gate #define	HID_LED_KANA		0x05
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate /*
3717c478bd9Sstevel@tonic-gate  * Consumer page (0x0C)
3727c478bd9Sstevel@tonic-gate  *	See the "Universal Serial Bus HID Usages Table"
3737c478bd9Sstevel@tonic-gate  *	specification for more information
3747c478bd9Sstevel@tonic-gate  */
3757c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_CONTROL	0x01
3767c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_MICROPHONE	0x04
3777c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_HEADPHONE	0x05
3787c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_GRAPHIC_EQ	0x06
3797c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_PLAY	0xB0
3807c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_RECORD	0xB2
3817c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_VOL	0xE0
3827c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_BALANCE	0xE1
3837c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_MUTE	0xE2
3847c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_BASS	0xE3
3857c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_TREBLE	0xE4
3867c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_VOL_INCR	0xE9
3877c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_VOL_DECR	0xEA
3887c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_BAL_RIGHT	0x150
3897c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_BAL_LEFT	0x151
3907c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_BASS_INCR	0x152
3917c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_BASS_DECR	0x153
3927c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_TREBLE_INCR 0x154
3937c478bd9Sstevel@tonic-gate #define	HID_CONSUMER_TREBLE_DECR 0x155
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate /*
3977c478bd9Sstevel@tonic-gate  * Main Item Data Descriptor Information for
3987c478bd9Sstevel@tonic-gate  *	Input, Output, and Feature Main Items
3997c478bd9Sstevel@tonic-gate  *	See section 6.2.2.5 of the HID 1.0 specification for
4007c478bd9Sstevel@tonic-gate  *	more details.
4017c478bd9Sstevel@tonic-gate  */
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_DATA		0x0000
4057c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_CONSTANT		0x0001
4067c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_ARRAY		0x0000
4077c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_VARIABLE		0x0002
4087c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_ABSOLUTE		0x0000
4097c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_RELATIVE		0x0004
4107c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_NO_WRAP		0x0000
4117c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_WRAP		0x0008
4127c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_LINEAR		0x0000
4137c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_NONLINEAR		0x0010
4147c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_PREFERRED 	0x0000
4157c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_NO_PREFERRED	0x0020
4167c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_NO_NULL		0x0000
4177c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_NULL		0x0040
4187c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_NON_VOLATILE	0x0000
4197c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_VOLATILE		0x0080
4207c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_BIT_FIELD		0x0000
4217c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_BUFFERED_BYTE	0x0100
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate /*
4247c478bd9Sstevel@tonic-gate  * Main Item Data Descriptor Information for
4257c478bd9Sstevel@tonic-gate  *	Collection Main Items
4267c478bd9Sstevel@tonic-gate  *	See section 6.2.2.4 of the HID 1.0 specification for
4277c478bd9Sstevel@tonic-gate  *	more details.
4287c478bd9Sstevel@tonic-gate  */
4297c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_PHYSICAL		0x0000
4307c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_APPLICATION	0x0001
4317c478bd9Sstevel@tonic-gate #define	HID_MAIN_ITEM_LOGICAL		0x0002
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate 
4347c478bd9Sstevel@tonic-gate /*
4357c478bd9Sstevel@tonic-gate  * Other
4367c478bd9Sstevel@tonic-gate  */
4377c478bd9Sstevel@tonic-gate #define	HIDPARSER_SUCCESS	0
4387c478bd9Sstevel@tonic-gate #define	HIDPARSER_FAILURE	1
4397c478bd9Sstevel@tonic-gate #define	HIDPARSER_NOT_FOUND	2
4407c478bd9Sstevel@tonic-gate 
4417c478bd9Sstevel@tonic-gate #ifdef __cplusplus
4427c478bd9Sstevel@tonic-gate }
4437c478bd9Sstevel@tonic-gate #endif
4447c478bd9Sstevel@tonic-gate 
4457c478bd9Sstevel@tonic-gate #endif	/* _SYS_USB_HIDPARSER_H */
446