linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v3 1/3] hog-lib: Don't destroy UHID device on detach
@ 2024-02-12 17:39 Luiz Augusto von Dentz
  2024-02-12 17:39 ` [PATCH BlueZ v3 2/3] input.conf: Make UserspaceHID defaults to true Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2024-02-12 17:39 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes bt_hog_detach not to destroy UHID device which means the
device node don't need to be recreated in case of reconnections which
speeds up the process.

Fixes: https://github.com/bluez/bluez/issues/737
---
 profiles/input/hog-lib.c | 48 ++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index 7ff1ede3db35..67492a63eca3 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
@@ -1309,11 +1309,35 @@ static bool cancel_gatt_req(const void *data, const void *user_data)
 	return g_attrib_cancel(hog->attrib, req->id);
 }
 
+static void uhid_destroy(struct bt_hog *hog)
+{
+	int err;
+	struct uhid_event ev;
+
+	if (!hog->uhid_created)
+		return;
+
+	bt_uhid_unregister_all(hog->uhid);
+
+	memset(&ev, 0, sizeof(ev));
+	ev.type = UHID_DESTROY;
+
+	err = bt_uhid_send(hog->uhid, &ev);
+
+	if (err < 0) {
+		error("bt_uhid_send: %s", strerror(-err));
+		return;
+	}
+
+	hog->uhid_created = false;
+}
+
 static void hog_free(void *data)
 {
 	struct bt_hog *hog = data;
 
 	bt_hog_detach(hog);
+	uhid_destroy(hog);
 
 	queue_destroy(hog->input, free);
 	queue_destroy(hog->bas, (void *) bt_bas_unref);
@@ -1823,29 +1847,6 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)
 	return true;
 }
 
-static void uhid_destroy(struct bt_hog *hog)
-{
-	int err;
-	struct uhid_event ev;
-
-	if (!hog->uhid_created)
-		return;
-
-	bt_uhid_unregister_all(hog->uhid);
-
-	memset(&ev, 0, sizeof(ev));
-	ev.type = UHID_DESTROY;
-
-	err = bt_uhid_send(hog->uhid, &ev);
-
-	if (err < 0) {
-		error("bt_uhid_send: %s", strerror(-err));
-		return;
-	}
-
-	hog->uhid_created = false;
-}
-
 void bt_hog_detach(struct bt_hog *hog)
 {
 	GSList *l;
@@ -1879,7 +1880,6 @@ void bt_hog_detach(struct bt_hog *hog)
 	queue_remove_all(hog->gatt_op, cancel_gatt_req, hog, destroy_gatt_req);
 	g_attrib_unref(hog->attrib);
 	hog->attrib = NULL;
-	uhid_destroy(hog);
 }
 
 int bt_hog_set_control_point(struct bt_hog *hog, bool suspend)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH BlueZ v3 2/3] input.conf: Make UserspaceHID defaults to true
  2024-02-12 17:39 [PATCH BlueZ v3 1/3] hog-lib: Don't destroy UHID device on detach Luiz Augusto von Dentz
@ 2024-02-12 17:39 ` Luiz Augusto von Dentz
  2024-02-12 17:39 ` [PATCH BlueZ v3 3/3] input/device: Don't destroy UHID device on disconnect Luiz Augusto von Dentz
  2024-02-12 19:34 ` [BlueZ,v3,1/3] hog-lib: Don't destroy UHID device on detach bluez.test.bot
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2024-02-12 17:39 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes UserspaceHID defaults to true so the plugin has more control
over the input device lifetime.
---
 profiles/input/device.c   | 2 +-
 profiles/input/input.conf | 2 +-
 profiles/input/manager.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/profiles/input/device.c b/profiles/input/device.c
index 6c64ff1c1c52..ff7e3482d0eb 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -81,7 +81,7 @@ struct input_device {
 };
 
 static int idle_timeout = 0;
-static bool uhid_enabled = false;
+static bool uhid_enabled = true;
 static bool classic_bonded_only = true;
 
 void input_set_idle_timeout(int timeout)
