From patchwork Fri Feb 23 16:48:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 775308 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2060.outbound.protection.outlook.com [40.107.241.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AD3B1272C5 for ; Fri, 23 Feb 2024 16:48:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708706903; cv=fail; b=Hlg1qc9NO/uvDP5aDeRyy73k6dleUeskLtlpU5DGJnloZ7zJOphoNiiHu7RTS2asAIwyIALcYnVywLQ/qyM9yyJp+xEUTnvKbdTu+jpE70xU3ACfiCSXTOiYxCb3ShdFDz35U8H0oSsZuAqDJY3w87cGFiJuESyTZPQ5zbzVrmo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708706903; c=relaxed/simple; bh=e9zndTgxsrySeQBGz73yu7p7Wk2G/ahmu2fKkt/WC/s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qD1mYC8e7eQRdOQfz1NvA6ADQQ0+VANUGrIUZh6/iVRsiatlDCxDzU2VJQq/PZU+KjHQtRn5jPUCQtvMtuP3RBR2AodFopn79vkVKsb9C/3yQS9rMGratt+BBKC8XUunGs+DoFfEEK4E1vOLcb6xmPrRrFNlIeShQlrBNKF3BtU= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=d9zbDd2c; arc=fail smtp.client-ip=40.107.241.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="d9zbDd2c" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IwImXD1wLBQv/dP3uwKKhpJyukhn840cqjQ2v0dTsQ+z5NOqUmrzt0curl0ER4RL/l4TalIIasSriTOLXrWZuy5JO/zTk2SKE7x8ZlI/H8mY5qpVOgx8QjokWhsscaddCabk5PvW5j88OFMfjKunFaRQcO1S3I8SSCCM6SV2PFq3XAyLxjgHDiwk2kvi6u59t+qd+8ddAejwBB6ie2YKtQqlqC86/rnaax0Bi7R+xHDvpsNYASqeKE+5EWLPj0x8PRquBkmvgsT8oXPwfqSWK8Zkyhge096crrC3WaCqXyhPEg1BYcrUFCnldvLC4CIJufspnsbd1w4jCmGQVNkGHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=u3XcdqB4CfMF1Y8TbacLE3tUuIXEHh2xCv0nMO4qmwg=; b=hioJHIAGkoUGy91flamWE2+rRfWztjZd4nnXhxeIb5YfWNSHCuL/Z2GpdG1mDsTMnKHtwVep0RvCQ+aJCpogPiR8eIoUjqYgqQ8sdcitTXpOFxX0l2rVBJCX+is5XHBItSawZgeoHP+kirToZxCHaWOijGTYF+QriXp21xL5R3sZH5uG/uxVkjxrA2qVJrV6BqJ2Qdc9Q74DQeXs128hyN0tyz5aC+3lSw26pb4xI0Xn9nxSN1sLyP2+kb5K1hgt45wo+k50jr/RvXNzjQKXq2rxPRuWKbULEBD6dEPUY3oYvEQwwhuwQLhuv68ms/ta+PWTneyYm/8ztVZP5VtH8w== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u3XcdqB4CfMF1Y8TbacLE3tUuIXEHh2xCv0nMO4qmwg=; b=d9zbDd2cM3X9Aur4O77CBRpYSxMbPquNa2DH/CfFcSQyWrRFB2vQoDbp3Rp3fEylZJEZbRfBc3UYgkPp+XzGT8GW8ss3gT1NWfqG151s1fGIgjMkWwZoqan71Z+A4OwoqmWWp6BSpMnk28jhDM7vpZ1rvIUT971LY1LDghIVopQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) by DB9PR04MB8479.eurprd04.prod.outlook.com (2603:10a6:10:2c5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 16:48:18 +0000 Received: from VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81]) by VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81%7]) with mapi id 15.20.7316.023; Fri, 23 Feb 2024 16:48:18 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, iulia.tanasescu@nxp.com Subject: [PATCH BlueZ v4 1/5] shared/bap: Fix endpoint dir for the bcast source Date: Fri, 23 Feb 2024 18:48:09 +0200 Message-Id: <20240223164813.66484-2-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223164813.66484-1-silviu.barbulescu@nxp.com> References: <20240223164813.66484-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: AM4PR05CA0010.eurprd05.prod.outlook.com (2603:10a6:205::23) To VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) 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: VI1PR04MB10073:EE_|DB9PR04MB8479:EE_ X-MS-Office365-Filtering-Correlation-Id: 043bc90b-73ef-429e-1320-08dc348f3caa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A+JPzW8teiy3J1ASSWJLccsAcQPHMLoUt0YFWvofV19NqO4WgJthZPqApTNkjKcOfmShYU6hZqAqe9Fw/hvijCiDiYx9SUJWy/gN9c3h4bE6YI12b6U48tI0iF5Yrpsiz6dS3lWKyck2nHHZXhDzyoZWw3ySrOLY4ubcyrZJqV5Wv+aFG+s2OCANh4emlUeqWGI3++81iRZlSPgUrClcuhEg06/4g3ptn41l612kBEIFECeC6iBo0dtpuAT4cO9PmkmLEYVWl11sEp8jnUGbYWpIXMzvV05LAAWrG0rVXNPUYQ7xARb0l4A7yRPe5guxTwj5p9tKsDWZVGnei4/QkJQ8f+yZmhl6/Kry429/aSXvglxTUghZIOuBdCZ218V+9SupCtkKnJCHe6qEbQKD3Ht2zDO0O693IF0FXtJvfvozBIQu/DOByvG/pDyIShXSgh0HeEcjnQRWB+gxYhb4S38D8rPY9X3ugDf8NENL4WmSELc8OvGTsRrZV36PKwDcJvx+xDA6mNlHmc6eoFdeIpxe5GNaRcS5Nhmt67zec5U= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB10073.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nhrQxP5SRq0FG17YaJVGJ2F1cs2+J8+IVjp2/1rlUqo/2H6jQmcFCEeb0P7vBF9JiYF0nFFhnfDJd97h4ANRpF2ay3cbm7pfWUphTFFcTwdamC+Jbno6Y0V54X9++FZv4C57g0NwrXhCp0ratiUwZJeWiGqmYm0ElzdwaXJFq19b8t/RyorpCn7yPKqi+1oSvM1mJA1N/ph0EHuzlxEnWRQ1dIHREm6rU28KduBSeguF/CLrLtUuoy7wnzcVKwXpdhIuQlqXjbgpmH6UYlwAqhABhIHh2Nj4FI3gmhMgvCmiJSZZ8PcMbwiHAwspb3SCWYgJKhBMENrPjo/GhTeQTlFvl4bf1O/hyt4BnYA4/5W5tBdPFFomoGu+9FKvB5KWCGcQ2lWRwsHV7qWOsnQ3OJQDMIdLh0lVdYAgNSDGw5FSbHXo2JD5DsoBNiw9N9YSBuQYXXxpB454fKRh3evfFng2TLbBW62Z1qo3X4jFaO0hmGLvEhFjkXoykhxMH7VJAwgp3mKeV78BQOWlZ91qJxqNrf7cVmecxhwmYZn1UnMUhdObg0NYxLW/LCBb3q1pAe55Nzem0GUTqZ/QaS413qfVswfz2y2PyoTKGMTknRdxBpeocZRgkXV2S2TOyw+YC3UDMM4aJhwcr38RAn45V8wYmfxxGDiWkoDTh8t77/cEvGqq1eH5Bq2Qgks9iTrehkHWyxJQcFNkJl1szmkfkYvgfOZiW5aA9Apjs/+6bRpeaZXeTuIfiiaMrFDOXtkFTzO/nN6t/CIJrVIJbVo1ldqR+D5yQOTd4pZi/ey8iAPwiTP1eeL3BOmt64+Coj21fkkiQyljKXG4MQ4ibk0xC+BhA6/YK8jxn21BKSZfJnIGk8WR+213Px8pGfKW33yqg2qsYoewoEpHoHiTe9HFbX+IdnqxE3ZZ/QGKyOdsxatuY2zpMvYqkPbheiy9q5tFjC2895HK0sJ+SckPDHxxYI0ZGDtzqO1doHIC0SluPPwQpL9vozcZz/YgYlONaGQTr3lAGugdeH4eM1mXxck7WpzLjoXwfankkWR6DBPQUgaTnnG0tWxXQx7dfX32VfRckQUnvOmZHu8rxjQV7n5fkgIm9nW9I6mg1kSUVm4iDQwWhh4YNFUqClLM/fGZAgCoYs1eqzUzo56xlHNeIGoQoXLY5DSkYXiMs33s0rZOK2lrskclDTNPOJwz1QYh/K7aBerHXIr/yhCOTVpy60B+17/Rb537W6AQImyRG1rsC0H0vLAtZE761CL9wwbPQMZkLvl4o235Bv8IU/RLwEy43SidNJpIr82KP5bI++F+x3iZZfj+2YgI2r9EoVORUlFE5vRD/BaCXSDRG8KByhhBNczuRGDi4EWK3/LBlFkwsb33D4tm4eu7UidpTSpsmOWoY2VAhogPVRiV22tRzD44sT+qyNW9aT061ds+KJ3++Th+3aG5ToB8vdOBAW2vdco7U/4Im884nOnQCWuBMebkCIGVKtQ5UXHCp2tcOkde+hU5YbyH7nLleOl0WwixxhNfkOjtYoNid1fCRoqi6J4JOwk6+OFM2WneymszJrfR13yKTwCW77Sat3Y9IfRFVrKTcpGKns97a1yMw6p35GoOaw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 043bc90b-73ef-429e-1320-08dc348f3caa X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB10073.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 16:48:18.3501 (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: yPCL4EKlFFCqJ91k3nlH+5T8h7bUH85CTNQ0nrCjKRclwlPsERxu5pEEthXeS8OvE5JnjBunbcVfvw51VrFK3kJv1C5B0P8+XcOFaj8k8v4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8479 Fix endpoint direction for the broadcast source --- src/shared/bap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 626e8f127..fd29557b1 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -682,7 +682,7 @@ static struct bt_bap_endpoint *bap_endpoint_new_broadcast(struct bt_bap_db *bdb, if (type == BT_BAP_BCAST_SINK) ep->dir = BT_BAP_BCAST_SOURCE; else - ep->dir = 0; + ep->dir = BT_BAP_BCAST_SINK; return ep; } @@ -1303,7 +1303,7 @@ static void ep_config_cb(struct bt_bap_stream *stream, int err) return; if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) { - if (!bt_bap_stream_io_dir(stream)) + if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK) stream_set_state(stream, BT_BAP_STREAM_STATE_QOS); else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG); From patchwork Fri Feb 23 16:48:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 775599 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2060.outbound.protection.outlook.com [40.107.241.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBA8512880E for ; Fri, 23 Feb 2024 16:48:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708706905; cv=fail; b=WZ9WvZdooU2Kj1rNT9VkOnn6T7QKnOU8ZeoqK7r5Kj9r4ZW2umw048SxXnHsyYX+LHgjleQ4BpkanhM2IU2JhdJam1eML2zd06R2o6mpu3mA/D+IXfQTpycHKYrNErjuA7ca1DxpMe06kJMY+QJHtsQZLMzl7uWPFRmVF8IpjAM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708706905; c=relaxed/simple; bh=xFQljZp9Y8UQKSimCcnE0Ofh/VLNQmMqh+TpxgwHN/M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=JklhF7/CuyTVkw+W3sCCfIzrGzFGDM7Y3gDjeCWl61QNOezHnbsJBlyT486Up12AoQzoIfCirAYgIdH+YAsnE+bEaIFTQfZA4mR/kruVC8v6QKb/X4VBu6//JMdBMMutCaRBHTDbz9gsxi4XqNTCtPDFkMlb2l3JfMq24f03ZAo= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=QDt7CUQZ; arc=fail smtp.client-ip=40.107.241.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="QDt7CUQZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SYeYQ0ZxNcjg61JZfl19BeuYzBurd6PzcxIwJT0Xa7gaFvAzfkdYunilIOPzW8+/O60yTDx/2NhB/Qbh31phQKE7Hwh03d98a/4ek4tiVV3FdQzxZKm+HMTPi6wjh5sj9B0bASbsridq05sXuNUuysf9xbzeFWKqP812QaVHPUQAgmn7z3q7jMfjmBGkvsgHFeeKT5Y0xkvEpxfUUuONOX17mGeVBYkXzESlasjoweI+SHokdjPSomG2evAO+cHIJFdmwB21b6oEGWCmllvN096wdMlSqX46WKF+mVYfcT8A6jWeUrxguwOYdEHD23eNAPIj+mrjFfJEIxTtOBM8nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=QYgH+pvODzD+YcGEXRrYjMyDmb0xa9sfFbcQdvHpYRc=; b=Drf62I8WhQnzLPTaTO04lqMZ9iqNHR+8uWDGa9ePm7we55Gv4cbW3S8hBW2q3xRkmCT9nMGusZ4tUwHhqKIWhUIOzCpxTUtBrNPX3GhHiiHiWUz/rwKTjDcN7pkudOy4vS216BjWv3yEQkf5POme6Bz0fJ8yfNGnEBcoOD8p1H7kzzMUDAoofOSbwZpr3bfBY51Kpcu49uafW3M7r2KHNr2g8GyMp/XILWn9HSnvwhv5mDgMVSM80lUhzGQExmHvij1kjC+Fpw+ZUzJBOMPu+fUDUYNAsrtbucPTw68H3clrz6X4IBMp3IiajQ73KuUpA1gtXg0VZPKbWBURY28SwQ== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QYgH+pvODzD+YcGEXRrYjMyDmb0xa9sfFbcQdvHpYRc=; b=QDt7CUQZ9Lpy+tDQOTxFkn2GiHWQnmYm0bkHqonnzC3qB5TPh+VS2+5nNBq8G61xWPk1AMshIg7wWU8jsYiUNnRSUtvcESF2TIEHV066HR9mCWnWlpdLCflIYyGBtrKjrYfdQlTs9RE2w6H0eybynqf8RpwMcVO0OkGLqLmiv9w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) by DB9PR04MB8479.eurprd04.prod.outlook.com (2603:10a6:10:2c5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 16:48:20 +0000 Received: from VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81]) by VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81%7]) with mapi id 15.20.7316.023; Fri, 23 Feb 2024 16:48:20 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, iulia.tanasescu@nxp.com Subject: [PATCH BlueZ v4 2/5] shared/bap: Add state in stream struct for bcast source Date: Fri, 23 Feb 2024 18:48:10 +0200 Message-Id: <20240223164813.66484-3-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223164813.66484-1-silviu.barbulescu@nxp.com> References: <20240223164813.66484-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: AM0PR01CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::23) To VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) 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: VI1PR04MB10073:EE_|DB9PR04MB8479:EE_ X-MS-Office365-Filtering-Correlation-Id: 53862b1e-e266-42fb-6e07-08dc348f3de1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tPAk8VPJmM9ysMfyEiUBPaj7SB6QnHJy0yIn4S41SP+wTjlYhQGf/UnEOw5JEz3w9mz0UdaUt3EaWQn0bG/tEnmLHp06XZ08YQ1HK8/WzhenLzxyNhGlS/xbpevp4ysvsMEq7uQFcokRqgrx0Vq6upK7Zj2Uqr0EfKWR1koL6V78C4CUgHi+iiBw0VOyF04DrzeeUP+P9Qx6SaBTpW5VgdV25hdqQUOV++LUHr8h9MWoGMbmEi1afGAuiosPixY7+VKrkURDUq+gcU1M5SEyVkGoV30qiAMaFFtGoJps0qs3GXBY2dPZiapdIfAKRnpDSndvQJ8GMeAHfL0JQQF+ha8g7JiTV9p/WDoF3Ua4MBendowPlK1+Miu2ojRjb68DdKqlWl/4sruJ350dlOfg+ZQDAjPP/LrAwKvu6eTgInZbnxduxZGlwWGbevaLV09TySIejXdhQHBWXkpp2ewmSv8DiuPWJp12Nx0seOzsajt1li7JVtOsdBtKE1zVhoIztJUeaH+kxORBTvBZgs/NNiEF2Kpuj3iJQemv9aqsrGQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB10073.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Bw3Tbk2hIxNr7YWf81SJiuAjYNMN8OEbQiH2Wghcq9/vV9DiPTeVhjP+FabeS8jzYDGo/YlCquDIN0OSulsTtOFKljRAKvHhdIEXRkoJ568bqsczYWjjfaVs3B2FnDMjOuK9SAjx8YoH8UzfsSv12fNo/ZkEZrSmCjvJ9HTOBkVljBkDz3ZML2KqrkRpj20lU4kMB7zlslWft9MpuslnrwRxBA8qsFr8gJYliTdzNGsgTgEMb2GwFO1F+t83WnsJOpZoY0cbTQYhU5vDCohycTWAmzy4FulzV5wh1q2YcQrNrz8zpGIjaUQQkeZIUm9ZyeKmS+2EkJ6h+wAmn2uXgZBX4aSQXkNjwuEje6HSIYyHpmiciMF3YyqiCL9GnohUXEhhIXRbotXVxarz+BTfdeMbclYx5lNmHKcr9Oo5DUH5bav+uQ+n6h1wwAKgY8FZN9HP4pf5QFcu9c0BckeKu1GKm0TUl9fL/hmMezzqesJtCNu7jgzPaLHP8lNnaBMys3v+HAWMX0EV2Te1a67Zso67Izjj5S9Uv9IldZqO+8vf472Uzs28B68bIImmg8L9V6vvR7OYMjUcZebVDmlxkEuo+DPmtZcWfZwyNyrAU+lgY1dosqELWHXE0A03tCHaJwTPWa249Z73qR+nXmNEAvslemkdKUf1sELDq5mSyjYH3YCzBb/nP6QQERbppF9UcEBZu8W+Mb6EdRzrBjZ7yzXNfdTT4rfDj6v8reWiBbRBbYJLlO0jCGw5dD7gyVB4AThfLTt7RTrrJHWwmYTVpdcNItWpwi0w2v/PcAOWF/9WCAR6RLPPZOZbQ/fgcy86Ioi3rSFUFrDufuHGsrPbo47MtkI26F6r5BMd0dzDiChbcWNnw9CVzW1nwZhFxrvyBrMJD5Yrak8+OhJVpoJswqHI94Q1vaIieNz6djt8fDT/J0GwKp/8aKgHyOvFLgcLVcRWHuuJYR5gjyAlqZ9GoQMbPIwpAkaMiyWcfcCKldVBrvvUuB9tbDwdlidZeVSKE7N+y98n2ISoEAqhT7ahdnN+1+lbj/0yZ8ojBCofA+7SdexRUjyCE6SbNkZ8I+yC6B8LyIVbtpktffEEg4ReA95zb0HR5YC3qOMRUlV0kXlTfh3FvRxbSs/AvFSZ9QMBsT80rUBSPfCmXZTzxJFsmgsy8TyIvqPGtI66Gba9NghZgHeNDvhfvGbx9IQCbxGNpoxZ2GrUCaOd8PTzv389ckFdFTAYN0hjOm5F8jXwAbip/l85Tg7IzZ+RDwH0aFPQw7f3AXyyJ/q6HWa+ZpiWSPJBC/JhI8VfLxdZ5Z564HIiH0vxdCuFqSMj5fGGBqOccQN0jVaLwJInznFEAIZQCIknImBuOPREeeRGWXN95zSE53OZX0/UMO52FxWfZH3yuecpaDOmmAr9jmhQn7fhUhrMMSA4KeyYBT3ege4A7h1xA/HNhgtAghFaj6HIEDcfvs7/VXW1/pQKT/ZkEq1SmOdA3NnerDijPUDblPjiPa5Pwxj8ghDOTVYhoBw2iNtNMSfLt9mNoIRN7RhD+9VIckIXl2dVOudOMTVecX+d+EunkyYUm0am/ryLMPp5m9m3b7OyZqGINmplVT0TPGjCWg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53862b1e-e266-42fb-6e07-08dc348f3de1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB10073.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 16:48:20.4198 (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: LLfgysveid4d4AHVh32jrC9Ge2S+2W6OLvs4v0gAfXyFJgpWcon7pu4LvHmvUq9htxC81YJFK+/vxriLLq7b4GtPc6e9MccnNYTJlI0o4Ys= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8479 Add state support in the stream struct for broadcast source. --- src/shared/bap.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index fd29557b1..0a336fc01 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -251,6 +251,8 @@ struct bt_bap_stream { struct bt_bap_stream *link; struct bt_bap_stream_io *io; const struct bt_bap_stream_ops *ops; + uint8_t old_state; + uint8_t state; bool client; void *user_data; }; @@ -1271,7 +1273,6 @@ static void bap_stream_state_changed(struct bt_bap_stream *stream) static void stream_set_state(struct bt_bap_stream *stream, uint8_t state) { - struct bt_bap_endpoint *ep = stream->ep; struct bt_bap *bap = stream->bap; /* Check if ref_count is already 0 which means detaching is in @@ -1283,14 +1284,6 @@ static void stream_set_state(struct bt_bap_stream *stream, uint8_t state) return; } - ep->old_state = ep->state; - ep->state = state; - - DBG(bap, "stream %p dir 0x%02x: %s -> %s", stream, - bt_bap_stream_get_dir(stream), - bt_bap_stream_statestr(stream->ep->old_state), - bt_bap_stream_statestr(stream->ep->state)); - if (stream->ops && stream->ops->set_state) stream->ops->set_state(stream, state); @@ -1527,6 +1520,14 @@ static void bap_ucast_set_state(struct bt_bap_stream *stream, uint8_t state) { struct bt_bap_endpoint *ep = stream->ep; + ep->old_state = ep->state; + ep->state = state; + + DBG(stream->bap, "stream %p dir 0x%02x: %s -> %s", stream, + bt_bap_stream_get_dir(stream), + bt_bap_stream_statestr(stream->ep->old_state), + bt_bap_stream_statestr(stream->ep->state)); + if (stream->lpac->type == BT_BAP_BCAST_SINK || stream->client) goto done; @@ -1942,22 +1943,25 @@ static void bap_bcast_set_state(struct bt_bap_stream *stream, uint8_t state) struct bt_bap *bap = stream->bap; const struct queue_entry *entry; + stream->old_state = stream->state; + stream->state = state; + DBG(bap, "stream %p dir 0x%02x: %s -> %s", stream, bt_bap_stream_get_dir(stream), - bt_bap_stream_statestr(stream->ep->old_state), - bt_bap_stream_statestr(stream->ep->state)); + bt_bap_stream_statestr(stream->old_state), + bt_bap_stream_statestr(stream->state)); for (entry = queue_get_entries(bap->state_cbs); entry; entry = entry->next) { struct bt_bap_state *state = entry->data; if (state->func) - state->func(stream, stream->ep->old_state, - stream->ep->state, state->data); + state->func(stream, stream->old_state, + stream->state, state->data); } /* Post notification updates */ - switch (stream->ep->state) { + switch (stream->state) { case BT_ASCS_ASE_STATE_IDLE: bap_stream_detach(stream); break; @@ -5243,7 +5247,10 @@ uint8_t bt_bap_stream_get_state(struct bt_bap_stream *stream) if (!stream) return BT_BAP_STREAM_STATE_IDLE; - return stream->ep->state; + if (stream->lpac->type != BT_BAP_BCAST_SOURCE) + return stream->ep->state; + else + return stream->state; } bool bt_bap_stream_set_user_data(struct bt_bap_stream *stream, void *user_data) From patchwork Fri Feb 23 16:48:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 775307 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2060.outbound.protection.outlook.com [40.107.241.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A5D41292D5 for ; Fri, 23 Feb 2024 16:48:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708706908; cv=fail; b=XNAIeQALU63KIkVuZLp0fMIWZ9fHFa1hrXCNqkd1GsA7BGXq0sWESpj/mKbt+48B+LC2fhV0BSbQGjI/92dba9euPAZtUB5dqlKJGiGhPXP5piOmiZxUi1QUFnqmOGhFeDIK/kKUoCdMt/jkTt3seJD0h2Cx337tZbTeUPMeX64= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708706908; c=relaxed/simple; bh=LlRSp+8Ua9A3XNddrlLOjmT0qohzHHbYajSaClwaG2o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=XCBT7VElcTEUNOfHC8WjSxykgUF1PjbDQJHSkoHZWZF3Z9Gh4HF5cPF9RlIwCP216DQVkH8SJ5pYDlgsidrj//V+sL1wFHFx19aD5pezohWXijg/mZk7/o43MFwWWwjj5rr4lQHfpKH1yuQBXfBgdJulzdLMA4EMIo7u+d+spEk= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=k/8wVjD1; arc=fail smtp.client-ip=40.107.241.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="k/8wVjD1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FSmLckr4C4JU2fo+BbF92kNTXhplPnH37keWjoZj57lWOzmLJrY6RkP0cTVQdl5H6jhJZbxJ8sm8I3ZWGLynz5hKHgN9P2JsufNNhaeUcyLhXxx3tGioeVJ6f5OO9adIRsw1I96Ajlu+Ncg/v4dluRkbdn4eopGaEl1LgZLEq4C4A5z9f8BBmYvLdc4Aw5ObVhGFBLYz6XXBTycPgXx5k7ZJ/A9P/VHmxQ2gzXF2G8ws7zpoz6sWtolHa4oaevXT1UOwqcJPyS/33kVaA0Ub0OdpsgOJHVWydNe41RuHZiE0l2ILGnpnAEIP+LIjDhY6ShoMzvrlq9b8tDhzVjDDHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=SOkCteYQTraNxDVvrJGA5+7PxNLuSIvyCF0eK4k0hGc=; b=GE8nCcKYQpAJHMsDet4w4GNg4mA43od6uwQ1nziuXdUveAAbrd9HeNaYRez4/jajex9pT/UPGf/Es8EVYCe/41nEi+eaEG+JmQKTyEiahuNv8Xxi9Aja2HJvynAmQiwFEAsn278o98fWRiT8cTlUmEO4CdrpOcQeGWyllBTO861cU2gKG8zkkc0URV7HgOImoXjB6c+snVWR9frtsofRbay7lejuZbTN0hnjnsHf4sR/Jor03hUJcGQw7xqosC1B614Rx+trSo8JhQoNP83QAvncFl8sZdQYQCtejOnhme4FhAOsVsU411FX5BEV/1rG+KuU351+laAK9U7bVGu+Kg== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SOkCteYQTraNxDVvrJGA5+7PxNLuSIvyCF0eK4k0hGc=; b=k/8wVjD1li7E8iyntuW8flEJkoZOmjvKmKqwSIk491dTBXTGyVO7+5xvwskSwdtzxEL07GZVgOHX7/RiRc5u2NFI4pTHtnTjo3zpfEpQddZXXigNeWcIbPwfSxYvRabxKzHxjpn9HSiyZh2XTU3DeD7rxkTd/vCAM6vb5VI6UmI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) by DB9PR04MB8479.eurprd04.prod.outlook.com (2603:10a6:10:2c5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 16:48:22 +0000 Received: from VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81]) by VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81%7]) with mapi id 15.20.7316.023; Fri, 23 Feb 2024 16:48:22 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, iulia.tanasescu@nxp.com Subject: [PATCH BlueZ v4 3/5] shared/bap: Add support to create a stream for bcast src Date: Fri, 23 Feb 2024 18:48:11 +0200 Message-Id: <20240223164813.66484-4-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223164813.66484-1-silviu.barbulescu@nxp.com> References: <20240223164813.66484-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: AM0PR01CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::24) To VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) 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: VI1PR04MB10073:EE_|DB9PR04MB8479:EE_ X-MS-Office365-Filtering-Correlation-Id: a472dac1-7088-44a9-7581-08dc348f3f2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A/U6p3d8ih+lWeimToS+igyy43ZLYv9K97NeLYCV+PO3CXgFrbMBTXvRkFc1I9nu48F0A51haqe98+XBu+wQztSElOsqbXrU9sX7UsCvCO63QqaSxDpyS7ki+2U9NJpz/AfzxxkrHpB9IOvSJweF4H08g1MMIDtgb2RWmBPIZfByRsrPbVNcP1khQ+dhschsp6jAlbQYgmvIDnDCinmcxnlCsGddtc2w45XoPxsUHaCm65UJSq0DqhhBxI8sF89EMHtprtRQnXMS/wRLARjiMKnjFjhvw+fUcP91qmJIhpm1d8am87iLXE2CJjE1pE8FG8GRa8KXdHRXbxdVAOj/G+ESEEoZmwQVac7tsa8Q6U69tLOZqbMNK8+w49NNEiLBtvm7PzAptyBT92opxa0gdAqh1F/xg6uQnk5hIE0JToomQEKmrYmdr4/CZ7Q45V/36m4cQSvf1s7cXHO3LPOWmEvUlXyAzDCamenk7cQIOBDwH4xIGuXX0R4ZdcZlgae7WQmLdYLFbrluk7gAJS1Oy9t2OXeRNOg9VN8OjoMIqh8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB10073.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xG6kh88ak0/rb3WY9r9ec8B3dmZfcbFktaqFyGM7w5LlyXzqaK1JNrhmdZ8LJq8ZSdRFyucCqA0HOolscI+HcvaR9nrPwG/5jAPpid4VM2Ezi4S4rYbqin86NG6yMN/XRqiE+AmU+RQPm6cxGe1NHu1kVyHGnbrSov0lGd0D4ENXCTaajt8jAie9AI714okSXjXcnBPlUz+B5VQ5wz90WXZsiR7S5Z49/55lZcBwROt0RGt1CxuaEwdCluVBGyyZRZdXxNhqCtenSb+0jkRVbvgWUofFa14bf/C3VVoREJc3INzvMtqqKO3rxproKuOREd2sC7/GBCHDwpgR0a5vzBmR1ZMtzGXPLbZ8y/JvWkupdem1AacfEJLsGhosGS9kyZ7aPATzuM2DWFfN+fnxKdHc6UN/luYiOKEE99IZsKoBD527MCiG5C7g4w9AUS/TFOD6YQUX8NDGM14kmEoga51xsup2ugpqOkC5yxDC/JGmD8VUcoowrT3v6JZ39bksbfqpNj5VpzCcFodaOfM8KDP+G+FSUAK/7+G04dAaxkB1ur5wWJW4lB62qzpC0gzt4UBAkczNRbL6EDfgpzAXAm3A2xeYqn9GZRmoEljS/cEZnpjPRpcOZ47eZf3+k6GQzfna2EhmP0pRG/6W+0OaGH1eGiTwTMk+fcWsEYQBBbF1lUaUg+7bZc7dJahlzPWjn4nifzTF28bHpcwW5KFZ69Apc8+zIfOM4eCtae1ljNFLHnqV0BNzo16jG/vyRyiA9wsp8zOzzaQX6A2ftU8jbht2wIbpK4P99xtBAbM74ir14szXS2PqVLULZ+zoihOqkJMSw0wRf7bZ8gNPIB8povJz1G1VpifXjShZIZ9fhAxaBGrLgKTek0XZzs60ankKDL//N9xZUFCaz7enzKsckaDs2LJNCM1gAAjzoo3/0KS/vNKrm2k5c511cqXs1sawuIOvpNZJJfqV24w/zx+SjfskbI6ya/2zG0gZnTYoZqbYZY2YglG4sDCj4giEAGHJe6rbI1DUerwHuOfPHTonblkgfPwjvj0LL5HJdDZD9iFeYb8idKQiyOKCHmSvn18Jr4YAQLdyDexlKYZbNvGi6FOsCFegBbDusa/pcDN8/kTREal+veOniPXMEKNd0JdDUuiB3pX5AJsteJ8DIFTKD0/GCZsx9dHsaLVJ5E/KT0O0YAEfebClB7rVsR7gDFYJ0TpvlIhm7/GN/I7oVLNYST1RfXpRcKIsVmLL2UTO6NdwaC7pGAJPSFah0cl/MbfeJva734yN1U1rsXS3/Vhxp3GzXU1IKWHhk5rxLpA0aJTNrD6mvQ6b6j5SQ+0PAcFQmTMvwq2DAOqqrQlDJLz8TNhnMHK/iVAeWOqkby/RmDLHVo8Fw4rZKJbIr5m0mSi+UWWB8VRZHF+JKr4mcnW+5GrccX8v0Dhi7CllhLftmVMDIUND1NXQF//tox0iQbCKXCXvPodBcK69fu3A2qJqbAZN9AG783zQvbRam59lncAZSQfzPpReYz69lwPW7GG1akgz5a96nEWF3sLCUUy2pEqhLpkK6hRYqztOj5IKZL0Ioir3m+Td2gGOqTWYfINICvxOvU4O8SRV3rxG2tRC0A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a472dac1-7088-44a9-7581-08dc348f3f2c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB10073.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 16:48:22.5892 (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: EGL7zHJ88z0FVpVbGEoUcYjqZqVHoBvBqiVBu2gN9SMzBaVk8/eEIEaGFzcx5eG86sMe/wjxBoB15Ld3LW6xcpEZt2RVHaBkm5U4U2RicMA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8479 Split bt_bap_stream_new and two specific functions for unicast and broadcast. Add a function to find an remote endpoint for broadcast source. --- src/shared/bap.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ src/shared/bap.h | 6 ++++ 2 files changed, 98 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index 0a336fc01..0931c8fa2 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -5043,6 +5043,16 @@ static bool find_ep_pacs(const void *data, const void *user_data) return false; } +static bool find_ep_source(const void *data, const void *user_data) +{ + const struct bt_bap_endpoint *ep = data; + + if (ep->dir == BT_BAP_BCAST_SINK) + return true; + else + return false; +} + unsigned int bt_bap_stream_config(struct bt_bap_stream *stream, struct bt_bap_qos *qos, struct iovec *data, @@ -5153,6 +5163,88 @@ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, return 0; } +struct bt_bap_stream *bt_bap_stream_bcast_new(struct bt_bap *bap, + struct bt_bap_pac *lpac, + struct bt_bap_pac *rpac, + struct bt_bap_qos *pqos, + struct iovec *data) +{ + struct bt_bap_stream *stream = NULL; + struct bt_bap_endpoint *ep = NULL; + struct match_pac match; + + if (!bap) + return NULL; + + if (!rpac && (lpac->type != BT_BAP_BCAST_SOURCE) + && queue_isempty(bap->remote_eps)) + return NULL; + + if (lpac && rpac) { + if ((rpac->type != BT_BAP_BCAST_SOURCE) + && (!bap_codec_equal(&lpac->codec, &rpac->codec))) + return NULL; + } else { + uint8_t type; + + match.lpac = lpac; + match.rpac = rpac; + memset(&match.codec, 0, sizeof(match.codec)); + + if (rpac) + type = rpac->type; + else if (lpac) { + switch (lpac->type) { + case BT_BAP_BCAST_SOURCE: + type = BT_BAP_BCAST_SINK; + break; + case BT_BAP_BCAST_SINK: + type = BT_BAP_BCAST_SOURCE; + break; + default: + return NULL; + } + } else + return NULL; + + bt_bap_foreach_pac(bap, type, match_pac, &match); + if ((!match.lpac) || (!lpac)) + return NULL; + if (!match.rpac && (lpac->type != BT_BAP_BCAST_SOURCE)) + return NULL; + + lpac = match.lpac; + rpac = match.rpac; + } + + match.lpac = lpac; + match.rpac = rpac; + + if (lpac->type != BT_BAP_BCAST_SOURCE) { + /* Check for existing stream */ + ep = queue_find(bap->remote_eps, find_ep_pacs, &match); + if (!ep) { + /* Check for unused ASE */ + ep = queue_find(bap->remote_eps, find_ep_unused, + &match); + if (!ep) { + DBG(bap, "Unable to find unused ASE"); + return NULL; + } + } + stream = ep->stream; + } else { + ep = queue_find(bap->remote_eps, find_ep_source, NULL); + if (!ep) + return NULL; + } + + if (!stream) + stream = bap_stream_new(bap, ep, lpac, rpac, data, true); + + return stream; +} + struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, diff --git a/src/shared/bap.h b/src/shared/bap.h index 2c3550921..fa0d4b524 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -244,6 +244,12 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, struct bt_bap_qos *pqos, struct iovec *data); +struct bt_bap_stream *bt_bap_stream_bcast_new(struct bt_bap *bap, + struct bt_bap_pac *lpac, + struct bt_bap_pac *rpac, + struct bt_bap_qos *pqos, + struct iovec *data); + struct bt_bap *bt_bap_stream_get_session(struct bt_bap_stream *stream); uint8_t bt_bap_stream_get_state(struct bt_bap_stream *stream); From patchwork Fri Feb 23 16:48:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 775598 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2060.outbound.protection.outlook.com [40.107.241.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56AF5129A76 for ; Fri, 23 Feb 2024 16:48:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708706910; cv=fail; b=EM/wPI/Ru1dHsbBexLRh5rNgd0AJHYEiT9pqA2MZZHjBwz27GvU3vHcJ3JiobO4KpU2qD8wfUdA2FSFvuQb87u1p9Y4NYYjZEU61T7114AH2tpsJ+LwFC9vzSgsXybym2ZmFNtFkUg0JupM/1zdKKXsDRf5Bq2/NDiw7mS9vHi8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708706910; c=relaxed/simple; bh=XeHNuvswBO9BhPanb6sn0ZRu4A7hde785ea2R4I7kMI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Cf8hoBztGG7MCYtzbd94GTH69h5jxFMyzRQ0o8CAZMi5jJZQG+2PqbU0IL4dK+F6v5DV/FvrCallANLBOtxX7kjFC3C3ir9uXnvfrlakG3KVrVRPnWkfXHFMhn9C+Fp/2WAyXvssnrKQsWwH6zYyGNZJ4fO/P7Xhej/TQVa4oLA= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=JRhSZ+zp; arc=fail smtp.client-ip=40.107.241.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="JRhSZ+zp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZBR+1RTGzDPjlgUAIbcbxe2euKqBZbH28j4TZK8+TC+Ld3JHrrWQ/5TN7KbWOYNgdpd5Y+PCorzCQz8K7oeJmKGZs/uB0Pl8jlEY7ZcYbwQCtKzeNzDhro9QfcjRS/CGn89raKnBTXic05Ge3fYKDptaNCpFY5Lev/f0l7edbOGt8oAinVZtvUHY4uo7zyCoe/J8roP9btZoEGLaAI3SNM7C9Y9PAbKMG+E6nc92xBr/BP1YQDBte389AWu431QltGUBMdCeaQI1pmJZHXHzKeE+h6tMUZRDSpb086fyky/u9pBq/lUHn8RjOHRq8cHAVL4yQwcYOE+2CNmTWY76DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=DCKP+nCk9WoQw0qWqjUAHr1oOzpTiWvzmHHUdw+qX/o=; b=PQs6WJ40MWDat2XtJWAG0dJmlMvFEtxlTyphEC6Hhl+rt4GvuGbN/IQvuP+afON9y8skQpuciJx/7rPKyIsiYf2uO7hpzBNrodAo13atIAx9aBv5ICLWlu+SbrjI+8daWLrUoq5ow2qJuqEWKmYXsPY6xjd1TToWRljbcM5h2zPCkVH2sKB/x0X3VAkEByix5gx33aMM9kaoLlp0cFmppiFER3CH8GXirxpE1Lp+1mEpTQkWQD7RbsMMDMRjCX+xsIgfRSooHXKAZsTcdGZr7Rk+WV2zPgl+hYctJPoA7vAZJ6w7fNiCUQ3JFetSAwWAYWsHOEduc6hT76MFC1Su3A== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DCKP+nCk9WoQw0qWqjUAHr1oOzpTiWvzmHHUdw+qX/o=; b=JRhSZ+zpYCC0HuXAZ7iAQ5HtbB5V/Qjj5x5KTYTzB+qttJ5htHDGbgEv+fgYxIlLfZEL9mZR4ja2ay6mDZns7j30tOYuU8YSM1wSJ/x5sJ6t2niq0sFeVgttG4efSuDQt0VkR+yIQ/pxQ6kLPR1A+/ziKL4av+pfNHHkO/hIdlc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) by DB9PR04MB8479.eurprd04.prod.outlook.com (2603:10a6:10:2c5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 16:48:24 +0000 Received: from VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81]) by VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81%7]) with mapi id 15.20.7316.023; Fri, 23 Feb 2024 16:48:24 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, iulia.tanasescu@nxp.com Subject: [PATCH BlueZ v4 4/5] bap: Add a callback to create a new stream Date: Fri, 23 Feb 2024 18:48:12 +0200 Message-Id: <20240223164813.66484-5-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223164813.66484-1-silviu.barbulescu@nxp.com> References: <20240223164813.66484-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: AS4P195CA0013.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:5e2::16) To VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) 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: VI1PR04MB10073:EE_|DB9PR04MB8479:EE_ X-MS-Office365-Filtering-Correlation-Id: a26f72d1-82d4-4c83-f722-08dc348f4058 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uFwbOy6zAs4SM0oCFBE5Zyz3/3XCIxT6vsKyC4DqRp9pRVO2hDDoSXxkhPW/ej+jumetCGzsoGqZaDTL870P+i+bXAcYwzKey5Za5kuBJgfH8YvJMR/aA9mdDZ0ruvxCslvdWhUTfxHBqgJJOQBcw6vkyNF8DtulD7xGl1cCsI9xWBhfl2QmukEh7bBEXR+fJKKfRS3l4tbbh0dUwFGqQ1u5d/v07r8xlxQ9LrVAIcL8cSxf9daywZXM5nAtbeP5M8G5wuZ4AcWj1e2Q1tE/PHEMZG80R2/E+EQMO2/mmYcgn6WPlGV447laox0UzFJD8mE8P0nA+SfgywDACy0vQKYxGghqgiaycRlv39TAAcIubgBfmwek4QC/+tAz9HKvIPba+nojpbgGxqv3fMst6KjedbLcctTseKEQa2IcyJ9cYlqZ3n9vot8fk9+He6MJpsufFhHeiQ8QLQkIPxeDqFeliDET8wwlEIjb2Zls97W9H1JF++P5KhbN6aK/z5Hpf6fDgYUbMF8SW/FLPZ6u533x99lvjRSWj6ymRWQZOF8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB10073.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ePsUqpZ3nao/2rvY5jp8v7uRfrzjmrl/I+L9IfJ4+T9yX+Ie3oU3EtgoUxp2TN16kfLlZx9x6MMLyPkq6pR0ESQXCO5wmqmOk6tq4WHoDcM9RBDaGfWUASUgImpQp03zYSGufkSnWewIM+JsnihhkIgGgiMlDtxbYxtAgLKAOrBzPmlf++0yB0gBN4b2Fa/akbYDfARLeKK4Iu491UTkDUS4K9W6CAigwFwbZG0WHUC6GDp/EtIvVMuUYdUtD11UEI0gVr/H/2+WcurLVJTWIx68Vt7VXSkp6j0O/G3nwSYkcav7ZNx5bWjGR7482mwQNj5edyGc4TL2IiGcZR7wH/Et0XmBlvHjFcR39kh2l+s0MaW7ACm64mySFUoYCWqzMjnypd9dtNKvl7w/aOjZe6md3lAC8RWxOpWmiuph+rIZfbyJ1tockl71sV3ADG2hkexFFeLcoH1ebr6Ia6QfEJ0zaDoaSpo13hhQoPJS3gBDMZw1sskS9+3T3qNVMrctYL/vrHhH0x8QMOMu+HDsE494VzA1hLzmQ8ac9FsL/haqRXfXiLJlEfuGdnGrqxUsYFizAOH+dryj82cZI8lXdgpZiC8B9fWSdVezf0uBQ++XV8GyOmtTlHcsDTXnJrOuuiLLANfRhcmhMyBFLvw0/ly0ngYd/zCHDW67hH0UD6PFQ54Yw5+HbB4/q35zVVEeEjd8ITotuL2fmCUqp2OTMfmK2pRJoHWWMkXQlbZ9SvV+IWGjo5OlGpt3UE4nISyIRyRSKsa0HTw5TAB+ivP1v/N/M85b/n6a/zFBR6/iru+6OZU32DiuOXgYFfjzLgGDxfwN9H4Xi8vY/pNZc01byxBMxgRWFyPQpy2nm9FGAeOif3SvL1L2Oo+06nUF9WqQcA3mnRDxskqgi6/yrC8LbK8PwNRUgmUh4NHEjlUen5Luj7VXzQOfvFagbrwZM9SasL2TV9Lqlnf62xsZ+aNrJPGCqEVZ3Ws/+8NShe8grrhCRufjaN2Jv0WiqMBFTGeO2Mwvzet3MpnyKuxJScuistKpeUwL7dJxlQSfAqJpeCiXMP15ZeuzrDwW0cMaP0+IrO+ijKgodQipwcnhuJpi9f4cKuO/kXXg4H5AxMwlhaFeI3rGN8f5z1rMGMXRz+s1FYL6GCAuR+8zqIHqkM4wB4TeH9Id++SwUZZojw8Ct5LbZCv/5RNZnljVsikXa7l+5aIG8+nleneyW0lRJKJCshbTBqzHjqTSJAPkgSgiqXxh+SIZycSj0wx2BcnlOWJjjQWtKGSYOCS19ZC5SevSVUgpdYS4FGRndjq02A3WItEtYSwjMNYc9RLzP/aobYmpO9N/uGdX4Tp2OoD79NPEaoZ8rG+1FLzIMFXOf2j8GPSy7754kAGyQKsGMxDEHsVrFXclk4VjWqVjRLzdKOyPPUnLMmg8TMUY9B2hpcoDxucFdcj+y8n6XsOSOpxls2AYjSsQqB0LjBn39DnzQ/WqPDRfZOJ6bws2UeMBRvPKPBEwGF72uxcf4aJsZOZbTo0OkbfoUW2Q+BMHL5iDiOUDdQIRLGftTjT82xWPXxyolwoeKQAvvzrSYJquwT+TeqIPn8991UbUgvxo7PsVmCrk2g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a26f72d1-82d4-4c83-f722-08dc348f4058 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB10073.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 16:48:24.5482 (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: DQGC4FDGANS+27RseZ17yd0BsROEXa2qo2xWFbIGamXOVGpxVSYSk2WMAwCo1du6oaHtsN6LwUnn5+DDQVvZqKDVuoV/tRJLfvvjqADLdgs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8479 Add a callback to create a new stream --- profiles/audio/bap.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index b4acdd9ef..2c7daa6d4 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -68,6 +68,11 @@ struct bap_setup { struct bt_bap_qos qos; int (*qos_parser)(struct bap_setup *setup, const char *key, int var, DBusMessageIter *iter); + struct bt_bap_stream* (*stream_new)(struct bt_bap *bap, + struct bt_bap_pac *lpac, + struct bt_bap_pac *rpac, + struct bt_bap_qos *pqos, + struct iovec *data); GIOChannel *io; unsigned int io_id; bool recreate; @@ -888,11 +893,13 @@ static struct bap_setup *setup_new(struct bap_ep *ep) setup->qos.bcast.bis = BT_ISO_QOS_BIS_UNSET; setup->qos_parser = setup_parse_bcast_qos; setup->destroy = setup_bcast_destroy; + setup->stream_new = bt_bap_stream_bcast_new; } else { /* Mark CIG and CIS to be auto assigned */ setup->qos.ucast.cig_id = BT_ISO_QOS_CIG_UNSET; setup->qos.ucast.cis_id = BT_ISO_QOS_CIS_UNSET; setup->qos_parser = setup_parse_ucast_qos; + setup->stream_new = bt_bap_stream_new; } if (!ep->setups) @@ -954,7 +961,7 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return btd_error_invalid_args(msg); } - setup->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, ep->rpac, + setup->stream = setup->stream_new(ep->data->bap, ep->lpac, ep->rpac, &setup->qos, setup->caps); setup->id = bt_bap_stream_config(setup->stream, &setup->qos, @@ -1290,7 +1297,7 @@ static void setup_config(void *data, void *user_data) * and PHY. */ if (!setup->stream) - setup->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, + setup->stream = setup->stream_new(ep->data->bap, ep->lpac, ep->rpac, &setup->qos, setup->caps); From patchwork Fri Feb 23 16:48:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 775306 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2060.outbound.protection.outlook.com [40.107.241.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7792912A165 for ; Fri, 23 Feb 2024 16:48:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708706912; cv=fail; b=H38eqvS9wtFHiOVzUH7ieb0uAmZtL5K7YVEVme3ZYYV3HQ2EbXWl048kj9Dnjck4RrTya4CPYVonByYjafkymOQ8k5uQGkGY8Q1etWXET565B5D61E8JoEum8xA0e5jTc10x2kUhq1xqm1l7RbYW2EVvZJRKRgnW1Df2Elkt/8s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708706912; c=relaxed/simple; bh=6cAgCzQZXJJrFUW+5N96GJzk39C2NNuQLps5t31aFGY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=lykN02jbZ4R0/FrtBhsL+LTme0K1I+pb3LM9IRMLbYSFwCe6MT3UKhwmxlweQWbMtC94RFRqF5LLBJ2ckd0yJwO3lGdSakkCOpAXcAC/+qpOmtv8vcHUDPjj4xYNA+w+XBlxtmm0nPGwiwpH5l5Hw/Lw3qXDmYO1AmIUN2+kykQ= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=KLldnGZG; arc=fail smtp.client-ip=40.107.241.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="KLldnGZG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DW49u1ZGw1G9B1un5FwIp/OkJKYekbks3Ylb4ofa4S5f9o1qKh6IFpXvpai3nAUyHbHgV/4Au5Gxeee7rqFlG54YGOTGJTRCAmC5HrtKhp3XqQXVNECPKZHeuK2yjl4lBREA2/SoE6wDAtT5brnpKbP88J2qTgLD2ycKteHEbxmefvyPpJpOaiwDr3nymiwQwuZ86lOvtSBYCiZnUgdMNeRZu06yVGIVnpmhzZ7CAnt+Qdj8Cujr6n4uC8zJIABvb70iTrA7eDmi1gcflqdt6M5l2wYeMyeecXVa6tBDYoJ7V1ymcI2AvlPHoo+uFxn0xTz2FyxC8HqYzAnbv19/tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=EFclAjxT4PeTaR/tuvwh4CBCCPBRA8PjnH8r5D+525Y=; b=NsspZvmcvLyLisXo3E1Jeh31JLR6SJSIjcpEBBrb79e6QB27sF3iP5HvFg3DJpCR5PlGdH+a/sujQuTpB6I+EXWwCXM7sVlHUmsLxPppopyUJq6AFU1cLZhe0E5DBaEh+j/IX8xzetAn+QwRtLzrpWplOmp+unqzrEBvOVjhwadoGSO7fF4N3XXXV2kSb8Y5MO3BUddm3bZ3rOZ3P5ugtspIVr7oZKHAHHjzTC+bWUP8c4fZUfNemuBwEFEUL4ISWrFhpWh0Am5XDY3w5VvBpDGp58jfl4jGyLFD7oapnbRL6p78+rRXO41/LIhm5KULLhStH7ww9PwG+QKwn+yz0g== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EFclAjxT4PeTaR/tuvwh4CBCCPBRA8PjnH8r5D+525Y=; b=KLldnGZGP2fYPpW0XCX6iAV+CyWueQADhY/fu4VlfjOe/3IntujH+SIi+pdjK5CTz0DEakaUAvIX46rGqLJuQxQ7BVhI24s97Fwa/z82s7VfGc5JzXvbCn5jrzTKvB8SVt6KfCVTaY/dBrOwTZoHE8CZYDbwdD1DxuTkZ+JH69w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) by DB9PR04MB8479.eurprd04.prod.outlook.com (2603:10a6:10:2c5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 16:48:26 +0000 Received: from VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81]) by VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81%7]) with mapi id 15.20.7316.023; Fri, 23 Feb 2024 16:48:26 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, iulia.tanasescu@nxp.com Subject: [PATCH BlueZ v4 5/5] bap: Set generated BASE on all setups from the same BIG Date: Fri, 23 Feb 2024 18:48:13 +0200 Message-Id: <20240223164813.66484-6-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223164813.66484-1-silviu.barbulescu@nxp.com> References: <20240223164813.66484-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: AS4P191CA0030.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d9::16) To VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) 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: VI1PR04MB10073:EE_|DB9PR04MB8479:EE_ X-MS-Office365-Filtering-Correlation-Id: 549dd00b-e1e7-41c9-0f8c-08dc348f4190 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YXMoVpx+qspCNtHp7THiMHJkQoKTzOuT0EYwGIMCW6M9ArHz8pcxtm2PBemcKtTSQfkvQoFTo6V7cfGBfLaAcGs/pz9fpxlDKq9OXOkaSzDkL/6mPfGoaKWzS5uEQfZB7vCej3fjP0eaunHM4VrjS1ONgzX7naKq6sLFLg1p1GJThwsQ4NBMkNEDVFw5XE9fQzANV4UpI9116JaA6OHitRBLiBmoc7zuJPPTwAdMUGindqPloslcQR0EM4zRHVEg+nMiOkpejuDqpnYI7WCocehMtbKjIXVToMdFEKcs0RFMwLZchUA6vgo5nxv7EdJivuvbgRMcwVHhoymJG2lDXFgQNjieTM+O5vgxcRQ3QcORig9fM4CWyaz+SyRRx3ZvzW7gQNB9AyWv2n8vwYAe3DwVgCwYWt2r93GQFoLEqUIzTxYWXvaFT/t/gh2rqVWRyaYZhfLYG+JFqHWcngOJQyUs3sUncNXo+kC7fwZLQI5w7AMe5VfCFLviFmacQ6ktb34+TwM8/X6MjAA9RU5uLXeJDIqqO21Xzrk+ZQH/Zfc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB10073.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZWLA5AiCF/VeBwlbsGuX0vp/Ym/o7430rFEbBrTMzEjaKEbU+8khO7SFdf+/+sXc4LiRNibYfb1kUyK/dwJY1Gdk9nwUS9b52dcjCmVMrrizJ0DV65CMScI57vk5rPd6/e0zQjHrAySEBBUYs0oGC/DHVKpDYMvTaW9Wm/RaCjbMs0d09g0LXSKEYg8RBPqMBzRBE/TSaCeEKLOV1GMBTbWGAAFZ1hP1uQmEXLOqerLnmn15k67VzYZH+i4HCc4QrgSetOyWAQHPqVuG37XIDmWRtqInxZvuYRmnJE05Jkd/U35Tljn7Qv5woT1t7PcM/PJZR3/Uu+lC1EZOp3aXraFASb7iWq+VAjvVAVqJNTuXadqozCIMkuWvyvAp+jXM91afqbOug3PAVZAPwkV1vYFnbLWjOMWvy9eQRqi5wT9xSuOoFgDqL7PaDhlQzrHo2SxREDIEo9iN6o9kKIISrYFOH7PDHq9S4c4Qaa4omSrDnmXqCrNlMpkEVyZT8KCck/RKoIjgpEYNXLo8DypkOqxEfd6VfuA182TE2JSjR+0SiusiVjdcXCcnFNrQjZi5Vd/Uq8OBIVAQKn+TqAU/8lG/m0QuUCvYAASThn2mj6BApkdSH2EaHPfGrS24/CwtrHlEmGqWIuG3la2GH2D38BQV3ftCEPHjU64cg1SfMFgi7iz9NUTxN6c/6SKbqYvUpUOVpTa8qCXJqxmReOHcg1O6D4JfTc7fypDv4bMevZvUrnhAckR2etWmx37XvBa1D8qu/10Xfq7PJZhb0rWABWQMYgKvzVFBzt817vjCSNXtOKv/0Zba/urxqpSlNl7tL6b9Cg0sExVObg+5guceuLLhbNjg3JOkgJz/HJ53SNzoetREW72b+y7jm4Ci8QmSqR50/W5ESNuEd7Rk55N0QiFiO5bdSEC+AuQynHhoe4fxiEuw4nRHohap9mjP+A+EM+zvNN066esdCMSSqZuvxEKfgJfd+sWNvVQY51V19WO8RcvmAdsbOpEjPriaBaiw1Nd0vhY3h/9DTqht1qZc6ESfv3AQCwjFS5aLTm7F52JZx0BAcuT2byI/a8qchDEt4blfSQTAfN2zRNB3ODU/lqKUYONHghFaJI4Qmiw1RIHI1srUIy/ZbFjfj3is6SKoRFFrocunmV63GTTwkxJc6SxSOMl4GlSK/hPP/Xy/LIEByK1CYS0dRvEh4mhXooxaycRWta6Sy8O2rVzZSpDA6pLJ38pmQJBk+w8McagcgWZ0YGBsPJncSLEBQ+3pe2PHBVnab6W50aauCSdpsnU7sLKUUVmLwQ0+xoZwLHOhkeJqdTPYAfX9wKUqnQCPmwyi6cULOxG8eXNBxJWktVxZ/5lHBS5YyKkSGW+DemvDjZke7TYAk8LRbcKYNEa9p3dZf4/YkMAsYew+U9Na7DfR6LpUcYnFKXJaoLeQcEKklWzVWt41uGJqx0/tp7qU9R+ZflLV0vd2+wJ+xhSs/ek3ZQH4VbSW2AhNQaU/zRffVWmCEH2ZjkHZkEmMaxjHx/ftF0nXAaTETj9MBn6h2+VbC01dq66cBdTzNHkpH7QESBO5ZssI8xZPFh0Y/QWTJg69grLFwzY/O9pU2K3cafCQkA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 549dd00b-e1e7-41c9-0f8c-08dc348f4190 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB10073.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 16:48:26.5733 (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: EfGOapFwkxTBZI0DS/GYQBYCoDn9hbvpcSx4Nq78aUHBtAcna5B57G+xwMq5+40SaSjl9O3hErELymLTbbt4O+unikuOCeZLRSyPu3as/Us= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8479 Set the BASE generated in BlueZ on all setups from the same BIG, and use defer to inform the kernel when to create the BIG. --- profiles/audio/bap.c | 212 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 196 insertions(+), 16 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 2c7daa6d4..38577bcf3 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -950,8 +950,12 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, if (dbus_message_iter_get_arg_type(&props) != DBUS_TYPE_DICT_ENTRY) return btd_error_invalid_args(msg); - /* Disconnect IOs if connecting since QoS is going to be reconfigured */ - ep_close(ep); + /* Broadcast source supports multiple setups, each setup will be BIS + * and will be configured with the set_configuration command + * TO DO reconfiguration of a BIS. + */ + if (bt_bap_pac_get_type(ep->lpac) != BT_BAP_BCAST_SOURCE) + ep_close(ep); setup = setup_new(ep); @@ -987,7 +991,6 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) setup->msg = dbus_message_ref(msg); else { - setup->base = bt_bap_stream_get_base(setup->stream); setup->id = 0; } @@ -1853,7 +1856,7 @@ static void setup_connect_io(struct bap_data *data, struct bap_setup *setup, static void setup_connect_io_broadcast(struct bap_data *data, struct bap_setup *setup, struct bt_bap_stream *stream, - struct bt_iso_qos *qos) + struct bt_iso_qos *qos, int defer) { struct btd_adapter *adapter = data->user_data; GIOChannel *io = NULL; @@ -1890,7 +1893,7 @@ static void setup_connect_io_broadcast(struct bap_data *data, BT_IO_OPT_MODE, BT_IO_MODE_ISO, BT_IO_OPT_QOS, qos, BT_IO_OPT_BASE, &base, - BT_IO_OPT_DEFER_TIMEOUT, false, + BT_IO_OPT_DEFER_TIMEOUT, defer, BT_IO_OPT_INVALID); if (!io) { @@ -2019,9 +2022,6 @@ static void setup_create_bcast_io(struct bap_data *data, memset(&iso_qos, 0, sizeof(iso_qos)); - if (!defer) - goto done; - iso_qos.bcast.big = setup->qos.bcast.big; iso_qos.bcast.bis = setup->qos.bcast.bis; iso_qos.bcast.sync_factor = setup->qos.bcast.sync_factor; @@ -2038,9 +2038,10 @@ static void setup_create_bcast_io(struct bap_data *data, iso_qos.bcast.timeout = setup->qos.bcast.timeout; memcpy(&iso_qos.bcast.out, &setup->qos.bcast.io_qos, sizeof(struct bt_iso_io_qos)); -done: + if (bt_bap_pac_get_type(setup->ep->lpac) == BT_BAP_BCAST_SOURCE) - setup_connect_io_broadcast(data, setup, stream, &iso_qos); + setup_connect_io_broadcast(data, setup, stream, &iso_qos, + defer); else setup_listen_io_broadcast(data, setup, stream, &iso_qos); } @@ -2128,11 +2129,135 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, } } +/* This function will call setup_create_io on all BISes from a BIG. + * The defer parameter will be set on true on all but the last one. + * This is done to inform the kernel when to when to start the BIG. + */ +static bool create_io_bises(struct bap_setup *setup, + uint8_t nb_bises, struct bap_data *data) +{ + const struct queue_entry *entry; + struct bap_setup *ent_setup; + bool defer = true; + uint8_t active_bis_cnt = 1; + + for (entry = queue_get_entries(setup->ep->setups); + entry; entry = entry->next) { + ent_setup = entry->data; + + if (bt_bap_stream_get_qos(ent_setup->stream)->bcast.big != + bt_bap_stream_get_qos(setup->stream)->bcast.big) + continue; + + if (active_bis_cnt == nb_bises) + defer = false; + + setup_create_io(data, ent_setup, ent_setup->stream, defer); + if (!ent_setup->io) { + error("Unable to create io"); + goto fail; + } + + active_bis_cnt++; + } + + return true; + +fail: + /* Clear the io of the created sockets if one + * socket creation fails. + */ + for (entry = queue_get_entries(setup->ep->setups); + entry; entry = entry->next) { + ent_setup = entry->data; + + if (bt_bap_stream_get_qos(ent_setup->stream)->bcast.big != + bt_bap_stream_get_qos(setup->stream)->bcast.big) + continue; + + if (setup->io) + g_io_channel_unref(setup->io); + } + return false; +} + +static void iterate_setup_update_base(void *data, void *user_data) +{ + struct bap_setup *setup = data; + struct bap_setup *data_setup = user_data; + + if ((setup->stream != data_setup->stream) && + (setup->qos.bcast.big == data_setup->qos.bcast.big)) { + + if (setup->base) + util_iov_free(setup->base, 1); + + setup->base = util_iov_dup(data_setup->base, 1); + } +} + +/* Function checks the state of all streams in the same BIG + * as the parameter stream, so it can decide if any sockets need + * to be created. Returns he number of streams that need a socket + * from that BIG. + */ +static uint8_t get_streams_nb_by_state(struct bap_setup *setup) +{ + const struct queue_entry *entry; + struct bap_setup *ent_setup; + uint8_t stream_cnt = 0; + + if (setup->qos.bcast.big == BT_ISO_QOS_BIG_UNSET) + /* If BIG ID is unset this is a single BIS BIG. + * return 1 as create one socket only for this BIS + */ + return 1; + + for (entry = queue_get_entries(setup->ep->setups); + entry; entry = entry->next) { + ent_setup = entry->data; + + /* Skip the curent stream form testing */ + if (ent_setup == setup) { + stream_cnt++; + continue; + } + + /* Test only BISes for the same BIG */ + if (bt_bap_stream_get_qos(ent_setup->stream)->bcast.big != + bt_bap_stream_get_qos(setup->stream)->bcast.big) + continue; + + if (bt_bap_stream_get_state(ent_setup->stream) == + BT_BAP_STREAM_STATE_STREAMING) + /* If one stream in a multiple BIS BIG is in + * streaming state this means that just the current + * stream must have is socket created so return 1. + */ + return 1; + else if (bt_bap_stream_get_state(ent_setup->stream) != + BT_BAP_STREAM_STATE_CONFIG) + /* Not all streams form a BIG have received transport + * acquire, so wait for the other streams to. + */ + return 0; + + stream_cnt++; + } + + /* Return the number of streams for the BIG + * as all are ready to create sockets + */ + return stream_cnt; +} + static void bap_state_bcast(struct bt_bap_stream *stream, uint8_t old_state, uint8_t new_state, void *user_data) { struct bap_data *data = user_data; struct bap_setup *setup; + bool defer = false; + uint8_t nb_bises = 0; DBG("stream %p: %s(%u) -> %s(%u)", stream, bt_bap_stream_statestr(old_state), old_state, @@ -2153,14 +2278,69 @@ static void bap_state_bcast(struct bt_bap_stream *stream, uint8_t old_state, queue_remove(data->streams, stream); break; case BT_BAP_STREAM_STATE_CONFIG: - if (setup && !setup->id) { - setup_create_io(data, setup, stream, true); + if (!setup || setup->id) + break; + if (bt_bap_stream_io_dir(stream) == + BT_BAP_BCAST_SOURCE) { + /* If the stream is attached to a + * broadcast sink endpoint. + */ + setup_create_io(data, setup, stream, defer); if (!setup->io) { error("Unable to create io"); - if (old_state != BT_BAP_STREAM_STATE_RELEASING) - bt_bap_stream_release(stream, NULL, - NULL); - return; + if (old_state != + BT_BAP_STREAM_STATE_RELEASING) + bt_bap_stream_release(stream, + NULL, NULL); + } + } else { + /* If the stream attached to a broadcast + * source endpoint generate the base. + */ + if (setup->base == NULL) { + setup->base = bt_bap_stream_get_base( + setup->stream); + /* Set the generated BASE on all setups + * from the same BIG. + */ + queue_foreach(setup->ep->setups, + iterate_setup_update_base, setup); + } + /* The kernel has 2 requirements when handling + * multiple BIS connections for the same BIG: + * 1 - setup_create_io for all but the last BIS + * must be with defer true so we can inform the + * kernel when to start the BIG. + * 2 - The order in which the setup_create_io + * are called must be in the order of BIS + * indexes in BASE from first to last. + * To address this requirement we will call + * setup_create_io on all BISes only when all + * transport acquire have been received and will + * send it in the order of the BIS index + * from BASE. + */ + nb_bises = get_streams_nb_by_state(setup); + + if (nb_bises == 1) { + setup_create_io(data, setup, + stream, defer); + if (!setup->io) { + error("Unable to create io"); + if (old_state != + BT_BAP_STREAM_STATE_RELEASING) + bt_bap_stream_release(stream, + NULL, NULL); + } + break; + } else if (nb_bises == 0) + break; + + if (!create_io_bises(setup, nb_bises, data)) { + if (old_state != + BT_BAP_STREAM_STATE_RELEASING) + bt_bap_stream_release(stream, + NULL, NULL); } } break;