From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796066743; b=JQOBQdr0oS1p2A3I5dxLFqDbU79Wx6gmj4DN3ewH3GVgU2kREoOaWeVZ09lWDe95k4jy HMSuSEsxVQYrTYxGX1uA21AIcPMTXoQ5jB0PvdbElxE6fa4aGLsqrIfJsTbWs8F1c4gqc qXZGbdADjlh+GIPQpwFSOmQAtHlzQQX6vbW/PVcNGi1pyr9gmlrS1//58aI9+352V6gQp 5LO0Cg7VNASnKPUAj+eQl1SEzKO3zIe13uVD7csuBR+cwgOGnPzpINPs3nLnSlAL9+RYM J7j46H26E0OFSFfACHO/R2D1chp230U0bYeeaNl7V0YNK5DiqxAlDqng6L3gt7zQmvw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796066743; 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=CYBvfwJW5RTdy+KPHqBpl3R+oklBfTP1ysqOJjvOiYU=; b=di/ttyISj6izxuu+ZPquISoTP70+AzpiBAU7V2kLbeC5Y/rlHHUEycU8NcA3CJV6gXHJ yuzOlUIfo32VYUO0pFjyMgujN45ViHYL0MeToVwSHjB1bviNIaFPh6mV+7GJBsK1NPTyq H6vXj7Cl8kPPB8eFQ4u9xNAe+eHTvcC2OupiP43qL1QTS0HWuzJhw6+8PY0gm75wXnLw+ CSyhq0f0kZ10ngjH2lZAqtvmSAc0wNT0WkI/Hxz5C83qAaX5inHjmHcpz/btaEe3ERJxE 7s6YOS5VLa3/TWOBztSm+z6gPo7dM8g8R1gn12O7gFY4Phwr0/dSmwYbEJFweg9g4sQ== 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=bbuvc06T; arc=none smtp.remote-ip=209.85.221.46 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 B4926606A32E for ; Mon, 30 Nov 2026 19:25:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B4926606A32E 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=bbuvc06T Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-48e09aa5264so6411296f8f.2 for ; Mon, 30 Nov 2026 11:25:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20260707; t=1796066741; x=1796671541; 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=CYBvfwJW5RTdy+KPHqBpl3R+oklBfTP1ysqOJjvOiYU=; b=bbuvc06TVED5Z+v5AWo3nJi5o8rrY1i4e8uJrqBMdfAFyGqlOZp2knMq7g0F1wNCaQ mvPZ4OrlbjtsUWYPX+SVryvfDCwEso50naDbvXx+QoTubUJjG0KyjYgx7P9rUqi5RK7C BCRhc9HIomoYjdYvh++W+hUso2zfgv33qPA/Ky7TOW9LQ1AuNNL4JUWu7BfAu50JJqNu DrHXxlLgTIld/yjvl8/s8nDpQv5jpSCiR5uNCxa8D6G0vEh7y9/fxrlbbE07Cshef3Pm 2kl17pN9rrf/z6fBjzD/Hz+ZnvP7cRXAQ2f/qFf0BfhhWIKB6uCraiGX+kFlqwYmtDLJ l9Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796066741; x=1796671541; 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=CYBvfwJW5RTdy+KPHqBpl3R+oklBfTP1ysqOJjvOiYU=; b=Cp2avjua3RfsgNwlBZrGbDlpOvxUE3fcby5m//ciVcF5VixUywhNulL5eqQcTzQmEc 1oo2Yl3uA9aTPYhMfhCK+3b4kZ2CWnYAOXqvZT9cZ322ryudaLq2r6L+ohAl1XseF4fJ i8qDVM8XnDbg2w7uYBERH66uM9a6wCSXIPqlCTI+uocTGblYE5jNV9DaFdL8V4OLHTbD zzc56LlVJanRWg8xgYxVcmngdgUE4tA4elQJUAjuyzGeUcVV3I7RwXSY2Rsrr0Lmfgxt FdPCHf+z5z8owr7ATnt/h+MvMx8BDDnlQjioZZOVR4VAY0XqZR4eCIFKsp6RBe482slO az/Q== X-Gm-Message-State: APuU4Z9MCp6+p2oVoFSGaGHG9cmrmQ7tkBasuVHyQeC3d8ho5ZeTuWi1 Um8K6O92cFzleaVgJH9nchOhj6Q8fSI9rpKzOQThrImrmL6iiqyv4xPmO+lXYXvkDLc= X-Gm-Gg: AZFdTZe79bM4VAej89LQ5GsBiou+FvQpkiwAjrv0JJBG7aJM2La2u2shyrwbCc8fRKz VgKW/T6sPiKmUvenc+8yKG5Quq9kzAYQRlTaCbhudUUBWCJV6+ClgsLLSGAXtLwlOaaaezIbQ18 9tVoCwoi1tgEcVV6D/+oQIMsRfpzq4EotOObe/2js4+TxuARNuuKEeRV84Vkx1PyzD4WB3vRqEO YWU0DlbRKqo88tMBc3mAWrqPkc70eQzoIJtllz07GOMkg9+f7VttiQjzYh7D+CPfZPkYrUjKLdL 8uKS+c0+E8BmbA9BCt5Dj3E2rOnUJpYKTTmrxfoYUNYX3Eh9DhUcCJCc1ug29DEPHp5O9oRjF6V Br80qfAeDtH+wGy0ztnp6cAWHy80bZZxEmQJnGVh29pgV02t/qgFSIl00iNw6Kg+kmg288uKl44 RB2m5oBvUB9j+RMedvoBaFcUsppnbjANdY6MTkkZYao63WN4zqhGD2WiVTnNRCj5R4mmJboNQjH jfG5UgCJiCCr7JQYT/56IX8POJC5Nl30p/VXU6NBfRWgifL4DHa5Bxa5b041fe6/CJrDQJ84WMO 87tOEFOE3fmHLPMwJfcv2pP7/d0uxn1I8yPOkxELkbRPIkhW+gZ5dX5jfA== X-Received: by 2002:a05:6000:4a03:b0:4ae:f6b2:9fa4 with SMTP id ffacd0b85a97d-4aef6b2a3b1mr56062438f8f.47.1796066741157; Mon, 30 Nov 2026 11:25:41 -0800 (PST) Received: from sp8 (213-146-237-228.ptr.skytron.de. [213.146.237.228]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab65cb4341sm65688773f8f.4.2026.11.30.11.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 11:25:40 -0800 (PST) From: Sebastian To: linux-bluetooth@vger.kernel.org Cc: Sebastian , "Claude Opus 5.5" Subject: [PATCH 1/2] shared/hog: Read the PnP ID before creating the uHID device Date: Mon, 30 Nov 2026 20:25:20 +0100 Message-ID: <20261130192521.246374-2-seb.witt@googlemail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130192521.246374-1-seb.witt@googlemail.com> References: <20261130192521.246374-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 Since commit 96f1201f5ac2 ("input/hog: Use shared/hog") the vendor, product and version of the uHID device are the ones of the btd_device when the connection is accepted. On the first connection after pairing they are not known yet, as the deviceinfo plugin reads the PnP ID concurrently, so the uHID device is created with 0000:0000 and the kernel drivers and quirks matching the device don't apply until it reconnects: hid-multitouch 0005:0000:0000.001C: input,hidraw1: BLUETOOTH HID v0.00 hog-lib used to read the PnP ID itself before creating the uHID device, so read it again, if the Device Information Service has one, along with the other characteristics the uHID device is created after. Fixes: 96f1201f5ac2 ("input/hog: Use shared/hog") Co-Authored-By: Claude Opus 5.5 --- src/shared/hog.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/shared/hog.c b/src/shared/hog.c index e62423fa4..ed89b3960 100644 --- a/src/shared/hog.c +++ b/src/shared/hog.c @@ -61,6 +61,10 @@ #define HID_INFO_SIZE 4 +#define DIS_UUID16 0x180A +#define DIS_PNP_ID_UUID 0x2A50 +#define PNP_ID_SIZE 7 + struct bt_hog { int ref_count; char *name; @@ -78,6 +82,7 @@ struct bt_hog { uint16_t bcdhid; uint8_t bcountrycode; uint16_t info_handle; + uint16_t pnp_id_handle; uint16_t proto_mode_handle; uint16_t cp_handle; uint8_t flags; @@ -1335,6 +1340,74 @@ void bt_hog_set_ids(struct bt_hog *hog, uint16_t vendor, uint16_t product, bt_hog_set_ids(entry->data, vendor, product, version); } +static void pnp_id_read_cb(bool success, uint8_t att_ecode, + const uint8_t *value, uint16_t length, + void *user_data) +{ + struct bt_hog *hog = user_data; + struct iovec iov = { (void *)value, length }; + uint8_t source; + + if (!success) { + DBG(hog, "PnP ID read failed: 0x%02x", att_ecode); + return; + } + + if (length < PNP_ID_SIZE) { + DBG(hog, "Malformed PnP ID: length %u", length); + return; + } + + cache_value(hog, hog->pnp_id_handle, value, length); + + if (!util_iov_pull_u8(&iov, &source) || + !util_iov_pull_le16(&iov, &hog->vendor) || + !util_iov_pull_le16(&iov, &hog->product) || + !util_iov_pull_le16(&iov, &hog->version)) + return; + + DBG(hog, "source: 0x%02X vendor: 0x%04X product: 0x%04X " + "version: 0x%04X", source, hog->vendor, hog->product, + hog->version); +} + +static void foreach_dis_chrc(struct gatt_db_attribute *attr, void *user_data) +{ + struct bt_hog *hog = user_data; + bt_uuid_t uuid, pnp_id_uuid; + uint16_t value_handle; + + gatt_db_attribute_get_char_data(attr, NULL, &value_handle, NULL, + NULL, &uuid); + + bt_uuid16_create(&pnp_id_uuid, DIS_PNP_ID_UUID); + if (!bt_uuid_cmp(&pnp_id_uuid, &uuid)) + hog->pnp_id_handle = value_handle; +} + +static void foreach_dis_service(struct gatt_db_attribute *attr, + void *user_data) +{ + gatt_db_service_foreach_char(attr, foreach_dis_chrc, user_data); +} + +/* Read the PnP ID of the Device Information Service, if any, so the uHID + * device is created with the vendor, product and version of the device + * even on the first connection, when they are not known yet. + */ +static void read_pnp_id(struct bt_hog *hog) +{ + bt_uuid_t uuid; + + hog->pnp_id_handle = 0; + + bt_uuid16_create(&uuid, DIS_UUID16); + gatt_db_foreach_service(hog->db, &uuid, foreach_dis_service, hog); + + if (hog->pnp_id_handle) + read_char(hog, hog->pnp_id_handle, true, pnp_id_read_cb, hog); +} + static void discovery_idle(void *user_data) { struct bt_hog *hog = user_data; @@ -1376,6 +1449,9 @@ bool bt_hog_attach(struct bt_hog *hog, struct bt_gatt_client *client) DBG(hog, "HoG discovering characteristics"); gatt_db_service_foreach_char(hog->attr, foreach_hog_chrc, hog); + if (!created) + read_pnp_id(hog); + /* Create the uHID device once every request is complete, including * the ones made once others complete, e.g. the CCC once the Report * Reference is read, even if some failed, e.g. reading an optional -- 2.56.1