From patchwork Wed Aug 21 14:55:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771704 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2049.outbound.protection.outlook.com [40.107.249.49]) (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 77FE81B251A for ; Wed, 21 Aug 2024 14:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252178; cv=fail; b=i1IZAWYKHBMmGGLk9OLoV3vrrHQF5yhMOT1aMEz7+6XroQRCpjGp0RpndMv794cU7YhwBostHZ6RI+hCb+7IFeUz7U8vatNxATQYuI6F6cel3TdZkIfd8PhSH0BdOZFdi6vMXYVgjSrkHa3s9D5t8n7Bt+8UUkkasjRCAokOsKw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252178; c=relaxed/simple; bh=7wljWqM+DduSEhbGxSGUs9FE3cXVuqtg/9T3pA6eiw4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HzLmrfikGR0sIyM+6pb8eLKMI27X0oy7RPvSkwjGkSBhAyoOqTMGSQsPwL32ozlv+8LUueNjJW9L1CLcW3goIZIrSEYLEEiFXnSzCaGL8KOMBV4mcwJXf9sRmErkqp524SI6nhdeonYzrzlYybXSCOr1r+6KpkP7/j70Bc7auXk= 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=mwCD3e/t; arc=fail smtp.client-ip=40.107.249.49 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="mwCD3e/t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gzflSlwsV/T8A55d6JaLg9HLoDMdfB/EImgo9DZDcX5TW/gmpOZiSDkgPk86UxvIgu3LGYfb4+8h7J28W7w8XyDE6HUI7ySEeltJF0ae5rnp74SmR75lIxcMsdhgs+Bl+i7FwX97TThobAri3FIrlkQlbxbXcbd5dDaVRy+BcBMafJUMPPvygkyWEI2UbG2PERgE6Zq7nUN3QhfKN7h1eRHIekBYYnA7oBe4U3ObcWrOU4nn1DRBya9rtbYUOzzLd0T8pjVf9Qn7PhuG141vj0nnof23fl9FK5uoD0gngmI+NwEfgcg8xorUXKcshZCwHkICAvdotILbNaA/HQ2i8w== 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=ulpr4fd48cl9mn9/fvY7mhwDwyPXBEejMRlWynTaFq8=; b=w8r83jF7vFoOabYSopF/I9DR0g9LlxYLnVgYu47kJaWMGYxMckSPgCLWbgDjiSvJwuICLIYEMNd0SLFYJ0fEY7v/pviqKauXrhzUcaZQuHtY/8+uioNTTeIp0hp++lL7kuzi4aCLu18ORoB1wdG3VYcd29Dq1gTPJvbauVk7lRbojPLhQN6WFqDMlrDSIin7nnTGxJxRCfjq5HzDh5rr/NnBbPeAV4yw8XzgVcaq3ao+eNmqPxvUbWaOLJpCyFAJ3YuUHdwzGmFp8sMtbvNfwzsMSNfgqkQfnU2WvI6tbkVwMcstaI2xxVJKMHuO9Djs6dJKLneD26dX2PSUtRAEow== 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=ulpr4fd48cl9mn9/fvY7mhwDwyPXBEejMRlWynTaFq8=; b=mwCD3e/tIkzVe1QuyahiYDWq2wSUwZjH3cxpl8HtgW53079XzwL8FtymvELikoeIGxLCO7K2bdyxQLCd2f11TlbTdmteQf6HH/tltNK+amydKx9k8KJseRW6e+QJx49bFrHhDi6JiMuJQglaoxP8RxKBUtyXuhFKTtld8rviVciwoGb4HLo0+kYk28GhgcS64g5n+u5exvbj+DOmqNzz01svVmEQLJ2yxk3dxiwTxoYABgmcewutwdIyWwddsrld3s3rlbxEuSlQSDjXjC20FLqPTTAHTA5xXqntSV/qM85hxMJa2KDI5m27BR2RkJR8bL0N66D8C+CDXc9WG7J6hw== 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 AM9PR04MB7618.eurprd04.prod.outlook.com (2603:10a6:20b:2dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Wed, 21 Aug 2024 14:56:14 +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.7875.019; Wed, 21 Aug 2024 14:56:14 +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 01/14] shared/bass: Register ATT disconnect cb Date: Wed, 21 Aug 2024 17:55:49 +0300 Message-Id: <20240821145602.92083-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P191CA0012.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d5::11) 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_|AM9PR04MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: 709d3565-455f-4ddd-db9c-08dcc1f16712 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: +wogUjWwkXEy1BGuzux25uTnverAAXn9MLPPmoOghlAlUhsj4+m/ik6ueIaI+MlpLTTSpHSc+QXqFN3JRbhxZYG8eBHZIPEZobXtRVMibWIgqxHakfwgOMIslKpgl4hiTX/6k3r20DBrbgLg5J7ZAmBCGChpdTRjsVr1+0Um9krj7iCB/fNo7WLVGH8e0udedL5gmzi8dRJH4GbnWcgmi9Kz2kRIwwLgs1L6E8AVE7Elon66GyVefySe5fplo9LudS6wZmkT+9Znm5HWoeaIdfZhnA81dMKveLaztWTroYMyfG25fr4mIB0xFOmtJ4ck2f2KP8NfL4axYK4l8wthFElVacRlrDULJKj6nDsywzwxxCdHWSKg2Qx3ypVYmEG34qJNJ2qKfxDmIz3w69iNQPDmq/B/sMnKUa9egOV1pjFggG+M7f+2/qBiAgX8Gz931KH0HPTUSVvE12XlQ6U85qzYAJZKQD3VIKN1kExHjKzTmKOeJesE3BrRHLYK4p1SLJrxmCWRH9uuxvexO57uudf8xQ+9Vj2PD/0guH8LzSHlwdq+wkiZhR9xyh4/qQW9yFe1vHy4NbEeEMCSghb2rFlR4DqJkRWtCOS9W68eeRi9uLTfC/I3YV/IwV8JxUKPB4OmdZI26iioCVZXsrMN/RpWAN2j6OaR7ixAJP3XXDpt1Xd5KWX6fiG6stnicPFnP67F0yd5n4bA5gMQJEU+RErc5/XtEoSv3vW+evgwBCI5VHv92rlScbx/pzV3SDeGYfKFzw/OqWsIUdLh9z4N1VHZE6ICIkiZsfGq0+fKkpqhMggQebTITXuNVyrrACPB3vHiOEroSARkiuJmEPmiAtxqrnZA2SHYDQn1JNx2Ja08CRhNaUnGRrdaKzB4/eVqIAmttoNJrLgsYKROhE2i9SdbHyJj66lpRsndvzIEcfP9Oe53UMCNrlO+GkkZTZryOzhiGY0wYosn2Qcg+TWy0CEOJGF+Qi/QnlwiC1QAN3eW2iy82SwmoYa94VUDybISWFWDGuqaakdQ5n0JFtI/Hh04JH1XZMMqlH58Jajniei1VkI/ouWdcUiRYAIAtoRbKIiaN6j/WiONsD8ylTauROLc36VkfAbLmC5YzhzVhBOujJJftwAc/PgCUtPp+UBtYJ2pwv3Pp8B5S0sTSVufxUxfIhZcmFyYM5AT9BXEtTjkOsNSeKlk/Y845nWr4Q905CtmEp7AtRPTDhVBPZPGfOWrCVoTgrUFEg5ETSxZtkWlrgzJopCh6sVx4Uzw2kx0hJj1PDPPdUSuuwoNOzBF4BQkPGXX4UUDMVugJ/zVL04mh5eNIIqQNghXwNkb8QR3iuriDMhUdpkYd0tHC7fWbg== 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)(376014)(366016);DIR:OUT;SFP:1101; X-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bHt+GXA3t+96KjElihqy1eE1Ph36RdDTW42hsPqf0Tu+4GldanDqrYNd2p+S//s2n4luCWem1zD9Ys0ofqpMgoDYEfIr5mIpQwpd/FFsDBWV7DGys+fWOZP4Wqw+tAitDQiEQklSRt9KpW96x0KxwoGkIE0DUhO8O5qyJv/bZZ/hoVctMuCn5hP7H6sEuZ/Ccz7AKoULdPmwTKdbTbF++ywz6xbS3mwySG7lVxLXir61qyzmuRVtv9wEayIUS4reMbAUhRApcHSmOKYoA83dB2ZeO8XmFRCNb3mvs2MWr83LO6CvcIFexfb9d2RrFN+7RUBW1FB/boiaAzyKerJGyVW9P4o8s6U2vfiwiB0Urt4xtZswtuPCI6jZGBbAIHaJ8zbVl86SXY0oL7L1tM52TD7en7yb0+UBWzVOV3PQwKWWSduUSRmhEgHgLcNE99BGl/cKsoax0bKpsB29bnx+mMX0q/LErRoi2UqugVvbfQdC9TeUBeXPMJEO8BMiv9ISBvv2TVpKkRJ6Ou3ynmlrcvNJd8RaLTvKebogGtZkaS+cIhCh0tcRSu5Ghr0lfjAqIoo36CG4AotfqCQQKmaRXZ0tzqQWNkha4A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 709d3565-455f-4ddd-db9c-08dcc1f16712 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:14.1105 (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: RNxpLs52EDf9buAjyNCYDcNO+lxZr75XkdHWfRmcnExKD669HVgSqHWP4OpZ+s3r7J4C1Ilga7tV7cngejXp6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7618 This registers an ATT disconnect callback with bass, to properly clean up 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 Wed Aug 21 14:55:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771705 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2049.outbound.protection.outlook.com [40.107.249.49]) (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 A0BDE1B2524 for ; Wed, 21 Aug 2024 14:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252180; cv=fail; b=AZ5DKf3WkDu11yh8xziH00ERDXqTFC75M3TJuEDrIuBun+Ht+WD3T6m4E6wKPXtJXSmj+F+KsZLSlbW1oDm2a2F3eLEoeMzfzQ7aGxw0I9FYWezyIBEgL+iCdpaFj8+GoYfGXbbA3i2Q2Ymakl3TuByrJz1OBYYiXvpUzXcfUjo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252180; c=relaxed/simple; bh=EoLwUWUOBhyU7gibLgVH8F/ZI+TfYdWGLy8RjLTFkBY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=emxxsEBajHDmjGiBkejq9sOJRsM04wkTwJTNKzEtkoomrGs28Eogo56a/gEYnKUrh6Xt7/QQRnRYrMY8LByKiwFGjtdLidNKwtMpCW8c6yJVx0E14uQ7Is21rziMANhXD0swL1JQkFBWP8iRrOG/xWCjJIWq5V2u1c+kBWbvA40= 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=WGyA4RxB; arc=fail smtp.client-ip=40.107.249.49 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="WGyA4RxB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A/uK/lrkx/E9OS3DHuAOoXfo1a1IyZLDaB1aWIFESFMI6uKqkAEt2HySFxdaJ3s+8rJZ5/NJYiroi8465lALXjyUytHhaiD21GMXP6dXdhlh7FBIjeOZVxPQvxnl1sQT3utbtGJhf5jmSAhuuwbhxAyrPBr8PuZTDBfQXLJjZZLgUQzMxREAsmL2UjxeI6HHBjzgVkARiLGwFPN7+pA54KK6y00RTNXhfxxCPH2yqIBIkLx43gugNhXJbOA1FFW4wHq+26YX6z7E5rkBu8d1//KScafgCt0bMs/hiqZoX1aPO+3mpleByCo1An2Efz2ZEr6/339Ar3NoxaIJv8DuEw== 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=6GaUWnikGt/IVfR5prLzSRcGv8npPOnXe/duAlPxmeI=; b=hMThwbNtFyTGO7PK1+F53pQ3eZ4lCSlNrom+eMcOaFUKlec+41AJvFjzWxD7BbDhxU1thYYyCq1SI8t2Nra+MFV1qlmojHmpGM4CGe8w24CxRAaNrrKte7mlMYjGByVcxnOzt7zsl0H2xGzCGquFJxN31kIPtrmhhPhIAUAIHOL1UsWxgcjqVtxEyV0UPVtlw8SZVeD2AUKS8VBgHRfhH6sD/NJpSR+zGMpDQBunqhcr94I2tOhRq79RXLBe3xqo8lc6b8xkHLK9y9d0L17VvZFkIjq16QKeKORBW/KScDaBJxiCMsLCZ9VM3tyrfhwRRQNTZURrDHEHufUzyNNNfg== 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=6GaUWnikGt/IVfR5prLzSRcGv8npPOnXe/duAlPxmeI=; b=WGyA4RxBcri1bytytH8wSQxJMofoaT0AuF4VvIdo8BsrU+Y8TDa4ptQyXVHOZWkuuUaJLybskX/4G+Zl05Sw1Bw2gUJIekodOPkik/8tK1jk7pqmUPXRKhWPYWpqGesHYTNJtq3ir5LYplItZnb5pkWRWjAL+2mioAD92rql85o94XrCZekTej6m/c96IWt/+/SISOD/CTFVOJXoS9JmpizJ6DfXSmVDAv1oJ4HAZh81ZI4o/L0LsEZTlUGcndYI0mJuQfL2CyajzrIIboYddiz+5zB0nYjl/wVCjIv4uuKrUtwiuTTqcdSQhjTfLbeNFgVIL3Pm0CKxv+PnhD0r2g== 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 AM9PR04MB7618.eurprd04.prod.outlook.com (2603:10a6:20b:2dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Wed, 21 Aug 2024 14:56:16 +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.7875.019; Wed, 21 Aug 2024 14:56:16 +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 02/14] shared/bass: Make bt_bcast_src private Date: Wed, 21 Aug 2024 17:55:50 +0300 Message-Id: <20240821145602.92083-3-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4PR09CA0012.eurprd09.prod.outlook.com (2603:10a6:20b:5e0::15) 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_|AM9PR04MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: ca28df40-8f4d-4e8e-a8fe-08dcc1f168b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: 2uaKOa6WLM6Xkyrebcu2oSWLhH3WkP1wRD3Wvm65ddeWr8Emadv8IaAX2qTT9m4+QEyX4HVyB7Xb7YkNjrEdRJGU058KG7H23ok7OWm/56auoQfYR0v15cU2VQXYD8Lc1qSrH7XClwiyyIg9E4c3376t58vwU/KKuNWa4ulT2VL6OSCalpEG5x/AclpBMqpt544aBaTkV6DEO2AFcrXJznSgQbmcnub+iFXKcoh+DRnTYvuoCZpI42ufxHaPBIRs7QG3FkDBxuIS5jedr4/DXQZ0t3FuqY2I2KsrWPHq9j0YrrHDmDisdVmFUHe+E5e2F4p27r1V4btggjJGzAcjT9OX7UmVr8oMqWSRD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KUatKIVCeDXFfIP9LxnRSspcmOCS8UVEpxIfIKP67QjS9bSJZDX5TRnmotQAhMVQW0AXSRF8Q9fSKXMlrxTy0mjNQrtf0q+B5DiEWcoZOiDk/QvctoGTq8Iqom9O8BF4ESxzkyrEA7n1iQdnoEJDQxi78D22zYF0FKn9opOA+fbwKYNQlrlP0qu1EBE3AeNQK0GrA491j4xq7E2WPWLfHy1Vt/YAT8YLxHyz9nxmfAnpn2iasg2uLQN2ytoEWl9iJAgEHrax/K/i5CF/e9ARERecM7LWDlFOhqoqKZIR7iB5L7LzqiwqlnSmsg4I+sQqnoW2i+jqir4ftIejaiH/2feZ761tteAreWvmAEb43XwfLcYJenYXQz870M/XU/nNTfsAhGLx1SaPxkv6lzLgpB98vl5YgRBeoNBhfbI1x5EixES/v4s5OJ1SZRzQrNOL0ZqsZl39yRd1mD9+3vWab1JAbdoKbFnNwVYZ4MVsevnXXpCDIZ45mYpnhckcLa1RbLUddk5sXL4ofLaHqTU+Aogsso/IYMi6x4AseNgHboqg4jd1iiv2lyU5j7HriXc7/byD9YUgizP0EEwqmFb/WRuiPGYh5dV5A7/fPXywN0wgG5w7qLBPFgvvZorl390m4KTs+a+WTPE4YR/KPvagBLXuu2mfYWuwGqbupY45V+kWbkWPMmciMRcA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca28df40-8f4d-4e8e-a8fe-08dcc1f168b0 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:16.8557 (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: CvLYSMr0u9E63K2x8WmD0BXUikHl3bB3m2WedV5VomPR6GUk9Zw92fio9S/Tu97uo9hJuwMs0TUAYUgZOyNrdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7618 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 | 26 ++++++++++++++++++++++++++ src/shared/bass.h | 30 +----------------------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/shared/bass.c b/src/shared/bass.c index bf739526c..ce13f2c24 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -78,6 +78,32 @@ 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; +}; + 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 Wed Aug 21 14:55:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771706 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2043.outbound.protection.outlook.com [40.107.249.43]) (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 594761B1D73 for ; Wed, 21 Aug 2024 14:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252184; cv=fail; b=ERSKgNX98AhP4fRdDOctCJzRY/kzVBFc7urJSw0RZjn5Czha8va8C4ZmJkXpwFCVMW7U9Z7wqLSpzrG4REjG/i5J3ShMx/64w2fj1AZGC3OdIxfQrAF039gAesZsngrN5YAg4bc0clImPBveIeIUUhvk9WJRkIp2aCHLDdvG7sk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252184; c=relaxed/simple; bh=GdrKSfE8RskHLwKIz7ufas77zD0wbF4L8HG1NyCYge0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=VUIMa+TYsNGXn6RUqLqmuvJ3VxOLcT3/mnn3RjZ/XLLlZbJgi1YyBO6rhv0fv708pZFbwJGB41rR/tYTI8++aNgFrbkeAyw1Fb6Yg87m7ojKZjt+lnwJcXmczCtIu4PmgTHs0ET+yLFcsYm0mMk+krHo7srwy4A0F0DZZlx/yZA= 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=bwSy0NHM; arc=fail smtp.client-ip=40.107.249.43 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="bwSy0NHM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=igOkxtwJ5dzatJJZk7q9edtO/qINYySf4cHn+DpGQ/GP9fYT5wlf3Bb0tyMFuVMY6BQfOHBRSxwS/URQy0eEiNj9sxDVKjf1oBq/YScn59KAgCrdlF7evwDawic47UOru4NxDCd+EURWWUije2USQfPAl7fLWciAIJCNsv60HPnPrZuM1/tORJjucL4uxSV7wALm40SPGy/tWZiuiOiKoCBLmcabuiNZNUzW8/2lT0OHcrGaPzAdROKqjeCfjlmlEehItCwdtgCvdsR/GoCh14KwjkJ3tr5WNibeuiT0qTkC/Z2YEUCFDhRTEsTPifur53TCqDw0YDS2ab5jeuK8dg== 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=Rqh8ShlMLengkjYJyf7tiFYNNbMFabZryoJvRZVfXcM=; b=ZVh0lm6weFq+Kbfy4cRra0QoNvQfSDAbA70huHs07bFH5p9ZsiTzQqSqThPYb4ziFE4qCczVOW0As4wlxTMGuNPFzmtVos9rRH3craLx6/ECUg5PqazJteArBXpL7ZzV5LBKqnbDsfPw8/HcGOAhrgS2R1ICqFpGiQu/0ULnYnuJNdcfPgkjTb2nHhw2qyU86NxGQq6mDHP0/lGF46CJMn53BGv1LugssGH7NFBwp5JIFNf1NZ5oHUEbEUOiVZPV+0My12E9l62ksPWObkeA3syyiKIOQGaObB8i3Nm+/MkE3QfUHJb+E/NkHIHYPTj0pnRCXFEIEc5pVxEtOuEuEw== 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=Rqh8ShlMLengkjYJyf7tiFYNNbMFabZryoJvRZVfXcM=; b=bwSy0NHMEkbLdCRf6Zk6Csq/ZbPZL11apX72rGQUZj0n3VzdD2XITtsgkUY8cDLZRs7umVKiAuWJFHKqdnj4oHi/9Rf42AXw6WMkt+F9dQ/Nwyp3mYce1QftEmfujHHWoXZ2pH9GdoHhQq9uPFlP3npQAcqtNncUq8CUg+fVDGe4eS4GppfTw+9us+Hw45QyO4n9Wb58WlXw7maI5bRhXJqiZ0lv82LwcUWMtA8p4Y+yOCs2kpXWdtoEKxlVP8fcE6YxtCvoEtGTGWD0N4dRHWBdiu4YEOtIWN+b12YAK+optBtqx2vWwelVScN6LPyTQgdW+AsaX+Pd14fGUpt5SA== 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 AM9PR04MB7618.eurprd04.prod.outlook.com (2603:10a6:20b:2dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Wed, 21 Aug 2024 14:56:19 +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.7875.019; Wed, 21 Aug 2024 14:56:19 +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 03/14] shared/bass: Remove io handling Date: Wed, 21 Aug 2024 17:55:51 +0300 Message-Id: <20240821145602.92083-4-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0021.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::12) 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_|AM9PR04MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bb09317-df06-4a8c-7f3c-08dcc1f16a4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: 6VLGA/kLIXcOYE+mnCij14Gp/KTcsQxzzFgAn/fyTLnTN28n0T/afenONsGBRzv+4wfaeUN5PlWCmAf784YklRSk2nOLQ44SIIMD6zizvgIW+INcVt7QBLDq0dV0oe1nF7Kn2e+rpCbCGNrBcCwTk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IoG8JqWtFk5AJnIQMBRMzOxbH9ufeK6G17n8m64QstDhaquiNA2qSOsFXzkl8tpk/Yn0/0ffNKJxQLRSDixm6hqnwDspIwyL6ESTL1IK5KzPvubbjayJMcvquWAcyT8tw== 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)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mOtE4b/W1F6M3Juwqs/X82fehLRBNsMDJg4yh77ncBfIyGHgdmlBMxVCATjPNHFShT7IDIy0UJAtwav1lQE96YfY/G73M0SAzn/llNj11yvWr2nnt7aEMOgZ7Jmw+mxdVhdhFga/KNbT/tcOuSg3L/Q1IdZXQnHFAQuoeMY+jOrlyLvBMqlANS2iKz7VHcx/oDwC28Gn4+qSKsTUb5zuC9TDIY0qOlzhsy3Dp3T9hLxVVBPQ23cq0jvfzYvWxnx9LYDXADZuOf6AUu36Ud1n/p1H2ad/O/4OKlpMZEIvZgEGbSpHDU9R0oKTIunVul90R/7qmoNBuChyLBXdFBKdJabUplSwdxzts+JusN5ZXStrM75yYdSw4uw6oJzCQdTtkJ9pL1to7ttAlIqe0Bdk+W0p35PDt81pAFoxsJxflzAEyhGn09JLRG+uPLV/RY9QIMwQ+U5mGh8/N9fhJ4JKicYq6ClkxsLAWFQUicOWTuCq/YQ1FG2vjuZM40qRSUjCnYDHP9DBv9JhXlR1jFCwjqJuccLoCp+cZaYFMHLmh1l9tqlwQShRxpZt6gsAglc2SabbjkB0bUZJCSGsQa30f8veoZcnjh24gSutrvLOvT2di+ZDmWmZY8dm1RvNtuV/fJwqQ+itmqVWROEUcD/iuVUm3DRxCldQu+1H0izqqP8yPRxR+FflmOrbLmqNtIONANAb51J1tYjy/T6H1+eQTksBhn4+iruhqSCVAH3SaXsTxIXBmbK0RsqMsC6HCnWCbjY0EvQxaUlnAG6FD7TQfzoIRzrOaL4OMBPm3zuk+CRKYKv/FoEnmOn4bEcxSRg1guePOmp3eq45VksoSoMaiZgqBsQ33h4QHXRKcpwBrnosMFfsgI2s/g4d/r9IlGjuRbppN5Ql/HubET/P9xLjcB7Y5g0XcyYQGPcHPKgE+MjwQZaTVo4m3ZjOiO92QUeaZyEGR4B6KBlqOhw/wswkEBKgmrCn8HZHxGQ1VTF2o2PG9DojoOgNeE/2IVS9Js8rO+8EdmWdqqmC+cbWkqO3x8YLOCxFzB5Ztl9+dbEi5aXyviAgVCZRR/b0XcM6bSFMLCljSVQhhDpJsldsr34uW7vBZylrwqiXb4pq6DQ0k99c2lb6scPd3hKtr+O7oGp//Rj6x9AoeyhSGlMalvt/Otj6+GQV99YBv0moN2EfDAWUfg5sklQLB31TftFvk3QuLKRKOksVM+XingiqSpoKWzEtRVYISto7KvoZgEPNTHXczJh3+s/W7uppb2DXKyNCRH/Rt9D3pMzBn+aY/aqu/fk4e6mCzt3hG/+ENv+rLusKpmNXNvbSL7t8ZumzxsdzCAIMFW8j1f+1N2bEUbcYYvUORVrUvl17z7QTR7gZWCsy6vfOLXJmWT5ycdHs/Jt6UkotC8YICZcSqZzN0IfqYyPKnEdJWrvChuyTDhqPXQPZhB1Uf7BWDtCUDWwyiIMplFe+mmfCnVkvOH+2my+OMpr2irFE+vrAC7SQVszJDoZTBzvtWf6a+39J44DtRlxwD4VvJXlik8JqbF1tqiqKTEDU7dclOFKLNqnDk8qqisE+zdZy2cng3hZ4PejLGKjfWNvydfBoguONkBTqJUi8tg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bb09317-df06-4a8c-7f3c-08dcc1f16a4d X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:19.6338 (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: Lk2rpCJscXms5RlN+KfeWLK1VM7Szvfi4rOpVESzJihbcscMJXIP9vaX4EfXO27Iel/LgSDkDeC0EUeBQWJuHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7618 IO procedures should not be handled inside src/shared. The BASS plugin should be the one to handle socket operations. This removes IO handling from shared/bass. --- src/shared/bass.c | 312 +--------------------------------------------- 1 file changed, 2 insertions(+), 310 deletions(-) diff --git a/src/shared/bass.c b/src/shared/bass.c index ce13f2c24..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) @@ -119,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; @@ -643,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++) { @@ -766,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) { @@ -919,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); @@ -942,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 */ @@ -1025,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) @@ -1051,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 = @@ -1122,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 */ @@ -1161,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) \ @@ -1375,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 Wed Aug 21 14:55:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771707 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2043.outbound.protection.outlook.com [40.107.249.43]) (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 5EE051B251D for ; Wed, 21 Aug 2024 14:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252188; cv=fail; b=KOctXSQHzckB0Nvel9ryL3n9GpY7P5hG6+UyUAgnTpESPtmr0LwD75crNehSTIfKQONo9g/4oSw9on01MLi54cCeyfypMMmn+yFCiuRXEDtcgDjCM2UfkxvnESe975/q1kqYoSLOqBJotqnv+h3C5csExfRGCK/YJs+zyAdBrcg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252188; c=relaxed/simple; bh=RkF68J+PDKIrq8XHFV7kRzCLCehNUl4bwfSWLw+aVRY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hvtNMNQ2G71eBZrODfVa6KOdZJ22A1/m4/TMSisI7Y0uTv+ubspzVA2XpnGNZCfptkKUZkl0jhcVy2Ef8VADvg2GvA9+TwPp7kGSfbJtFvwTfclcyjNqoxCo9Ftrz3nJoeaJ3xwJ4qDCANqRG8RmxvSnL7filGRN3Un7axWxedw= 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=cFKMJoCg; arc=fail smtp.client-ip=40.107.249.43 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="cFKMJoCg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZqXK/XPEuENqkIZUMO9plXwUF46O+takCepryk4BdvTor08s6h9w18gB1w8WxaW2LP+XAFPxk+EKQkChRg6YhgaMEvfx+i1jKywVHMzrOvQuuXUwmyg4uXOvB7gyo9jrQBdA5Gt/D4voxNKjC2+bT7btmqlJ+5I8veaUBVvcw6381uNBzCussVQOh9pCvcG5i4Yr945dpDhBP54y7RwMEkvk4fidS0yXAN/bRVBk3dvjfBvkGyl8noyrz5Qb0ayWQUydnGGqsDNWfU82FgkO7d0B4wes9xFeqflmFXjdOeQMu0++B0TqYmq2bjSVHzbrAZE/2Zf1PDGjUIr0ELfzzw== 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=Eg2NnHXfts7yKtiAvynfursASm+1a92E+spJvY24umQ=; b=cn9VXtUN7vaCj7/BGBN7S3VJFoC1JN2Bp2w6mknqTT1LsMigTvXvAMSOLPVT8xAD+05xk71OZltb03ElWogjMi253n0x6pHeBiKE2uJvkF7l7UkX2SsU+BMAKozHPythm2Ti8yDqBAgEg+qiuKOVbjGKPlgN7253xSmYkz0oLLmlJ/T9nM6DDCjQsJPfMvz3Yn6Aghps5FF62CdWBULpnVAeqbvBoA8fXngf8ad0sgGj95a/e13oD1c0ANW4nwnsgR705rTgN+aHFJPhk15jMd0L5C4G7opK8vHk3BK56m1Xa/CNwQeUXXbD6o1SX54pm+mgC8wxHC/tNw7nBKMTww== 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=Eg2NnHXfts7yKtiAvynfursASm+1a92E+spJvY24umQ=; b=cFKMJoCgXwCJ8OJZTgj+lkJgd+q8bprVOdxdkGT+8I7VKxQOTpI/euENpwPFE/pH/CA44q9lMG69Hh37QY5OXVzREfE9Jbnzw8CjC9mWof+AqXACHw92eQtanzk4iSO2Jc/tEcHImDKex49IdRc75V1nx0QO+vlUB27HDHBoPJfCga15wAh4f5Kz+jFH5xU3Zv290IWXsFuC80aLZQ0N7+RxKE522yIE9aPz8mQfGh+rLweGp7DOGkntZ0mLhOnfPflQf9iQM8a0BOfhmD6E0pjc/8U0B6EEJDI6JWZrmKf/6E/eokDVAQtVStwTgZSXgaSGlb+7mh4/pZ9ctvtjqA== 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 AM9PR04MB7618.eurprd04.prod.outlook.com (2603:10a6:20b:2dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Wed, 21 Aug 2024 14:56:22 +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.7875.019; Wed, 21 Aug 2024 14:56:22 +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 04/14] shared/bass: Add support to register cp handlers Date: Wed, 21 Aug 2024 17:55:52 +0300 Message-Id: <20240821145602.92083-5-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P192CA0022.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5e1::20) 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_|AM9PR04MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: 2af1c114-5ce7-41cb-2959-08dcc1f16c22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: YMveEXP3TpWpjUDC0SclOYmZepOEMTmPzOC8UUh8qMMB0tOknCGd0JQN8LuAe6X7cK+lT7v2Jpc1bTmnHQYh40kWSDIGYY0xPWFcLn6lz35RVUaw7S8tlafaPZOLlsAe5D9vLtHDsnMizIUdPLg1MeVUqQsmaI6/MiDfLYtV1bP7r+bsEk82CA3BukZRQjn/b+3k8BPPbLCMhxb4Q7kulNzaAj7pXJh5dZ2AzyOOxPuEkhlKNF3y10wg/jNfQDNli+KYNlQIcDiriM0xaRxOfvXOcHrJPxwIEurTwunLNXOLDfh7d2meXAzwCRwmrTxQwLwEfFHuxGXg/1e4RBALsf86Jy+kg/V12x3N1OQm9aaEUSuElt6dlOfXpywba2lIvDunju0AH0nW9XA/jod8ylr9pcHyY69qZ6EfGGFBakKG3JLj1y8ICmq9xTYi0I/mS+32/6+aEKSJhI2Jk3ABCfZRCD50ydZzWG3bIQ/hsMIL1iMoZcRV8G4cgdOcxaUmzvN2YlQXz8D6kokOcvVhTvneW6Ec5hsulSmAyVUQ6Vuv8Niwuyx7nDZF0Pcrhoii9F+sefDuKtlSqfgzozmvmnkUcH10OejsajkPzxdLbL2hEQ3bI746Vj2YxR6CrBaxOSlivPVg9dWOKVno5+17Q3swJn8F67zlQxnCmyII8L+NKy8PGEHfu2UMfUxjj9uCpo3twfCzV4Mh0M43sjE097eHnrp6mclRXnXC7S2r5EpDEKhupai+32RW/5W/abDXwosbG4h8Bdw/ahkDsmhdHyO5KVAKC+rms1pUlqJjXHjK80djEzu6s9t6FBLz6cS/Cem20CjlOYfMWiCYkR289PomLIWEaJSfm5IESLQIJpVuAAMD7+lPVsl1hX3Mx/+DkEvEnT2vip7FmSRRIJBX20EkBw4j7B9VL6rf+aIhYqEBmP7LxSoqC5EGKCx0q3dAqJuRnDGBCdz3RXsHWe6LdKutmBJLutNomr1lPsizlXtgkkZl4Znye2/MZzDRCPKyGs3UD46ogk1JTO7Maxn6WVCBX3VKTIJHyW2MpCU3V3fLqIaJBSTYBma2SHcYSdE0KmqNSItuZ5qxnEkOSVvOffceZ5Fzix3M+kp8Fq2cjSeE5r5eaS8/eP3GOMGula4BqYdxjdpEbUiTnrMwKsrXolTuS9r9E/fGQDd6Ykl+KF3YGzExHVHjSLi5lIWvsN0JwrxKqTomP7qnB9FCPT+cYmFoy5Twbo6gDMrw+xViMrmfsRxIM/Spd9oHk8FyKgcexF7xeJOkRZNJ1am69Nf1OIhU3IRKFK6KWvRrjxHLmYyRvXIz7pKFpcWJfxI90wmYjUCvSdPClGtJ2jo5s05rjg== 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)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eNpBnF5sUDVYhRslXxUpEOsMehIC99ngQIy6ED/rOVb7vtgE2RLKp0fF2tQ5juZ5yJd5k0jouFT1X/9oerHahU6bQ0B4m13mUPqNXGD0Urq40A8X2pLelinMI8MxO3uW69jqrw0fU9L8I1CkYBeLEcLtA4TaKt7vE9td4kvxwNhzIe+ViP0ydgf4Y3Yvx6nFnfh0aK9iSAaXUiwOkvCCv0C+qPJVMtleGlXwz7innvt9424n51kKiLS7Nm58aKkfNJEe7ohzx4sYkiTcdRwDEuLrbixSf48P2ThfQDx9CJVh9kRsYVOf8MQWMpgyuQrtOMSS9RyTdLqr3Bp7QrnboLojxSIBzJ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CCYb0sxvM65SasLwG5A1QKd3zHqsWGvDSAPuEYIwPV5H6FamqXhapoGuNtu26+vyFlsc+S8zjX6fm/mdB8ZINVutS1QLu0XRrNZFxchcy5BPpDftyfEdcvBEpwv6ScncrK3Xee/YBato7NgpNrXLxk6hXTngp3Fbe+2Hj2q+3fMMXGUqAXBYAgLF3g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2af1c114-5ce7-41cb-2959-08dcc1f16c22 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:22.6217 (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: 3KBzVMXhnZAOesT5p29H9VngznBE+ORmOhf+vn1XQz/yCBKnlSYM6QfUe96GxHZhHuWf2nITN45rccGAyiBQDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7618 The BASS Broadcast Audio Scan Control Point characteristic defines a number of commands that require socket operations, which 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 Wed Aug 21 14:55:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771708 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2043.outbound.protection.outlook.com [40.107.249.43]) (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 B25DF1B2526 for ; Wed, 21 Aug 2024 14:56:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252190; cv=fail; b=ehrW6H2BaOR9k8SZS7YibJQ/rwh8R6Qpbvu2qX+CSlx6oJ40DsVDhN1Zok9q873rOKHurNBrVloxAXSxSo3Lf9liP3ckZBs8sNvS1JKbEcDvUbOJ8q+fsVjM9kK5Ek7Zle5G/zGw5l//x97swa9+OYvAuHTyFSgz3DjH8KcUzgI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252190; c=relaxed/simple; bh=nsix/iydcx6bPKQBiccwOlfLprFxWvXlo1C93K+Ti58=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hJC09M+gesa8iSxwOVowxdMmM9Qja1nPv0+I7JIbtFc5XHIMTbb+jgWYSI7GV8YzI3IoR0aB2aAAQ9fEFx1ya+50K77CWWUekaFJQ+KG4g/fhl+BwaFTymbSa9JW0rf8BT9F/vWnLzhMcrapg3BEiqd+wAovOMMkQOuLkqtUeiY= 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=QOODsb3d; arc=fail smtp.client-ip=40.107.249.43 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="QOODsb3d" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Et7maD7VKzByeVRV4vJKBojXZzj68rAOlnAJRhsZqF0heO6CCgrG8SQX0DxoHtCcrKeHtloNk1pWoBqMTzKwuPtopk+aBbCe31/2NB1E0bCVH56iKl2yiVt/cZP34G/izXDF22lMnI6osjbe4/EUJSOdCIL6iB9DXdpV8bzewI5lVsmUPLxwaYRZ0NSgiObaCiaCotg+GFj5hQ9cIhkh7zJjFe6Jr/YB7ybA2NPVgzq+Bgo+sXHh6/8Xz4NfekZaoYeH1dLkKFxHIcrEh747CNu8CIn5bIS6qzir8UFleMd/Ggc+LyYy8WvoIKt+Lj4uvzK7RT0bJ5C68YrbJ+DpnA== 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=aOk76gSQzcEmV+4aDAZNH8bBzjFePn52Js8YUXJNBfA=; b=zAoq8R1NXg/hXEa4HuqFF1AEA6d79pUtvWNoJl2EQ91a4bCBe5/7if1tmPpDUO08wEzN7u6tlT6sU8XVE8aj1oUdgW7A1yyjm1jxnHP1xkxoF+PpUFO4ExRwGJuUJFYmUtuZh8fSs5FOM+2w9dsiFC8zh3jVJ7b0s+02Cg3TqDtgTYJD99WU62VlI2Mn29NfroyMyPTWz4cLcGrJzcDtZQnPM+K+WAty7wIA6WENylAkwlGToQXgDuhQR6fOSTWKAGOXU2tbY8MF94++WUv1kYa4cTP5sNCDJOsPpZrhLioyqma95hCMXlf+D0dGUxvMNDDAIBi3kHsYleMH+cf8Ig== 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=aOk76gSQzcEmV+4aDAZNH8bBzjFePn52Js8YUXJNBfA=; b=QOODsb3dLIcsdq0cZfd+coFJqXS7MuLkR+YbeqMtkPB/ti5MJX7DWoXolurh9RL8Zyma7krDEcTeXZhUKKyEe5UeF76/rdFsX898r/YIATYrmO4W9XPaIjsNzRMKaeN2jHVnE2Py3XBcCaEEbj+aWULdmFjh7qszZGulDvAaKKdgPvkUgG68Mq9VHcq9HM6Pydx9AF84Ha36fX9YnvWlYQsXJ4iDL4+FZWvvbQ0xxrn4pCrkJwxB/kTbUC5S8AUFuDn+IkbzOSxqGWAKqv/s2qsRTJlGKogoxMzHNUKMUqDDWJBXtaIgCk3q3g6NMOrCst6McoQQUR8COhmlE0tHUg== 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 AM9PR04MB7618.eurprd04.prod.outlook.com (2603:10a6:20b:2dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Wed, 21 Aug 2024 14:56:26 +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.7875.019; Wed, 21 Aug 2024 14:56:25 +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 05/14] shared/bass: Call cp handler for the Add Source op Date: Wed, 21 Aug 2024 17:55:53 +0300 Message-Id: <20240821145602.92083-6-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0019.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::10) 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_|AM9PR04MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f160f4b-bab3-4ddd-4461-08dcc1f16dcb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: rGMT39WFj1o0nd4PHfYH34D9cYYkdidf4mHhEscOIPZijKcMOd9FpSmwxRIlspDig89ltJPzd/nhozQ7/3UL9vH+83zHvDBGF0top2VGjMoTTFDwB1luyik65f0gfp+/0It/Qxxk0SyCvhmrEEA3e2q83Ixulu7wa7VT7mc0+4+roLrgz1dyAwAHTMOgOa+AeSasWCxSUaL7GFxcMCv2bPAXnInF2qpRHwW0zsXZa+/RWG/0sru7/jCYPtIAZP8ZvCQYEYKOl1sBgB9Dvl3l/qGo0lZ6LW4wPFuBMEdkWdd8t/uQwNV4ayLin1tAZVf664Q0yjYKjQ+jwkAvS8uR4+Dt+JGbbUuq438nbUBK1uQ4v8kVzwiWvAaJ7RZKjK8rVFbl0TlQ/7dsF0Vk130j2hu2a6bOM681/0jvoZDSU4ov0d1/etorhTFnXi+rYnbng+L2Mm5YJMQFKs+ig11M28x9pSMIkv4NxgLLvIS9ruHLmZ5ByWAxo9ZO/akjXewmeSlyyq3Rj803iY85VTTZ1ciBuEfkmXXU7MGjNLU35gA30UViXJlNCRY9YseSdte9t4QB2pSR9MK8b7rDFoyKkRtAjJqGypxGJTncLv3ZwghEH//rHmnYlz0nENP0fXY26d5hJH1ecljhfNXDqKDGY+9gP+Fb1y1ituE2e3i9jGx0Btc6nmhudhGiBbiggiUyBpb+67iXhQpyE3/vuUwomwvqtHW64xkzrD5ywt1BpKaTWAeH0m+87FzpyzZVRYUina07XDlRUI27oKcujo7niqyPkILbB4N4btkCEjyWv0/f/4ghTh4IHxAPY6I/Y7UCzfdWW59wFDF55AFohAIG0peykIx4+HHx82oou9j1QMmcCXNYyjJBZSfzhs/oS7riL1sYwcYySXmF8l+YIuQA/pPwnTMycBlsIoh4F/x20t0PkLG8PWtbNZAuo6ci3UdSr5Z3pHkaquMS6q+aM7HOQ2E8UfoGXcaLWi2G/Ask6ELUZzpJsZEzX5YRYAVDir8KKKT26kPS/XAosX1e5Ct6rAf+mAmUknWYxYQMxvdGn33ViObSyu/SqL/75GBUDSZNmX6aY2Ojlx0NfbEnqvslXdlFsIusBkxB091eYF3b7qH7t3AMbqkGWx1kET6rI8h6MlDNbWaext9oFdg8FKCLwDwhYN8DoYTfz8gfyw+Mu6stjSPLCTyNsU36TYC1ICk583qD7VYQzBlxWh9iwsZzBSzmFxmUxJuaeRT74hRuMkTe+0IP9oyu7TmROsyNtkc6m0O/spsMWdRIYqpcCkEBq0BgPlPeW88CoXj9DFlgKxMBwgWFcjVw/6nc52EuMt4ESWc30x/wRrcOi6zl6SM3qw== 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)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xWmXDwnuRN64t6gTKg618/GqI2vYzQzOeUEzvRseYXy0M0XLZg/mRGHFjFP0zNurpPCeLZ4u9dc939+0KbwQQ4ACc0YdH5lggDX3PdeM2g9qG71AsDgXg0NazimcdzVP561jmrtd2c8FNEgwh8nunpaFcrVZou1DarrTU2qDAcXp7WAmw3BZpb0mJw/V2LkSsFvI2Ii5qZCnfVoEjl0F/D+BymF7MgwbyRb59nkCVcopX3Er3fIr1AbDD2k07VB2o7u5cVTouGupMLbM+66oJp2Xy9b+Dy3h3ldQDdEkCT0aAW5hNIfWAxZz/PxF5riO5I3FHN+oFMpU1xNEHWTii7XOu0XMArvBrKRy9TYtBXLJJAPn4AQtbGQ18b7/7YIp1uWWoCBHSxRs+/DYYZXZpgJGVe2mNbiS+NvnDNQXDe81nAl+l9Bje9S6N61Uii4JFigK+bC8MhgJK4BKATtO8jQaeMgyB173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qN932g2/TGZa6TOGkbqlt9vNBZ2NbqGJaljwJazfq/+F+3l536oSF8ORVHlcQq33DwsVJK25BtFQJlK0ScfA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f160f4b-bab3-4ddd-4461-08dcc1f16dcb X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:25.4117 (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: w+KhIZ0rJXv7NAtXREKIbaNefKhrtolTGScDjYzyTAPUQg5Lgj4ncsQ1WcWgie9WaDaa9WhiP5KZ4IfUy5ao8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7618 This updates the Add Source control point handler inside shared/bass to call the handlers queued inside bt_bass, so the required socket 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 Wed Aug 21 14:55:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771709 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2043.outbound.protection.outlook.com [40.107.249.43]) (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 C43791B2ECB for ; Wed, 21 Aug 2024 14:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252192; cv=fail; b=uan+cCNVQ9l6H9TFHduouGTtVeVgWLzVGD+GJry9Qu7mkzVP4fV1diHOmXsODmAhNUVYxCg9sQJ79Ya7UTrC0zx5XN9v6bjb8wK6c1DbXm1A1RADdOwi3B9BwfnOqVfoE+zs6LheS5q5hXxgljVi4A4DiRQtunNUCB2LAIK1agM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252192; c=relaxed/simple; bh=95UH4s/foLAkT3QKsu3Buzf/TkhgaUTyMyaYD+vUJ8c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=GycKwDHSMqYuZTc7EVecU06ov2cDigkkLa2PStlg6kKYzwNJjwNdqGLwMgsNf4b+YXiDJzoDHYdy4szwKllb4VjXSiGuP5LztjAv0MEA+wuRJIieIhcT7/+F5yUqA3ue1vLzhrRzu7sUuH5qvZrfRbiR9+ZHwhAWu5RdkLr3H+4= 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=Wxv89Vd7; arc=fail smtp.client-ip=40.107.249.43 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="Wxv89Vd7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d+iYoFpu64L3H+VsaLhoDRN18TdVeoHJ3bkygEQBKgsLgIQzj7L7h4iovdtUHKQ7AUHxMpBTWrhAm43u0tBc4a9B9eArmty1bPUBhUPgdexacsz78wH9M1tDdJ+aKWAX0kYpqTlGCDJfenQfGD4l/hnGJk75dVszdvSHbtOchbIevCqdl0NLwV/tmkGOHbo3L0G7sZuRrhCKkMI03WlLnK09QvpgksApGhUSqoApMFqRqtTbMruG2ggVmwbyfd/z2NY5+subGVk/u//ZH+ageb9bwmYKCASJ2vffDYOghPH6z3kbYuVg6iBNbEvDy79niWUP3cGt10lhYLZEwgsdFw== 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=HPA9UyDUbYSnziAvlCyD2eNGoyv3i21ONWLjsV0Q9eM=; b=q3nMEY7MEEFpNOeHclBgeXCoh1mVxxU13Q0tIH2r8BBVJEFGba9k1lkx0yyQflB+r8oT7+Z/Xana5O1mmrRUKB1ZTViME2svz5nNRmSY584gpxZ1lrPndlDGDwHTPkD0/RAVdxfdKh7MgaZJ16rm23C6p8hbp2OV9Qa0gXW7/4lJgE1ExPZuZKZR3/We2JG8Cj8ta413ou/C3nJUv7XUN0GuFA2ERK7QBEWVxlJaZ1ogXooUcYgRmj9OFk0EOG7hJ6EdI0GV21VVFu8RGLkR5aaJbTHj1VKGiLtzE8maCT/H1Y/AgpLiLz9N0r+U6Oa4hGvWQTiW3OIeolcklNeWyg== 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=HPA9UyDUbYSnziAvlCyD2eNGoyv3i21ONWLjsV0Q9eM=; b=Wxv89Vd74pBOhRactiGF79IlhWAstp9A0i8O0lef/M6O7oniFNyrlvNic0Eik7OY3zPARpzNKub7RQH+9j9w1lx740L+9/xKQpSDpRaKAdRxG9oeK+W0KMZBVGg2zkO50ntTGsrtP95mXTROWoKHttwKxUcgyXRrjo2NHbnUMO8ThkwO6e89h/gpnqyEyJO9tux0no7+/KlLeWGycbyfPJim42VVZU0ie7n4HSRWME17a/RW14NvpAHMQqA+wuUEr0tyY0pgiv2+GR7mt9PpDRBawAeeRCtRDiACILodY8xTbUeSfbmT0wlrPVb6a+JSqehmBn64AsZATq/PZ+Nerw== 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 AM9PR04MB7618.eurprd04.prod.outlook.com (2603:10a6:20b:2dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Wed, 21 Aug 2024 14:56: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.7875.019; Wed, 21 Aug 2024 14:56: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 06/14] bass: Register cp handler for Add Source cmd Date: Wed, 21 Aug 2024 17:55:54 +0300 Message-Id: <20240821145602.92083-7-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM0PR10CA0030.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::40) 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_|AM9PR04MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: a2581dbc-12ea-4124-fc72-08dcc1f16f8c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: AK2R3U+v0PwN+oIiOsmv1lGpmsGI3XXexBBPNjcK4DRQ/HGvT2R/jshIQQBBmphw/lnx6VIrx0QRxCX1904wgLrQtBHxNOWfeI4nakEBbWN/FUx+sES+j/vLg6oXQKP4M8aJhaBjSnuyVK00B9lJQskuBDA2jk8cp0vfnaNcY6bBOvryzwN5NnPO50Qe8ik3VDtOu3K9TcS6bdAMvYz5gZ65VUpTOaz07BNWhbE2ryvTla1HiKRO2TJMNAD9w5J8v/G2rJZrRc7j3a+r20+IPYLm/w0QOG+W9t5vmuFUkGnQ8KQrYYSVBS0IKT/2gOu56ezlkDAMHrLkqpHpE47xI+Q6GHA4HE45WVNZZf2Hpj281vGDlww6q8Ej2YP5nffJcucUb9PE8p8QDA/VS9vSs6tvaT4NWlJ1l9e6U4hvA8bpeXV4r4TI1hsvyAr5Gdi0VsqPS/0b8XZM5pgEGKRVMLXt5Vfvtc1xFhUEdyxnCHkDWEbAoWojmNZB8XpuTXgjy082K1n8wR76eTe0bBj+4PAQyK3rc0OeuximRpHDuY4DRqrREg/wmk2BdpWx+YyBbEJBo3+GEgtzt1xLGQ//MhQ4cy0Aqkeng+3KMUAhYDxCL7rTsllnCPTPqT4IMTBtxYQVYT1R9mTLRpCauDhZnjb2+Wt0tBW7laXuMVjq6C1715OGEqc93eApvp/Pj7Va7DBXtzGnSdT/uO/tjELHeRGZ3RKh0gpWV+Gigtmkn6PxV8zGDgNyZNUOrwOr2sYrkrOQLcwnmdJF+Hs//q9BENxIMEulItlGwobpTo/wW/x5o27xG9rNSM3qMGlAecgt9YcaCykavHzLBQX9mTN5edVwsypEnUQ1bg37Ik7DVbhdx6/bmQnE3/iqfAJYKMD+6P8W7ahn2zDmhj472zrzD4XnUDyPQ3PKy7/rxdwqoeh6/NP0BNEvx4Cl+Dyl+8R09lqtnkxCW9klD0tcTZB+GrhWgmVM1bvX1mkG1cAN+XvFIMNbfvbvnveBwVQP0nsCHjQvXQcaj9tevbGgjG7bJsahtTIy4vD4MLMWsnO/w+Svkadsseb2+hFdoJ8dDmbli05w31cJF/MVMMU2GAWOskHWRiro7GMIKIEDWFYo8fNDqAYAp6ycRSayY5EHhiowZv8hdnOfmLgXRm8/KWBR88DQTttnA/gK6ASyd5ECFCsYbI59EduSFrxVRl0a/yl01z1/afvG3zyRm9FcD8sy6BB5KZsW5tYtIthRTbvKvyQ6FbCdruhT5SfFw1tFmc9RJ42g1RZZ/gXJSPFTrlTsjlFkb4tqPEoYWjnkqBKd/OqOBywXNVz5ZVdAZgMBNK3lziY30XDspT5emkMSaLB3+A== 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)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mxLtI3iMSsNUhV9aod30db92aqoqrv0WrbIl8FL44RReqExT8tUlYo3cxAi9T3P6VcYOgnjxszj3c/I0IOAjO2IplEaTp65lt6T87Dfo+rqIJA0AfxlElhk6sxyMhYmegrH6UsR/Uc7GbOJwm0cyLYP2msNmk+oxF0Qp3OvVynKE76dqIwxFc+aA32yvu1yAl3373b7zJfVxqbSf/2pzUOBmMsTXbYFaF4PIGOasG/9Dy82G2SW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1Ol5M4JGsuU0iTXgBWbnhbaQRB0cC6+tExnqJlTVKejKGmiFCf6NXiamiuQ/UJAbbotyTZfbrkgLw4QpaXz7AgVd7B26CaYIZRl805iKeF7vjET/4xvxPlrnoDri1hNx5M2pJI8Lz03HCJJb9Goi4sygsIudG3h/LiOlPATVs9CY2Buc+1WiNAX7SAlNQUUMptl29RfKDFPdm4tqfIguvloXmKUlYdvFIWM/cnBvYJkrkjh6vst+Zcu9dwebJnu4vBn2/r1RXyVHpzH2PNFGxXpVFnDnZycSQu+u2S7PzhDy8QByFQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2581dbc-12ea-4124-fc72-08dcc1f16f8c X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:28.3590 (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: 19SRran9v7RXGEY9dUZevAi4zcUh/9P4VsTYLUl0Cj3Uu08imiBZpRzCi/SBSYHrWB5nejf0xAvatG2Aaftyaw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7618 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 BCAA service UUID is then added to this device and the service is probed inside BAP, as if the Broadcast Sink scanned the Broadcaster device autonomously. The BAP plugin will then perform short-lived PA sync and it will create streams for each BIS found inside the BASE. 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 short-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 | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index b3740f64e..5aadb0dc8 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,72 @@ 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); + + /* Add Broadcast Audio Announcement Service UUID + * to device and probe service inside BAP. + */ + btd_device_add_uuid(device, BCAAS_UUID_STR); + + 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 +727,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 +858,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 Wed Aug 21 14:55:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771710 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2043.outbound.protection.outlook.com [40.107.249.43]) (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 0813C1B2539 for ; Wed, 21 Aug 2024 14:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252194; cv=fail; b=uO96X88XrliNM6epiHjFUI0Jx24H2j7YjBizAnzuCxXcRSog0hJ0olGzetpjIo02nuzguHEX1Ne5oSVpG4OwwOIPEqXeUXOIGk97gjwgGtbYoJvv9VX2PIm66xt5oFECRtzPIslTpD+J0Dhm2unY0RsfofDg54Rt70Ty2gVF104= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252194; 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=r1MLbB+HR3TTc+bwMBsXlkdhAZrCQSOsEi7HJ+a4GDl6IAZ31+921VPV/Q5vv4TNYcDyXNKP2v72liT4ikkrijvNHPU76Tyj93+adVr9uBMwZBHb8CNUjPWtm5mCT+MBIcf3lOIyFd+KFJg6Kl7tTphZGBzUt8YP9n3ba+UbWAc= 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=Dd8ncMwB; arc=fail smtp.client-ip=40.107.249.43 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="Dd8ncMwB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ueyzu15Cl3u4herEt/SxpM9wve397hGJ4aZZF7+6sh3j08+WxCF9rZaZxarOhp0lliXzMOxdF6GbSNEyvHN1XK0kwphdq+3tgAZcLVraHfSq3h9aCNIjUtl/sQfP/m14Tp338u2knyarOKDdvEDrkjlD+LA6TRm0b0m2A+f1ofYZYQlxGJ0QCPfZKbZ1UNJM8Wy5/TEeM0ynwek/Z7gR+36v5YHTLvEAZIwL+1E9xTL2af7TsGP37jOzBtST3CsycmF7h16qtTCqqN9Dxx0gYEvgOQdOwgz5FcQtTx49u9HGuplq/imi/ALsNr1r7FcrmCo3/L1kzUn0K+ixunOiQg== 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=YjeckLP/hlt4Te7hJgaZfoHQM/Jg9yGFKCMRbsaH5Q8yIl3Cyg5TXKHvX+P8KLvdClAroWVQa3YiE/venSCyGgBe1Q5WAw5b988usBkC6Yvh+NMkemz1R4IzFVajW8Wafhw7vH74NLItCRvAMms0oa1hql44uMMFiJJh3fTW0YQmfX6WL0ifo3SWP4qD6Etmfd2XtKzAzxnuDJjZ2Gddh4yTw+IdYBRjyxinpmiBl7DeF60pegGfNYCDFi/nPXq80PdMvrdhtPMYWDFZNhzwGEjyFRw3PKDAxgx1484gKwCNNXZMZSEoDhveDGfFBl9h8B3TafoMPq/XPJYUZSh9MQ== 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=Dd8ncMwB+JBMMkb1rdDrgwEeltZNHLP9OiF5to5EMXQVQgkd5lQrXW89xaIHAlLWcL3kk9FOZWSq0UCVQx5SHd0fQfpG6YhZ6h3sgcvDZpRAdirD0EViklvlObAk1HPETlzhmhApWII0CYDeZtzWZwpicCtc7KkV3k019kcLXqlzy290PdgoNfUX2bONVc9QFWpfZppv1jHpDxu5yhDK9nF5ToFUHhG9rQg6PwA+Nw4XaPZZQnnFIj6UncPupy3hs6906eoH6uyolue67jnOzPzX/ifCA52kEI8uQkzNzNKD9SJTR/yp5CqiYsY+wpS8FG4wFUTPxIfL3iODbsfveg== 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 AM9PR04MB7618.eurprd04.prod.outlook.com (2603:10a6:20b:2dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Wed, 21 Aug 2024 14:56:30 +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.7875.019; Wed, 21 Aug 2024 14:56:30 +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 07/14] shared/bass: Add API to set PA sync state Date: Wed, 21 Aug 2024 17:55:55 +0300 Message-Id: <20240821145602.92083-8-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM4PR05CA0015.eurprd05.prod.outlook.com (2603:10a6:205::28) 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_|AM9PR04MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b45df27-0a2c-42e6-0ab3-08dcc1f17116 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: y68dghuhhlzVk2dK8ATH3SAQZhWTfebWBDg8f/DKAgiEC25ZD2luSK3UvA0YVSL0yztxrQFFlSH2N/yh2m+nPMMkglYvFbIQtm+wMe/EZJvQRlhEcd5nhAhTyKzlBG1Rw7amFz9RVP3fePjg8dxo1pxVz9iaxrIlnxsvQWnMo7fpbj+nzCXBaD14MK9MHy+ph+T55Cs2WltLe4GrYvMCOo2GIzkP9UhBSxiYg+h1Yx0GUADPVJYc5YbIokXXuP09eLTgtwYEJM5Y31ZJYLUMoSCzcFzWhuNA7DIBe5QZA5yxsU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.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8898.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ppFdQ2ITlQyZqRomx291qXRidASYmMJ38+UjwLfpmo8nbvPT9LYmtVecHr7DU2EGqvUofZZhILAw4dhliQmZEetyEdiyDdov5J62ueHUfI+LXMOyZAT6sg/fM/zkUN1N8jR3dxRrqYKRxw6g+yWNCjWEP3iB54QzrLd28MymFmgTNxZYkxjTjZNA+BYEDbf5JQ0l6OFgH+BRs54kqJ31yJBqp09P7cnxMXH1x/xShZHmopQ774L1ZCNUb6TWsOi8vls7g6mGWrlMpJsKYSd+kQXjmERg8xetssGfhxDrYsmrCg1FdApsc6qZ5KExrgva6lmX354KDVR47H7e63YMHP//OcdMnJ4WUAPWqQesi01KHIAoT6VixZBp01KH47zsJkVUiFn8J8FLEPHp5gTHLoWcQlG+4JUJH9Rg0jgaQReExLx20xJEk6xtTY429HLgnuPyKW20w62dy8e/OK5Lxy6TfPgD2JsGKBpM1YTm1p1xwM8oNrOyFjrn83c5bzPGGR2azfWswSPRF8PEfYtwkdw50a7+iVSMrX6ttA9x1DvJ7KqINw7ZJp0mhWpCiKG9j9NSafo9pTWgm5OGZLPUncpeRa7O2zNNMQCCbRuKGz7kFEqCKLMwGiqjbpd7lPFzs+VtnoUTFlkeAOHKZTJpIvWqA8TW0ig/OsQa6MRjzItlVYsMLBgS6MKXoXGH7jkqZpc2ScukCc3T8V5ftTOZlgyxK0GpBZT2gY7gcGlgnBfjFkOoHM+PyFh6QrcglBSzgDqZY9qlpaGEyauG2qVgLGFVs5VBmj/2+t1bcVTzU83PnnmENey9txEkCkqtBdNxD0MPhSaZ8xxif/p8/kEWjhIrbe4+kkqJeLPsSw201ccfWoVwHs57ZW+mbD3EJu2nOInFD22IWHPc8aZ6AVvd/5I/lj6FnOhoDYWUr5/DqQYNs56IF1sjNrVTmVanNSFlEDbNJ/8XP0nETd3VMzK3WdYAnY1XuSkTc57cNMU/LT7CdcUchj7QQ9Th1wITBKwryCKmlfdKoKtu5w82glMPkB+9DIMfOGdr1grLkwa6hWXGAcx+GLtuaq4VLpRIoI/B8ylLCLYC/MTcUDQRdwN4LzEOzn/7Ct+4Uk+DDJrHh6oFzA0VyJJc8zwgmnROMEMO7FO+UFrV5/mFs58nLNfcwvbArr84mV3TohkPSHn5n2AULfD0+GGpyLvgMrlkiEEL864SXFVO5VgtUtRdXPcoQM9Qgmn+k5z8LMZ9u482F1F+o4C53a2qw5YbQklf/IjlP0mMS6V1mRgn2CGaLIz4GcwCjXCitsxcbGOeZtCNh4cLar+QQrASRpx9KDzqryiHKDrc5ShkbC1aAv9+a+0y8Mbygt39AvDiuSAE7q9DHr81wejjzr4KGQFXxBPaFHONrVoS8Fm047viDQRpJA2K465qj1hwNsiZzk6l0GLxoFvXvkKABvEPKuaxllHtfoUeJsMiRLIya+nXfynMR/7W5HPPjAGl9z5q2+WFih12E/7kq9R+0nwdjaXQMM77irHi63uvw4EFS6o0dH4XcQJEDaIXdUbKPF9jqR7mxntXHzx4VpWmeQVniL8r9nSmhBApy+jkaNzHmyGY1hnxQ/SF0Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b45df27-0a2c-42e6-0ab3-08dcc1f17116 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:30.9078 (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: 6BhsibkOpkpPBp5MDpX0qxLe1pLof632JNatrm8HG4+qKq7+pC0N8AGcRrGxMXZNW8uMDxBHl6Pjtpci0c+2iw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7618 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 Wed Aug 21 14:55:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771711 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2043.outbound.protection.outlook.com [40.107.249.43]) (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 02B521B2ED6 for ; Wed, 21 Aug 2024 14:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252196; cv=fail; b=B2P2o/MFm1tCCKP0EE01UpvHhc+QXw07VSGZ6yioPdm6SPJkTSrN5DZXa6u2yp1mE8rawAoEnQyKBdfzJURR2jljHR3D3CZmRVk4wQSv0ibw/U7KFJ09WMO3diYaABiXuG3xwakQx4iJM5qUm2aER35XnoUD74jaD6kw2Hr4dE8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252196; c=relaxed/simple; bh=byegnlnYu/gcSMgtojUeTNxvU5oKZO+2XC2mnLl9i5I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=dx319MViHFZ65pPCRV7euKFP4MZPbq5PmY239YZjvR+Eal5xbL7NTsUC820o65OYLpr2/Qb7JyVBCYXHR5PrIssI2rcUA6zM7HefEUlohNmIsvasdYaeNimtSCa76e7O8aIxFD3klIzuJY+FE3iSaMx92p5pz8K4Zcixd775qtI= 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=adx1vlP9; arc=fail smtp.client-ip=40.107.249.43 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="adx1vlP9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V7KgTTkCFYIGHcc2PhSF/VmE78o52XI32ZkzT304WjJvAsm4aYdwLRenflVCM+mMtuOz2JT2I67FWhHUbMaZTZjOW9Th2cfJOtcwzf5km6svBVEaeEiSr4PGUuIl38W/5/FBESiQecHzREOnpTp/H7Wcv5UZE5a7rcC3H9Nc5F87YjVxCSOMN481WJcyX9El2j5BAe89dW2bdbUav/O77EWkPh+90WbPH8tiIgfjGrgSgpsSN18vRzLIql0gZHrniquFSVOMEMPlIdJSTd7LJIM0WnJeRMdNI8YqI7+qM5sRGNn0rLD8XAdYvtT9EDM//PjqA91N5zpt7JA8LAfLHw== 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=fFjbGv1gVK4zKseDku8+u/eMqcE953O6sweqZZBPOQk=; b=Ilp1pJXBNci7W/FEgbMlk9jbW40nBezAdpvVOG7rfwZEGU/ZkwUnJkiReo/esQIhgyQn6giQl07IC5T3d5q2oXdSAq2SDMBGCu+Ss6XSSZmEW5tJ6qj5i8jlTI7hy4RRVPE5+0ePtx9znz1cw37WUe6wYfj3HEv9f+HNeoSDtKCvoGicxDSX3xdYPtsVzLW8nX0Ys6/eUHxmYfZPxbPkHvnZCAio1aIlS/sTzEIORGlgmcfJlbWwfjlitiqT01OsHVP/56xUSF88wxfGjhUGn0DwfDdOMkuYHNN3N3XeY3x3258ghGaQTxUJ20fIUxudH6jEEEsJgcNFNqZwibn6rw== 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=fFjbGv1gVK4zKseDku8+u/eMqcE953O6sweqZZBPOQk=; b=adx1vlP9srQ5+ATG5+h/n0WpSZ3zi1yGEcegqyjRa0pq/ajDCDm10hSiu9AtyZJH2zCOxWHraCZWRYO/KHlcMX8PfTjm0Aam5PXa2iDNFhxDiwckKF5OkvwnMlyGj3xZ3Fx7wVbnR55iM5y208sDPCPfMfmPfll9XVREBFbzaAfGUGNrM2lNz2LH2XphA86jzjfHfAXQu+eR3nDGNiZFHOWSjUAGCTYsCe2b/lY4XXF+IN5QbWAPb7H+KApYbwERyvNkpUgRpk/becLeipZyJS5P5YV5zxWbtsEyMkuuSdMXtCQeGdod5El+WEGWEl25hEyZdsa+SCJa8qx2V0wQBg== 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 AM9PR04MB7618.eurprd04.prod.outlook.com (2603:10a6:20b:2dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Wed, 21 Aug 2024 14:56:33 +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.7875.019; Wed, 21 Aug 2024 14:56: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 08/14] bass: Add APIs to probe/remove Broadcasters Date: Wed, 21 Aug 2024 17:55:56 +0300 Message-Id: <20240821145602.92083-9-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM0PR10CA0010.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::20) 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_|AM9PR04MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: f9e56ef6-9972-40ee-eaab-08dcc1f172bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: wFwd5du8fwECXAP/M5xPFX+cRtc8C2aEQjrkpM04SGnh2woLjAeQzMLLU00zWKKfDM3brjR29muTkMkdQfj/Rark/wnpcGxfmltzNZwBAI+FjMOUWqI7sshGTY7dRBdcUy/ZlqxIwzESrDjYDJZM1aUaEKg1tw7uAcT6RNQWPsHsf7rh5uuwgseIO30KX7j983AzEbYBJfRHUbXKXyQ1MEnL7DzmEzsndu6Lo6B8385HUTLROt9V5yVpmKVP2O4EYT8X23+hfhyde53ubd35DnNBuVX+IMzUB/6ckCOCv0whml5vWgWhiutV1TkX8t8lwVWgnXj4J76VKDNid11LUdUyO89R3aUiVsMs5uvgBzwfger7ZuX57TCM8/RW9/+HebLb80cymuZBBO7/1rf+KSIGiVeWXnT2yckHfAzt8IknyPcdZRw1hzutIRMtcyPhWK2j8I8oXIJ+yLFVrtPw4XYoNyTgkyzyz5ELJPSzwShvJn6CEE5hVUuCUbQLDYcA1+v5sauMUs2tkpvKCVeFCQYxf3dfJFC01lADB7H17y16Z0oSFPHs3Vy1UU9BoA0G6ca+E1tv16bMrqCeZOD9xtg31Ymj6I2PBCCLA/oaMSZVACUZMDNzMgOpZEcZwZuK9KLGQuAcM2lLhvXMwP1Lkw8J8glMIVm3ZQjk9jxMhzrENdOI+sSz2pr0ra25sqNhNIRUbVhvpunAp8/pyCib8AVjyU5yTf1M3GOTVQzgg7yc5YQCz+Z8vLwLT8u8lbgy4CFHR6slhgNlzQ/hajLTRffoqP7LZ4abhCVnx9BNrC8dEGiFf47p/1YeA2HVr0BCGnWPvSl2+aYIY8cDBWzsMG8MigJ83NwQVKWDTB4HOCmWAxHO1MAjMUDVyIC/rtvICQlPmkiWOqOOqBZuI3Rq5c3yPazUT+quHI4svuxhM83oEF4/afSwb5OTA80EXtT+NbJb+39wDGDCcNFcJSePx02BEupvHlpY85A4+MbylotutPE5Ug6JwrQugFgqumCkK7cf2KVHMTCDje8OvshBsQH9Mq6X3LWQzXSnBw1g/l+dEiRUzf7OrYyxCWO3L1eP3vL9gBGgxsytZ6+AKxLNVscDXgFZk8ZH270ur5SzXrBbZeKgNnhC+r1pl3qPVWkDoVPRGN1LRIZOYE6Xe+EC5c/myqB316J5eDcR8wCFuWhPH2FS83C27vOsejG+XvFVN1U8W4R+CqZEjBXHkrEufsmhcf2Qw3fPxnDrQr9FJQOr9VXs3mBL4mUO35NaWB1hn6tdsOQmOBppJZ0D6r/5pZlt36n2X/qb5ijxyyvP2EF64AJi2WJUZoPmFDiRbI4cQ1kazUeQ9CXVar8U2izotg== 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)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: akxfhqBPc99r5mmpWrwrWFoQIWXudnHbumfIRNVvYVeQHMbrxNt0TOOgFF5K+4QRUSfaV/lK2cYScyPft5vGTNtfkiOEGqv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8SHuAWfOLDNbAndmK+tfESWjvyrz9AjjtVbw1MvW+uizm/mLhZifat3rk3NmviVSxMXOmhfcyfrQs6xNcfSY1Ptv0iEfIe6whyIRxOtuEcEQpECC4w6PEQteCjaWsSNUQlWGXW3A4EmZiLiM0Ruz9YOjcB/FqEaWC1H1z5VkRLeDy0wOd0V+/6641TR6TWbHgyS+XhgZWfPP+9mHDJrTahdKatfMdLWODEslOr6hy9NlXF2HuVvLQJq5pvYlw43xev3B8uBJjwkQHqXC9O9RzsSEEs94bzzTMrmNKY2jylgxdOAC8ZbfFcE/jMbr95sMb9ZBTHL8KOPJUFtjUEU9WUckJ6pghNWBduQE4PY8wef++Du0pqIyx90UVUFkuVBNm54q3YbwZ1pYFlob+8OuOk/4jGH6H2f3lPdmK86R/A7Kq5NzeKAZtejj92JYTsGtg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9e56ef6-9972-40ee-eaab-08dcc1f172bf X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:33.7392 (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: t17FpEtmJfgbvLZZztBF+3aq6iT54y1EIeMHhYc/30NXusGf8Gzqyvrp8xXJJWueNt451O9i/V16t0ahi+pdjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7618 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 short-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 5aadb0dc8..22e8d1c9b 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 Wed Aug 21 14:55:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771713 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (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 6EE181D12EB for ; Wed, 21 Aug 2024 14:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252203; cv=fail; b=pYZQnfFVMtzl+/94zISxw93WCl599TXwhmw5+pcd9fL3LNfOwBTVoPiFAKuqmyQ3WP8T+4MPy+06kH6nLM/RiL9ACJUY3uf78CNVdoRqTUPeh1EPqqaYrMCI/FVjBQW6R5snpuikprCOsCo0AwUN5fEI5u7G83VeA5QwwzTDJ6E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252203; c=relaxed/simple; bh=UMtvmE9KOFjO5DwYqccnDX+TnlLfO5YvRweUgpJywQo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=vBJ5261qzGuCyDMeJGZ7mA7uzhOo/lao6SOQ//pMX+6S/SFEGkgCImQFn5MjwCSu/8q0HN2BVlowq+mz0t7skkBh0vyhWZp9isbtkaua+w6QGUbhjigEV3OOqbinuPv5Sd8Tjw6LfhNUhbzgqFuvc6FaN/FyFFqncQDyz39U/BQ= 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=PiefOYab; arc=fail smtp.client-ip=40.107.249.66 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="PiefOYab" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HukO2+MExS3x1/DSnmJ566FVfrPWN8QP0620LutNRBC9WY1hlQe8eH1qH6viSKFg0zXyr0T/O2ee79qI7YzQT+AreAl3dRMYUFi2NrPH4U5DL7Wsemz4wgz3hsqHU6ugdf/v2imwa3UxFaBhDoh/oHpwm8n1Ez2/bDNfZFFmzBGtgh+oRuh+XvTad1p1BSkBsHsD5CYvYe5JaHO08fwp5zZBwwv4r4JCNgwHV9UZEKxHDTC6QV3w0Rxm1fMBy4oLX64BkLDYr1u15RSBgLHnjx1XNBPlOp53flAjXm56kcgKswsr3/sY+XB+82en5CXE0GfIEjs8d2iOoemojCKJBA== 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=zu+Xa/IKvjHCXjfnnrmisL5s66Wsc1W5UcZC56R2R+M=; b=HEcjhtpv+0m/CdOuoo7kfai7PqYObOsJHcDb5AIetKPtba7Z0t3mzENSkeLBU39uQEl76UTU3jhjvhqf4V68RCBgVyyAUQ8ZEPZ127t57k+dozHrSw0ss+UG0TsDjHyJ1tz8GTlrA3iGxGGSMcIfKKjBv5vpONpJV1qFpYNb6McRdlCauQ5i/ImEZ6/o1JP+HCZgfTQlAS1Wkq0QlyBLKLdzbRHCOC7UXcJ0m/tK8H6mGBD8tmodcYYInkxLIbG9mqbh9RzOTAf2ahpoWvIaqFa/vw7CTXGj4tb65KFLZ+6o8w8MY9VkWR6LcvsTH4NXEcjFz8uGxT0ndRlYanJYyw== 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=zu+Xa/IKvjHCXjfnnrmisL5s66Wsc1W5UcZC56R2R+M=; b=PiefOYabJKW5uypqjkv2aUvqYZ5S898LU5n7aF8ixoF2E5AnnRcLffy8p8Gi2rUku6pTx8ZZ27u+AyVSQyNzoLfdmXJQfKNp+rzkvAdrbJIgXEbR3op19Iel7YN3BmY7UJjI/SwkNufWsRKiB9O+wlZyWrOWeE91zPRIRp2/Meo4fZnWsd3rQzK6NeAurq8w5oRAaeBX/d33g+whqTxPpg+x9lQBmXER9mwO9OPoSW8O+1jnCR1VYfh8LVN5KCN0NSNwkGnfh2hps80S7gW+B8I3xcZQTV11yeaCXpkXBBaeL9e4REGy+RwcID7Pl2r3Yrwr53ROpAqoh/EICYmJpw== 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 AM9PR04MB7618.eurprd04.prod.outlook.com (2603:10a6:20b:2dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Wed, 21 Aug 2024 14:56: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.7875.019; Wed, 21 Aug 2024 14:56: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 09/14] bap: Probe Broadcasters with BASS Date: Wed, 21 Aug 2024 17:55:57 +0300 Message-Id: <20240821145602.92083-10-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) 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_|AM9PR04MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f69f11a-d84e-45bd-ff59-08dcc1f17482 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: XLgua2u3jw7kBRmW5IVH4iD4uH9hgoNKkZ2ev9kSWptIWYRIiP0xS3NFI2gjptQrKGz1C2puYS7r1PJv+oe1nkwi0U5E5O259l9BUS2wX7J1RFHvRaJV5I4BV4vx0du5eZxFpjqb0ZPOTTpB/rU36t/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O+iRnJ79Gh0EF0W2IbDdDh2RWiNhUTB0e5mdcruHaX0fgsa4WL4k14AXTJkZdONwyAbo2k9+FSVYZIcNwHOrM/9LKWPi527LFyrTC1f+CIE36+bbSaw1hwKSp00Rf51NzFOKVKqY8Y9g5/x+hayw== 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)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +bTooKdzIph+LzGCBj4gRugikegPbt9Z1m3V3w1LP1oVfTdYq+S5dxmfg500aHEzRqOOTDo/inJ7j5eKLQJpX7SeBmIYjaucfCO9AA3IbjXIwB23fSYH1C1Z1pE35csd4GWQ/dDTwgRPVu1GwNAsYuGhf2a5RAnxFg+N+H3RPyN8dCxhqmUmUS0jVEOK9r7FRZoGCXHLjbOpQZUVTBuR/4O1SxFwXZx87u253YSMZuQb8k7C/cj3C1QBDfYtbaK6X38K4YWyDGBGsq2UwZkka+K37OXbrksArMbxESMrH19zeZ1SINhoDvenuchUQqlFucdsdEYcs5aA5yrV2RudQGaLNwMU3ucpHIPX+t+ArofdvLACH6pMM42JT1XvzKsOPkJkMiiBezsILcbxY949/s97EwPT8IaHY2dd/gBhhyBRDHvEe9LjSs7Q8oWxLHKtKIp7Fy1E8A+Qnm0O+NyFiWuK9sQvXJNQ3PkMUFTUIrE3eHRmZuN9SKY2r685E6s1FKIAmfgh6wu6Q4LFlo99jWE8/UhRlVfhoZrbRZDmATzdVufV9CHjGPQiizU8i2A9Uy2JzmQRJuuDXrbN5dlwqr0UToRPAnqtKkuf60guLj7Km1nd+U/xrQnykmcA42iy6UIFYrlSU8BpMiOkX2x/UFSzR6WX4jg+WQ+LDpxpuFYOxa6viIuDhw7Hw2LdLA+MrrQuFf0AdORXRm8xVL+opkjVXcjQ6k3sLeMymSrboE/2Gat6Dbw3+kcH99ehTtKswNRPp7mZlPkNGF+IjZFg7Xcr/UUyxjZx/CXGs7YlDXGTijHNSviW5zjJWrMR64RVAUphzYysFpje/TbO8wYz6DZ7GgXW2XkdJJVkG4vCXDdwvxOlF8XWdbH495yHHCYGBFnmooivbxjuvlnsd+ZIhzUP6z9ZCoBKJaUQ26WCz+yAY6q6EZXabZH1cZh7S8uYUZSSWxgUXZB5iZAh08KYVD2kECYfpU3Yl4fv8e+U4Gwj1N4kkvvkY7ca/OLwESyivOJOZ6mDumeac2b5jW41FeC6p3bOnrk3M3Tl6Nxt53IEtU2EoyPDs6yiPdOwZNYReC8AEzjsYXxU+hNGSXeQkOYGC0uduFH5wTZNYIWvzERwLiTwV0xXsxuDRqDuQo93d77gGHqtlBbXMEWZ5ruVszOym4vtglr6UYz0xZcyGOUZ5t6UhXSrSb7Dcwp6lvOQ2VFss8j3z09Rb2eSXUgUIiPO1ESbUqsNsmqsMsBskUXMBaFHe8RHud9KkjXzHEEOlWO8jrxVm7thP2Bjghkql7CckJt579lEKSw5u81r1+7KNAst4X+X/kYhDGahKhLw7SB5z1cC9rxj7uVQTpyzBSmk7TpQYJDR1CvcvNdcx9mIESuyL1JxX9GG/DZCcOi7fHD4ML1T88LFjqG8cO0VsNDFLALkdnQsl4QR/moJPG6p7FTNBL8kAKORTkl8AB0/MXLm6EikeLHYUw7yZcso9bUUk7mSH6+bD6W0XYRDbAA8HGgOLmL19B4onx6HEJ6oI8s4U9qj3OpvqSQrlnbLz/tD5G+rAzFzJVcRBnq3ActwzLzQW15QrdmzImAyT2Ggb2bHzR1GNIMMjPjubG5/rQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f69f11a-d84e-45bd-ff59-08dcc1f17482 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:36.7822 (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: X5jN70wycX+ZFOogNtUDQv1itKyJ16/o/e8sosH0vtK50lmyA2c/70r5iVP6K9A00AG/0iXgl/j/MbsiZ8vh9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7618 After short-lived PA sync, this adds a call to probe the bap session with the Broadcaster with BASS. If the BAP Broadcast Sink has probed the Broadcaster autonomously, the short lived PA sync io is closed immediately, since PA sync needs to be terminated so other Broadcasters can be probed next. If the BAP Broadcast Sink is acting as a Scan Delegator and the probed Broadcaster was added by a Broadcast Assistant, PA sync needs to remain active (it should be terminated only on Broadcast Assistant command). This commit updates the way short-lived PA sync is handled in case of a Scan Delegator use case: A reference to PA sync io is kept inside data->listen_io, to keep the sync active. The PA sync request is also kept in progress in the adapter queue, so that no other short-lived PA syncs will be attempted. Once the BAP data is freed, the listen_io will be closed and the PA sync request will be dequeued and freed as well. Then, other Broadcasters will continue to be probed. 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 | 128 ++++++++++++++++++++++++++++++++----------- 1 file changed, 95 insertions(+), 33 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index a2c5a546d..bf924932a 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -182,6 +182,9 @@ static struct bt_iso_qos bap_sink_pa_qos = { } }; +static bool match_service(const void *data, const void *match_data); +static void iso_do_big_sync(GIOChannel *io, void *user_data); + static bool bap_data_set_user_data(struct bap_data *data, void *user_data) { if (!data) @@ -211,6 +214,8 @@ static void setup_free(void *data); static void bap_data_free(struct bap_data *data) { + struct bap_bcast_pa_req *req; + if (data->listen_io) { g_io_channel_shutdown(data->listen_io, TRUE, NULL); g_io_channel_unref(data->listen_io); @@ -230,6 +235,22 @@ static void bap_data_free(struct bap_data *data) bt_bap_state_unregister(data->bap, data->state_id); bt_bap_pac_unregister(data->bap, data->pac_id); bt_bap_unref(data->bap); + + if (data->adapter) { + /* If this is a Broadcast Sink session with a Broadcast Source, + * remove any pending PA sync requests from the adapter queue, + * since the session is about to be deleted. + */ + req = queue_remove_if(data->adapter->bcast_pa_requests, + match_service, data->service); + if (req && req->io_id) { + g_source_remove(req->io_id); + req->io_id = 0; + } + + free(req); + } + free(data); } @@ -1004,9 +1025,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); @@ -1258,9 +1281,25 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, /* Close the io and remove the queue request for another PA Sync */ 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 (bass_bcast_probe(data->device, data->bap)) { + /* If this Broadcast Source was successfully probed inside + * BASS, it means that the Broadcast Sink acting as a Scan + * Delegator performed short-lived PA sync as a request from + * a Broadcast Assistant. The Scan Delegator should keep PA + * sync active until instructed otherwise by the Assistant. + * Keep a reference to the PA sync io to keep the fd open. + */ + data->listen_io = io; + g_io_channel_ref(io); + } else { + /* Unless it is required by a Broadcast Assistant, PA 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 */ @@ -1268,9 +1307,18 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, service_set_connecting(req->data.service); - queue_remove(data->adapter->bcast_pa_requests, req); req->io_id = 0; - free(req); + + if (!data->listen_io) { + /* If PA sync has been terminated, dequeue request to be able + * to probe other Broadcasters. Otherwise, keep this request + * in progress to avoid probing other Broadcasters as long as + * PA is active with the current one. The request will be + * dequeued and freed when the PA sync io will be shutdown. + */ + queue_remove(data->adapter->bcast_pa_requests, req); + free(req); + } return FALSE; } @@ -2236,6 +2284,26 @@ 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; + req->type = BAP_PA_BIG_SYNC_REQ; + req->in_progress = FALSE; + req->data.setup = setup; + + if (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(data->listen_io, req); + return; + } + + /* Add this request to the PA queue. + * We don't need to check the queue here, as we cannot have + * BAP_PA_BIG_SYNC_REQ before a short PA (BAP_PA_SHORT_REQ) + */ + queue_push_tail(adapter->bcast_pa_requests, req); + /* 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 * can also be treated. @@ -2244,15 +2312,6 @@ static void setup_accept_io_broadcast(struct bap_data *data, adapter->pa_timer_id = g_timeout_add_seconds(PA_IDLE_TIMEOUT, pa_idle_timer, adapter); - - /* Add this request to the PA queue. - * We don't need to check the queue here, as we cannot have - * BAP_PA_BIG_SYNC_REQ before a short PA (BAP_PA_SHORT_REQ) - */ - req->type = BAP_PA_BIG_SYNC_REQ; - req->in_progress = FALSE; - req->data.setup = setup; - queue_push_tail(adapter->bcast_pa_requests, req); } static void setup_create_ucast_io(struct bap_data *data, @@ -3030,10 +3089,17 @@ 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); + + /* Keep a reference to the PA sync io until + * BIG sync is established. + */ + setup->io = io; + g_io_channel_ref(setup->io); + } /* TODO * We can only synchronize with a single BIS to a BIG. @@ -3086,14 +3152,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, @@ -3211,7 +3277,6 @@ static void bap_bcast_remove(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); struct bap_data *data; - struct bap_bcast_pa_req *req; char addr[18]; ba2str(device_get_address(device), addr); @@ -3222,17 +3287,9 @@ static void bap_bcast_remove(struct btd_service *service) error("BAP service not handled by profile"); return; } - /* Remove the corresponding entry from the pa_req queue. Any pa_req that - * are in progress will be stopped by bap_data_remove which calls - * bap_data_free. - */ - req = queue_remove_if(data->adapter->bcast_pa_requests, - match_service, service); - if (req && req->io_id) { - g_source_remove(req->io_id); - req->io_id = 0; - } - free(req); + + /* Notify the BASS plugin about the removed session. */ + bass_bcast_remove(device); bap_data_remove(data); @@ -3393,8 +3450,13 @@ static void bap_adapter_remove(struct btd_profile *p, DBG("%s", addr); queue_destroy(data->adapter->bcast_pa_requests, free); + + if (data->adapter->pa_timer_id) + g_source_remove(data->adapter->pa_timer_id); + queue_remove(adapters, data->adapter); free(data->adapter); + data->adapter = NULL; if (queue_isempty(adapters)) { queue_destroy(adapters, NULL); From patchwork Wed Aug 21 14:55:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771712 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013045.outbound.protection.outlook.com [52.101.67.45]) (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 DAF3C1B1D4E for ; Wed, 21 Aug 2024 14:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252203; cv=fail; b=o8mDgUwYiRnRmBY9m4FIj99kE7XXaVwJ3dZevMurlwng+ritpBtCTeQ2rk3HCmSiEJa6Vg2tVYTQ1vVEkH0kUT6mbwHLmSvX+YVyjm2/wb8/EQWnm7jzM3fxo5EE/FN6kqNUJSrnleICn0tNSWtpWL4KZRABifoFe5tG9ChzE4Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252203; c=relaxed/simple; bh=Xj0iuXMp4wmKPn2xSlhixHToEFcoUPboiEoVbnGWTnk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ZPY1AN13uvR89/Emmb6wbTVKWY3t7v/WM3pP46be3PV9xSQrDHkJLaOLiR15HFmGL+HaZxpOOm41PighLSKYHGYsY58JERJ+ZKG35eb1bjdKayaJOTAv3910Izw8Y3YAZHu0piJSQmjxbtJi1EdNyFtNndeLQuY64iFZxw27zbE= 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=PplJo1o3; arc=fail smtp.client-ip=52.101.67.45 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="PplJo1o3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wJMF1rhf7ejAEm3gNNGH31DesdmSZPG2eGzCW/y0q0B1HToopDZ8KB/OXpJ/nDsgR8a0OmdYTGdPE9nNjaJrK73sETlbqp0Nusb9uQdfkIvRzdExxLu+0lg9dGm6mGqClpTpVpDrAb8KgiAvWQcJFUppT7tQTYn65G8Xh4yZiVuIb+uV1eq76Ulz9dCUeOIc2GTIs3Usl53F19oU0TNjQqlLyoWeb0JJYcUbEOOA8k5NB+VTGvJVZ6vUUM2pyuk7wNtdkk7slSxjqBncTEnWHDC5EP/mOzmW8P4NVa+ReaLRsdIbWDgv4i8NVeTSS1kU2RcHXjCr81fEG1Kr2GZKmg== 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=W5crR2O9iDw3gltDTlCm16x9Uo+DyovLl/uEnDiQjl7oGjZ5keKjTywqK/iZeLHETM0xxvezmg2ktnES7QsKRTcWWbMeLLOFyGMzWJh/QTZK/2vn7WSoHJxd/ZOm8Xs1ZM05EwWCzXYSi6aO34MOAJL2aZcKyFM+KMufTeVoWSc4l2QgKgI8jGGUCAA4gwKDcnLK6Q3YRkjww9zlrxgTYiuN6DoILXc27B6hNkEXI+DEqtZ7SdtTx8K/oKWXxlWSmqKElbABcSOwQPsgY1FFiLNJvmOdlRuGA8EwE5MKkQinMsqJH6O0m/vCbTGJii5db/pFKso5BvySexYbxRAR5w== 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=PplJo1o3w7EFu6/YA+sTEIm6FGlQnjOKzrC05qBlny4cXGBbE1nBiRG5pAd5hTpk4fsPrLxIuvrXzKH7EQ9ua02K4UEQOF2Rtok+4ED/n3YzGWNwJC1ub3cKjEulen9MsN1cUZec4ABaEHgOtxqqiPd4DK/Z+w8i2EP2pOxELAQo0b5sjOnDt7mKMAk9apLQNrRu1icn7Bz+CK4vyZlJnxYPXB49Byb87RYjdmwNVXhx2UKLunG4nC9QbD2jrg8YowRAJwz+dO2Dmg0kNjGmq8mf48RXRpogf75BEA27fTkeNZMYsj0g/i/mj/e83iGaSW5CIcMxYE7G3T6ZoKX/FA== 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 AS8PR04MB8753.eurprd04.prod.outlook.com (2603:10a6:20b:42c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Wed, 21 Aug 2024 14:56:39 +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.7875.019; Wed, 21 Aug 2024 14:56: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 10/14] shared/bass: Add APIs to set/clear BIS sync bits Date: Wed, 21 Aug 2024 17:55:58 +0300 Message-Id: <20240821145602.92083-11-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM9P250CA0006.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:21c::11) 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_|AS8PR04MB8753:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a1b1cf3-9aa9-4e9c-f9f8-08dcc1f17624 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: pI+qsal6ifBfaWlV+9jxQaG/zgpONePGlFNjpqMGDGR2vq62llKTYq38P8g6CyT7Cm18ST1+kxSpztOkB3282nOIhyMTFQniCcmfYu0WLsQ6LZPp+vJQJiI0F4bBCTMngoApxEp59fGjrANO1stst9GR8/RE/iFAoXud/TybnFsC54gSSxHZhv27BaoiAMZC8zwhcpPcr2+mXLzL1AOSzKrH9gRwlTNmbVa/74hnIhjAN948is3MtIaqCLdVyyYMA/Zw3pjS3nC8lSGivqbdSfH6nPACyJVtS4lATXvbXLPeHqOWiLhXfKAwi07C2pBVUhqG/G+9HlvtSGx+dTih2Ax4paJ4jsEqSCGULZFptE5rR9v7wcA11CE52DHilpon7QvKgWvyQFVtjFd0V71krtHAXiVXWjit/N4Nmdry9sspaxt/M3XPZbFvwUZvOdzZp3YGZq91RLYewNfQdOvEAPmmk70syLjPUIsNWHIMgZjIyafZliDt3m7U5oQ2zirN0BO0nAxy6mexfZFqzTcusF7/oxEl5lWi8tNZLpyPBnEtz+BXaeFZsE6X7uci/fG72AGnKms4so2iS/5aRmZuBymA7NVSHcTZUqZubBr66D6QRIw5T2Nuyz56Zjfy+EwpvRA4ES/NBbCww0TRm2u883I75UfFRIZGw796uqtuXz+4KPnMkkAMMuJ5aRq6dt3NusLL6xsx19DkOlllO76MpKXGG6xaXqBY+MnB0mhxSP4YnU5+gzpQBs67bzDEc5xra1Do9st3UcKVSS36kB6qzj1LlLGn8bAf0Q7CVGDCA/xH78WFx3JNjijLoPd7k6vXQdwUxfq3zQkaTZSo2D8LvECmk7o0Jp8qUPm+idPmzi3Z9MLkhbnEKAEDNCmQ5rmYn8wbbeMuyUQetw/nwunuju7JqqmV4xiwwAwVJNAiCMvrBpQnh+NlR3qb9gsB5xtY+Lxfcuoyuv9lAZPfFfMTn+kz1ESDthhrGRzR4Y2HtX5MMXKLZoNzO5/zbbuaGbL8HSq3h0GlxRpXOoDl+dIuYx8X5e8gqHFYTSMDPkxRu1+2HhOuAFvStXysRt33PSFOK2n4+5oa7kbpjgI/W2hBVfNnuNV4IzdWT/K9v0xk6Thmoi0qyY6Oz1jJD1W7iaho5JhhMSrpcvTQp8iuAU3YCTdNac7xHWBhZssvUqFqBfnh7uEk+9UcrpqnQ9GrtOWip1mpkW3jchGpyz7kPJJ4Lo7UB1i2D+sLk8bIQhjf8/tjPZ43fzSjo7576rpkeErbMCPppFxqg/SDzFVv1sQjrul8+sVVGn7uv8qoYvDkymKiIH+vTaP/+P1wPZEbSenXDV5b8SI9IDKVsxiJrYOFdQ== 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)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c7U/TpCsOsQ2sLgJQfn+BuMCGXRGXf5N2pheiuiXcjj3JQkoUtb3AGwrubHDiRZ9ukNyoM76fF06WEkf7uJGxiNGQxlB9a/KzGoQk+zHwrh+cx97XaV/CajcmdTJjnpb3zm9ZJ7tp9fWtcy12ZY/9gvvkTyMKEL4mAAx8+shd2/LuEOLx0NJnNp9iaNbUwv1wHIEBwKgTFog7mwQW35bmY0o3nRUz9MWoDRVjGriBzkatnrh4OYFgy4xyvpDbVNZxAGtFgC7zvP848LWZoQioF+AqK7/LtI/lkn41te0hcOcUjq33l3yf7a4z50pr4cPWhjDhZwhEwKvp6VGKCbLOqVKm8W/YODsUp+JLX62yVzRQG8EOrfdk0/hrOByavS+EAGXul3wQI/n93u9BOLlSx7G9qNBIeW8bMpZvrusinV2A+fFzNqIHlcKKBra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uMSGs8z/v3AjGag1Cxgi8CpSQi/aUO95GI3UbtQDtvaWAnImasAfoHDVsXEY9m6p7qSymFxLeM6h3SXavXdsjyDjMA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a1b1cf3-9aa9-4e9c-f9f8-08dcc1f17624 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:39.4064 (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: aM6DbV3hZUD6CGAYJ8t1Ur1fzXW4xszDlQbo/WEaYgRW5Snjhixx1D9MVSWdUUpklSlubUXtUaBv5R91n/kBfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8753 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 Wed Aug 21 14:55:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771714 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011024.outbound.protection.outlook.com [52.101.65.24]) (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 8B4181D12EB for ; Wed, 21 Aug 2024 14:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.24 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252210; cv=fail; b=O/48l60mDt8ICnhES7HlBLV0l8BzsKsikJXud9NeUBo7GoA2E4pkTBOIPov9gSbZgZwSKGqaIjqiGl1kSHd7Pd+Uo9qDGS7kqr+rO9NvYS+019OqUWam8xxwpjfWdB1CKC7LTgzaUwJQhjVEGn1qqHoLdDNBEEwnpedZbl4fDxo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252210; c=relaxed/simple; bh=IC1oWMCYEocMFeyC9UVvz0B9LLezz87vOOSKz+83drE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=su6qAgTb4vIUVUnEHrsIKEBmAzbQBhy+f4A/uXl5M05dQ0SGMIqa0hqZJtNbwfoTToLel2/haiFlI2AK2LI3YODvsDbNEXr2aLSB9KSJ5M23hSyMi/arIkIkDiQYe5qK//XiL8fLRWbDwq01GBEG38blkmIbjc5qShQ8Ipee8kM= 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=bNVRSVK8; arc=fail smtp.client-ip=52.101.65.24 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="bNVRSVK8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EFoVGRBet9hJy9SLfBVwMOvj9Uc3gEpa5bfSancXE/Krq2govhmeTgS7pkdtPjbaskbV598KrNaOwFs9aCJNoIUSCzjxv1sEq4zW5zVdZhJSJrmjfNxgmguRmgdG3Vk1DNOiTfSQnk8B6oMIfQLaFamWCAByoFtTWUiG5mrH/dJa4pUt+d8TPdNp6cUyeptXeYGQ401/zztwVQD5QYqsJyHCJG7316Tnw6xKZSqF/7FI31hv4N0jzM3wh0zZAuDr/64rADa7S/Kk8gxfaoCSyVxB19NpIsi+GS1XYJyD8+QrCRu99UYvH4E09kffiMjyojxb6lKXgq2d2Q9cK6wQlQ== 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=h7P4ED93GOtTYJowAKOm/VNEvBpUJqYc0Dqp2K3/VEU=; b=idmPawdPsH+wz3Howuf2/aptf2WPmhk0gOO58R+73GIcRh6R9gr+Np8NzvlQhyVYPWz1+/RmLAlS+2F+EPCd9TYNTx6bFG5BVLMQstIVTA+i2uYxPdCJE/ScqRR3ybKOlo/z5a1jp2Jfqv8GAclj7yNLElnLooRFUIbIw5MlWXELvlMojghTXyE+10z5Xq/dooHdeZSYZgYPAFfsNcj1cvvvHrXNQ2/JFtFN/c7yf68zinTTE8/TjDwBxhXTEW6XNPvIrZeP8zgNkOdWqVbYb1JPCV09OtqSgxIuAT44pxBGIzeT3eT1+emOFW7e2bU1DQd9acfdIu8/EH5+bQWYZA== 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=h7P4ED93GOtTYJowAKOm/VNEvBpUJqYc0Dqp2K3/VEU=; b=bNVRSVK8yvdA558YlNeHAmXwYljIoAv3GS3t7EpKNDpf/0rE2OY12/NztG5h8ZTNcwts6qIv2mMgI0Pq5gxmRrkiyKpyjW2wiJUuvkloBvKCMvKsRQd3iiwak6DfyeerN/C7GkkHf3zC4DGKWus8T+DOJAHZN9VoQRrfBMz+OH3AdjKMyJ9LiJBByaPTpofBujIaOEPAWbx5R3ZOJ3vwLVnZJGyHPK+KdwcY0OCHpGBlvCwkvDcb0SwxFDhlyFdCgA+diHjOmNa12UBYsq2C1bZ3TXDvc0ybTGy4yYNu40P9cXEVtwqbjsZ8oUgL0o94pi0HxLNUEFXfJor23Rf0FQ== 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 AS8PR04MB8753.eurprd04.prod.outlook.com (2603:10a6:20b:42c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Wed, 21 Aug 2024 14:56:46 +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.7875.019; Wed, 21 Aug 2024 14:56:46 +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 11/14] bass: Register BAP state changed cb Date: Wed, 21 Aug 2024 17:55:59 +0300 Message-Id: <20240821145602.92083-12-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0027.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::32) 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_|AS8PR04MB8753:EE_ X-MS-Office365-Filtering-Correlation-Id: 98073ec7-5b31-47d3-c60a-08dcc1f179d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: xNJY04kDaaitWeZrDHvS9zoB9PlVbVxeYbHMSu0n5ZUHzIdLKiQvEAxj9+V0tCIOrJcdL/4QZf4eJBl4iWawi245rhPZ5UDgCmKTdBZZJ99364XxlrLbr90wH3VnQDAsdCLqJYhqzkZ1FNKMM8GfT1kRUN+2WFXLLInFqDwu/0KeL0/KWGspuIiBmCcrxz/YHrLRpyf+1zcLs3ir1NOBMgcD1pg2IJBePZib9tyYf0SWPbpu5u5I7+gNuhCSTNfTBlCftq/f0CK9qaoI3JKcpgGqZejodN0CnuHHIYGIodvAD7SXLkGOIF8dDMZ/ZwVt76rOuPBN16T6CqAWGfLpbzlbsYkac5eoDBiZItfZ44rSBV0zDdkas3R6dd2qSoks+rkZspswYhUvAhTVQh06FuFqp+t+OJLQVEG6QiqvwgohBZVj9qeyaaAC7mKg8ru0uCyUNxsMCd+IqRi9xDEt+ca7ZuQBX+ZFoyqDOh55o2IR5YVvL3x3iWAQnaIRAMU2oCHFmqd0SQrdfWRzUhRVAXWCSMgBDSoYhPvBqBaRnHdue/2P3dFUup19v+f+Bg/4aJ9pGYYUcPXYkIBFOvFVBTkf6g2oscAaIxFAuXYFZ2za0IOK7fArwc0bWGXkG/13twvyZdKlp/MML96LE/vvWI6lR/ZB60GOqktAABx1OzDWL0HX+zHrsYFbqhyVmG+xN0Qz3tadms9IDVqGX8MAwvnRQGXze6dLgFMl042DrPpIvcbcCSRkqguGZ7t5ZcQ8gx36yyc6tdUZz4fEMNyyeau06nLZiBY016OVYojt+8KuPf16cQzAab4wDZswViGSHzeuO7RCf7M4u0Sd1T7FRxINaB/lIzmAgYiiiVQTep4351/15J2CxOtONpoCtGWppq0fsl1Pib5Q7JXVydXz7kag93WHN1GcS99uuGbVT8EV/31hXa38meLcRtNNvXPJQFCjoNmd/23RnUHtG+x3jxzzYjTb7r2DCzp/Ww+Hs3Q7MNVPDccIExwggaZkovpd02i73kU2l8otRjVcUc6YYojtbC1k8A/NF1yGAtHWEeU53dh/DePiU7+lxxuzW+XsjOtXDSOMttcsoce+e4MPQmWNTFTNiyNuF4rYf4/3Dztfr1CcYGW+4PIxgi3yvfG4mog/rDTgLjgzUPj48/fWbYtnPEa1qpQyMmD+a8agKkOxgBOVjEQlNrh2/ulxcjuEhLoifDeaof9jqA5UY7LKZRV7R0bnJ/l4zh3W4FJCdpQFqLLFYFeudVyR7++EduZsyUwoVRZiBbE3yFjp0gLrOs3a/bp2HHY01+1nnfIy5DQdC/0k4BeTKeSHv61drMJ+DMSY+zVTNjFuvrCUwQRRnQ== 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)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wK+rHNXgfBqR5TnDd+h2ZAYH4QqhZ8xULPlUL3gswQy6MyX3TpqAnuaUjE+habF17OdI93XYoGnG6QokohtAbI9oOIOVt3BLDn0pJmz+bxzlmJybZwkJggUiPCCMD55J4uUbV8nhXU64RbH0IwREdjFbP/gE9a+WGGTjCpHa9PjTUdj8lGcuIiZyv5nvwFLXFitEqTT8YPaiBM1iqFqVFrQ3x4kFaGwWOjhtvUKQyqITZOzygtrqYgk9mdNBlvB69o2wjlFZ6u1KfNcjJ40laaj7DEiITm+1xddYKU9r7AaHGl5xiibaV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ngMwcRP0dju8Xh88kXrQWX2YzS2I1tBvI+GLLU1emt73nlrcGTuQf0Y8ZDSvWThvDGn7fpM9/r2j2cvKe2Ntlxtul4wy5ACsBSgVFylBpA7j9Xrp213GraVoqtAye/bl0adPfsdVofTe3EIqabIKhscYFeD/LvldhKkARdZHP5S25cSHnueZdJjpL1ZvsL9Br/er8wO/rya1NRvU2OQOi/TPmnayMkA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98073ec7-5b31-47d3-c60a-08dcc1f179d7 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:45.7206 (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: esyqgptL5yGwWka2gVd5Q6WlpnzoOZx1TTYjWQDEEsDD/J4tIgS09wJ7KvQILHWNc01RUYmP1q0pmuqrYwuAvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8753 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 22e8d1c9b..47445b4b5 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 Wed Aug 21 14:56:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771715 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011024.outbound.protection.outlook.com [52.101.65.24]) (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 2D0971B2EC8 for ; Wed, 21 Aug 2024 14:56:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.24 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252212; cv=fail; b=opsGks4i+Y+RNNEdqlWe4Cd5QWgKgsJMWFGg12aljy+q8IGLHCqhThpeo7Z00cDG3YlNFtvCa++3SmfcMVC/fcYOmxTlAgbvTvIZyy/vumEApuObhkhGsas49g3RdoLL6nmfCm8WyuIuB0FpR3wX4AtXwsh1I8wc1aAFgJDi6vY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252212; c=relaxed/simple; bh=h1Pdzj+zfWtprnTo+hsm1383pgdYoXs7IMrbZv5XvPI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=OAjifPH77DLT8RcKvKQONuF79Zs9x8pqmyoKyLD6cpQmHDzewudmNFg8ki39IOvFyuWfBGjBd5WCYNhgbL59SN2eMTwqGElbYazyR9rVCUk1Q58p6cHYM5hdGrLu3KKohbyi5/fEqKa5NQZsfZ1J6fQIC3JOPBS1ehX8NmROD0Q= 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=SpmboDFV; arc=fail smtp.client-ip=52.101.65.24 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="SpmboDFV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xj4/CIT3Uu3cjqNfMGhC4kSN93Vy9aXbY/9DZRndN485L9KCzKi5TQZLPOF8o7rXqJQ0WatoBjUViOZayojmfQearEatOhixittL6QXLO5g7n2jXPJ0QJ1OmzoiG5JBF7jsn4rapLqeTe2XxdAdlE1Mt6k9WNcoBWXr+SPDzquNJbnB/c4O0FWVGg3OwzSp+64X+FAbhzdiCJdTE7DyCWnkgvzL5y+OZddYdf37JKs8ARJUFFzNdu5HynggeRnk4MlvjPhqQMd+GKzcWs/b0wTD1XN67rVbirNRol8Lv2Ke+GtclJnq7+mMmslwbT0D7FQHNn+cL3d7wp/nHpnLiKA== 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=gRgIqz18wD/IM2LqKDi9nJeOO8RWsLMvxQFVhGIUTVdzWilz7pt93mJo6e9fNS2kpottWujbUR1SDhdiUzJcmoH8U9yfKrCc8J668HfhO0/+OZXq7NV5DbkibavkWSvHAqzmHd22BTXbMUSvZb1BIXpu06BFCjDRIioFbnLipzaPOdOHT+c8X+Oi2eGO+nyMOA9BloMX835Mo4nZfekJVgs+MihWqze/eBCOHinq3dIjjvvdB8dsWbZ5wlErV7VLLFilxLuHZLRmsO3NOdZvqcSdmePI1Gmk7ltf79Sj4IsS3uCGu1hJUqRTnuI7CbCgYa8GCjQTJhQCIjeq3adscA== 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=SpmboDFVUezNiGVYgfEiN2UW09YuyQehD0m7fj+9xKPIK61VIu9jo5lsof20Rew73gbbtGfSHDQtfT3ug3i3Wcdd5l2EPkTPITBN2TNDMPxb54aopW5ENem2PlWGsgIKuus5S0UQSmqBnCEy3qBWYPgzuPOk4Jj7eOjd55f/gIpD4Zxdg7BHfeRvLEnrnlJqLsjLDhHIAcYEF75BaDu9/mJHrmOcGm1tHKNnf4a+p5BD8AmD/LfC/IMtfslt7znNQ1stA2EWtDwuywIT4PNSTf+s/+4iWlkTuc4+d9ZkBA7bV3hMJsBs9kxDBsXThSiCiE75UnE0o+iQU8HuGyLlIw== 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 AS8PR04MB8753.eurprd04.prod.outlook.com (2603:10a6:20b:42c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Wed, 21 Aug 2024 14:56:48 +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.7875.019; Wed, 21 Aug 2024 14:56:48 +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 12/14] shared/bass: Add API to check BIS required for sync Date: Wed, 21 Aug 2024 17:56:00 +0300 Message-Id: <20240821145602.92083-13-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM9P250CA0018.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:21c::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_|AS8PR04MB8753:EE_ X-MS-Office365-Filtering-Correlation-Id: 4de6e05b-5a48-40f7-067c-08dcc1f17b97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: 6m+md7YBGIxUwCzNktlCJ2Rb+DTBN2j2dduhIdXi+syC0NRph4xeg9oN2ppa1JWMNGzLC3+yasHvwcOCMx6wWzGo/POnQKTpRcozL8CkKbyNdt/EcO9YX3AqLMTZTKNqp79RcUowVUlY7s1kGCrrXzX5BuX0pXDrtE8OWrTAqAouF1kjt4s3JMYE2ZXnTlbDg4yAIV11tWN92eiDu7s7pPuOuvfeE8IjNOiXRd5YlW0cVDjldp6EmVjRTd2n7CyzUr9kB/WZrxz5PyHpe9LDznR8IedphbTzV4RlbJmnLxUF9OLxgYSpDb3tT49jHFWZ2FrlkwMQzko1THrdHBujHYV6LioMysSkF4NLTBnJfDmR1rHED4IrrYe/Fb3f/GPC5Og9pf5uk5eHc3DJ3Z6cB4im4n9NN5UPAxELX38dIYc4DfT8kv6zW5nudbu9WSXv2MbB32o3Zf0wk0bMN90BySBYKjGPCVNSCctl0Ke4F+yYWG8olXORWleEkQBnlgtEZfEq9CdcaFCQ24gQ5OQmMJ23d+sq2CzZHYeYutnlwO2nWzl/RA3zDuLzn4s2GBZsNp0q0kRQUfnt/pyThSnQT9cCEizDoH0jWa42WqZxi+0fmbbgWL6GWGyPMyc0DlJs/j1QWFg+FbuCpw5r3A3CBGeHOlHPzPpmXOtE2gtbgQJWiZg/40eQ+nLR7X3CpkcmXP3nGa4iowiOoQ3YJfEsZQig3iMQWooi9HYKpE3nmfoOO/SC47RJsiJ8dBhZz5iWlaq0qcO8e55eSzZ/hZ09x9ZIn4npmwKMJju6GMv+WNm6UUrwdj705J/5Jv/5cX3Q1bfAw22wb077LWwKRpTEZFM/DUAzVC/OvmtNV84u40+QcRLSx7OL9lM7H9/T8vh+uakJ21eqWejVMhMHVM34TAi83Y37OWEW8IGyEjPLTa9+ZHEk5fkpy5Oh1MSaSNpGyJoTJxt1VIjkXgxFSqjh5fMVuDobMjP7kGw819wiK+/U8Ty6pfbsl7iOb1cN//e6DZyhsIc68x/vM/PTEfThJE7G+QvF98pz8qTE+54E2N3YWxkBj+RHBco0PTTHODHCF/f8h9WEzXBO9wLKbEbWC9ayJ5p59f4kGN32IrcV9m9D9F+uFiM1rDli6sMoykdeqB5NcXy0XRxC7TtusMIAQ9kqRzFJ30ZjCE51ZXIaEseRWuFK4TvQOG+DQgeKFkspuJ6At48iAnbJiR8pc/kOXR9sSReJSf/Enw8H9zkaMoJugmoSgSpcs0W8ijASDNao5GpkP7AImu/dwyhhti7kB1oQoPFWobmXkM9OgN/WRy4E3MYcVCEGnUP8pxwNluDMUdj0NX5+D6qdkbSTZMSaAA== 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)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sQ7OcBs0UwU4j4UwIw486YcuBf8JIL6daJ/XaNAD33EQqs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39lkJme3T/QgAicDAXqQuv7bAckMF+DI9ufCjwutWjg41vb8AKvYyqFjQ9gTNvp8/xCWZpIFb1epav1mwJkqrYTRK5z3f2W0+wcz2Rui7JxJX/PpYQDWDnTzgcj9BFUEbjlb4g2uGyYvyOtHi7ynBMFBoeexd1WnonDR9xoBxDxcAhrSiqMLc6jrvrTvKVFmjmuyuUTG9byHcsRGwn2Pd8Rw+dS7k4gMpFqasmYXlycUpMEP+u0BeW+opTvYQCqlfd45Le4UV8fwMrGBXt3wvmas+k5vrMC/EcMXqjqwmmlAiFZ/41gpGlPcXKuzPPkUJnVSSpOThabDKb4cyMZr68FK3fakU4t56kl/vhgwTXl8TOLMLMfv1ZEBfmUmxOTCqaEznxCVrXvX8aaCt1mZ8nlPuPIA61QK6Gk0vF/cFrsQwZGUQFRF24VzYl8ifHnhiX/kHLnmZ858PQtRrqUkZl590In7fZwUEkyumxbLAkji5Oxf1M5YQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4de6e05b-5a48-40f7-067c-08dcc1f17b97 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:48.5603 (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: i+UYq7mdyE+9I1T1LzmkotoTsUNui+Zk6Iq6lTdDhrz3JHaxwslvHU5W1E/Iwm4ih4aVaGW6OUBcGg5TaIeszw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8753 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 Wed Aug 21 14:56:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771716 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011040.outbound.protection.outlook.com [52.101.65.40]) (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 87ADD1B253C for ; Wed, 21 Aug 2024 14:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252218; cv=fail; b=b009JQkiS/iX1S+jvUiG0mcfMNc5XmxzvebcFd9umUGXNtZD240m4EusQW0g1G5yU6bG6kKUIZQy1dEjfJxYfmy2gNRyq0xDtlU03XsugqlSaqjaNFm4Y3bBtxjly/gWqPjveNOYcgZdV9M5jRRGu+/ouUY8U5bUimj/YfFHNCs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252218; c=relaxed/simple; bh=6Q7Dp8ZpVufUn5nO/u6slhumENWaHaUR3cchai9fW6k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fgxYCkXYUOGf6YmcULmj5hLZwkjYXJonZ7hOWdBvYp2Ct4dfWtaga2/NtzU7Gbs1UvOkRdHOxK6Zb6PDixNyfkoJ2DEcUI8m69JAYTjsl/CBtl74n7PiJDdtGmxKtWg92xMFwbRJrEMBiSz7HmwvG0NHW8IJEqbZhiwg1qfLWSo= 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=l652jIdi; arc=fail smtp.client-ip=52.101.65.40 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="l652jIdi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lod5Ks2q0nchysQsC5QYDITUJGiF2zcVNzysnztuoWPkvYCh5ubpkPE9lcpEFlz1USt74ppzaSkd4Hlf8FIUXiqBLj6R2N/D588Hv1ToN6Mv+LhjTIZR9QtTErlR2Mv2mgS2G2VzyEO/1PmkJ1iFyU3tK0Q7CZlNvGpXD+UD6M2BBRNe0R4aoC03HORDtiUA/xp1L8rMTA8SDpLBEXF3os7fQj7pegCQFoEGabCS3L45ZgI77gAKLcFXRz5nKZbjSvDDnedm9beixwQcjUhu3kPfRbQEq+FZmzRMsnWQM9IzyC7eCGPwlKgY7rIxCs6J0q3WDXh0eeTitRPA/cpIBw== 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=rhYuc7zrrgJ0Y7owRYe1lR2JAnzLA44gESQxSuy4vg0=; b=Nqtum7zBg5ys5NoTiD5dqkzLWT2MYdK7UVmQgYeoye35T9YF4w0ZyQN/m988usRcdhXGTqCiCXd9fJ/gMKjEtsIG2dB2cMQLVqJfCjkcv7d5VfzdACCiCQLlf8SW7plJzuISJiClxpKhsEatTALFbfejmxiycFDTP05sCmfFof82y1//6Kt7xpXz2z6vgioaJW8FxI4+FZyI6gw4AYGl5QUV5cveEwZcuDWun/2Use7h41UoxlgcG7gpxDpFliaC4QTA7bJ0lt9ZEc2VrBixtP+J1DxPjU0Uarv4Qv/+Ts2u3yGMsjMzitv0cVm403VrRJ1/gdGv8VlVmvLJou2Zhg== 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=rhYuc7zrrgJ0Y7owRYe1lR2JAnzLA44gESQxSuy4vg0=; b=l652jIdiIcO66XQ5k+vfvRbFDRBV3Bq/c1+2qPpbYNglXLV8V+KnRaVEagX0G99OIVYW2CtQDKBYifvF/zre8rkG6FVn5kTdG3lkfQiPgRJPA7jjHpyGXDctD1yM4QYwfnO3nkO7NmZXGK9ZttALXVde1zZQCxM6xuA8XUtXgrpd13/Y5HkYGtYqjvwSgRXGh2+tcEwKvhwFm+V0zcE/h0RTFpg1oxjkRQtBfTdD852gmORE94ChhaswASqnJXWfA/F1YV7rSmKien3QcUAzz+/VTZmgmdm2Zz2MPBprU9C5DJ6dbYE8FlkZM7Ju2lWOa+HdQEfm50azVrI2/cECHQ== 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 AS8PR04MB8753.eurprd04.prod.outlook.com (2603:10a6:20b:42c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Wed, 21 Aug 2024 14:56:51 +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.7875.019; Wed, 21 Aug 2024 14:56:51 +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 13/14] bass: Add API to check BIS required for sync Date: Wed, 21 Aug 2024 17:56:01 +0300 Message-Id: <20240821145602.92083-14-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0002.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::7) 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_|AS8PR04MB8753:EE_ X-MS-Office365-Filtering-Correlation-Id: fcf20039-8005-4d62-3b6f-08dcc1f17d44 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: tcNXHcQlMr6wKK/5dlgaVphB7KWQDHKgXzz9yqnJbx9rdwF4mOpK4rox+5KIQsYgBP9NuT8X2NBSzuDkxHGEGhcY7fWb/d2lAIT28P0iBapUIB4U1gT+iVHU+8VuKPhpVl3h64KKXy7mxiY7ku45g/rHJJzfZfH6+4LgA5SSZludTUSxFclfUtRx1XqOmJ34wNSXVORDMWu3RJ4VJV6KoWvggLSnRYn0TwuLXPOLk6YXOy7+KZEVEG5xgjOr7M7tmaYCT9Jr6fVU6whkQ7EyMPwenXwRMdTJqfkTgngtgTVTqvJML+xA45/aO9G5ouRnL6fquTRVBBUZOSun99E8AySJ3/sue04iAnTknWc7m7mIdmbb25woKdqnbpgjr8HX7a53A9225alkfCgsb14zYdjUZNYeGQ7cWE3YF0ca7JK6NSwl23J9SYX2P6xfjduPyalVEZChWahm39/h2/vcF3urgW9OpRZrQNVid5/rd5vJSCe0f2knLW9dSeMaNJoQTdqW99Oagl1z/QYQNn/TRN/2dMWaqor/26EkdTm+k9uqkJpBdz7ojGFG1HWNxIQlH8Kbd93Z2QvjSN8VQLxuEYFjc4uYWb5JvMIfMSmb3Y48Mj1bOcOTLwZAZ+tnY4qRDyMR7I2pAgzag8HqPbzzlTSLJ8Nk2uQ/WUkNo7txmZgDmJlSCUDlkYrTTO+aTgHza8Ra/zHGtXdMqEn6n95rL0hr6m5gB9oC8uWMWzGXjSJ5pOzIGtfJM9qomll0TRr4vu9vBuOZ63nA4BZv17GBAnryBsoYC7oJLFiqAxyGFRGvktDaEt3JTMRssLARBXdc2XaYcObCREeS6AnLHG1v0DlPr0aC7L8wpuFxxknBYkmmXx2wXLxJ57zyxiNJ5QfhpPWZ4bmSv7a3nKZw49AUFO+bNxOKoDmTkbMF0YIxIB+Dza8sHZhPrwL4Q8lyxluWDc5meASXdYfZe7Bnq2oSIM8lImSxSqfdwkvF0Z77l3Xt4hjHMIMVc0a33Elii51L2wt2SENqSJjCvkYsbkHyS0Wz05DopuQj6j8iEi+mfZIpggFa2Ig4kcD8u1wXorjxOY87tmuQfYIcAIyYdIznfHjdjLiDMjJ2TAKUZoc30EqobtnVEyAA084WwjUnHomhS5fw/ghlnq78neBJ5GXqjFKQ9LFH1oJInbb5rtL4IUJRErjYGHD1ZjQuYxyii0TZ4+8+RXVQsy6tMyDY1tbI/Za5sBV1MGhWe++bAVgOiXIM7ksegdaP1Bbu12GuKzzsOBGNxcoGqiOTTZjvnE73Vb1h5a5cqNYLdapp4mj6GW8wwVXYMwmw1jT/M2zCXvUYvR8aUthZtNyqqM9Btlw3Yg== 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)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: K+5ByFMYaYVd64/ZQ/m5xgpjZ/x9sgtBP0jmngxQ6wQouoaOFFqg+/kKh4tCO6YCUkpHK1K+MtXsgljViPNA4DacAn5G8v+dkxjaqIvTwt0Bb9Y4eqAZMw2zg9UUjP1c90SMmvTJEjRYHL5+QtN4duU20TVY6uDv1artVZHwfJgkxoVrS+IElAG7cuPlRQ+8ChiAnCEamiDB7afziYM8DdcHp6KX1Eam/nYA64s/uQ31hP9ro6wuGOekXbtP0Gt8CELAoK9vlcLDkeWEjWyF2pgZIC5vRvMSekkGYBASW6aQtiGT1bNMLkx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LkVSdjw60X/PsDdWBa0lVsmurqMBrRDgpvAOlkw9Q5U59soPcIsM5bP/LdO9pW4wkDUolOTmpPg8DGC5uNpgqf3pRE7LFAnQuccZMKTex1jDZsnL5W6EL9T2EL+pgmMVW2wOAFkBNofeoCHB//alKmDfyiQTNwrZXOCV1c1rImgq2yXgzShXJznz9Ydql2MV3FRM1JhWaXIC+3StqJYzniz7kU1/4q++kmEKVzYg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcf20039-8005-4d62-3b6f-08dcc1f17d44 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:51.3542 (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: UB7DKj5I3zBxfrzraxJ6HpKL/g4UjeQ3kkkNrz4suHf+N6UD1gfcEfUoHUNqEBbYAhmt/ATB+P+EzuOLLYxlNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8753 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 47445b4b5..1c63bc163 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 Wed Aug 21 14:56:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13771717 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011040.outbound.protection.outlook.com [52.101.65.40]) (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 8F2DC1B2EDE for ; Wed, 21 Aug 2024 14:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252220; cv=fail; b=I6ogLWi9dc4TgsoLCykP8bmXV0t2tqdhFUwtdRPiC86VoJqBMm6ib3eXCwsizqLIDUxHQjXLn4tdu/MD72hlwD2AtRfPv7etdvrDFJ9k9acn7wEccZZCdV2Q6TKJoSQvMETopgIHvzLAVse7VkK+SYAONm8qvqqGuwL5EgnijIo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724252220; c=relaxed/simple; bh=3870dVQT0bg8s166mnssLePIRVoYONnIUVlPwOpeSDw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=E+aYzdjnuhg+GTslT5p8JGmVLXmyPPF737xDEFJoaI2NLPcUlIsquEQn/5WNRZqP1kLszzqhUGXNCDhnJ3T0SfKvLg/K4C9RIENs9nisJX3yJImahWEQNLhymAWc4hqknk1Mc3KpXJFzzeLu+nugSOyD3+QbLxFaHpxohXqqYR4= 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=HPMkJzPa; arc=fail smtp.client-ip=52.101.65.40 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="HPMkJzPa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wl4TIKPrE0xUjGDxoL87w+L/sbETyP8+lhv/P0UYtDDM9G6TKI20joKQD5pMu1bthXq9uqC4k2vfAVvS/cERxNge+THfzTxLXqSnWk31LlgnOFXJNaGCUntMObe/crOAAW9n67qT+WqOphbNyYO9547j5g7ZfEV/Fe02B6JZjYB8YYSbdTqfgvpKx81b8xpF97IBmkLtzeUucL4Qf83hOV7f7VS2uuUo5OUzpSZ+C9wlopww++QWlTNlOu+b7lXShon05wxG5Jky1CfYT4NAKQO6AGTnIBUlY2gZOrU05/BedBF5CLef4VapKIa62C7eYnNjPSrRvgSp0+RlWA1IDA== 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=WKbbd849qvszLUfPUqVzWaD+9YNN/hToCsnyJjyyKnY=; b=WaasLZn9HwBWUi25o0utoapgP7r/fADPljyodUsDx4ayASmJuhj8UdAun4AfB1OccV1JXLvy3fCdSreYIgSAlhTrgpPl2efDotD3CYKWpsjiy3Pa2O/pFwAatM+Crp6weuRrd/bBymdbjD+Vnc2q04dJ5zXCKSyQB5Y4+B+K/5VKw0aiRlqntqs55ZSqXhM/3cpnzW8c9MwcCILOGObPTi1i4vC4TG3OEpu9Glr0cZ071K/i3edxB71GFal39NsvE1YRsO+wkYFx1kjOHSRFOLCBueMcC6MiV696zH94HeHPhONu0no/1Ly4WtEeEMCPetC4pHoIzCHxkMwpedEObg== 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=WKbbd849qvszLUfPUqVzWaD+9YNN/hToCsnyJjyyKnY=; b=HPMkJzPaD+CvQcg+rfJErSS6nvSIIv1eHPfWus2CK9zu14Nwqyo1X2uOC7X6zjtUrmqLaKpZQZcfq8gETxyIy/WRp2mvAzoaywBhWg1LNY1v+r1rnFpNmiBJguTaz3D8hr9KiCaAvN86QBARUAQ1qnyJds1UHLYz7/Pcq+Jh5H/nwcTjh3HbqH+x6kDNGB3CDRU884hzfsTi4bgQko+MEjcpLk6BaVWtEUBhAKzYi5WAwFk5VBk7VaDZdUOy5odGhjcvc6m+b9ezXnvUcU5lrpPQvhk23/Cly/TFWZEvMMGHHR9r78423xwUl/z+25EZJPFoANk5ofA4K6An+rK1SA== 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 AS8PR04MB8753.eurprd04.prod.outlook.com (2603:10a6:20b:42c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Wed, 21 Aug 2024 14:56:54 +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.7875.019; Wed, 21 Aug 2024 14:56:54 +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 14/14] bap: Create streams for required BISes Date: Wed, 21 Aug 2024 17:56:02 +0300 Message-Id: <20240821145602.92083-15-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821145602.92083-1-iulia.tanasescu@nxp.com> References: <20240821145602.92083-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM0PR02CA0126.eurprd02.prod.outlook.com (2603:10a6:20b:28c::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_|AS8PR04MB8753:EE_ X-MS-Office365-Filtering-Correlation-Id: 98410cb2-5c51-419f-3e18-08dcc1f17efe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: BccbpsluWc5yCEleCWuCfUoif2cWo85OXGsybjGdPRB9+v8dMB0flELd53IS1oDQadi0MXQVjCGxL+6Apkjzkm4s+UFC15TvV5eyUdlHepbruee1n88qVR9N4jVrRjDDci63LNRzab53DFgbTPU086fmWUQ7iwP20J+TgSljrKkPaftDiAzggk7NYS+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QK+ZWtkiuus7EGglTZQ3y/d/uV0y+qqaS9LXOveFES3FEtC9ZxPzlajHYZBLiWS4uFKx39iM9rjjaLiR8GsMkcSZc40Q6ndnGufRB0gcPcHcg== 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)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FqrJGV7Ju+hJk5wMOOmZ+HVo0jemPIaLFKsZ9u1j7nzAoEqDneDjV+jyHtjaXcra4+PePbg+YkFbdmdpmn+jMX8sz3uIHhEWKFVvXvFpNsvnROiNX0ydZE3nxhlSKdUUVJ5IlE7WsJesUE7qZxak49pBwrLiN/Hmei9SrETrnxhIYXAGaVrLTD6Sp+MLACEZxod7eQQZuEL4ToBTUIEYk/LybffjSCv9UYVw//vwXsgtg0gs2geKkPYLW+SRdsXU7evvz/Tmexo6cA5okz7hewwVCXe6+SRYDKneZQcgweBRCzRijG4dUymptnusm/Hu3zTn7M13PUORb5yzaOaXj5KWMepR2xLBwpgmtQTJ3t46ct5GW3RubnuL7Fmz8cD38OXel1hO4DhmcI3S+llwMXd5U5/isjBg0oBvZHTmTYfKTCPGKEdlK5dGs0qBjgLAdd62+wnSX3cgBZSfQ03eJt4ZqfVY6L4n1dJ29W05zebqrq7AmYSi3pwKi/t5d+UkbqThl+3B2yqKc9ep96puTBBTTvyF97XPG4f/BECupgpLcAgRAS0uPFJJwxlNl8sPTDgL0niCsxaXU+pLmB6oJIH7A/nR8raZG1FC2FfZLWB+kH/BE2Yy7zCA2Rk+8PMNa7/Xgpby0OBVxJn4/xgjuUbTJOjK1QMCuUgC5bS7bOLGvFevs3sp0HQa7jqxyZT5my603htaYnnQ/aaWL1s1rzTfFLXt5flf0c+0wkcaq75IEOfPFZZTsZxInhB0mKnn3uZeMAygXpGnPYQmSx92u9wG+GazCTD5c7P7sJiKrHEWK2i2hW2pCpFQUKy4r1YSgR06KIBX0x23tXZSWaA9RIEVnzYrtl7K2viDHJ3JW+bUPIodItbKCfyRF2pLJc+PJTzOb8P4Eg22jHipRZSop71hzijUYnFwzctP9/qJo7rA4Ll2CMuekyd01c62J4mlztgiOk17CAjx0prAdUKagaG+45vO1dBLIeC5pr2UYP2hW6J8HI9I5Ejbq2rAqjDYeV7G7tfg1Oi4B0LP98MCqwv0GTH/qtcLtcr1QsD+9L05U1jTXtSMaxwIK8VTKwk3YSUA7PB0I9TB/vqjSLgldQ9NQgkicNCP54wOQE0Gg9uvnW+qWOwJg4TmTIeLQHLKuXY1mA1/fze69+VBiZhte6+kp1LD2QAEc6jcXUcqvomEYT/xOtz0v/AUV7vxKuNMqB/rZPbdS8uUozLMFsOWQo5CXKBlrLsowBICLtbRBV3fiN9xmzCzhfKadIUM1WOS5zHfjOsZPjoDDklRhuWdTQpHhQi2sWtaj328DUV31dCIU1nva8mdKkOiBG9Bre+apYUWF8bTh1+vbXSksOBoCGY3Sd9PLcrCG/i4isEAfc0GXaCkA6ln9QdYX921Jqq9yqEoAhJHpvsyx46bXcug8/p1aHYXXLyj3dzF35zAtPtQUKmY+TsbFyPstVJIGidUOFmWNXGOoOfNMrPV/jneeG3lg+WaUVXF/zZA7xMQX1PSRHnOGSmwA3dwxx7TRsD1nITUnhHz4zvPzAGZODs/5BHO/oCBNYgaUOGKC4umuPGQKAo/vmi5YOWOA/OQ82/9Rad04ZSOlaWnde/regw+7A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98410cb2-5c51-419f-3e18-08dcc1f17efe X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 14:56:54.3315 (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: CUcoHdPXSc4LyzjxYKBBclwL78b/6U6gAFZah7IGTN+iXZCyEGQ6ANBi85BHAQJssnKx5CCd++VN6w+oebVIwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8753 If a BAP Broadcast Sink is acting as a Scan Delegator and it has performed short-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 bf924932a..a6a9f5818 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1226,6 +1226,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);