diff --git a/profiles/input/input.conf b/profiles/input/input.conf
index d8645f3dd664..00a34eb63de1 100644
--- a/profiles/input/input.conf
+++ b/profiles/input/input.conf
@@ -9,7 +9,7 @@
 #IdleTimeout=30
 
 # Enable HID protocol handling in userspace input profile
-# Defaults to false (HIDP handled in HIDP kernel module)
+# Defaults to true (Use UHID instead of kernel HIDP)
 #UserspaceHID=true
 
 # Limit HID connections to bonded devices
diff --git a/profiles/input/manager.c b/profiles/input/manager.c
index 92789a003c89..69ed646727d5 100644
--- a/profiles/input/manager.c
+++ b/profiles/input/manager.c
@@ -83,7 +83,7 @@ static int input_init(void)
 	config = load_config_file(CONFIGDIR "/input.conf");
 	if (config) {
 		int idle_timeout;
-		gboolean uhid_enabled, classic_bonded_only, auto_sec;
+		gboolean uhid_enabled = TRUE, classic_bonded_only, auto_sec;
 
 		idle_timeout = g_key_file_get_integer(config, "General",
 							"IdleTimeout", &err);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH BlueZ v3 3/3] input/device: Don't destroy UHID device on disconnect
  2024-02-12 17:39 [PATCH BlueZ v3 1/3] hog-lib: Don't destroy UHID device on detach Luiz Augusto von Dentz
  2024-02-12 17:39 ` [PATCH BlueZ v3 2/3] input.conf: Make UserspaceHID defaults to true Luiz Augusto von Dentz
@ 2024-02-12 17:39 ` Luiz Augusto von Dentz
  2024-02-12 19:34 ` [BlueZ,v3,1/3] hog-lib: Don't destroy UHID device on detach bluez.test.bot
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2024-02-12 17:39 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes classic HID behave like HoG which keeps the UHID device
around while disconnected so it doesn't have to be recreated on every
reconnection.
---
 profiles/input/device.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/profiles/input/device.c b/profiles/input/device.c
index ff7e3482d0eb..08bdb30f1f3e 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -985,6 +985,10 @@ static int uhid_disconnect(struct input_device *idev)
 	if (!idev->uhid_created)
 		return 0;
 
+	/* Only destroy the node if virtual cable unplug flag has been set */
+	if (idev->virtual_cable_unplug)
+		return 0;
+
 	bt_uhid_unregister_all(idev->uhid);
 
 	memset(&ev, 0, sizeof(ev));
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [BlueZ,v3,1/3] hog-lib: Don't destroy UHID device on detach
  2024-02-12 17:39 [PATCH BlueZ v3 1/3] hog-lib: Don't destroy UHID device on detach Luiz Augusto von Dentz
  2024-02-12 17:39 ` [PATCH BlueZ v3 2/3] input.conf: Make UserspaceHID defaults to true Luiz Augusto von Dentz
  2024-02-12 17:39 ` [PATCH BlueZ v3 3/3] input/device: Don't destroy UHID device on disconnect Luiz Augusto von Dentz
@ 2024-02-12 19:34 ` bluez.test.bot
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2024-02-12 19:34 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=825316

---Test result---

Test Summary:
CheckPatch                    PASS      1.25 seconds
GitLint                       PASS      0.89 seconds
BuildEll                      PASS      24.49 seconds
BluezMake                     PASS      735.31 seconds
MakeCheck                     PASS      11.79 seconds
MakeDistcheck                 PASS      162.84 seconds
CheckValgrind                 PASS      226.50 seconds
CheckSmatch                   PASS      328.83 seconds
bluezmakeextell               PASS      107.23 seconds
IncrementalBuild              PASS      2067.00 seconds
ScanBuild                     PASS      921.72 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-12 19:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-12 17:39 [PATCH BlueZ v3 1/3] hog-lib: Don't destroy UHID device on detach Luiz Augusto von Dentz
2024-02-12 17:39 ` [PATCH BlueZ v3 2/3] input.conf: Make UserspaceHID defaults to true Luiz Augusto von Dentz
2024-02-12 17:39 ` [PATCH BlueZ v3 3/3] input/device: Don't destroy UHID device on disconnect Luiz Augusto von Dentz
2024-02-12 19:34 ` [BlueZ,v3,1/3] hog-lib: Don't destroy UHID device on detach bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).