• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/hid/

Lines Matching refs:parser

109 static int open_collection(struct hid_parser *parser, unsigned type)
114 usage = parser->local.usage[0];
116 if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) {
121 if (parser->device->maxcollection == parser->device->collection_size) {
123 parser->device->collection_size * 2, GFP_KERNEL);
128 memcpy(collection, parser->device->collection,
130 parser->device->collection_size);
131 memset(collection + parser->device->collection_size, 0,
133 parser->device->collection_size);
134 kfree(parser->device->collection);
135 parser->device->collection = collection;
136 parser->device->collection_size *= 2;
139 parser->collection_stack[parser->collection_stack_ptr++] =
140 parser->device->maxcollection;
142 collection = parser->device->collection +
143 parser->device->maxcollection++;
146 collection->level = parser->collection_stack_ptr - 1;
149 parser->device->maxapplication++;
158 static int close_collection(struct hid_parser *parser)
160 if (!parser->collection_stack_ptr) {
164 parser->collection_stack_ptr--;
173 static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
176 for (n = parser->collection_stack_ptr - 1; n >= 0; n--)
177 if (parser->device->collection[parser->collection_stack[n]].type == type)
178 return parser->device->collection[parser->collection_stack[n]].usage;
183 * Add a usage to the temporary parser table.
186 static int hid_add_usage(struct hid_parser *parser, unsigned usage)
188 if (parser->local.usage_index >= HID_MAX_USAGES) {
192 parser->local.usage[parser->local.usage_index] = usage;
193 parser->local.collection_index[parser->local.usage_index] =
194 parser->collection_stack_ptr ?
195 parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
196 parser->local.usage_index++;
204 static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags)
212 if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) {
217 if (parser->global.logical_maximum < parser->global.logical_minimum) {
218 dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum);
223 report->size += parser->global.report_size * parser->global.report_count;
225 if (!parser->local.usage_index) /* Ignore padding fields */
228 usages = max_t(int, parser->local.usage_index, parser->global.report_count);
230 if ((field = hid_register_field(report, usages, parser->global.report_count)) == NULL)
233 field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL);
234 field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL);
235 field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);
240 if (i >= parser->local.usage_index)
241 j = parser->local.usage_index - 1;
242 field->usage[i].hid = parser->local.usage[j];
244 parser->local.collection_index[j];
251 field->report_size = parser->global.report_size;
252 field->report_count = parser->global.report_count;
253 field->logical_minimum = parser->global.logical_minimum;
254 field->logical_maximum = parser->global.logical_maximum;
255 field->physical_minimum = parser->global.physical_minimum;
256 field->physical_maximum = parser->global.physical_maximum;
257 field->unit_exponent = parser->global.unit_exponent;
258 field->unit = parser->global.unit;
291 static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
296 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
301 memcpy(parser->global_stack + parser->global_stack_ptr++,
302 &parser->global, sizeof(struct hid_global));
307 if (!parser->global_stack_ptr) {
312 memcpy(&parser->global, parser->global_stack +
313 --parser->global_stack_ptr, sizeof(struct hid_global));
317 parser->global.usage_page = item_udata(item);
321 parser->global.logical_minimum = item_sdata(item);
325 if (parser->global.logical_minimum < 0)
326 parser->global.logical_maximum = item_sdata(item);
328 parser->global.logical_maximum = item_udata(item);
332 parser->global.physical_minimum = item_sdata(item);
336 if (parser->global.physical_minimum < 0)
337 parser->global.physical_maximum = item_sdata(item);
339 parser->global.physical_maximum = item_udata(item);
343 parser->global.unit_exponent = item_sdata(item);
347 parser->global.unit = item_udata(item);
351 parser->global.report_size = item_udata(item);
352 if (parser->global.report_size > 32) {
354 parser->global.report_size);
360 parser->global.report_count = item_udata(item);
361 if (parser->global.report_count > HID_MAX_USAGES) {
363 parser->global.report_count);
369 parser->global.report_id = item_udata(item);
370 if (parser->global.report_id == 0) {
386 static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
409 if (parser->local.delimiter_depth != 0) {
413 parser->local.delimiter_depth++;
414 parser->local.delimiter_branch++;
416 if (parser->local.delimiter_depth < 1) {
420 parser->local.delimiter_depth--;
426 if (parser->local.delimiter_branch > 1) {
432 data = (parser->global.usage_page << 16) + data;
434 return hid_add_usage(parser, data);
438 if (parser->local.delimiter_branch > 1) {
444 data = (parser->global.usage_page << 16) + data;
446 parser->local.usage_minimum = data;
451 if (parser->local.delimiter_branch > 1) {
457 data = (parser->global.usage_page << 16) + data;
459 for (n = parser->local.usage_minimum; n <= data; n++)
460 if (hid_add_usage(parser, n)) {
478 static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
487 ret = open_collection(parser, data & 0xff);
490 ret = close_collection(parser);
493 ret = hid_add_field(parser, HID_INPUT_REPORT, data);
496 ret = hid_add_field(parser, HID_OUTPUT_REPORT, data);
499 ret = hid_add_field(parser, HID_FEATURE_REPORT, data);
506 memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */
515 static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item)
641 struct hid_parser *parser;
645 static int (*dispatch_type[])(struct hid_parser *parser,
661 parser = vmalloc(sizeof(struct hid_parser));
662 if (!parser) {
667 memset(parser, 0, sizeof(struct hid_parser));
668 parser->device = device;
679 if (dispatch_type[item.type](parser, &item)) {
686 if (parser->collection_stack_ptr) {
690 if (parser->local.delimiter_depth) {
694 vfree(parser);
701 vfree(parser);
1933 printk(KERN_WARNING "HID: hid_debug is now used solely for parser and driver debugging.\n"