From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796312066; b=08ArhPwC/zVcP8Q57yXbYpdzAtYSs9bRW2AkZ+R7TYxCggas2l9OS8w9Ot/jAvi3aJvU c8qDJJu3c/WdZOrWBJefxDsiVgOi8HKh1T/bnMA0izK6FpQCoLmu7V6EyIXGdIeZZ9e0J /x4U72T2Vos97h8iZoOKC4vfFgKW1XpO/XzefC99YmiPBVGBgwosULGd5K9AMO8QQ4upk u7FnG0c8GSkqMvaO9pKjsqHugsCJgWHDEtaOBTsWnNVBhg9M4a2nBbGXfxKcbDVK61Ne/ X9yoK/wjArRa5aMj1PayZRjqshZkHA080ehQk8X4akCOP0T9W6OPEtC98RCB9kyzIeA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796312066; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=a7JSYYZP1XFnUZ/2i0607qR737kv4woR4tU7nwcHkPg=; b=Jx8RZN4ohgRwy47XRvZFB7qjnsPxnoAYI1dndeQoLVh9GFQlC7aqgzEtMpQ8m2O8tv5o OQnrLHbGHiL5/MEWphdlHmi/DIPCcVuGKSQuvs4VMMpUjdqnqH4qiCfGjIznGGww9hcQY oO43g+8pwXeT44O1vpKJRACr4Di478tK8bRelwXMpdWWr/y8urOWIouUFl9jzQ9dKHkx8 jJmwitT9089ey2q/OGa9eN5rywrX1GR8PIfFw5Q/NGf2HjknS1x8dKWRHV1AOJKjO0VYQ CP5OvjbpXXnWTimStTF4yubFz5jv1CZbJnIknvpvrQacJwnKHW2NNTNUIM6b6jsa9aQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=googlemail.com; spf=pass smtp.mailfrom=googlemail.com; dkim=pass header.d=googlemail.com header.i=@googlemail.com header.a=rsa-sha256 header.s=20260707 header.b=XIfqmjzJ; arc=none smtp.remote-ip=209.85.128.42 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9774E606A680 for ; Thu, 3 Dec 2026 15:34:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9774E606A680 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.a=rsa-sha256 header.s=20260707 header.b=XIfqmjzJ Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4bb5b8ef642so120047135e9.1 for ; Thu, 03 Dec 2026 07:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20260707; t=1796312064; x=1796916864; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=a7JSYYZP1XFnUZ/2i0607qR737kv4woR4tU7nwcHkPg=; b=XIfqmjzJ/h+0DKRu2+YGR4TR/neyw3kgKGPzuSSy9ZP/67sUyYa8fvuIJhrNGeGpXP FOuec9bdRzKOP2Cyx86CGtxzVNTrFSGYXQ4t3hW7SKJ79iQtzkqic4yholYj1JvG6ie3 FAqY5ViM577/7C39bqmsBFYJEAWJG2Jr7knzBewQqAYSFaTGUVXeelnVgb86F7ycMyro xpmax4FBME6Pg760sW0lL8gG9T019BZh9i5gvdwx4IpDh+jxferR4R0KBTHuxPFp7pqg eAKTya8uHp52VDy2x3lprEBB6Teokn5SszbwoTcJ1AE/BII9YM3dmsBHnhq3HV9zW8Z6 xB3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796312064; x=1796916864; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=a7JSYYZP1XFnUZ/2i0607qR737kv4woR4tU7nwcHkPg=; b=R+7q0Bm5QPBASZq92EcLYDvQnaPzIW6jJjFLHgkBA3tFIfqDcD1/z2Pe8cNeuJ/Kru deXtgyjQ1Yj7WkYS+/Q13tggPL2NT6uq0Z8qmdrXQeiJ3xvMChdP9oNYHuYRou7ovVQy VG8IkNNPawpkU+p4MGsBaBvx8XjOtMX3ZWTozhW6qQ8fSJpbNFVvhq3xADSvzahosFFb vjQDy+2WhzorgKENXTTlwto34nkxSjJKJxoYTBSfMdYdhkvlrzV2xdA6l1pX9F8PZyix oPgKq5bg8QXUEx2t+kFjuywdVC0KOl/JXO8uSbWljmM+EYeuT3rWniX6C7vDDFyg7FOx f5Gg== X-Gm-Message-State: APuU4Z9q4JMNqxs38ig0O6ELJ3Bh0bZOn1FBNhJe5piG2hk/ZA1Xdh4L D04IEiZK/c8I9W7uOeJVuqlVxgxRQTrilUIJ2tDdXoWCQzwyhFE6Gb0OsdUS/v7y X-Gm-Gg: AZFdTZcfq2/9eZf+Ne8FQ6htLeUM3NClW3Shk539G2L4Uk7RVfDF1jd8szxs2SSC4HO R3Uc9z/pM2EgKho/tZfRxfFGVvh8lSBc1IgFEZBAotb7b9KKBQQwcZOyGxxNgJni9PxpQV5rArn 4T9NezdKt2lJQ2YziSeM7gR0onos0MncnrGOML9nY8fSoAV3Kq5bVahKxgmN6Jjbf02YmbeDjhi SGw9aC5W9SH8G8bYSdKW7DtAWRUnVbGsm0Uor7DTyKVASWe7iAK3Co3QaSuHTSzVDBKm5coQnaO Tov+phojMWdBTZRB1KAqSYclOe5qQNQasO5KuCjj3b41rgUYB9BQgl3fQHi9zA1F7tgqZ0Abqg0 BrwCI4s4JwNKfebCn/9kFu11EQvz+0IrwP5u3eC0VnH+1FKOwZfKtK5q3sEOYdXVwUxABNH3Wee FFWIoly9LSeatSeAUn7nskMhfLp4QWxeaTHNKd6SQ1DKJJGfMHF6lRQ4KyJZJ12B+yvV6D91rbS QkvXzUnFgLLhHHxdFhjEFQVnSX0qsRPoaoeOD5ZhNpkoQBzkxmEYOcOgZ4sFTolcg2f0tGUq4kx Au2WhDsCk4kbuNUd9VnbeuSMJiZ7QUS4/cUTNArZaVhOhMeX/3g+FLWo4g== X-Received: by 2002:a05:600c:8b76:b0:4bb:b796:66f8 with SMTP id 5b1f17b1804b1-4bbb7966874mr361582245e9.21.1796312063875; Thu, 03 Dec 2026 07:34:23 -0800 (PST) Received: from sp8 (213-146-237-228.ptr.skytron.de. [213.146.237.228]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab65cb42absm83352896f8f.1.2026.12.03.07.34.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 07:34:23 -0800 (PST) From: Sebastian To: linux-bluetooth@vger.kernel.org Cc: Sebastian Subject: [PATCH v3 3/6] shared/hog: Add bt_hog_set_long_report_map Date: Thu, 3 Dec 2026 16:34:05 +0100 Message-ID: <20261203153408.31769-4-seb.witt@googlemail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261203153408.31769-1-seb.witt@googlemail.com> References: <20261203153408.31769-1-seb.witt@googlemail.com> X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add bt_hog_set_long_report_map to accept a Report Map longer than 512 octets, up to the 4096 octets of HID descriptor UHID_CREATE2 accepts, by reading it with bt_gatt_client_read_long_value_max_len. It is disabled by default, so the Report Map is read as before. --- src/shared/hog.c | 43 +++++++++++++++++++++++++++++++++++++++---- src/shared/hog.h | 5 +++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/shared/hog.c b/src/shared/hog.c index e62423fa4..1ef886e42 100644 --- a/src/shared/hog.c +++ b/src/shared/hog.c @@ -56,6 +56,13 @@ #define HOG_PROTO_MODE_BOOT 0 #define HOG_PROTO_MODE_REPORT 1 +/* Some peripherals expose a Report Map longer than the 512 octets an + * attribute value may have (Core v5.4, Vol 3, Part F, Section 3.2.9). + * When enabled, accept up to the size of HID descriptor UHID_CREATE2 can + * take. + */ +#define HOG_REPORT_MAP_LONG_MAX_LEN 4096 + #define HOG_INFO_FLAG_SCI_SUPPORTED 0x04 #define HOG_INFO_FLAG_SCI_LOW_POWER 0x08 @@ -88,6 +95,7 @@ struct bt_hog { uint16_t report_map_handle; uint8_t *report_map; uint16_t report_map_len; + uint16_t report_map_max_len; uint16_t sci_mode_handle; uint8_t sci_mode_props; unsigned int sci_mode_id; @@ -151,7 +159,8 @@ static void db_value_cb(struct gatt_db_attribute *attr, int err, * The requests are cancelled by cancelling all the requests of the client, * which is a clone owned by hog, once detached. */ -static void read_char(struct bt_hog *hog, uint16_t handle, bool cache, +static void read_char_max_len(struct bt_hog *hog, uint16_t handle, + bool cache, uint16_t max_len, bt_gatt_client_read_callback_t func, void *data) { if (cache) { @@ -169,11 +178,18 @@ static void read_char(struct bt_hog *hog, uint16_t handle, bool cache, } } - if (!bt_gatt_client_read_value(hog->client, handle, func, data, - NULL)) + if (!bt_gatt_client_read_long_value_max_len(hog->client, handle, 0, + max_len, func, data, NULL)) DBG(hog, "Could not read handle 0x%04x", handle); } +static void read_char(struct bt_hog *hog, uint16_t handle, bool cache, + bt_gatt_client_read_callback_t func, void *data) +{ + read_char_max_len(hog, handle, cache, BT_ATT_MAX_VALUE_LEN, func, + data); +} + /* Cache a static value in the gatt_db, see read_char */ static void cache_value(struct bt_hog *hog, uint16_t handle, const uint8_t *value, uint16_t length) @@ -1103,7 +1119,9 @@ static void foreach_hog_chrc(struct gatt_db_attribute *attr, void *user_data) * handled by reading it with Read Blob, unless cached. */ hog->report_map_handle = value_handle; - read_char(hog, value_handle, true, report_map_read_cb, hog); + read_char_max_len(hog, value_handle, true, + hog->report_map_max_len, + report_map_read_cb, hog); gatt_db_service_foreach_desc(attr, foreach_hog_external, hog); return; @@ -1194,6 +1212,7 @@ static struct bt_hog *hog_new(int fd, const char *name, uint16_t vendor, hog->version = version; hog->type = type; hog->attr = attr; + hog->report_map_max_len = BT_ATT_MAX_VALUE_LEN; return hog; } @@ -1220,6 +1239,7 @@ static void foreach_hog_service(struct gatt_db_attribute *attr, void *user_data) instance->debug_data = hog->debug_data; instance->sci_mode_func = hog->sci_mode_func; instance->sci_mode_data = hog->sci_mode_data; + instance->report_map_max_len = hog->report_map_max_len; queue_push_tail(hog->instances, bt_hog_ref(instance)); } @@ -1335,6 +1355,21 @@ void bt_hog_set_ids(struct bt_hog *hog, uint16_t vendor, uint16_t product, bt_hog_set_ids(entry->data, vendor, product, version); } +void bt_hog_set_long_report_map(struct bt_hog *hog, bool enable) +{ + const struct queue_entry *entry; + + if (!hog) + return; + + hog->report_map_max_len = enable ? HOG_REPORT_MAP_LONG_MAX_LEN : + BT_ATT_MAX_VALUE_LEN; + + for (entry = queue_get_entries(hog->instances); entry; + entry = entry->next) + bt_hog_set_long_report_map(entry->data, enable); +} + static void discovery_idle(void *user_data) { struct bt_hog *hog = user_data; diff --git a/src/shared/hog.h b/src/shared/hog.h index 910a2261b..a4aa8a5d6 100644 --- a/src/shared/hog.h +++ b/src/shared/hog.h @@ -46,6 +46,11 @@ bool bt_hog_set_debug(struct bt_hog *hog, bt_hog_debug_func_t func, void bt_hog_set_ids(struct bt_hog *hog, uint16_t vendor, uint16_t product, uint16_t version); +/* Accept a Report Map longer than the 512 octets an attribute value may + * have, as exposed by some non-compliant devices. Disabled by default. + */ +void bt_hog_set_long_report_map(struct bt_hog *hog, bool enable); + bool bt_hog_attach(struct bt_hog *hog, struct bt_gatt_client *client); void bt_hog_detach(struct bt_hog *hog, bool force); -- 2.56.1