From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796071592; b=r3Hf9xSf7h4i/zxAJ8Gsx/3cFfGVbVnslC3FOKzn210uH88Kv+9iHkvYOQewSTmA5gDw atObOSX6MYf4QCC9jbD8uHdLJKlY1Jx2LYkxuaxV4/DFGjxtsONC3/q5XJSSiQS+iyxfk B4stkinJ/xkKFahBvWeRE5FCSxWN9YQRprZRY31ZRYGLxs0hLVty2TZvnj4nKbl5n5obB MF35LG3dgEpBvcpsVShu7TPiZd4ddlw39FpKAnwRDjz4hp4653HyprSGuA10hclQ/ClIg KLeJ9RIeOjhZoHCoSo7R8GwCuCaQWFfp0FsQtBr4mSRYna0x32b3aRZJ4Qr8R86McOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796071592; 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=N0hS0c6RgQvanHBvCp2BU8ER+WsClfvc2c5nsQoCXL0=; b=W1S8J8CxiWUoY5jIEG0TvwcdVxKcIQz3PiS0oh+Yo5uVfhAgV6W4gVLWMFCZJMSpOXGv iUogEu5925S618NTTiOP7BmeRJCwKJGRihbmHapp5fxWKbS+m2iQTXMhHf6SUsbCNZVkE +94r5WC87jG3q1NYOy+v3D9fjnxp55AthtE5omNcQK1+lJxpgiUHYgSLiszxYFnW5fJpS iod/dfEJGWwnC8OhPJ684alaGlfIWfzAs3GIxF0gTcQ9rR9mp6Wan2gtnb2jvYx/y4oWj /XI7rklNqoiAiSYUQTHhtC94Nhp2N7ySCMheTQu9wEgZd4WwptmL1lstQiX1+1JrW8g== 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=T1crol9r; arc=none smtp.remote-ip=209.85.221.52 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 A5289606A31A for ; Mon, 30 Nov 2026 20:46:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A5289606A31A 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=T1crol9r Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-4a3e706b5dfso6991472f8f.2 for ; Mon, 30 Nov 2026 12:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20260707; t=1796071590; x=1796676390; 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=N0hS0c6RgQvanHBvCp2BU8ER+WsClfvc2c5nsQoCXL0=; b=T1crol9rz+3xjfOr4u+GdVJIJh1REd984/U+UEHLfyie2GZg02neSGuz8YCeF2vW0q 3m5yS/NPtSACzD1ZY+oS6YA2twg+PAPAu4iOQTTvWQopGPGm8K3W8p0yRUWQp9n8/Muw BvS8IfBGzOA3QKqkV4TRcQPTwJqVZzV3ZI2MwZ/Mwzt/Y+9W59Wot15Bxyhb/uOaL5J9 ZcBoSHVuVOqg/D8VR6IIyVBNtjOtZ/z3Cuzp9gxcB9MS6FTs2YzucY+Q4DCIuLQe/ynO 9dHTBcCcq41IYJHSeDiYuEalpFUhhSUtO6BIpv9ubRdWV13xevunw+zvOWJaX6WZM8D6 t5Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796071590; x=1796676390; 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=N0hS0c6RgQvanHBvCp2BU8ER+WsClfvc2c5nsQoCXL0=; b=lDKdUq0qkAYK2aITUMdD4OYqsloFqSMOLXVuoIy9b5r89hNQ/mYUVO92ttwWCLJqKL zTm95OGTOubZkjyj+Wni8sGstXjVJ2EhmYuAkgaaMxIhLkUou/YgzQ3mBmOqQceytGBm YBlorn8OHPNFgMmfFZYrFgGp7qZKAZzVLlXVLi+053GXHCZkCqsia3xGFZvtTkMHFNeE luHSWPbfuuANhiUggW3vbJXbGB87Zs9X69o+6gQcBiKSFswHVA5PuE7egjYncO2itivx j80EaLOBiz82Uo/5ldTjRQcjOUyvF9hMG1m4OY1Xiev+MvrVFq0lXCKXw1EbhE+jeoWF KUqA== X-Gm-Message-State: APuU4Z/sM1bWkRz18w4a4KbhhcLl4X/2JtPlBcLsi+2Toqg46LMBQkn2 x8/8hQXe/3eZEnch6HxA+EqItxpOpLD80IBDjJUis6IhtPilsu7SL74plOG+8wbk3Iw= X-Gm-Gg: AZFdTZdUyMydSMvKfTr3ggrHkU1ikejpEnasmiiq/BdaHJRBo2BwGi77Qskiar1OVIz crY1AJHxdm5l8mEbJ2KnVEp8h5NtXM2iAY/1fHbkVx+y3yer3xFdWfv5JudzF8EuxfeJ7GEZo2H byXRgywGmNlvL77vZGx2eNWbvnK+MY3PwQMJ641ewbZf14cYLZ24Cbb19OCjsRf4FB3srWe2X/z e49WuGpWUV5BJy/TK4boswPeHb15aEQQe7V1PNihop385luBfxQAVVOA7CXuvRH+YwshxCM0FSg +bkUlUiaM9VSh7D6KFu6qOKTVPRQFA9G6j2CPVTLzN88/m8z+X60VU4a4QW0L2eYlqMZZMScRWl JgDiJztFCtZ7MyHv4A8zCxXwOFVtBY0oWEFf0XzzX8X8Qn2qISQ9t4AhJAMXTGqOv23spWQmqMe Fb6HzyuDv5XQHNWaCJnhMSBcuIVYOPmzhATKT/9GCtIbeOmw6Ge6BG6mn7lsk7Tb34dZZSl6a1B NdjNVJBTBnLTdP73/5JPAqKQA2sOGXCOpBp1PiaIejP1xtjeWgLn3yV/WGKfMV1YqYWR+VHkqeu 6OcHwX9wwVz9HlpMRj2OiCt/jwnEaj0t0+vdb6Exk1+VYO1m8kvEi89dcQ== X-Received: by 2002:a05:6000:4b0f:b0:48e:d7c:4bc8 with SMTP id ffacd0b85a97d-4abad6a1782mr63333098f8f.7.1796071589917; Mon, 30 Nov 2026 12:46:29 -0800 (PST) Received: from sp8 (213-146-237-228.ptr.skytron.de. [213.146.237.228]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a680483sm67435844f8f.28.2026.11.30.12.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 12:46:29 -0800 (PST) From: Sebastian To: linux-bluetooth@vger.kernel.org Cc: Sebastian , "Claude Opus 5.5" Subject: [PATCH v2 3/4] shared/hog: Add bt_hog_set_long_report_map Date: Mon, 30 Nov 2026 21:45:55 +0100 Message-ID: <20261130204556.357834-4-seb.witt@googlemail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130204556.357834-1-seb.witt@googlemail.com> References: <20261130204556.357834-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. Co-Authored-By: Claude Opus 5.5 --- 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