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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_USB_HID_PARSER_DRIVER_H
27 #define	_SYS_USB_HID_PARSER_DRIVER_H
28 
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
35 /*
36  *
37  * This header file lists hidparser interfaces that are accessible only by
38  * the hid driver.
39  */
40 
41 
42 /*
43  * hidparser_parse_report_descriptor():
44  *	Parse a report descriptor according to the rules in the HID 1.0 spec.
45  *	Return a pointer to a hidparser_handle_t which will be used for
46  *	later queries to the parser.
47  *
48  * Arguments:
49  *	report_descriptor:
50  *		report_descriptor obtained from the HID device
51  *	size:
52  *		size of the report descriptor
53  *	hid_descriptor:
54  *		pointer to the hid descriptor
55  *	parse_handle:
56  *		pointer to a hidparser_handle_t
57  *
58  * Return values:
59  *	HID_PARSER_SUCCESS - no errors
60  * 	HID_PARSER_ERROR   - parsing the report descriptor failed
61  *
62  */
63 int hidparser_parse_report_descriptor(uchar_t *report_descriptor,
64 				size_t size,
65 				usb_hid_descr_t *hid_descriptor,
66 				hidparser_handle_t *parse_handle);
67 
68 
69 
70 /*
71  * hidparser_free_report_descriptor_handle():
72  *	Free the report descriptor handle
73  *
74  * Arguments:
75  *	parse_handle:
76  *		handle to be freed
77  *
78  * Return values:
79  *	HID_PARSER_SUCCESS - no errors
80  * 	HID_PARSER_FAILURE - unspecified error when freeing descriptor
81  */
82 int hidparser_free_report_descriptor_handle(hidparser_handle_t parse_handle);
83 
84 
85 /*
86  * hidparser_get_top_level_collection_usage():
87  *	Obtain the usage of the top level collection.  A streams module
88  * 	will be pushed on top of the hid driver based on the usage.
89  *
90  * Arguments:
91  *	parse_handle:  parser handle
92  *	usage_page:    filled in with the usage page upon return
93  *	usage:	       filled in with the usage upon return
94  *
95  * Return values:
96  *	HID_PARSER_SUCCESS - no errors
97  *	HID_PARSER_FAILURE - unspecified error
98  *
99  */
100 int hidparser_get_top_level_collection_usage(hidparser_handle_t parse_handle,
101 					uint_t *usage_page,
102 					uint_t *usage);
103 
104 /*
105  * hidparser_lookup_usage_collection:
106  *	Look up the collection specified by the usage page and usage id.
107  *
108  * Arguments:
109  *	parse_handle:  parser handle
110  *	lusage_page:   specified usage page
111  *	lusage_id:     specified usage
112  *
113  * Return values:
114  *	HID_PARSER_SUCCESS - found the specified collection
115  *	HID_PARSER_FAILURE - error or not found
116  */
117 int
118 hidparser_lookup_usage_collection(hidparser_handle_t parse_handle,
119 					uint_t lusage_page,
120 					uint_t lusage_id);
121 
122 
123 #ifdef __cplusplus
124 }
125 #endif
126 
127 #endif	/* _SYS_USB_HID_PARSER_DRIVER_H */
128