From patchwork Thu Aug 29 12:49:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 824219 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010048.outbound.protection.outlook.com [52.101.69.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BD5B1AE860 for ; Thu, 29 Aug 2024 12:49:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935773; cv=fail; b=uMKaWajNvFMJMMhL2i/kur7cD2Vt3D0aKb8oQh8xgJ1SqvQK/rwU9wE4iauboy60taQ0TSheCFnPXwFcK0TDg2BbJJpiCiENs4biva5o+sZquqQt+PcpTbXRo4ADEcsdaluboS9Xkgp88DPdXbGYDHPiQFzZtZmd0HvlgrN0mnQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935773; c=relaxed/simple; bh=gKDyHTNpHEQoXhGeR0poSKbW+fu9XI6e02W16qKV1uo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=o5wIT6soZlCA73sgVj5ZK7+nuMWFnA5vtNcb6FiJLY8phnVb0eCPkkYkFBqhdTuZ/OUr+wLxGQpjHlt2GLgPBePe+1/X1+AOigvQv23+gfwC2TJCuO43dvEJUpAbu6gSNQ9INFxgJITpBL/dmE2Yigdw+v2luSgNr7At92uMxu8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=m+y417Yt; arc=fail smtp.client-ip=52.101.69.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="m+y417Yt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oBW/Z+h+GKnQHSFRyGz9OzYr+4LrrVAzsNymvD7O0Uhgnic99oVXm+7m3UHarFuiJfV0h0BG0h9E7C5PGjRyT+jN8rvkipjAKy1lzXY8isfaWRETxWrX+TK3lYH0T499nBTV6vNI0D3XWU/ErOUmgoL32nlN2/10jPAuQg7bMLB6+gFg55NeV7sEQop3yNW9zMsF5vv4dB2wh8b9GVYUeJs8k2Ohjcqv1JjCEpxnHWPS7G571eYy7Bmulcu8zcWgtGfYL/l9kC/UWmih2SAUBMxtqjxImV/icydhsdZpRQBKJNAFt+vPaKZ0IqG3ACDPe+/oQupsNkeysGYFpqIu7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P78dLhEckEI7M9s756uuWK5zuiswAEtJxHVmG5ivHdI=; b=d8w5fwoKWsAwg7NDiFnL0HQ5lRH+lXg85usmTTwsmWOY36q3EI1Nst6eryiswAEq1+YGz1lpa1shkgafs6ESQWVI7c3C17a2XDWnDBbOPbkB+vIpndUDlNd63odL/ZKMR+1OATfywiUbQGLsuEGp4ZvL0IF3EckeVEhtJib+8UDheQM27HgpOF1GMjVQlJp/I1NYJyCussy+JkUr7fgybz5brhRGLW5SLp/NvdGOLfy2JXSUP404Bt8A1Y2jBI6N47lZ1KHC9GaPYC/W6i/a8zuVOy55x+3+4XhlTt8fKg7DcnnHzHfqyh6jTDS8FB6ygybt+1VDw/PfNPx7nGfrNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P78dLhEckEI7M9s756uuWK5zuiswAEtJxHVmG5ivHdI=; b=m+y417YtMVeI4hBu1wy2eFn2y2sKF2DYGGAvqU1Zw1SMCMSpVSr5Oqx65uTk8CiFyxkCGqiuFvdmNCMbd11Gw6QCkYJZCpJ9uGMqEBPMly/QjIp01xWBSKA44euXC8PbiC2QZYtfYpYy7UCu/K315aYtqByafDfVnup7oEp1ZO7n9olLWFyMQtSRMUZmhdgUpF6ery/TSUTqUWKE3PvjUm/P5zH4lGBxjGwvpejOMt+GiBJN+YMNWw5ERcAGz0B5mGRN4dnS3+liGmVus1ZvGprKaDEwgX3wFLA6Sp3tn2sa1KbUzyvzlgAJNzdntRy6xdilx39m0f5tDk9h4e1fzQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7425.eurprd04.prod.outlook.com (2603:10a6:20b:1d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27; Thu, 29 Aug 2024 12:49:28 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:28 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 01/16] shared/bass: Register ATT disconnect cb Date: Thu, 29 Aug 2024 15:49:03 +0300 Message-Id: <20240829124918.84809-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P250CA0027.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5e3::18) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: 512c59e7-ba59-4287-497c-08dcc8290507 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: boDyMaiR9VQag/PJTm15BFfrhOK+MAZ+k1FpGENdN4KJ8EErLNRODcWZ2Fkrzj+3UUKdxbos7OErKsD29qo4rJo+y7B5tubrvgEzasmyJqTQoeEU4EEqvsFXjFfsBVzbZ1uevK0xkZm5j/azJNaJAo+6jn3zURncEn2V4RrMsRfiZSNR6FfF7RJbmA88wR63P6iPRktS5C6sSW4EPiIRBRz8m1FA4DQEpWiY1kFq98rHjYYRDklW9FQN4Pm1HPLPfQS4m4WN5g6Fv8SFaVTk/RF5igw9XmAYu5uVBAJplJ9WLp4tMgpfvQZZqSPGEkcsb0OB3JCSFT/Q5coFdADYQDhoM5C/TaqQj0Clyp6YYUI7LJR1dr0o/L85o7llUcj35FZzKjxW2EuYN1DwNMo9UlOwkw0ZOl2KVT80AlI9N2pGUkOivTiKPiH1x4gNFXNi1cu0XX48p9epA7umKlFHwbRqMO8ICFtbwPIbcGJ5/AKq+ba+VQH0eUAxRkGDZIqyUiFV2GBh9ZkpGhu6WhYtAmbAb/efN3yFjQ3o2dirwrcuFW5GSzNjg0ZEWxlx+UjbXGp+1BuzoZCJ2dMuWUNtcAsM/FoAFlxWa5m8oQNkR1X543rDShqS3KtBtA20HUf8cxJEPgtXmzWUo6ace21E3ySQRCxoKygstp53SkgW5ZOXCi70MkX2mIMTn2akHTHz9jpHi5V8fvWmAVF7KAMaqdFRfWcHEpCNyc31qLmyJv6T3ZvPaAlD9W/a6c5ZQ49Svyj16RwDY8BGtmfUofit/onfdghdFEzusx/47QrqAnodk+qVlPnUD3qMkFnQP9KIW4QHnxtT+JiT/5/dRzJ3MjhFAreLGHrbsF40RupryymsEqTD8gXIbnkXpvUWFCb/b9Jl46xm4Y7u+G2Hp2GvNZUf5hJmElhDQ1GxMRP5G7go22MByVpzsCzmRu6bFtKHI4q8sipRZ8Gj8/ulBs4lZxAGNDI8/2wNIjnsybmbi7ApJXqx5t6k44R7nw7icK56EIiHziVc3Q0fOBr4C/nPsdvrz1bvaExnDS2LyVBRQpXTNDovcFlvZgTv+WaNyCGiypl4dD4W1fNrT/hW143qGEvVJpUYpBUEHFoyQwkGcljItePRQjBbAjFgkCrcA9SO3hjBnrgg43mda1/Dh35SH7QwyInahOX6BTqjZ6+aRsmO5rSV3ba40NiFR3+unfhf7exkghL2tt2Us7p3QgSooX28USelWq0izcBfqEg9ZewZrDN6LyE7lTz1KQY/wjjazpN/MCLL7feril9HYxxUgPn20yjO2s96MnhvL1IokiM1Cg2pv4C/U22Fxtek4kjS8bEymNnYwJuOYiKWtzrxTQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)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Za27L3pcRhCbKpQRs6Qy7OYVX0tTKPcG4nJsH/eEg46r1ICkJUXxes5kTo4NLTuJ5DCxvFOYTkxwRWtMzK/88bkGJ2sfLkAv198jChqwyuHRKB7XxveUWoX7n7CEigFTD7KJlm/Suwf/v7vOzcn5LK+PlsV+GYo3aemohoBpn/HWbToyQAKttlh+cChYuN6Sp81C9oFnkCXDWX7IG1i/ddut4u5z4Wqx2v7hqfhjeHdcTkCorFsLTZm3+zgFN8wKB002dMQC4i4tAxPj9F6cryIha0LrOpePIRg+tDuOZqOdfcTq6xE6SOyIDOh5eUwHaO24t3OXuQdTBolMtR/2y+/w/xpwpOvZ0kUldi+hjUhTTgnIVbsfkYluC5OTSXeAEG14FKdBYWHpatzAQh7Rl3hyT+wKnsYMTUpZ6nLUsyTlOGwdVoFU0lP1VlkQn5xyISa3ifkBeT9jOTPuheZHmtzCf+MXNanzhRHIZXoTCnPnvv/HqHPD1DUSyHzRbMuLGsc/cCejkpba3Vdh7EH+d0pvCVROrGupeCEt63TOTwqZTbTOOTrXYKwxzyVYPjwOW3c1yckrJBzlCGDmOkotwvRG+rPRBLXij3V8Qy26l2QfpmGmw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 512c59e7-ba59-4287-497c-08dcc8290507 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:28.4466 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: T7npcYYrSQfyl0T6QZTy7mLCM/AoY/drv6krQxRr8K3cB/D8NwXK68+z9KEz9m2Lkrne2v64kfsljNbjPKwmQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7425 This registers an ATT disconnect callback with bass, to properly clean uo the session if the ATT connection is removed. --- src/shared/bass.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/shared/bass.c b/src/shared/bass.c index b54bf3094..bf739526c 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -73,6 +73,8 @@ struct bt_bass { struct queue *src_cbs; + unsigned int disconn_id; + void *user_data; }; @@ -1579,6 +1581,32 @@ static void bass_attached(void *data, void *user_data) cb->attached(bass, cb->user_data); } +static void bass_disconnected(int err, void *user_data) +{ + struct bt_bass *bass = user_data; + + bass->disconn_id = 0; + + DBG(bass, "bass %p disconnected err %d", bass, err); + + bt_bass_detach(bass); +} + +static void bass_attach_att(struct bt_bass *bass, struct bt_att *att) +{ + if (bass->disconn_id) { + if (att == bt_bass_get_att(bass)) + return; + + bt_att_unregister_disconnect(bt_bass_get_att(bass), + bass->disconn_id); + } + + bass->disconn_id = bt_att_register_disconnect(att, + bass_disconnected, + bass, NULL); +} + bool bt_bass_attach(struct bt_bass *bass, struct bt_gatt_client *client) { bt_uuid_t uuid; @@ -1590,8 +1618,11 @@ bool bt_bass_attach(struct bt_bass *bass, struct bt_gatt_client *client) queue_foreach(bass_cbs, bass_attached, bass); - if (!client) + if (!client) { + if (bass->att) + bass_attach_att(bass, bass->att); return true; + } if (bass->client) return false; @@ -1600,6 +1631,8 @@ bool bt_bass_attach(struct bt_bass *bass, struct bt_gatt_client *client) if (!bass->client) return false; + bass_attach_att(bass, bt_gatt_client_get_att(client)); + bt_uuid16_create(&uuid, BASS_UUID); gatt_db_foreach_service(bass->rdb->db, &uuid, foreach_bass_service, bass); @@ -1626,12 +1659,23 @@ static void bass_detached(void *data, void *user_data) void bt_bass_detach(struct bt_bass *bass) { + struct bt_att *att; + if (!queue_remove(sessions, bass)) return; + if (bass->client) + att = bt_gatt_client_get_att(bass->client); + else + att = bass->att; + + bt_att_unregister_disconnect(att, bass->disconn_id); + bt_gatt_client_unref(bass->client); bass->client = NULL; + bass->att = NULL; + queue_foreach(bass_cbs, bass_detached, bass); } From patchwork Thu Aug 29 12:49:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 823627 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010048.outbound.protection.outlook.com [52.101.69.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E5A81AE86F for ; Thu, 29 Aug 2024 12:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935775; cv=fail; b=VYMJVEPtJozJKGFY0UtLY7KrX1YR1PaeReIjlflfl7PWv8htzD47qZI8w+Uxg5zkUtANu45m/zj+PTWju8O9JS4aAr5zdzxSrGL83eciEv2DuN1+8fFUX2b4Mf/sozi5Dl3k3jEyslxJcJZ2Io7oP8TOJv5KnCsDNF5XrKSeixA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935775; c=relaxed/simple; bh=klDnZ6fy+Xc04clq0EJ3VLDTQAsebXu+r4W1LpWRIc8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=OsLGEcYNb0P6WdCRYuE0+nZisT+pO0Fitq+IXpgTvXnywco7FIrfk3+NZJpWAayb7xgKreV12d8/O818zgLgOpAvJnpGvXzTL9j6f7KAQPJ3TCrocXtB1fc+cBEbKGdlmGznE8KWk0CcXEtqbA1m/ssa2ZtbhWuHGRvvPjTs0ec= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=gGpZXk++; arc=fail smtp.client-ip=52.101.69.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="gGpZXk++" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uo8lN0QMsJKPKiKWbRhVBKDZ7x9km2xohDd5a8U9X9suMCXmvuYsh9nhmqyA5lYwawozge3pY/UxEtNDYHFJ6MQ/3xahogAzgG24lubpLwstj27EO6C2uKzPH5FAhdcuSopK47HKu85VH9Kdf4XS7l00cl7x3ABg8RU2hkEsYkam9tL7/bWK1bAoq2SMG/Bz8gR7SDGPOJzVdVjixaxWl7sN5XQDmHCpJ4RjgK3pbXo7D8z1AuU0egqnEW4yh0Xj3NfPF0NVC+CAxIJQs/Z6WLBwHLFWtN6UT5+ElgHx1rvavu9iv164/5S1UAB45tMg6y9exZhWJEd/WLJgga+9nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sGT5rxydsj9x+DVZG3GqjZudONw42DWsN+IDAfyzGpk=; b=PeTOz7xkBhss3IlLzHbNIoxdYDE7m99tT67wF2B4ilTGCWI190OcUFHUoCZ8jN5IeIor8cT3naEgNcpwKZMJyS2+5EbkjAHyEA+6YAI0QkgngMFSgJtbEx9ah+KXVAGM/Vm4kzuxBLPrVBNBXqfitdCOY/X4KXIG/oh1eDKYgEh72dYGqjDqzooSu9L8PpCn1ppM+gtvd4wgcsNiW1mt/Xv49sz+J5SlJNQ8etbqjzFMdhxsokGWfoX4aBhYzA66VElSGo2Y4hYp7QM2/BEFFt03ZvgpLSr9g7kJcw0Kuowwwbo25e2h6NBYwTGuYICxUvzA5SmpbPuX6LIViyjxmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sGT5rxydsj9x+DVZG3GqjZudONw42DWsN+IDAfyzGpk=; b=gGpZXk++MeRa0MnpDBJw5wnO9yxHjDgbrVzkH6umaL8JM2JRXaTLFBejVySmA9GoUGKCuIQQx5AorYqt463h21Eii78FzEoQSNEOzfSPzHxkITdCq4evUkw9bkybilqE4lcdzj1DJ1jY7MLyZeyuNCzUCmsPltRH7EYLCMgsJJShTif5PvZjf5aco0tY8wjbf2/WCfwfwrysy7DrLTeuuS5cqGQJ5lXLEDJM0HHUtHS3yv40OmnOBgegOJpMNaQXQ+y89jHBsnAKjwDryFWY9xvuDgvuKBN9H0Fv7UDjDGI9dCWlJ0STRTmaHP7X25gy1QJq387vnMOkOUkrABcuhQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7425.eurprd04.prod.outlook.com (2603:10a6:20b:1d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27; Thu, 29 Aug 2024 12:49:31 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:31 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 02/16] shared/bass: Make bt_bcast_src private Date: Thu, 29 Aug 2024 15:49:04 +0300 Message-Id: <20240829124918.84809-3-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P190CA0062.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:656::23) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b0c5679-7d06-47f4-c297-08dcc8290690 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: LaP6jFr8tRhxRZYBRvI7S0G/BSTE0eOkISLNNEePR6BXWCRvI7P6gIX0KRJfAMOPQPUU+T3+LpO1Z9xBkUJr8MFLqwDHwr6HIwOq5IY2wOSQmViRGAc3ctPrN1vufc8+R52j15SJlxlhDRgRlWFlfTJ1DkiyltVBuEQ+bV0BRO6t9pKF7gXCvmyDIfjCMOT69O+zLpASJfPCSeIQtdJVtB6seOFX366pGzw5YhdoTEdeAUEzuQjIkgr4Hf9QT/WYcdknPdEvmloWoin4fspwpUPtd8CGf81jw7PkEuWMeAVDmwqrCRSvJMP2InZKSl3/U9S/KNbF2dzNemI/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SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WGMhi2jfzNuQngxaL2fIl5qOHxBJcDv5/cXQwbyR4jAilMatQuZmCIAL828YblUqfkjNbyTttIoE8ft7A3uMqYMUU9xI3eqwtLZowAwoaj3U72qrG9ihGmz6uBu48jj75ep8wS8ZURUHNxR/QplZtnxl3Rd7pHw87fxvXNgQDeSdQotkhHSSmSDzm0YoVX2HCkqNoyo6N1wmVPhBQyEe7at7ri1bc1YV8tIHo5CHjJLvyfml+Mqzca5PQ+Hi/UHPd/RcHpKMPXUa1TOLr0tnVFMptJcIrIri3AlotOJQI1YW1Ib034nwl0xjHxmoBF9VNvG5tS2ZHn/zuVy/POBpEvp4rjoPUDo7jDXqwwgYXR8rSk7xrAthP5TXDsoiUmF0OxuxDSTJYxOn6dqUq1Kk7r2JuYK2T5pcrybAFwC32E1V7/BhI38CbOGHg7PWaQz3GIdUtFqNMdj6XjV7UeAmFOCRndZr60GoTZ7CLaLkCsbJ9lRWJZ7ARIziOatpc3jypGSdnlZ7pMGYpia59t1wRGmuN/i5nuU0bRJz9AFqKeqRJ/S8tCbk1xOfiSHGiaWvYi2T6JOU9c34khjHKhIAm2IQ/Hy/sRqF/puctu9Qwpa13nIHXBQGHpnmf34Go+QrwxRyZC2J5zKgraWoJCEouEQySAYtbJuBUck4/d+eUrTJ8VG+8xyk1vG20Z+nSE0LQ04P/uldJo5OC4qtpYG/EUdyQXN7e00HA5fCH9NHcro9eOJOBj7lc0HfRRZQAODJaGnrNISuVSgeYA5qeeTknutKeFY+g43iiB4iPzxBmSxUyZzlAbTEBZEw/H2wIh4vWFCst4pFYmO0/lMi0gHQc5n8XtusO/wlZnC76Bt8EToqOqGQr9dQ7aarD+IeHbkFqEJmK3YCIljf4kmsZyXcq0ITn58XvBGnCXGb8M3fVXmvT1O7Mo1CtWHIvYBNCi+QQwcw1x1LqaPvoW0kU6KymFOJ298vnCitS26DX99FXnEhZdx75GzFay1pCayUKgJwW9DsLrGyZiIAtOYrxAimceiesmYvsn8ToJ7VVqLse/NT6Hul30NwaekvScX3/+hX+Tex138poEOrHvKD5BtJBnB4fyzeU8OVZRGvSHYsodzpPUb4NW8Q+9A2AVDgIXZr3nkHdemJ9AIBm92l2U1UImCIc0d0pnBrmfw2d5d7BIOJ3dfKKDTE1sR0HWPWKogcs+32CCNvtAGi38tGzWs/p3qsuWQ54sfXnsv18bBu20sMH9Qhq7YhIqYZotbFjbZCLA6sea5Ej/2rDuOxxdHbSK+LRlicQe6NDN2ChMc9YS2ZL0Pe6FVydRysLVdhLqdMSNGuzl7TvXHR4TbGqGOkUOiwOywETdCokc5PZkw6oIdmimD6CMGnZ1/+EzUADu5+ZU0gj4EQUWakgk7l3fWS3jyDRlGt0sFTzRq5u2/Y09nzWKiwmBC6+3iDbMhJVRT2oGphL89PBQwAvol1mejtiamWtPGTgjy5rHakWNfhj+JZMtnMiMuwGhTzM04QVPKdo7oCMHIcSPQa070KmNXH6yFvMMq08Q9imnsQoPMsU/MS3wSG8OZB6d0JuN0zSWvCjsK3jpXvt+n4C8H2J6fVdQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b0c5679-7d06-47f4-c297-08dcc8290690 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:31.0104 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zwF8e7dLHq6nq5h4ZNskAimZKpnYmwDkNjwEI+VsgMKZeeHeirY7FDR8AO7YHy+mKFEVLIcQdJNmUHQggHPLFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7425 The bt_bcast_src structure holds information for the BASS Broadcast Audio Receive State characteristic. This commit makes this structure private for shared/bass, since this is the only place where GATT characteristics should be handled. --- src/shared/bass.c | 29 +++++++++++++++++++++++++++++ src/shared/bass.h | 30 +----------------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/shared/bass.c b/src/shared/bass.c index bf739526c..131f978b0 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -78,6 +78,35 @@ struct bt_bass { void *user_data; }; +/* BASS subgroup field of the Broadcast + * Receive State characteristic + */ +struct bt_bass_subgroup_data { + uint32_t bis_sync; + uint32_t pending_bis_sync; + uint8_t meta_len; + uint8_t *meta; +}; + +/* BASS Broadcast Source structure */ +struct bt_bcast_src { + struct bt_bass *bass; + struct gatt_db_attribute *attr; + uint8_t id; + uint8_t addr_type; + bdaddr_t addr; + uint8_t sid; + uint32_t bid; + uint8_t sync_state; + uint8_t enc; + uint8_t bad_code[BT_BASS_BCAST_CODE_SIZE]; + uint8_t num_subgroups; + struct bt_bass_subgroup_data *subgroup_data; + GIOChannel *listen_io; + GIOChannel *pa_sync_io; + struct queue *bises; +}; + typedef void (*bass_notify_t)(struct bt_bass *bass, uint16_t value_handle, const uint8_t *value, uint16_t length, void *user_data); diff --git a/src/shared/bass.h b/src/shared/bass.h index 878bab51a..086fe335e 100644 --- a/src/shared/bass.h +++ b/src/shared/bass.h @@ -8,6 +8,7 @@ */ struct bt_bass; +struct bt_bcast_src; #define NUM_BCAST_RECV_STATES 2 #define BT_BASS_BCAST_CODE_SIZE 16 @@ -32,35 +33,6 @@ struct bt_bass; #define BT_BASS_BIG_ENC_STATE_DEC 0x02 #define BT_BASS_BIG_ENC_STATE_BAD_CODE 0x03 -/* BASS subgroup field of the Broadcast - * Receive State characteristic - */ -struct bt_bass_subgroup_data { - uint32_t bis_sync; - uint32_t pending_bis_sync; - uint8_t meta_len; - uint8_t *meta; -}; - -/* BASS Broadcast Source structure */ -struct bt_bcast_src { - struct bt_bass *bass; - struct gatt_db_attribute *attr; - uint8_t id; - uint8_t addr_type; - bdaddr_t addr; - uint8_t sid; - uint32_t bid; - uint8_t sync_state; - uint8_t enc; - uint8_t bad_code[BT_BASS_BCAST_CODE_SIZE]; - uint8_t num_subgroups; - struct bt_bass_subgroup_data *subgroup_data; - GIOChannel *listen_io; - GIOChannel *pa_sync_io; - struct queue *bises; -}; - /* Broadcast Audio Scan Control Point * header structure */ From patchwork Thu Aug 29 12:49:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 824218 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010048.outbound.protection.outlook.com [52.101.69.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7CE31AE87E for ; Thu, 29 Aug 2024 12:49:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935778; cv=fail; b=bZNzXj+2S0xw5SXURNnyCiU8Q0yCpKlzDkHzD3CCj7p7G0cETnVOo/HcA5oZ0/D+M4vTLsQKL20j9jDe2CuvxlguqIjtWxGFsk4a8KfiFDZMjkDWQUL6CQrS0YkKpy3posD1EKG+iUmMUGzYG7WQuiqWbviyt31zw+6vm0t4aQg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935778; c=relaxed/simple; bh=cK5eRj94DvJJ+vkSFcDaaQt8uMBKkn8Yak0ZuEHGT1M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=k986JbYT2k3D/o+GZiOb4BF9iNeOC5FXL0xAIAAilGM7e19nJixIzCLPwOM7f9n9MIeaqUKhtc4UodZC8Sek7DyEHmHHhtrOEsEyOknV1V53aKftlvz6YIMjwsJM4an+79UqbNvsYcxhIcoIl+eGvdTZ5u2Y6c2nJKsOUPvutZk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=maDmJtAE; arc=fail smtp.client-ip=52.101.69.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="maDmJtAE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tRrKro6YPvCEVTQy5GgN51XLoMKtVvHl8RBWfiMp7rad9ae7U8x30G5HWdZD6XLGfGrRUBs5meQFnZXEeNicRaGkPQ+h4zgKqBRM0cgprsjn/pxnd/aIUn6ZCK31z2wfJh6Fcw98aga6d0QTpN0GhmEC0skZwPi6Cs6u4UVToJKqYbHG6HzN9OJ4+vN8kiTRngsVm6LVniDrce1XWpnZZ4TZsYYowqbtrTpM2VdWbIsmu+WvpyrBJrn5iW5ZdkSXie3Cd4m9aB4NTrhxQNImSndTS2w5DxsJw0rzXocdUv9keqooPIIafFLCfystU+eteT2O30heyP2ENWRWguG9vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HGQvvXv3zJn5kt7g/XqmjGIR5Hs/awBU7QrET2rmmnU=; b=pgnaFcSrhGtrWDDQkVk7xZiMSNkyaHd8aT7ggV16i9K59yYTCsM7vOmRZ2TYcL4/djNz6p12L4bCtEFLrMxH799aRqdv9fICvfm/eqOCioPy5mEsKtawlBAhRP/V28fBsxIxHUZReHy8n4a+9JjPIG8cSH7ZeDf/5MXfaNaHcfomuIA38tTO3O480zvbZoG+es3imGrV9osKbNLufDkmb9ziqjRZaFJ4MdjNyzfz9Vbhxugo8wc2j6BeW8kQEnDuRcL0rpN1tNu2IVCxuhYxTt5a4/PWUuN+4p4xf1qkeHKAHZ8nyowSQNZtTVYI1hGzaTxvDlOPrppIjZjmKxxwog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HGQvvXv3zJn5kt7g/XqmjGIR5Hs/awBU7QrET2rmmnU=; b=maDmJtAEDwO25MAbzoNhGJRjT/fTNVlE43pOYGiw6I8Qy7HX6Vp6FeD2fCGOPIviZZt/r+ATst8NHCeBk/FLrViivckjpmnB/9VzGCtqxulbfQELVjFlxVVu7PsZpHnIcScVr3Xqmhs3YO7eAr8zOyMmhyrAJ8m7Y7qISRsMtXPcaMOo40Zy2dHoLvIzQN8HgNTPFGTyKBcCEcaXhViwyJ2plZHeiCHDtz8hd38hp1MikqP/Gr+aSqGo1VuU0YQSFK5DbWXZWqbdBWqb3tZ+gu3jWHDaNk9XOsV9fcbXqQIvnofWpb9TNAIzoeOCSf4aQRzDaRggQdt5O5Z6MQqRgw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7425.eurprd04.prod.outlook.com (2603:10a6:20b:1d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27; Thu, 29 Aug 2024 12:49:34 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:33 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 03/16] shared/bass: Remove io handling Date: Thu, 29 Aug 2024 15:49:05 +0300 Message-Id: <20240829124918.84809-4-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM9P192CA0025.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::30) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: ffbd7cff-a19d-4ecd-2d42-08dcc829084a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: 8iqGosSsAYZE8DbkVvzKD+eloKmihALrzG0+TauU/bjj4pwp8+NZ3oVIIgjtN8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/llP1v4B52OS73kC0RT/v8+iBIWM8QfKfBcBffHRRJMVDZo3l4hmEzc20Jaoiss+ou8Un+Y752QgR1B5HYu4Kwbm6N5r4L9sESSjGBDsARIfyVInCXpB6pSvCEgaPkJKckg0vgCk8QMcNSfYZ0K+bo/kyPltOPBOpC2djlV0SegM9TwyTFWVVpxhJaZfjNIRBkHcKDGx0/2ywhxCwqa6ByW40la5Z1b9fA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cg9XIerjgv2GGNmZ5P/3GmV9PM0m0m0SQUk8aLpMccOWN4mMzXmA/tmvmmfRd6GYkSS6WsyijEGnY0cdnqZmRJtuH7D0vUlqpRsHUPQtY0mYUhIW8ZJyYR1nzDU7jJWMTh06UpUy3CKnFCloN5rdprcdzTXL3TyP9OVRzF+2ANKV96qoEtswewdXUrIG+1KTkwq/U5VgSZsFYNHSqMmg01jbegNJ/1U/guk8mmwwkeKlJLTbznjggn5pOiWGmnUcRQ6A2pxFpeGB0aA+80MFJ0GNlMAd0r6XqGPb/Tr2FayuFqU9oE7XIme+x7X6bGbUkyu6ag81tcFIxJ+UB6R6qKIkkdbOetXs1YTsEcuaWHObmJdJmbZ8rAOhbah6/BF2qKzqeJQGabNzkLJ01v8jWXFdXFCjl3dh6SKI2Yod3qgQ1BFQDQvRZTuKQHrKFGpOPGMHLBpkhzHYZsGr/FeJBjcBrbqcrvSZoFmG2oh1lFe863+SVkNDA01KrPZjhWo/JG+TfPzGk6BM7MAH7tWF9iR40vQfxst9mWYcII7Yf8XraqqRRCyfSYq4cKXDUT/Gq7C4kJczwBbVIQIUCf8+yB2sZkTpfhE76egJKJSEExifkNQu4eTSUI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exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:33.9632 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YmkmYp2iExG60/2m0DifcbII7HFUSYMbyIh5fd12XtpDQsQ7rLb8HpqHQSJ3mgci6d9n2Fa+lf7c58q+ZPaHWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7425 Socket connect/listen procedures should not be handled inside src/shared. The BASS plugin should be the one to handle these socket operations. This removes IO handling from shared/bass. --- src/shared/bass.c | 315 +--------------------------------------------- 1 file changed, 2 insertions(+), 313 deletions(-) diff --git a/src/shared/bass.c b/src/shared/bass.c index 131f978b0..636eb24fd 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -14,13 +14,9 @@ #include #include #include -#include #include "lib/bluetooth.h" #include "lib/uuid.h" -#include "lib/iso.h" - -#include "btio/btio.h" #include "src/shared/queue.h" #include "src/shared/util.h" @@ -29,8 +25,6 @@ #include "src/shared/gatt-client.h" #include "src/shared/bass.h" -#define MAX_BIS_BITMASK_IDX 31 - #define DBG(_bass, fmt, arg...) \ bass_debug(_bass, "%s:%s() " fmt, __FILE__, __func__, ## arg) @@ -102,9 +96,6 @@ struct bt_bcast_src { uint8_t bad_code[BT_BASS_BCAST_CODE_SIZE]; uint8_t num_subgroups; struct bt_bass_subgroup_data *subgroup_data; - GIOChannel *listen_io; - GIOChannel *pa_sync_io; - struct queue *bises; }; typedef void (*bass_notify_t)(struct bt_bass *bass, uint16_t value_handle, @@ -122,35 +113,6 @@ static struct queue *bass_db; static struct queue *bass_cbs; static struct queue *sessions; -#define DEFAULT_IO_QOS \ -{ \ - .interval = 10000, \ - .latency = 10, \ - .sdu = 40, \ - .phy = 0x02, \ - .rtn = 2, \ -} - -static struct bt_iso_qos default_qos = { - .bcast = { - .big = BT_ISO_QOS_BIG_UNSET, - .bis = BT_ISO_QOS_BIS_UNSET, - .sync_factor = 0x07, - .packing = 0x00, - .framing = 0x00, - .in = DEFAULT_IO_QOS, - .out = DEFAULT_IO_QOS, - .encryption = 0x00, - .bcode = {0x00}, - .options = 0x00, - .skip = 0x0000, - .sync_timeout = BT_ISO_SYNC_TIMEOUT, - .sync_cte_type = 0x00, - .mse = 0x00, - .timeout = BT_ISO_SYNC_TIMEOUT, - } -}; - struct bt_bass_src_changed { unsigned int id; bt_bass_src_func_t cb; @@ -646,115 +608,6 @@ static bool bass_src_attr_match(const void *data, const void *match_data) return (bcast_src->attr == attr); } -static gboolean check_io_err(GIOChannel *io) -{ - struct pollfd fds; - - memset(&fds, 0, sizeof(fds)); - fds.fd = g_io_channel_unix_get_fd(io); - fds.events = POLLERR; - - if (poll(&fds, 1, 0) > 0 && (fds.revents & POLLERR)) - return TRUE; - - return FALSE; -} - -static void bass_bis_unref(void *data) -{ - GIOChannel *io = data; - - g_io_channel_unref(io); -} - -static void connect_cb(GIOChannel *io, GError *gerr, - gpointer user_data) -{ - struct bt_bcast_src *bcast_src = user_data; - struct iovec *notif; - int bis_idx; - int i; - - /* Keep io reference */ - g_io_channel_ref(io); - queue_push_tail(bcast_src->bises, io); - - for (i = 0; i < bcast_src->num_subgroups; i++) { - struct bt_bass_subgroup_data *data = - &bcast_src->subgroup_data[i]; - - for (bis_idx = 0; bis_idx < MAX_BIS_BITMASK_IDX; bis_idx++) { - if (data->pending_bis_sync & (1 << bis_idx)) { - data->bis_sync |= (1 << bis_idx); - data->pending_bis_sync &= ~(1 << bis_idx); - break; - } - } - - if (bis_idx < MAX_BIS_BITMASK_IDX) - break; - } - - for (i = 0; i < bcast_src->num_subgroups; i++) { - if (bcast_src->subgroup_data[i].pending_bis_sync) - break; - } - - /* If there are still pending bises, wait for their - * notifications also before sending notification to - * client - */ - if (i != bcast_src->num_subgroups) - return; - - /* All connections have been notified */ - if (check_io_err(io)) { - DBG(bcast_src->bass, "BIG sync failed"); - - /* Close all connected bises */ - queue_destroy(bcast_src->bises, bass_bis_unref); - bcast_src->bises = NULL; - - /* Close listen io */ - g_io_channel_shutdown(bcast_src->listen_io, TRUE, NULL); - g_io_channel_unref(bcast_src->listen_io); - bcast_src->listen_io = NULL; - - /* Close pa sync io */ - if (bcast_src->pa_sync_io) { - g_io_channel_shutdown(bcast_src->pa_sync_io, - TRUE, NULL); - g_io_channel_unref(bcast_src->pa_sync_io); - bcast_src->pa_sync_io = NULL; - } - - for (i = 0; i < bcast_src->num_subgroups; i++) - bcast_src->subgroup_data[i].bis_sync = - BT_BASS_BIG_SYNC_FAILED_BITMASK; - - /* If BIG sync failed because of an incorrect broadcast code, - * inform client - */ - if (bcast_src->enc == BT_BASS_BIG_ENC_STATE_BCODE_REQ) - bcast_src->enc = BT_BASS_BIG_ENC_STATE_BAD_CODE; - } else { - if (bcast_src->enc == BT_BASS_BIG_ENC_STATE_BCODE_REQ) - bcast_src->enc = BT_BASS_BIG_ENC_STATE_DEC; - } - - /* Send notification to client */ - notif = bass_parse_bcast_src(bcast_src); - if (!notif) - return; - - gatt_db_attribute_notify(bcast_src->attr, - notif->iov_base, notif->iov_len, - bt_bass_get_att(bcast_src->bass)); - - free(notif->iov_base); - free(notif); -} - static bool bass_trigger_big_sync(struct bt_bcast_src *bcast_src) { for (int i = 0; i < bcast_src->num_subgroups; i++) { @@ -769,73 +622,6 @@ static bool bass_trigger_big_sync(struct bt_bcast_src *bcast_src) return false; } - -static void confirm_cb(GIOChannel *io, gpointer user_data) -{ - struct bt_bcast_src *bcast_src = user_data; - int sk, err; - socklen_t len; - struct bt_iso_qos qos; - struct iovec *notif; - GError *gerr = NULL; - - if (check_io_err(io)) { - DBG(bcast_src->bass, "PA sync failed"); - - /* Mark PA sync as failed and notify client */ - bcast_src->sync_state = BT_BASS_FAILED_TO_SYNCHRONIZE_TO_PA; - goto notify; - } - - bcast_src->sync_state = BT_BASS_SYNCHRONIZED_TO_PA; - bcast_src->pa_sync_io = io; - g_io_channel_ref(bcast_src->pa_sync_io); - - len = sizeof(qos); - memset(&qos, 0, len); - - sk = g_io_channel_unix_get_fd(io); - - err = getsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len); - if (err < 0) { - DBG(bcast_src->bass, "Failed to get iso qos"); - return; - } - - if (!qos.bcast.encryption) { - /* BIG is not encrypted. Try to synchronize */ - bcast_src->enc = BT_BASS_BIG_ENC_STATE_NO_ENC; - - if (bass_trigger_big_sync(bcast_src)) { - if (!bt_io_bcast_accept(bcast_src->pa_sync_io, - connect_cb, bcast_src, NULL, &gerr, - BT_IO_OPT_INVALID)) { - DBG(bcast_src->bass, "bt_io_bcast_accept: %s", - gerr->message); - g_error_free(gerr); - } - return; - } - - goto notify; - } - - /* BIG is encrypted. Wait for Client to provide the Broadcast_Code */ - bcast_src->enc = BT_BASS_BIG_ENC_STATE_BCODE_REQ; - -notify: - notif = bass_parse_bcast_src(bcast_src); - if (!notif) - return; - - gatt_db_attribute_notify(bcast_src->attr, - notif->iov_base, notif->iov_len, - bt_bass_get_att(bcast_src->bass)); - - free(notif->iov_base); - free(notif); -} - static struct bt_bass *bass_get_session(struct bt_att *att, struct gatt_db *db, const bdaddr_t *adapter_bdaddr) { @@ -922,13 +708,7 @@ static void bass_handle_add_src_op(struct bt_bass *bass, uint8_t src_id = 0; struct gatt_db_attribute *attr; uint8_t pa_sync; - GIOChannel *io; - GError *err = NULL; - struct bt_iso_qos iso_qos = default_qos; - uint8_t num_bis = 0; - uint8_t bis[ISO_MAX_NUM_BIS]; struct iovec *notif; - uint8_t addr_type; gatt_db_attribute_write_result(attrib, id, 0x00); @@ -945,8 +725,6 @@ static void bass_handle_add_src_op(struct bt_bass *bass, queue_push_tail(bass->ldb->bcast_srcs, bcast_src); - memset(bis, 0, ISO_MAX_NUM_BIS); - bcast_src->bass = bass; /* Map the source to a Broadcast Receive State characteristic */ @@ -1028,18 +806,6 @@ static void bass_handle_add_src_op(struct bt_bass *bass, util_iov_pull_le32(iov, &data->pending_bis_sync); - if (data->pending_bis_sync != BIS_SYNC_NO_PREF) - /* Iterate through the bis sync bitmask written - * by the client and store the bis indexes that - * the BASS server will try to synchronize to - */ - for (int bis_idx = 0; bis_idx < 31; bis_idx++) { - if (data->pending_bis_sync & (1 << bis_idx)) { - bis[num_bis] = bis_idx + 1; - num_bis++; - } - } - data->meta_len = *(uint8_t *)util_iov_pull_mem(iov, sizeof(data->meta_len)); if (!data->meta_len) @@ -1054,38 +820,7 @@ static void bass_handle_add_src_op(struct bt_bass *bass, } if (pa_sync != PA_SYNC_NO_SYNC) { - /* Convert to three-value type */ - if (bcast_src->addr_type) - addr_type = BDADDR_LE_RANDOM; - else - addr_type = BDADDR_LE_PUBLIC; - - /* If requested by client, try to synchronize to the source */ - io = bt_io_listen(NULL, confirm_cb, bcast_src, NULL, &err, - BT_IO_OPT_SOURCE_BDADDR, - &bass->ldb->adapter_bdaddr, - BT_IO_OPT_DEST_BDADDR, - &bcast_src->addr, - BT_IO_OPT_DEST_TYPE, - addr_type, - BT_IO_OPT_MODE, BT_IO_MODE_ISO, - BT_IO_OPT_QOS, &iso_qos, - BT_IO_OPT_ISO_BC_SID, bcast_src->sid, - BT_IO_OPT_ISO_BC_NUM_BIS, num_bis, - BT_IO_OPT_ISO_BC_BIS, bis, - BT_IO_OPT_INVALID); - - if (!io) { - DBG(bass, "%s", err->message); - g_error_free(err); - goto err; - } - - bcast_src->listen_io = io; - g_io_channel_ref(bcast_src->listen_io); - - if (num_bis > 0 && !bcast_src->bises) - bcast_src->bises = queue_new(); + /* TODO: call BASS plugin callback to establish PA/BIG sync */ } else { for (int i = 0; i < bcast_src->num_subgroups; i++) bcast_src->subgroup_data[i].bis_sync = @@ -1125,10 +860,6 @@ static void bass_handle_set_bcast_code_op(struct bt_bass *bass, { struct bt_bass_set_bcast_code_params *params; struct bt_bcast_src *bcast_src; - int sk, err; - socklen_t len; - struct bt_iso_qos qos; - GError *gerr = NULL; struct iovec *notif; /* Get Set Broadcast Code command parameters */ @@ -1164,37 +895,7 @@ static void bass_handle_set_bcast_code_op(struct bt_bass *bass, return; } - /* Try to sync to the source using the - * received broadcast code - */ - len = sizeof(qos); - memset(&qos, 0, len); - - if (!bcast_src->pa_sync_io) - return; - - sk = g_io_channel_unix_get_fd(bcast_src->pa_sync_io); - - err = getsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len); - if (err < 0) { - DBG(bcast_src->bass, "Failed to get iso qos"); - return; - } - - /* Update socket QoS with Broadcast Code */ - memcpy(qos.bcast.bcode, params->bcast_code, BT_BASS_BCAST_CODE_SIZE); - - if (setsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, - sizeof(qos)) < 0) { - DBG(bcast_src->bass, "Failed to set iso qos"); - return; - } - - if (!bt_io_bcast_accept(bcast_src->pa_sync_io, connect_cb, - bcast_src, NULL, &gerr, BT_IO_OPT_INVALID)) { - DBG(bcast_src->bass, "bt_io_bcast_accept: %s", gerr->message); - g_error_free(gerr); - } + /* TODO: Call BASS plugin callback to sync with required BIS */ } #define BASS_OP(_str, _op, _size, _func) \ @@ -1378,18 +1079,6 @@ static void bass_bcast_src_free(void *data) free(bcast_src->subgroup_data); - if (bcast_src->listen_io) { - g_io_channel_shutdown(bcast_src->listen_io, TRUE, NULL); - g_io_channel_unref(bcast_src->listen_io); - } - - if (bcast_src->pa_sync_io) { - g_io_channel_shutdown(bcast_src->pa_sync_io, TRUE, NULL); - g_io_channel_unref(bcast_src->pa_sync_io); - } - - queue_destroy(bcast_src->bises, bass_bis_unref); - free(bcast_src); } From patchwork Thu Aug 29 12:49:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 823626 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010048.outbound.protection.outlook.com [52.101.69.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45FD61AE86F for ; Thu, 29 Aug 2024 12:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935780; cv=fail; b=d7Pc0siDRArkYmqdElb0bNFWc+Ej5bPXe//bRVgI78yMQM1xOPBX+Q3de4Qz48icvUsbLVzxJiN7S37ril0LYMH2LsRbil0ZMKwiGmDC48wgS0wJwFvaB88Vxoo7R3aYjtXWQHYn2y1vQa8cB/RS5O3JmB3m94C9rxp6I+CSO7I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935780; c=relaxed/simple; bh=bYtobMeCi93vQcLNCsgOIgdTn8jo1PkkdCVk58WJKQY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=lp1ppg2mwFaldziUiI6wFnIvkV8SrCq644W/xUNntTKxb0XI1156SbZS797SEdRNZtLS5OHky5OF358m+6ezuQtj5GmIVhoZIvnvkVUE3d5h9NDHIWMhrKAxDkqt7bCKhqWHDOSfsbsZ154E5ZaZCKE1+mwM1srL/spzEPCVaaQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=SRuazCjQ; arc=fail smtp.client-ip=52.101.69.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="SRuazCjQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g2Ve0NaLB3i1VFvisyzyaJPWXN+Rvdt9a5dnle0zTSlA3h48zOkRoIEArT0epWvD82ykFsoQ+B+Anu8fdy5dR1XgFZXRENmUbO8SnmGANl7yTfFWpouYpkBVcdYkr4wJNVkndRWtB2VG6JgJ6gv2XrYt4bi35vXbkq8OtyIqUWSfS5XsFTXCgpWyf7DJQdo6bsh2RRfG2HAj1UUL/p2j9MpiD0YvMq03lJsfrCOM8NEFSQgLVYmIOLEVX/B8gM01blEUkLWLrgvqhQOUpKWGd4xLeMJsaSZ/rIUBYqLREf6TvOO6AK3IbiLlrLzJcD+dMFZ9y4vgKyi9SlsXSpjenQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hgP1XS9qydvy8vPz2ZQts0LN3mcAD17o4NCBn7CUkYU=; b=uwN0QbXvVtf2sXfjvDPFP59pz/u4qJExcIT+AvN/DHaS5JG624xOMqJu2WPma0qAXNVZ5pQajJvgKjdQcYKmZw+ESqttfP941e/psIMTMiCeoGJzLArW+8rmFa4riM3mcVuiolI+NSvaR7Uy6NgmtY0GIpc/MNCvb74EQ88lbDN7CWBMINeOkNpgpLYREwrBvb9Kt1ZA4SYINona2MVN25MnVxaEzE8Ugx+ua23EqrYG/Z4pgpGZgaazK493OvfA8AyewSJEaEZUFYKlgOE1m0FdY1LyMWxPmDRlrnny6Xr42AlcOhnhFLnJz+mPXo3hjXTO8njSF9BIkZq4HD/mTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hgP1XS9qydvy8vPz2ZQts0LN3mcAD17o4NCBn7CUkYU=; b=SRuazCjQZK+QFnkj6WIHwGLY2TjsWZUdsid1MJWvxSY98bOP92W8fW8W0P3VQ9g2lXTl6GAwmFQ5n+Qbha8oC57it2KIqJ7DOpbPpy1jzr4Iuq9dd4nLwsjsWmFjNrFlUWedVJherpadc6giUYrAVYrT/ccQV3FLpPtCM0KhMcUhPUtctX0iNiSH2399Vb+Hjg9zUW7q5rvFOMs8Qu0vD3Hi1cEMytw0cdbhyElvR9GjW++sNb9wuVZTaAvY7it1LqVDUYjEz58XdybzoP/t1tBvvGQ3D2gfk39pSe1V6gSk6pDoyIAXuLbYPjRKgJCfSN1+ZOGqp7J+8W5OmJ4QeA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7425.eurprd04.prod.outlook.com (2603:10a6:20b:1d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27; Thu, 29 Aug 2024 12:49:36 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:36 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 04/16] shared/bass: Add support to register cp handlers Date: Thu, 29 Aug 2024 15:49:06 +0300 Message-Id: <20240829124918.84809-5-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM0PR04CA0103.eurprd04.prod.outlook.com (2603:10a6:208:be::44) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: cb359fc0-1a37-431e-76ba-08dcc8290a08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: QMOuNGmO2KVIexvJl5PG9Ck2K7d6X3+GjfJtbduL5qzdjYZn8dkovGQ48uOP6/x7LJTZet/KTTKK0AxQjMZSp3uJG267+TZE2m7qf7Muc1OTIBBZSi5MR5QL51OrcEorxwohtmGLjYmljYAgtzm0OUFxMonJvdrJ1naHKAnbVF36QHY1VyPBXWxngtHVHmAAKJmMtPJyJmoqowid37SLEzg2+/xIK8XlhRS8OPEncot1dALPhORw+uHY6O2iwlLGkYs/GbQGO7PFDjZmTczN/SxA4bDRb5DvPNk1hEdF/2DOImALPIrjuIWezC9dxd1OKlF6wvOhdH9wL07RgiuKBYQEIBXoq8X62sN2EIYkdM9DuDKqMQ1ov5ZK8jycj5cazKGwVPwRJFM2r43RHWYn9Zi9uvKjEZqIVLUVouICUCwmVj4+XFTqwQ2UUssmk6KFhPd3JRig8Be0/o20ccA4woyeY9eHVG51qpo51nxauLhjD+8ODYOJHSje2exe9O2outvLTOpmYv0IJ+jcFhBFEao7CNX5VKW6sNyAufn7pEe9/Wb2Peib4jKM6EGt9+NByPTI/51kjq29z+gN7S82j7McyxTs1vX2jTFpAu7A4ZCKPp5nAVis59Jur7p5EaTe9pTlFex0EuwX458uAgVkLz6AdMSxdiIScct+54g4hJInJ4y6gtj60Ub/sfhbCJjgyq0CVf4PAnnwzwW3rIRHpb+LlFMleJrKRrV+Zazd1lu2JApOviEkn96x4nmo/q9GYGEJa3U8tzeC1Z8ocj4A+dodfnWyDQJr05E2lXP9yhvlHI8Hx1sQvYc4xfDUKPlXrLXz23JPs7YfX6/Lzn0JprTifZa3UWQKVefGmrsXf8uwwulVJtBPdzprjxkM7qKoFwkh56ZHciMiNarWAZdICtRm2iDTQQ7QaCh13CyM1xBO6LXovgSz29E1VA2spSAgiR+610C5TKjjHyUbOLM/Z8+/wrsEBzO+wPqqHUqtcaM2H2pQKYJgZ3N/OZ1QbRZS3Cs6jBebWOXKgQzTIZNaGfO7+kFbIkDidTGzGDofTtJD9x2IOpVFlDbGtm0X6tP3x+EikEr3QXnzlzu8TseArjVVefiLI6deLH2XRefpxQPHTIgfLM9czZztIR5p4iXauAnhEG5XJSGmiINCS0F7O7biBii7Y0qw7LSVzWZfOXJYiY9suEu6CwN/lKD1DH44TmgECbGO3ZOGoPmTdNPNbRumJhtgE9XzCQObI+roGJyB/+M1iRASFuCkOvXUIQ1GGZaJ0c8ck+FabBq+JemY2IrCr0kE6wcPt9/yX9v+zqncwPSjfFi52EAlfIDEqJA2CcfQMjfluacldsThjVbotA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NBA3hA7vAXMdZqOsvvK9Pas1+X9m0EMv9TwyQ3gYnxV2/brqMX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01qvgzH2ahlvTHi/1TNq97uLrm6gIyMBVtnTY/Wm70T8Wf2mwRXZwRxiPNHApWfXtgfVrOLmrYOmjznl8k5yeAdzC9bVtAS0Y/6fDG2ablNL7pIwcxh0VVZm+RFrk76rSEpoZ/9UXFn5K8P8Iif1ytLtmtJJEiackscPUjpqs5UUg45u8sRJIUOOw5DQXwriYnyrIt3d/lNwLHOU7qBaMl8JUAALb96cK0vC0BcP3nD8ybbH9ourTPfDXA4PWfNfLheDTajFL+iPa8DUkr5tEg0Lb4F8vDaSiexLH37BxC95P64ySGGkq2lL9zBhWKWjqN+U/2/mc4NsR20FaZ4NeFPyfqsSYeXGvO7pr8XWKqkHUuI5b2+8P8+WbQNCSFChdQVRJwECz9Ybhb2qpeYhx93e7eAShbNWaWB2olI/hIphQM9TeW7V7CsDOX+HOJUch1Lt08lp+rtYb0Cvh9ZK0hT0aQNB3Vws1F4JpNnMkyYk5/WZPVMrz5pgt+zHxxQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb359fc0-1a37-431e-76ba-08dcc8290a08 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:36.8291 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NRiyVYhdNiZ1iibgSPLhv7XGzjYCgTJzHa4xI9XJtnbm3TNTyQyXuGPwVPtf1/2fbn6rO3IdlaocQdD753uW7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7425 The BASS Broadcast Audio Scan Control Point characteristic defines a number of commands that require the BASS Server to sync to Broadcasters. This should be handled inside the BASS plugin. This commit adds shared/bass APIs to register control point handlers with bt_bass. The BASS plugin will use these APIs to register a control point callback to handle each operation based on opcode and parameters. --- src/shared/bass.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++ src/shared/bass.h | 9 +++++++ 2 files changed, 77 insertions(+) diff --git a/src/shared/bass.c b/src/shared/bass.c index 636eb24fd..635fe1054 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -66,12 +66,20 @@ struct bt_bass { void *debug_data; struct queue *src_cbs; + struct queue *cp_handlers; unsigned int disconn_id; void *user_data; }; +struct bt_bass_cp_handler { + unsigned int id; + bt_bass_cp_handler_func_t handler; + bt_bass_destroy_func_t destroy; + void *data; +}; + /* BASS subgroup field of the Broadcast * Receive State characteristic */ @@ -134,6 +142,64 @@ static void bass_debug(struct bt_bass *bass, const char *format, ...) va_end(ap); } +unsigned int bt_bass_cp_handler_register(struct bt_bass *bass, + bt_bass_cp_handler_func_t handler, + bt_bass_destroy_func_t destroy, + void *user_data) +{ + struct bt_bass_cp_handler *cb; + static unsigned int id; + + if (!bass) + return 0; + + cb = new0(struct bt_bass_cp_handler, 1); + cb->id = ++id ? id : ++id; + cb->handler = handler; + cb->destroy = destroy; + cb->data = user_data; + + queue_push_tail(bass->cp_handlers, cb); + + return cb->id; +} + +static void bass_cp_handler_free(void *data) +{ + struct bt_bass_cp_handler *cb = data; + + if (cb->destroy) + cb->destroy(cb->data); + + free(cb); +} + +static bool match_cb_id(const void *data, const void *match_data) +{ + const struct bt_bass_cp_handler *cb = data; + unsigned int id = PTR_TO_UINT(match_data); + + return (cb->id == id); +} + +bool bt_bass_cp_handler_unregister(struct bt_bass *bass, + unsigned int id) +{ + struct bt_bass_cp_handler *cb; + + if (!bass) + return false; + + cb = queue_remove_if(bass->cp_handlers, match_cb_id, + UINT_TO_PTR(id)); + if (!cb) + return false; + + bass_cp_handler_free(cb); + + return true; +} + unsigned int bt_bass_src_register(struct bt_bass *bass, bt_bass_src_func_t cb, void *user_data, bt_bass_destroy_func_t destroy) { @@ -1418,6 +1484,7 @@ static void bass_free(void *data) bass_db_free(bass->rdb); queue_destroy(bass->notify, NULL); queue_destroy(bass->src_cbs, bass_src_changed_free); + queue_destroy(bass->cp_handlers, bass_cp_handler_free); free(bass); } @@ -1513,6 +1580,7 @@ struct bt_bass *bt_bass_new(struct gatt_db *ldb, struct gatt_db *rdb, bass->ldb = db; bass->notify = queue_new(); bass->src_cbs = queue_new(); + bass->cp_handlers = queue_new(); if (!rdb) goto done; diff --git a/src/shared/bass.h b/src/shared/bass.h index 086fe335e..2ca659cca 100644 --- a/src/shared/bass.h +++ b/src/shared/bass.h @@ -99,6 +99,9 @@ typedef void (*bt_bass_debug_func_t)(const char *str, void *user_data); typedef void (*bt_bass_src_func_t)(uint8_t id, uint32_t bid, uint8_t enc, uint32_t bis_sync, void *user_data); +typedef int (*bt_bass_cp_handler_func_t)(struct bt_bcast_src *bcast_src, + uint8_t op, void *params, void *user_data); + struct bt_att *bt_bass_get_att(struct bt_bass *bass); struct bt_gatt_client *bt_bass_get_client(struct bt_bass *bass); unsigned int bt_bass_register(bt_bass_func_t attached, bt_bass_func_t detached, @@ -120,3 +123,9 @@ int bt_bass_send(struct bt_bass *bass, unsigned int bt_bass_src_register(struct bt_bass *bass, bt_bass_src_func_t cb, void *user_data, bt_bass_destroy_func_t destroy); bool bt_bass_src_unregister(struct bt_bass *bass, unsigned int id); +unsigned int bt_bass_cp_handler_register(struct bt_bass *bass, + bt_bass_cp_handler_func_t handler, + bt_bass_destroy_func_t destroy, + void *user_data); +bool bt_bass_cp_handler_unregister(struct bt_bass *bass, + unsigned int id); From patchwork Thu Aug 29 12:49:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 824217 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010050.outbound.protection.outlook.com [52.101.69.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1D3A1B0107 for ; Thu, 29 Aug 2024 12:49:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935785; cv=fail; b=Iz74L4X0OlEbaSlmexqZ26YST8Ugo7e8AvX7efBTrBsTlMjetSOsjPxy2Xirg/XfoI51bCUPtYmRPab5EDzb41jiwY95aMdUcTtq0QtmjeT6Ycchza/LinJjfMFVpyjxSp7srvj77T2O5lujz1wJ+WNwBmCVb2WdDCoKLRTfp4c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935785; c=relaxed/simple; bh=qVwvPqEVtmoByQIKYqZz3r/i4zD018A9/KGme+KSlF4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rCfeQ0JBvESdR+Fb59uYDYkFPULkY+k3TYf3E0haeub+mjmSLZBqpis9GFk74w8HGTUm/A5eJBKt1d0T7tJxVGn0mv9C/WW06sTgxFzGdih1qtJ1Uw3lL2SLOBPuhLPA0sCDmjsyd8LJai8lSi9iZunfbYVh9P8XKZxC9ecqp/0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=LOjjz2L2; arc=fail smtp.client-ip=52.101.69.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="LOjjz2L2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CsmIZKGUCNd7G+67UvPQRuQr0YH8Z5drI+6DOdf1FTvAy0mHeEAAlg4vhHkefsywaBJQVKS10/V+tY2I+D8nwNenwvexJ1msVHKZtebP7kOz03WPEQOnUScnWSL0IfNUULnLPFh0qzxCknJkAkItq6PzggUHFh4Q28RkRilBuHgFPvcYuahUxfSB0MHyfQtZag3izP2c6fIBNGc3M8EUqHVofRFSdpt8tZYcnvvtjDObSmGmNEzJrlBOd8KfRgGqW5t+vuLQ9rKAPcjReF0lZl7xV6lmKsKBN0dWVtHa5W42Bggwvd+kzkhcr2MIrECBUn2QD9Mq8eeWvLrjO9SYgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NjRfIlvAnFlE6NSEczbE4Xh26b3Wp/YThy/UvFlIwMs=; b=DLQSRp81FE2XkLfbpnpWEzexv3AP4LUxC++NCcu7/cRe+0pZ/tDnkGapbzZTRBESoGCquzAFOhSpL2iAcAlQI5hRpN4L2uV+lTtj5rhHO1+kNJWZNi8qSC9kP/ryjhVANL9c/t+PtHfR82a5OPzJPgv4bGV95j980pD6cdigtFxVBFA3BYdGqhDgl0P4QyNRdd83bMBOpvu8BQ3EWabinu/I91cO4FgEA84MHXqVfKlYsB+YT2P8IKRJWBzwPK70wCnBqf5yOjg9Lq23f153rVNne9KCYoA+2RlIu6GtumGpIZwcNjLIS2hiMGsSaUhCziISFOrBfzseDatISOiDug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NjRfIlvAnFlE6NSEczbE4Xh26b3Wp/YThy/UvFlIwMs=; b=LOjjz2L2KIDnnIRRCCoeVp0nfhyHUaqInNQutNTn/dtwBp2dsfdTggkILfXsXrxfmYgrPC0ctv0gk0qDRkqVWzJwI7LBgCR1XudbM1d8D32yFgGwDJ/Rc502sBHID+tVXoZzgGNsr+B1I+Ns6AhO2PBrZw2luH/nHzlW+ifcmTI+YLLKCfajEswPTlrTrqP+RivUtoZ8whD2tvs0//ACRNtpWi55DgRelRqyQytVlr0RJ4QYSa8IcknJh4IhFrBZCo0/zWuP4gTC8kO7RCI1IiukDQwK/lIIdQGaToy6IgSTAbUo0wAiEKZ6IfGTScr6lkoRs35VG9OkaT90O9alMg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7425.eurprd04.prod.outlook.com (2603:10a6:20b:1d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27; Thu, 29 Aug 2024 12:49:40 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:39 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 05/16] shared/bass: Call cp handler for the Add Source cmd Date: Thu, 29 Aug 2024 15:49:07 +0300 Message-Id: <20240829124918.84809-6-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P191CA0003.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d5::18) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ec72e6b-2d86-4e50-3ecd-08dcc8290be4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: zsRH2u6nKQGGaij19LWRkZrzFGFx4vB8njjtrgzHiraPa/8r3xe5kAh/JP9ZzKwiCNaqTTaNsyAbWb+XT3NumaQSlSQQWFJuiAgucf6D0Js8VDBpapUtWliLwdwgiciBBhu55Om3xo6BJSmBsHo2p8ZzimHFrargR9BHRMGlTvRDfSJ8pEEcKdjsUm0dpeCoVelNAQNFpUeuvF+ngB7zw4tqOWSjtr2izhcAvvtPpFuqUn3K+RzaCaLxaH1WRSkWTQO6Rg0Mv8qwVF9Fy5kGqMS5f/HZda1ogihVFV7oSIJ1UoBwqmHAGEdWXsCRjnqDItJr4Y3SVrXMxAtRHPFQ2shKZtNB+IMnpfUAdKvuxEf8t4J6MsEXZJKgotIlxi0rrlUWQYhn7DD1D+mwNfhmG/bMS8IsWrIAcMD4AyFgp87q5Tw7ydQ30kuUWy6yVSzvJZuz9oHJLAzwj6S2X5t1OZBtz37mU2H/5mhAP/w/b/ysCp3Qi4LZZ72swmV8wI3FIae1XGvAuTTxf35uQpRQ3XRZGMT0c4f+Y+Rd7Vq2ScKOcagnfmD2LXOoK3e15sXSu0kaUW0TnlLZtgkWg0RiGoclNNg173fKFAnyvy6RSuxyV1snIt6rYlliR1yXCVwcusUpwsB5gM/zvuYNvCBiHhXEbTBFLjL9A3mDyG51CwBFfTIISm9V46W9e5dK5LjTA6SAMLFsLdxozqmfFgXLHOy2JdkBUfxuwdjUQdByDmk4LWIv8VHEm3ErcT320aQQAFkqa6gNLF2CVuO9XqiUS3taYJou6iBW2S66+uSf4AswwLUhTtsBuEGpjqLxp7U/7idrv72T7edYNOhad4/wM65cQn1Q85zrVtk7d1eDomEhXvopOHAE/1uprLdelFc+PJkAv14Qu7RRjusc1EPXPYEb2SKMtKIx+2aLXKgyqrSw3fzNUJtugwzmP1RbtwFps+z/NcIlw0BQO+7rayfeh4eytMXIMMq/TEFdq8LD2WsWmUvK8ejrlT1GqWd/Lm1JsuRPoZ89OUvkTgKlch1cWIzx6oXcQ85Zn3Ds2scFtlJegNizJQNtIz9nT93PTcv25DjFG0OSXvEYAQfbX532ZPso6ESztOVuBzgZ9F1GJAT+8pHvFKWBiXbw/f/KJn2ZvXK9ji8zF7KzoAO7i0ofVZacait8fBM1+2iiC+m3325gafkNWfcaB6nvE8uQujj7Z8SnIvtN+/8iHfC0RoMSCD4Hi9Y5dYn5jBQNUl6C7HmlU75Qf4L+DZDSO+Zjs2uWKRW3CyKhChxpees3iZhpb/OssAdqg4VQfi99hfhVnUWYSMUt9dTPp+VTb0Iow+t9gprYwqH/SrmTBl7IMeZOug== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LJKSOhUHGY4gbyW98VHwjLyCBSvbZrulROsz+Y0r14iL/Esu0MB1EGB/DBiJOzGWbnw08klCDfs5g/M1MrJzwTcMNKcu4ebG4eYsqUU7BqmKJysUDPABAaAbYV8hKnO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4lVkUZCw93W1yIajD7kgw9bJa/53Dc6456kI94qh7pFtxdlO2L92JFsSCay+EkjvbFBitJZWyj4GRD8KvF/MJBDu5aVYoztRM9hQWlNA5WZPN6OOK45YKD1+xcSF2kCdXLcaN2G7t+uRMz184IOEYsp2Qoke3iCoJmaT+Mpz6eg1rD2nj7QY4q8K1Z8uMky05IUrZsS3ksjRtnfoUEYn37hYjUb02Mlv62gs1r2TF7ymjKXE5mPCNfPeSsTQrfbNS02eNkbaP/qgxuKFCO7qzGtl8VkJHK7jyqQSq3gD9L27hdUulteVNTiqUdNiqwcLSJsMi0ba4G6uFNA4frzRjcIYA+n4bDLWfJEaBCHjKWOQig1hlZ8qYfiHI/kPyMZSyoT5qbb/MpPF5ZWT+eUo11dCxdaEJr9XmUnEgY4n7vw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ec72e6b-2d86-4e50-3ecd-08dcc8290be4 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:39.9281 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TtnYJAheSpSEGa9RajDNYieItkstldfS2JuueotMouqdUsMUM7hvHuUqw0Gt6oVxpIMtVHkRwEL3IQjiKPFn6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7425 This updates the Add Source control point handler inside shared/bass to call the handlers queued inside bt_bass, so the required sync operations will be properly handled by the plugins that registered callbacks. --- src/shared/bass.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/shared/bass.c b/src/shared/bass.c index 635fe1054..70e747700 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -775,6 +775,9 @@ static void bass_handle_add_src_op(struct bt_bass *bass, struct gatt_db_attribute *attr; uint8_t pa_sync; struct iovec *notif; + int ret; + const struct queue_entry *entry; + struct bt_bass_add_src_params *params; gatt_db_attribute_write_result(attrib, id, 0x00); @@ -839,22 +842,25 @@ static void bass_handle_add_src_op(struct bt_bass *bass, bcast_src->id = src_id; + params = util_iov_pull_mem(iov, sizeof(*params)); + /* Populate broadcast source fields from command parameters */ - util_iov_pull_u8(iov, &bcast_src->addr_type); + bcast_src->addr_type = params->addr_type; - bacpy(&bcast_src->addr, (bdaddr_t *)util_iov_pull_mem(iov, - sizeof(bdaddr_t))); + /* Convert to three-value type */ + if (bcast_src->addr_type) + params->addr_type = BDADDR_LE_RANDOM; + else + params->addr_type = BDADDR_LE_PUBLIC; - util_iov_pull_u8(iov, &bcast_src->sid); - util_iov_pull_le24(iov, &bcast_src->bid); + bacpy(&bcast_src->addr, ¶ms->addr); + bcast_src->sid = params->sid; + memcpy(&bcast_src->bid, params->bid, sizeof(params->bid)); - util_iov_pull_u8(iov, &pa_sync); + pa_sync = params->pa_sync; bcast_src->sync_state = BT_BASS_NOT_SYNCHRONIZED_TO_PA; - /* TODO: Use the pa_interval field for the sync transfer procedure */ - util_iov_pull_mem(iov, sizeof(uint16_t)); - - util_iov_pull_u8(iov, &bcast_src->num_subgroups); + bcast_src->num_subgroups = params->num_subgroups; if (!bcast_src->num_subgroups) return; @@ -886,7 +892,18 @@ static void bass_handle_add_src_op(struct bt_bass *bass, } if (pa_sync != PA_SYNC_NO_SYNC) { - /* TODO: call BASS plugin callback to establish PA/BIG sync */ + for (entry = queue_get_entries(bass->cp_handlers); entry; + entry = entry->next) { + struct bt_bass_cp_handler *cb = entry->data; + + if (cb->handler) { + ret = cb->handler(bcast_src, + BT_BASS_ADD_SRC, + params, cb->data); + if (ret) + goto err; + } + } } else { for (int i = 0; i < bcast_src->num_subgroups; i++) bcast_src->subgroup_data[i].bis_sync = From patchwork Thu Aug 29 12:49:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 823625 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010050.outbound.protection.outlook.com [52.101.69.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1620D1B0108 for ; Thu, 29 Aug 2024 12:49:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935788; cv=fail; b=M5Sz5dLCNmDiALquMcJTRy/cm53R7UoGPouXJJX98dk9SxjmzZtZWbbtIboGyfAP1n9E9W1+Bj/KRmH+9gCAxe+YFCDGXTbJb5ZKtiDFYyuIMmeDM1lo3XhL/ej66Yy+0A+uR64a3V2buh9fZN6XWogm7fxMwCQoyy7WjSA6VgQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935788; c=relaxed/simple; bh=ERxG2IDhETKOPb5e7H5IcZXTpeNUeKrSBEgCkSQJI0M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=NHzu+nJ0CnNs1rqFRpO1rT/IX88ocneQicQIwLMcNtVuE/375XIatE4cRDbxrEamGCg4APVXBwlpf5EOVkyoAIp6a/UvE4LBbFr0SQKgQXS22Fg6yii0Fo42+9ha87ksCzO53ZkAgnNhtIhWGU4MqnCyii54oF8/RZW6mniQX6I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Qq8g6V+h; arc=fail smtp.client-ip=52.101.69.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Qq8g6V+h" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PXpuOZRobwz4rAsJX6eipN+9Fkf2cyO+DvkPBL2aRO+13Bgqn11A9RxM5sciB+H1OHeuO0K9pj21XRufKi2QfEE2T6Yk5DkE5J5uKMPCMxvRcP5lS64QGv/ldYFn+CVpfnead1G2QQuDPakAgJ6HqKInROHwD/1s2hvHMrSYWs+T9CE76GXmM2rVwX0DVq2sTks3QLWG0AJTb3b+EGFvED4Dk43uafpsS7Ud0kReqgXNPQitU4YDNTDoWIKOz9Mk2AWJlPugmZiCnUARF0K0oqm4e0nyZWO3QmWkTJK+scn/szdV29f0hTnx5cK7CmZDaW5gZKMmNEC87k8TsvEh5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v+TXB8Kqtf7gWb8IYxE1d5u4Txz4gzc4GMY7zCPjP4k=; b=kVwtyEfORV/aTTsx4EOtQ0BnwaUMHYL0OUhApWHUaXpL1hH93CLsK4hsSxtzCr/gVfJYOgV2Rljy2ghGokz7f1wcmp2s49CpYyqxPNR9HbLeuQsAjDdWPVd+x39kBI+NIlYyz8GLUpdj4e/KoN0iMXo7hYQvNlpV2dptxZJrJzYOJclJEIv5S64w/dowMUWwqqqmLPllXk+kW+I43qURX5L4kKgx/QMEN2xBcA3KAZa2zZBaBiE/zFrNP3dM/aNYay9YSeZ1gD9Ox2nXVxuT8ez5pTqNWK1AuAIXKSnLMpi0qTtn8S3HljWyjQk88P2YHPbRbQSBtiF3SWDorw8tLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v+TXB8Kqtf7gWb8IYxE1d5u4Txz4gzc4GMY7zCPjP4k=; b=Qq8g6V+hwXmLJfTVLSNfwVl12wOIDB7MFy6QPmG9Kc6JhE1hMX9b5hV8by8DYnyMJQKGqBjv8U6H7OQo+JyV+bvuNGpNpAoFo6MyMCAZG+rWWpPQpFT4FjEP0J9fizXhJ4UddXIyKc4fgv0QGXAJgkpWvePwlgqEdNBRZhVaem+798YmsBnymGYCah4u6oM+TYIN7+PJOZ+D2HI1WFUZXTC38nZzq661+nOFlvPeWk5itczVtTfW8u+Q6Y3nsocvq3vdYWmRRZFi1WgzFit3HP1xPewKliX1JwfI/b5Dqwwe0TcgEEiremGYkJppSurYXCzjxgfqMt1LCyBh8BEV0g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7425.eurprd04.prod.outlook.com (2603:10a6:20b:1d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27; Thu, 29 Aug 2024 12:49:42 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:42 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 06/16] bap: Add support for long-lived PA sync Date: Thu, 29 Aug 2024 15:49:08 +0300 Message-Id: <20240829124918.84809-7-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P195CA0046.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:65a::27) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: c132e0ed-ac6d-4fa9-043d-08dcc8290d6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: KGoK6KKdZn/qUig7XJinj3gerA9tALxF9TGF+vwCu2lIaDVpMfHQtdJKDBMbuDm9cp3TykTqDxinM6iFcRqV+Wz1sm/8GvCfGAMNMbaYKt8X0oc4DsQKBLFWsnAMj8mzzlOSHfiyBvZICklCfWGDM0ptF/JxpDAaEhdTGQsLN8T2/8s5sNSCjsQET9gi92gqBH5WG/SmwKrB8wpoCI3sV3lyIat/tjCEIbFQkQ3YDZRQWPEjQA6424UIfEkTZuj+hljBNP/N+59Hg7OUNk8bRLtj7tGTlHiEuLy5taIIv7l102GhK3uTEkUFAP9Q95vqGKUgro1FfNoWs0x1maAu100tY1UTPXn5KemnZqWYMDZyUVGCVQ5GJqA6HA4ZAE87aH8kjH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.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ur0Fu5yyrK2oDAfsJOwqSW5BR5lqm87uROQ3WiskZ4bcTuM+WKMJpQ7iCTAFI27byCVV18QeWnW1Nj4IXP7PG5wv36Uw834HBUYjBkAuNaOsJ54K+zXCH34sp2O1pe5ii/3WOCnMrEg0vAJlzL8smTD/dx18lRid9HO5uLKKiAtA5V765E8D/ylvEs+AheludNOYTraKtsjeZe1QB0lavbdJN2SZiEK+urSJQpdy9qCqDdQLsGKlVqUcRtodFa8iRdUCLS0wcQiKynyF6Fgt9deyo4qWMyvco2e1y5ZUzrnRdsUZ/pVLAdsneVvLlZbwvWGDf8YR2FmhvSKXqHhGDEarSTXGNXItJc2+d/aS7MQfbGO05jAPbLAcsfWwe9jgNTnxfrNnl0l9yB46xCFkLE6l+6TSnowPKvB+SFw7OMlNAme+5BDGSC8NHXnOtHDCmEp4U8rKbikkarAV7lZfvtdVaGT8F0PNy+zO3BImz/EjVS1NUxubT/PCTWKSK1A1T9U5V92Wa8KJMI0TQV23tTFsxPz3zBbxdgPXTyOSeIsxBlvcxxJGHvV49puDBStGXovVj66rlIY40+KdKz80pAB5K8DdvJFEtLbE5apemPPg6smN4D0FyFA37SOly31A0MgTBbeYCKD53HioRPTN0yxHe8y19A+HqcpvWOYXgwYmPMFqE5w1buplHZgzyYKt1a3myQVWQHeBEfMNkQwgw7F03A/mfWzXRaYkqx10ZKliUaaF5yse+tKBqAGMv3ak0zGdy9cV7CP8Eo7p5RKeRRSxjMOBF9b7YNS3WqiYpEEAhA//a8vCqi4BnedUOWeQ0uFR74qMZm13BnWhFE6ZP1oYtCmuxI5FlvJQeJMoCRpeCYE7I7JZxHuJ66w914bGPuuadMOvrFtVYyWeL5Xn1ZBQ409JjZxBIb9eSso1mhq7yMNzdb5N9JuVt7PoPpuntSvWoBbYCFy4Rc/lazG4F1td9Bic/QxHtfOyKwpl0eBDZtEShOvaVtFAIsFmkLbiGbsmrnXYN/OOx1VoDyoaXjaWzCSN8xddaN6iuy7GKpBald2NYJW8ZG872ukHn5WN0ceXUuZ2TjzPTjjDUazapfrpA74xg4s8UCKzDpFce7xCvfB4sdLh/+eenmV7O3cUllRiLFYYyVCV9fUbbkM8lmwhpgq3GYckDNwE/LFdEpp6Q0I//D7DgD4bJIEihuF2vv5kekwU3+cqA1WylzqYx8ZUNK+4MkuD+/16rlANEL8mdJff+Sr4zDdKPsPTXLUygflzw89f+t2M38LgG3byXnBXmrWhf4oH8qmDPE4iP0uyU9QWTUdRiAMeofsjvKzsnZK6x6mxGwESjVTgOziwxEOr1evAofBcG5iSX63zXp6u7/zDrbxQ935YaFhVnG/FJ6FeI8k709v+yOyiAKhz9nBl2EQQF6ovbP4sL1WvLrrk9C7Hg8Lh2bH0oMmS5XtF3iOjmEX3NsXcNGUqedF4O/RJUneccv+L4f1iB00UImvTECv4k/Ck1+dFFwKx043/Ao6e2SGH/Wzn/0tvT+rCfS14RNniR/XYzt+ZKAjOaUtJxORXlX2mchHrvswTyBLlUNsO9s/jxEHg+JVB0ezVVw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c132e0ed-ac6d-4fa9-043d-08dcc8290d6d X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:42.6279 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: u0Zxj0gE7HR7biCoyvlGYsgGHmuYDhmzrslpzAWbTIttERqRI0cHG+MJpiaeW8V6boYPuvoAA/VuczNXTzbkhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7425 This adds BAP support for long-lived PA sync. A BAP Broadcast Sink might probe Broadcasters autonomoulsy (by performing short-lived PA sync to parse the BASE and discover streams), or it might act as a Scan Delegator, probing Broadcasters added by a Broadcast Assistant. If the Assistant requested the Delegator to establish PA sync with a Broadcaster, the PA sync should be long-lived (it should remain active until requested otherwise by the Assistant). --- profiles/audio/bap.c | 64 +++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index a2c5a546d..76171eae7 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -127,6 +127,7 @@ struct bap_data { enum { BAP_PA_SHORT_REQ = 0, /* Request for short PA sync */ + BAP_PA_LONG_REQ, /* Request for long PA sync */ BAP_PA_BIG_SYNC_REQ, /* Request for PA Sync and BIG Sync */ }; @@ -1004,9 +1005,11 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) DBG("BIG Sync completed"); - g_io_channel_unref(setup->io); - g_io_channel_shutdown(setup->io, TRUE, NULL); - setup->io = NULL; + if (setup->io) { + g_io_channel_unref(setup->io); + g_io_channel_shutdown(setup->io, TRUE, NULL); + setup->io = NULL; + } /* This device is no longer needed */ btd_service_connecting_complete(bap_data->service, 0); @@ -1255,12 +1258,24 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, return FALSE; } - /* Close the io and remove the queue request for another PA Sync */ + /* Close the listen io */ g_io_channel_shutdown(data->listen_io, TRUE, NULL); g_io_channel_unref(data->listen_io); - g_io_channel_shutdown(io, TRUE, NULL); data->listen_io = NULL; + if (req->type == BAP_PA_LONG_REQ) { + /* If long-lived PA sync was requested, keep a reference + * to the PA sync io to keep the sync active. + */ + data->listen_io = io; + g_io_channel_ref(io); + } else { + /* For short-lived PA, the sync is no longer needed at + * this point, so the io can be closed. + */ + g_io_channel_shutdown(io, TRUE, NULL); + } + /* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities */ @@ -2192,7 +2207,7 @@ static void check_pa_req_in_progress(void *data, void *user_data) *((bool *)user_data) = TRUE; } -static int short_lived_pa_sync(struct bap_bcast_pa_req *req); +static int pa_sync(struct bap_bcast_pa_req *req); static void pa_and_big_sync(struct bap_bcast_pa_req *req); static gboolean pa_idle_timer(gpointer user_data) @@ -2210,7 +2225,11 @@ static gboolean pa_idle_timer(gpointer user_data) switch (req->type) { case BAP_PA_SHORT_REQ: DBG("do short lived PA Sync"); - short_lived_pa_sync(req); + pa_sync(req); + break; + case BAP_PA_LONG_REQ: + DBG("do long lived PA Sync"); + pa_sync(req); break; case BAP_PA_BIG_SYNC_REQ: DBG("do PA Sync and BIG Sync"); @@ -2236,8 +2255,8 @@ static void setup_accept_io_broadcast(struct bap_data *data, struct bap_bcast_pa_req *req = new0(struct bap_bcast_pa_req, 1); struct bap_adapter *adapter = data->adapter; - /* Timer could be stopped if all the short lived requests were treated. - * Check the state of the timer and turn it on so that this requests + /* Timer could be stopped if all other requests were treated. + * Check the state of the timer and turn it on so that this request * can also be treated. */ if (adapter->pa_timer_id == 0) @@ -2980,7 +2999,7 @@ static void bap_detached(struct bt_bap *bap, void *user_data) bap_data_remove(data); } -static int short_lived_pa_sync(struct bap_bcast_pa_req *req) +static int pa_sync(struct bap_bcast_pa_req *req) { struct btd_service *service = req->data.service; struct bap_data *data = btd_service_get_user_data(service); @@ -3030,10 +3049,13 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) const char *strbis = NULL; DBG("PA Sync done"); - g_io_channel_unref(setup->io); - g_io_channel_shutdown(setup->io, TRUE, NULL); - setup->io = io; - g_io_channel_ref(setup->io); + + if (setup->io) { + g_io_channel_unref(setup->io); + g_io_channel_shutdown(setup->io, TRUE, NULL); + setup->io = io; + g_io_channel_ref(setup->io); + } /* TODO * We can only synchronize with a single BIS to a BIG. @@ -3086,14 +3108,14 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) memcpy(&qos.bcast.out, &setup->qos.bcast.io_qos, sizeof(struct bt_iso_io_qos)); - if (!bt_io_set(setup->io, &err, + if (!bt_io_set(io, &err, BT_IO_OPT_QOS, &qos, BT_IO_OPT_INVALID)) { error("bt_io_set: %s", err->message); g_error_free(err); } - if (!bt_io_bcast_accept(setup->io, + if (!bt_io_bcast_accept(io, iso_bcast_confirm_cb, req, NULL, &err, BT_IO_OPT_ISO_BC_NUM_BIS, @@ -3114,6 +3136,16 @@ static void pa_and_big_sync(struct bap_bcast_pa_req *req) req->in_progress = TRUE; + if (bap_data->listen_io) { + /* If there is an active listen io for the BAP session + * with the Broadcast Source, it means that PA sync is + * already established. Go straight to establishing BIG + * sync. + */ + iso_do_big_sync(bap_data->listen_io, req); + return; + } + DBG("Create PA sync with this source"); setup->io = bt_io_listen(NULL, iso_do_big_sync, req, NULL, &err, From patchwork Thu Aug 29 12:49:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 824216 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010050.outbound.protection.outlook.com [52.101.69.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52B8D1B011A for ; Thu, 29 Aug 2024 12:49:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935790; cv=fail; b=eh5gcI0W8hYP+tweeIDd5S6kKeLDZJZoe56jIxCYi9z/gPquNlnOg9kgSR2ysnO77Md/izu/lFZcapL0aZPVEfIzeBjwsTD+b3c72BbzE1IXd4rKUbq9mmXzkvn9Kev1+6PeTIYzviLNzLJCunb4p2oj3ZvvC5MbXIVZFYFnSWk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935790; c=relaxed/simple; bh=fMVPu/sucQBHpQFWxlUgu1Wpg/AjxVrNDKqTRcnBl0g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SPq4+BP/hgqfIQoaYFH5FNm4Fo+XDgKVSAimBkzhLOIJ0xfbyZD5py3Nkghx/aI77u9QsvDr3cGLXYfqpnrDbAqoGJalPWRPCsgY023vgLxa6GAibqzvG6AiyGaCK3dmrfL70RuJWWta1ZrvnzUIuOZVYPLsqmeNvCqNqEPmNkA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=QFI+cXev; arc=fail smtp.client-ip=52.101.69.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="QFI+cXev" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Bc3PgG5FQ2x/KBFNqorHWtlUuniJLXDJHiRhyIo8HBxso9tsFcfZ7gfPkS0H1VnEeKTwEL2pUiNF0q8dX9wIQgaKzEPKUZSIX0CPps5QGQsZUrJorfbgMA4ERQWzc0emTQ+C5dFn2DOiBILbzsPauHEs/6h17SSd7XW2hGvU3+x8m9Msn1VfoSY/DoWCEcwXTywFpzCZoQQo8gnHAdRBU0lVVwaiixxGbmbGq2HicYTyALgCcxdXxKPwcvaDrN595etRfFX09SybfhHhQBdZXSV1cj1MzKa8LnqM1yK+SzwW84tKKQTXFtF2qaQf/Z/2IQNlTTHpf5F6wfKUk4R1BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wE4x9B4TumoXik6Bg9LVUVNa//Bpv2gfcrGExAjhKTk=; b=fkN7RHEI2ASZsv3BU3zWkoS85redCIcjqRBmeYBqs5o4QQ3WklYroy4wOBE8sF+n1YF/N5uvaph5s238iqTKDkFBCh6a43z0QgMpz39n7RJ5GaytdHZf3TVvgdAz8O5F/Ff0remm/ehix7qU+rlel+oC5z700IGe0Bt4AFWJd62UWMQ5TGtxLBqxowe6RMrRvAeoOAhfC9qWo48w2Y/mvDnOmvzrTv8E2lPnaSkanuycM+CPEM3fp9Q/SbUi/xkwaJTXwbOsJFnd8EOt2WBpcfdG78nSJWAMQ6rAEyzyn678xmSuZAzQuDQ3Fg3SIP4IlFtfB84SQBTDv/KfEyoyqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wE4x9B4TumoXik6Bg9LVUVNa//Bpv2gfcrGExAjhKTk=; b=QFI+cXevogPORrFLPUAFQ9elRedWbp8cRmTjTRiv0bvDfxMIdmyvyf/RgjjlZH99xz/kCk4BfPoUagT7TwTdfk8JjfBnhuOFndfWezQlaqW3rGEtm+OpgTmqGpV+S28LUO6pFy675qi7MJ2olT/WYJp3drxUtAhjk2ftJMZHVBTq6WNyKDVyEjArVqa+Yc5zUw6gn/QyQ3+mVsZEPa0/eSLXynf0mk/6pnZiB32LVzmAqFCRnXYOCocHP1NsYdwPecc93C+OqX2OKZR2CzeADlk7HqR9vLZvYV0ihOUraT5YB/pJ8c9R0EtYsMgkFDTIOTomHOT0sYn5VCdro8GHQg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7425.eurprd04.prod.outlook.com (2603:10a6:20b:1d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27; Thu, 29 Aug 2024 12:49:45 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:45 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 07/16] bap: Add API for Scan Delegator probe Date: Thu, 29 Aug 2024 15:49:09 +0300 Message-Id: <20240829124918.84809-8-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P195CA0051.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:65a::17) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: c342946a-1998-4fc5-68a5-08dcc8290f05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSp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9qIujNB+Qklrp6H7yFCXuOC6As7xVdnCIeJZpJ8WsbKgk+szpX8xNOHDh/uIRsjR33jJxgNDq2UKV/PvEuW8uiLjdcWE9sc7tpgX1r09Z0sXdUF281i+evBWJytgD/TiN1iU88Q9o4Y1xNVXFYsFcDdT/BvrOJ2r1j10/1WhmpEcJSk45iu10Y1QKtJ4fwaKwRvBTevWUydgYNUQ2WZOwM1OExl/B5EpN6WXI/bRPepmAEtcgpU9cLu3dPJ3CxMV2AgcvZAGtthCa+XlrWaAOklQEZkuCbAhpM6/iYV0XY+e+VRYJt+FqPHOfGTIO630Jk1UKdClarAU0yvYnwCkJX0lwLR8tzlHsvUI1j4hg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wmbmmW8zug1hvQDZ9kOUucxm0/ZEv3rlf4gmV+oxUKosZMvH0O7HWb7QoBtOZ5pETheo3hGcr1Y+qCHKgnxeNnnF0qpTFoAreXq0f6EwTn1YVRPBUqmvttEXPZiKAymcmUsd+8TB229sqM/wIpqFMcLRolW55C61IpI1hDe7fDIW7feONmr7mkykul9jTrz7huOxTggA3A/1Kv1p85v6fuK7t/Vijyc3dbQCqc3fjDT8v+9QE09ykONVlZtBQLTFx4c9DM9AMdLLREc0Vs5J4MS29PAXvEZFTuTTDKi7V+LDD2eaadnlBmAlbbdRyTJYLKazbHwpOvEMJ9jAvH695hxdsxcV+hW0VhR4nb/yGdETFjF5hOY1AiWauIFw32LTCdKuxgpzJQ6CFdeYewiMUYUn5nIa1+nh91KleBGDbnKndPZDsp0p/yU/wILg3x/tJjDW2Xg5JOG2B9zawW4OKhyjGgqLRytIWeRzJH0BCv7uhYHYfDdt1b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H7EtnRWDjXsHXdN7iSOwfttkQcZvOUZditBlA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c342946a-1998-4fc5-68a5-08dcc8290f05 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:45.1976 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5IO3zxkzHF+fWo7ERtumH25jvk++KcXAmtOY67SIVoq+f3aJgoYTjU5+VFIrd5K9S/SJON89+GCriHBK93beNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7425 Since a BAP Broadcast Sink might probe Broadcasters autonomously or with the help of a Broadcast Assistant, BAP needs to support 2 types of Broadcaster probing: short-lived and long-lived. This adds a BAP API for Scan Delegators probe Broadcaster devices long-lived. --- profiles/audio/bap.c | 45 +++++++++++++++++++++++++++++++++++++------- profiles/audio/bap.h | 1 + 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 76171eae7..3b2a742c4 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -3171,12 +3171,29 @@ static bool match_bap_adapter(const void *data, const void *match_data) return adapter->adapter == match_data; } +void bap_scan_delegator_probe(struct btd_device *device) +{ + struct bap_data *data; + + /* Create BAP session for the Broadcaster device */ + data = bap_data_new(device); + data->device = device; + + bap_data_add(data); + + /* Add Broadcast Audio Announcement Service UUID + * to device and probe service. + */ + btd_device_add_uuid(device, BCAAS_UUID_STR); +} + static int bap_bcast_probe(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); struct btd_adapter *adapter = device_get_adapter(device); struct btd_gatt_database *database = btd_adapter_get_database(adapter); struct bap_bcast_pa_req *req; + uint8_t type = BAP_PA_LONG_REQ; struct bap_data *data; if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) { @@ -3184,10 +3201,27 @@ static int bap_bcast_probe(struct btd_service *service) return -ENOTSUP; } - data = bap_data_new(device); + data = queue_find(sessions, match_device, device); + if (data && data->service) { + error("Profile probed twice for the same device!"); + return -EINVAL; + } + + if (!data) { + data = bap_data_new(device); + data->device = device; + bap_data_add(data); + + /* The Broadcaster was scanned autonomously, + * so it should be probed short-lived. + */ + type = BAP_PA_SHORT_REQ; + } + data->service = service; + btd_service_set_user_data(service, data); + data->adapter = queue_find(adapters, match_bap_adapter, adapter); - data->device = device; data->bap = bt_bap_new(btd_gatt_database_get_db(database), btd_gatt_database_get_db(database)); if (!data->bap) { @@ -3202,8 +3236,6 @@ static int bap_bcast_probe(struct btd_service *service) return -EINVAL; } - bap_data_add(data); - data->ready_id = bt_bap_ready_register(data->bap, bap_ready, service, NULL); data->state_id = bt_bap_state_register(data->bap, bap_state_bcast_sink, @@ -3220,11 +3252,10 @@ static int bap_bcast_probe(struct btd_service *service) pa_idle_timer, data->adapter); - /* Enqueue this device advertisement so that we can do short-lived - */ + /* Enqueue this device advertisement so that we can create PA sync. */ DBG("enqueue service: %p", service); req = new0(struct bap_bcast_pa_req, 1); - req->type = BAP_PA_SHORT_REQ; + req->type = type; req->in_progress = FALSE; req->data.service = service; queue_push_tail(data->adapter->bcast_pa_requests, req); diff --git a/profiles/audio/bap.h b/profiles/audio/bap.h index 66f8db887..cfe633311 100644 --- a/profiles/audio/bap.h +++ b/profiles/audio/bap.h @@ -8,3 +8,4 @@ */ struct bt_bap *bap_get_session(struct btd_device *device); +void bap_scan_delegator_probe(struct btd_device *device); From patchwork Thu Aug 29 12:49:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 823624 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010050.outbound.protection.outlook.com [52.101.69.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AC901B011D for ; Thu, 29 Aug 2024 12:49:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935792; cv=fail; b=O6Wx0H8kdxCLB5ovM9PC7tnMxwi3TPyYt9loECm3k50K/e6/hu3mERtcmIyzgvbbY7YXKbwtfYUSfs87wgaH9++WD92zhODPxUv8SvKzANY8J2KctcypUH0CmZaxKeqqulUXtB7GGfsPSTor25W+4hucE0LkFjdSZwVEGSoqXrY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935792; c=relaxed/simple; bh=6g1Dx13eJLM1s2WPBaekNW6JBB2aR7+mKHVxZPj0ar8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fh8Z+cu8Lfmz81iBGE/JQUXsUh6TJUwxMkV4V1iibP1oRVeVFE8PuHW/9OuaBYVZT6fmfdPCb/BfCMrKW7xei4bz40wTGVvjVtLHnTc6fxCAh34HT/dBIBAO5JanD9EJDIxCe+4z9Z6qhe+sNhcUes/yz+sRe8De+8me7kp7/sE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Wpib8/7s; arc=fail smtp.client-ip=52.101.69.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Wpib8/7s" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UaGFwrVZ1h3uNNAnLUGPJFUTsXlMlVPS/pu1hXVNMeVARnu1avV0bj2Pul35ZB+ljkM7yg6ibIc0Ks77Bp5ykrC4Y6R6EmR1NDwq+XvmckvI33ar/QhHJl533ifhEgC/MkZLPNQHZJSIXBAjCZ+OlbepEWAyc1yxeStk4H3oXI/nIekIKAgsH7RFv+YK1Vk06uSwH7o4CMo0BFi+vuOA9+x+8tyGHUK9yd6PgsCe20Fg38Dd/yR3IYT+vqsNBhxFtocBYWkEPUuUomKvvBBVfbLR1gVGUOkEqKElSENrZ4fXIv2jGjC7NyCgK/BY7a0ES3FM/9bIJVkMa6q56mvq3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AC+5rePicT7S1P6urc4AjchrgpGKZsRii3Faz3R1V5E=; b=Lipygow2gmXl8/H24UockavmbGUrdMx/KqsQZkZFANRqAFuX6/TS0Y1assBTDKkEdN/1xmNEV3f8a1X7qPyJ5QKsY8+HuIOBgbRRTfxTj45ChiF7gXNNFSv7PCTv3SOjgFjzbHA+coQTs6OQPG4yg/QxirlUnxVGlQGY3yCoV6HNbSQkGGnaOjchK8/1NDIlxAW/iyc2ke1SxfuevwVqsYa+zvsxApIgaL3dODiDJwFHXgSXSY9nYBC5I3MzXYKdD3g+OmJ2UwjIq3SjWKg5YD4T/2iYVEqV9AlpGcyLA7QcUBS/171hiKmQ9r+o9u2wvqE0cVnYxPrscqoZ4Wpj2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AC+5rePicT7S1P6urc4AjchrgpGKZsRii3Faz3R1V5E=; b=Wpib8/7sj3FSPFm/s666S/MPKFA1MAAhkK9AHIkWrWHvMnIdtwI6lz9o0T6wGWGB2dZFCxQevIb8x+TubLBYcoZ0AAjrbJ0keagsGeLg6GIubf755d6Qzn5B/yDFYBg/yYVOgEalz5iGE/K8vsutvpG5+E1J0tA96D29pqsdR5PCFtRXeK2rJxJVj/IVDxgRl72Kgx27OdDtuKjuZN671Jb9LsP+ntbrn7ypA5F0C+gAoY/THl8U5mmSCpTX2UZZOvcrQWUA5fkHL8pa8iwejOiuPb9XSYmzil5+WauBNUyaecYZxgz3Gsmfx5DWIDKALoEWKgnpQ7rKzNXgHX4SRA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7425.eurprd04.prod.outlook.com (2603:10a6:20b:1d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27; Thu, 29 Aug 2024 12:49:47 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:47 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 08/16] bass: Register cp handler for Add Source cmd Date: Thu, 29 Aug 2024 15:49:10 +0300 Message-Id: <20240829124918.84809-9-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P195CA0035.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:65a::19) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: df5e8c9b-5e82-4379-a8ad-08dcc8291096 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: OFY6P3quO0Fqc20ut2cS0zKzr9mpzqzoGx6sBJYxldZjfrb2tgcrdHU4w5PR5pMe33oFUxIi2FDPkNwtFr+PC6WFp9Yce0/LZ6kvibMuvScrrOsT0ZQuvw8w9piSN0VCQWXK+UoaatRqKajCz6cfauRpinanl5sfJtSMMGrZ+ewqm/H7VzIxeKsQ3MGQydlREUPPlW2+CpuXTa+9o+yZSPq1n1+1FGS6mWadFaDh03brGCCCWZMpc926Iv2iivZI3U8j8duxYVrdJSh6jFFzEObxY8rWc24/eVXXyWElO5D86TXtuiArUdu9jFZH/kQTxCSkrpwj9hkD5oowlE4SmgnDD8Erhb4NvprKv3QhAprUFSznn0II1fLY7dCcGgauBpm2PkZsZlnkJRps8h1p5Y9dH43NEcrPQMiZSv37m5OqRKEgaZ0ItW2SZBzrxI5TC/xJP6bhBvUCvMsDSIQBgec6YNzo6PlGWQpnUY311CPwUQcjEXknPusXmkwViy/FbLRmjB7px0BmLq+XHiavzuAzTfVsLPxZyhk1zb27x7FmgiCkE9VJeY82gYqknVNFmTHPt3c6R8sJ10uN6yYO8akfYHlSRylQH0TJsHwCfS1rmG/JAQE6iPpsZKh3m3i4xiXUUYTAj10i3Hbv6dV5Gm7/tRVD7BW7igQjd79KRQRhGA5jw2QrCeTYf3tTEN8gxw6dyLAvUPcMPQ/zRWrFOsT5zL+/QQ8fsQXQXOzQ5C8p9U7P2UNzU6OttzNHHPqfmypiUf8TegPgBjW3NXgaiwv5FR0ebZhcMVFoSIPMueR9arDJt2AMkBSwnexDq4MCoafZjwhUSzSUG5/5ckGBEBwVipAPaa7S7YE5nkheH3AqM2aiTPh3BGxqBxbIFSIknzDSFRX6g12fuXaxK4KfQKvtxMJC2Mh6Jecla/7JSMtAiln8MJvmHBeVByRoelzA1IPy7IlzDHQUFZ9pF5tmO1vGAd7JZHBGMZFupBeckKBPYk3BDo/cQ7UxzJda1qtT527yyy3bK6NHk+zh0dbzsFiE6c07dG6u62q+s8+aoX9uy+ZqC80qPB1zQCteQuB10P4sln6JtENXGAoyKArhR+OQj83NbfLumN20aNgp9xnF/v+oSECqYTaLJ5hnUQh5CiXStESF0WLgRTd85lVJ7KSoNfLaJ4bAF5FeKg3N94cBThjy6QGIVqg2lqTkefY83HmW1nV4Dfyqpt/DuWNOB4etAxaLQUMxedH+k1oxgsrch3/le9HduJuKBlr52vzsBumXeTo5CkaatI2LqHSzPQCrKWvIHbXXdHhyCp3R9KywkPDXA0GDaCdhlJnv5TCruatOPe0qeoYtH8zXUg6+IQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YPF9P/trfp3BvqaQjk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sm7p1NjFca6J5QszR0uc0K+9ifj6AYQBbhcRVeaicxdU6k3HwUuSHvrNnDw/UcEUJRe7aRnCFmARxAcO2mv9zc3sYxD1VBR4u5BjrnB0nXgsSkuH/y6zJcForEkgjn1zBsIRm3IBlx/eExWJNAbsvqO+bw6N8T+2s54ZZe4TcbZvYRXOygrnkNkEjAghsEh8bWqr0F2Z+FEPQdEFdYwZMDtK3nZzhcyE7WS003BPyBNlTBM6fg2JuuyfkYWdAtlD8BQXb8p4/1diQo9nsuHIPeWf23oXR68l1emN6LC0vESmG6bSSbi7bVNOVz5+OZJNjpj8e/ERFI/BUnzL8m4KOZe7PnBloEQYv/MtvnSg2aHA1V9RW94BOUiprSF+eK4z8RwvTWIHmKvd2kdt3zTuJwsdaCci0XvEdpKVdZRrFcw+d0STWroSM8DXPtZwNtteAxqkSQRxebglzTnNL9cpS6zFV/Q2B/hTGXwVhgImruf0SZKlTteJbqYfWAYJfOqUemOGtveeIxaipiVaiXjYM+dQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: df5e8c9b-5e82-4379-a8ad-08dcc8291096 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:47.8356 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J8tLreXyjOt6VCk7siJlalP9Cs8iIx2JrGfNU0pbKN2zb1KgMGgPrVOUPN2zZNn1DqFFDvmwQA7AVDy/dDP0rg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7425 This registers a control point handler with shared/bass, for each eastablished BASS session. For now, only the Add Source opcode is handled. Using the parameters provided from shared/bass, a device is created for the Broadcaster address. The device is then probed with BAP, where long-lived PA sync will be established. After parsing the BASE, transports are created for each BIS, as if the Broadcast Sink scanned the Broadacaster autonomously. Below is a bluetoothctl log which shows a Scan Delegator starting to advertise, connecting to a Broadcast Assistant, receiving the Add Source command for a Broadcaster streaming one BIS, creating a device for the Broadcaster and then creating a transport for the BIS: client/bluetoothctl [bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep0] Auto Accept (yes/no): y [/local/endpoint/ep0] Max Transports (auto/value): a [/local/endpoint/ep0] Locations: 1 [/local/endpoint/ep0] Supported Context (value): 1 [bluetooth]# Endpoint /local/endpoint/ep0 registered [bluetooth]# advertise on [bluetooth]# [NEW] Device 00:60:37:31:7E:3F 00-60-37-31-7E-3F [00-60-37-31-7E-3F]# [NEW] Device 03:E2:C0:11:57:DA 03-E2-C0-11-57-DA [00-60-37-31-7E-3F]# [NEW] Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 The btmon log below shows the GATT write command with the Add Source opcode, which was received from the Broadcast Assistant. It also shows the long-lived PA sync performed by BAP: > ACL Data RX: Handle 0 flags 0x01 dlen 1 ATT: Write Command (0x52) len 23 Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7) Data[21]: 0201da5711c0e203001a2d5602ffff010100000000 Opcode: Add Source (0x02) Source_Address_Type: 1 Source_Address: 03:E2:C0:11:57:DA Source_Adv_SID: 0 Broadcast_ID: 0x562d1a PA_Sync_State: Synchronize to PA - PAST not available PA_Interval: 0xffff Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000001 < HCI Command: LE Periodic Advertising Create Sync (0x08|0x0044) Options: 0x0000 Use advertising SID, Advertiser Address Type and address Reporting initially enabled SID: 0x00 Adv address type: Random (0x01) Adv address: 03:E2:C0:11:57:DA (Non-Resolvable) Skip: 0x0000 Sync timeout: 20000 msec (0x07d0) Sync CTE type: 0x0000 > HCI Event: Command Status (0x0f) plen 4 LE Periodic Advertising Create Sync (0x08|0x0044) ncmd 1 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 16 LE Periodic Advertising Sync Established (0x0e) Status: Success (0x00) Sync handle: 0 Advertising SID: 0x00 Advertiser address type: Random (0x01) Advertiser address: 03:E2:C0:11:57:DA (Non-Resolvable) Advertiser PHY: LE 2M (0x02) Periodic advertising interval: 10.00 msec (0x0008) Advertiser clock accuracy: 0x07 > HCI Event: LE Meta Event (0x3e) plen 42 LE Periodic Advertising Report (0x0f) Sync handle: 0 TX power: 127 dbm (0x7f) RSSI: -64 dBm (0xc0) CTE Type: No Constant Tone Extension (0xff) Data status: Complete Data length: 0x22 Service Data: Basic Audio Announcement (0x1851) Presetation Delay: 40000 Number of Subgroups: 1 Subgroup #0: Number of BIS(s): 1 Codec: LC3 (0x06) Codec Specific Configuration: #0: len 0x02 type 0x01 Codec Specific Configuration: Sampling Frequency: 16 Khz Codec Specific Configuration: #1: len 0x02 type 0x02 Codec Specific Configuration: Frame Duration: 10 ms (0x01) Codec Specific Configuration: #2: len 0x03 type 0x04 Codec Specific Configuration: Frame Length: 40 (0x0028) Codec Specific Configuration: #3: len 0x05 type 0x03 Codec Specific Configuration: Location: 0x00000001 Codec Specific Configuration: Location: Front Left BIS #0: Index: 1 > HCI Event: LE Meta Event (0x3e) plen 20 LE Broadcast Isochronous Group Info Advertising Report (0x22) Sync Handle: 0x0000 Number BIS: 1 NSE: 3 ISO Interval: 10.00 msec (0x0008) BN: 1 PTO: 1 IRC: 3 Maximum PDU: 40 SDU Interval: 10000 us (0x002710) Maximum SDU: 40 PHY: LE 2M (0x02) Framing: Unframed (0x00) Encryption: 0x00 --- profiles/audio/bass.c | 79 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index b3740f64e..ee378e141 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -54,6 +54,7 @@ #include "bap.h" #define BASS_UUID_STR "0000184f-0000-1000-8000-00805f9b34fb" +#define BCAAS_UUID_STR "00001852-0000-1000-8000-00805f9b34fb" #define MEDIA_ASSISTANT_INTERFACE "org.bluez.MediaAssistant1" @@ -82,6 +83,7 @@ struct bass_data { struct btd_service *service; struct bt_bass *bass; unsigned int src_id; + unsigned int cp_id; }; struct bass_assistant { @@ -97,8 +99,14 @@ struct bass_assistant { char *path; }; +struct bass_delegator { + struct btd_device *device; /* Broadcast source device */ + struct bt_bcast_src *src; +}; + static struct queue *sessions; static struct queue *assistants; +static struct queue *delegators; static const char *state2str(enum assistant_state state); @@ -582,6 +590,7 @@ static void bass_data_free(struct bass_data *data) } bt_bass_src_unregister(data->bass, data->src_id); + bt_bass_cp_handler_unregister(data->bass, data->cp_id); bt_bass_unref(data->bass); @@ -627,6 +636,70 @@ static void bass_detached(struct bt_bass *bass, void *user_data) bass_data_remove(data); } +static int handle_add_src_req(struct bt_bcast_src *bcast_src, + struct bt_bass_add_src_params *params, + struct bass_data *data) +{ + struct btd_adapter *adapter = device_get_adapter(data->device); + struct btd_device *device; + struct bass_delegator *dg; + + /* Create device for Broadcast Source using the parameters + * provided by Broadcast Assistant. + */ + device = btd_adapter_get_device(adapter, ¶ms->addr, + params->addr_type); + if (!device) { + DBG("Unable to get device"); + return -EINVAL; + } + + DBG("device %p", device); + + /* Probe Broadcast Source, if it has not already been + * autonomously probed inside BAP. + */ + if (!btd_device_get_service(device, BCAAS_UUID_STR)) + goto probe; + + return 0; + +probe: + dg = new0(struct bass_delegator, 1); + if (!dg) + return -ENOMEM; + + dg->device = device; + dg->src = bcast_src; + + if (!delegators) + delegators = queue_new(); + + queue_push_tail(delegators, dg); + + DBG("delegator %p", dg); + + /* Probe device with BAP. */ + bap_scan_delegator_probe(device); + + return 0; +} + +static int cp_handler(struct bt_bcast_src *bcast_src, uint8_t op, void *params, + void *user_data) +{ + struct bass_data *data = user_data; + int err = 0; + + switch (op) { + case BT_BASS_ADD_SRC: + err = handle_add_src_req(bcast_src, params, data); + break; + } + + return err; +} + static void bass_attached(struct bt_bass *bass, void *user_data) { struct bass_data *data; @@ -652,6 +725,9 @@ static void bass_attached(struct bt_bass *bass, void *user_data) data = bass_data_new(device); data->bass = bass; + data->cp_id = bt_bass_cp_handler_register(data->bass, + cp_handler, NULL, data); + bass_data_add(data); } @@ -780,6 +856,9 @@ static int bass_probe(struct btd_service *service) data->src_id = bt_bass_src_register(data->bass, bass_src_changed, data, NULL); + data->cp_id = bt_bass_cp_handler_register(data->bass, + cp_handler, NULL, data); + return 0; } From patchwork Thu Aug 29 12:49:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 824215 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010020.outbound.protection.outlook.com [52.101.69.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91CF01B012D for ; Thu, 29 Aug 2024 12:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.20 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935796; cv=fail; b=AD2hE+tQSC+ZiUMrdJgbUWB6bCqph9VbYFwTHerlgJvXh0BiADe1+e3bSzyNbu/fKRiTSbfGzsuj6fGYbni1VVAqmPynhJzVdUTrAFm3Xa4QqA/UZ14XmRf0NGHJjRi4sym1qoHRixHlP3hzuPIW0uMiwb/h2AYJRNlsbM1TGLE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935796; c=relaxed/simple; bh=C+bdOP/CtooUgzeUcN/4LT8YfgOda6kM8lHsJU1XzfM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=sQitRL9UGCprfIY8VMwm6dBbe44YVqQ69rZugaeIiwjTb/Kz+O2lqBukgICSb4kfXnHMJb7GbwUN37ujmito0C0zoW55An4YNooyjkKJOj86l1acBxIeVTCV5C1qRVEc0yU4MTtTPBIM4/EgW80EpE6+qOJWvnsdbWKV6cISme8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=i1nzZ/eb; arc=fail smtp.client-ip=52.101.69.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="i1nzZ/eb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K8UAkhWTVpB96E1nUxX/SOu7TZTsQYyD2uzp5L/aCw/9X9rkNSE/dOPjUYjjRRHvIWI1D5XFduQtkM+J+xYhc0vFiF5vdZrN4f60yYMS3e2DPbbq5KqxKnJXC4+kbbGI1TCvxd+zzj+qXTUbsz0y4KRZFjoaapGDgxQk9dgjtgcrEe6zMXbSGC8aU2CAo266BOFR/CPHYutMaB5Pyvzg+3Df2ybqw+26uYBY3h/sQ0fZTkcDUJoMBIDU47R/rx/3FYYcJM6iE1wDSCK9mnVNgV3FX6/YmYjW4CmXahQKPPLS8Z7r4eKkOLC4ZueYiQ3/tUnMe0uQUrMnpzRY+PzUHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4gsSC/ji0e6hjh1/rymHMqyQq+8WSJuERiuPNx6S7HY=; b=JZCg+kbfRdmDo+jrmeIBxVb8+b5XlC4uduynQQgto98wKJq4uB/x98oknf5dK+dxqgsh0BoEMvJrvoqazuOdh0P6M+/rIbbegn/svVhdrn3Q7AVshz3S88uImbgxYxYMw8lQltzzgbxzHpVd6Dd9zryejH+spnEDURPqYqZanZgROCxsS30cWJpH352BVjePywtquX10oIgUsvcK68Wcez+F/lSmwIr3qvhBGSZIyUVkFjvt0JlgzCBUt3xXc3FHyMQHIKqVls7GF6PNcw0Q51jDqdPq9EzimnLM3/opFQiCqC8QRFM08ccwRFZ1w1qwDpg/R/fJTomxnlAV57JqcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4gsSC/ji0e6hjh1/rymHMqyQq+8WSJuERiuPNx6S7HY=; b=i1nzZ/ebpDvyQZndGBmkIW3mPVz1nYwTh6TvKUpuz3y7XEcTCNTEEOGnhxXhDJsSNz4Z18eWLJxu03wGIozGTx2pNlh9OYg6nkHHuz+RTFtCGxid3XcKtbEiXl7RScPDAg2X/QuHNONDGRvnlZB/vejT8MaSToQKHuWUyeZUrbtEhttjaryEPDYNOmzBM5nFnjpVjdV+QvqSkk99A08bl1U02Q6mnTXFdv5bPSqCvKub6sbOh8bUOfrp5UVwdjq8PvgYiYiwjamURwJkOl+YpkRIW3yLPWAHr4ifdcYUi3QG6IeG2Gphobv7VaavjYb6puqCGAVuVpf2xf3fAbjdRg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7425.eurprd04.prod.outlook.com (2603:10a6:20b:1d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27; Thu, 29 Aug 2024 12:49:50 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:50 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 09/16] shared/bass: Add API to set PA sync state Date: Thu, 29 Aug 2024 15:49:11 +0300 Message-Id: <20240829124918.84809-10-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM0P190CA0020.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::30) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: d06ef35e-e6b9-42cd-dfeb-08dcc829121b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: wJ3cXuuWC+YlauNstP/S4nlKzTNBeY5fligW0W6J3PmRFSsdFTwg8IE5kjkh2DxAZ4MUmjYGdPuZ/fnyQ7MU4nUhVM2SA8GlmdU7ijynJIpiPgP7kZ1sHkZJfbq+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kV0+uibu5OrLjHNduY2Wzu4lhr3HGoy3k+Wz3n+TdhtsnrhCvWgaUDAkNLxmjfVwDL1K4Cqlm0J5xe4MyLio4gZJN2xnZ723kCOdGaximjymL9m1v3xlXFeg/ILHoFUf5QP1VasNw5gq4CJJkGA6bd8Ge1CwbW/AVQ8aTqw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: skKac2FcxRo8QOAPGked4hGFmny4SgquOtCyU5tOd/NeuJu/HBtTGTICa4Ghq0SapJ0uatH7+50jTib/YxMlCWMxqAv6YR1DWgIPc0icyY0hVBSX6wxOdRfhOu4FT1IwuJ/J95AKHhjRr9/xpiT5cxBkfXcFJ5PT0Vf6D1mbm7mwotrNpvJHpfuKv+JXMYuwgWWWk1vguOnKzbUpDS3RZfZYDKK894j1rXQA3/zk7fnqWtKkdAXWZGbhiBGt58NUPCX4fX4Phst+8bIKfFOcGuQOsfxHBw04gxCrYjHSWbhvgdpAldeWdfA2ot3WcH6ocuqkOBk3hDxANcEMCbTxqSx/n/ajLBsZMg41CSl/CEnLIYsteTdjPA6OCaNpVf1W4y7V3Glsftp1FlMwCQYp3/FQYlxwB/3hDCE/JFtKR9PlFAgbdZ3QfSQsbOXOAUDvPGOBZWFrFZm6eVUeD+zEPRihyn+IvSu3NlNFS88MkBEMUbwTYn7sLAmbnsnLWR2PrOlUXOuQYh7PTR2SlkkbnEoSv22rWB8XuipJ959qk+uV8+fWa58kvLuQtdh8MAtfpQyxJ/yf2+dmVxsXOqnEDlFVOcEonGQWf3h/EHr0Lg7nkbnGxBWyb+HUWyqPihjUF4ugloB2ZtbvlOK9U+f/IGhsiWslfYFWOnEHv1U9QJixMKCpyqmNsfud6Uvult81NWOrpvBzBvXRQGHNWahUOB/Np8THQz06mb7YnuRWjQ7gq+istwOhafwLh1xE6kE7dRaZBXxJ10udGDUgHWMXdfWT65Hx3vJglpun7FuiCVqcYfN1IVoagtboG8eOwRHlY/gcYRGhe0JJmiUl2AtF7NdGXgPsQdu78iIe4s+G+dJvj0Tz9yiUuHPR7KjaTZoZMxVoCVa8+G7GVZK47oN2pg0K2N4LPf4i8KYnm0QkrQEXjpIYz44t3WvFz/fGVfJ5n/L1Tlti/y0lWZmANPC6eNJGZ9y8BCAcI/f9riF0F+hMU9ycKsPXUg9PjmY0WhM6oHGcki5em1l/oQ3008/FkFgFpMzTFvJncpQNaswhf7V0+Ov2Ksu+7cqwwLMg02Td6SUKB1vUYeKRVbDafpRfyFp1dOa0YrurWHdbfc26jjh6ie8w65m6kcqIorzhL+Cqq9aFOjLnM3/EP6f2DKOFR4ANEmP6AZnj+rgFsPXcFZor6DSYlmxwI9zQ7/a+lBAnrOTUSuukvoWeP/Yc4BAUrRbl0XbnvkFnIgg6s0/wiRs15ieJN2jqIQaXMCbhi6QzQfVjZ8Vq0P6s5SSGZ+8h31AwRpJsjzMgXvRWXFm0OFz7ihlMRddoZkbq4Fng2onuCri3lucJ/duFbeqD9Q1pyNaXXrkAApDsAyOWaDz8oMMDp4ZGe7EaPuKk5IsYNvvvFehkCvJ//iXG/cHosgrlcDFSeL1dUpUv7ZXY7v/bBtNWF0L3ZkFQH6A8l0pLbYVHmxAIH1jhkOIVGICKQR/r6r+FST2c+WAYsFibCfqcCsgQ+YR6K3UvuJWclg51dXBqCgY0sXESxwLNdqgvappr2Ssu9SbcO/+fJB6XuYAAmkZLImqER8Qlco+HgrUHF4WbkLXOfR05wuoGczl/tg1t3Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d06ef35e-e6b9-42cd-dfeb-08dcc829121b X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:50.4092 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Xhfc2NjDEim+Z/4znRB6+oGMrqOa7eh2Wa/lFOrWIUK3H5OrUeX2oJWZgDjYa+r5GdVhDhJBGXqWRll1Fs/5TA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7425 This adds a shared/bass API to set the PA sync state field inside a Broadcast Receive State characteristic. Notifications are then sent, to inform all peers about the update. --- src/shared/bass.c | 34 ++++++++++++++++++++++++++++++++++ src/shared/bass.h | 1 + 2 files changed, 35 insertions(+) diff --git a/src/shared/bass.c b/src/shared/bass.c index 70e747700..958b6f788 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -1732,3 +1732,37 @@ done: return err; } + +static void bt_bass_notify_all(struct gatt_db_attribute *attr, + struct iovec *iov) +{ + const struct queue_entry *entry; + + for (entry = queue_get_entries(sessions); entry; entry = entry->next) { + struct bt_bass *bass = entry->data; + + gatt_db_attribute_notify(attr, iov->iov_base, + iov->iov_len, bt_bass_get_att(bass)); + } +} + +int bt_bass_set_pa_sync(struct bt_bcast_src *bcast_src, uint8_t sync_state) +{ + struct iovec *iov; + + if (!bcast_src) + return -EINVAL; + + bcast_src->sync_state = sync_state; + + iov = bass_parse_bcast_src(bcast_src); + if (!iov) + return -ENOMEM; + + bt_bass_notify_all(bcast_src->attr, iov); + + free(iov->iov_base); + free(iov); + + return 0; +} diff --git a/src/shared/bass.h b/src/shared/bass.h index 2ca659cca..a82d8f573 100644 --- a/src/shared/bass.h +++ b/src/shared/bass.h @@ -129,3 +129,4 @@ unsigned int bt_bass_cp_handler_register(struct bt_bass *bass, void *user_data); bool bt_bass_cp_handler_unregister(struct bt_bass *bass, unsigned int id); +int bt_bass_set_pa_sync(struct bt_bcast_src *bcast_src, uint8_t sync_state); From patchwork Thu Aug 29 12:49:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 823623 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011019.outbound.protection.outlook.com [52.101.70.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6ED871B011D for ; Thu, 29 Aug 2024 12:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935798; cv=fail; b=Yw1b8o0w2pIsKlIdvReIcLGPBn6Hg9OazVVsHlQu99yxRk/GZwPwb/aa3cK1XJ296o+hDTCAgRTAOzkeQz1bKeHsyiRxcBxDqf9jCR3Mp08RI5FPek6/2lMpTPKfdleP9e6HFdoZNusrYv4hb1cCq2fnQ3wMQUMnEj/tHdZuWk8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935798; c=relaxed/simple; bh=QD6rJvLNp34+FiD+ldTLzVsAHSi6Ovh1GYVuN2gZQK4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ghMxrQ75Wkv7UjnzPjJPHFU+Hfu0lpbjihjdwLtxPtP16/ojUaV6dKbxy5oc6uVTYsMvj6JvvMoIsJudMcnt6zmHadDNxkI9MrouvIJG6Nmi24u9m7ifGhJ5BjLuaQQyj1IZIGWJO0OuKtA2lsi9LUI8qbDn6YAQKGRgsbzPiBI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=nUg2gP2f; arc=fail smtp.client-ip=52.101.70.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="nUg2gP2f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=y67Pw3xTRDUrz2zGkhuBsx4+sIhcuwQXDJv01Q0vgYo7YVNHx4Di2igh53xFIjdJgvV+mca2arzqSJ7Z5ppbaCxbtiqn3o3ZqsJldaWgifj0MSYXO5CcaXzv7PVj+yHt3phnVr2bH112vsDVmcYZTpCA9L3PovAY1BNO5PvsVZnBE2tCviGQZefXXcTjagdq5/64HQy/Nlfc3G2+x+x3sWIlnzWol+eai7ldnAGa6X5sr5FzDK7p4IioePdolWzQEy/C3WouOza5miXRbQu7Cngz5SR40wsUjTjIXLwMB5F45j00hGWbLXo1KP5f1x6TEWhkjDFYDPuZX/6rV5D/Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H8xm51Zv3fTzx8IYIA8sWH8c6BtjiH/CweslYX+XuTg=; b=EG5K05kFz5b29sC2RQGVSbdZXhHNkQIaDWXK7sZVRhsw8k8LGky+8c5197E8czlA2sk+ryA1zP2SlAnYGt56U7A3ReMhJxRBPT193YbD5WWDwb2e1Zk628AO3mdMClgUpNViM5MiBIIKoktciBCQ14F9s39UDlUWEOlp07sj0SM/kJpapNH6nUcDxfrHydCdOgl+ojBGF3zdESOKitqWCLYe/w/HOsVPeA0bLm14LBanpPn5xLViW9n9GneouRhpPWmTE3LLMdXqy1GjgsWyiibyUPI0Bp8Sczdo2YieVsOyvtmUs71CPrPhiW0/IXx+QBcJhjDNmHYzfsvoIOHozA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H8xm51Zv3fTzx8IYIA8sWH8c6BtjiH/CweslYX+XuTg=; b=nUg2gP2fmiN3l7Hx8ZxY7iXRQOr1OH817IekJPb/zckahnbXlitJcZCSSNDiUgZ+NacrVRiG4Ltf6AM1RTlyCVnUEsgubDXWcXgPyTwN/UXsO8A8lahuaLvU8d8hLM/fdovyPMxWZ1mF4eDuQ6xVXNX1vgBoDJEofTwy8xCHhcPgN7Y47L2SBbtJqPYkIoK2H5qoLSri/99Va7OJaIFkpEe9BTSC2xfZB8oE6CaVM9Tzz3l+7OiNaHGopIyyjvcCZ+Uqk2hGxvFgwBkVEwS+XfoNc6+d6SSr54SY4i3cKhT1sstg9XtLuZFPU1TroWKrkpbt0OksLDtgZ/J2BVK82Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7939.eurprd04.prod.outlook.com (2603:10a6:20b:241::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 12:49:53 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:53 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 10/16] bass: Add APIs to probe/remove Broadcasters Date: Thu, 29 Aug 2024 15:49:12 +0300 Message-Id: <20240829124918.84809-11-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P191CA0030.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::35) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7939:EE_ X-MS-Office365-Filtering-Correlation-Id: a0c1fbbb-30a7-4edf-3ad3-08dcc8291414 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: KglrqCcNKjeP0+R685i6/NhOO6Hi85OT0+D+rbTJHqgCDJIdBexQ6/6C2cQxYj3lOJgGkYewabIPoCN22zC46mudS3CjeQ4FRN6dAUxScAlQnz6jUCj2CTnWtFKGlMWKm4H8fWxREYCu78GhHYDA/ybqiUBSXKh+HHs2vgs7XuYbklhJQc3AWapmHWRUxfJopqcWOk2LvW6OkD2ScjcK6nHXLF94wjmJwh1EvBze0+mHColk7RsAzoi03PR7o41X1lt8vMZlFQgFd8ZkSCbbLKWJ7d8IsGfy4V1q6YxymRrGgt2V9nfoPYHff4yGmEXMINsZOV2Q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ANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UOo0Tfy0bcsbiiodfcqX5esODo4b9MJZoZggwzWMPsWHDKhvvnadjMWG4p34GmU0b5YyW2WlaWivlB1zpLTCxRZHim4OE9ioMq/+cFQwPTzV7EMjlFGkLtP7AtDaRfE0a3ivRCVkMc0qFIwUPfwuCSOvxUzJqB/3M+sCoWDqpqhJ4vvNgNGTpM2bcZUtca+aLgNZuueuubXysLBqQ4prLAvv0Xqr/XEJDrqkxRa1Tu+NgGUFfTqkupNJSMi3gn+mX/5Bwm2kOTbarz3Jdut6bnTRamDXmVrqkTL4kFjZW2VGy0WsLPID4BjOadjD+bf/iuT54yhhuLw12Ka3T9nc9R51+FnI53mbFgnNzFOFcqmG3+DGAw29cBwU3u8Wr+o+gYJoGbBkagUxxKwQcdZkirU281TvBjuo18mw6sOao8eNYD5KTod15uqsz8z/PVM02gA0hjQRB3aZoBKt90vEH7pUVbLkwj49Ll1rITmSGEeXHjjuCFgPU4NUKVmEoPoxLcvouSpcor0Sk1Rqvfd30OfzZs8FJZppdjIapE4eSJd3Rr22AR2gokYD9msWGRVsliD1wVvM+ARqcMxMVJm7cOSYhwZcuVnph2z0jWTrgSHXiN4KnpOnYHPLK2Zb441Rde6YDmCIINFAb2HNGCKjgEX/rj5D9R37F0efyYAzSh9ft8jrxnmdtJZ+AZ0Y+yW3EH/skBDh15AO594mVLcvePIly1dkbnMwrOjg4sCZgwYoSmibmfgK75oGXyeGyuGRxyjFalnb2hRB6YiX2frvnCt0JabWzfHSuN55dBzWdeDZD8e1Ials25etlNhlfiSzwanUWLOOAAz/x+4yO7xjIEUEEETn9WbOcajFbi1dvNRpellcsCnLtpqRVKFZh989ih5f/6fqVIMW3p0CGVjqeezxsVMkmaurpsDitjbajmN6MzbhFuviSnFGNRDLiS4h5CiAiZxD0GpEMX/w/wHXs2BNdNbmAVsg1fKW8ZUYgKA54cXiE9VVzryzPhRIZDAwSQ7dbggPHN5VNeFE8NkTRfiS0JUBj/DGwEThVFfk4FmrOMw7yV2y8WoR/Y2R/ZaljqLD8Ig3rnkGZMWuVEkOWctFBSmbsZ+Ae/COzaK0d6ArX0ezzG/J7IasYF33cVHYuEd2pv0oPs/SCL7Fu4MU2rtTkMbiRfaqsmDnIEadVB/MwZuERFUoYlxqp9cvldEItqgHRMq86+XOqY0wjspWRoNaz3RkZPgV3EVJ4gdnJNbHGQPJIl0DI1frGJgB4flQRwMo0sTt7jyEU14OqrshcNVhTeoL10o7SFFo8fmvCjAElRjZ+itOiYhAMaoxn2ZyaHdT9icIxknAzN/Z5H0QtANX++GTnwN5FjocqL22NpHw/lIlYZsrngJiImbTODM/mV5/V7YHQ6G1wjk0D/fM9q3lMMmpwcd2F9Ung88JMSp9EQJf/AFNiZ7xRN7ExfGHfENDVng4GS/+pmaObdpQ9Cuv9CeqSq75AskbvEODYkX0NbNvFfP7HnNjzFIrsDh+Dc8gvYQ56lHCIp//vJptUycBfnWTRWFAPas6b+QLXfok4D3YGJGyvcselq/dTvBXBAQB0HCBK6/3Umv46fgqKg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0c1fbbb-30a7-4edf-3ad3-08dcc8291414 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:53.6678 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: U5WfB3cOKXjySa+ERcUFjWwwZPviIYcF+Vz7xf8AVc/X6PMygXirS41LLYDc5r96XEEFsvyVSqoXQ1SwwsldeQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7939 This adds BASS APIs to probe/remove Broadcasters probed by BAP. The BAP plugin might probe Broadcasters that were either scanned autonomously, or that were added by a Broadcast Assistant through BASS. After performing long-lived PA sync with a Broadcaster added by a Broadcast Assistant, the BAP plugin will call the BASS probe API, to inform BASS that PA has been established with the Broadcast Source and to provide a reference to the created bt_bap session. Once a Broadcaster has been probed, BASS will update the PA sync state inside the corresponding Broadcast Receive State characteristic and the peer Broadcast Assistant will be notified about the update. Once the BAP session with a Broadcaster is deleted, the BASS remove API will be called, to inform BASS that the Source is no longer active. The BASS plugin will update the PA sync field of the corresponding Broadcast Receive State characteristic and it will notify the peer Broadcast Assistant that PA sync is no longer established with the Source. --- profiles/audio/bass.c | 51 +++++++++++++++++++++++++++++++++++++++++++ profiles/audio/bass.h | 3 +++ 2 files changed, 54 insertions(+) diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index ee378e141..933eecabd 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -102,6 +102,7 @@ struct bass_assistant { struct bass_delegator { struct btd_device *device; /* Broadcast source device */ struct bt_bcast_src *src; + struct bt_bap *bap; }; static struct queue *sessions; @@ -115,6 +116,56 @@ static void bass_debug(const char *str, void *user_data) DBG_IDX(0xffff, "%s", str); } +static bool delegator_match_device(const void *data, const void *match_data) +{ + const struct bass_delegator *dg = data; + const struct btd_device *device = match_data; + + return dg->device == device; +} + +bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap) +{ + struct bass_delegator *dg; + + dg = queue_find(delegators, delegator_match_device, device); + if (!dg) + return false; + + DBG("%p", dg); + + dg->bap = bap; + + /* Update Broadcast Receive State characteristic value and notify + * peers. + */ + if (bt_bass_set_pa_sync(dg->src, BT_BASS_SYNCHRONIZED_TO_PA)) + DBG("Failed to update Broadcast Receive State characteristic"); + + return true; +} + +bool bass_bcast_remove(struct btd_device *device) +{ + struct bass_delegator *dg; + + dg = queue_remove_if(delegators, delegator_match_device, device); + if (!dg) + return false; + + DBG("%p", dg); + + /* Update Broadcast Receive State characteristic value and notify + * peers. + */ + if (bt_bass_set_pa_sync(dg->src, BT_BASS_NOT_SYNCHRONIZED_TO_PA)) + DBG("Failed to update Broadcast Receive State characteristic"); + + free(dg); + + return true; +} + static void assistant_set_state(struct bass_assistant *assistant, enum assistant_state state) { diff --git a/profiles/audio/bass.h b/profiles/audio/bass.h index 5bef92946..7e20385e5 100644 --- a/profiles/audio/bass.h +++ b/profiles/audio/bass.h @@ -11,3 +11,6 @@ void bass_add_stream(struct btd_device *device, struct iovec *meta, struct iovec *caps, struct bt_iso_qos *qos, uint8_t sgrp, uint8_t bis); void bass_remove_stream(struct btd_device *device); + +bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap); +bool bass_bcast_remove(struct btd_device *device); From patchwork Thu Aug 29 12:49:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 824214 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011019.outbound.protection.outlook.com [52.101.70.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91C3D1B0138 for ; Thu, 29 Aug 2024 12:49:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935800; cv=fail; b=WkHwqS+TvyXDnQK0tjuAn0q+I7wQ0t75gCSupJjgHGggQlFFMqPRp4Hae0Qg9A8IRASGsVoS8loviOEUmcijhyOdaRmowPt9vb2xgBYuUsITPhVaNdCeZc5K5TW4h2Jw9aLvMoR3ayLcA2NufYAWoN/e9Ey0AE9yXLtTd1OJ6f0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935800; c=relaxed/simple; bh=gQ/sKGbq9Pq5HpYUoBWAVRiYG17NtQ4dKtd2VgJehNg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=BaPIU/xbPIjsiZc+wELDQheTjmVEYcuLcRxGMYnt/lBE/a+93k42v6NHiWWcQl5K9tsPUArAe8vF9A+4uPae4dYJ7FFloSxbCyWYepaIoNPUKp9c8TIfeJp6LJtCK45WTBgFdNqQWvJqQ1M5Oa452+ThS9G5hl4tcf9t7TCZDnc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=mKQDKxbj; arc=fail smtp.client-ip=52.101.70.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="mKQDKxbj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IPIDAy88eJB+uzsa5eWptJz1c+G8QTQzmHCiEtM0Qg4wLteC0bhzECKbZ1hm5BsaQLcUdN2hjzlfpYO/ovQxAjFWbeBoD59BeDZNAViBOC3S0joL5aNhFJ8ZXYwUUnYjZxhnZp3BHzvsZsOQEgbP4r9rP5tZp4LTfH9+Qu8NcMgkukS360JpMqlxDj1iPTDvGU9fmG2tibZ6weuuPaZPjVVxiNQV1xhOE+voNgrnAXPZ7+Bs9wHc6WjSVa9/peUyMeADpya3tvjwsH7wjqhPAOFUpqEFISoJHMs+ZWrVreYJN/SpvPN/tlXDopLAc4Hd6+05GHG9ux5J0gHD0eabkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZiAeQ+6qr9qHJ1ESsmm+AhEG1n4Cr3WY2eZEljg3aYc=; b=zAIdVDHe+79VhwgNi47Vc4DfEKVO10KUWqWR1dz0K2uwXlS401xCXa9534HFQShERwkAVKZmDehGnHTzLX9AW50UbbEOHAO84speMa2o/gH40kpRRhRFhp0WEQCHoGq6nrEu8FpEtHIx2dIzjZMuJlV+dG0vlp0wRCec4aXG7DcnWE6KPTP2pljHZu01Gn8MGgsJx2/jj407ldoQ11xseyE1gCsjusmTG0TtICVVXGiBAEemElb0vfyDUO+ueKekjZX6zRZuQavNZ66B6zljs0w7bajh7it8sv9dxn5/XWgXFfpXBnS3bU4ftJQMSOeMbZibpD81KjGUh5VuWFMLVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZiAeQ+6qr9qHJ1ESsmm+AhEG1n4Cr3WY2eZEljg3aYc=; b=mKQDKxbjQ+fXA1Ip/9H8kXzVn3NUsWx97dlCm3VKRaKQDXw58tsWAoLfcj1pkyjoKedP/611MpEIhCRM2J9AMuvpKvP+drfIV22RCekGjsSD6A92uzxG60js0G3dgYkPzoU9oT25c4xiUTft4j/oDV2iKnzXkuwp9TdTQ1LKj+xN7s2GQHRKqi6uVP73yPJunVVY1T9UB1bIn1GKmyGwu88u89IblRBEBEAflg52JGH5N1GAC0mMYWn6ikvWygMrCVo/KINR5Iu5/4vQHTkvbfG72a8lx9D7AIRBe2c2ksQka0fOdoZxO9cvEF0HCZ6eq5FldrOI0+lJrujv2BUcUQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7939.eurprd04.prod.outlook.com (2603:10a6:20b:241::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 12:49:56 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:56 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 11/16] bap: Probe Broadcasters with BASS Date: Thu, 29 Aug 2024 15:49:13 +0300 Message-Id: <20240829124918.84809-12-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P190CA0011.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:5de::13) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7939:EE_ X-MS-Office365-Filtering-Correlation-Id: e8ffb2d7-9b4e-4b84-11bc-08dcc8291591 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: p3JR5Ga20E8dsuF3MZvUP/wyA/B2aoq4vzG8uSOKPG2fip5za2iQYHkVq3OmC0AyhLM/lIQPkxP/HD3yCQVcbJKKU4S6f3p9oluCqxSO+aX3nEha7JhBHAMZ7uh5nTbvu6Apj0DuUOIZ7mGMk7PqFAjTdoVodFs9wuLKMg7BNgf63G/+mUyGGK+31enOXwucUIG9RzNwy4oBxph6hEGFV5v66d14IrXgKVxI/xRTocVpwVK7zU+OKUD5zmIhKIFcE1Yk4QWeoR7Qzt+oS/PNir7yFhJjZdkt0hNXlomiu9C9ch3nSRNr/vITlqHZvjvtd7Z0wZCekT0xC9vVD425/P/ilWEASF9JEKgBZuHQzPnvKavcg6V+TqoPZ9Jem1iGsXONTourld6kMps8nC8N3/+pDVVqkkU7vrJ5tg+CbtxxqxPuU/9L+z0uLjPHFAYxZRJcIPgeUA2zgfaX+IGnu6s9q1wKxZKSLrd2PDrz7KGzRjDZb12xRPmEkE3ChlmOWRs2Q7dTk03pd7InlRWXoocJI2uOllSMIOfI/qgpIuOkw34a7vSYsmQ8VbWX9itwve/KZE48yHGLA53mN+k0lQsJS4+SFkBgTkQCKukyie9qz+hytiMkYpe0FvcCSwbgOGs670f+vUNF1xcBReNQB7vI9JEQyvps/tBVqIQ8ysZEtUHj25B4LSXkOhWO034Ivp8JiFy9Qs3tk7QLf6u9kvIo09ZK7Da92VtynddNmopArrgjIg6rWcFeCvcDH5giIzuvXliBsmVZ1UkKLQLnK+VBWOiG2v18pluft1oPlg8C3LAzJ2UqCLyzU3Ug8IKxv9XV97Sk8PsllYwt/a3P/EDbdZMxDqPntZjQdIl8miRzeUzBF1ebhRsOsXfqHbe8+5iu2GZkhy18GA41VGG+r4X06deaxeto7xDP/n2b3WxTTgn++vdZ7Dsqz6iGwqNqPa9NY+6J18MfuJAAYa5kG53CxS1JTOep9jq3tg3WspTvzET0gllp3KMS5dhEt6Ai9QJMIv87JvlQf2oRU5ZodV3K59aamWUgYyDjL6r/asucanZ5hY3JxbVvDGrtFXxsPzyvPIsv2pjNqSLTIhmdV7zfAi+TJIhiKbJlfIRBUxhcen1Ljwt+e6O6sgmna8SnbB3OnLtxOKg8wjTCOgyEXtzIaP5fjI6uDy9BS2Y+9ZUSenh+jlhG/+l+O0mUyg8S2F6cJfnIbrfEqmb3eIbxo1Hb8fYOU36GrS3C7IT9o1tnV+hw09Hq/i4pQoNmwgMV3MCo1GwiVkMuYhP426+S1iKcb9YqPIUro6/ltTbAQXGevX5U9eATLKZwXEs9jXeml0b7n5GfZ1ImQdZmOBCrTw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CxobE9E8MGtYw9nQgEoBfnlhf1NIQ6vvJg6aIW8NIGIc0Gh3dWtTmNKvBH2llNyR14a3/uPBapGxQvW7cmM4AKADYXqaWZQ6vfW5cqAMtTN2Tkksnc4h02AJ7qOkzl3ALVNKDZk3polscfLBkU+iX8YwjK5H3tvy3qNex8vdoT4RQTNYQNjZdENMaGfGBlEWyGJRSfj+VC8tnilU3PvMDweY4C2jxX6tW4yknUIUvmbNyOXXWtnhCYgbxGWhWZsNDSBgnRmA+C5gSebL8VjyJukyx6iikzkUr9yAn6vLePrh1vdrHXmgV8nwZVajcXeNWdtMD2l4to1UkZNtzJgbNYMFksO+c+4mpj+gJsB8DHM95yF5ZjwrOhiWuJR7sC6OfZbJ1+ke68HBIRayzRU5wmLbleopDYfcmKx1gTWATn2q9d/sdZfV1xfMUKcRfxJlpjf4QiE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rBOd7USlskOcOpDKnkdJZoPepVLsuQSgYUpL3C9GGcYXVLKvzKxmXdQjTZu92nK71SefK/cnXNhCMudfjzWxA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8ffb2d7-9b4e-4b84-11bc-08dcc8291591 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:56.1816 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +N6n04xlnT5+V9oR5JFLi9HZYuIgiZXuGBEbMlclc98Lm3/bsRG0yRo3yz89ub9C9vjaPmLVplDJHe0ZmwQ27Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7939 After long-lived PA sync, this adds a call to probe the bap session with the Broadcaster with BASS. This also adds a call to notify BASS about a session with a Broadcaster being removed, in bap_bcast_remove. The bluetoothctl log below shows a Scan Delegator creating a media transport for a BIS added by a Broadcast Assistant through the Add Source command, and then disconnecting from the Broadcaster: client/bluetoothctl [bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep0] Auto Accept (yes/no): y [/local/endpoint/ep0] Max Transports (auto/value): a [/local/endpoint/ep0] Locations: 1 [/local/endpoint/ep0] Supported Context (value): 1 [bluetooth]# Endpoint /local/endpoint/ep0 registered [bluetooth]# advertise on [bluetooth]# [NEW] Device 00:60:37:31:7E:3F 00-60-37-31-7E-3F [00-60-37-31-7E-3F]# [NEW] Device 03:E2:C0:11:57:DA 03-E2-C0-11-57-DA [00-60-37-31-7E-3F]# [NEW] Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 [00-60-37-31-7E-3F]# disconnect 03:E2:C0:11:57:DA Attempting to disconnect from 03:E2:C0:11:57:DA [00-60-37-31-7E-3F]# [DEL] Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 [00-60-37-31-7E-3F]# [DEL] Device 03:E2:C0:11:57:DA 03-E2-C0-11-57-DA The btmon log below shows that after PA sync is established inside the BAP plugin, the Scan Delegator sends a GATT notification to inform the Broadcast Assistant that PA sync has been established. Once the Broadcaster device is deleted, PA sync is terminated and the Scan Delegator once again notifies the peer about the update: > ACL Data RX: Handle 0 flags 0x01 dlen 1 ATT: Write Command (0x52) len 23 Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7) Data[21]: 0201da5711c0e203001a2d5602ffff010100000000 Opcode: Add Source (0x02) Source_Address_Type: 1 Source_Address: 03:E2:C0:11:57:DA Source_Adv_SID: 0 Broadcast_ID: 0x562d1a PA_Sync_State: Synchronize to PA - PAST not available PA_Interval: 0xffff Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000001 < HCI Command: LE Periodic Advertising Create Sync (0x08|0x0044) Options: 0x0000 Use advertising SID, Advertiser Address Type and address Reporting initially enabled SID: 0x00 Adv address type: Random (0x01) Adv address: 03:E2:C0:11:57:DA (Non-Resolvable) Skip: 0x0000 Sync timeout: 20000 msec (0x07d0) Sync CTE type: 0x0000 > HCI Event: Command Status (0x0f) plen 4 LE Periodic Advertising Create Sync (0x08|0x0044) ncmd 1 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 16 LE Periodic Advertising Sync Established (0x0e) Status: Success (0x00) Sync handle: 0 Advertising SID: 0x00 Advertiser address type: Random (0x01) Advertiser address: 03:E2:C0:11:57:DA (Non-Resolvable) Advertiser PHY: LE 2M (0x02) Periodic advertising interval: 10.00 msec (0x0008) Advertiser clock accuracy: 0x07 > HCI Event: LE Meta Event (0x3e) plen 42 LE Periodic Advertising Report (0x0f) Sync handle: 0 TX power: 127 dbm (0x7f) RSSI: -64 dBm (0xc0) CTE Type: No Constant Tone Extension (0xff) Data status: Complete Data length: 0x22 Service Data: Basic Audio Announcement (0x1851) Presetation Delay: 40000 Number of Subgroups: 1 Subgroup #0: Number of BIS(s): 1 Codec: LC3 (0x06) Codec Specific Configuration: #0: len 0x02 type 0x01 Codec Specific Configuration: Sampling Frequency: 16 Khz Codec Specific Configuration: #1: len 0x02 type 0x02 Codec Specific Configuration: Frame Duration: 10 ms (0x01) Codec Specific Configuration: #2: len 0x03 type 0x04 Codec Specific Configuration: Frame Length: 40 (0x0028) Codec Specific Configuration: #3: len 0x05 type 0x03 Codec Specific Configuration: Location: 0x00000001 Codec Specific Configuration: Location: Front Left BIS #0: Index: 1 > HCI Event: LE Meta Event (0x3e) plen 20 LE Broadcast Isochronous Group Info Advertising Report (0x22) Sync Handle: 0x0000 Number BIS: 1 NSE: 3 ISO Interval: 10.00 msec (0x0008) BN: 1 PTO: 1 IRC: 3 Maximum PDU: 40 SDU Interval: 10000 us (0x002710) Maximum SDU: 40 PHY: LE 2M (0x02) Framing: Unframed (0x00) Encryption: 0x00 bluetoothd[4636]: < ACL Data TX: Handle 0 flags 0x00 dlen 29 ATT: Handle Multiple Value Notification (0x23) len 24 Length: 0x0014 Handle: 0x003a Type: Broadcast Receive State (0x2bc8) Data[20]: 0101da5711c0e203001a2d560200010000000000 Source_ID: 1 Source_Address_Type: 1 Source_Address: 03:E2:C0:11:57:DA Source_Adv_SID: 0 Broadcast_ID: 0x562d1a PA_Sync_State: Synchronized to PA BIG_Encryption: Not encrypted Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000000 bluetoothd[70621]: < ACL Data TX: Handle 0 flags 0x00 dlen 29 ATT: Handle Multiple Value Notification (0x23) len 24 Length: 0x0014 Handle: 0x003a Type: Broadcast Receive State (0x2bc8) Data[20]: 0101dd7c8046f72a00f863f00000010000000000 Source_ID: 1 Source_Address_Type: 1 Source_Address: 2A:F7:46:80:7C:DD Source_Adv_SID: 0 Broadcast_ID: 0xf063f8 PA_Sync_State: Not synchronized to PA BIG_Encryption: Not encrypted Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000000 < HCI Command: LE Periodic Advertising Terminate Sync (0x08|0x0046) plen 2 Sync handle: 0x0000 > HCI Event: Command Complete (0x0e) plen 4 LE Periodic Advertising Terminate Sync (0x08|0x0046) ncmd 1 Status: Success (0x00 --- profiles/audio/bap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 3b2a742c4..0daaae9fb 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1276,6 +1276,9 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, g_io_channel_shutdown(io, TRUE, NULL); } + /* Notify the BASS plugin about the session. */ + bass_bcast_probe(data->device, data->bap); + /* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities */ @@ -3297,6 +3300,9 @@ static void bap_bcast_remove(struct btd_service *service) } free(req); + /* Notify the BASS plugin about the removed session. */ + bass_bcast_remove(device); + bap_data_remove(data); bass_remove_stream(device); From patchwork Thu Aug 29 12:49:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 823622 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011019.outbound.protection.outlook.com [52.101.70.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3BC41B013F for ; Thu, 29 Aug 2024 12:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935802; cv=fail; b=FJYu/2up/26cFskWo5muRF/5kk69a7ToWRFPg646+K5Uq33PZbeu7leGlTcZuq5EBdd9gsd+kAshfJ7xLGJABChZQLqbvAXwW4wuTMiJ/3Z2p7S/BK9mb3FpKT2v7GawTPDcW/nq+YHaaCpw/9g7OgWt7aGy9Qu67vqWMnndAMY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935802; c=relaxed/simple; bh=Xj0iuXMp4wmKPn2xSlhixHToEFcoUPboiEoVbnGWTnk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Cb9JOfPvJY1vaej8bSZtehI+cMLA2urs3T6IEpLIa+2gcYaEBLqkA79oB3ypSN6yrnYZ15xA1QLiJRB4IfiudrP0o5IiNbpYG2HET99kDRF/DLwR+ofjpTHkpjSNyxzAAQS7y9VJmNjefOeo2UkoyvBppfAI2F45t7SMKVF1rxo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=B/O+kLqK; arc=fail smtp.client-ip=52.101.70.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="B/O+kLqK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GXeeCdeyyikAUrvidrZkjkeQAXlZmgc8xwMjUMImwU5YPeXjqG7KqE223QUSbXfK+yzL8ZukZbwRQc5SANk/GLN2wl8uU3JNZqmKWfekshboRYf27f6wft0AeXEcJWow9lSgkxeG4K2bqE/l1sOTYM1RTXRPtNBipTEAcYk/KzsxygnM+FgC50xG58CJW1KZft+nITv4IH3U0AsqNL7Sy8IFcGcTnqZA6/ckrKXC8ukU3FjTHFImSlRsiP1gcB0RpIgs4vW62hC5uQ74Ox1cHHwDgpDltBf8siT5XphyAmE9RyRkVoFHScQUWKVrb5Et7wDM1z/B3Q5FYN7N7cW+iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oTUifbOiXRLSvfccmIcxkAcS1tj32YAhduDe53d0QDA=; b=IEpZ9922pMN00x9Wubs6Hc3f857eA2LjQuAOmREnAR9wxyDkUDjYVoOL4Kp4QwfGgozDFFZx/76CkmKuOdkdYQUjF0zjtfH/DiB5jXHmn9jfHqdT0NfCbYALwY5hQvc0DULRt5CzxgGn4mkGlywkUVTErypdAOxiNAHrFR1noRZN8oalRpirkpw5yroxDdrGWmH8qsSFCq+EUEnyiAAYQdZ2Vw7krRCN0HCmZKVmVHsYEikHtOhvB3wxuHTRBXZlYLdboAKADDNE57WrVswSAL7WQl3AG4L1azdcv7Vy1gFNdlRbqLmjg9vVV6ARCZFmrZwGjtdXE277NiruP02SLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oTUifbOiXRLSvfccmIcxkAcS1tj32YAhduDe53d0QDA=; b=B/O+kLqKT+j8qDBZWvrARNi1VoW2pl2KAcF8YYRfAo+oQMBp5+F8dEHnnMjvLA8jyT6We7Dc1Qli4ThcIEFEzv2nMa4b9uL7uV5sgAQiFZlXjl6uukbAVQA6ClkIG6nUDeJItFBRph8g01y3sQZQQeiCxPBMaXTPlBcdj2Bn5kzgiaF+evHii75t+MnKOx3BmX/rFrW6EpDDciBs5UJnmwtZFfvK2aYJPuduInddg46IHgg/zkiiDZiqKznjWdK67itdVa6IOodKGGJVnKYL2wMUW8L4hVAS2l3xlr5qI2Qd5RfAJo0YJZ+RB3JS9IniaP/Ux6atDtJ2GEzLvIyvgQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7939.eurprd04.prod.outlook.com (2603:10a6:20b:241::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 12:49:59 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:49:59 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 12/16] shared/bass: Add APIs to set/clear BIS sync bits Date: Thu, 29 Aug 2024 15:49:14 +0300 Message-Id: <20240829124918.84809-13-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P191CA0008.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::13) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7939:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ba872f8-6c1b-4df4-ed6d-08dcc8291765 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: ROOLSPIIL8BIiCnIRaqXICrW/4tTGCR3paXTUvkMgZ/CYorPyD7sGEMXS5U48n17JTqHllELxkxLdmJV8Gpdc2f6K28UMuIBcDOFWs0SgvJMXOTwNpe7XP6KsNjUGxvQP9yiAOtekWMixG0QAd8QFwqnGOoL4NB6TUIsmP1nQsYbwPB9q6CIUjbNn1QSLUQ+dabTsPudzP2+Mb16FYTfUtV3q+USiga6UVQvx7xAONUbnfsNa2TmAzG1IKCmIh6zAX5gjspnSJ7VJ1uIp4zJXRKVYk2XW8UNHBuvO2aZaoT3z4uSNv8A740/f4sWbYv0lWmoSTkEndNmICAi1rJsZ4Ledgd4dx7NYxhbjWlBMmOKb9F/md3KY06RKwnSEwmdFZG5QbB/cX0ZuumJdePUX+DnwYn7LysGp+BE3Ma2EGSLt60TbmppZ6EpX+RCvIywUFtoTWaP7uABTUBT3krapKWxeQnaVf9ZHOzdIWC65mHNWiEp1MH4jPdrR6cYyvndNWmlWkAMIxkGRAsbRdbi0FWYrEaJqDhbwqBientOM11fXCe3YWIPOEODneE9hfuGoHMFzwrwjBZDRDnCw4kon0Qqzc0Ws9gXnP0VxJO/5QsNVBZ/ABxCsg6nvVkiGGODAN4nlcQKOXj/IGMwmdvA8uM2flm2AoZsMojs2ai7fD/P24/aJHmayqvuduNiZZl3Jy2BIbi8WUmOMJifpF+37mjrGJlAXleAbojdxzMbidb5p51o5PD/Cu7GrjAtT/Mp/2L1YzZIWAEzTtS5xdp/wGxTE1IbpE7mjp9ILVUhEBoH/w/809ua5hgG06G5ZQB/w5GeQdbMMdHyVsUEdhNNcqlFTP649GyzjFxuH+QIyRvxXyTaivmeeqYcnhC0O4OfErCtis+6boTFsl+PdeSt04HW8fhlRssiKkILEcysxlhz1Hi50gJtp7b5z/ECaDIfuSqOjomgjKnmBUIBE5g9/IWRNefKpnQODxQ64tR3gaSgfxHEaRAIBTgFHSQzB5/XLopXJnEvk3HWIJzAxOqr23SlYl1mSugleh/hYMDNmUoxCHSI4d/38gaT1jPB5XVcz4kr8oeo7lBcMpx0MUt6boM3v96x32GwSJpdeuPujzZFdEuVt7ltAm/evn1sN8ZcVd0xr2wR57xS9ExhInoEzRyd4+cCqfNzaZQiyAnn3NICMJxgzq8DlfhIEG2Nf7O98nzTj3n/qd/3yQAqidHtjOyBQrejjTbTkmn3ey0iF3mv5dNKhCKc8uqbCCD8O8xpegfGwP9IiYfTHXehdDFu8Irp5eOfbcdJIgdAcGnSPL9PSQEYLlXCRgpA7mGwNVL5PErmXfGeF+oPsXELjPCmEA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Izc3YQMFu9H9pXc7CPw5uE6u/b4gJfnsJSj5hRsGEuIfSh9PCKS/BaVDzPwhTVCtzrJkPNefBB990NgPVcUKz86bxGWcBj9riQ7/kM+jrcMFozOzCUvwvoudQZJVRKurhBIKAcRWj6ITwHk1T/+8IJ7WEgWF4pFAq5xbw8x1wCqxjd9Z7XNK3IvspvZExoMaFCH8ne0y3SmquvmNgXyEyD5KnP4b9RcNkAOCUr2v+UBvwkmcb5pGtNzk6JwcPTsKDM+JO5Z6PYV8E1lU6NLHny2Cr+x6D59w3lwKvKDxV2SZZydxO3X7GvmdDyMlQh6gnbz8u5EzVgu8kV8zJbJJIsXJ/XsYaQpRvIRuugOEuLzX26yqsF4ffspDu6FLc4XCv0DeYpH0e34WbFd++X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DWsKBzv0zFyp+0YSj4goAdf8LgjcG2I7XPLiq9kuA5Z0/IlwoZ92aA5gnqVc+U2tGudIAL6E21mXS1XPwhvY6NW6vPLBVf1AXRmGxNtwnbGD8nhsqgCpmoNjJ8cIxxmsgvjueMt8FZgj+VtRGbXfxwJmW9YgCjLOhA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ba872f8-6c1b-4df4-ed6d-08dcc8291765 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:49:59.2595 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qMndSVyVb7RTu4X+v0Ra7Fck100wOnfLl78CBojSL5nXeRGmpWHGpHhX0IoLpBX6rAyyTUK2kVS697kerLioYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7939 This adds shared/bass APIs to set/clear bits inside the BIS sync bitmask of Broadcast Receive State characteristics. Notifications are sent to the peers each time the characteristic is updated. --- src/shared/bass.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ src/shared/bass.h | 2 ++ 2 files changed, 54 insertions(+) diff --git a/src/shared/bass.c b/src/shared/bass.c index 958b6f788..8f02086a1 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -1766,3 +1766,55 @@ int bt_bass_set_pa_sync(struct bt_bcast_src *bcast_src, uint8_t sync_state) return 0; } + +int bt_bass_set_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis) +{ + struct iovec *iov; + + for (uint8_t i = 0; i < bcast_src->num_subgroups; i++) { + struct bt_bass_subgroup_data *sgrp = + &bcast_src->subgroup_data[i]; + uint32_t bitmask = 1 << (bis - 1); + + if (sgrp->pending_bis_sync & bitmask) { + sgrp->bis_sync |= bitmask; + + iov = bass_parse_bcast_src(bcast_src); + if (!iov) + return -ENOMEM; + + bt_bass_notify_all(bcast_src->attr, iov); + + free(iov->iov_base); + free(iov); + } + } + + return 0; +} + +int bt_bass_clear_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis) +{ + struct iovec *iov; + + for (uint8_t i = 0; i < bcast_src->num_subgroups; i++) { + struct bt_bass_subgroup_data *sgrp = + &bcast_src->subgroup_data[i]; + uint32_t bitmask = 1 << (bis - 1); + + if (sgrp->pending_bis_sync & bitmask) { + sgrp->bis_sync &= ~bitmask; + + iov = bass_parse_bcast_src(bcast_src); + if (!iov) + return -ENOMEM; + + bt_bass_notify_all(bcast_src->attr, iov); + + free(iov->iov_base); + free(iov); + } + } + + return 0; +} diff --git a/src/shared/bass.h b/src/shared/bass.h index a82d8f573..f3f708246 100644 --- a/src/shared/bass.h +++ b/src/shared/bass.h @@ -130,3 +130,5 @@ unsigned int bt_bass_cp_handler_register(struct bt_bass *bass, bool bt_bass_cp_handler_unregister(struct bt_bass *bass, unsigned int id); int bt_bass_set_pa_sync(struct bt_bcast_src *bcast_src, uint8_t sync_state); +int bt_bass_set_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis); +int bt_bass_clear_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis); From patchwork Thu Aug 29 12:49:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 824213 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012015.outbound.protection.outlook.com [52.101.66.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 600361B1415 for ; Thu, 29 Aug 2024 12:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935807; cv=fail; b=LBXH1WEuh0aZR/4VFylEQXXKajCHZfInxbGhjDBIHYufLQ6CzoNAlhMI7oR23l6YaIwE91o3bT4kY2Axd4r++Bi68zfZpTL/BjULwxwESSSDXPtog3aAtQH0E/mwhX6WoADHP0xXV+vhkNudBLKJQ8NpoHeYUz8ApwkAUlQm21A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935807; c=relaxed/simple; bh=ik7y9/ysnwickFshVrx4ZZ3k7LZuo8sEbpJyRsfkxjk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=A5QpxTEkb1ZD1pRJ4o6Z6cBLRv2kpGyHSJVO9zQlXgQiEg7TZEPUe8bvqp9YlkkoyLrjSc/a8oJTf9lGtnkrFX5/IjVdSJdWiMmqUbslY1v0LYYlCE3MFOoB8R8oGMUaZbL0AZrlYFyFjYOcg/ehhPCSEDBvqSHV+7Dtq6oCRio= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=ffQ4yFcp; arc=fail smtp.client-ip=52.101.66.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="ffQ4yFcp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BrFXH/2t6JSQou38JEGhfw/2q8SCARHpPnQtA5VGyop3F0AbBsd2V09sXPCc+whtMMrSZnN/Il5q3GUNMDdHAQX8FjNsixIlOoWVp6t4ILxYPbP8klfE/QgfC+k3bYO/qYtkeKrnCCZUhYsx/hSc/lgCeOfnD6bDd0bsCc67SxbSCvMWqMvpZOsLSXGBSh+Faxt52NieTwQIIYHSJzF1twACVSqYtHUDy5vFyjZtiB6n4SVdDUL2aYJyNfHFaTWVz0RC0JJjzNIxZgJJFA0wiEH2OI/ZLc8j0CJKDf4IJ3DloxuZKz9nt6NqNj9h2oV5fsK0wD9qT+p9fxY7NX+aYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nWWcPuzPkQrGyggI5XxerOGnp0d3BAmxDNTfRK3K0Uw=; b=PBMroRNX9q+pAygaJwYJbTNvDiSMIaafW/5CYYu8iKs684Ef8VKe/Eo8QeyQq4AWp5QoxrtAC66fAm4zdhgXzFjPvRHi8dvSwz5QzBCiYdwj0RTLzHIl0Irw1tAH88q2mlUANt98ykC+rYPsWwFvlyeuR/SZCEc40BgG8INgopaqYYe9P/B8YMdtfeiu8MFInMQ95qyouNPHYBd905nP554LSxSTM79PcTwJpDjHKNk9grHRmSZSNq4y2hH9Wp+vtP/Me5cwcDC48xEOfWf4u2kwHfED8lk1WzH26Ec5uwvSvaJRAh4MyNcpqmCR/FVp2INt9j2kr1Uh5FBzKVOGVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nWWcPuzPkQrGyggI5XxerOGnp0d3BAmxDNTfRK3K0Uw=; b=ffQ4yFcpLKcLYwdE2ICqmw8wADbUA2uO2xHqiSmXUGYXwNspahMNP+K7hSvM5z8gkMdfn/lXwq+LCAXDiJWu2cfZ5vIim2jZ5wFzd0xGVMLgssg/aXbcrMaeVOm1be18BOmvyB7gWmgbVJSL6nrBPpSyyW8KltJbj4O3Kf7oXH56bYZ47ozD6uiSvMJZ+7pmDbE0eBdSA4dw2F5m8xZ2v/t3K/rKi6K0KAWkZ/g2jHANLKrjfnv6+XhP4bFeHeH40IZycOpuqZ4+8iR5scTZJ4lub1v2/GkJ2fsAVZqLDwYNgBwSlwUyD/6gtPR7Mzftrey/jhlFzDq5FPuNHKNK2A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7939.eurprd04.prod.outlook.com (2603:10a6:20b:241::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 12:50:02 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:50:02 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 13/16] bass: Register BAP state changed cb Date: Thu, 29 Aug 2024 15:49:15 +0300 Message-Id: <20240829124918.84809-14-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: FR0P281CA0265.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b5::14) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7939:EE_ X-MS-Office365-Filtering-Correlation-Id: 497ffbd7-b612-48cb-8664-08dcc829194d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: BHzxpeJ16oUDW3LP4cUlLlb4IwN9FzPEbQSFtL1mopiV45fJacGumxe86L0gN2depyF0jU//J1R395m2XxiUw4MsYci/7MAMehR1kXuCZaNSaJ0uAWV5j6rVYpooTQUvlVJ1M1KYXjyVbK2CETzwO3SMffCmBnjDAaRe25h8vH8k8JirXuClNZd53HOzXkF4stn1zQZOKB53wiXrKxstqFvg0AzWlV1Fg5i2aqg9bKI7LP6nWin9JqW26revspKhRq9ftKOs7URLDnJ9VhHwRw29l37YkaAObC5K7Jo9txWLO1SzK5rthjD7IIszWSihn9TU0ZWTQEvgdev8DuKRJfJRgu83m2hpvhOcGtZHOVnnfsDomM0vQfy2M1I05VVJHuPIqi0EExb0Avwv8WmMMN9ZBybEdxtasCaCdRbdnxoa7jqMYBtU7nOCD7ggd0SgmCHeEGZBtIt9mRVlW5UyRTImBTwbmJxPYUS4wrbHvbPtStxpnvSoQ+WmiOag8UG9Kl43By1ARgk90EheDcl2r6mYnP5e4ot1PYt0QTPjHPN0kwyLZ1coqyr4TKGZzXnn2IZfDlwUPai84ZHQaj6uPg4/zD/f5tb08JZIVHsTBnxoJ6tAGz4Nu+mBqbNqFSmWBRYdwzihVobXEDryJhpQEHidfEnKxG02QmNMEkfrgtTnPK3R5Oes4sw9pDLGRMpjoOtnuxM9iquidbaGkISx1h4r/TDA1Ry3qTOZnDmyLYKcdvhOKgS6lIiGPcIoMzL9x85AfdMJKN5PJLxijgVlJMklcZzA1faeyP5cPzXpEB5lcxVNFKzsk324QzTcQmYcAIfnsvFw91udOs/MNJXV8fjzsTXEbrdD9x1rUR/DYjj2HaiOwzLymq6JieJjsL+oJ8+eTTGGC+BcDlCjpeI6g3/yE1Np1xnsDQ8H8/iK27eEyMWwfFNR9PlbOpkKiNswEFeBkE6k+Jef71rtPu8cPx/t1XOWeVX4XpdYraEPbZcm4Pb3OCEuDEHxB/AOjleGMekUPHDiA8Nbjz96j/GedydzxZmO+8OWJfNTqqyE4Yjm9c6JDF5DF+lk5Ab7K6AR4tCEJ2S77HCRbvl5op90LofSouDWK+67Ksv5+CZC7sOYt29jJFmOJ4iyKyXGZeUAVtblwMUnf/AJRguwbP6vVAa9C0jqSHvKTwErR8683PLl8vnk7pIh1gHgS/FlGNrWslYQpD3jqyBPI0SKl0TG/bQqw3McEibSLN+nOfUVDO1fGwi7hvrrkHDH891nYApqCKqUxbCpNajiJ40rZf2n0ckjsyb5YY5BZkRa0fafti4RASwWJroz4GSbFaWJFKsG0JI8i/CtWBE0i39A5Vqd4Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h6XLiW2vcZmdvgCahKl5nX2OMFnOrZWhUDAlp8GubhNQXOZFj4HJ1YdPqj2lm+4ZBg00H6z9iIaDpUFSPwKoC66xnzpuYE9T0kwmkbnroiCtb/5TCnQeYwIzfNbFbaKVPCoX4cxMoKIq7+T6bIMI1kDyKelVjZKV0fiDRgOBPK7VtrSYAAZ3/lkWX1F8tWIepwpWKGLBWBYwYi9oSkQaxYtXSa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yrZ4PL4ZfXC51s1vwbK+dq/vY5GS2HivwbrbJQpPTuec/AP7cNM5K8lh1fRp2KhhPo01xJdg1CWKWtc+EAKxF47PZcaCDgq061a9TAfoypr7BnLaHJn6JjLpByEthbVQKhAflFHEO2HwZ6a+J8SlX6Ipc4gmT/VtecJf0YLseUyYTj+MeX0pUh1JR7yzTWWoB92yKEqIikCHkq/A6LcSM+0d+sxzsrJuG0v31egcplsHKVgGy/4E5fyRybfV6BkkBf3F4rl7rvORK0uE3nOUn5K/MiSWYfFQqvHKdzCjMjDg0Vc15wZsakGbGsfV0nQWoQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 497ffbd7-b612-48cb-8664-08dcc829194d X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:50:02.5702 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AjJAC3D+64+ePz/ZkT2PVSat+h3gjPFBXqet9tWv6tdeH8iubk+ozxJ1WOea4kF6KHmL8dEsAT49VxskM1/lNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7939 This registers a BAP stream state changed callback inside BASS, to monitor the state of BAP streams created by the Scan Delegator and to notify the peer Broadcast Assistants about updates. The bluetoothctl log below shows a Scan Delegator creating a media transport for a BIS added by a Broadcast Assistant through the Add Source operation. The transport is then acquired and then released: client/bluetoothctl [bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep0] Auto Accept (yes/no): y [/local/endpoint/ep0] Max Transports (auto/value): a [/local/endpoint/ep0] Locations: 1 [/local/endpoint/ep0] Supported Context (value): 1 [bluetooth]# Endpoint /local/endpoint/ep0 registered [bluetooth]# advertise on [bluetooth]# [NEW] Device 00:60:37:31:7E:3F 00-60-37-31-7E-3F [00-60-37-31-7E-3F]# [NEW] Device 03:E2:C0:11:57:DA 03-E2-C0-11-57-DA [00-60-37-31-7E-3F]# [NEW] Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 [00-60-37-31-7E-3F]# Endpoint: SetConfiguration [00-60-37-31-7E-3F]# Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 [00-60-37-31-7E-3F]# Properties.Device: /org/bluez/hci1/dev_03_E2_C0_11_57_DA [00-60-37-31-7E-3F]# Auto Accepting... [00-60-37-31-7E-3F]# transport.select /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 [00-60-37-31-7E-3F]# [CHG] Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 State: broadcasting [00-60-37-31-7E-3F]# transport.acquire /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 auto acquiring... Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 acquiring [00-60-37-31-7E-3F]# Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 acquiring complete [00-60-37-31-7E-3F]# Acquire successful: fd 8 MTU 40:0 [00-60-37-31-7E-3F]# [CHG] Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 State: active [00-60-37-31-7E-3F]# transport.release /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 [00-60-37-31-7E-3F]# Transport fd disconnected [00-60-37-31-7E-3F]# [CHG] Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 State: idle [00-60-37-31-7E-3F]# Release successful The btmon log below shows the Scan Delegator notifying the peer each time the state of the stream changes: > ACL Data RX: Handle 0 flags 0x01 dlen 1 ATT: Write Command (0x52) len 23 Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7) Data[21]: 0201da5711c0e203001a2d5602ffff010100000000 Opcode: Add Source (0x02) Source_Address_Type: 1 Source_Address: 03:E2:C0:11:57:DA Source_Adv_SID: 0 Broadcast_ID: 0x562d1a PA_Sync_State: Synchronize to PA - PAST not available PA_Interval: 0xffff Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000001 < HCI Command: LE Periodic Advertising Create Sync (0x08|0x0044) Options: 0x0000 Use advertising SID, Advertiser Address Type and address Reporting initially enabled SID: 0x00 Adv address type: Random (0x01) Adv address: 03:E2:C0:11:57:DA (Non-Resolvable) Skip: 0x0000 Sync timeout: 20000 msec (0x07d0) Sync CTE type: 0x0000 > HCI Event: Command Status (0x0f) plen 4 LE Periodic Advertising Create Sync (0x08|0x0044) ncmd 1 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 16 LE Periodic Advertising Sync Established (0x0e) Status: Success (0x00) Sync handle: 0 Advertising SID: 0x00 Advertiser address type: Random (0x01) Advertiser address: 03:E2:C0:11:57:DA (Non-Resolvable) Advertiser PHY: LE 2M (0x02) Periodic advertising interval: 10.00 msec (0x0008) Advertiser clock accuracy: 0x07 > HCI Event: LE Meta Event (0x3e) plen 42 LE Periodic Advertising Report (0x0f) Sync handle: 0 TX power: 127 dbm (0x7f) RSSI: -64 dBm (0xc0) CTE Type: No Constant Tone Extension (0xff) Data status: Complete Data length: 0x22 Service Data: Basic Audio Announcement (0x1851) Presetation Delay: 40000 Number of Subgroups: 1 Subgroup #0: Number of BIS(s): 1 Codec: LC3 (0x06) Codec Specific Configuration: #0: len 0x02 type 0x01 Codec Specific Configuration: Sampling Frequency: 16 Khz Codec Specific Configuration: #1: len 0x02 type 0x02 Codec Specific Configuration: Frame Duration: 10 ms (0x01) Codec Specific Configuration: #2: len 0x03 type 0x04 Codec Specific Configuration: Frame Length: 40 (0x0028) Codec Specific Configuration: #3: len 0x05 type 0x03 Codec Specific Configuration: Location: 0x00000001 Codec Specific Configuration: Location: Front Left BIS #0: Index: 1 > HCI Event: LE Meta Event (0x3e) plen 20 LE Broadcast Isochronous Group Info Advertising Report (0x22) Sync Handle: 0x0000 Number BIS: 1 NSE: 3 ISO Interval: 10.00 msec (0x0008) BN: 1 PTO: 1 IRC: 3 Maximum PDU: 40 SDU Interval: 10000 us (0x002710) Maximum SDU: 40 PHY: LE 2M (0x02) Framing: Unframed (0x00) Encryption: 0x00 bluetoothd[4636]: < ACL Data TX: Handle 0 flags 0x00 dlen 29 ATT: Handle Multiple Value Notification (0x23) len 24 Length: 0x0014 Handle: 0x003a Type: Broadcast Receive State (0x2bc8) Data[20]: 0101da5711c0e203001a2d560200010000000000 Source_ID: 1 Source_Address_Type: 1 Source_Address: 03:E2:C0:11:57:DA Source_Adv_SID: 0 Broadcast_ID: 0x562d1a PA_Sync_State: Synchronized to PA BIG_Encryption: Not encrypted Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000000 < HCI Command: LE Broadcast Isochronous Group Create Sync (0x08|0x006b) BIG Handle: 0x00 BIG Sync Handle: 0x0000 Encryption: Unencrypted (0x00) Broadcast Code[16]: 00000000000000000000000000000000 Maximum Number Subevents: 0x00 Timeout: 20000 ms (0x07d0) Number of BIS: 1 BIS ID: 0x01 > HCI Event: Command Status (0x0f) plen 4 LE Broadcast Isochronous Group Create Sync (0x08|0x006b) ncmd 1 Status: Success (0x00 > HCI Event: LE Meta Event (0x3e) plen 17 LE Broadcast Isochronous Group Sync Estabilished (0x1d) Status: Success (0x00) BIG Handle: 0x00 Transport Latency: 912 us (0x000390) NSE: 3 BN: 1 PTO: 1 IRC: 3 Maximum PDU: 40 ISO Interval: 10.00 msec (0x0008) Connection Handle #0: 10 < HCI Command: LE Setup Isochronous Data Path (0x08|0x006e) plen 13 Handle: 10 Data Path Direction: Output (Controller to Host) (0x01) Data Path: HCI (0x00) Coding Format: Transparent (0x03) Company Codec ID: Ericsson Technology Licensing (0) Vendor Codec ID: 0 Controller Delay: 0 us (0x000000) Codec Configuration Length: 0 Codec Configuration[0]: > HCI Event: Command Complete (0x0e) plen 6 LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1 Status: Success (0x00) Handle: 10 bluetoothd[4636]: < ACL Data TX: Handle 0 flags 0x00 dlen 29 ATT: Handle Multiple Value Notification (0x23) len 24 Length: 0x0014 Handle: 0x003a Type: Broadcast Receive State (0x2bc8) Data[20]: 0101da5711c0e203001a2d560200010100000000 Source_ID: 1 Source_Address_Type: 1 Source_Address: 03:E2:C0:11:57:DA Source_Adv_SID: 0 Broadcast_ID: 0x562d1a PA_Sync_State: Synchronized to PA BIG_Encryption: Not encrypted Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000001 bluetoothd[4636]: < ACL Data TX: Handle 0 flags 0x00 dlen 29 ATT: Handle Multiple Value Notification (0x23) len 24 Length: 0x0014 Handle: 0x003a Type: Broadcast Receive State (0x2bc8) Data[20]: 0101da5711c0e203001a2d560200010000000000 Source_ID: 1 Source_Address_Type: 1 Source_Address: 03:E2:C0:11:57:DA Source_Adv_SID: 0 Broadcast_ID: 0x562d1a PA_Sync_State: Synchronized to PA BIG_Encryption: Not encrypted Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000000 < HCI Command: LE Broadcast Isochronous Group Terminate Sync (0x08|0x006c) BIG Handle: 0x00 > HCI Event: Command Complete (0x0e) plen 5 LE Broadcast Isochronous Group Terminate Sync (0x08|0x006c) ncmd 1 Status: Success (0x00) --- profiles/audio/bass.c | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index 933eecabd..ca20d6e30 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -103,6 +103,7 @@ struct bass_delegator { struct btd_device *device; /* Broadcast source device */ struct bt_bcast_src *src; struct bt_bap *bap; + unsigned int state_id; }; static struct queue *sessions; @@ -124,6 +125,54 @@ static bool delegator_match_device(const void *data, const void *match_data) return dg->device == device; } +static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, + uint8_t new_state, void *user_data) +{ + struct bass_delegator *dg = user_data; + int bis; + char *path = bt_bap_stream_get_user_data(stream); + struct bt_bap *bap = bt_bap_stream_get_session(stream); + const char *strbis; + int err; + + if (dg->bap != bap) + return; + + strbis = strstr(path, "/bis"); + if (strbis == NULL) { + DBG("bis index cannot be found"); + return; + } + + err = sscanf(strbis, "/bis%d", &bis); + if (err < 0) { + DBG("sscanf error"); + return; + } + + DBG("stream %p: %s(%u) -> %s(%u)", stream, + bt_bap_stream_statestr(old_state), old_state, + bt_bap_stream_statestr(new_state), new_state); + + switch (new_state) { + case BT_BAP_STREAM_STATE_STREAMING: + /* BAP stream was started. Mark BIS index as synced inside the + * Broadcast Receive State characteristic and notify peers about + * the update. + */ + bt_bass_set_bis_sync(dg->src, bis); + break; + case BT_BAP_STREAM_STATE_CONFIG: + if (old_state == BT_BAP_STREAM_STATE_STREAMING) + /* BAP stream was disabled. Clear BIS index from the + * bitmask inside the Broadcast Receive State + * characteristic and notify peers about the update. + */ + bt_bass_clear_bis_sync(dg->src, bis); + break; + } +} + bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap) { struct bass_delegator *dg; @@ -142,6 +191,12 @@ bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap) if (bt_bass_set_pa_sync(dg->src, BT_BASS_SYNCHRONIZED_TO_PA)) DBG("Failed to update Broadcast Receive State characteristic"); + /* Register BAP stream state changed callback, to keep up to + * date with BIG/PA sync state. + */ + dg->state_id = bt_bap_state_register(bap, bap_state_changed, + NULL, dg, NULL); + return true; } @@ -161,6 +216,9 @@ bool bass_bcast_remove(struct btd_device *device) if (bt_bass_set_pa_sync(dg->src, BT_BASS_NOT_SYNCHRONIZED_TO_PA)) DBG("Failed to update Broadcast Receive State characteristic"); + /* Unregister BAP stream state changed callback. */ + bt_bap_state_unregister(dg->bap, dg->state_id); + free(dg); return true; From patchwork Thu Aug 29 12:49:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 823621 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012015.outbound.protection.outlook.com [52.101.66.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E74D01B1419 for ; Thu, 29 Aug 2024 12:50:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935809; cv=fail; b=K3mq/kdrYEljvK3yxdyp51Tj4bvGxeExjRh8t0JPbPv+zmln7BZll/6lKGY7qQY+juYfxOhvQCjn2+lwWQbPY6F3yME+F0ysYoqIYgiO0ycVZ3Q6a8KaTfsImjUFKOymQaKqW/NkeL3hPhOdawSl1aN5uCu2s5VsH3SwTYOD3Zg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935809; c=relaxed/simple; bh=h1Pdzj+zfWtprnTo+hsm1383pgdYoXs7IMrbZv5XvPI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Mahkup5508ybKIFEkftX0Q6VRgDsFlFWb6t6OEluaTsiIrMHdljqJUTcLrkfGd/0nHWkG9WGAIVdLiTQK/jBT9FC6hDPWuDpTEaqwwLHPDEsYedVCBppDNrIBaEHEsOzJ74bTuDWscT3c2yaZCalX/X7BZxGZzObeOM0oIadZek= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Iu5+nOki; arc=fail smtp.client-ip=52.101.66.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Iu5+nOki" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sZIJEN/SGJWDjqX7okcWEvDlqxNmRFadcjjv/gw6So8CwCjVRl+WXUssiWTHUIQUfB0rhDJpGVrJMS7QipsuO4Kwmq7EAgzPAzd0ZlZmLcZ6rl3mB/Q43f/UMC2q5EO2nyfWRV1wRBSIjoMNPhKkejc8klUk85muIA+DiynYeRC2kCK2EYygW09RbN7McAZ+kfXCom1aGzRCdPu+gLLAY7sRVE9An5uQNLfZNRvIuhAj0LY/PCRmkOuqoguj4X04gmDkBcp2nmYqU4tWKLecOvHXkmX9la0iDfgH08kqCFKWy5ywsIKiTrs7Kec5VarVq4GrjHyjouCRZ9T5DTlQRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y1h42R/mGDQqlayKksC1QpMJXK0Ml/b/moD93vmE16g=; b=j0oi557YyQvH3T5akjs5T8V1IBk8LBFybkCA895kQV8fv2vbVOwLEqxOH5pP5mpydhf4OP88ESRM9GT1HnAty64+UXGbB1VNTmh45DwYGSupIChY4s3pZCM6H1Yi2UsWQUttYKj8TLr2t7W/h1gpTnZWyYmBy3N17fwk703VIQOv6V4E7LLYCCFn3WuAPcsZVIdMWAAjM7dV/2XJR+bul/4dV3R+G5oZce+e5CycdF1gDN8qdT8pDAsAXaToHegDWkROq+KnO3Y6svVxcAx1nG49Ja6/QbVHhMbDmiNnsjgkeilsmMhXaGAzakaJZV1x8aA2mpHJk21bBk0eVNDFHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y1h42R/mGDQqlayKksC1QpMJXK0Ml/b/moD93vmE16g=; b=Iu5+nOkiOag1+wrkA5B1wf8UGmx8CKsyGLtKJ/I08i8WrZJgvOZaZblPAKu7jsluuxsI/QZuzi5T80+dJn49CSRst8LVzS2l3HHPyltjnVj7R7gforh7y2+LRnKEzDzNyopSvsTpCN1ZGSxeTW9o1nBjdN2oGu7VnB1FFejc1RziSYfBzw0VqHMpg5AA5J7P1xpN77fxEzlWBAchRzQkOqvM7/0s3zHHoPiuE6bNWWoPlkgZM92AzDFPhWnBreZyF5L3JFyGQZNrmKGxaQmrTDrIrMswnKt4/zpn+6/vy8hX4Dig8U5/pXBn9q3l9sqk8LFdh6ilWms9tC+11FtUtQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7939.eurprd04.prod.outlook.com (2603:10a6:20b:241::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 12:50:05 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:50:05 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 14/16] shared/bass: Add API to check BIS required for sync Date: Thu, 29 Aug 2024 15:49:16 +0300 Message-Id: <20240829124918.84809-15-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: FR3P281CA0090.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::6) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7939:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c39a5c8-3543-4863-55b5-08dcc8291b0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: 37XDvQm4GAmGqHeJxg44V0a+A6+RAlGD8d6wcgBG9iY9ICWChSssSBzFKtHb9b7OnRJox/0muWqzaHeQF7ivDvI5Dka+Q3A92Zt4AxFguVFpB/OTv3kTwOX6y9h94DRGTJzsnEQ5Ka+n+7uiiwLToV8NNwoRdbAxoSik2XuzFQ3YcTnBalscxMc3g8V1rxwcNWzFi6RwuF17EDTKtYL8d/1gStePa/ZruqIZKPEUPlDJNH0WR0d9hBcrjZ8DV4H3NFHy3An8L40ke90LCrrY6gxEczK1/+eiqos6ntgRkPbUuMZKq7ecLs2jdOfjMsIYLPdG3nNc4GjcaVLIL0+/0foULGDmJYFj+XNeHBcQQefOlt/ZOMkgMtJRRbVthUpl/Db4KLBFs2QpFiIgeei1a4bhVfWt2+Arn9CwoU3LETzSOpYHFaXcQlluOkuu2eOcXxZLeCECAiuY4xAW2yPtUomPjlSAKevhyQp5IRka/n+wRQP9tarUYHLxo+OER9750w9es3mYI5GorEjiwjB1mO85+VclvUIXNBAhol25zbnCFFy36d7ujKoz0a5WfQf+7MCCB52mHC1FuS/moCcWSVSRbWnw0UKGuozGZQhhvKKaWfQISBhUP7BllN9rYOKmyluCmMYtb/BJ2/7fIMMdZYaS80CtWxSk4Ns4+QiFLNSJ91iAVcxQqr4GDGiXkYmvb3Erxx+CHZBhPlD+sSDzTrDIqg7u5I6PNgHlRQY4IER0OEWSXQg35kV5c6UwQMHKo0DA0RJ/rWEmizyupLrjdDQEPcghk09CgSX4X+ifwruWrmIBVKbI5+9tjnY8SOR3yS05Qm3+MH/xwcp3juzYFe3ech0J06ERP0cSth5leTdHjY81LPoXIrSE2/6DYHYbFBwYmU3rvYjKEOiTq041kTHAsOz2WPjz0u5UCLU6Rno1zB3SfZiodvqbEX7uhXpmgUIx/mH/3BwLoDovzETzhiNo6BzdsKXOqpBxhTnt6Lp5+J3YteXffeH3mpZlnaZE7zyhFh6gbQyQsf98hbv364NxufvbvrQpm8xYDMKY923X15wQuRWn5bOckkcns/SyqD4y3NAOiXDPS9hXb5u6j9NpWWU705uLSIdfZZiCh6oXjMr8ufV+LpyfLZvd49TFtYjDPT4EjtA0BDQfghOkZmmMSCR/Mmj4c71GLNShNx4wD8LQppgPmsa2H6dPS7Try3uU4rL/Kv0BkYSF/4oCKVSH4pmIxF5cnBqYZR0Zk3y1zkTog3hsfRpJVo4LoS312wodnryhjH4/UV5ZfUIj2Afb8XZ3TtqB6CCjK894YjiZNPC+G7N0iYYa/6m03HNA+AvV1lW2OFMF4brb6Dta1Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 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8KcOrslSgkaql00cUuhGx8xl2zp1p6zzZzVkIe68XFb9QJ98dpEQkQyJZhhDW0iDsSAG/QZTNorEHK2RptLElu3ag8FA41JVWXeSiYY15xakf4A8rlzGdtViAp5SR3B4b3lB5cFpsXqAnwWIequEd6El38Zdl7sifbGX5MExPJ6h8Tk8pL0JCqy3rip8gbP8TLE6G7m1xZVnB73x3HxIWFfFL5yV1De3TLx9A1XmHG4qlihS0ZimSKrsJHLqlbDaM1/6HXagMmLsEEQLwOrAKF8LP/HMLy9sMatUlRxQnmNBpE8i4m/sfn3ZaHYDl8IWbvxfK2nZCUErfCwlA2J3M/qylT/94kXjsCWUUz6DS2zoeix87xyd7JOWOx8sfAxLsyuKHVxdc2CrOPQACI/C8Ty9Dlxxdg1qzQoLOLxAYibsHKPwpAPfbSUaLckFmERioKNrgqxyB0taKg8gCGUJqs83BLI26/bH06xoBjeVhtRx+8MnE6qV3RxL3un5O/xIS7b/B9BSCkXwMJVY67uw8XyGPN4cqrYC2wzUFd2iV+pP1DvrqYnOgZAfP4Kg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c39a5c8-3543-4863-55b5-08dcc8291b0b X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:50:05.3923 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FgjqrLO1wr1yuv9zV588UQck0hmLRH6wnBz9ElWsBN2EAlFu37rFsc8EiknnzF3ayb29aMhtIwOpSaLkYc+LuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7939 This adds a shared/bass API to check if a BIS index of a Broadcast Source has been requested by the Broadcast Assistant to be synced with. This will be used by BAP after parsing the BASE, to filter out the streams that don't need to be created. --- src/shared/bass.c | 14 ++++++++++++++ src/shared/bass.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/shared/bass.c b/src/shared/bass.c index 8f02086a1..76287cfbc 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -1818,3 +1818,17 @@ int bt_bass_clear_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis) return 0; } + +bool bt_bass_check_bis(struct bt_bcast_src *bcast_src, uint8_t bis) +{ + for (uint8_t i = 0; i < bcast_src->num_subgroups; i++) { + struct bt_bass_subgroup_data *sgrp = + &bcast_src->subgroup_data[i]; + uint32_t bitmask = 1 << (bis - 1); + + if (sgrp->pending_bis_sync & bitmask) + return true; + } + + return false; +} diff --git a/src/shared/bass.h b/src/shared/bass.h index f3f708246..b21256efd 100644 --- a/src/shared/bass.h +++ b/src/shared/bass.h @@ -132,3 +132,4 @@ bool bt_bass_cp_handler_unregister(struct bt_bass *bass, int bt_bass_set_pa_sync(struct bt_bcast_src *bcast_src, uint8_t sync_state); int bt_bass_set_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis); int bt_bass_clear_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis); +bool bt_bass_check_bis(struct bt_bcast_src *bcast_src, uint8_t bis); From patchwork Thu Aug 29 12:49:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 824212 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010060.outbound.protection.outlook.com [52.101.69.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B26E91B1439 for ; Thu, 29 Aug 2024 12:50:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935813; cv=fail; b=atBKqfsFS2P2RQ9/hP81JAc2qOB2PAdrvilBoITadIuBPMkEWufTIZd33BE4nG2F6IH8pUSaztXmu8OBEK3nttp1S7f0ecjCBpwbf4Hq9m3xfLnkChmsP0IqacLckwAQ63ggZdxnEkarTdASKQWnqR5U1Z9yv8j9kFD9uh0PJmM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935813; c=relaxed/simple; bh=5MV5UrwmXSeydobPGwNOawb6B80ZeItyNfWTSaPGP44=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cMtvXh3qFpt7hRQZ3xVKKmtlc1fh/dbi3fpNWLyjaSceKrfHXRBLeTIv5489KkUY0Lg/T5siKWi5owVInxM28sZgsPdIOk6QfxYTI6auSsPF0DAOHN1GB6dCrz/1xP+PJ5/Aqj+fyKwDcInNq+AR+eWz5Ge5yISL/3Qc1wleYF4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Dtx/yNaT; arc=fail smtp.client-ip=52.101.69.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Dtx/yNaT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yB1707krYN5jNWKZr//QBiT6+jtX8hzHMEtEzesB2gc4WwNbHPyQDHDAUZHPWai471vNZNqCnF7YTDN4NaNDjUQic2Zq3d+DalUfLlQ15zACdMPfUWEL3KgLfNRihG5fmD2Fx5/gPFjhCA6FnHvL2F9D7cYUlXgQ2xvAJ7wdfV7739BFpfv5hSxUuWn2nSYjc4iG3Os1EcukOTgju9sxNDMyxzgCodKBYyJeAsiJYUGsu+pBU4hieTk7xfnv2EHs1R3Q6ZbobbmU/tlltZkBfQaUcn2MW6SGywEMlzsqxZ42650RwmcIbC+sDWWa2dHsBgGXwTsI+dY1d3yYP2McXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LUEXboWe2HygsTkmvJpK0kOAwb7810UMAQYj80HQckw=; b=miZkzO5jCUMk2ZMTCXODiNyA6f+T4MKUdWpGQ0s4mGn7Z3zqaFHbVh9XOy8a+ZyzMKuG5J4pZcBFrRrglPA/yS4M3M18IpHsuZGh5rJJx0r7ICNJZymcIoI8f5TNRywF9J47vO0ZWG9ub5aXo5e8aBNFPbSwkks/71gLqILJYShVDeiRnHXZCz9DViQWgcAOQytT9LfozWVkqXTVHVQcKjqx2Ws6pzELaluV6zFnVaq8fiBgztzmGhQNc8AWEKKgXaMIV9HLzagJ1sbxzHQLZQ4eE2JA1+/QO1TT0OxRXUNARFETZMc+lXxySTsSIghNur+u/A0S5fHM1+yQ6tkrdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LUEXboWe2HygsTkmvJpK0kOAwb7810UMAQYj80HQckw=; b=Dtx/yNaTyCHOD+JBPx6AM6/zf3ieR4j4JksG+Vy1HvrEKjiLIzkSXN65jbdAaiPOoe/NbP1exltuN2INd6DPh+da0sPLRngn7zESv2ODNaLBEH45NqBjdrMUjGRv9O1jaXOfrXZZ4ZN4kqe6P1hupaWNFxKJVACw+KzM3B8fYFNHCcou6vo+/R9lkJfYU7CKDRSk670hACAWk2m+NyaYl9fVPTNMCzgT+yp9Mto4ge4XM9Qx5ab937wr+SVUX4xCrNcszb3A/l2y0mD69KM14JauCs28xM0zmBP8KvlFq29EcY6PBnuPfw5uWEtnEwyOQUw5wcLCNIpqufnQhgLDZg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7939.eurprd04.prod.outlook.com (2603:10a6:20b:241::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 12:50:09 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:50:09 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 15/16] bass: Add API to check BIS required for sync Date: Thu, 29 Aug 2024 15:49:17 +0300 Message-Id: <20240829124918.84809-16-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: FR3P281CA0181.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a4::14) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7939:EE_ X-MS-Office365-Filtering-Correlation-Id: 48c46d15-0185-456b-2eec-08dcc8291d2b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: MQqop5XtdORU6oEbOVXwuHwd9rcHfuMAEwB8jVJowBUHBst9wZDGpzzP5+bHbAy8/gR/XH0sYR4b3/FRcIEb2Q1XgX2Ep04NpztpwZq6dAl3iiSpI1+vTHbi2sEwexzRq6Jfi1jun5oMEtdfBnbogjQau4FiA6s12ari5A//aH8Qn170ito0vu5/poGd8E2ED0T4kQbWudUWfgC88epWg5ivo/EaN4uzBjyzzcCxnR7r1oyxPub2Q6CIz17dYZheB7wooMf/VnVBh23QOfUQQ3iy2QsEh8rIwWbZ1D05kzN4tL3juRhPlj7THxVCnHEVJXUUSQrfDcMVnzZrDsXH7CmJr6kEfDdZhYIymzXLElrXfi1GCKTsc6X0LzpfJUwyKtItjHzUd+daOYsokXt3VF9QaDPCKgSn2d6Z0sRTqFuEaz2LkyJEo2AGOXc0fm1xGmIQElhXYxha6svDeLGAqEusoNwukN8FoZ/nrkvY+Fjd8LzOY3AwNw4JOCNvMfiIGfkY+gk38oYO1xSlB633voti9nNr4N/6BTLoIz9XDbEsrv4/pzBt0gMXMiugVu9qmiSV9p1bkNA9HA86f/dZBmuPJLQbj08BC/St9gxnUh3/xWnIM1pMTI6UJYIff0uKox2695x9CQxX7++Fg18DPYKsxrDIIUtiRR9ep7PA2JQn5B4ESxt7gmzpl/8mRYXXrRmZygkX9wSGBjGIcUX2vsIAdhLE12AQLXdF95F+IRugh0kdu9Z3/JoNBuJqxr/J/40mYLZkGi/IYeMrgvFFyemK9WqPk+iNSKAtn/7Dr+wu/e/8Dk29SYVa9QSJxylzY1AVMJMc+Y1QQfZl3D1z2z6Z+UiJvXd4hmMFEJ4azsCzL/PETohcGwSn7PQr2Ip/8dshQ0e7GW6cKMTw/l3IoOZJQzn7fUYTDr01BqlFkv3sreAEuDALMWB/tPGCKSfRJUUlwR1rLOoPW1+MeJ9mPAHJfVFTPTSV9pFlDS6cC499OdBvhnqE+JFE8iWZQ8z5rOqih204muuEBJOLwKTIx3RUrNhh+1AIPP/x2RnWFCvYXwioQdwyZt82ih0t/wKS16p1l/ws3QeCF2CNybXsojI0SSzdedp2RTJGqj2PysLgMvbJwu9ZHRlBqTUCFB1H9Z3EtogXykh5E1oFC7OQ7fV7tAIWHZlFgA3l2KUqzngNQRysJ24uHDAsnT9fWQM218nGKqn1dZ6sJdlSu6QNXaitYC94yZSFXdF8hSFmAkdlgld0xUlHsqcrz8Ll4dRIsIXSZBmo1+PP9tJIulA+LNa5hz0QQwRYR+0zg2Rjlr64eCC8tb0cOH+r8jYqYS55QJEzWjH176dzvOZw+wq31g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RAWuKWmwf/vX4I70pzhJdDjZOlThGfLR8vkakzXwfCLoG6MgMR2m26lfnSN38BCis44WQHk3CyzEaoi5q/uMDUA+lWgshRvJVavLXo3GpYGgtLjC8NJm3aSMkvXjKbElI5+cUvFSYZ3nVl26NEqz0iFV77Hcamu0OCSSJRMGpZUL1+4HDLFTqQYDdGzhyMcyDkXT0hZCeaDMLoN2QFwN/UY6Pm2ZGZv815LqJbbJkZfVcApvp6KmW2FuKI0coar/bpqXWItQYYq+hpV3pm6l+uWlL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pbGy7siGWRf7enlPfezywtVDq8tZwCvzLyne/68u2uZE54x/Qqg6U19dbILC0nditNBr59gKPCOcGvr0aHaWUOGlyofNLDyhHHz2ZnOulQxWu6tTCB02AqduKEacirE7yItbzqV0Hsh3m66bCmrBqvnFAj2GWYu8sSpG1GX3/x7PDHToprG/rz48+HtbctrdKZQwdDWN7DB1KI33C0el2sE/5RYUIDdQCuecYYUywIYCLfNcje53QanzGgW8tAu9ubQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48c46d15-0185-456b-2eec-08dcc8291d2b X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:50:08.9857 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1zN0E1lfggZF4mqg1cad0a5fA6NANpEeb8mTxOBU28kxL8MMkZaDpAm18v6tcBcQT8ooUbbznYhlNNcuWRAGjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7939 This adds a wrapper over bt_bass_check_bis, which receives a Broadcaster device and a BIS index and checks is the Delegator has been instructed to sync with the specific BIS transmitted by the Source. --- profiles/audio/bass.c | 14 ++++++++++++++ profiles/audio/bass.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index ca20d6e30..7553d1bec 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -125,6 +125,20 @@ static bool delegator_match_device(const void *data, const void *match_data) return dg->device == device; } +bool bass_check_bis(struct btd_device *device, uint8_t bis) +{ + struct bass_delegator *dg; + + dg = queue_find(delegators, delegator_match_device, device); + if (!dg) + return true; + + if (!bt_bass_check_bis(dg->src, bis)) + return false; + + return true; +} + static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, uint8_t new_state, void *user_data) { diff --git a/profiles/audio/bass.h b/profiles/audio/bass.h index 7e20385e5..5e34db90a 100644 --- a/profiles/audio/bass.h +++ b/profiles/audio/bass.h @@ -14,3 +14,5 @@ void bass_remove_stream(struct btd_device *device); bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap); bool bass_bcast_remove(struct btd_device *device); + +bool bass_check_bis(struct btd_device *device, uint8_t bis); From patchwork Thu Aug 29 12:49:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 823620 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010060.outbound.protection.outlook.com [52.101.69.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA53B1B143D for ; Thu, 29 Aug 2024 12:50:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935815; cv=fail; b=mEaN/QkslESKW5taQe9A79F3iH+OGaTWKle48wZx+r6UPXZBzDyGvZTYYUEMWMOKQy84+0GfZUybPiatAz+glGDBdSAYLMfVMPwWV2t/NyFNM94/qfT1BFhtWXTdH7x8i8mETq/43RdSfhD15ssb/fUJbpsC9xv8wQs0GOS+yTE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724935815; c=relaxed/simple; bh=yFTlVrtkF7sODqtToEJm5nwDeXSwhWQ8t2zHv92UaR8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Kx2C9shOX1qFfaZRiBVYolvlNbtCm8831koDs6IzW5uLia2jsW7AwBnkrkeRHCBsOr1GE6YgAfOc78pOqNAXTFhZRv88G+1gZXP5siurW9kdBb6VRBOwKHDiejqL446IcXRgtwXYSWWvC1gfbi94ZYgpQ4CuCEqmHIo9o8WKJ6k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=e0hBJaXY; arc=fail smtp.client-ip=52.101.69.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="e0hBJaXY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XqdeqFbusLED61zbhZJjHPIh6RLA4f7C7yTx/UWM6VZlJAJzacjiRZ2/F+rVMlfhRZp6kbS8A/c3s6rzu1xljvFHvFgqs51nXDo2x9Xk3MEXOeCMgcee7lwj57ECBcoYCoXEvX2uRKejk6B8tUVs56jeZNqHm+n7R1SVyp9UCVeJOXLc/NTEurzDXOARnBbDerULqdw/QMX5QJHuTQSfvOsuEJu7ZAVA4Axpsnq0IPSWnYRLeJSKlgBDOrRTY46FmXENPqudIh/lv1bodexvG/gqzwUp0trmku1tYTPJLBkqStHwohfCl5v86XIOJUMcfS5Wp1FjWDB26WgUSaeexg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z9aXSYqpbopLkJfiDw/t1eqe2QY6IMXxltySSnoFTmo=; b=hgh+E/DfzTetcUkubPNK0gl6G5JpfA8usp4xhGH03uK8ba8A6ivh7srdvBsdsWM6DjGxPtKpO4OlbKbZoJmM5s1N9XRbQ7olGGpuT0rGABOsh27bqLeb+Pe1htNfS/i/5Nv5eeT6hAVj5KwSu2+YZmqXNaosNLGmgcvYEKG2Tmn2s6JbyYHoOVrpAN6Sk1RN7BuUn6PXqamOOQnIIU9DsU5qa7hSXGd4m258J34F0uxZ5httzhTCkZHeRaJOGJmqkhz0MIYnbyozziHw9fZh0/axF+JYYA1BU82hRzITl3L2N7t+9KO3SvCkO5ZFfzWjDiVyqUs7pxXGPiz2dzyePA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z9aXSYqpbopLkJfiDw/t1eqe2QY6IMXxltySSnoFTmo=; b=e0hBJaXYC0O0jGhYPfyZSr1EhMDgciO0SbR4hVIC3/sEk2wykaNjdniMISPNbNjpP/5eOeow+8j+oA5o1daFAmANDvJGWeF89FQgllTVgzcMpazelXHMfTRxtqCm9R/SBBw2ruhqGQm5WbBYpg5Y2fgPWAgfcBRJ2HEWQkV29ATEfD3ZjbR74d7djuy1t3+tZcDmQqC/QNV9eQFiie57TOg55ryZBnmPlc8NcgPSy6lTUuzGmONVU+CuHyLmIDPCqbTRsI6Q/5MJLowsVfJVZM8kvuvh9PEQWOlH5iUoMbSkZFTMhrr5obCtNsOETEtcyufZZ0vuqemXQDcuMgouvA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AM8PR04MB7939.eurprd04.prod.outlook.com (2603:10a6:20b:241::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Thu, 29 Aug 2024 12:50:11 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 12:50:11 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 16/16] bap: Create streams for required BISes Date: Thu, 29 Aug 2024 15:49:18 +0300 Message-Id: <20240829124918.84809-17-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240829124918.84809-1-iulia.tanasescu@nxp.com> References: <20240829124918.84809-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: FR3P281CA0078.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::19) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AM8PR04MB7939:EE_ X-MS-Office365-Filtering-Correlation-Id: d0aedeb0-7733-48a5-edb7-08dcc8291ecc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: e29uKiTcCxUYoKVNxvttvF3JJEB5c2zVImURKgKTmtC568InqpLSDCZdaUx2e2Jx+mX/+XjetVt84ye85YXUa1c6RIMQLN2IPpIxe5erIWOdc0jLT+H3SEaoMUFRiDnfSJC2x2sPwDhbzD8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Md693rFHMm45PO1lW3BwXNVXVwPHIfVWerpPmKaUIH68CFkr5cYCRLrRg7uP22wnblOtdLG1QCxaheo6uMndfM2SB5sg8BJzdrfLsYLSqzQTOfog6LRuMLtGDX7kOfg0XrDIkPhJam5aHiooeyR1Ow== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fb5Kj3lnnVB6pDErva6TjrmuHBoUnv6u4DUAk3Q5oj2Kjomuzut7s+mNsXxqCcRyMa+Evaxbi+mIobIfVuiAESKlrzLUSy0qAG8STUw5HAts2MKwuuC0idq3A5aRIpBm9B6XUMD/UilNlRd6LMULq+n5bYcWqITdPPC3xSX4GWsmzOW65qG7+epl/8GkX4ix9cnL7wQchPjIM/AO267mbQRAhWmwcszCjTSaloy7qhAffFJNveAa8ePpcFVESh/5L1sVcBzJH8cxYdD+TMRRgHujhuJDQdDvXxgZdp9pYLBFCkAY8RmiilKMq1LiMoHaE+b35VXxKTRHh+3YQtOzsCkMTTdWHY5/H9beQz5xQPgNsiMsILaYY+xDyiY4UK0umMm3gkTAIeOCyuCn7jroSP1MK/KSWGVG+xNxIJLJ+jCWWft9gLvWb7I8o7UMMGR9YALEkxhSds/368geGTH4Ev2ivnpWm9DXu94jKb40U9GvovtOjXqt+VLDJCUc4gx+OHr5X4ly0am42ajM2liO93g1/tRIo3oSmFn7L6iystWgRxecH+l4/LYhg7qrh9w82D9z7fbGkCMYkP2x5bHd7Otyx39f2g+k/N12hf/HCEmxplk3Wxln25iUUSkOXllGohA5LYLj+q80GckhWvQwkGaFnQoIp5JpFIfGKfEaA/raQoeg3bPhkYUZNhC47eg5fiwOEz+Zxa4rhY1FLkMCLv2Ufev7PHScWRONuR768OOchQKx7DNU8ezve0oFSTsuI8s86wISH8d8HIQS1CdmHygVuEqwCsE4+zb276Y/Sb0U2BI/2S2UZJB8Sfbqh9Rd0/Him0+5B8XwcNr815yPDZCUXYcByLcttV2Ipsx0xAZxnTbz2/JdVxfuX8RVK9fjW6LSx+IYXucTzTZJ2eFDRzmRcP1jbP5Yvqwc72eRXxfcqyfGqTTpSZcNsS+tBLBSmwA35n8p3awjsDKRwD1eFE6wIlB7OnX/dLSFV/dW6W+Pv0IxOTsRDLmdiNSClYMxXxs7IPugzBrMNF4yi0eP7tLd2YykuuZykq4uCZB5C/cMPqjFs3Kb4dUVWMr20aXxvdn66TUZuqgyoKZgM95jy36Z8gfaWJe/5aYgdoEPgdAiFL5tLs8gQKnctqflTg9p2caR+Bg0fPwQ5aO74C5dBSpEMxHITq4078RMX8nKTJAf5Z2u/a5NfPPjKQKIYZfAyXqjO3CT0wcPh+fx5k/wR8UdYo77pP+pGLu52kdlNXDXAQF/XOIuxtz2SUk+YjZCClcCpFjlM5OhH25cEvpySchai4k4Xrj1NR6d8+igrnoQG+DvbZw31MNt8kfH1DpB/3JK2oNj3CXigNTnvLmGCf3yi/QQe2PgACHYC/riiYfcaMbGvQzf0r20/T6Jbk2aqzCKnu2BwWouvE01XLdVGbKHCIeb1joLeMtWrf1No8x9lzedRtEia+he7bvLniCw/yiMgmN/1tB/xuJ14fLwK0/mN4DbWURLFvQ+PqJ1w2YDFQKsHQWEJXpaaTHHalAD/X+W5MfUrEgAAXTdrNrbCdMJPfpr+vylmJ2cuJl2plC6YsoaLsZ40FhLT3gNxIBztAfmFvloTikmfIV3wbnuTg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0aedeb0-7733-48a5-edb7-08dcc8291ecc X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 12:50:11.8094 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gCot6uI0jpvQIAdI4BYXsmwyiQ0dwMSC+E6RAJJf2Epcj6AbNKDZl3JNsjX9CBdI5KRdFgHWK8h0w5VTCOlqxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7939 If a BAP Broadcast Sink is acting as a Scan Delegator and it has performed long-lived PA sync with a Broadcaster added by a Broadcast Assistant, the BASE should be parsed and streams need to be created only for BISes requested by the Assistant. This adds a BASS check inside parse_base, to filter out BISes that do not require streams. The bluetoothctl log below shows a Scan Delegator registering a Broadcast Sink PAC and connecting to a Broadcast Assistant: client/bluetoothctl [bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep0] Auto Accept (yes/no): y [/local/endpoint/ep0] Max Transports (auto/value): a [/local/endpoint/ep0] Locations: 3 [/local/endpoint/ep0] Supported Context (value): 1 [bluetooth]# Endpoint /local/endpoint/ep0 registered [bluetooth]# advertise on [bluetooth]# [NEW] Device 00:60:37:31:7E:3F 00-60-37-31-7E-3F The btmon log shows the Scan Delegator receiving the Add Source command from a Broadcast Assistant, requesting to sync to BIS index 2 of the provided Broadcaster. After PA sync, the BASE shows that the Broadcaster is streaming 2 BISes, both matching the audio capabilities supported by the Scan Delegator: > ACL Data RX: Handle 0 flags 0x01 dlen 1 ATT: Write Command (0x52) len 23 Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7) Data[21]: 02014605638ad50e004dda9b02ffff010200000000 Opcode: Add Source (0x02) Source_Address_Type: 1 Source_Address: 0E:D5:8A:63:05:46 Source_Adv_SID: 0 Broadcast_ID: 0x9bda4d PA_Sync_State: Synchronize to PA - PAST not available PA_Interval: 0xffff Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000002 > HCI Event: LE Meta Event (0x3e) plen 50 LE Periodic Advertising Report (0x0f) Sync handle: 0 TX power: 127 dbm (0x7f) RSSI: -60 dBm (0xc4) CTE Type: No Constant Tone Extension (0xff) Data status: Complete Data length: 0x2a Service Data: Basic Audio Announcement (0x1851) Presetation Delay: 40000 Number of Subgroups: 1 Subgroup #0: Number of BIS(s): 2 Codec: LC3 (0x06) Codec Specific Configuration: #0: len 0x02 type 0x01 Codec Specific Configuration: Sampling Frequency: 16 Khz (0x03) Codec Specific Configuration: #1: len 0x02 type 0x02 Codec Specific Configuration: Frame Duration: 10 ms (0x01) Codec Specific Configuration: #2: len 0x03 type 0x04 Codec Specific Configuration: Frame Length: 40 (0x0028) Codec Specific Configuration: #3: len 0x05 type 0x03 Codec Specific Configuration: Location: 0x00000001 Codec Specific Configuration: Location: Front Left (0x00000001) BIS #0: Index: 1 BIS #1: Index: 2 Codec Specific Configuration: #0: len 0x05 type 0x03 Codec Specific Configuration: Location: 0x00000002 Codec Specific Configuration: Location: Front Right (0x00000002) Only one transport will be created, for BIS index 2, since it was the only one requested in the Add Source command: [00-60-37-31-7E-3F]# [NEW] Device 0E:D5:8A:63:05:46 0E-D5-8A-63-05-46 [00-60-37-31-7E-3F]# [NEW] Transport /org/bluez/hci0/dev_0E_D5_8A_63_05_46/bis2/fd0 --- profiles/audio/bap.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 0daaae9fb..8d0be544c 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1206,6 +1206,15 @@ static bool parse_base(struct bap_data *bap_data, struct bt_iso_base *base, bass_add_stream(bap_data->device, meta, merged_caps, qos, idx, bis_index); + if (!bass_check_bis(bap_data->device, bis_index)) { + /* If this Broadcast Sink is acting as a Scan + * Delegator, only attempt to create streams + * for the BISes required by the peer Broadcast + * Assistant. + */ + continue; + } + /* Check if this BIS matches any local PAC */ bt_bap_verify_bis(bap_data->bap, bis_index, merged_caps, &matched_lpac);