From patchwork Sat Feb 11 10:53:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 13136997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E4EAC61DA4 for ; Sat, 11 Feb 2023 10:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbjBKK5L (ORCPT ); Sat, 11 Feb 2023 05:57:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbjBKK5J (ORCPT ); Sat, 11 Feb 2023 05:57:09 -0500 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6712230D7 for ; Sat, 11 Feb 2023 02:57:08 -0800 (PST) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id EFB03240769 for ; Sat, 11 Feb 2023 11:57:06 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PDSGp2QjJz9rxM; Sat, 11 Feb 2023 11:57:06 +0100 (CET) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ v2 1/9] doc: remove unimplemented Quality Report from MGMT settings Date: Sat, 11 Feb 2023 10:53:45 +0000 Message-Id: <3df45c4a6737b249b519d4c6128e2eb783198abc.1676112710.git.pav@iki.fi> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The Set Quality Report command was removed in commit 0454e2d09570 ("mgmt: Add support for Mesh in the kernel"), but the settings bit was not removed. It's also not implemented on kernel side, so remove it now. --- Notes: v2: split to two commits doc/mgmt-api.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 90d612ed8..0e0b4fdf0 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -332,7 +332,6 @@ Read Controller Information Command 15 Static Address 16 PHY Configuration 17 Wideband Speech - 18 Quality Report This command generates a Command Complete event on success or a Command Status event on failure. @@ -2925,7 +2924,6 @@ Read Extended Controller Information Command 15 Static Address 16 PHY Configuration 17 Wideband Speech - 18 Quality Report The EIR_Data field contains information about class of device, local name and other values. Not all of them might be present. For From patchwork Sat Feb 11 10:53:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 13136998 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A691FC636CC for ; Sat, 11 Feb 2023 10:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbjBKK5L (ORCPT ); Sat, 11 Feb 2023 05:57:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229824AbjBKK5J (ORCPT ); Sat, 11 Feb 2023 05:57:09 -0500 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95DE06A75 for ; Sat, 11 Feb 2023 02:57:08 -0800 (PST) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 33B1A24072C for ; Sat, 11 Feb 2023 11:57:07 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PDSGp58gSz9rxS; Sat, 11 Feb 2023 11:57:06 +0100 (CET) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ v2 2/9] doc: add MGMT setting for CIS features Date: Sat, 11 Feb 2023 10:53:46 +0000 Message-Id: In-Reply-To: <3df45c4a6737b249b519d4c6128e2eb783198abc.1676112710.git.pav@iki.fi> References: <20230127205205.20235-1-pav@iki.fi> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add definitions for new MGMT Controller Information settings bits, indicating adapter Connected Isochronous Stream - Central/Peripheral feature support. --- Notes: v2: split to two commits doc/mgmt-api.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 0e0b4fdf0..58395dc90 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -332,6 +332,8 @@ Read Controller Information Command 15 Static Address 16 PHY Configuration 17 Wideband Speech + 18 Connected Isochronous Stream - Central + 19 Connected Isochronous Stream - Peripheral This command generates a Command Complete event on success or a Command Status event on failure. @@ -2924,6 +2926,8 @@ Read Extended Controller Information Command 15 Static Address 16 PHY Configuration 17 Wideband Speech + 18 Connected Isochronous Stream - Central + 19 Connected Isochronous Stream - Peripheral The EIR_Data field contains information about class of device, local name and other values. Not all of them might be present. For From patchwork Sat Feb 11 10:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 13136999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 265BBC64EC4 for ; Sat, 11 Feb 2023 10:57:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229984AbjBKK5M (ORCPT ); Sat, 11 Feb 2023 05:57:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbjBKK5J (ORCPT ); Sat, 11 Feb 2023 05:57:09 -0500 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0383A83D2 for ; Sat, 11 Feb 2023 02:57:08 -0800 (PST) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 8E46F2404CC for ; Sat, 11 Feb 2023 11:57:07 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PDSGq0SlNz9rxR; Sat, 11 Feb 2023 11:57:07 +0100 (CET) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ v2 3/9] lib: Add defines for MGMT setting bits for CIS feature support Date: Sat, 11 Feb 2023 10:53:47 +0000 Message-Id: In-Reply-To: <3df45c4a6737b249b519d4c6128e2eb783198abc.1676112710.git.pav@iki.fi> References: <20230127205205.20235-1-pav@iki.fi> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- Notes: v2: no changes The kernel mgmt.h doesn't use BIT(n) macro here, so I didn't change that now to keep these defines identical. lib/mgmt.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 796190cd9..efbdfb4b1 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -96,6 +96,8 @@ 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_SETTING_CIS_PERIPHERAL 0x00080000 #define MGMT_OP_READ_INFO 0x0004 struct mgmt_rp_read_info { From patchwork Sat Feb 11 10:53:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 13137001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB9F1C636D7 for ; Sat, 11 Feb 2023 10:57:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230003AbjBKK5N (ORCPT ); Sat, 11 Feb 2023 05:57:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbjBKK5K (ORCPT ); Sat, 11 Feb 2023 05:57:10 -0500 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A7AA1C7F9 for ; Sat, 11 Feb 2023 02:57:09 -0800 (PST) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id E106824076D for ; Sat, 11 Feb 2023 11:57:07 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PDSGq322Nz9rxL; Sat, 11 Feb 2023 11:57:07 +0100 (CET) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ v2 4/9] monitor: add MGMT setting bit names for CIS feature support Date: Sat, 11 Feb 2023 10:53:48 +0000 Message-Id: <4fce505a05e24dfa66e35cbef4371f8166b44853.1676112710.git.pav@iki.fi> In-Reply-To: <3df45c4a6737b249b519d4c6128e2eb783198abc.1676112710.git.pav@iki.fi> References: <20230127205205.20235-1-pav@iki.fi> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add names for CIS Central/Peripheral MGMT bits: @ MGMT Event: Command Complete (0x0001) plen 283 {0x0002} [hci0] 3.745117 Read Controller Information (0x0004) plen 280 Status: Success (0x00) Address: XX:XX:XX:XX:XX:XX (Intel Corporate) Version: Bluetooth 5.3 (0x0c) Manufacturer: Intel Corp. (2) Supported settings: 0x000ffeff Powered Connectable Fast Connectable Discoverable Bondable Link Security Secure Simple Pairing BR/EDR Low Energy Advertising Secure Connections Debug Keys Privacy Controller Configuration Static Address PHY Configuration Wideband Speech CIS Central CIS Peripheral Current settings: 0x000c0ad1 Powered Bondable Secure Simple Pairing BR/EDR Low Energy Secure Connections CIS Central CIS Peripheral Class: 0x7c0104 Major class: Computer (desktop, notebook, PDA, organizers) Minor class: Desktop workstation Rendering (Printing, Speaker) Capturing (Scanner, Microphone) Object Transfer (v-Inbox, v-Folder) Audio (Speaker, Microphone, Headset) Telephony (Cordless telephony, Modem, Headset) Name: xxx Short name: --- Notes: v2: add example output monitor/packet.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 44f1941bd..d9e8abf41 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -12649,6 +12649,8 @@ static const struct bitfield_data mgmt_settings_table[] = { { 15, "Static Address" }, { 16, "PHY Configuration" }, { 17, "Wideband Speech" }, + { 18, "CIS Central" }, + { 19, "CIS Peripheral" }, { } }; From patchwork Sat Feb 11 10:53:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 13137000 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84E9DC64EC7 for ; Sat, 11 Feb 2023 10:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229943AbjBKK5N (ORCPT ); Sat, 11 Feb 2023 05:57:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbjBKK5K (ORCPT ); Sat, 11 Feb 2023 05:57:10 -0500 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7138F23112 for ; Sat, 11 Feb 2023 02:57:09 -0800 (PST) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 262E0240769 for ; Sat, 11 Feb 2023 11:57:08 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PDSGq5PjZz9rxM; Sat, 11 Feb 2023 11:57:07 +0100 (CET) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ v2 5/9] tools/btmgmt: add MGMT setting bit names for CIS feature support Date: Sat, 11 Feb 2023 10:53:49 +0000 Message-Id: <34f7dbd9336538420154195bd0d353d8cbbeb2dd.1676112710.git.pav@iki.fi> In-Reply-To: <3df45c4a6737b249b519d4c6128e2eb783198abc.1676112710.git.pav@iki.fi> References: <20230127205205.20235-1-pav@iki.fi> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add names for CIS Central/Peripheral MGMT setting bits: [mgmt]# info Index list with 1 item hci0: Primary controller addr XX:XX:XX:XX:XX:XX version 12 manufacturer 2 class 0x7c0104 supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr le advertising secure-conn debug-keys privacy configuration static-addr phy-configuration wide-band-speech cis-central cis-peripheral current settings: powered bondable ssp br/edr le secure-conn cis-central cis-peripheral name xxx short name hci0: Configuration options supported options: public-address missing options: --- Notes: v2: add example command output tools/btmgmt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 29f86091f..323c26712 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -353,6 +353,8 @@ static const char *settings_str[] = { "static-addr", "phy-configuration", "wide-band-speech", + "cis-central", + "cis-peripheral", }; static const char *settings2str(uint32_t settings) From patchwork Sat Feb 11 10:53:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 13137002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83778C636CC for ; Sat, 11 Feb 2023 10:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230005AbjBKK5O (ORCPT ); Sat, 11 Feb 2023 05:57:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229962AbjBKK5K (ORCPT ); Sat, 11 Feb 2023 05:57:10 -0500 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE05126CDD for ; Sat, 11 Feb 2023 02:57:09 -0800 (PST) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 74D0D240769 for ; Sat, 11 Feb 2023 11:57:08 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PDSGr0SM0z9rxK; Sat, 11 Feb 2023 11:57:08 +0100 (CET) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ v2 6/9] adapter: add function for checking adapter features, add CIS features Date: Sat, 11 Feb 2023 10:53:50 +0000 Message-Id: In-Reply-To: <3df45c4a6737b249b519d4c6128e2eb783198abc.1676112710.git.pav@iki.fi> References: <20230127205205.20235-1-pav@iki.fi> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add function for checking adapter features, similar to btd_has_kernel_features. Currently supports the CIS feature bits. --- Notes: v2: use feature flags, not separate functions src/adapter.c | 13 +++++++++++++ src/adapter.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index aadad4016..4ccacdb8b 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -10712,6 +10712,19 @@ bool btd_le_connect_before_pairing(void) return false; } +bool btd_adapter_has_features(struct btd_adapter *adapter, uint32_t features) +{ + uint32_t flags = 0; + + if (adapter->current_settings & MGMT_SETTING_CIS_CENTRAL) + flags |= ADAPTER_CIS_CENTRAL; + + if (adapter->current_settings & MGMT_SETTING_CIS_PERIPHERAL) + flags |= ADAPTER_CIS_PERIPHERAL; + + return (flags & features) ? true : false; +} + bool btd_has_kernel_features(uint32_t features) { return (kernel_features & features) ? true : false; diff --git a/src/adapter.h b/src/adapter.h index 78eb069ae..96a8668d5 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -256,6 +256,13 @@ void btd_adapter_for_each_device(struct btd_adapter *adapter, bool btd_le_connect_before_pairing(void); +enum adapter_features { + ADAPTER_CIS_CENTRAL = 1 << 0, + ADAPTER_CIS_PERIPHERAL = 1 << 1, +}; + +bool btd_adapter_has_features(struct btd_adapter *adapter, uint32_t features); + enum experimental_features { EXP_FEAT_DEBUG = 1 << 0, EXP_FEAT_LE_SIMULT_ROLES = 1 << 1, From patchwork Sat Feb 11 10:53:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 13137003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ADEBC61DA4 for ; Sat, 11 Feb 2023 10:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230006AbjBKK5P (ORCPT ); Sat, 11 Feb 2023 05:57:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbjBKK5L (ORCPT ); Sat, 11 Feb 2023 05:57:11 -0500 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9B5F30D7 for ; Sat, 11 Feb 2023 02:57:10 -0800 (PST) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C7C0224072C for ; Sat, 11 Feb 2023 11:57:08 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PDSGr2n8Qz9rxL; Sat, 11 Feb 2023 11:57:08 +0100 (CET) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ v2 7/9] media: Check adapter CIS support to add BAP in SupportedUUIDs Date: Sat, 11 Feb 2023 10:53:51 +0000 Message-Id: In-Reply-To: <3df45c4a6737b249b519d4c6128e2eb783198abc.1676112710.git.pav@iki.fi> References: <20230127205205.20235-1-pav@iki.fi> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Don't indicate BAP support in SupportedUUIDs, if adapter supports neither CIS Central nor Peripheral. --- Notes: v2: use btd_adapter_has_features profiles/audio/media.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 505c4b3a6..0e0c40dc7 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1279,6 +1279,10 @@ 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_features(adapter, ADAPTER_CIS_CENTRAL) && + !btd_adapter_has_features(adapter, ADAPTER_CIS_PERIPHERAL)) + return false; + return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL; } From patchwork Sat Feb 11 10:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 13137004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 779F5C64EC4 for ; Sat, 11 Feb 2023 10:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230007AbjBKK5Q (ORCPT ); Sat, 11 Feb 2023 05:57:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229824AbjBKK5M (ORCPT ); Sat, 11 Feb 2023 05:57:12 -0500 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07D596A75 for ; Sat, 11 Feb 2023 02:57:10 -0800 (PST) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 1ADD924072C for ; Sat, 11 Feb 2023 11:57:09 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PDSGr561Dz9rxD; Sat, 11 Feb 2023 11:57:08 +0100 (CET) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ v2 8/9] shared/bap: support client-only case Date: Sat, 11 Feb 2023 10:53:52 +0000 Message-Id: In-Reply-To: <3df45c4a6737b249b519d4c6128e2eb783198abc.1676112710.git.pav@iki.fi> References: <20230127205205.20235-1-pav@iki.fi> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When client-only, skip registering ASCS and PACS in the local GATT DB. The data structures used to track the local ASE & PAC registrations and ASE state are then also not needed, and are set to NULL in this case. In this case, local "endpoints" exist only in the form of locally added bt_bap_pac PAC data. These usually are in 1-to-1 correspondence with the Media1 API endpoints registered by media applications. --- Notes: v2: * Use named boolean flag for client-only in bt_bap_db instead of just NULL field values, maybe makes the intent a bit clearer. * Add bt_bap_set_client_only for setting the client-only flag on databases, instead of exposing bt_bap_db. The client-only state cannot be indicated to bt_bap_new by passing in ldb==NULL, because the local PACs are in the ldb and we need to know which adapter the bt_bap is for. So instead use a separate function that sets the flag. It cannot make already peripheral-enabled DB client-only (currently), but this is not needed now, and maybe not in the future either. src/shared/bap.c | 42 +++++++++++++++++++++++++++++++++--------- src/shared/bap.h | 2 ++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 22f2e6714..e85815d8d 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -109,6 +109,7 @@ struct bt_ascs { }; struct bt_bap_db { + bool client_only; struct gatt_db *db; struct bt_pacs *pacs; struct bt_ascs *ascs; @@ -620,7 +621,7 @@ static struct bt_bap_endpoint *bap_get_endpoint(struct bt_bap_db *db, { struct bt_bap_endpoint *ep; - if (!db || !attr) + if (!db || !attr || db->client_only) return NULL; ep = queue_find(db->endpoints, bap_endpoint_match, attr); @@ -652,7 +653,7 @@ static struct bt_bap_endpoint *bap_get_endpoint_id(struct bt_bap *bap, struct gatt_db_attribute *attr = NULL; size_t i; - if (!bap || !db) + if (!bap || !db || db->client_only) return NULL; ep = queue_find(db->endpoints, bap_endpoint_match_id, UINT_TO_PTR(id)); @@ -2170,7 +2171,7 @@ static struct bt_ascs *ascs_new(struct gatt_db *db) return ascs; } -static struct bt_bap_db *bap_db_new(struct gatt_db *db) +static struct bt_bap_db *bap_db_new(struct gatt_db *db, bool client_only) { struct bt_bap_db *bdb; @@ -2178,19 +2179,23 @@ static struct bt_bap_db *bap_db_new(struct gatt_db *db) return NULL; bdb = new0(struct bt_bap_db, 1); + bdb->client_only = client_only; bdb->db = gatt_db_ref(db); bdb->sinks = queue_new(); bdb->sources = queue_new(); - bdb->endpoints = queue_new(); if (!bap_db) bap_db = queue_new(); - bdb->pacs = pacs_new(db); - bdb->pacs->bdb = bdb; + if (!client_only) { + bdb->endpoints = queue_new(); + + bdb->pacs = pacs_new(db); + bdb->pacs->bdb = bdb; - bdb->ascs = ascs_new(db); - bdb->ascs->bdb = bdb; + bdb->ascs = ascs_new(db); + bdb->ascs->bdb = bdb; + } queue_push_tail(bap_db, bdb); @@ -2205,7 +2210,20 @@ static struct bt_bap_db *bap_get_db(struct gatt_db *db) if (bdb) return bdb; - return bap_db_new(db); + return bap_db_new(db, false); +} + +int bt_bap_set_client_only(struct gatt_db *db) +{ + struct bt_bap_db *bdb; + + bdb = queue_find(bap_db, bap_db_match, db); + if (bdb) + return bdb->client_only ? 0 : -EINVAL; + + bap_db_new(db, true); + + return 0; } static struct bt_pacs *bap_get_pacs(struct bt_bap *bap) @@ -2328,6 +2346,9 @@ static void bap_add_sink(struct bt_bap_pac *pac) queue_push_tail(pac->bdb->sinks, pac); + if (pac->bdb->client_only) + return; + memset(value, 0, sizeof(value)); iov.iov_base = value; @@ -2346,6 +2367,9 @@ static void bap_add_source(struct bt_bap_pac *pac) queue_push_tail(pac->bdb->sources, pac); + if (pac->bdb->client_only) + return; + memset(value, 0, sizeof(value)); iov.iov_base = value; diff --git a/src/shared/bap.h b/src/shared/bap.h index 47a15636c..90d373e35 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -111,6 +111,8 @@ struct bt_bap_pac *bt_bap_add_pac(struct gatt_db *db, const char *name, struct iovec *data, struct iovec *metadata); +int bt_bap_set_client_only(struct gatt_db *db); + struct bt_bap_pac_ops { int (*select)(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, struct bt_bap_pac_qos *qos, From patchwork Sat Feb 11 10:53:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 13137005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16B7BC636D7 for ; Sat, 11 Feb 2023 10:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230011AbjBKK5R (ORCPT ); Sat, 11 Feb 2023 05:57:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229985AbjBKK5M (ORCPT ); Sat, 11 Feb 2023 05:57:12 -0500 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07DB383D2 for ; Sat, 11 Feb 2023 02:57:10 -0800 (PST) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 6F56F240769 for ; Sat, 11 Feb 2023 11:57:09 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PDSGs096Cz9rxF; Sat, 11 Feb 2023 11:57:08 +0100 (CET) From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ v2 9/9] bap: handle adapters that are not CIS Central / Peripheral capable Date: Sat, 11 Feb 2023 10:53:53 +0000 Message-Id: <80fb0196727ff8ea422b0e003be028a99844da70.1676112710.git.pav@iki.fi> In-Reply-To: <3df45c4a6737b249b519d4c6128e2eb783198abc.1676112710.git.pav@iki.fi> References: <20230127205205.20235-1-pav@iki.fi> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When BT adapter is not CIS Peripheral capable, set client-only for the local db, so that ASCS/PACS are not registered. When BT adapter is not CIS Central capable, ignore the remote device GATT database, and don't start client sessions. --- Notes: v2: * Use bt_bap_set_client_only and btd_adapter_has_features to do the stuff. * Don't attach client in bap_accept, if adapter doesn't support CIS Central. We still mark the service as connected. If we want to mark the service unavailable in this case, we could return error in device_probe. Server connections are handled in bap_attached/detached and work also in this case, this should work based on looking at the code, and it works in testing. The patch series was manually tested with two machines running it, with Central flag forced to false on one end, and Peripheral flag to false on the other, and testing Pipewire being able to play + record audio over the BAP link. Playback + recording on non-BlueZ remote device was also tested with Peripheral flag disabled. bluetoothctl: Server (CIS Central bit disabled): [bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep0] Auto Accept (yes/no): yes [/local/endpoint/ep0] CIG (auto/value): a [/local/endpoint/ep0] CIS (auto/value): a Capabilities: 03 01 ff 00 02 02 03 02 03 03 05 04 1e 00 f0 00 ................ Endpoint /local/endpoint/ep0 registered [bluetooth]# endpoint.register 00002bcb-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep1] Auto Accept (yes/no): yes [/local/endpoint/ep1] CIG (auto/value): a [/local/endpoint/ep1] CIS (auto/value): a Capabilities: 03 01 ff 00 02 02 03 02 03 03 05 04 1e 00 f0 00 ................ Endpoint /local/endpoint/ep1 registered [bluetooth]# show Controller XX:XX:XX:XX:XX:XX (public) Name: xxx Alias: xxx Class: 0x00000000 Powered: yes PowerState: on Discoverable: no DiscoverableTimeout: 0x000000b4 Pairable: no UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb) UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) UUID: Volume Control (00001844-0000-1000-8000-00805f9b34fb) UUID: Device Information (0000180a-0000-1000-8000-00805f9b34fb) UUID: Audio Stream Control (0000184e-0000-1000-8000-00805f9b34fb) UUID: Published Audio Capabil.. (00001850-0000-1000-8000-00805f9b34fb) Modalias: usb:v1D6Bp0246d0542 Discovering: no Roles: central Roles: peripheral ExperimentalFeatures: BlueZ Experimental LL p.. (15c0a148-c273-11ea-b3de-0242ac130004) ExperimentalFeatures: BlueZ Experimental Blue.. (330859bc-7506-492d-9370-9a6f0614037f) ExperimentalFeatures: BlueZ Experimental ISO... (6fbaf188-05e0-496a-9885-d6ddfdb4e03e) Client (CIS Peripheral bit disabled): [bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep0] Auto Accept (yes/no): yes [/local/endpoint/ep0] CIG (auto/value): a [/local/endpoint/ep0] CIS (auto/value): a Capabilities: 03 01 ff 00 02 02 03 02 03 03 05 04 1e 00 f0 00 ................ Endpoint /local/endpoint/ep0 registered [bluetooth]# endpoint.register 00002bcb-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep1] Auto Accept (yes/no): yes [/local/endpoint/ep1] CIG (auto/value): a [/local/endpoint/ep1] CIS (auto/value): a Capabilities: 03 01 ff 00 02 02 03 02 03 03 05 04 1e 00 f0 00 ................ Endpoint /local/endpoint/ep1 registered [bluetooth]# show Controller YY:YY:YY:YY:YY:YY (public) Name: yyy Alias: yyy Class: 0x00000000 Powered: yes PowerState: on Discoverable: no DiscoverableTimeout: 0x000000b4 Pairable: no UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb) UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) UUID: Volume Control (00001844-0000-1000-8000-00805f9b34fb) UUID: Device Information (0000180a-0000-1000-8000-00805f9b34fb) Modalias: usb:v1D6Bp0246d0542 Discovering: no Roles: central Roles: peripheral ExperimentalFeatures: BlueZ Experimental ISO... (6fbaf188-05e0-496a-9885-d6ddfdb4e03e) The client is client-only, and has no ASCS/PACS. [bluetooth]# connect XX:XX:XX:XX:XX:XX ... [server]# transport.list Transport /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_source0/fd12 Transport /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_sink0/fd13 [server]# endpoint.list Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_source0 Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_sink0 [server]# endpoint.list local /local/endpoint/ep0 /local/endpoint/ep1 [server]# transport.acquire /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_source0/fd12 Acquire successful: fd 7 MTU 40:40 [CHG] Transport /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_sink0/fd13 State: active [CHG] Transport /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_source0/fd12 State: active Server: Auto Acquiring... [CHG] Transport /org/bluez/hci0/dev_YY_YY_YY_YY_YY_YY/fd6 State: pending Acquire successful: fd 7 MTU 40:40 [CHG] Transport /org/bluez/hci0/dev_YY_YY_YY_YY_YY_YY/fd7 State: active [CHG] Transport /org/bluez/hci0/dev_YY_YY_YY_YY_YY_YY/fd6 State: active [client]# endpoint.list [client]# endpoint.list local /local/endpoint/ep0 /local/endpoint/ep1 The server is peripheral-only and has only local endpoints. profiles/audio/bap.c | 26 ++++++++++++++++++++++++-- profiles/audio/media.c | 6 +++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index b8c75f195..426aa89aa 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1259,6 +1259,7 @@ static int bap_probe(struct btd_service *service) struct btd_adapter *adapter = device_get_adapter(device); struct btd_gatt_database *database = btd_adapter_get_database(adapter); struct bap_data *data = btd_service_get_user_data(service); + struct gatt_db *adapter_db, *device_db; char addr[18]; ba2str(device_get_address(device), addr); @@ -1269,17 +1270,32 @@ static int bap_probe(struct btd_service *service) return -ENOTSUP; } + if (!btd_adapter_has_features(adapter, ADAPTER_CIS_CENTRAL) && + !btd_adapter_has_features(adapter, ADAPTER_CIS_PERIPHERAL)) { + DBG("BAP requires CIS features, unsupported by adapter"); + return -ENOTSUP; + } + /* Ignore, if we were probed for this device already */ if (data) { error("Profile probed twice for the same device!"); return -EINVAL; } + adapter_db = btd_gatt_database_get_db(database); + + if (!btd_adapter_has_features(adapter, ADAPTER_CIS_PERIPHERAL)) + bt_bap_set_client_only(adapter_db); + + if (btd_adapter_has_features(adapter, ADAPTER_CIS_CENTRAL)) + device_db = btd_device_get_gatt_db(device); + else + device_db = NULL; + data = bap_data_new(device); data->service = service; - data->bap = bt_bap_new(btd_gatt_database_get_db(database), - btd_device_get_gatt_db(device)); + data->bap = bt_bap_new(adapter_db, device_db); if (!data->bap) { error("Unable to create BAP instance"); free(data); @@ -1303,6 +1319,7 @@ static int bap_probe(struct btd_service *service) static int bap_accept(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); + struct btd_adapter *adapter = device_get_adapter(device); struct bt_gatt_client *client = btd_device_get_gatt_client(device); struct bap_data *data = btd_service_get_user_data(service); char addr[18]; @@ -1315,6 +1332,11 @@ static int bap_accept(struct btd_service *service) return -EINVAL; } + if (!btd_adapter_has_features(adapter, ADAPTER_CIS_CENTRAL)) { + btd_service_connecting_complete(service, 0); + return 0; + } + if (!bt_bap_attach(data->bap, client)) { error("BAP unable to attach"); return -EINVAL; diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 0e0c40dc7..d9e133007 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1110,6 +1110,7 @@ static void bap_debug(const char *str, void *user_data) static bool endpoint_init_pac(struct media_endpoint *endpoint, uint8_t type, int *err) { + struct btd_adapter *adapter = endpoint->adapter->btd_adapter; struct btd_gatt_database *database; struct gatt_db *db; struct iovec data; @@ -1122,7 +1123,7 @@ static bool endpoint_init_pac(struct media_endpoint *endpoint, uint8_t type, return false; } - database = btd_adapter_get_database(endpoint->adapter->btd_adapter); + database = btd_adapter_get_database(adapter); if (!database) { error("Adapter database not found"); return false; @@ -1158,6 +1159,9 @@ static bool endpoint_init_pac(struct media_endpoint *endpoint, uint8_t type, metadata->iov_len = endpoint->metadata_size; } + if (!btd_adapter_has_features(adapter, ADAPTER_CIS_PERIPHERAL)) + bt_bap_set_client_only(db); + endpoint->pac = bt_bap_add_vendor_pac(db, name, type, endpoint->codec, endpoint->cid, endpoint->vid, &endpoint->qos, &data, metadata);