usb_hid.c (193045) | usb_hid.c (193074) |
---|---|
1/* $NetBSD: hid.c,v 1.17 2001/11/13 06:24:53 lukem Exp $ */ 2 3 4#include <sys/cdefs.h> | 1/* $NetBSD: hid.c,v 1.17 2001/11/13 06:24:53 lukem Exp $ */ 2 3 4#include <sys/cdefs.h> |
5__FBSDID("$FreeBSD: head/sys/dev/usb/usb_hid.c 193045 2009-05-29 18:46:57Z thompsa $"); | 5__FBSDID("$FreeBSD: head/sys/dev/usb/usb_hid.c 193074 2009-05-30 00:22:57Z thompsa $"); |
6/*- 7 * Copyright (c) 1998 The NetBSD Foundation, Inc. 8 * All rights reserved. 9 * 10 * This code is derived from software contributed to The NetBSD Foundation 11 * by Lennart Augustsson (lennart@augustsson.net) at 12 * Carlstedt Research & Technology. 13 * --- 86 unchanged lines hidden (view full) --- 100 c->string_maximum = 0; 101 c->set_delimiter = 0; 102} 103 104/*------------------------------------------------------------------------* 105 * hid_start_parse 106 *------------------------------------------------------------------------*/ 107struct hid_data * | 6/*- 7 * Copyright (c) 1998 The NetBSD Foundation, Inc. 8 * All rights reserved. 9 * 10 * This code is derived from software contributed to The NetBSD Foundation 11 * by Lennart Augustsson (lennart@augustsson.net) at 12 * Carlstedt Research & Technology. 13 * --- 86 unchanged lines hidden (view full) --- 100 c->string_maximum = 0; 101 c->set_delimiter = 0; 102} 103 104/*------------------------------------------------------------------------* 105 * hid_start_parse 106 *------------------------------------------------------------------------*/ 107struct hid_data * |
108hid_start_parse(const void *d, size_t len, int kindset) | 108hid_start_parse(const void *d, usb_size_t len, int kindset) |
109{ 110 struct hid_data *s; 111 112 if ((kindset-1) & kindset) { 113 DPRINTFN(0, "Only one bit can be " 114 "set in the kindset\n"); 115 return (NULL); 116 } --- 369 unchanged lines hidden (view full) --- 486 } 487 return (0); 488} 489 490/*------------------------------------------------------------------------* 491 * hid_report_size 492 *------------------------------------------------------------------------*/ 493int | 109{ 110 struct hid_data *s; 111 112 if ((kindset-1) & kindset) { 113 DPRINTFN(0, "Only one bit can be " 114 "set in the kindset\n"); 115 return (NULL); 116 } --- 369 unchanged lines hidden (view full) --- 486 } 487 return (0); 488} 489 490/*------------------------------------------------------------------------* 491 * hid_report_size 492 *------------------------------------------------------------------------*/ 493int |
494hid_report_size(const void *buf, size_t len, enum hid_kind k, uint8_t *id) | 494hid_report_size(const void *buf, usb_size_t len, enum hid_kind k, uint8_t *id) |
495{ 496 struct hid_data *d; 497 struct hid_item h; 498 uint32_t temp; 499 uint32_t hpos; 500 uint32_t lpos; 501 uint8_t any_id; 502 --- 36 unchanged lines hidden (view full) --- 539 /* return length in bytes rounded up */ 540 return ((temp + 7) / 8); 541} 542 543/*------------------------------------------------------------------------* 544 * hid_locate 545 *------------------------------------------------------------------------*/ 546int | 495{ 496 struct hid_data *d; 497 struct hid_item h; 498 uint32_t temp; 499 uint32_t hpos; 500 uint32_t lpos; 501 uint8_t any_id; 502 --- 36 unchanged lines hidden (view full) --- 539 /* return length in bytes rounded up */ 540 return ((temp + 7) / 8); 541} 542 543/*------------------------------------------------------------------------* 544 * hid_locate 545 *------------------------------------------------------------------------*/ 546int |
547hid_locate(const void *desc, size_t size, uint32_t u, enum hid_kind k, | 547hid_locate(const void *desc, usb_size_t size, uint32_t u, enum hid_kind k, |
548 uint8_t index, struct hid_location *loc, uint32_t *flags, uint8_t *id) 549{ 550 struct hid_data *d; 551 struct hid_item h; 552 553 for (d = hid_start_parse(desc, size, 1 << k); hid_get_item(d, &h);) { 554 if (h.kind == k && !(h.flags & HIO_CONST) && h.usage == u) { 555 if (index--) --- 17 unchanged lines hidden (view full) --- 573 hid_end_parse(d); 574 return (0); 575} 576 577/*------------------------------------------------------------------------* 578 * hid_get_data 579 *------------------------------------------------------------------------*/ 580uint32_t | 548 uint8_t index, struct hid_location *loc, uint32_t *flags, uint8_t *id) 549{ 550 struct hid_data *d; 551 struct hid_item h; 552 553 for (d = hid_start_parse(desc, size, 1 << k); hid_get_item(d, &h);) { 554 if (h.kind == k && !(h.flags & HIO_CONST) && h.usage == u) { 555 if (index--) --- 17 unchanged lines hidden (view full) --- 573 hid_end_parse(d); 574 return (0); 575} 576 577/*------------------------------------------------------------------------* 578 * hid_get_data 579 *------------------------------------------------------------------------*/ 580uint32_t |
581hid_get_data(const uint8_t *buf, size_t len, struct hid_location *loc) | 581hid_get_data(const uint8_t *buf, usb_size_t len, struct hid_location *loc) |
582{ 583 uint32_t hpos = loc->pos; 584 uint32_t hsize = loc->size; 585 uint32_t data; 586 uint32_t rpos; 587 uint8_t n; 588 589 DPRINTFN(11, "hid_get_data: loc %d/%d\n", hpos, hsize); --- 26 unchanged lines hidden (view full) --- 616 loc->pos, loc->size, (long)data); 617 return (data); 618} 619 620/*------------------------------------------------------------------------* 621 * hid_is_collection 622 *------------------------------------------------------------------------*/ 623int | 582{ 583 uint32_t hpos = loc->pos; 584 uint32_t hsize = loc->size; 585 uint32_t data; 586 uint32_t rpos; 587 uint8_t n; 588 589 DPRINTFN(11, "hid_get_data: loc %d/%d\n", hpos, hsize); --- 26 unchanged lines hidden (view full) --- 616 loc->pos, loc->size, (long)data); 617 return (data); 618} 619 620/*------------------------------------------------------------------------* 621 * hid_is_collection 622 *------------------------------------------------------------------------*/ 623int |
624hid_is_collection(const void *desc, size_t size, uint32_t usage) | 624hid_is_collection(const void *desc, usb_size_t size, uint32_t usage) |
625{ 626 struct hid_data *hd; 627 struct hid_item hi; 628 int err; 629 630 hd = hid_start_parse(desc, size, hid_input); 631 if (hd == NULL) 632 return (0); --- 94 unchanged lines hidden --- | 625{ 626 struct hid_data *hd; 627 struct hid_item hi; 628 int err; 629 630 hd = hid_start_parse(desc, size, hid_input); 631 if (hd == NULL) 632 return (0); --- 94 unchanged lines hidden --- |