From owner-dev-commits-src-main@freebsd.org Thu Sep 2 19:36:01 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8DDDF665611; Thu, 2 Sep 2021 19:36:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H0rkn2XqQz4kPG; Thu, 2 Sep 2021 19:36:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 076E11E74A; Thu, 2 Sep 2021 19:36:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 182Ja0ir064291; Thu, 2 Sep 2021 19:36:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 182Ja0a8064290; Thu, 2 Sep 2021 19:36:00 GMT (envelope-from git) Date: Thu, 2 Sep 2021 19:36:00 GMT Message-Id: <202109021936.182Ja0a8064290@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: d51e437669e4 - main - hidbus(4): Add routine to check presence of collection of given usage MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d51e437669e4ac35ac4be366241ae6ba4a16c378 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Sep 2021 19:36:01 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=d51e437669e4ac35ac4be366241ae6ba4a16c378 commit d51e437669e4ac35ac4be366241ae6ba4a16c378 Author: Vladimir Kondratyev AuthorDate: 2021-09-02 19:32:57 +0000 Commit: Vladimir Kondratyev 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);