All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC, BlueZ] bap: check adapter support before enabling BAP
@ 2023-01-27 20:52 Pauli Virtanen
  2023-01-27 21:12 ` [RFC,BlueZ] " bluez.test.bot
                   ` (4 more replies)
  0 siblings, 5 replies; 43+ messages in thread
From: Pauli Virtanen @ 2023-01-27 20:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Hi,

When the BT adapter does not have the "Connected Isochronous Stream - Central"
feature, establishing ISO connections fails at a late stage.  Namely, we get
EOPNOTSUPP in connect() due to cis_central_capable(hdev) being false.  However,
at that point BlueZ and the rest of the userspace like sound servers have
already set up the BAP stuff, and think they are trying to do something that
should succeed under normal conditions.

It appears the information about what features the adapter actually has should
be available to BlueZ earlier, and BlueZ should provide accurate information
about the adapter capabilities to the rest of the userspace.

For LE Audio in particular this is sort of important, because the adapter
support is not currently there, and only fairly new adapter models have these
features. There's also a few other bits (Core Sec 4.6, table 4.6) that BlueZ
might need to know later on, once support for more LE Audio parts is added.

At the moment the ISO sockets are under the experimental feature flag, so I'm
not sure if this is something that is to be added right now.

Below is a quick hack, which just exposes these bits to the mgmt settings a la
WBS and handles them in BlueZ.  But would this be the right place to put them
in the first place? Other ideas?  Trying to connect() to some random addresses
from userspace just to probe the feature capability probably is not the right
thing.


---
 doc/mgmt-api.txt       |  2 ++
 lib/mgmt.h             |  1 +
 profiles/audio/bap.c   |  5 +++++
 profiles/audio/media.c |  3 +++
 src/adapter.c          | 11 +++++++++++
 src/adapter.h          |  6 ++++++
 tools/btmgmt.c         |  1 +
 7 files changed, 29 insertions(+)

 include/net/bluetooth/mgmt.h | 1 +
 net/bluetooth/mgmt.c         | 6 ++++++
 2 files changed, 7 insertions(+)


diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 90d612ed8..11798629a 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -333,6 +333,7 @@ Read Controller Information Command
 		16	PHY Configuration
 		17	Wideband Speech
 		18	Quality Report
+		19	Connected Isochronous Stream Central
 
 	This command generates a Command Complete event on success or
 	a Command Status event on failure.
@@ -2926,6 +2927,7 @@ Read Extended Controller Information Command
 		16	PHY Configuration
 		17	Wideband Speech
 		18	Quality Report
+		19	Connected Isochronous Stream Central
 
 	The EIR_Data field contains information about class of device,
 	local name and other values. Not all of them might be present. For
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 796190cd9..610770491 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -96,6 +96,7 @@ struct mgmt_rp_read_index_list {
 #define MGMT_SETTING_STATIC_ADDRESS	0x00008000
 #define MGMT_SETTING_PHY_CONFIGURATION	0x00010000
 #define MGMT_SETTING_WIDEBAND_SPEECH	0x00020000
+#define MGMT_SETTING_CIS_CENTRAL	0x00040000
 
 #define MGMT_OP_READ_INFO		0x0004
 struct mgmt_rp_read_info {
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index e5ffb7230..2cd12465a 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -1264,6 +1264,11 @@ static int bap_probe(struct btd_service *service)
 		return -ENOTSUP;
 	}
 
+	if (!btd_adapter_has_feature(adapter, ADAPTER_FEAT_CIS_CENTRAL)) {
+		error("BAP requires CIS Central, but unsupported by adapter");
+		return -ENOTSUP;
+	}
+
 	/* Ignore, if we were probed for this device already */
 	if (data) {
 		error("Profile probed twice for the same device!");
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index fbb350889..873dee33e 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -1259,6 +1259,9 @@ static bool experimental_endpoint_supported(struct btd_adapter *adapter)
 	if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET))
 		return false;
 
