git: d51e437669e4 - main - hidbus(4): Add routine to check presence of collection of given usage

Vladimir Kondratyev wulf at FreeBSD.org
Thu Sep 2 19:36:01 UTC 2021


The branch main has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=d51e437669e4ac35ac4be366241ae6ba4a16c378

commit d51e437669e4ac35ac4be366241ae6ba4a16c378
Author:     Vladimir Kondratyev <wulf at FreeBSD.org>
AuthorDate: 2021-09-02 19:32:57 +0000
Commit:     Vladimir Kondratyev <wulf at FreeBSD.org>
CommitDate: 2021-09-02 19:35:27 +0000

    hidbus(4): Add routine to check presence of collection of given usage
    
    MFC after:      2 week
---
 sys/dev/hid/hidbus.c | 19 +++++++++++++++++++
 sys/dev/hid/hidbus.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/sys/dev/hid/hidbus.c b/sys/dev/hid/hidbus.c
index 58d19a2a4d74..69f3d3911631 100644
--- a/sys/dev/hid/hidbus.c
+++ b/sys/dev/hid/hidbus.c
@@ -172,6 +172,25 @@ hidbus_locate(const void *desc, hid_size_t size, int32_t u, enum hid_kind k,
 	return (0);
 }
 
+bool
+hidbus_is_collection(const void *desc, hid_size_t size, int32_t usage,
+    uint8_t tlc_index)
+{
+	struct hid_data *d;
+	struct hid_item h;
+	bool ret = false;
+
+	d = hid_start_parse(desc, size, 0);
+	HIDBUS_FOREACH_ITEM(d, &h, tlc_index) {
+		if (h.kind == hid_collection && h.usage == usage) {
+			ret = true;
+			break;
+		}
+	}
+	hid_end_parse(d);
+	return (ret);
+}
+
 static device_t
 hidbus_add_child(device_t dev, u_int order, const char *name, int unit)
 {
diff --git a/sys/dev/hid/hidbus.h b/sys/dev/hid/hidbus.h
index 05911fff5732..d4324a2dc394 100644
--- a/sys/dev/hid/hidbus.h
+++ b/sys/dev/hid/hidbus.h
@@ -152,6 +152,7 @@ int	hidbus_locate(const void *desc, hid_size_t size, int32_t u,
 	    enum hid_kind k, uint8_t tlc_index, uint8_t index,
 	    struct hid_location *loc, uint32_t *flags, uint8_t *id,
 	    struct hid_absinfo *ai);
+bool	hidbus_is_collection(const void *, hid_size_t, int32_t, uint8_t);
 
 const struct hid_device_id *hidbus_lookup_id(device_t,
 		    const struct hid_device_id *, int);


More information about the dev-commits-src-main mailing list