From patchwork Mon Feb 19 12:15:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 13562592 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2060.outbound.protection.outlook.com [40.107.20.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 5BA072D04B for ; Mon, 19 Feb 2024 12:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708344921; cv=fail; b=ajPPvoijrWOTHrV8P/Ljz+bg47FV8+8Ncc0QtA3LeP3IkGhvhB3MvMGVX9qUPtKa8HOSwe0Hxa96a6/H2AsywbwCSGcLfg5VHexKhYRkJxl5TJ+qZs8MHlqi+8AmOQbUJAEsGOVIzC77KW2lHiENtyEqXO3UKbjzZUU2fHn8G4c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708344921; c=relaxed/simple; bh=UcSKOeRUVuNBQYV/M3sgW3TBRLQFbsqeUJnPPqzwFNM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=IAQplB0FW3WKP5nsLfXKqZ06jvar32+4SlfjPPwlDxF3eqChnYRNCYB4Fzi3LUt6svQsZVnokLnB0lE//tNrhoeyoS2Mmoq0YJ5qqFxEMPxovn8dsM92xYhlhuxdjNNxpyj3w5Gm4q1vGmakVeW0KJGxctYeh29zMOvay2S0j5U= 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=O5PEULnB; arc=fail smtp.client-ip=40.107.20.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="O5PEULnB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UwAX7r72T1de2FMt5BVGC0j61TUyDYupv3v+1KA8MuIiITaQrLav91vKrjyX1Y51EERJtpjb7KXct+xqDgLvTBmhU+4p504BTOdOKlHECUVJGIE0Fyji78UaoiFVepoiJ+ZUQMxwXzAc/EZCjzgUPoPqUIo8UOe7CSylmVMrb8bD+QN8P3Oz3Uen+pXZPUuyb65oyXAC2DIcC8R6VPODzgjHnTVAgIKeEtXUIsQaH2cEdemaItV7pocZ2p0/y/ySgtA4sRqW8IgH1v2KFPfQNa9PkQ8MVd87lYDRAKuo0vY3S9S79XGIwo7Qw0qObt1EgufH0WSdx/kVuN73TAjgCg== 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=Eu/Y57aVkzLZAvngIF8NaTXxbDGglPoTNZIrv0D9lwk=; b=RJTYAnmIl1tkt4cYDw3rHOHihp2fQYJbUPkXTzASlQmRcroVXGW6PpRUeVUhXQqod7/ApTeuuo219w9o5foKzCkjEu5WmpZNr/CBwEQSJHQKtoSXmRoqK+7tnlrWJF78uVugY0DFIe67ftqOxAjT5zCo5gxAF5F6nLNewW7gYK7BPyho4iQ6tx2A+WnHJZVt7WPxDWVvkDwRj9aRg2DVbi9u9U9fdGL80yACyQgnjmHF/Wd4u9gANiXp6feJ+Se9Om22SgtEG+yNmvpzytvjKU//xjAzkPYl8x4MDtkwkTUOUz195icDQCB2fX+95kcDJeYyfN2HP1KTW0LpsqXV8g== 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=Eu/Y57aVkzLZAvngIF8NaTXxbDGglPoTNZIrv0D9lwk=; b=O5PEULnB+RRDmp8yZEnMxPCeLsjV9ULJSPmLdpRs+wDfod1pJi92yhlIi2HWhTsNCoX5cHRDDhcFtSXp9TvzN9Z7E8nHLQ5OPlgRGPuDug8zOOwTdC5dEVVaDn0boyuCFUTTRUG+t1gmNvYyNDfhZP3hD05UEdt/urVld4TahiA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by AS8PR04MB9141.eurprd04.prod.outlook.com (2603:10a6:20b:448::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.37; Mon, 19 Feb 2024 12:15:15 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::bbd0:4409:3f0e:afdd]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::bbd0:4409:3f0e:afdd%4]) with mapi id 15.20.7292.029; Mon, 19 Feb 2024 12:15:15 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ v3 1/4] shared/bap: Add API to convert BASE into bt_bap_base queue Date: Mon, 19 Feb 2024 14:15:06 +0200 Message-Id: <20240219121509.5702-2-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240219121509.5702-1-andrei.istodorescu@nxp.com> References: <20240219121509.5702-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AS4PR09CA0006.eurprd09.prod.outlook.com (2603:10a6:20b:5e0::16) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) 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: AM9PR04MB8938:EE_|AS8PR04MB9141:EE_ X-MS-Office365-Filtering-Correlation-Id: 827f75db-6c67-44b5-1c3a-08dc31446e3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pHsHaeNlVReGR8RhHI8OtrJlrER2xXEXYjcszKi8wMp/+65z7o3UHS8XKdB9ID6EqvhlZUvHmyj7MPsEUMIpbDB17PlION4rHeTNRELISLUFOTqTJJlFgJXk1dAJ5i5sb9WZeZPK1k7Y1EgEP5c+cX4CMMgioKc/MZsUH+BGBYGgBZIwfhFRSM//jSWr5YmfnwwYFVIJC4BY84LJdPASw66x34bnZRhZ/x8Q5bjL/Dm/4vahviea9RaqaH7BRSFTGa/sfbF0F83XZ9PJfXeujkiOF/fkp2lVKiq7nY6rHzmrEMbZs4iF4BZzGpkX3F2PTFjQjNt/d3mm2h7guWd/Be06abpLTQ7wDKXgizqNCdzDJgb4eTjWdGQOl8n6qsAI0y4gwvwhQs0bryTp/KiZ7roOAjDih69my5F4CQyb3XjwZYTyXSvFWVwvGQpn8Fm92L1ZDReiNakUBiwuJ0PaLoyQqk0tVQGckik8KfNCz3H/Q4rkDQs1ACEj6k7q5klB9Jh7lq+cl55VJUuDGonvOrJwPKQI4q1B23X9RKoUReY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8938.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: ReHpShcKkl1OLGTcqeyihTOzqhFOpAA5GznPbXL0Bk1qvL+9ivkVUHB6CqSv+o0KJ9ZFRiQ+SxDpzVEwFfxFQ29GFEj2lRSqCxP3S8W7nBWzj1k1dk1cFWgtcqqnAKXGijnXO6nq+WiFeba+mq0fNIWA/I9NhZ57qq+gyThyj7aRyaq2yQFG6sbE92fFbftLH2E61xh8riCF/Rjrcz5CortILpEp7KGq87du+wb9yw0kDsr6In2A1MNG4lxoeqoCtg3MdGpT41/2DTIA6n2XwYGItkzil0IEdNGvZ+LeR+KPP7gw6tHenHWkL8m1XZdsiEajjZ/dy2+qamKuqTsBpds+89482VlHPeipqw2j7IggBUvEscNk6X0e5SG6SNkybPAGVhP1CtSYnjQLW9bzJ/R74LQ2EmF10TUl4Cr4NS3sEYrxK3pjwdT0HRwZRu2QA2YkUFWyTYRW2Z/87lgWUumiDobyCjUwQe/WBg48FAcjHmgLW1Bugbx+dYH7s1yY+R2J+gRIAyeV4tqihgq5xAiqgk55J68xAI/LuzqE4md57MndpKgHgc+xFUBiISqyD4fA9zJJqc6Fj/kh4KLIfiKFTaDmAk/HcvqZ9z5nDz1N4voIf4gCYMIWY3w3YxAN7EUliXBl1CEphY911qbAzcxlPTkApzsPTrwqMCiRSLPixnt4w/8ZOLkKRy0VSTZOJ4udjelH76Pgft+c+IOtEC+6p1HTB5vwpzZAmCqe65myjKN0OYe+PBAjZZyJYIvbwhcwcPR6VONNnAUQ1k0LhgFUtNCdctmA0wYCI1i0G24pB0YzjNCajdj/iZs0xaYgZCZQVoADmp1zScm+Abmlo5+g4TacASKuXZ6gzLhHRP30On5oQBz/FR+w0Yjkq8APAYWi+nx9X49ELaWDwJEISK2Lwps4or2MSMlSP+bYzeTfFvQz1q1BoCkvPj7Ik17luIwI0EgjdwBmZbYUJlkeLG2aoSU0/pzKDyxK/g+lw+jxA7WHBwfl4iZz7teNd4a+iARqQ20D5Jvyoa+NNrLjXLKFTf5atPBiJKM2MtyAsrIEhX+Noacr7ud4J/0bTxLJOWDfkg8fOzGr8nR1st8sG/fg7XEiYpIvbg6EVsQ74zgJdWCKsAOUD0MKr3AFS7+VD3kFClswZqjRcvLb7q7oFn1c+2vT5o5qLof9EUeuJTj6BOTZLjFivD8Raz81ylcHxy6LyZgajpaDdmVQojwELsDuBAh7slEeX1wuN2HVqIPLWSGLShISA0nsTYDzoZ/4dgHAH2KcXmWHXvIcL6MhNY/QsIj9PpNZmil2Ec2qBOYw9hxLejcgtjiJjGPde6iRJCqoUF8grt0q78iIKUbdAZ1Rg2OAa0p2fwcLhRi9X6+to8iGX+KDLwmpqwhbdXk0/enlFVd3r3Ea+W73/z4mb8FLt6qGqxsjvCmz2ZPiWm5rtZtpQ7yjFVUEBKyX1B3s3/LHEDuP+lOrWRfvOVIHkj9vYftwr4sT4DcWPKsT3fZc3MnRvOc+4nPzqpLmgjkGtk15D/rWiBoESlYLzfO8fg8IYs3YWoeg1g4lWiXcTLQT4/vN/2Q27KzcDjTNEq4KhuZ3P6t63c4Px9Vst671lQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 827f75db-6c67-44b5-1c3a-08dc31446e3c X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2024 12:15:15.8035 (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: uspm6QW1sXCAgRnCPb6K1Ccux3LgMNqBPVaTlb/CQ8E8ghxSmr02CAGqZqEcR1E5SLOSe3GQtM1eVjO/UHF5uOP7lDCwOe0eASZQBfzn8Ek= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9141 Create public function to read the BASE bytes and populate a bt_bap_base structure for further processing. --- src/shared/bap.c | 250 ++++++++++++++++++++++++++++++++++++++++------- src/shared/bap.h | 27 +++++ 2 files changed, 244 insertions(+), 33 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 4cc81844f1be..f688e1ad53fb 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -282,26 +282,6 @@ struct bt_pacs_context { uint16_t src; } __packed; -struct bt_base { - uint8_t big_id; - uint32_t pres_delay; - uint8_t next_bis_index; - struct queue *subgroups; -}; - -struct bt_subgroup { - uint8_t index; - struct bt_bap_codec codec; - struct iovec *caps; - struct iovec *meta; - struct queue *bises; -}; - -struct bt_bis { - uint8_t index; - struct iovec *caps; -}; - /* Contains local bt_bap_db */ static struct queue *bap_db; static struct queue *bap_cbs; @@ -5765,7 +5745,7 @@ void bt_bap_update_bcast_source(struct bt_bap_pac *pac, static void destroy_base_bis(void *data) { - struct bt_bis *bis = data; + struct bt_bap_bis *bis = data; if (!bis) return; @@ -5778,7 +5758,7 @@ static void destroy_base_bis(void *data) static void generate_bis_base(void *data, void *user_data) { - struct bt_bis *bis = data; + struct bt_bap_bis *bis = data; struct iovec *base_iov = user_data; uint8_t cc_length = bis->caps->iov_len; @@ -5795,7 +5775,7 @@ static void generate_bis_base(void *data, void *user_data) static void generate_subgroup_base(void *data, void *user_data) { - struct bt_subgroup *sgrp = data; + struct bt_bap_subgroup *sgrp = data; struct iovec *base_iov = user_data; if (!util_iov_push_u8(base_iov, queue_length(sgrp->bises))) @@ -5833,7 +5813,7 @@ static void generate_subgroup_base(void *data, void *user_data) queue_foreach(sgrp->bises, generate_bis_base, base_iov); } -static struct iovec *generate_base(struct bt_base *base) +static struct iovec *generate_base(struct bt_bap_base *base) { struct iovec *base_iov = new0(struct iovec, 0x1); @@ -5852,10 +5832,10 @@ static struct iovec *generate_base(struct bt_base *base) return base_iov; } -static void add_new_bis(struct bt_subgroup *subgroup, +static void add_new_bis(struct bt_bap_subgroup *subgroup, uint8_t bis_index, struct iovec *caps) { - struct bt_bis *bis = new0(struct bt_bis, 1); + struct bt_bap_bis *bis = new0(struct bt_bap_bis, 1); bis->index = bis_index; @@ -5867,12 +5847,12 @@ static void add_new_bis(struct bt_subgroup *subgroup, queue_push_tail(subgroup->bises, bis); } -static void add_new_subgroup(struct bt_base *base, +static void add_new_subgroup(struct bt_bap_base *base, struct bt_bap_stream *stream) { struct bt_bap_pac *lpac = stream->lpac; - struct bt_subgroup *sgrp = new0( - struct bt_subgroup, 1); + struct bt_bap_subgroup *sgrp = new0( + struct bt_bap_subgroup, 1); uint16_t cid = 0; uint16_t vid = 0; @@ -6013,7 +5993,7 @@ static struct iovec *extract_diff_caps( static void set_base_subgroup(void *data, void *user_data) { struct bt_bap_stream *stream = data; - struct bt_base *base = user_data; + struct bt_bap_base *base = user_data; /* BIS specific codec capabilities */ struct iovec *bis_caps; @@ -6031,7 +6011,7 @@ static void set_base_subgroup(void *data, void *user_data) } else { /* Verify if a subgroup has the same metadata */ const struct queue_entry *entry; - struct bt_subgroup *subgroup = NULL; + struct bt_bap_subgroup *subgroup = NULL; bool same_meta = false; for (entry = queue_get_entries(base->subgroups); @@ -6065,7 +6045,7 @@ static void set_base_subgroup(void *data, void *user_data) static void destroy_base_subgroup(void *data) { - struct bt_subgroup *subgroup = data; + struct bt_bap_subgroup *subgroup = data; if (!subgroup) return; @@ -6087,7 +6067,7 @@ static void destroy_base_subgroup(void *data) */ struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream) { - struct bt_base base; + struct bt_bap_base base; struct iovec *base_iov; base.subgroups = queue_new(); @@ -6106,3 +6086,207 @@ struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream) return base_iov; } + +static void cleanup_bis(void *data) +{ + struct bt_bap_bis *bis = data; + + if (bis->caps) + util_iov_free(bis->caps, 1); +} + +static void cleanup_subgroup(struct bt_bap_subgroup *subgroup) +{ + if (!subgroup) + return; + + if (subgroup->meta) + util_iov_free(subgroup->meta, 1); + + if (subgroup->caps) + util_iov_free(subgroup->caps, 1); + + queue_destroy(subgroup->bises, cleanup_bis); + + if (subgroup) + free(subgroup); +} + +bool bt_bap_parse_base(struct bt_bap *bap, void *data, size_t len, + util_debug_func_t func, struct bt_bap_base *base) +{ + uint8_t num_subgroups; + uint8_t num_bis; + + struct iovec iov = { + .iov_base = data, + .iov_len = len, + }; + util_debug(func, NULL, "BASE len %ld", len); + if (!base) + return false; + + if (!util_iov_pull_le24(&iov, &base->pres_delay)) + return false; + util_debug(func, NULL, "PresentationDelay %d", base->pres_delay); + + if (!util_iov_pull_u8(&iov, &base->num_subgroups)) + return false; + util_debug(func, NULL, "NumSubgroups %d", base->num_subgroups); + num_subgroups = base->num_subgroups; + + for (int sg = 0; sg < num_subgroups; sg++) { + struct bt_bap_subgroup *sub_group = new0( + struct bt_bap_subgroup, 1); + uint8_t caps_len, metaLen; + uint8_t *hexstream; + + sub_group->subgroup_index = sg; + + util_debug(func, NULL, "Subgroup #%d", sg); + sub_group->bap = bap; + sub_group->bises = queue_new(); + + if (!util_iov_pull_u8(&iov, &num_bis)) { + cleanup_subgroup(sub_group); + goto fail; + } + util_debug(func, NULL, "NumBis %d", num_bis); + sub_group->num_bises = num_bis; + + memcpy(&sub_group->codec, util_iov_pull_mem(&iov, + sizeof(struct bt_bap_codec)), sizeof(struct bt_bap_codec)); + util_debug(func, NULL, "%s: ID %d CID 0x%2.2x VID 0x%2.2x", + "Codec", sub_group->codec.id, sub_group->codec.cid, + sub_group->codec.vid); + if (!util_iov_pull_u8(&iov, &caps_len)) { + cleanup_subgroup(sub_group); + goto fail; + } + + util_debug(func, NULL, "CC Len %d", caps_len); + + /* + * Copy the Codec Specific configurations from base + */ + sub_group->caps = new0(struct iovec, 1); + util_iov_memcpy(sub_group->caps, iov.iov_base, caps_len); + util_debug(func, NULL, "subgroup caps len %ld", + sub_group->caps->iov_len); + + for (int i = 0; caps_len > 1; i++) { + struct bt_ltv *ltv = util_iov_pull_mem(&iov, + sizeof(*ltv)); + uint8_t *caps; + + if (!ltv) { + util_debug(func, NULL, "Unable to parse %s", + "Capabilities"); + cleanup_subgroup(sub_group); + goto fail; + } + + util_debug(func, NULL, "%s #%u: len %u type %u", + "CC", i, ltv->len, ltv->type); + + caps = util_iov_pull_mem(&iov, ltv->len - 1); + if (!caps) { + util_debug(func, NULL, "Unable to parse %s", + "CC"); + cleanup_subgroup(sub_group); + goto fail; + } + util_hexdump(' ', caps, ltv->len - 1, func, NULL); + + caps_len -= (ltv->len + 1); + } + + if (!util_iov_pull_u8(&iov, &metaLen)) { + cleanup_subgroup(sub_group); + goto fail; + } + util_debug(func, NULL, "Metadata Len %d", metaLen); + + sub_group->meta = new0(struct iovec, 1); + sub_group->meta->iov_len = metaLen; + sub_group->meta->iov_base = iov.iov_base; + + hexstream = util_iov_pull_mem(&iov, metaLen); + if (!hexstream) { + cleanup_subgroup(sub_group); + goto fail; + } + util_hexdump(' ', hexstream, metaLen, func, NULL); + + for (int bis_sg = 0; bis_sg < sub_group->num_bises; bis_sg++) { + struct bt_bap_bis *bis; + uint8_t caps_len; + uint8_t crt_bis; + + if (!util_iov_pull_u8(&iov, &crt_bis)) { + cleanup_subgroup(sub_group); + goto fail; + } + util_debug(func, NULL, "BIS #%d", crt_bis); + + bis = new0(struct bt_bap_bis, 1); + bis->index = crt_bis; + + if (!util_iov_pull_u8(&iov, &caps_len)) { + cleanup_subgroup(sub_group); + goto fail; + } + util_debug(func, NULL, "CC Len %d", caps_len); + + bis->caps = new0(struct iovec, 1); + bis->caps->iov_len = caps_len; + util_iov_memcpy(bis->caps, iov.iov_base, caps_len); + util_debug(func, NULL, "bis caps len %ld", + bis->caps->iov_len); + + for (int i = 0; caps_len > 1; i++) { + struct bt_ltv *ltv = util_iov_pull_mem(&iov, + sizeof(*ltv)); + uint8_t *caps; + + if (!ltv) { + util_debug(func, NULL, "Unable to parse %s", + "Capabilities"); + cleanup_subgroup(sub_group); + goto fail; + } + + util_debug(func, NULL, "%s #%u: len %u type %u", + "CC", i, ltv->len, ltv->type); + + caps = util_iov_pull_mem(&iov, ltv->len - 1); + if (!caps) { + util_debug(func, NULL, + "Unable to parse %s", "CC"); + cleanup_subgroup(sub_group); + goto fail; + } + util_hexdump(' ', caps, ltv->len - 1, func, + NULL); + + caps_len -= (ltv->len + 1); + } + + queue_push_tail(sub_group->bises, bis); + } + + queue_push_tail(base->subgroups, sub_group); + } + return true; + +fail: + while (!queue_isempty(base->subgroups)) { + struct bt_bap_subgroup *subGroup = + queue_peek_head(base->subgroups); + cleanup_subgroup(subGroup); + base->num_subgroups--; + } + util_debug(func, NULL, "Unable to parse %s", "Base"); + + return false; +} diff --git a/src/shared/bap.h b/src/shared/bap.h index 2c3550921f07..b13fef688da3 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -98,6 +98,29 @@ struct bt_bap_qos { }; }; +struct bt_bap_base { + uint32_t pres_delay; + uint8_t big_id; + uint8_t num_subgroups; + uint8_t next_bis_index; + struct queue *subgroups; +}; + +struct bt_bap_subgroup { + uint8_t subgroup_index; + struct bt_bap *bap; + uint8_t num_bises; + struct bt_bap_codec codec; + struct iovec *caps; + struct iovec *meta; + struct queue *bises; +}; + +struct bt_bap_bis { + uint8_t index; + struct iovec *caps; +}; + typedef void (*bt_bap_ready_func_t)(struct bt_bap *bap, void *user_data); typedef void (*bt_bap_destroy_func_t)(void *user_data); typedef void (*bt_bap_debug_func_t)(const char *str, void *user_data); @@ -323,3 +346,7 @@ void bt_bap_update_bcast_source(struct bt_bap_pac *pac, bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac); struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream); + +bool bt_bap_parse_base(struct bt_bap *bap, void *data, size_t len, + util_debug_func_t func, struct bt_bap_base *base); + From patchwork Mon Feb 19 12:15:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 13562593 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2060.outbound.protection.outlook.com [40.107.20.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 EF2A82D05D for ; Mon, 19 Feb 2024 12:15:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708344924; cv=fail; b=INBXKCqqie/0sl5RQi3GV2O2CEPxVdOeBD8L9b/ZNupBBXwet71bNjY4l6+2V8BAxvKIrZ+wcVK+MVVZ6MgptWnH8jGopoTFWtxy3fk0Bwu68iioV9wIqfjvf31ApnQhskyP/x0Eja0lAuOKi7SW2QY8JNW4o2FfsmafBSuk2yM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708344924; c=relaxed/simple; bh=agQ2ziC2vfXf8irGj/zSeo9cWOKzQYf8M/krdZst8jc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=uEfUDBIRiQD8C5LPNaXKbZVZ4JHpCU/EbfZ2yB2iAUhVyg3nMriWOqmABhx/cTTGq5OmkKy1gGBdl9M+Crw2D6Jyk9jZZY8+KyeotLGz5swGLV8lMCjFNBG8ZqCC+EK7KCHiKHuZ4PBYEyJY70U4rpVddpb6MrXB80elfI+xiy4= 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=l50ET57d; arc=fail smtp.client-ip=40.107.20.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="l50ET57d" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Atmafpb2wyAxFeBUCOMHKG7iNsgEvOX5KV1k5Zen8D/XtlsYRO+dBkj1c97yedFOKqqRXnTHcZnVCJCmv7po04Y7QbQ77kJre88N/LHe54zZyd/MtbwbVondat6mi3xRuchguQ7GVV06DcuMrVDu8g6T771xALkmfM8EwQpL5PQoUpzFQbLxKWj7/9jD/nAANjNTW7am0krCMcgzGsV3XwrD5e828BW0IsdAkdlIoETW5oK3+NMzhB1puQK3+f+1P4MPXZdMoKHfXlrZYICEm5pQ60hiJa9GAFkK44r7jeYvAfxX1YO99lwfV47nozo00UbR13cfY8d8mRAAtqtFXg== 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=Lg++FzvjYN1134bTWbPZUK6VU8jHRQzAairVUbtJTvc=; b=VDltAIcMjhWxY0PsePF/r827blyB9v9QQhPfMlMABNEuNjFvQ+cH120QjmeKJ7yPjuWPFf2yZmMq8TkeZrECJ6eNhTZzraSlGehSzbPZWcAKBk0bWUNNiChq2ZQz/4T+psQ1z2EzguS5tkQrUqtvL90NrsH2p7iNn66H/iyFUk01EG4QH11nLVc7X3lizeZeIDQGGrEFzqIcqDX4J0/rKmRG8tdbCyX7ooLxH/5/6sAo5D68hrMmF+ENqjBonOSf4FF4KFwL9ZufF/9Xk4O5CdlzcWxcC845PPnMPgZTssrq0LgSJw1RRutYgdeL4vn8bRsRU0/WTUL0p+5nx9FB5Q== 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=Lg++FzvjYN1134bTWbPZUK6VU8jHRQzAairVUbtJTvc=; b=l50ET57dqcpe/UtMNGsmMbSuVyqRuTU2Hx4Ktgc/Awva9Po2RN2LOclpREEcKm/ERN/AM/YUiPVse7GA7fF57tg2sJph56+39TA31bmhrVmyhuqRFjMX2CeYkp27EZ8a1lgBQIADn8nUSqj2t/ZG4S/lX94qQSrKS4h/27iq3aQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by AS8PR04MB9141.eurprd04.prod.outlook.com (2603:10a6:20b:448::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.37; Mon, 19 Feb 2024 12:15:17 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::bbd0:4409:3f0e:afdd]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::bbd0:4409:3f0e:afdd%4]) with mapi id 15.20.7292.029; Mon, 19 Feb 2024 12:15:17 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ v3 2/4] shared/bap: Add API to convert parsed BASE into pac data Date: Mon, 19 Feb 2024 14:15:07 +0200 Message-Id: <20240219121509.5702-3-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240219121509.5702-1-andrei.istodorescu@nxp.com> References: <20240219121509.5702-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AM4PR07CA0025.eurprd07.prod.outlook.com (2603:10a6:205:1::38) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) 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: AM9PR04MB8938:EE_|AS8PR04MB9141:EE_ X-MS-Office365-Filtering-Correlation-Id: 94ab2a04-1d54-41ab-c206-08dc31446f1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ggHxbU55PfCYJFQJC2XB7DkTGHc/Nw1+8TpV/ANiPXuczSQQahIWfaG5NMHB59nyK0N7pz9YM+pyqsojrRftcauzN+W8QDHUAPKISNXNLj7Teafx5cs2dYQtwbgWtHZ3OHe46itDdbo9mDmJmnOdEwbWoaaXW8dgOQrzdy6mO226AcQfCze0fmTtSpNVbjWLoBiaLL/+VEvxLt5nK/0wc7MykHo+TvSRu8GAiWWLRMTtH+D0GR8L+mEAm0KNXbZNKdeJzYuqq0C4PNpJ2cmj6v3kwGtti+fkJoKsP4pDMtN2j+AYjgDKpHWRUh7IPB5PCGR6sZrbu+RjYmyssk3JtmgIEDOId7UGs1pXuOSrdV2KwO1TH3PzSKvTZ+1EKJyJXxgCcvLdB9VYXzFIPqTB+GNd4dXQZMT/gJfNnBZqRN3K4eh8zbotVxzVuJZ4JxRdc18zoxBBnj8EbXZ/sN8NofK2A5Kg7DL8+arroT9K3VlQjzwqjy0eyX5eeDlhji/mrek+Cq9qyb2t32YdRre/G/YAe5bcMDnalGQ7nBoS9rQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8938.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: 5e9/6Fq21sKNzbWHKnZTbkQdlkSW+Wx2lfj62pNrHso/txaLPSFIjchsHQSYhVUTg8Jms17o0tIkQXtnrNyrEOikhtoungHy/KkkRQs4YYdFR/NKSDJUCkXiKmO+zdui+aEcGUhmSvz6+e/PfqfBQK3Y8sX4JTAc2VQ1auPCY8yWjCsPlnWzHynh50ZPXtC445HYpodaj38bOViZcmiSmteUGRplv7jJoLUt26x7MioVUDO53yoaJMpwkzQkRULZK4+Ezet/ale2C1Knl3CRHb5EZzlGHvWhglGHFTFm7ivoJo2ZmO258tEVBlMSJUlF3apAzSjaB7U2G9FS78vJcFxxEACXRPsTMs8lKoorqVleisqFBaMho5DsOa2nDw3FkvGkw05//s3O932vDPQArCspGCnCCAyeqC0m/6pzOWJZAUQp4a3E5usQxrC5Vh/Nrq6FiN1L492Q7mKXJbOI9FcfkjD9hIP8AvVonsLV0DuvPlYjjUma7pEb0Ro4XghD/SQH8+27k3JkOuMe30jMw0zHA4uXeJRONS2ekz7Pttt3YVgWXv0A+/E9JRqTSh4b+9EGfA+1OBW0mYfiujer8gpWwbOupV9wsRuzSekwxBqyU4qsG7zocJH2HWZV6BCAQwVfuo9hUerkLtutXOr02jpr/k+1p7DShikd2YDiNn5QwIu5YUtMM/VtodN+KPLhfhmTEO7ne7XU9/dyt+dy7tNeECy1mA706CxMaQEWI9DZ/S0E2XPPp9xBKBGy4qcSvxTWu/Wa5a/oYkq9guG1IcKYJS1i/1xemLB/OzZatl676rcgHMmZTRW6yGobPnTc1OtiKIkcFkY08+BXfaKdWTqdQ/3DGP+FTuoiD2VZ0vLuJpLgFTSg0rkXXGifBOwXAGy6DZO966wKiJmlIdoSE5lnNdapOC5Tskl1v1/F7FqWMCyNHDDhAHmCecVVfqlmSRP7FV6o+FIT3MlREp/RZxCSDb0JHFcd/JF9MMMdItWXmlDtDvV12f+igcAtAKuTdTtgWxkLAlOn4Uk2IrFTLSVhVknRL4yrtakcZxRUvz9poExejsZrxpDmtw4atc7YMTj+a2+E4kGI1pDIEQFO5VqivfTpczQt8i2LZwUPFo6e4P57IGOPUGZbDLPi7rj9im3m7ttXbnp2SQzxuxhfsS+AfWJ93UzsAE7Bnjhliw+1BuAySVxJURSwmCbjk93h6GiXIYSxU43g0D4A+s4c6s7rntAFD63wajci1j3aGBvxYgiLBM3UlQfaNdVr27YAP8gyhSVuc0Vb4w/9/fIEMJfuuLLdOr4du6HCdoA9vfKRX3lCgkWEFnXCOUtkKoiZJFkqAox4VXaukiSg372a9ZDZZwBoJ0PEFCmAqnwpf1X1L5Bjt1yqj2fi4LZgYGYy3UwIdxwrm6XmniU2HlUMT9MeNw/m7eBOTC/7Y+8FE5yVVfQDt6Ffzbnj69w1JE2OndrG2dkdy64qlnKn5H5+/bl0cEJJR7str8DxvOK4exT6KqWHf9oeZkVmc8lj2BvZKk/m0uwy/lyxbJA/og+XRk7cTpbS7KNbQQ23PpL7bFhBp6g6bgwWeBgyavYEg02Grqx//b44h2YgXVvw4WgnYA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94ab2a04-1d54-41ab-c206-08dc31446f1a X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2024 12:15:17.3131 (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: KXA68mpjmoEkEh0DJlQYW9G7mddgeyBF4+tCk6TJ2ty57qaS8gYzFr8CK/Jq+zJ4ng+Lt7YnxNULxdMY5YsrtQz9X3YiQGafLIPScCykhic= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9141 Create one remote endpoint for each BIS present in the BASE which matches the local sink capabilities. Add API to get the PAC metadata and capabilities. --- src/shared/bap.c | 497 ++++++++++++++++++++++++++++++++++------------- src/shared/bap.h | 11 +- 2 files changed, 375 insertions(+), 133 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index f688e1ad53fb..c3d96c08fddc 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -48,6 +48,11 @@ #define BAP_PROCESS_TIMEOUT 10 +#define BAP_FREQ_LTV_TYPE 1 +#define BAP_DURATION_LTV_TYPE 2 +#define BAP_CHANNEL_ALLOCATION_LTV_TYPE 3 +#define BAP_FRAME_LEN_LTV_TYPE 4 + struct bt_bap_pac_changed { unsigned int id; bt_bap_pac_func_t added; @@ -3282,6 +3287,13 @@ static void bap_add_broadcast_source(struct bt_bap_pac *pac) static void bap_add_broadcast_sink(struct bt_bap_pac *pac) { queue_push_tail(pac->bdb->broadcast_sinks, pac); + + /* Update local PACS for broadcast sink also, when registering an + * endpoint + */ + pacs_add_sink_location(pac->bdb->pacs, pac->qos.location); + pacs_add_sink_supported_context(pac->bdb->pacs, + pac->qos.supported_context); } static void notify_pac_added(void *data, void *user_data) @@ -3433,6 +3445,16 @@ struct bt_bap_pac_qos *bt_bap_pac_get_qos(struct bt_bap_pac *pac) return &pac->qos; } +struct iovec *bt_bap_pac_get_data(struct bt_bap_pac *pac) +{ + return pac->data; +} + +struct iovec *bt_bap_pac_get_metadata(struct bt_bap_pac *pac) +{ + return pac->metadata; +} + uint8_t bt_bap_stream_get_type(struct bt_bap_stream *stream) { if (!stream) @@ -5872,8 +5894,9 @@ static void add_new_subgroup(struct bt_bap_base *base, struct bt_ltv_match { uint8_t l; - uint8_t *v; + void *data; bool found; + uint32_t data32; }; struct bt_ltv_search { @@ -5892,7 +5915,7 @@ static void match_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, if (ltv_match->l != l) return; - if (!memcmp(v, ltv_match->v, l)) + if (!memcmp(v, ltv_match->data, l)) ltv_match->found = true; } @@ -5904,7 +5927,7 @@ static void search_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, ltv_match.found = false; ltv_match.l = l; - ltv_match.v = v; + ltv_match.data = v; util_ltv_foreach(ltv_search->iov->iov_base, ltv_search->iov->iov_len, &t, @@ -5945,8 +5968,10 @@ static bool compare_ltv(struct iovec *iov1, } struct bt_ltv_extract { - struct iovec *result; struct iovec *src; + void *value; + uint8_t len; + struct iovec *result; }; static void extract_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, @@ -5958,7 +5983,7 @@ static void extract_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, ltv_match.found = false; ltv_match.l = l; - ltv_match.v = v; + ltv_match.data = v; /* Search each BIS caps ltv in subgroup caps * to extract the one that are BIS specific @@ -6112,12 +6137,16 @@ static void cleanup_subgroup(struct bt_bap_subgroup *subgroup) free(subgroup); } +static void print_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, + void *user_data) +{ + util_debug(user_data, NULL, "CC #%zu: l:%u t:%u", i, l, t); + util_hexdump(' ', v, l, user_data, NULL); +} + bool bt_bap_parse_base(struct bt_bap *bap, void *data, size_t len, util_debug_func_t func, struct bt_bap_base *base) { - uint8_t num_subgroups; - uint8_t num_bis; - struct iovec iov = { .iov_base = data, .iov_len = len, @@ -6132,161 +6161,369 @@ bool bt_bap_parse_base(struct bt_bap *bap, void *data, size_t len, if (!util_iov_pull_u8(&iov, &base->num_subgroups)) return false; - util_debug(func, NULL, "NumSubgroups %d", base->num_subgroups); - num_subgroups = base->num_subgroups; + util_debug(func, NULL, "Number of Subgroups: %d", base->num_subgroups); - for (int sg = 0; sg < num_subgroups; sg++) { - struct bt_bap_subgroup *sub_group = new0( + for (int idx = 0; idx < base->num_subgroups; idx++) { + struct bt_bap_subgroup *subgroup = new0( struct bt_bap_subgroup, 1); - uint8_t caps_len, metaLen; - uint8_t *hexstream; - sub_group->subgroup_index = sg; + subgroup->index = idx; - util_debug(func, NULL, "Subgroup #%d", sg); - sub_group->bap = bap; - sub_group->bises = queue_new(); + util_debug(func, NULL, "Subgroup #%d", idx); + subgroup->bap = bap; + subgroup->bises = queue_new(); - if (!util_iov_pull_u8(&iov, &num_bis)) { - cleanup_subgroup(sub_group); + if (!util_iov_pull_u8(&iov, &subgroup->num_bises)) goto fail; - } - util_debug(func, NULL, "NumBis %d", num_bis); - sub_group->num_bises = num_bis; - - memcpy(&sub_group->codec, util_iov_pull_mem(&iov, - sizeof(struct bt_bap_codec)), sizeof(struct bt_bap_codec)); - util_debug(func, NULL, "%s: ID %d CID 0x%2.2x VID 0x%2.2x", - "Codec", sub_group->codec.id, sub_group->codec.cid, - sub_group->codec.vid); - if (!util_iov_pull_u8(&iov, &caps_len)) { - cleanup_subgroup(sub_group); - goto fail; - } - util_debug(func, NULL, "CC Len %d", caps_len); + util_debug(func, NULL, "Number of BISes: %d", + subgroup->num_bises); - /* - * Copy the Codec Specific configurations from base - */ - sub_group->caps = new0(struct iovec, 1); - util_iov_memcpy(sub_group->caps, iov.iov_base, caps_len); - util_debug(func, NULL, "subgroup caps len %ld", - sub_group->caps->iov_len); - - for (int i = 0; caps_len > 1; i++) { - struct bt_ltv *ltv = util_iov_pull_mem(&iov, - sizeof(*ltv)); - uint8_t *caps; - - if (!ltv) { - util_debug(func, NULL, "Unable to parse %s", - "Capabilities"); - cleanup_subgroup(sub_group); - goto fail; - } + memcpy(&subgroup->codec, util_iov_pull_mem(&iov, + sizeof(struct bt_bap_codec)), + sizeof(struct bt_bap_codec)); + util_debug(func, NULL, "Codec: ID %d CID 0x%2.2x VID 0x%2.2x", + subgroup->codec.id, subgroup->codec.cid, + subgroup->codec.vid); - util_debug(func, NULL, "%s #%u: len %u type %u", - "CC", i, ltv->len, ltv->type); + /* BASE Level 2 */ + /* Read Codec Specific Configuration */ + subgroup->caps = new0(struct iovec, 1); + if (!util_iov_pull_u8(&iov, (void *)&subgroup->caps->iov_len)) + goto fail; - caps = util_iov_pull_mem(&iov, ltv->len - 1); - if (!caps) { - util_debug(func, NULL, "Unable to parse %s", - "CC"); - cleanup_subgroup(sub_group); - goto fail; - } - util_hexdump(' ', caps, ltv->len - 1, func, NULL); + util_iov_memcpy(subgroup->caps, + util_iov_pull_mem(&iov, + subgroup->caps->iov_len), + subgroup->caps->iov_len); - caps_len -= (ltv->len + 1); - } + /* Print Codec Specific Configuration */ + util_debug(func, NULL, "CC len: %ld", + subgroup->caps->iov_len); + util_ltv_foreach(subgroup->caps->iov_base, + subgroup->caps->iov_len, NULL, print_ltv, func); - if (!util_iov_pull_u8(&iov, &metaLen)) { - cleanup_subgroup(sub_group); + /* Read Metadata */ + subgroup->meta = new0(struct iovec, 1); + if (!util_iov_pull_u8(&iov, (void *)&subgroup->meta->iov_len)) goto fail; - } - util_debug(func, NULL, "Metadata Len %d", metaLen); - sub_group->meta = new0(struct iovec, 1); - sub_group->meta->iov_len = metaLen; - sub_group->meta->iov_base = iov.iov_base; + util_iov_memcpy(subgroup->meta, + util_iov_pull_mem(&iov, + subgroup->meta->iov_len), + subgroup->meta->iov_len); - hexstream = util_iov_pull_mem(&iov, metaLen); - if (!hexstream) { - cleanup_subgroup(sub_group); - goto fail; - } - util_hexdump(' ', hexstream, metaLen, func, NULL); + /* Print Metadata */ + util_debug(func, NULL, "Metadata len: %i", + (uint8_t)subgroup->meta->iov_len); + util_hexdump(' ', subgroup->meta->iov_base, + subgroup->meta->iov_len, func, NULL); - for (int bis_sg = 0; bis_sg < sub_group->num_bises; bis_sg++) { + /* BASE Level 3 */ + for (int bis_sg = 0; bis_sg < subgroup->num_bises; bis_sg++) { struct bt_bap_bis *bis; - uint8_t caps_len; - uint8_t crt_bis; - if (!util_iov_pull_u8(&iov, &crt_bis)) { - cleanup_subgroup(sub_group); + bis = new0(struct bt_bap_bis, 1); + if (!util_iov_pull_u8(&iov, &bis->index)) goto fail; - } - util_debug(func, NULL, "BIS #%d", crt_bis); - bis = new0(struct bt_bap_bis, 1); - bis->index = crt_bis; + util_debug(func, NULL, "BIS #%d", bis->index); - if (!util_iov_pull_u8(&iov, &caps_len)) { - cleanup_subgroup(sub_group); + /* Read Codec Specific Configuration */ + bis->caps = new0(struct iovec, 1); + if (!util_iov_pull_u8(&iov, + (void *)&bis->caps->iov_len)) goto fail; - } - util_debug(func, NULL, "CC Len %d", caps_len); - bis->caps = new0(struct iovec, 1); - bis->caps->iov_len = caps_len; - util_iov_memcpy(bis->caps, iov.iov_base, caps_len); - util_debug(func, NULL, "bis caps len %ld", + util_iov_memcpy(bis->caps, + util_iov_pull_mem(&iov, + bis->caps->iov_len), bis->caps->iov_len); - for (int i = 0; caps_len > 1; i++) { - struct bt_ltv *ltv = util_iov_pull_mem(&iov, - sizeof(*ltv)); - uint8_t *caps; - - if (!ltv) { - util_debug(func, NULL, "Unable to parse %s", - "Capabilities"); - cleanup_subgroup(sub_group); - goto fail; - } - - util_debug(func, NULL, "%s #%u: len %u type %u", - "CC", i, ltv->len, ltv->type); - - caps = util_iov_pull_mem(&iov, ltv->len - 1); - if (!caps) { - util_debug(func, NULL, - "Unable to parse %s", "CC"); - cleanup_subgroup(sub_group); - goto fail; - } - util_hexdump(' ', caps, ltv->len - 1, func, - NULL); - - caps_len -= (ltv->len + 1); - } + /* Print Codec Specific Configuration */ + util_debug(func, NULL, "CC Len: %d", + (uint8_t)bis->caps->iov_len); + util_ltv_foreach(bis->caps->iov_base, + bis->caps->iov_len, NULL, print_ltv, + func); - queue_push_tail(sub_group->bises, bis); + queue_push_tail(subgroup->bises, bis); } - queue_push_tail(base->subgroups, sub_group); + queue_push_tail(base->subgroups, subgroup); } return true; fail: - while (!queue_isempty(base->subgroups)) { - struct bt_bap_subgroup *subGroup = - queue_peek_head(base->subgroups); - cleanup_subgroup(subGroup); - base->num_subgroups--; - } util_debug(func, NULL, "Unable to parse %s", "Base"); return false; } + +static void bap_sink_get_allocation(size_t i, uint8_t l, uint8_t t, + uint8_t *v, void *user_data) +{ + uint32_t location32; + + if (!v) + return; + + memcpy(&location32, v, l); + *((uint32_t *)user_data) = le32_to_cpu(location32); +} + +/* + * This function compares PAC Codec Specific Capabilities, with the Codec + * Specific Configuration LTVs received in the BASE of the BAP Source. The + * result is accumulated in data32 which is a bitmask of types. + */ +static void check_pac_caps_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, + void *user_data) +{ + struct bt_ltv_match *compare_data = user_data; + uint8_t *bis_v = compare_data->data; + + switch (t) { + case BAP_FREQ_LTV_TYPE: + { + uint16_t mask = *((uint16_t *)v); + + mask = le16_to_cpu(mask); + if (mask & (1 << (bis_v[0] - 1))) + compare_data->data32 |= 1<data32 |= 1<= min) && + (frame_len <= max)) + compare_data->data32 |= 1<data; + struct bt_ltv_match compare_data; + + compare_data.data = v; + + /* Search inside local PAC's caps for LTV of type t */ + util_ltv_foreach(pac_caps->iov_base, pac_caps->iov_len, &t, + check_pac_caps_ltv, &compare_data); + + local_data->data32 |= compare_data.data32; +} + +static void bap_sink_check_level3_ltv(size_t i, uint8_t l, uint8_t t, + uint8_t *v, void *user_data) +{ + struct bt_ltv_extract *merge_data = user_data; + + merge_data->value = v; + merge_data->len = l; +} + +static void bap_push_ltv(struct iovec *output, uint8_t l, uint8_t t, void *v) +{ + l++; + iov_append(output, 1, &l); + iov_append(output, 1, &t); + iov_append(output, l - 1, v); +} + +static void bap_sink_check_level2_ltv(size_t i, uint8_t l, uint8_t t, + uint8_t *v, void *user_data) +{ + struct bt_ltv_extract *merge_data = user_data; + + merge_data->value = NULL; + util_ltv_foreach(merge_data->src->iov_base, + merge_data->src->iov_len, + &t, + bap_sink_check_level3_ltv, user_data); + + /* If the LTV at level 2 was found at level 3 add the one from level 3, + * otherwise add the one at level 2 + */ + if (merge_data->value) + bap_push_ltv(merge_data->result, merge_data->len, + t, merge_data->value); + else + bap_push_ltv(merge_data->result, l, t, v); +} + +static void check_local_pac(void *data, void *user_data) +{ +#define Codec_Specific_Configuration_Check_Mask (\ + (1<data; + const struct bt_bap_pac *pac = data; + + /* Keep searching for a matching PAC if one wasn't found + * in previous PAC element + */ + if (compare_data->found == false) { + struct bt_ltv_match bis_compare_data = { + .data = pac->data, + .data32 = 0, /* LTVs bitmask result */ + .found = false + }; + + /* loop each BIS LTV */ + util_ltv_foreach(bis_data->iov_base, bis_data->iov_len, NULL, + check_source_ltv, &bis_compare_data); + + /* We have a match if all selected LTVs have a match */ + if ((bis_compare_data.data32 & + Codec_Specific_Configuration_Check_Mask) == + Codec_Specific_Configuration_Check_Mask) + compare_data->found = true; + } +} + +static void bap_sink_match_allocation(size_t i, uint8_t l, uint8_t t, + uint8_t *v, void *user_data) +{ + struct bt_ltv_match *data = user_data; + uint32_t location32; + + if (!v) + return; + + memcpy(&location32, v, l); + + /* If all the bits in the received bitmask are found in + * the local bitmask then we have a match + */ + if ((le32_to_cpu(location32) & data->data32) == + le32_to_cpu(location32)) + data->found = true; + else + data->found = false; +} + +static bool bap_check_bis(struct bt_bap_db *ldb, struct iovec *bis_data) +{ + struct bt_ltv_match compare_data = {}; + + /* Check channel allocation against the PACS location. + * If we don't have a location set we can accept any BIS location. + * If the BIS doesn't have a location set we also accept it + */ + compare_data.found = true; + + if (ldb->pacs->sink_loc_value) { + uint8_t type = BAP_CHANNEL_ALLOCATION_LTV_TYPE; + + compare_data.data32 = ldb->pacs->sink_loc_value; + util_ltv_foreach(bis_data->iov_base, bis_data->iov_len, &type, + bap_sink_match_allocation, &compare_data); + } + + /* Check remaining LTVs against the PACs list */ + if (compare_data.found) { + compare_data.data = bis_data; + compare_data.found = false; + queue_foreach(ldb->broadcast_sinks, check_local_pac, + &compare_data); + } + + return compare_data.found; +} + +static void bis_to_pac(void *data, void *user_data) +{ + struct bt_bap_bis *bis = data; + struct bt_bap_subgroup *subgroup = user_data; + struct bt_bap_pac *pac_source_bis; + struct bt_bap_endpoint *ep; + int err = 0; + struct bt_bap_pac_qos bis_qos = {0}; + uint8_t type = 0; + struct bt_ltv_extract merge_data = {0}; + + merge_data.src = bis->caps; + merge_data.result = new0(struct iovec, 1); + + /* Create a Codec Specific Configuration with LTVs at level 2 (subgroup) + * overwritten by LTVs at level 3 (BIS) + */ + util_ltv_foreach(subgroup->caps->iov_base, + subgroup->caps->iov_len, + NULL, + bap_sink_check_level2_ltv, &merge_data); + + /* Check each BIS Codec Specific Configuration LTVs against our Codec + * Specific Capabilities and if the BIS matches create a PAC with it + */ + if (bap_check_bis(subgroup->bap->ldb, merge_data.result) == false) + goto cleanup; + + DBG(subgroup->bap, "Matching BIS %i", bis->index); + + /* Create a QoS structure based on the received BIS information to + * specify the desired channel for this BIS/PAC + */ + type = BAP_CHANNEL_ALLOCATION_LTV_TYPE; + util_ltv_foreach(merge_data.result->iov_base, + merge_data.result->iov_len, &type, + bap_sink_get_allocation, &bis_qos.location); + + /* Create a remote PAC */ + pac_source_bis = bap_pac_new(subgroup->bap->rdb, NULL, + BT_BAP_BCAST_SOURCE, &subgroup->codec, &bis_qos, + merge_data.result, subgroup->meta); + + err = asprintf(&pac_source_bis->name, "%d", bis->index); + + if (err < 0) { + DBG(subgroup->bap, "error in asprintf"); + goto cleanup; + } + + /* Add remote source endpoint */ + if (!subgroup->bap->rdb->broadcast_sources) + subgroup->bap->rdb->broadcast_sources = queue_new(); + queue_push_tail(subgroup->bap->rdb->broadcast_sources, pac_source_bis); + + queue_foreach(subgroup->bap->pac_cbs, notify_pac_added, pac_source_bis); + /* Push remote endpoint with direction sink */ + ep = bap_endpoint_new_broadcast(subgroup->bap->rdb, BT_BAP_BCAST_SINK); + + if (ep) + queue_push_tail(subgroup->bap->remote_eps, ep); + +cleanup: + util_iov_free(merge_data.result, 1); +} + +/* + * Parse each subgroup, check if we can create PACs from its BISes and then + * clear the subgroup data. + */ +void bt_bap_parse_bis(void *data, void *user_data) +{ + struct bt_bap_subgroup *subgroup = data; + + queue_foreach(subgroup->bises, bis_to_pac, subgroup); + cleanup_subgroup(subgroup); +} diff --git a/src/shared/bap.h b/src/shared/bap.h index b13fef688da3..aed3bf52b8d9 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -4,7 +4,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2022 Intel Corporation. All rights reserved. - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * */ @@ -101,13 +101,13 @@ struct bt_bap_qos { struct bt_bap_base { uint32_t pres_delay; uint8_t big_id; - uint8_t num_subgroups; uint8_t next_bis_index; + uint8_t num_subgroups; struct queue *subgroups; }; struct bt_bap_subgroup { - uint8_t subgroup_index; + uint8_t index; struct bt_bap *bap; uint8_t num_bises; struct bt_bap_codec codec; @@ -198,6 +198,10 @@ uint16_t bt_bap_pac_get_context(struct bt_bap_pac *pac); struct bt_bap_pac_qos *bt_bap_pac_get_qos(struct bt_bap_pac *pac); +struct iovec *bt_bap_pac_get_data(struct bt_bap_pac *pac); + +struct iovec *bt_bap_pac_get_metadata(struct bt_bap_pac *pac); + uint8_t bt_bap_stream_get_type(struct bt_bap_stream *stream); struct bt_bap_stream *bt_bap_pac_get_stream(struct bt_bap_pac *pac); @@ -349,4 +353,5 @@ struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream); bool bt_bap_parse_base(struct bt_bap *bap, void *data, size_t len, util_debug_func_t func, struct bt_bap_base *base); +void bt_bap_parse_bis(void *data, void *user_data); From patchwork Mon Feb 19 12:15:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 13562594 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2060.outbound.protection.outlook.com [40.107.20.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 AA0492D602 for ; Mon, 19 Feb 2024 12:15:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708344926; cv=fail; b=e3kLiZOTc6aGSDSrqxciMhYAFF/wa2ftu0ApI0s3pb8AY0wfs42QAXrMozEKf3UL+faqVKuC2Uv75WE2fe7A1nRizVy96lSW/aOiXGwiCOtvjH4kRkL5i3yvt7Dr+siXUkaWacNryDCeQ4h9IO//L6t4UYomnqWgyv64eozs7kY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708344926; c=relaxed/simple; bh=g8HzpD242OE1BEHH9AivH1bfQovIMlejxPb82jHU0qs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ft87okKJhnOnOWZk7dIoA2ar4AY77/H4DXMMdcdrOOqn8gOgXRKip+3NzaMoEUSGzXTRTwPEq9eYkDPtt+1bzl+N2iDW3LJM7CaZ0r/PV0keRcbGGm/C5CnHMGejtncjQyL895L8rZ34Aa3NVpuVH8rcNQXzpV071NDOcF9eKi8= 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=X/j8Lgze; arc=fail smtp.client-ip=40.107.20.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="X/j8Lgze" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bXVGmdwqY5inJHt2FALR+ZkRQX6AIDnceSmRHEdVWkm/TizhKZWW83vTivIlWPV9mPaI4GXLbkSUAKYUweeNQ++z1pOyS1Id/ycu8uemSb1faLxAZxBR9+R7Xu/+ysEgLHG4/U1vJTsGX66cTvhyrTV4vAeVIr/WCFtGQFK21P69in8GDePj/QXToMPkfidgEkKwLrk8eC9N+pBt5f7UwYcHYqehmhwwYnanL6a76q7fSP6diJkwet1voLTG+TjpZM6LlfVwQZCVrU+EGrwPqrCa3p8iPq5+FbfdtVQqKFZvqga5wCGS9rVJ3htSpBZC7x/4+QG2cfK09GAuvS6F4g== 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=XrfbAIFEw8KaXKvHGllD1LufCIzh4RDJiDcsJYsv6MQ=; b=VsG4/Z92oKl1oaW5kpupvQTli6iIe8Zet0/NO7LWVEqlfLeqkNYEwp1U4ZrBxK6+Tm9pjpAgxWQDGGEmgcCP66dmBdsWQd7VMYlaZNG3U51NiUJjLXJ53spqcfc3akXxMTQ9qQwzAOnyiZmuiJoea2UktkM92lEh/M39D2+Rg4Xb14VDv29NXx4jjZTdKVSnkqI1aXzbbi66kGUdpEE5EzTHOnHofKdhtScMuc0Tndwj8x7imjwn6mxE6eBfX4SG8IaG3ZQP06KVQDY83+++7j9AV62uOBo4qSbu7yBt70dmek4RP/CC9kkMr6+rbogzz4iI5jIt/sm8rRjHrRHPuw== 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=XrfbAIFEw8KaXKvHGllD1LufCIzh4RDJiDcsJYsv6MQ=; b=X/j8LgzeCKhRJCY9d/0UhP02Wg/sHgyn3C71qeBiTQfC6Cl6DSPynpt8RWgqcBpe+LQk+rx05Ns5GX9q62xqhAIT/8CTxabFW21is9G8cZz8wtUPfRr9A6n31TVMe5JL1eQ+RMMW9NOaMMo3Vhw7gQmwWKQeH3Kr7VO+Al1E/fY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by AS8PR04MB9141.eurprd04.prod.outlook.com (2603:10a6:20b:448::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.37; Mon, 19 Feb 2024 12:15:18 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::bbd0:4409:3f0e:afdd]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::bbd0:4409:3f0e:afdd%4]) with mapi id 15.20.7292.029; Mon, 19 Feb 2024 12:15:18 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ v3 3/4] shared/bap: Add Broadcast QOS copy functions Date: Mon, 19 Feb 2024 14:15:08 +0200 Message-Id: <20240219121509.5702-4-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240219121509.5702-1-andrei.istodorescu@nxp.com> References: <20240219121509.5702-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AM4PR07CA0016.eurprd07.prod.outlook.com (2603:10a6:205:1::29) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) 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: AM9PR04MB8938:EE_|AS8PR04MB9141:EE_ X-MS-Office365-Filtering-Correlation-Id: 82949da8-567f-4474-397e-08dc31446fec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uSePvjcqaykavfCHPhBAu+uCDP3xLjxealilEfhxEvQPeUo2/qyBk01OiN882HOEereTcJkBwH0IVPYWl79zT5ZzqzGgSuZ2I+k+jDEA6N8Z5snWkCLHwVzQZtOXm04PSGj0GNbya96us9f5QeuBwQDNh3HFTdzQymcceoxrW8rvFJqo9LkDH4mj1OHec8uXCIzgrt8+1pSDjErKe3LhRHbzXNNu476opWg2uOoJpt32m36o3SaNrPGKfiXt2WhVkttONCqNRwtUXxyAqTZy9p51Ds3gtouR4C2XSzjv5rssue1aG3TCEHWYxYHqYndVzsqYx19ernrVCZzsGqoJxbo5O+WTAeoLuWVz6GnSru/wk1zd2iIBGrpUa5hZYWrxcj4m2s4g60NxZbruGO5APHUudtv085Xn9DJzQSk0pnoApT8HpHYqv6elk0kPl+QVmhEhCI94vMRLEzP0UTzbmAvsc+EMizGsWYFBM8ojV1zmz/gDg0sgKQmtbf9rwidUVpp5FohiE5WZlBvJnu66AsrjbFKgi0D0Aw9CNBnGej0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8938.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: BvR0tMRZzmtKKNkOkEjxt2yN8VSIfl4E+kV6tOnkp3kIfBtd72sN7M+kWOnIxaUGtxLvP9gbNCCbKUNPA3MPE3MJBVpQpBogVHo2Zmv5q78Fpr5CMpwgn/5//wDCcW4QyI2MKTEUel5+hcSLGXnnR5P+pomSrROXlkFPEGSaqV1xWTfikjh6mtqRmbYvswrgqi9caZnjav3j885YccgIecJgZt9N3q+ke3cYuv2Upg/sMBIhZjVV4Ol+s+fxrWhBnmaBfDGGHcBaKo2AzmI3Aiq51d8Tsj4wX5953zHhL+PqbRU4xTkmtLnmNvGODdBJA2uWz9etd/Njkz1bnVVTcr58tuzhWRMEkK0e1HTNUYHKhkFLGPXVLr+vybXwXE04A0yY6PmSdJURJgRGFelPCjmNjgqNMihcYN12xI6sL7ZiG5obqj4FuT6P33qNC5bugHUKFQzrPme1NgwXYep49HZ820/uoKUUBswBV95+VherYvl6M22vfc8vcWLWtmIbLynYJOj4Pp3YbgtDQJjpJcNVGSkpBzPu9WGFN1xK27vk+AxLgjy4wW1fvmcOskMz6PvEir1rSyxcxUhuMKvs5jr7EKQA6ZOryAiIkavpLpjqbtnxQ44IJR2B95PJpTPBUyk0y00Fr/cXVrEs3bj3VdUoFcwpuGcTvX1ITjweBtLQj4owgLT51Y2eSr5PjOGi9ds6pfkkpmSp/65oIDhCY6SlqurlOPVvS7p02jLlygkSXWk6h0VSuSU0mjN+nWKxZsm6p80r4IuTO0t8D/cjrphPgMKKFfksOQHt4g+vcyasYxVsJ5xZrCEiI3Psdle2T8fzktDiWWpN1d+clG0tXZVphge/sFN1feB/7ZAvA3CFDVrj1CHXAGhXzM9vVVSMTQCvvmdhT+5itIaXnCD3wl3VURf7YG/bketxtcanqCU1pIrk1L2ALcw6LeAwhpzJuXYqPet8vOWyC9oPrxoc+E6nYbwpjBa9Lb8LpNblwMjxYaO59aLXbPdfqwfBnXpTfdCtBz183IfDbv9JJJJafDyi1fLC2RwoEkFh4vc+Lx0DHbqlHkZiX3033dBiqdDzc7S+F6srHJfwBE/DAj1JgKCLJbkVvFljNVBYR32QVBxVyGX6lIetACsuKoJ9Hg6ZHSxGVlSGyS8UhRzgssX3wZbvubwJs5hq3LV2mvpRvou4Spm7Cen8c4neR4nCN7qi+WNNLC14BgaL/F/yVLeYFsCthaXIBNz/Io7/GVdsZX1Mk53+gwWeoi7691AF3wzjy9U7Mj0XOapR/KXvdEKf/tbSaSvbmhb+RPf4yOXL9ZRlY1Nh+NUflHCOANf7kIdgZEzNBgQBb/43MPzdPzb1r+3fR96uv8cxPFU3nb0LwbwWA1NDsUT9ntJ4DYXwVnorWbV1Q0IMnPvK/gWykHvPfJP9SFcjBkHq8ysmOn3y1/G0L96SonBptG37Q/AJPr7aKpIgbgXZMWoOjQhlk3fHi+/GZEl9t5fy09lZRNLMRLztBMukmGE4BmVMR1X/GRj7a6enT8ap82A2ZWbI6MBljdfMa1Sjrz8G7LV6v8WKYqF3RriJ7rbFxEU/mC//nEVoovB4xlblr9B1rYmktZ29cA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82949da8-567f-4474-397e-08dc31446fec X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2024 12:15:18.6103 (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: wquWliXUR/M88K6loywdzRhajeh6P1vJ8vXWxutSokxmHMuH4Ffk5MkOFmYyRJJtGyLuk1aykUoWqY1/o/7i2pb/h93ogj2K7Ta1l85Sky0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9141 BAP works with bt_bap_qos structures and kernel with bt_iso_qos. These functions are utilitary functions to allow jumping easily from one structure to another. --- src/shared/bap.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/shared/bap.h | 4 ++++ 2 files changed, 48 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index c3d96c08fddc..19e40e3c70f4 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -6527,3 +6527,47 @@ void bt_bap_parse_bis(void *data, void *user_data) queue_foreach(subgroup->bises, bis_to_pac, subgroup); cleanup_subgroup(subgroup); } + +void bt_bap_bcast_qos_iso_to_bap(struct bt_bap_qos *bap_qos, + struct bt_iso_qos *iso_qos) +{ + bap_qos->bcast.big = iso_qos->bcast.big; + bap_qos->bcast.bis = iso_qos->bcast.bis; + bap_qos->bcast.sync_factor = iso_qos->bcast.sync_factor; + bap_qos->bcast.packing = iso_qos->bcast.packing; + bap_qos->bcast.framing = iso_qos->bcast.framing; + bap_qos->bcast.encryption = iso_qos->bcast.encryption; + if (bap_qos->bcast.bcode && bap_qos->bcast.bcode->iov_base) + memcpy(bap_qos->bcast.bcode->iov_base, iso_qos->bcast.bcode, + bap_qos->bcast.bcode->iov_len); + bap_qos->bcast.options = iso_qos->bcast.options; + bap_qos->bcast.skip = iso_qos->bcast.skip; + bap_qos->bcast.sync_timeout = iso_qos->bcast.sync_timeout; + bap_qos->bcast.sync_cte_type = iso_qos->bcast.sync_cte_type; + bap_qos->bcast.mse = iso_qos->bcast.mse; + bap_qos->bcast.timeout = iso_qos->bcast.timeout; + memcpy(&bap_qos->bcast.io_qos, &iso_qos->bcast.out, + sizeof(struct bt_iso_io_qos)); +} + +void bt_bap_bcast_qos_bap_to_iso(struct bt_iso_qos *iso_qos, + struct bt_bap_qos *bap_qos) +{ + iso_qos->bcast.big = bap_qos->bcast.big; + iso_qos->bcast.bis = bap_qos->bcast.bis; + iso_qos->bcast.sync_factor = bap_qos->bcast.sync_factor; + iso_qos->bcast.packing = bap_qos->bcast.packing; + iso_qos->bcast.framing = bap_qos->bcast.framing; + iso_qos->bcast.encryption = bap_qos->bcast.encryption; + if (bap_qos->bcast.bcode && bap_qos->bcast.bcode->iov_base) + memcpy(iso_qos->bcast.bcode, bap_qos->bcast.bcode->iov_base, + bap_qos->bcast.bcode->iov_len); + iso_qos->bcast.options = bap_qos->bcast.options; + iso_qos->bcast.skip = bap_qos->bcast.skip; + iso_qos->bcast.sync_timeout = bap_qos->bcast.sync_timeout; + iso_qos->bcast.sync_cte_type = bap_qos->bcast.sync_cte_type; + iso_qos->bcast.mse = bap_qos->bcast.mse; + iso_qos->bcast.timeout = bap_qos->bcast.timeout; + memcpy(&iso_qos->bcast.out, &bap_qos->bcast.io_qos, + sizeof(struct bt_iso_io_qos)); +} diff --git a/src/shared/bap.h b/src/shared/bap.h index aed3bf52b8d9..968257651766 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -354,4 +354,8 @@ struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream); bool bt_bap_parse_base(struct bt_bap *bap, void *data, size_t len, util_debug_func_t func, struct bt_bap_base *base); void bt_bap_parse_bis(void *data, void *user_data); +void bt_bap_bcast_qos_iso_to_bap(struct bt_bap_qos *bap_qos, + struct bt_iso_qos *iso_qos); +void bt_bap_bcast_qos_bap_to_iso(struct bt_iso_qos *iso_qos, + struct bt_bap_qos *bap_qos); From patchwork Mon Feb 19 12:15:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 13562595 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2087.outbound.protection.outlook.com [40.107.20.87]) (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 8D6752C6B2 for ; Mon, 19 Feb 2024 12:15:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708344931; cv=fail; b=gn6o5g1W9d+TAjZTUkWHMu4oY2HvmsJJ7VavBYB6pOAfYP/6kSreu9neiFDE1CxWyd7mGfBy4XS+SccS++w0grjPtYmGTsKqOaFLibnucikPGOGKW5PoAn+bH4nfkv8/ETzCzvE8gsnkBMcbbq++p6gK8RYfHMA1BASFSDlw3zk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708344931; c=relaxed/simple; bh=yzH8YVj4GwJHelc+aQtQ5NuR6tVtBHneItK3rYZlb6M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mAtkzxNfEYEybq+Ivljl1Q+SvLhmEk/M0XwxtEoIMBENw+RxxGLWsebBj6zmqmLsm+IQSpaa8geFHuhEZnFZDUrMYn2U7ngl84+D0MILBmgh8UdYnE3yOfou2xr6CBh6JgZlqvldLvOoR0FcFEiQkRDbXTTbHaP9ZTP7Ocgt1P0= 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=n17Z5aAJ; arc=fail smtp.client-ip=40.107.20.87 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="n17Z5aAJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kEL72n0pZtORsklr0Klf7pC+Dk1oWcyGv+xQl7NllO5UkZVuDH3a6ZDMrYBU7wOFgYxIy5x/o5jw0cLRaNOvnFmMs9YMST9wAZxzUND9f2quIrdvNjYVuUHJB0lc7YV4Ptn05ZRttVPyyhnW1NTtwj7XjqkLvc459CNvAYtRY/2ZuM/V2QNTOWsUpHDBoPXsGV9/gTM3wle3DAAdvvSI7No2XRw5SWzT7taxUmkJm+VhqU+xXYjLKMSPgOtTnIWT8FknFaRjNKRj3Jir6Ull8coaVS3dCN3MSWceorLayvtzn3Bj6mMwzBUpjAuuM7EDrel+lewpM6dQMjU4hJXUlA== 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=EILv0Vd/57cZWFI1Yl7J+urCytM5VoRAGq+MZ6Uw+Bg=; b=az3tOBwSrj4sJ6CNCLZ1Js/LtueMsarh+yjav96Pir7V31icHwJ6OsuE6yR4GQ3hBWtaKJ4oghdzjO/SZwcefD3cnMf2fqYmAcrG1xtgDJDzZWUHxFsXqsfBLcwotwX10HqWVwzOA4nfSonjrkYkgfDZmPexhLsQTRnhDN4SWYjtHcl8n+Rlcb0ig4dtNlicIPQxve1muNe2fMjZquvdEz8t/YXMXDM/y01FhuJQiGbbO9jEnhQJ81qOgnUqqVYnbM+n+YAXev3YdnvbsIODK2TfNhOSWlug98wmrYR9o6FsGpg8x+Hgvd8ORH5zb8r7mcS3FzwOn512UHm3HCht5A== 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=EILv0Vd/57cZWFI1Yl7J+urCytM5VoRAGq+MZ6Uw+Bg=; b=n17Z5aAJHv+wFeoyddMcnclsawLBSShdoiDrC4626gvkDZ/c7Ug0ezT75nXwxNPQQktz3upe9EhPZPJdQjsL5DzDOb2TJsXdIsooQ7OxVNfZgz/ceB3rYx9YCGnW7OwXJNWBSUaTZDW36DgsrAdUZaL3p3zJfL8pW59RikqfoL4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by AS8PR04MB9141.eurprd04.prod.outlook.com (2603:10a6:20b:448::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.37; Mon, 19 Feb 2024 12:15:20 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::bbd0:4409:3f0e:afdd]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::bbd0:4409:3f0e:afdd%4]) with mapi id 15.20.7292.029; Mon, 19 Feb 2024 12:15:20 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ v3 4/4] bap: Do PA Sync for each BAP Broadcast source discovered Date: Mon, 19 Feb 2024 14:15:09 +0200 Message-Id: <20240219121509.5702-5-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240219121509.5702-1-andrei.istodorescu@nxp.com> References: <20240219121509.5702-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AM8P251CA0015.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::20) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) 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: AM9PR04MB8938:EE_|AS8PR04MB9141:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ea6a92a-99cc-4c4e-4b3a-08dc314470bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jaaRRz3e3QFpZigGMIRBMM5UbBs4MsNepYrEXqoCPKgeUZTSFlaxb0wsYAroBGVdIIkLyTV4xTUJS5+5sR+/JnwWqFAueongQ23QKeV5TWLCNDH7b44ax4eQ0TmNMz/bTZBwaIdyGvZk7TeQdnqwuEONiegapceIMA46jHz7qBWTwG6H/KsY0RMwgPsp30zkLn5wRsKLDpsdxSqFPNFUzArcV5nGvJ7b6CovPbMqvDsRsavc8mTpB/JXWNvuye8rISxban/QUgGbZNYfHZhs7epAyJkJwtB1zpUtAWf1KN5MJq89O33iM7doL5g3Iu2nwNDR3L7lhpEPPWZ7Rb1Sd/gfX6z5T1FrfKGPwZBRcW+iPG4haEyiKGmcJGo7cv7k63eO662B4gS/SvUr/Ej5Gj2Xj98jMW1zBSJmapLZiN2SG47nNbI0NRbvUX346c2nh2YjojyGRnFyT8BQ1MijOQfdujoQu0qXzuFsrJl4h7FhOsXRqHmF8mIz65Bdut/A3R2dK23zEmj60xtRWYM5HJWBSYjv62isL67yuRjKDp4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8938.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: IjfLfxqPaxL/gA9qREs8uYmtyjZy8q7kZ2sT9E8CYJSgHGptM66hXz3kPKUNiDHK/rL/8fOQcIjVM9HkvSQmHGbHL3Df2K4uTuX4rmPUYBKlTSOzvntpJ7/XDprUQxHVIBpharip6FU6XPQZtr0Qvf1Bk2QXpOZ9w6mi7icpRnV23QCNTW9fIQNHpb5PufVlQVprAPq5cB9DInoNa4zg6TZI2pzuVCbvdtizVdAdT9wfkFB4NwJcdxxL+1DuE2Dgjxnr+Fjzlm5GbTH5R71+78SfkEnhMzMUgZVjny+qV/QIdZCksBqo3LofOyrLKGq1XwZDwVU0PUxGMzquDfGCvaaBwkLHXPlkptOkdTnCAVxamtnPDvspmoOkQWfZbLyqVZKnk8Z/bPrwA0YAbpOau7gqgg9ffIXxhj2th200gAtvGAq/+XcstkwKQUw/kNdWVsKWRJND2myWpc8usqKmDWXkXnKZbEk1wsK+fcoLNXFSB9KtbRrNe61pjhVxLj7KLQPwdyZ5nF7xsYJknobTKSmFHx17kCIZlkprws9HSEuF3FgT5g7sZBisj1PpN/eqwst+N4gjnLUAh5aC9XYQX3TI8IVYqUhr2jjcLABqZKDZMGSfI/D06CVuNwyhW83P2pmLCOlVvjURKTINm4QO0whG4ObHpJP/FB8z0AkU/xJz2EzLvlVuKAGd3OLqxFixcl79+Ak/u+iyv9isa6iB5Uzt/V6+/OQt98gIy+nMbUjRuPeyrf7oYEIpJSKhXUtaYu6lxXBkXCkcDO1p8UlwoGsSKqc+p2W5o6TW/6dM9JD7fVTKQP4CDdeZbwfjoVv7l2cTiRXYfPaYKvnIKtOiL+a2yh4J/+m/Q8DSniIEJcs+GCwBGcksln/L1m2V7upT0QSpjjTsK7/D3RfmzUUH4YaZ1Zm/MW8gUvwsU862TM9OvnpDeMwENc7EuI3DffhuZrlvbUcvuUzZpUL6I7X3mQwyJHZqKpVsEANOWeaVQhe+BGfxJSGfjyhn4SQEeahELhbyOZyxSPJ4YqFlg1QL3Pcq3h4Zr6RO86oV6ZRkJXlCtOYNGIzndN8BKSAZCAByeOPmcc1b6Jy+sgwNpkRCHCZaSzHuR7qAX7EPdvQ9nSSadYxUePyxqdurBFSLO2YJ/bhGhxnb3NFUAVMSgPVYk8HQ66AIufSzHk+bo/sti+Fq9q2fqm4dqete/daTolDrruFmXJQ8J+41LkWE5QKq5kksQIbZ8q5vLB/ZETMsEq3u+6SnuweZMGvTZ3vnR+pozCM8vSUIyZFsis43qKS8Do+JKdfgNfz5mSxGyCklSaMzPjj83rNbL572U3HtTWq/r0iMAWmVn6L6rzSdZA9XbevS63ZeS1M/BHKr1AxlqpeRMdXT3ZDgP3nw2QGzwP8dRbtRvkztg/M2CgB7UZlnc+X7Le1ND1MSVNQqpntulyhw7lFmQIB5wStQTtRgVC79FzMWVVDBT+TMoNXitRl4cX4SIb5CvTvUTYjmfPjIQs+mTePCwGEBeFiU1a71cDHF1AjD290O20JIsWg3/nNZEiClQ+CEOEbyCfoxiequg2Ds2bPPKBACgk0XG2OUkNyuMS+XZG4W1c47edkxnv73yg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ea6a92a-99cc-4c4e-4b3a-08dc314470bf X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2024 12:15:20.0527 (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: CPAeFtF1uSUCr4uFOkQm5PbUflA2eFCZdH0ndo+X2UoGB3chGaN9U5iLuYQ1HmDI2pjN12NUzNKHdr2xw7DB19v3PIIv+Qm7URzo6mYHulk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9141 After discovering a BAP Broadcast Source do a short PA sync first to learn the BASE. After discovering the BASE check how many BISes are matching the sink capabilities and create endpoints for them. Allow user to configure one endpoint using "SetConfiguration" causing BIG synchronization to the corresponding BIS; also this results in creating a stream and the corresponding transport. --- profiles/audio/bap.c | 546 +++++++++++++++++++++++-------------------- src/shared/bap.c | 11 +- 2 files changed, 299 insertions(+), 258 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 88c93127bea0..3a32b7f4e106 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -62,6 +62,13 @@ #define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1" #define MEDIA_INTERFACE "org.bluez.Media1" +/* Periodic advertisments are performed by an idle timer, which, + * at every tick, checks a queue for pending PA requests. + * When there is no pending requests, an item is popped from the + * queue, marked as pending and then it gets processed. + */ +#define PA_IDLE_TIMEOUT 2 + struct bap_setup { struct bap_ep *ep; struct bt_bap_stream *stream; @@ -105,7 +112,62 @@ struct bap_data { void *user_data; }; +enum { + BAP_PA_SHORT_REQ = 0, /* Request for short PA sync */ + BAP_PA_BIG_SYNC_REQ, /* Request for PA Sync and BIG Sync */ +}; + +struct bap_bcast_pa_req { + uint8_t type; + bool in_progress; + union { + struct btd_service *service; + struct bap_setup *setup; + } data; +}; + static struct queue *sessions; +static struct queue *bcast_pa_requests; +static unsigned int pa_timer_id; + +/* Structure holding the parameters for Periodic Advertisement create sync. + * The full QOS is populated at the time the user selects and endpoint and + * configures it using SetConfiguration. + */ +static struct bt_iso_qos bap_sink_pa_qos = { + .bcast = { + .options = 0x00, + .skip = 0x0000, + .sync_timeout = 0x4000, + .sync_cte_type = 0x00, + /* TODO: The following parameters are not needed for PA Sync. + * They will be removed when the kernel checks will be removed. + */ + .big = BT_ISO_QOS_BIG_UNSET, + .bis = BT_ISO_QOS_BIS_UNSET, + .encryption = 0x00, + .bcode = {0x00}, + .mse = 0x00, + .timeout = 0x4000, + .sync_factor = 0x07, + .packing = 0x00, + .framing = 0x00, + .in = { + .interval = 10000, + .latency = 10, + .sdu = 40, + .phy = 0x02, + .rtn = 2, + }, + .out = { + .interval = 10000, + .latency = 10, + .sdu = 40, + .phy = 0x02, + .rtn = 2, + } + } +}; static bool bap_data_set_user_data(struct bap_data *data, void *user_data) { @@ -422,113 +484,6 @@ static int parse_array(DBusMessageIter *iter, struct iovec *iov) return 0; } -static bool parse_base(void *data, size_t len, util_debug_func_t func, - uint32_t *presDelay, uint8_t *numSubgroups, uint8_t *numBis, - struct bt_bap_codec *codec, struct iovec **caps, - struct iovec **meta) -{ - struct iovec iov = { - .iov_base = data, - .iov_len = len, - }; - - uint8_t capsLen, metaLen; - struct iovec cc; - struct iovec metadata; - - if (presDelay) { - if (!util_iov_pull_le24(&iov, presDelay)) - return false; - util_debug(func, NULL, "PresentationDelay %d", *presDelay); - } - - if (numSubgroups) { - if (!util_iov_pull_u8(&iov, numSubgroups)) - return false; - util_debug(func, NULL, "NumSubgroups %d", *numSubgroups); - } - - if (numBis) { - if (!util_iov_pull_u8(&iov, numBis)) - return false; - util_debug(func, NULL, "NumBis %d", *numBis); - } - - if (codec) { - codec = util_iov_pull_mem(&iov, sizeof(*codec)); - if (!codec) - return false; - util_debug(func, NULL, "%s: ID %d CID 0x%2.2x VID 0x%2.2x", - "Codec", codec->id, codec->cid, codec->vid); - } - - if (!util_iov_pull_u8(&iov, &capsLen)) - return false; - util_debug(func, NULL, "CC Len %d", capsLen); - - if (!capsLen) - return false; - - cc.iov_len = capsLen; - cc.iov_base = util_iov_pull_mem(&iov, capsLen); - if (!cc.iov_base) - return false; - - if (caps) { - if (*caps) - util_iov_free(*caps, 1); - - *caps = util_iov_dup(&cc, 1); - } - - for (int i = 0; capsLen > 1; i++) { - struct bt_ltv *ltv = util_iov_pull_mem(&cc, sizeof(*ltv)); - uint8_t *caps; - - if (!ltv) { - util_debug(func, NULL, "Unable to parse %s", - "Capabilities"); - return false; - } - - util_debug(func, NULL, "%s #%u: len %u type %u", - "CC", i, ltv->len, ltv->type); - - caps = util_iov_pull_mem(&cc, ltv->len - 1); - if (!caps) { - util_debug(func, NULL, "Unable to parse %s", - "CC"); - return false; - } - util_hexdump(' ', caps, ltv->len - 1, func, NULL); - - capsLen -= (ltv->len + 1); - } - - if (!util_iov_pull_u8(&iov, &metaLen)) - return false; - util_debug(func, NULL, "Metadata Len %d", metaLen); - - if (!metaLen) - return false; - - metadata.iov_len = metaLen; - metadata.iov_base = util_iov_pull_mem(&iov, metaLen); - if (!metadata.iov_base) - return false; - - if (meta) { - if (*meta) - util_iov_free(*meta, 1); - - *meta = util_iov_dup(&metadata, 1); - } - - util_hexdump(' ', metadata.iov_base, metaLen, func, NULL); - - return true; -} - static int parse_io_qos(const char *key, int var, DBusMessageIter *iter, struct bt_bap_io_qos *qos) { @@ -954,9 +909,20 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return btd_error_invalid_args(msg); } + /* For BAP Broadcast Sink, the capabilities and metadata are coming + * from the source's BIS, which are present in the remote PAC + */ + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) { + util_iov_free(setup->caps, 1); + setup->caps = util_iov_dup(bt_bap_pac_get_data(ep->rpac), 1); + util_iov_free(setup->metadata, 1); + setup->metadata = util_iov_dup( + bt_bap_pac_get_metadata(ep->rpac), 1); + } + setup->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, ep->rpac, &setup->qos, setup->caps); - + bt_bap_stream_set_user_data(setup->stream, ep->path); setup->id = bt_bap_stream_config(setup->stream, &setup->qos, setup->caps, config_cb, setup); if (!setup->id) { @@ -965,8 +931,6 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return btd_error_invalid_args(msg); } - bt_bap_stream_set_user_data(setup->stream, ep->path); - if (setup->metadata && setup->metadata->iov_len) bt_bap_stream_metadata(setup->stream, setup->metadata, NULL, NULL); @@ -977,95 +941,29 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, break; case BT_BAP_STREAM_TYPE_BCAST: /* No message sent over the air for broadcast */ - if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) - setup->msg = dbus_message_ref(msg); - else { + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) setup->base = bt_bap_stream_get_base(setup->stream); - setup->id = 0; } + setup->id = 0; if (ep->data->service) service_set_connecting(ep->data->service); return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); - } return NULL; } -static void update_bcast_qos(struct bt_iso_qos *qos, - struct bt_bap_qos *bap_qos) -{ - bap_qos->bcast.big = qos->bcast.big; - bap_qos->bcast.bis = qos->bcast.bis; - bap_qos->bcast.sync_factor = qos->bcast.sync_factor; - bap_qos->bcast.packing = qos->bcast.packing; - bap_qos->bcast.framing = qos->bcast.framing; - bap_qos->bcast.encryption = qos->bcast.encryption; - bap_qos->bcast.options = qos->bcast.options; - bap_qos->bcast.skip = qos->bcast.skip; - bap_qos->bcast.sync_timeout = qos->bcast.sync_timeout; - bap_qos->bcast.sync_cte_type = qos->bcast.sync_cte_type; - bap_qos->bcast.mse = qos->bcast.mse; - bap_qos->bcast.timeout = qos->bcast.timeout; - bap_qos->bcast.io_qos.interval = qos->bcast.in.interval; - bap_qos->bcast.io_qos.latency = qos->bcast.in.latency; - bap_qos->bcast.io_qos.phy = qos->bcast.in.phy; - bap_qos->bcast.io_qos.sdu = qos->bcast.in.sdu; - bap_qos->bcast.io_qos.rtn = qos->bcast.in.rtn; - if (!bap_qos->bcast.bcode) - bap_qos->bcast.bcode = new0(struct iovec, 1); - util_iov_memcpy(bap_qos->bcast.bcode, qos->bcast.bcode, - sizeof(qos->bcast.bcode)); -} - static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) { - struct bap_setup *setup = user_data; - struct bap_ep *ep = setup->ep; - struct bap_data *data = ep->data; - struct bt_iso_qos qos; - struct bt_iso_base base; - char address[18]; + struct bap_bcast_pa_req *req = user_data; + struct bap_setup *setup = req->data.setup; int fd; - struct iovec *base_io; - uint32_t presDelay; - uint8_t numSubgroups; - uint8_t numBis; - struct bt_bap_codec codec; - - bt_io_get(io, &err, - BT_IO_OPT_DEST, address, - BT_IO_OPT_QOS, &qos, - BT_IO_OPT_BASE, &base, - BT_IO_OPT_INVALID); - if (err) { - error("%s", err->message); - g_error_free(err); - goto drop; - } - - g_io_channel_ref(io); - btd_service_connecting_complete(data->service, 0); - DBG("BCAST ISO: sync with %s (BIG 0x%02x BIS 0x%02x)", - address, qos.bcast.big, qos.bcast.bis); - update_bcast_qos(&qos, &setup->qos); + queue_remove(bcast_pa_requests, req); - base_io = new0(struct iovec, 1); - util_iov_memcpy(base_io, base.base, base.base_len); - - parse_base(base_io->iov_base, base_io->iov_len, bap_debug, - &presDelay, &numSubgroups, &numBis, - &codec, &setup->caps, &setup->metadata); - - /* Update pac with BASE information */ - bt_bap_update_bcast_source(ep->rpac, &codec, setup->caps, - setup->metadata); - setup->id = bt_bap_stream_config(setup->stream, &setup->qos, - setup->caps, NULL, NULL); - - bt_bap_stream_set_user_data(setup->stream, ep->path); + /* This device is no longer needed */ + btd_service_connecting_complete(setup->ep->data->service, 0); fd = g_io_channel_unix_get_fd(io); @@ -1074,26 +972,44 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) g_io_channel_set_close_on_unref(io, FALSE); return; } - - - return; - -drop: - g_io_channel_shutdown(io, TRUE, NULL); - } static void iso_pa_sync_confirm_cb(GIOChannel *io, void *user_data) { GError *err = NULL; + struct bap_bcast_pa_req *pa_req = user_data; + struct bap_data *data = btd_service_get_user_data(pa_req->data.service); + struct bt_iso_base base; + struct bt_bap_base base_s; + struct bt_iso_qos qos; - if (!bt_io_bcast_accept(io, iso_bcast_confirm_cb, - user_data, NULL, &err, BT_IO_OPT_INVALID)) { - error("bt_io_bcast_accept: %s", err->message); + DBG("PA Sync done"); + + bt_io_get(io, &err, + BT_IO_OPT_BASE, &base, + BT_IO_OPT_QOS, &qos, + BT_IO_OPT_INVALID); + if (err) { + error("%s", err->message); g_error_free(err); g_io_channel_shutdown(io, TRUE, NULL); + return; } + /* 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; + queue_remove(bcast_pa_requests, pa_req); + + /* Analyze received BASE data and create remote media endpoints for each + * matching BIS + */ + base_s.subgroups = queue_new(); + bt_bap_parse_base(data->bap, base.base, base.base_len, bap_debug, + &base_s); + queue_foreach(base_s.subgroups, bt_bap_parse_bis, NULL); } static bool match_data_bap_data(const void *data, const void *match_data) @@ -1675,7 +1591,7 @@ static bool is_cig_busy(struct bap_data *data, uint8_t cig) return queue_find(sessions, cig_busy_session, &info); } -static void setup_create_io(struct bap_data *data, struct bap_setup *setup, +static bool setup_create_io(struct bap_data *data, struct bap_setup *setup, struct bt_bap_stream *stream, int defer); static gboolean setup_io_recreate(void *user_data) @@ -1934,47 +1850,58 @@ static void setup_listen_io(struct bap_data *data, struct bt_bap_stream *stream, data->listen_io = io; } -static void setup_listen_io_broadcast(struct bap_data *data, - struct bap_setup *setup, - struct bt_bap_stream *stream, - struct bt_iso_qos *qos) +static void check_pa_req_in_progress(void *data, void *user_data) { - GIOChannel *io; - GError *err = NULL; - struct sockaddr_iso_bc iso_bc_addr; + struct bap_bcast_pa_req *req = data; - iso_bc_addr.bc_bdaddr_type = btd_device_get_bdaddr_type(data->device); - memcpy(&iso_bc_addr.bc_bdaddr, device_get_address(data->device), - sizeof(bdaddr_t)); - iso_bc_addr.bc_bis[0] = 1; - iso_bc_addr.bc_num_bis = 1; + if (req->in_progress == TRUE) + *((bool *)user_data) = TRUE; +} - DBG("stream %p", stream); +static int short_lived_pa_sync(struct bap_bcast_pa_req *req); +static void pa_and_big_sync(struct bap_bcast_pa_req *req); - /* If IO already set skip creating it again */ - if (bt_bap_stream_get_io(stream) || data->listen_io) - return; +static gboolean pa_idle_timer(gpointer user_data) +{ + struct bap_bcast_pa_req *req = user_data; + bool in_progress = FALSE; - io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, setup, NULL, &err, - BT_IO_OPT_SOURCE_BDADDR, - btd_adapter_get_address(data->adapter), - BT_IO_OPT_DEST_BDADDR, - device_get_address(data->device), - BT_IO_OPT_DEST_TYPE, - btd_device_get_bdaddr_type(data->device), - BT_IO_OPT_MODE, BT_IO_MODE_ISO, - BT_IO_OPT_QOS, &qos->bcast, - BT_IO_OPT_ISO_BC_NUM_BIS, iso_bc_addr.bc_num_bis, - BT_IO_OPT_ISO_BC_BIS, iso_bc_addr.bc_bis, - BT_IO_OPT_INVALID); - if (!io) { - error("%s", err->message); - g_error_free(err); + /* Handle timer if no request is in progress */ + queue_foreach(bcast_pa_requests, check_pa_req_in_progress, + &in_progress); + if (in_progress == FALSE) { + req = queue_peek_head(bcast_pa_requests); + if (req != NULL) + switch (req->type) { + case BAP_PA_SHORT_REQ: + DBG("do short lived PA Sync"); + short_lived_pa_sync(req); + break; + case BAP_PA_BIG_SYNC_REQ: + DBG("do PA Sync and BIG Sync"); + pa_and_big_sync(req); + break; + } } - setup->io = io; - data->listen_io = io; + return TRUE; +} + +static void setup_accept_io_broadcast(struct bap_data *data, + struct bap_setup *setup) +{ + struct bap_bcast_pa_req *pa_req = new0(struct bap_bcast_pa_req, 1); + + /* Add this request to the PA queue. + * We don't need to check the queue here and the timer, as we cannot + * have BAP_PA_BIG_SYNC_REQ before a short PA (BAP_PA_SHORT_REQ) + */ + pa_req->type = BAP_PA_BIG_SYNC_REQ; + pa_req->in_progress = FALSE; + pa_req->data.setup = setup; + queue_push_tail(bcast_pa_requests, pa_req); } + static void setup_create_ucast_io(struct bap_data *data, struct bap_setup *setup, struct bt_bap_stream *stream, @@ -2037,10 +1964,10 @@ done: if (bt_bap_pac_get_type(setup->ep->lpac) == BT_BAP_BCAST_SOURCE) setup_connect_io_broadcast(data, setup, stream, &iso_qos); else - setup_listen_io_broadcast(data, setup, stream, &iso_qos); + setup_accept_io_broadcast(data, setup); } -static void setup_create_io(struct bap_data *data, struct bap_setup *setup, +static bool setup_create_io(struct bap_data *data, struct bap_setup *setup, struct bt_bap_stream *stream, int defer) { DBG("setup %p stream %p defer %s", setup, stream, @@ -2060,6 +1987,15 @@ static void setup_create_io(struct bap_data *data, struct bap_setup *setup, setup_create_bcast_io(data, setup, stream, defer); break; } + + /* The function succeeds if the IO was created, but for BAP Broadcast + * Sink the call is asynchronous, as it is handled by the Idle timer + */ + if (setup->io || + bt_bap_pac_get_type(setup->ep->lpac) == BT_BAP_BCAST_SINK) + return TRUE; + + return FALSE; } static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, @@ -2091,8 +2027,7 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, break; case BT_BAP_STREAM_STATE_CONFIG: if (setup && !setup->id) { - setup_create_io(data, setup, stream, true); - if (!setup->io) { + if (!setup_create_io(data, setup, stream, true)) { error("Unable to create io"); if (old_state != BT_BAP_STREAM_STATE_RELEASING) bt_bap_stream_release(stream, NULL, @@ -2415,32 +2350,23 @@ static void bap_detached(struct bt_bap *bap, void *user_data) bap_data_remove(data); } -static int bap_bcast_probe(struct btd_service *service) +static int short_lived_pa_sync(struct bap_bcast_pa_req *req) { + struct btd_service *service = req->data.service; struct btd_device *device = btd_service_get_device(service); struct btd_adapter *adapter = device_get_adapter(device); struct btd_gatt_database *database = btd_adapter_get_database(adapter); struct bap_data *data = btd_service_get_user_data(service); - char addr[18]; - - ba2str(device_get_address(device), addr); - - if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) { - error("BAP requires ISO Socket which is not enabled"); - return -ENOTSUP; - } + GError *err = NULL; - /* Ignore, if we were probed for this device already */ if (data) { - error("Profile probed twice for the same device!"); - return -EINVAL; + DBG("Already probed"); + return -1; } - data = bap_data_new(device); data->service = service; data->adapter = adapter; data->device = device; - data->bap = bt_bap_new(btd_gatt_database_get_db(database), btd_gatt_database_get_db(database)); if (!data->bap) { @@ -2457,15 +2383,137 @@ static int bap_bcast_probe(struct btd_service *service) bap_data_add(data); data->ready_id = bt_bap_ready_register(data->bap, bap_ready, service, - NULL); + NULL); data->state_id = bt_bap_state_register(data->bap, bap_state, - bap_connecting, data, NULL); + bap_connecting, data, NULL); data->pac_id = bt_bap_pac_register(data->bap, pac_added_broadcast, - pac_removed_broadcast, data, NULL); + pac_removed_broadcast, data, NULL); bt_bap_set_user_data(data->bap, service); - bt_bap_new_bcast_source(data->bap, device_get_path(device)); + DBG("Create PA sync with this source"); + req->in_progress = TRUE; + data->listen_io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, req, + NULL, &err, + BT_IO_OPT_SOURCE_BDADDR, + btd_adapter_get_address(data->adapter), + BT_IO_OPT_DEST_BDADDR, + device_get_address(data->device), + BT_IO_OPT_DEST_TYPE, + btd_device_get_bdaddr_type(data->device), + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_QOS, &bap_sink_pa_qos, + BT_IO_OPT_INVALID); + if (!data->listen_io) { + error("%s", err->message); + g_error_free(err); + } + + return 0; +} + +static void iso_do_big_sync(GIOChannel *io, void *user_data) +{ + GError *err = NULL; + struct bap_bcast_pa_req *req = user_data; + struct bap_setup *setup = req->data.setup; + struct bap_data *data = setup->ep->data; + struct sockaddr_iso_bc iso_bc_addr; + struct bt_iso_qos qos; + + DBG("PA Sync done, do BIG Sync"); + g_io_channel_unref(setup->io); + setup->io = NULL; + + setup->io = io; + g_io_channel_ref(setup->io); + + /* TODO + * We can only synchronize with a single BIS to a BIG. + * In order to have multiple BISes targeting this BIG we need to have + * all the BISes before doing this request. This request is triggered + * by an endpoint "SetConfiguration" command. For multiple BISes + * we need another way to specify which BISes user is requesting + */ + iso_bc_addr.bc_bdaddr_type = btd_device_get_bdaddr_type(data->device); + memcpy(&iso_bc_addr.bc_bdaddr, device_get_address(data->device), + sizeof(bdaddr_t)); + iso_bc_addr.bc_bis[0] = 1; + iso_bc_addr.bc_num_bis = 1; + + /* Set the user requested QOS */ + bt_bap_bcast_qos_bap_to_iso(&qos, &setup->qos); + if (!bt_io_set(setup->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, + iso_bcast_confirm_cb, + req, NULL, &err, + BT_IO_OPT_ISO_BC_NUM_BIS, + iso_bc_addr.bc_num_bis, BT_IO_OPT_ISO_BC_BIS, + iso_bc_addr.bc_bis, BT_IO_OPT_INVALID)) { + error("bt_io_bcast_accept: %s", err->message); + g_error_free(err); + } +} + +static void pa_and_big_sync(struct bap_bcast_pa_req *req) +{ + GError *err = NULL; + struct bap_setup *setup = req->data.setup; + struct bap_data *data = setup->ep->data; + + req->in_progress = TRUE; + + DBG("Create PA sync with this source"); + setup->io = bt_io_listen(NULL, iso_do_big_sync, req, + NULL, &err, + BT_IO_OPT_SOURCE_BDADDR, + btd_adapter_get_address(data->adapter), + BT_IO_OPT_DEST_BDADDR, + device_get_address(data->device), + BT_IO_OPT_DEST_TYPE, + btd_device_get_bdaddr_type(data->device), + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_QOS, &bap_sink_pa_qos, + BT_IO_OPT_INVALID); + if (!setup->io) { + error("%s", err->message); + g_error_free(err); + } +} + +static int bap_bcast_probe(struct btd_service *service) +{ + struct btd_device *device = btd_service_get_device(service); + struct btd_adapter *adapter = device_get_adapter(device); + struct bap_bcast_pa_req *pa_req = + new0(struct bap_bcast_pa_req, 1); + + if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) { + error("BAP requires ISO Socket which is not enabled"); + return -ENOTSUP; + } + + /* First time initialize the queue and start the idle timer */ + if (bcast_pa_requests == NULL) { + bcast_pa_requests = queue_new(); + pa_timer_id = g_timeout_add_seconds(PA_IDLE_TIMEOUT, + pa_idle_timer, NULL); + } + + /* Enqueue this device advertisement so that we can do short-lived + */ + DBG("enqueue service: %p", service); + pa_req->type = BAP_PA_SHORT_REQ; + pa_req->in_progress = FALSE; + pa_req->data.service = service; + queue_push_tail(bcast_pa_requests, pa_req); + return 0; } diff --git a/src/shared/bap.c b/src/shared/bap.c index 19e40e3c70f4..3dadb9063b35 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -1677,11 +1677,8 @@ static unsigned int bap_bcast_config(struct bt_bap_stream *stream, bt_bap_stream_func_t func, void *user_data) { stream->qos = *qos; - if (stream->lpac->type == BT_BAP_BCAST_SINK) { - if (data) - stream_config(stream, data, NULL); - stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG); - } + stream->lpac->ops->config(stream, stream->cc, &stream->qos, + ep_config_cb, stream->lpac->user_data); return 1; } @@ -5255,10 +5252,6 @@ bool bt_bap_stream_set_user_data(struct bt_bap_stream *stream, void *user_data) stream->user_data = user_data; - if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) - stream->lpac->ops->config(stream, stream->cc, &stream->qos, - ep_config_cb, stream->lpac->user_data); - return true; }