+	if (!btd_adapter_has_feature(adapter, ADAPTER_FEAT_CIS_CENTRAL))
+		return false;
+
 	return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL;
 }
 
diff --git a/src/adapter.c b/src/adapter.c
index aadad4016..2e038ace0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -10717,6 +10717,17 @@ bool btd_has_kernel_features(uint32_t features)
 	return (kernel_features & features) ? true : false;
 }
 
+bool btd_adapter_has_feature(struct btd_adapter *adapter, uint32_t feature)
+{
+	size_t i;
+	uint32_t features = 0;
+
+	if (adapter->supported_settings & MGMT_SETTING_CIS_CENTRAL)
+		features |= ADAPTER_FEAT_CIS_CENTRAL;
+
+	return features & feature;
+}
+
 bool btd_adapter_has_exp_feature(struct btd_adapter *adapter, uint32_t feature)
 {
 	size_t i;
diff --git a/src/adapter.h b/src/adapter.h
index 78eb069ae..6a9a626bc 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -256,6 +256,12 @@ void btd_adapter_for_each_device(struct btd_adapter *adapter,
 
 bool btd_le_connect_before_pairing(void);
 
+enum adapter_features {
+	ADAPTER_FEAT_CIS_CENTRAL	= 1 << 0,
+};
+
+bool btd_adapter_has_feature(struct btd_adapter *adapter, uint32_t feature);
+
 enum experimental_features {
 	EXP_FEAT_DEBUG			= 1 << 0,
 	EXP_FEAT_LE_SIMULT_ROLES	= 1 << 1,
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 29f86091f..de614ced1 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -353,6 +353,7 @@ static const char *settings_str[] = {
 				"static-addr",
 				"phy-configuration",
 				"wide-band-speech",
+				"cis-central",
 };
 
 static const char *settings2str(uint32_t settings)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 743f6f59dff8..dc284c5f5cbb 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -109,6 +109,7 @@ struct mgmt_rp_read_index_list {
 #define MGMT_SETTING_STATIC_ADDRESS	0x00008000
 #define MGMT_SETTING_PHY_CONFIGURATION	0x00010000
 #define MGMT_SETTING_WIDEBAND_SPEECH	0x00020000
+#define MGMT_SETTING_CIS_CENTRAL	0x00040000
 
 #define MGMT_OP_READ_INFO		0x0004
 #define MGMT_READ_INFO_SIZE		0
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 0dd30a3beb77..d802faf60f26 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -859,6 +859,9 @@ static u32 get_supported_settings(struct hci_dev *hdev)
 	    hdev->set_bdaddr)
 		settings |= MGMT_SETTING_CONFIGURATION;
 
+	if (cis_central_capable(hdev))
+		settings |= MGMT_SETTING_CIS_CENTRAL;
+
 	settings |= MGMT_SETTING_PHY_CONFIGURATION;
 
 	return settings;
@@ -932,6 +935,9 @@ static u32 get_current_settings(struct hci_dev *hdev)
 	if (hci_dev_test_flag(hdev, HCI_WIDEBAND_SPEECH_ENABLED))
 		settings |= MGMT_SETTING_WIDEBAND_SPEECH;
 
+	if (cis_central_capable(hdev) && iso_enabled())
+		settings |= MGMT_SETTING_CIS_CENTRAL;
+
 	return settings;
 }
 
-- 
2.39.1


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

end of thread, other threads:[~2023-02-13 22:31 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 20:52 [RFC, BlueZ] bap: check adapter support before enabling BAP Pauli Virtanen
2023-01-27 21:12 ` [RFC,BlueZ] " bluez.test.bot
2023-01-28  0:28 ` [RFC, BlueZ] " Luiz Augusto von Dentz
2023-01-28  0:29   ` Luiz Augusto von Dentz
2023-01-28  9:26   ` Pauli Virtanen
2023-01-30 18:37 ` [PATCH BlueZ 1/8] doc: add MGMT setting for CIS features, remove Quality Report Pauli Virtanen
2023-01-30 18:37   ` [PATCH BlueZ 2/8] lib: Add defines for MGMT setting bits for CIS feature support Pauli Virtanen
2023-02-07  1:13     ` Luiz Augusto von Dentz
2023-01-30 18:37   ` [PATCH BlueZ 3/8] monitor: add names " Pauli Virtanen
2023-02-07  1:12     ` Luiz Augusto von Dentz
2023-01-30 18:37   ` [PATCH BlueZ 4/8] tools/btmgmt: " Pauli Virtanen
2023-02-07  1:14     ` Luiz Augusto von Dentz
2023-01-30 18:37   ` [PATCH BlueZ 5/8] adapter: add functions indicating adapter CIS capability Pauli Virtanen
2023-02-07  1:10     ` Luiz Augusto von Dentz
2023-01-30 18:37   ` [PATCH BlueZ 6/8] media: Check adapter CIS support to add BAP in SupportedUUIDs Pauli Virtanen
2023-01-30 18:37   ` [PATCH BlueZ 7/8] shared/bap: handle central-only case Pauli Virtanen
2023-01-30 19:39     ` Luiz Augusto von Dentz
2023-01-30 20:04       ` Pauli Virtanen
2023-02-07  1:19         ` Luiz Augusto von Dentz
2023-01-30 18:37   ` [PATCH BlueZ 8/8] bap: handle adapters that are not CIS Central / Peripheral capable Pauli Virtanen
2023-02-07  1:27     ` Luiz Augusto von Dentz
2023-01-30 20:13   ` [BlueZ,1/8] doc: add MGMT setting for CIS features, remove Quality Report bluez.test.bot
2023-02-07  1:08   ` [PATCH BlueZ 1/8] " Luiz Augusto von Dentz
2023-02-10 20:07     ` Luiz Augusto von Dentz
2023-02-13 22:20   ` patchwork-bot+bluetooth
2023-02-01 18:41 ` [PATCH BlueZ] media: set default value for BAP endpoint Vendor field Pauli Virtanen
2023-02-01 19:10   ` Luiz Augusto von Dentz
2023-02-01 19:51   ` [PATCH BlueZ v2] " Pauli Virtanen
2023-02-01 21:14     ` [BlueZ,v2] " bluez.test.bot
2023-02-01 21:50     ` [PATCH BlueZ v2] " patchwork-bot+bluetooth
2023-02-01 20:05   ` [BlueZ] " bluez.test.bot
2023-02-11 10:53 ` [PATCH BlueZ v2 1/9] doc: remove unimplemented Quality Report from MGMT settings Pauli Virtanen
2023-02-11 10:53   ` [PATCH BlueZ v2 2/9] doc: add MGMT setting for CIS features Pauli Virtanen
2023-02-11 10:53   ` [PATCH BlueZ v2 3/9] lib: Add defines for MGMT setting bits for CIS feature support Pauli Virtanen
2023-02-11 10:53   ` [PATCH BlueZ v2 4/9] monitor: add MGMT setting bit names " Pauli Virtanen
2023-02-11 10:53   ` [PATCH BlueZ v2 5/9] tools/btmgmt: " Pauli Virtanen
2023-02-11 10:53   ` [PATCH BlueZ v2 6/9] adapter: add function for checking adapter features, add CIS features Pauli Virtanen
2023-02-11 10:53   ` [PATCH BlueZ v2 7/9] media: Check adapter CIS support to add BAP in SupportedUUIDs Pauli Virtanen
2023-02-11 10:53   ` [PATCH BlueZ v2 8/9] shared/bap: support client-only case Pauli Virtanen
2023-02-11 10:53   ` [PATCH BlueZ v2 9/9] bap: handle adapters that are not CIS Central / Peripheral capable Pauli Virtanen
2023-02-11 13:45   ` [BlueZ,v2,1/9] doc: remove unimplemented Quality Report from MGMT settings bluez.test.bot
2023-02-13 22:20   ` [PATCH BlueZ v2 1/9] " patchwork-bot+bluetooth
2023-02-13 22:30     ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.