From patchwork Wed Nov 20 10:25:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 844568 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2088.outbound.protection.outlook.com [40.107.241.88]) (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 5AB8919ABA3 for ; Wed, 20 Nov 2024 10:26:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098384; cv=fail; b=rMi2NBLJJiDO9LRhz/lkD9l1gEeVsytXnb4T6bcXgyMm/oDtOgFAHqPHqXa5zg04X/K6yM0GdQhvXNFl91+qRDO9QQChQF9T516n6EWNXWIEP6v81VE2kHCj1tGMT9OpJ0DFP0Wc42XRdqY3/TQS+WY/P3x6glYly9TA+ModQXI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098384; c=relaxed/simple; bh=OOqmAF8Deik0zNLaQrUFgCc3EHiKXm6NQy7IHLYgHpw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Tz1OWxVKMDvTRnI5u/C14E98Ky7qjGerF+PMdOaC6s0XNwfz5OxjjPQPGDZPaAqhibn6OhcDiu+1o7n+doXi091/xyk+/9Vc0OHypRUsXI74qI/MbCRZqhnwBCpBKv0My5odwig3caLex23CZeSCishTA5sULvfibakMbQWbkXM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=f2427rK7; arc=fail smtp.client-ip=40.107.241.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="f2427rK7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u3rkabF8hVgTjbjlwrhh6FJS0Js7rV6JNchtJU029BBNVcYjbDfsdiATzUa6HAWOCOI2g+NiQSJv/JtMMZ5jOFIXzYGKsw5/bykXujsGXhD8nMMVRgtAaxtHjykZqZscj8O/s1tUxpgJ3psaD9Ccaab4ntWismFTC7pqVWKEPkpzE5ddeO4TsEvESlz9IrwSzue3usB7Xs8n51+Q9sgi1EBZAdExi924F5QowRI5dWZ0hReFNMZYeI/pDEW0GUIvdkhJ5xcvSz0HQHGzuzaHuCYrRN49CUnNS0Bj3ij/rOdoTlIqkqnF2uArCtvTQUQ9pk/wmcmHryRATpwJTFRCjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yv+iviCXdxM/4XPlJW6QWcbAojIy5C6JsDiZEIIpnX4=; b=uJbGn7LjPcX1nRXJtRr5YVcM/K+A6asb6gPZych7R/Nu6vglGIURNiPlsQD01+ujKorEGrNxF9rrakQ/HpxyvMZoxomgedES1Hc5BbTrGg4p7NHGcuRRqxrzP3W8KuLzvH8FBQYRxb1m3Fne69MVeGCviqTTVzU2R2u3iZOLk1n7y01a0f7AhfRgbcq8RJsVama/HrYYe/77o4wLZbTa2TNVYXIlihB7n2js7mgQaUn28jqAGPDrDxYpG2yCPz1EhpagKh3m0Besr8nROJNWS1N2sTH6dVdCVvAA0oyV01+BLlvmFNcBBz9zda23svfZNZayU8SUnzCkdNuL503aKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yv+iviCXdxM/4XPlJW6QWcbAojIy5C6JsDiZEIIpnX4=; b=f2427rK71VCX1OOUd2VQGquM9e9JPwojeyGlG/0gMdIF1z/nohRlYlpeGV/57geEI5e2QpbQpsuzrmV4fyAoyyTFISmhAJhErJEPEFXNMtf/DnGOlC8J841Wd41IwQHqCOqs2gjbMuOLm4lP2yNTa/gFjXV9a1EDTY4kj/HCZn0/zsCX4Xtut7RM8C99Aj7iboEw//hyycJNWJDB1ahWWFEyOHRwOSPWQETUdHwA3hBYMlFe3zcasyeDG+Fmz7slShX/+dalilA5ccMNKYeLhFLRB87L5ipL7/nG+zpcvQDGuIf6A5a8AC42rkVZ41JfBraX//pluws+1IatYWMYng== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DU2PR04MB8904.eurprd04.prod.outlook.com (2603:10a6:10:2e3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Wed, 20 Nov 2024 10:26:15 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8158.023; Wed, 20 Nov 2024 10:26:15 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 1/7] shared/bap: Add helper to parse BASE Date: Wed, 20 Nov 2024 12:25:55 +0200 Message-ID: <20241120102601.38415-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241120102601.38415-1-iulia.tanasescu@nxp.com> References: <20241120102601.38415-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM0PR02CA0179.eurprd02.prod.outlook.com (2603:10a6:20b:28e::16) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DU2PR04MB8904:EE_ X-MS-Office365-Filtering-Correlation-Id: a1184df0-2584-4022-ff51-08dd094dc3a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: oM+mkTBRYQoRFdlKWCJiJWXDxcymemuUYDOlAtWbhgGx2Mi9HFZB4RxidhgI9HVMhCgWGtXKnjommJ5sFUHXt03ojqDaM7EjVWUJsQ7gkQ+rM3GzsrFSAvKNhBeAjjZF3+LV0pjb3WZWVwHEir+svEDzrSRIm2ElAtYBaxjUVZyzKyERP2SgobbXLKDt8OLP6rVM3Ta/f/7rSxaSuCbhzENIVgvm6SunqdP2I+yA4oASikrvKj9N0Io+MrgwSV70mYlcJ8QwCwA6pM5qR2FjYurT6emLCDrSIQHpMXhH3EKhtArWj+KcDtGgG79ngXYjjoeEt37pNjA/Bbg5ROQIXoM4idIO32twmij1t/y6a27WH1c8pQt3YKdu9YfCSJBqrGKIF2L+fYKQ2h7HgTL2l7Bv17DWdjP+/mLu36qzkpAO3EZgU/wH8GWgivOKFIEGA4t/reK2djeMMHWvf6+dBXU8gtsXNYZuEKp8Y6dr0Wpx1KZ6KkZEZpcWbG8KdEDAKBWAm/WaYkFduqpqLgJzEw/pD6ngAcGtm7H3IU6ok0Aa+yvybEk3Po0d5B9Ax2XrKx67pu/EXWXeEW1IYA1+hD0p8L2vZ0ohi/0UQXHbK0FT+JzbnPh23S2oHaTVs1dbxMdKxsvkOWFAzokayCzc3EuNWSAc5XRygLihSapuF3eLwcrbjAjsP1VFsK1ONUwblpXs4GMzrXnbks+Flax0fQvJ06F24dxZKfdGYVYxVUgzC41y1J9Gd3uJLDLyy5EupretoCabfN+UIEysQ0JquDaGq/L7dfw7nB6FyIo4lb14sYypf/SsPfqFJezcq23fhUNebDvRbkiyy51NExuJ/8WVzTDnJFLtP5vWlWk39elzKHm/oMc8uN3Qi3hM+3iLaf+F71nAPfz4OM6+ene/RHfkx6oLtogsERi02imJEOh6J6+ZfyA8TSXcs0xesaZbI9886IJNEcN17AAhUirv4b/w7Vsq+8Hmc4/AhQo5QNpQNzsO1rzcMS/8D+bH3x3nVRraRcfFQCbBuGKQKdJheOECPBGasc5t4V/Wl42y3D/XU0F2sLSVPoaRKPoNAYlAJhRL+KweJETqSUiEH0yW5PuloiiCXxwwC88PEo1+ljE3funWwzEIPuMAzHz74fZOf/hPmYcZ9c972QJVRjZgGv8s/8BzG9fXCaCLWPbM+eXHrMDk6LrG6j5iv4/0SVSO890vAU/Z/yBWRMndIEXP1uqBwgYkeAvuIiqC4tFFI/z/5UETmPy5TytCtGKPCg6XmxSYN7+WIcJ5jgo06U/gHzEt/9tQc8W3q3s44kOHnJiUEvflXdNJpS31VqpXGHnq X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-Anti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JCs7qvhD8EJSE0fs3XvH6sKGFSMK0RvX59xmhLR7zEJ9KS2Z1rK/Sth+l9HLIYxTQBXtzHLssNynAs6btNd+07su3fZRmh4O4TbwggH6NTp1X6zXm4I5vRgaFS/7BR56GOKwv/EajsVtOaS0zu9PrFfS3DOCRb2t8OaBCwreu5J9E+hueQKDYyCToMfK7ACJam8sdcCQ0Ok0omlDs9ff5jBlb9/R9tfrxEKtWWim4exSBvaM/GJzkQz6S+Gv8Gu+YIQW6ttrOtWBay0fT85lGoPaJykSlL1PMxu8N7dY3ywBeNt1QS8iaBWeNKsyZ3pIO8fvQQPrOoIOVJeFJzvqbVDfr67owJlC4CmTQU1KJtyHDEIuyZ1/PB6ZZNiwz3uDH5S+3BRCYYNy4HoF2+wtjPeHe/Dh8weV3sEFVG3b+Ama75XViciFgJI0yxloV0Eh0ojRavwMRwh8niXu/w3khv46c2ymgO0Ni9rm4KtpainGOBqNn1pIR8X+5hlNIlWYQfg0XYgUo8RWpF7p84s+Hx/uNXytfgIHVKHhM3Sh0w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1184df0-2584-4022-ff51-08dd094dc3a2 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2024 10:26:15.6962 (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: U0oFyaSFTNb7tlc4T5kyuW8Zz0ejR0x10EC4+qQkOEUwpYe8ofL5y2+k5A0rx6vbdv+c/zwbErZus4VZLWF07w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8904 This adds a shared/bap helper to parse BASE. Any plugin that wishes to parse a BASE structure can call this helper and provide a callback to process each BIS. --- src/shared/bap.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++ src/shared/bap.h | 10 ++++ 2 files changed, 135 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index 658ee1370..167501282 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -7067,3 +7067,128 @@ void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index, } } + +bool bt_bap_parse_base(struct iovec *iov, + struct bt_bap_qos *qos, + util_debug_func_t func, + bt_bap_bis_func_t handler, + void *user_data) +{ + uint32_t delay; + uint8_t sgrps; + bool ret = true; + + util_debug(func, NULL, "BASE len: %ld", iov->iov_len); + + if (!util_iov_pull_le24(iov, &delay)) + return false; + + util_debug(func, NULL, "PresentationDelay: %d", delay); + + if (!util_iov_pull_u8(iov, &sgrps)) + return false; + + util_debug(func, NULL, "Number of Subgroups: %d", sgrps); + + /* Loop subgroups */ + for (int idx = 0; idx < sgrps; idx++) { + uint8_t num_bis; + struct bt_bap_codec *codec; + struct iovec l2_cc; + uint8_t l2_cc_len; + struct iovec meta; + uint8_t meta_len; + + util_debug(func, NULL, "Subgroup #%d", idx); + + if (!util_iov_pull_u8(iov, &num_bis)) { + ret = false; + goto done; + } + + util_debug(func, NULL, "Number of BISes: %d", num_bis); + + codec = util_iov_pull_mem(iov, sizeof(*codec)); + + util_debug(func, NULL, "Codec: ID %d CID 0x%2.2x VID 0x%2.2x", + codec->id, codec->cid, codec->vid); + + /* Level 2 */ + /* Read Codec Specific Configuration */ + if (!util_iov_pull_u8(iov, &l2_cc_len)) { + ret = false; + goto done; + } + + l2_cc.iov_base = util_iov_pull_mem(iov, l2_cc_len); + l2_cc.iov_len = l2_cc_len; + + /* Print Codec Specific Configuration */ + util_debug(func, NULL, "CC len: %ld", l2_cc.iov_len); + bt_bap_debug_config(l2_cc.iov_base, l2_cc.iov_len, + func, NULL); + + /* Read Metadata */ + if (!util_iov_pull_u8(iov, &meta_len)) { + ret = false; + goto done; + } + + meta.iov_base = util_iov_pull_mem(iov, meta_len); + meta.iov_len = meta_len; + + /* Print Metadata */ + util_debug(func, NULL, "Metadata len: %i", + (uint8_t)meta.iov_len); + bt_bap_debug_metadata(meta.iov_base, meta.iov_len, + func, NULL); + + /* Level 3 */ + for (; num_bis; num_bis--) { + uint8_t bis_index; + struct iovec l3_cc; + uint8_t l3_cc_len; + struct iovec *bis_cc; + + if (!util_iov_pull_u8(iov, &bis_index)) { + ret = false; + goto done; + } + + util_debug(func, NULL, "BIS #%d", bis_index); + + /* Read Codec Specific Configuration */ + if (!util_iov_pull_u8(iov, &l3_cc_len)) { + ret = false; + goto done; + } + + l3_cc.iov_base = util_iov_pull_mem(iov, + l3_cc_len); + l3_cc.iov_len = l3_cc_len; + + /* Print Codec Specific Configuration */ + util_debug(func, NULL, "CC Len: %d", + (uint8_t)l3_cc.iov_len); + + bt_bap_debug_config(l3_cc.iov_base, + l3_cc.iov_len, + func, NULL); + + bis_cc = bt_bap_merge_caps(&l2_cc, &l3_cc); + if (!bis_cc) + continue; + + handler(bis_index, idx, bis_cc, &meta, + qos, user_data); + + util_iov_free(bis_cc, 1); + } + } + +done: + if (!ret) + util_debug(func, NULL, "Unable to parse Base"); + + return ret; +} diff --git a/src/shared/bap.h b/src/shared/bap.h index 126348e81..200dc8f13 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -40,6 +40,10 @@ typedef void (*bt_bap_stream_func_t)(struct bt_bap_stream *stream, void *user_data); typedef void (*bt_bap_func_t)(struct bt_bap *bap, void *user_data); +typedef void (*bt_bap_bis_func_t)(uint8_t bis, uint8_t sgrp, + struct iovec *caps, struct iovec *meta, + struct bt_bap_qos *qos, void *user_data); + /* Local PAC related functions */ struct bt_bap_pac_qos { uint8_t framing; @@ -259,3 +263,9 @@ void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index, struct iovec *caps, struct bt_bap_pac **lpac); +bool bt_bap_parse_base(struct iovec *base, + struct bt_bap_qos *qos, + util_debug_func_t func, + bt_bap_bis_func_t handler, + void *user_data); + From patchwork Wed Nov 20 10:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 844775 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2088.outbound.protection.outlook.com [40.107.241.88]) (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 ECA48198E69 for ; Wed, 20 Nov 2024 10:26:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098387; cv=fail; b=PDNLy8gPLeX+2U9bP399am1mFs9G/UWYdeHi2ACBktfIJK1Co3I1eMYGbwrgKcRUwEqHac6Z5UGdgKPmx0eMIPqROJjTnTrttX/Qs6lMIEPNnVjR/1EQliw+h/nWoUm+huIIY/VG3cR8ROrxd2L4r6JaY0KEtYmkO3OnGjD4Yic= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098387; c=relaxed/simple; bh=8D4+T/Iz8nvPchRe//YkWZcB+4y5I1fVh6dktN8qVoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=XQnaCnGtrSV2TZv/n4vuS7/1971AVQNZ2URi7sUDjBfMZxGX1fdMl/UAdxSjjHclEfWv0n8OCNLPiAqgGIDhlVAv/u0q+xTNZOXmfqPoUKSKawAjFFEsB2tVGo9PpvDqhN0hiasrOCgBXKZ34bWNUGsYR95K6oM+GWf38ZLA/JM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=W1iB1hZS; arc=fail smtp.client-ip=40.107.241.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="W1iB1hZS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZaFPdJFsjHfzEBa/Z6iLRFqVivGo9S7xmyn2R4iPTLs/Vwe5k2l2jqoHkZ551pnfilY5Cw2t2Dbo5qKionQ2yv6irQGc2DEQp9TQYIko+HNhFgZBE4pAT/CdC3Y2eS0AM6Benz5JxqzsALuxm9hatbqWLvp14ryQNPqz/kKTGLc4f3+hUh08hMjY75HHRYtpWtdwV1rkyB3q5u7J305aczlmvXV8EkHTYJBkKroReLdTfWC4uDH0GVP4ltWCBG/5Jfhqx/fmW2LFMp5x4ZuuNMuQqxB6FfVuL3ckxkvDas+u+ZfVhl7T56zgaMzwOt8mQaKesd4a26+xoYmXvif0WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e7CCuEdhvRAy8h2vTX1QWI2klzZVTr9TMvz09+SHnZ8=; b=Zrt/xzwODWX9II8Iq10bYGJg6EksKKvyCpFcuYClQbakxTnzUIAgb7M8mtLLwX87w3OQyJfw46uvwLH2SYoXqlu4o0SVJVf0w04QA/pWXHYNGxmE1/i7BtZ6tnRIbOJZgJKCz3kO9lXVSromUQ+qkIyAWi4UkzyD3nSEVp5qUkjAQTKjhza+eouhkzfQTOLwMTldbMAXBZKTTxnRm7wDAuy510vjwI+90QMZ+rfv5Ojo8rPOj4iN6SGPrDYSv9gDPDvoe0ExZICPNepqd/vYFNryuQCkLH+r3c9GP/t/o7b9Ix45YWmGGUXFZ6mfe4jHFKxH+TfFP3aNVtSteyNsaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e7CCuEdhvRAy8h2vTX1QWI2klzZVTr9TMvz09+SHnZ8=; b=W1iB1hZSNveSIcpGCbgcVyKHvUSWlJLCgit9LnJ/4KCwS1uh64K8AscYem46nPOR5Zb595fDEOHmhy9cpiR8IrucI4AenwZSH3wcbEkafJl1vtz7PP+s0qYIWck4IAFNKoK7qYuiS5OodEbiwNMhpaBhFfJf6CfqXGqDIuCnVQkDRIEpo/jVvizP9b33Ck323i7t2uru1g3hdGGrkbL8zzwhB2LNsZlMWQR54lRAzC4aoxfFt1BR+xETW6cqYiSDy7XvgZdJ7Y0vQgvJVqJQIfpeCHeF4PkwmKhliINGIHuV/uq5rXsW25bNK34g+2DmMXdkDwzyN2KswCHqj0v3Hg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DU2PR04MB8904.eurprd04.prod.outlook.com (2603:10a6:10:2e3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Wed, 20 Nov 2024 10:26:18 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8158.023; Wed, 20 Nov 2024 10:26:18 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 2/7] bap: Add helpers to convert iso_qos to/from bap_qos Date: Wed, 20 Nov 2024 12:25:56 +0200 Message-ID: <20241120102601.38415-3-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241120102601.38415-1-iulia.tanasescu@nxp.com> References: <20241120102601.38415-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM0PR10CA0004.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::14) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DU2PR04MB8904:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a46f631-68fa-4a85-2d3c-08dd094dc565 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: a8SlE/i+NV06Pbm69lAwxR8lpFiYyAc0G2pgPiah1qbMQW5wc7gjM2WeZUnyMW1/SONf0eZGuSHc/KG0GapoMAUVu8vzn54csftjwmID/Ap+ylhFgTSjVrNtHiMwq2378CDhcX6R+I02ph0dnKpgz1qPQ07jOjI5sYce1rmzNGtg9AUhUkwGMWr7T/VXqE+Cy0ZdBVPPodcIldg0dQFbzC48j4kDZC2XoW7AVFSPoap+JFTj9P7icyQP/0SROsaISxFG5v/NdSfYujcx6ZcJLckw4iAVVahI7aN8IewMoKHUJPTRyV49SKPLE5yXMO6zx2ViFOOcNQg/JOV2AN+tnLNwb20GKaxLh1RvIVpwDHlCTkFxjF2eujBQopCoQ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ONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DfxO3D/holKoo4Yoph7iiosJpR85fkE7U3F0PSlBE6jv30DaL0I506gg5d1b0E2okHhOvJrKDnBOFfPz1uB8OBHWTi2B0iQY/0DS6uJVWSQ1XGwTilf+IwbdkXcfSABw2gWEFUNkkws/wPJxj0mXzZY299azKRYZ2OJjlOADvGUZDKszya0Ec630rLnvJYnktsNBXRDRO4WiHA0NXZMXqBoatT4pafY70dpEbtxoAIE1WLgE6fus9AfI12Q6zR3B0WHepjnOnhCqYBU+NK6lSOHLbOUd5eja6KifpTVSlOAIDXAJPIJol2WKhqRls4eJG1s/t1qhAO+TUTyh0kW9InTJMpdGxB7tY+l/1JhXk1IIhcXYodMb+4vndgP36A2OjOaAm6UHMYVQ13VFi+BDjxGOVSddT6WCWFbkYwJKroZ7knNF6hZckge1ZfCys8f6qsk+a88ANdzWyRY5m520wZp5rWvPvqU19opg8ykWDLH0nQuzxAukIw9UKDCYHkXi4J8ZWXaXTgG+ntZQ9zcjvBL/AgUfmxyIzRg8sQj9UPxFf3xODi1Tf+PE2XSC1rt/ysSX3b9PFE9506BP3ojEFI6Mx45PHJX9oRIMApAbO9nJ06WV7+fL3lEBLtQtfF50XFoQXype8882fgkdPSxVtt4Svi5+lFsCsdH78upHSPatqmrYN3lUoMvizxorATbhkyjkNgwmOL/6dO6caZ25DewC2iGzgJGI7GBhq4ME/rnKgdqB2WuFjwg1vzgUdKzrANvvkytCDf+EABteahONoCZq8yCfV2yAUvcRmpJdjl3/iWP3EhHux1HjD/JP6Ja5c1SSq4dv+jbdHV1p27PMJgT7CN6D2GBQFtJfU+TUAQuqUnQ3RmDGPOvV94CifRj6iblulVIq/ALgSdkO3pwg7+BlYxKWHTaDAuH9Tk7GshkXolkgyYgOqk85yDjQptb294T0VWJKfdqhfj8PNvCM8tcUPiet7J5XYY2P8HyR8J6fGA4xNkR+JxTBxCVVldDf2sa6dZuIRbM0ja9CRWnpKB+rq1HWdeysJZdYrGmvlYgkW8FovnZBWDuziA4ZUpJzOg+IAHiPMa/qPWcF5DAqhGKYvNKVo2Hwk0JOBwLN4T+S9Y7I1Fn0N4JPwqLBFUkpHs5Oo3goFscABe16oyMCnBb5cP3uoanHP+PyX/0p0SqsfAeiL/eagDVKzvSvnagR2nqGV6en0h3Usanu1F9+ZUHxnI0lWbdB24aOIwFRnSTUer7UL9bCF021G06EJmHgp8SXASfE6yzbNB94uoUlhC9qZ/7JfioH5zAEdM4kHL8p6IU60+NA8tcEfIA9lbq7rr7JhbyM1Fgnh7lIBDX3LgywfCiQPAtXNmThNEcBQrgKo5EdmJYjK7teHHF/xTxhvLuwV3RlKWnWHIygDXT35M+5iiPE7X13stCjJDMBUSTbhdVXqJCSpoSHOZ3nkVc8vQwh5ojV5gnZUuch03HqOS7QQ/pC88bjpTXKcAE1HSNPpnYwreMEJYz5HgYhygyU1j7SIaHdKz09UQy5BHukA985IPzSC73z+jYsyXwZYgQHonE6YWfHrJVzsb0quUrZbbXvwKNbHh+K2iCZQFBBEA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a46f631-68fa-4a85-2d3c-08dd094dc565 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2024 10:26:18.7185 (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: qSfDC/5hK3j1UvRwRE4Kv9nA+FUFCFk/PJ+DSY2M91JWv+bRx3PoUaHEaNRDSYPArJVDTGSSaDpKCeY61qjUeg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8904 This adds public BAP helpers to convert iso_qos to bap_qos and reversed. This is needed for the BASS plugin to handle the Scan Delegator (BASS Server) role internally (to create/handle BAP streams when receiving the Add Source command from a Broadcast Assistant). --- profiles/audio/bap.c | 93 +++++++++++++++++++++++++------------------- profiles/audio/bap.h | 5 +++ 2 files changed, 58 insertions(+), 40 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index df685c6d3..6acb0895c 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1041,6 +1041,57 @@ static void print_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, util_hexdump(' ', v, l, user_data, NULL); } +void bap_qos_to_iso_qos(struct bt_bap_qos *bap_qos, + struct bt_iso_qos *iso_qos) +{ + memset(iso_qos, 0, sizeof(*iso_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)); +} + +void bap_iso_qos_to_bap_qos(struct bt_iso_qos *iso_qos, + struct bt_bap_qos *bap_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.encryption) + bap_qos->bcast.bcode = util_iov_new(iso_qos->bcast.bcode, + sizeof(iso_qos->bcast.bcode)); + 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; + bap_qos->bcast.io_qos.interval = + iso_qos->bcast.in.interval; + bap_qos->bcast.io_qos.latency = iso_qos->bcast.in.latency; + bap_qos->bcast.io_qos.phy = iso_qos->bcast.in.phy; + bap_qos->bcast.io_qos.rtn = iso_qos->bcast.in.rtn; + bap_qos->bcast.io_qos.sdu = iso_qos->bcast.in.sdu; +} + static void create_stream_for_bis(struct bap_data *bap_data, struct bt_bap_pac *lpac, struct bt_iso_qos *qos, struct iovec *caps, struct iovec *meta, char *path) @@ -1050,28 +1101,7 @@ static void create_stream_for_bis(struct bap_data *bap_data, setup = setup_new(NULL); /* Create BAP QoS structure */ - setup->qos.bcast.big = qos->bcast.big; - setup->qos.bcast.bis = qos->bcast.bis; - setup->qos.bcast.sync_factor = qos->bcast.sync_factor; - setup->qos.bcast.packing = qos->bcast.packing; - setup->qos.bcast.framing = qos->bcast.framing; - setup->qos.bcast.encryption = qos->bcast.encryption; - if (setup->qos.bcast.encryption) - setup->qos.bcast.bcode = util_iov_new(qos->bcast.bcode, - sizeof(qos->bcast.bcode)); - setup->qos.bcast.options = qos->bcast.options; - setup->qos.bcast.skip = qos->bcast.skip; - setup->qos.bcast.sync_timeout = qos->bcast.sync_timeout; - setup->qos.bcast.sync_cte_type = - qos->bcast.sync_cte_type; - setup->qos.bcast.mse = qos->bcast.mse; - setup->qos.bcast.timeout = qos->bcast.timeout; - setup->qos.bcast.io_qos.interval = - qos->bcast.in.interval; - setup->qos.bcast.io_qos.latency = qos->bcast.in.latency; - setup->qos.bcast.io_qos.phy = qos->bcast.in.phy; - setup->qos.bcast.io_qos.rtn = qos->bcast.in.rtn; - setup->qos.bcast.io_qos.sdu = qos->bcast.in.sdu; + bap_iso_qos_to_bap_qos(qos, &setup->qos); queue_push_tail(bap_data->bcast_snks, setup); @@ -3158,24 +3188,7 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) queue_foreach(setups, setup_refresh_qos, NULL); /* Set the user requested QOS */ - memset(&qos, 0, sizeof(qos)); - qos.bcast.big = setup->qos.bcast.big; - qos.bcast.bis = setup->qos.bcast.bis; - qos.bcast.sync_factor = setup->qos.bcast.sync_factor; - qos.bcast.packing = setup->qos.bcast.packing; - qos.bcast.framing = setup->qos.bcast.framing; - qos.bcast.encryption = setup->qos.bcast.encryption; - if (setup->qos.bcast.bcode && setup->qos.bcast.bcode->iov_base) - memcpy(qos.bcast.bcode, setup->qos.bcast.bcode->iov_base, - setup->qos.bcast.bcode->iov_len); - qos.bcast.options = setup->qos.bcast.options; - qos.bcast.skip = setup->qos.bcast.skip; - qos.bcast.sync_timeout = setup->qos.bcast.sync_timeout; - qos.bcast.sync_cte_type = setup->qos.bcast.sync_cte_type; - qos.bcast.mse = setup->qos.bcast.mse; - qos.bcast.timeout = setup->qos.bcast.timeout; - memcpy(&qos.bcast.out, &setup->qos.bcast.io_qos, - sizeof(struct bt_iso_io_qos)); + bap_qos_to_iso_qos(&setup->qos, &qos); if (!bt_io_set(io, &err, BT_IO_OPT_QOS, &qos, diff --git a/profiles/audio/bap.h b/profiles/audio/bap.h index cfe633311..2968f6216 100644 --- a/profiles/audio/bap.h +++ b/profiles/audio/bap.h @@ -9,3 +9,8 @@ struct bt_bap *bap_get_session(struct btd_device *device); void bap_scan_delegator_probe(struct btd_device *device); + +void bap_iso_qos_to_bap_qos(struct bt_iso_qos *iso_qos, + struct bt_bap_qos *bap_qos); +void bap_qos_to_iso_qos(struct bt_bap_qos *bap_qos, + struct bt_iso_qos *iso_qos); From patchwork Wed Nov 20 10:25:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 844567 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2043.outbound.protection.outlook.com [40.107.22.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1AAE19ABA3 for ; Wed, 20 Nov 2024 10:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098388; cv=fail; b=eTouQZTQJ2ffK3XgBulpvhuv8RqcbCpuQVIeN/XHqtyR4YgiOvh9xzKO/D/jaQDykRiJXtN+sM1AZqQHssC7wkw56edxRfuUPrTzNDy29m8i56pMEzoT8tmCSFsmZKCgW2wUkbtyWrXk0AE2TajmiM6LW0BH+tNTxYiWNOblPps= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098388; c=relaxed/simple; bh=nd89I5G5ALyXPoM5r6oP3XUJj0/eJvT7kIliZKRxUuw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=uw6eZHq1Rc0uyL0W7wHn0TPJB7zWaHPc2nxU2eOuPv0UNo3FtHtGd4bmqJrQ4ASQ6jxtVA6yjXfrXh62J+Lo1wEvpmKCe6oWwbUIsZJtvkNS6I+2lI5izyoJ8//StMAz83M7vWLL8mj2GRZ8PQoa8Q/k1g8Q8Mw0hZQCwm4ToxA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=hF5EZ2ZR; arc=fail smtp.client-ip=40.107.22.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="hF5EZ2ZR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VMM0SkQm09wcJmqNhWMOTH00Mn4BWSJHWfyifFtQW0Vnm6kDgOffavVla94hXJ1Z99PN5B3QW88y6dwoN7w1vFmGASMzmw2x9EfIEGA87bBb54u+qJjGr8puZ8l7dM3dH+fyW+KE1vIg3UqXtOyK9HICLvBHrRoif5sNovapzxTuyuwExd14D75YaeRsCmP+OEGw775czAQjWaomlqTIeWDjPT2gpoEFSI5GiWXgv4ypuyWRM5xK41f/7ZQ4d3OBO38XlZq242gfSkVllKMaI5+QeEXlDpsAIXb3E7JwveGfnB++PfBKrESl6dHGSylZ1BbGTprutzSeVaz3aOErrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2gesZWfGn9keodu/wYs5MwLhYNEVzE1s6U/gD38uZOw=; b=p8YIRzKDUzifELSY/whG9Y8OaZ4tCq7FozuXXxlWFQSDagaaLPssZkie5O8kINxJkzh2kgX1O36Ee5urJblBqOsBVaXCzUVMJXao9UOt0n7+usGCYL4ltH8/YPr5hUpcj+vpWGS48SNw1WfsOhi8UVaVyDf0Ns4gkySevLbhRvp+UGXBc29GEqTFuG/2yAXcFMk/slzm4FZZQd8glchFyEI8X1p5FF1zrFsBvkKJA3IOZ5fEdzLSvjT03mY86SK6od7NVleDpyCNAZqrHtzgV3fgPuPvoYbO2zCPk98BpIZ0W91zLrOK5sypJsx7lEjN2d9Vcf4XSk/3RjMenlBGrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2gesZWfGn9keodu/wYs5MwLhYNEVzE1s6U/gD38uZOw=; b=hF5EZ2ZRb74otKYWGCL2lKsh3Xg8/25Nw5qtT2ac4vVGAuOGk45+yatseKLzQZou9Mm5LM5Je/S11YUWToAnarUUE3C+67QA1PIeBHwfq10Kvu8LFA+fxaCfjkjx6ByQb1v3jV7sdL1k4qsZv2xu/T4tM3oN4EDsqvzUVMymo7rw8hnmM59J+Yv+Qii4ECaIQ305WCkl7m5hLCbfbsKmoW0egv4fjJL3rscbFr2oqquitopWXpNW39iBmc0aKwp/zcZPxrtvqf6AGywYo59Q4FRVsk7cr0x4BjVXVjfS/RaTqmeYDxEhk6bdzUuHiko8/KzF4tvt3yinX+Lt8C4Kag== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI0PR04MB10389.eurprd04.prod.outlook.com (2603:10a6:800:217::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Wed, 20 Nov 2024 10:26:21 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8158.023; Wed, 20 Nov 2024 10:26:21 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 3/7] bap: Rework BASE parsing Date: Wed, 20 Nov 2024 12:25:57 +0200 Message-ID: <20241120102601.38415-4-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241120102601.38415-1-iulia.tanasescu@nxp.com> References: <20241120102601.38415-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM0PR10CA0089.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:15::42) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI0PR04MB10389:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ce8bbde-c39a-49ac-8d13-08dd094dc720 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: FYVEmdlT+3ddpyBybbiTj5xCLw9SauyK56IyaMPm92C1ftCQniJMW6VAQdFZ7pgdJHNyApfqu4f/jbzuV3X2SBpTRGOHb6ho4VOAldaA2FPttXy+R1rIDqmMupihZW3bcyZsOv++yA/5a9ZbJbrv7z/t7wuxyiDwRiWfhIE2/sQ/LXjE+n9YfCitOOb2/nRMfunR86PN5cYa2T1Lf/E7GIfKam7KiYsScMpXGK5tOvjGTvQ5nzYqEtntgYo5Ab2WLaPhy4Rg2go7yYFO6fOMLYbp2as1QkDRlcGx+0H85womSnzES8/3T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255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rJABZRDKL444TLoXoE4ISJEmVWExTog4QgCSxYeJjqEQfP8nK1E+vx2P2XJ8XEMPZopOBXHrL5+rEPkEvTRNVtXZYbqb+HGnv79TkLhFbSnSL7rlovcc/XDmct9bRD1+SSrbP6O1NnW/eCvJZja56Egb4VdS0AB36UXJP07wGUWESMsRu+Q/uLL/HKC+XHW9Yv9ciix6bYFk98qS1+dcl6uuCYtZOjIE0HuhlBWRE/PFOGwzbd1Pth5A7LdFFPLJ1QVpXHcuLxOa+UKEauXvN2wEjB1mRhEdKeALtor/FYqRuPZfGSR0qOct02Tyj57/G5Ky/GMm8MWQ4z71y3qcevgUd86PUACPCW5k2w9cZQ6KXG+w97FJ30F+qmcmAPzv/hSoGlPuNTmxXXJ8MuObDVu1+0m9bhpaHvVi+NCgpOszW6vjde4yvVT3KjVafLT4DvFTw+lr8k5uTRj7Wa8gxPXaKHQbq2BIyvomgYOD2pDqpdU2cVtA7+cW+wSSMSaHw2mkSeZ79pj2s/xIojCl4PCdjFExCOAAc4/T8VetyL9dZycD2M2U3mH4HGXA6W8dK2WvYIzJobUqgQImB/izx7b9nkwijIsOAzQNtLGBtp7lt7OT+aevDg4z9u4OBVK5j5oW5yMCwhxL+LvrSH2q24R6tQmjWXCaKVxaKV9UGT70cfKbvyTApfh/QOdDD3K5zEB40uFNrIDTO/1XWrf1xeEh5fL/mlwjFD0+s7p/WtSA69lbpXDQnyxhjaeXGaBOW0uBMcJmhH32EtYf1BgNman3ssj+8e+8O5qxX4ei/fTrrp/JDvIsJVAdcc9bCozNgMsYiY6tAxvsf0mzpP4yDHzYOtdUMk71FKfWhmPXQ9pG8HyKQ7PC+m9l5Gi9aiYwLc0tIlwL//LSn2lK704eITaEIfI9aR+D1fyppIFMljvYJqYR88HB2U5LbmkySoosNZkgrn+kAW9/3OU1qUAHShz3xtQNp3x/oA0Tc106HKconEsAx4ytixJdKKESthbRtxVxw/6kcWBpnHFkgLNX1KngtWY7oOdasAMecx5Wguv0XuecX1hJidIJtnmWjpYEcoQtDaFJmD2Apk+JUHeF7Cq7pE3MocIkxfv14CcK6+f8q93tYO7WQtpTd7kxQrcnEq26BsuyBxWDzYy+sZ3/laC1zhEu+4oVig/vmbq3PcMrOoH3PZbjROWvxXKsOMkI8xM0bJ0gWFjM7NH4Km50kjmG0LCMYF4czwV4Yy0GQUfXS2UENSv8g6bzfVj+FqXPlzPb+ypBe8xHq7b0ZQ2XtvN6PH5PXdX7d1j9EuCc+0ka8OHHEk+O/GniGHXSzwciafk0WU+97vyjiKlPmxS2P8HTS462K4QK8FPdtfHDOmG+rrwvZ31YkdKFtd7DlTY0z4Wrs/5uzn2hhnWlu1nhpc/SmisJ0YeCZ+thBLBBG+qfM+tow9JlPZHge1XGlXVFUWz1EUaX7dhhXBaIR6xBJdQikVU3wmU6i1naRmlLuJI43DFhvERlNF/vcg1jD/oOSuXhVq2W71uCfcVea5mo+5mWwT6j3HzLaYEnAxNzGCpruCyRmDs1Rw9Kob82rZ7CvCKCrcatjwKzm0rNfcB0jw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ce8bbde-c39a-49ac-8d13-08dd094dc720 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2024 10:26:21.6753 (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: YsTTOwqVt2QgyrsNUUQv0mtt/k20bgRKaAs1AxUbtWLrjF6wjaPyPXkaRS3sxU9zHJYtU4L5VEOHNiq3tUY5kw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10389 This replaces the internal parse_base with bt_bap_parse_base from shared/bap. A bis callback is added to handle parsed streams. The Broadcast Assistant implementation in the BASS plugin is also updated to use bap qos instead of iso qos, since the BISes are now parsed along with bap qos structure. --- profiles/audio/bap.c | 207 ++++++++---------------------------------- profiles/audio/bass.c | 30 ++++-- profiles/audio/bass.h | 2 +- 3 files changed, 61 insertions(+), 178 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 6acb0895c..2a194d709 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1034,13 +1034,6 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) } } -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); -} - void bap_qos_to_iso_qos(struct bt_bap_qos *bap_qos, struct bt_iso_qos *iso_qos) { @@ -1093,15 +1086,16 @@ void bap_iso_qos_to_bap_qos(struct bt_iso_qos *iso_qos, } static void create_stream_for_bis(struct bap_data *bap_data, - struct bt_bap_pac *lpac, struct bt_iso_qos *qos, + struct bt_bap_pac *lpac, struct bt_bap_qos *qos, struct iovec *caps, struct iovec *meta, char *path) { struct bap_setup *setup; setup = setup_new(NULL); + setup->qos = *qos; - /* Create BAP QoS structure */ - bap_iso_qos_to_bap_qos(qos, &setup->qos); + /* Create an internal copy for bcode */ + setup->qos.bcast.bcode = util_iov_dup(qos->bcast.bcode, 1); queue_push_tail(bap_data->bcast_snks, setup); @@ -1116,170 +1110,37 @@ static void create_stream_for_bis(struct bap_data *bap_data, NULL, NULL); } -static bool parse_base(struct bap_data *bap_data, struct bt_iso_base *base, - struct bt_iso_qos *qos, util_debug_func_t func) +static void bis_handler(uint8_t bis, uint8_t sgrp, struct iovec *caps, + struct iovec *meta, struct bt_bap_qos *qos, void *user_data) { - struct iovec iov = { - .iov_base = base->base, - .iov_len = base->base_len, - }; - uint32_t pres_delay; - uint8_t num_subgroups; - bool ret = true; - - util_debug(func, NULL, "BASE len: %ld", iov.iov_len); - - if (!util_iov_pull_le24(&iov, &pres_delay)) - return false; - util_debug(func, NULL, "PresentationDelay: %d", pres_delay); - - if (!util_iov_pull_u8(&iov, &num_subgroups)) - return false; - util_debug(func, NULL, "Number of Subgroups: %d", num_subgroups); - - /* Loop subgroups */ - for (int idx = 0; idx < num_subgroups; idx++) { - uint8_t num_bis; - struct bt_bap_codec codec; - struct iovec *l2_caps = NULL; - struct iovec *meta = NULL; - - util_debug(func, NULL, "Subgroup #%d", idx); - - if (!util_iov_pull_u8(&iov, &num_bis)) { - ret = false; - goto fail; - } - util_debug(func, NULL, "Number of BISes: %d", num_bis); - - memcpy(&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", - codec.id, codec.cid, codec.vid); - - /* Level 2 */ - /* Read Codec Specific Configuration */ - l2_caps = new0(struct iovec, 1); - if (!util_iov_pull_u8(&iov, (void *)&l2_caps->iov_len)) { - ret = false; - goto group_fail; - } - - util_iov_memcpy(l2_caps, util_iov_pull_mem(&iov, - l2_caps->iov_len), - l2_caps->iov_len); - - /* Print Codec Specific Configuration */ - util_debug(func, NULL, "CC len: %ld", l2_caps->iov_len); - util_ltv_foreach(l2_caps->iov_base, l2_caps->iov_len, NULL, - print_ltv, func); - - /* Read Metadata */ - meta = new0(struct iovec, 1); - if (!util_iov_pull_u8(&iov, (void *)&meta->iov_len)) { - ret = false; - goto group_fail; - } - - util_iov_memcpy(meta, - util_iov_pull_mem(&iov, meta->iov_len), - meta->iov_len); - - /* Print Metadata */ - util_debug(func, NULL, "Metadata len: %i", - (uint8_t)meta->iov_len); - util_hexdump(' ', meta->iov_base, meta->iov_len, func, NULL); - - /* Level 3 */ - for (; num_bis; num_bis--) { - uint8_t bis_index; - struct iovec *l3_caps; - struct iovec *merged_caps; - struct bt_bap_pac *matched_lpac; - char *path; - int err; - - if (!util_iov_pull_u8(&iov, &bis_index)) { - ret = false; - goto group_fail; - } - - util_debug(func, NULL, "BIS #%d", bis_index); - err = asprintf(&path, "%s/bis%d", - device_get_path(bap_data->device), - bis_index); - if (err < 0) - continue; - - /* Read Codec Specific Configuration */ - l3_caps = new0(struct iovec, 1); - if (!util_iov_pull_u8(&iov, - (void *)&l3_caps->iov_len)) { - free(l3_caps); - free(path); - ret = false; - goto group_fail; - } - - util_iov_memcpy(l3_caps, - util_iov_pull_mem(&iov, - l3_caps->iov_len), - l3_caps->iov_len); - - /* Print Codec Specific Configuration */ - util_debug(func, NULL, "CC Len: %d", - (uint8_t)l3_caps->iov_len); - util_ltv_foreach(l3_caps->iov_base, - l3_caps->iov_len, NULL, print_ltv, - func); - - merged_caps = bt_bap_merge_caps(l2_caps, l3_caps); - if (!merged_caps) { - free(path); - continue; - } - - bass_add_stream(bap_data->device, meta, merged_caps, - qos, idx, bis_index); - - if (!bass_check_bis(bap_data->device, bis_index)) { - /* If this Broadcast Sink is acting as a Scan - * Delegator, only attempt to create streams - * for the BISes required by the peer Broadcast - * Assistant. - */ - continue; - } + struct bap_data *data = user_data; + struct bt_bap_pac *lpac; + char *path; - /* Check if this BIS matches any local PAC */ - bt_bap_verify_bis(bap_data->bap, bis_index, - merged_caps, &matched_lpac); + bass_add_stream(data->device, meta, caps, qos, sgrp, bis); - if (matched_lpac == NULL) { - free(path); - continue; - } + if (!bass_check_bis(data->device, bis)) + /* If this Broadcast Sink is acting as a Scan + * Delegator, only attempt to create streams + * for the BISes required by the peer Broadcast + * Assistant. + */ + return; - create_stream_for_bis(bap_data, matched_lpac, qos, - merged_caps, meta, path); - } + /* Check if this BIS matches any local PAC */ + bt_bap_verify_bis(data->bap, bis, + caps, &lpac); -group_fail: - if (l2_caps != NULL) - free(l2_caps); - if (meta != NULL) - free(meta); - if (!ret) - break; - } + if (!lpac) + return; -fail: - if (!ret) - util_debug(func, NULL, "Unable to parse Base"); + if (asprintf(&path, "%s/bis%d", + device_get_path(data->device), + bis) < 0) + return; - return ret; + create_stream_for_bis(data, lpac, qos, + caps, meta, path); } static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, @@ -1290,6 +1151,8 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, struct bap_data *data = btd_service_get_user_data(req->data.service); struct bt_iso_base base; struct bt_iso_qos qos; + struct iovec iov; + struct bt_bap_qos bap_qos = {0}; DBG("BIG Info received"); @@ -1329,7 +1192,15 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, /* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities */ - parse_base(data, &base, &qos, bap_debug); + iov.iov_base = base.base; + iov.iov_len = base.base_len; + + /* Create BAP QoS structure */ + bap_iso_qos_to_bap_qos(&qos, &bap_qos); + + bt_bap_parse_base(&iov, &bap_qos, bap_debug, bis_handler, data); + + util_iov_free(bap_qos.bcast.bcode, 1); service_set_connecting(req->data.service); diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index 6237f5acc..d3b35f62a 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -92,7 +92,7 @@ struct bass_assistant { uint8_t sgrp; uint8_t bis; uint32_t bid; - struct bt_iso_qos qos; + struct bt_bap_qos qos; struct iovec *meta; struct iovec *caps; enum assistant_state state; @@ -399,8 +399,8 @@ static int assistant_parse_qos(struct bass_assistant *assistant, return -EINVAL; } - memcpy(assistant->qos.bcast.bcode, iov.iov_base, - iov.iov_len); + util_iov_free(assistant->qos.bcast.bcode, 1); + assistant->qos.bcast.bcode = util_iov_dup(&iov, 1); return 0; } @@ -592,7 +592,12 @@ static gboolean get_qos(const GDBusPropertyTable *property, { struct bass_assistant *assistant = data; DBusMessageIter dict; - uint8_t *bcode = assistant->qos.bcast.bcode; + uint8_t arr[BT_BASS_BCAST_CODE_SIZE] = {0}; + uint8_t *bcode = arr; + + if (assistant->qos.bcast.bcode) + memcpy(arr, assistant->qos.bcast.bcode->iov_base, + BT_BASS_BCAST_CODE_SIZE); dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING @@ -648,7 +653,7 @@ static void src_ad_search_bid(void *data, void *user_data) static struct bass_assistant *assistant_new(struct btd_adapter *adapter, struct btd_device *device, struct bass_data *data, - uint8_t sgrp, uint8_t bis, struct bt_iso_qos *qos, + uint8_t sgrp, uint8_t bis, struct bt_bap_qos *qos, struct iovec *meta, struct iovec *caps) { struct bass_assistant *assistant; @@ -666,6 +671,10 @@ static struct bass_assistant *assistant_new(struct btd_adapter *adapter, assistant->sgrp = sgrp; assistant->bis = bis; assistant->qos = *qos; + + /* Create an internal copy for bcode */ + assistant->qos.bcast.bcode = util_iov_dup(qos->bcast.bcode, 1); + assistant->meta = util_iov_dup(meta, 1); assistant->caps = util_iov_dup(caps, 1); @@ -689,7 +698,7 @@ static struct bass_assistant *assistant_new(struct btd_adapter *adapter, } void bass_add_stream(struct btd_device *device, struct iovec *meta, - struct iovec *caps, struct bt_iso_qos *qos, + struct iovec *caps, struct bt_bap_qos *qos, uint8_t sgrp, uint8_t bis) { const struct queue_entry *entry; @@ -998,7 +1007,7 @@ static void bass_attached(struct bt_bass *bass, void *user_data) static void bass_handle_bcode_req(struct bass_assistant *assistant, int id) { struct bt_bass_bcast_audio_scan_cp_hdr hdr; - struct bt_bass_set_bcast_code_params params; + struct bt_bass_set_bcast_code_params params = {0}; struct iovec iov = {0}; int err; @@ -1007,8 +1016,11 @@ static void bass_handle_bcode_req(struct bass_assistant *assistant, int id) hdr.op = BT_BASS_SET_BCAST_CODE; params.id = id; - memcpy(params.bcast_code, assistant->qos.bcast.bcode, - BT_BASS_BCAST_CODE_SIZE); + + if (assistant->qos.bcast.bcode) + memcpy(params.bcast_code, + assistant->qos.bcast.bcode->iov_base, + BT_BASS_BCAST_CODE_SIZE); iov.iov_base = malloc0(sizeof(params)); if (!iov.iov_base) diff --git a/profiles/audio/bass.h b/profiles/audio/bass.h index 257346374..845949117 100644 --- a/profiles/audio/bass.h +++ b/profiles/audio/bass.h @@ -8,7 +8,7 @@ */ void bass_add_stream(struct btd_device *device, struct iovec *meta, - struct iovec *caps, struct bt_iso_qos *qos, + struct iovec *caps, struct bt_bap_qos *qos, uint8_t sgrp, uint8_t bis); void bass_remove_stream(struct btd_device *device); From patchwork Wed Nov 20 10:25:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 844774 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2088.outbound.protection.outlook.com [40.107.241.88]) (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 51E4A19D063 for ; Wed, 20 Nov 2024 10:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098389; cv=fail; b=ahuD0uuLEf585jX9kL3P+QSjmS3HsTjqjlVqYKJOvLpo6wRoyJb7KThaT+5T+hUNLS393khKPyU3OsMEJ77YRI+YpkHQ2H84bCWBsb2eJ58nLFaLAbbzzM/bBU2uiDERq9awvvHIXnzyH/3ux6vbtMVVcC5+8yVKs1xm98uh2BM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098389; c=relaxed/simple; bh=VSQqDI/KvjPp/Xhad5XuqiArJNRl2ZVszpE9wQx55BE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=kBEufxJ+A76a07xk6d0HVpzYSUFGT9xKbWfsuGmECDwak1eyICc399XTJZYWtzVJVKFqhrgJN99+3GSsFf55b8n+0n9SmkDhvLW9fIDVp2L4dJ+u9Li0J6vBpfPTcgdYcTgAed8TWVNpQAZjCcgCoqFLYeWXvaMsAxkivV/WUas= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=UYgqBmiR; arc=fail smtp.client-ip=40.107.241.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="UYgqBmiR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XW7PsVlU59VBxpz31u1fd+h/VCRjYco9IyEQG1sAVQuYKNwRCOXCWea02RzSzGP3zDfKh3XwMntOvj/4Tf1dQOOSn8Yjma2AR2Fl2O8m2dJGFoCKXeDygr4GZI8ujZPH9qHt4V7FnZtKM/X2CchTW4gc134On4VUmI80COETiWcZ5Jxqn8sixYYgc8LV/3se1ppkTFvmxsErYGsqY/74X7KPSFf/ylTbIZczBUJuLvgIComU92WIxqtVu7x1KBwboO44VCnnrQbGbr2nstkv5RE7WL57+boYW3S8exxne/fwbOa1dmztMvBrtOsdyctaXQyjt4Ut4v64e+kS+2zLrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6RuJIhM5uJW9TwzU2NZ+Xc/U8fXHUVVsb61igd+FcbI=; b=nZ/GD7IGBxQiDCdUb1qJocjBGwyesO8tyjvAdnSDEwkvjlks3FtVGNh2LOnlflX3OE1szFK52w9Fpgyx1LAdXrv4ywrWia0LCajLhNCjl9kGkkOs0uSv+gjuIpt6XxQLa+WSC2YL/pOcmUOuyrCOxWGEUD+5PYCrCFhfpdUsC9mLcZzFDs9nQzuwYq4RfAA+XMm9VU/+5kz031GjRmu4jJ1fmveFqlT+JpPsvOHN9dRz8XAfMrRSaorZAJVyTmMSXoken2Aija91w5rSlAkAp9qtWyUq7a9kVrXTj8IMaQj4KYIWeWbRQNcty4nyzBboS120IoDGw3OL/Qm0Fn4UbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6RuJIhM5uJW9TwzU2NZ+Xc/U8fXHUVVsb61igd+FcbI=; b=UYgqBmiRKoMrpqxCKqdTkhNv3yxr7PthHYA18fombUzxXU/OpdniIYcasrgu9FKwooVgBnGW5dCkveHYSU0MLQwRQYR1D+rnhBHpdGPu2ZiASi4j0Q3ZoVqPIc77i/S0VZy5UQV44n4FXnBWYmrU/gM+GcSJbBLi6J9BTKTS63K53EdbNBeg5kMvxKlqyxs5vGX1NKblcauEIBT213CT+UQatimrZuCH53R3uNa2MY137Z5BbWI7XTYZCAme41H8apP2ZBEkYN5nJqKchlHGpDXKTZ/UyWSgTz5b3v7yrmkTiUoADThMc5fq37J0HKT2lyiqzHZ/uBCRbvKJH84ghg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DU2PR04MB8904.eurprd04.prod.outlook.com (2603:10a6:10:2e3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Wed, 20 Nov 2024 10:26:25 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8158.023; Wed, 20 Nov 2024 10:26:25 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 4/7] bap: Make default PA sync QoS public Date: Wed, 20 Nov 2024 12:25:58 +0200 Message-ID: <20241120102601.38415-5-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241120102601.38415-1-iulia.tanasescu@nxp.com> References: <20241120102601.38415-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0006.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5d7::10) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DU2PR04MB8904:EE_ X-MS-Office365-Filtering-Correlation-Id: 8dacdfe1-c1aa-46f6-60a3-08dd094dc964 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: 2njTrE3YprCcsjF5HtgP+xmW0iAm7mM1Y54QRy33alzDmotBfKwNM88LrO1AgwWfvafjorh1fbURagm/toaupTgkBNaNcoGa5gifKsOrix5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mcqZe+TiAY7ubl1+7fdIVIaAKB5Uuxs4KmLUx0J0myYzFIQp+XZDz8BYebjQCBaJ1/S17nzdfMNWdRq39G0tHUeRBQf3p569MsJ0RgJ9gPk1ynAsYxyulP1PXsRDVl8Gy70WL4pQao3+Ms X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /R9gXslywph3JrBGIv9zAsXZuYEzSOU9WBOjhnYnOKcDl5HBViJTkR20TI5RcWt2qOnyCFSDqBerZm/fzmHi7KJx7+RNAqii9AuIXXmzuw3IWU3YeKyWVnWBtKuBKb3LpxEO+OxRvZQVhvWHqX9JxIJY7cyz+ymevTESymWrqRz4TyhcXXxq/oLJ3zZnC/ARbtEu/EGM+tzA/Jsin7x6oHlnEBmSfTk/SL+r/2JYKE4fvAb/biotPExhYVSPPfSUzw/KbbDbS9beXBxGWC/eimJ+iZBdhd5zXmoZMJEbYuZ6+cPXlRJA+mgBNpB/PcxTnAIp891lOZZtGlmPpgc13gAMgnX4UoDewn68islpsownlds44aq1iNX9BcsDx1JOSrpj9OdNO0ZThTKLOq4ljCsmLDRcQCsIIs2GtqTK+N1lSVxpPs9C5y00+S5r99kJ8X+OV3wjtI6p9Ga0Bwo/bnrAGE2V09hVm4Ozxu97AHN4qyMJShPSuotAA8mhmABqbugxieektAtVvEEILlVqA4m3pO3YHUP/KPzieTFL0RF9Xq2poOMOhLytXD1+ndKzTgLmTEXq59kfptnmrmnvYdCll1RmBKzUdLbvgRxLptF7JKF84d+K6/w+nQ0zwZF6EjeCbosSib1mcOOCOFxPSl3i/cxpxk+sjTHKtBQmsDKzjJbQOYkbz9sJL4x5S1leZbbiaPgE2P3SgomZYc5z6r/vjKYbJrT4ZcUB/Eopr2+Ztr3OVwJw99zzMjkzhl2iC79TYsaTG8JvipPCNTZpY7UUOucGAaNxw3IowJeohDxhzxnUyPqqQUA3zXW0tFGNTWNGuwd3Olf2oX07qol4JSPpbE8CBgGJqFP732VwK92t5hVMFGqw30mCSU0CszaLdRqNDK6wT+EEcbhkJeHIrK7gct/D54S/hgd+ciBE7UErwma31A6mJ2OW5eBYZ3s5sxmnYnmquqscr0AS4Theb5GvcypBVxPnlys5UMDTW2mAYuk3DBvg6DV6AgAt5WlGFz+EnBWmBVII8RD6EkacmrF1khNnmACrmSOTO8+yx26mkhkcsPAabYmlB4YhUBiT6LXLKdA/p2jNcDbYWFgm887yuBJjNOLIadmfhJHe6WcojXweBHKldG5s771MjKXdU1WNPL9alHaAei8mButvn7eEJMbBxnt2G3r4vvVz/Tl2LghuNt2yY+JRvVgtrkZ3S5rK7Dzr6ffz0TZ8ACwAxWhB3PwXjLDWXnJvlzfeNQR5gQOo4abAk5yy1hR5N/T0/cB5JqQk9Bz4sYmrgZxHsDkc8PAzrskWEu8QuPJK4zUxZWASKcLPMe2rmrHpoEJcD3Xglap8dGe5vRx/UldNz4kDGmX1aSb+ItRz57NXY1YLORGZvVC2OnHgPLH/ybSXzWGUD3SrJIdMd4UUHRdZkiBmvM0FIpP/Ve3vavRhVKyF3/oTs3YDwEdT5HeQTAd9CozdDdDpM6UNqw+hfk5I6eHjXxj3J0TR3rHAR+zD+i+fFpDuCg8A4k2WI369Yfl6NDCxZXTg2n3oAEbsIhbqhrofZZ5i/OUGfqx+Tox23OXOiYf7EeFY+z0qoaPxKKdGj3tIG3gzlr7RYbC7DBBXmA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8dacdfe1-c1aa-46f6-60a3-08dd094dc964 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2024 10:26:25.3686 (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: kfDp/T8WdsFbsNesAdU/R74wb+Hgl8/GRBMeQ7NKMRRIN5ic42duryJ0Zwg7/54Hc0xvEu51sW2QRNEnhAGyaw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8904 This make the default BAP QoS parameters for PA Create Sync public, to be available to other plugins that might need to listen for Broadcasters (like BASS). --- profiles/audio/bap.c | 2 +- profiles/audio/bap.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 2a194d709..675c33c6d 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -150,7 +150,7 @@ static struct queue *adapters; * 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 = { +struct bt_iso_qos bap_sink_pa_qos = { .bcast = { .options = 0x00, .skip = 0x0000, diff --git a/profiles/audio/bap.h b/profiles/audio/bap.h index 2968f6216..fcc443dbb 100644 --- a/profiles/audio/bap.h +++ b/profiles/audio/bap.h @@ -7,6 +7,8 @@ * */ +extern struct bt_iso_qos bap_sink_pa_qos; + struct bt_bap *bap_get_session(struct btd_device *device); void bap_scan_delegator_probe(struct btd_device *device); From patchwork Wed Nov 20 10:25:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 844566 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 B79FB19E971 for ; Wed, 20 Nov 2024 10:26:31 +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=1732098394; cv=fail; b=az38p25akPuQ/HX6U+EYUtcomjiUvfWMDblxc6fJmUu2zlTO12FiNTl5tMaIHSLGsOTqriXNgtVB8WphZ7g4YeL2zPTlaZBmlhCw9CQE+UdMaEiVoFMC5tjNm9OUyO2qk49P8PFDsaC14EU4sH/jG+6gggqrkJqI5zwj+07aTbk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098394; c=relaxed/simple; bh=OGFlKRLdMFvT6jb44gBgMXr6Yu8dyb0wc+oLzc2qb/Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=VaCLr5AoTas9BIgAh3QbBVing+WGl8I1o93foZYD5Hf/8NSBfCnTd8NLlJtsVTV2LxsLEjWobeNjPWQP+UxX/20Ts2mB217XYnlxG2wwlZ2bpeIcYLzD9gUSqVv6Qfpxnp8ef6aX/Cin+l+uH09F/UkgDgXHr8lhr4AJLrICycQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=O1UzB7/C; 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="O1UzB7/C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xAZ+C4yI6cx5DwddrRMDYV11zY5SzprzpQl0Ki3TDXTwoCq2oBiFa42Z6mRzN3Ejw/lvVWEDgtVEuWW0eTYhT5nOefmuMikrFOq1RhM2lAOI1ajUp0IzP4HsCNEW8UpLSvC0N+wviGDP+qUrl+3CJxF5claviE9S4MVnVjXOPEDk2WtmCRnzakoFaY/awC/OOntCPywHJVjceHIw9NR/MMJYshx4tr6HLS9kDBTVrxpxg1cLBreONwWAngOZ7NXpCdi3CdFQ6er2dy+1wyrs23PEaIAOWUOdaHRbTYLWFO84wdkS9TcLZV7Grmom7qLlNXfeaLHLetAcTPUYFTSX5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YzKNjZnmRPRC+eGHldCkm1pl1dB2je8+8EBJzdzgk6I=; b=l0M4UjzLeYgCPkhyvrm/+wnaZpxvgeshrZXr9oDGFUh5Al652H3Rf9iPPMH13eKrG9jj15Rl3xuB7d2N3eW+fOD/CUl4ReKD43Rs90IAKPJ8CmMz5poVz78+BNNCYnLBR8M4xGbUZszjBfUwphz9UHCYmxfuRURCxB/iHkeg0XCEuXFns71qGDIOdn98myS/3QjeW3En2vMB7lGIVvIB5XY9rBKv4xh3E9Pn3Cw0t+K6Z/xpFFeVnUQ+rNnNoip0HTBrgnfpzSzDIdVV9gdE7enWaweWMI5Og+nwjKfvrNVL9UMYIwMrCAF/7eYsE9r5e0xRyHOxNX8V9rq2z5Hokg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YzKNjZnmRPRC+eGHldCkm1pl1dB2je8+8EBJzdzgk6I=; b=O1UzB7/Cd3OacJ09zV2GHr/kjSiKvYoP+y8UGPhm2ciIomgRkdMH61EbbtDtuoBvlXT7EZbMnfGpKYeAfkQtMuHJ1Vit1bDwViLs0PiMnO5tstb3FWpjBnkqgM4rtae/WJ+uiuh4v/VdZhZlkpsMmn3gg+rBb2uTOpavDfHREgPP+0wV88p7zSoRDoNOM7tYOWLGfaxq15f16T1NfiOrbWiQIsaO2XE72IbIRcEyjASun4nHb/gyXGrQ6MhPBaVbQeNq+gv1TGEm+GQUHgOGmlVUFBCQfztppRY5a6CpWHoxEI3ZbXvz6jYHidQRnhLIDgVRgUFxzNTCBuVC0vqdVw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI0PR04MB10389.eurprd04.prod.outlook.com (2603:10a6:800:217::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Wed, 20 Nov 2024 10:26:28 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8158.023; Wed, 20 Nov 2024 10:26:28 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 5/7] bass: Rework Scan Delegator to handle BAP streams Date: Wed, 20 Nov 2024 12:25:59 +0200 Message-ID: <20241120102601.38415-6-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241120102601.38415-1-iulia.tanasescu@nxp.com> References: <20241120102601.38415-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0001.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5d7::6) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI0PR04MB10389:EE_ X-MS-Office365-Filtering-Correlation-Id: 9dcd3974-a967-4d8c-31e2-08dd094dcb28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: iZ1bBK1ULGYO3mc6wCOp12b5TEIJao2iIT07klRNX9YDXiIu8uoHOOhS3eWTjzMBWeuWt3h0iOFlqfSzBIf6ibyhfyxdVGeYvuVLq68Kr//6c3slZrxmloNS0UWN6kFc8MlV8tTOs+vygz5fHc3/GKeiYVso1TIwlADGh8d+YuVo9zYaR0DYjn4Al2f+5GZB9THpWOd0ctyhG7cUhoA02SKpfF6UK3udoLNrlbxCoV2eA3r24y0k77vrk6DC9jMsEcfeQcHQWmRVpXKgcCtxCC6WAOsxTmEQG5fuzYRDxG4ctRimrekoojiQlTwSB2x77bY12ifBGZtAisylJJ1TsBax6BlfU7dECm0vCzjNbcN8fJvSEf0DewqqLjwkqeiugJ5LHUTQiLePhKLarKyi9eUA+YBF67vk3VYajv1aizL7Wg9LfcTcfiC9BNG27gZXlQGFjEoWeunz+EHC8/TbFVDSZtgJTio6w5hudilskKEFX4BkCGVqF7sP+o/1f+5Obj35Fv1eQQjn4eG8QhHbhNkryhfSzx4EiZmfz52vdM8frv3TCuhhUrP56XgEqOR90O+ta5qeWs7SSdZ8IH7wUfMyEYAMhUXeppRs6NAcS3rwTmhkX74Txl5Mf+BAEFgyfCpzgDfSab175+Hq5k/eZhNjPAEt45KDlwU3tJ5DmZFnuF/5zj73TUNbryfldyKPAvLWjhepmsQ9RLppK7HW0I1nM1VCAD0RqAZ7j/1V3j01I5CVN3nanjgBI1AtLSWAUa+Zvm8zlCzvjZ7sZ+a+1H4nHvilYUq31BUDn7hfRchr+yF/aXx7EH8RMrClle0Dz+bJJRmVfJbE8pPhvVlkwTZ+fNl3PWAqbrFezDG/xkgrCaIzXSR9rpqgtrlPhBxnDDG4DewYCqbHKoEZRQvWW7pAwbwip8JTljtvQNg0JoMYBA4fPZjJ7NyMhtoDMu+xfXIPAPA9UIK/oIKzZdFbBS879ibEN2GdAZmOfv6EcjCrZrUD7h6C3hScpcxJgjX8L8XjS0FB49JfCD9rb9KgNHVhbTXMNT+c7t92kNsz9YTU8fYAWN7i+UF1bNxjeLAsa5kah27rnDgLnoWSf6RVZwt4hyoMV/qchl/RtQfbV7dx/vAOVkxQV4g/Gd8TTyan1pLw3lSHWw8jjGkPLjy33vDilLWhhG/70khTuMhNMEonHMjDd5WoBpD7zQCzN6tYatcii6XUZ89WPEgiXFLAXtuqLWfb4EjMZ9JmFZgv1RO4t5WajimQEC9AMMqNP1W7A0l1LwH7AXFunOM3wCulLDZ+/zMwLYaIAYvLrMhN6VQgkChm2MqZcgyrThH0a5qG X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mvpEyLt9RwJ14Q7gXwCoY/87jHeB7vdgcign7NB4VMmGG1cUQKJF3A2a2ZegGRv+wi+XYVpMGeOKvbECHt8R5kbXXaAvisys2p+UESnioeHULk6CnE8qAhv8dghloLqNG6ohgBSzeNmoFxYJZNK7u2zATPUnnnctDWMTB91Uc841OBLMZjUuEuwEkgjsA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Hfitg/XEbGPLBpp87GIdcyQJVKAfbmL/T69G9BUIUE6Wc3PYgrBy6VKWCY5eE4dISDyGGz5sLHFvx0K2RFOuBSsMffXjY63iQpJ1+pYjYxA1MFdbqCeQ2YaXpIowPY9bnR2xuFRFA54otCK4cp9s1pdczYLbmx4EY3fhjw6DUQGBrQF7Fbq6i4U8xoIPb/ibvLSpPJjN2EpjJjItEbG1zvGjxAV9/hIr8PCFXFn/6zly0kreOiKhLQR+bykbFEYWlwdEYkbs5ijx4gNlBa8YinfBHx5fNWfwZsQplqcrMa4QzNbELKK2gyaMvrcXcCMnYXqFmtNwP/F3grswJxp4W/Folry85PLG02gK5wpnowxfrqg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9dcd3974-a967-4d8c-31e2-08dd094dcb28 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2024 10:26:28.4383 (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: ISFHeT5DTNj+VEMFPwh1TykhmTSaAhTzunAgcJ/pn3dAkWRLbqvZCLtAfcFCAPTUWI6j5TrpHwB8gPGJcRQTaw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10389 This updates the Scan Delegator implementation to be handled internally in BASS: The BASS Server is responsible to handle Write Commands for the Add Source operation by creating long-lived PA sync, parsing the BASE, creating and configuring BAP streams, as well as enabling them. --- profiles/audio/bap.c | 18 +-- profiles/audio/bass.c | 332 ++++++++++++++++++++++++++++++++++++------ profiles/audio/bass.h | 4 +- 3 files changed, 297 insertions(+), 57 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 675c33c6d..a1cb3aeae 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1119,14 +1119,6 @@ static void bis_handler(uint8_t bis, uint8_t sgrp, struct iovec *caps, bass_add_stream(data->device, meta, caps, qos, sgrp, bis); - if (!bass_check_bis(data->device, bis)) - /* If this Broadcast Sink is acting as a Scan - * Delegator, only attempt to create streams - * for the BISes required by the peer Broadcast - * Assistant. - */ - return; - /* Check if this BIS matches any local PAC */ bt_bap_verify_bis(data->bap, bis, caps, &lpac); @@ -1186,9 +1178,6 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, g_io_channel_shutdown(io, TRUE, NULL); } - /* Notify the BASS plugin about the session. */ - bass_bcast_probe(data->device, data->bap); - /* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities */ @@ -2598,6 +2587,8 @@ static void bap_state_bcast_sink(struct bt_bap_stream *stream, return; setup = bap_find_setup_by_stream(data, stream); + if (!setup) + return; switch (new_state) { case BT_BAP_STREAM_STATE_IDLE: @@ -3145,6 +3136,7 @@ static int bap_bcast_probe(struct btd_service *service) struct bap_bcast_pa_req *req; uint8_t type = BAP_PA_LONG_REQ; struct bap_data *data; + int ret = 0; if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) { error("BAP requires ISO Socket which is not enabled"); @@ -3198,6 +3190,10 @@ static int bap_bcast_probe(struct btd_service *service) bt_bap_set_user_data(data->bap, service); + if (bass_bcast_probe(service, &ret)) + /* Return if probed device was handled inside BASS. */ + return ret; + /* Start the PA timer if it hasn't been started yet */ if (data->adapter->pa_timer_id == 0) data->adapter->pa_timer_id = g_timeout_add_seconds( diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index d3b35f62a..21f708ba6 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -29,6 +29,7 @@ #include "lib/bluetooth.h" #include "lib/uuid.h" +#include "lib/iso.h" #include "src/dbus-common.h" #include "src/shared/util.h" @@ -42,6 +43,7 @@ #include "src/shared/bap.h" #include "src/shared/ad.h" +#include "btio/btio.h" #include "src/plugin.h" #include "src/gatt-database.h" #include "src/device.h" @@ -101,16 +103,28 @@ struct bass_assistant { struct bass_delegator { struct btd_device *device; /* Broadcast source device */ + struct btd_service *service; struct bt_bcast_src *src; struct bt_bap *bap; unsigned int state_id; uint8_t *bcode; unsigned int timeout; struct queue *bcode_reqs; + struct queue *setups; + unsigned int io_id; + GIOChannel *io; }; -struct bass_bcode_req { +struct bass_setup { + struct bass_delegator *dg; struct bt_bap_stream *stream; + struct bt_bap_qos qos; + struct iovec *meta; + struct iovec *config; +}; + +struct bass_bcode_req { + struct bass_setup *setup; bt_bass_bcode_func_t cb; void *user_data; }; @@ -153,18 +167,30 @@ static bool delegator_match_bap(const void *data, const void *match_data) return dg->bap == bap; } -static void stream_set_bcode(uint8_t *bcode, struct bt_bap_stream *stream, +static void setup_set_bcode(uint8_t *bcode, struct bass_setup *setup, bt_bass_bcode_func_t cb, void *user_data) { - struct bt_bap_qos *qos = bt_bap_stream_get_qos(stream); + struct bt_bap_qos *qos = bt_bap_stream_get_qos(setup->stream); + + /* Allocate Broadcast Code inside setup QoS */ + util_iov_free(setup->qos.bcast.bcode, 1); + setup->qos.bcast.bcode = util_iov_new(bcode, BT_BASS_BCAST_CODE_SIZE); - /* Allocate Broadcast Code inside stream QoS */ - qos->bcast.bcode = util_iov_new(bcode, BT_BASS_BCAST_CODE_SIZE); + /* Refresh stream bcode */ + qos->bcast.bcode = setup->qos.bcast.bcode; if (cb) cb(user_data, 0); } +static bool match_setup_stream(const void *data, const void *user_data) +{ + const struct bass_setup *setup = data; + const struct bt_bap_stream *stream = user_data; + + return setup->stream == stream; +} + void bass_req_bcode(struct bt_bap_stream *stream, bt_bass_bcode_func_t cb, void *user_data) @@ -172,6 +198,7 @@ void bass_req_bcode(struct bt_bap_stream *stream, struct bt_bap *bap = bt_bap_stream_get_session(stream); struct bass_delegator *dg; struct bass_bcode_req *req; + struct bass_setup *setup; dg = queue_find(delegators, delegator_match_bap, bap); if (!dg) { @@ -179,9 +206,15 @@ void bass_req_bcode(struct bt_bap_stream *stream, return; } + setup = queue_find(dg->setups, match_setup_stream, stream); + if (!setup) { + cb(user_data, -EINVAL); + return; + } + if (dg->bcode) { /* Broadcast Code has already been received before. */ - stream_set_bcode(dg->bcode, stream, cb, user_data); + setup_set_bcode(dg->bcode, setup, cb, user_data); return; } @@ -193,7 +226,7 @@ void bass_req_bcode(struct bt_bap_stream *stream, if (!req) return; - req->stream = stream; + req->setup = setup; req->cb = cb; req->user_data = user_data; @@ -218,18 +251,58 @@ static bool delegator_match_device(const void *data, const void *match_data) return dg->device == device; } -bool bass_check_bis(struct btd_device *device, uint8_t bis) +static int stream_get_bis(struct bt_bap_stream *stream) { - struct bass_delegator *dg; + char *path = bt_bap_stream_get_user_data(stream); + const char *strbis; + int bis; - dg = queue_find(delegators, delegator_match_device, device); - if (!dg) - return true; + strbis = strstr(path, "/bis"); + if (!strbis) + return 0; - if (!bt_bass_check_bis(dg->src, bis)) - return false; + if (sscanf(strbis, "/bis%d", &bis) < 0) + return 0; - return true; + return bis; +} + +static void append_stream(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + struct sockaddr_iso_bc *addr = user_data; + uint8_t bis = stream_get_bis(stream); + + DBG("%d", bis); + + addr->bc_bis[addr->bc_num_bis] = bis; + addr->bc_num_bis++; +} + +static bool link_io_unset(const void *data, const void *match_data) +{ + struct bt_bap_stream *link = (struct bt_bap_stream *)data; + + return !bt_bap_stream_get_io(link); +} + +static void connect_cb(GIOChannel *io, GError *err, void *user_data) +{ + struct bt_bap_stream *stream = user_data; + struct queue *links = bt_bap_stream_io_get_links(stream); + int fd; + + DBG(""); + + /* Set fds for the stream and all its links. */ + if (bt_bap_stream_get_io(stream)) + stream = queue_find(links, link_io_unset, NULL); + + fd = g_io_channel_unix_get_fd(io); + + if (bt_bap_stream_set_io(stream, fd)) { + g_io_channel_set_close_on_unref(io, FALSE); + } } static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, @@ -237,31 +310,54 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, { struct bass_delegator *dg = user_data; int bis; - char *path = bt_bap_stream_get_user_data(stream); struct bt_bap *bap = bt_bap_stream_get_session(stream); - const char *strbis; - int err; + struct sockaddr_iso_bc iso_bc_addr = {0}; + struct queue *links; + GError *gerr = NULL; + struct bt_bap_qos *bap_qos = bt_bap_stream_get_qos(stream); + struct bt_iso_qos qos; if (dg->bap != bap) return; - strbis = strstr(path, "/bis"); - if (strbis == NULL) { - DBG("bis index cannot be found"); - return; - } - - err = sscanf(strbis, "/bis%d", &bis); - if (err < 0) { - DBG("sscanf error"); - return; - } + bis = stream_get_bis(stream); DBG("stream %p: %s(%u) -> %s(%u)", stream, bt_bap_stream_statestr(old_state), old_state, bt_bap_stream_statestr(new_state), new_state); switch (new_state) { + case BT_BAP_STREAM_STATE_ENABLING: + iso_bc_addr.bc_bdaddr_type = + btd_device_get_bdaddr_type(dg->device); + memcpy(&iso_bc_addr.bc_bdaddr, device_get_address(dg->device), + sizeof(bdaddr_t)); + + append_stream(stream, &iso_bc_addr); + + links = bt_bap_stream_io_get_links(stream); + + queue_foreach(links, append_stream, &iso_bc_addr); + + bap_qos_to_iso_qos(bap_qos, &qos); + + if (!bt_io_set(dg->io, &gerr, + BT_IO_OPT_QOS, &qos, + BT_IO_OPT_INVALID)) { + error("bt_io_set: %s", gerr->message); + g_error_free(gerr); + break; + } + + if (!bt_io_bcast_accept(dg->io, + connect_cb, stream, NULL, &gerr, + 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", gerr->message); + g_error_free(gerr); + } + break; case BT_BAP_STREAM_STATE_STREAMING: /* BAP stream was started. Mark BIS index as synced inside the * Broadcast Receive State characteristic and notify peers about @@ -280,17 +376,99 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, } } -bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap) +static void bis_handler(uint8_t bis, uint8_t sgrp, struct iovec *caps, + struct iovec *meta, struct bt_bap_qos *qos, void *user_data) { - struct bass_delegator *dg; + struct bass_delegator *dg = user_data; + struct bt_bap_pac *lpac; + char *path; + struct bass_setup *setup; - dg = queue_find(delegators, delegator_match_device, device); - if (!dg) - return false; + /* Only handle streams required by the Brodcast Assistant. */ + if (!bt_bass_check_bis(dg->src, bis)) + return; - DBG("%p", dg); + /* Check if this stream caps match any local PAC */ + bt_bap_verify_bis(dg->bap, bis, caps, &lpac); + if (!lpac) + return; + + if (asprintf(&path, "%s/bis%d", device_get_path(dg->device), bis) < 0) + return; + + setup = new0(struct bass_setup, 1); + if (!setup) + return; + + setup->dg = dg; + + setup->qos = *qos; + setup->qos.bcast.bcode = util_iov_dup(qos->bcast.bcode, 1); + + setup->meta = util_iov_dup(meta, 1); + setup->config = util_iov_dup(caps, 1); + + setup->stream = bt_bap_stream_new(dg->bap, lpac, NULL, + &setup->qos, setup->config); + if (!setup->stream) + return; + + queue_push_tail(dg->setups, setup); + + bt_bap_stream_set_user_data(setup->stream, path); + bt_bap_stream_config(setup->stream, &setup->qos, + setup->config, NULL, NULL); + bt_bap_stream_metadata(setup->stream, setup->meta, + NULL, NULL); +} + +static gboolean big_info_cb(GIOChannel *io, GIOCondition cond, + gpointer user_data) +{ + struct bass_delegator *dg = user_data; + GError *err = NULL; + struct bt_iso_base base; + struct bt_iso_qos qos; + struct iovec iov; + struct bt_bap_qos bap_qos = {0}; + + dg->io_id = 0; + + 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); + return FALSE; + } + + iov.iov_base = base.base; + iov.iov_len = base.base_len; + + /* Create BAP QoS structure */ + bap_iso_qos_to_bap_qos(&qos, &bap_qos); + + bt_bap_parse_base(&iov, &bap_qos, bass_debug, bis_handler, dg); + + util_iov_free(bap_qos.bcast.bcode, 1); + + return FALSE; +} - dg->bap = bap; +static void confirm_cb(GIOChannel *io, void *user_data) +{ + struct bass_delegator *dg = user_data; + + DBG(""); + + /* Close the listen io */ + g_io_channel_shutdown(dg->io, TRUE, NULL); + g_io_channel_unref(dg->io); + + g_io_channel_ref(io); + dg->io = io; /* Update Broadcast Receive State characteristic value and notify * peers. @@ -298,15 +476,70 @@ bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap) if (bt_bass_set_pa_sync(dg->src, BT_BASS_SYNCHRONIZED_TO_PA)) DBG("Failed to update Broadcast Receive State characteristic"); - /* Register BAP stream state changed callback, to keep up to - * date with BIG/PA sync state. - */ - dg->state_id = bt_bap_state_register(bap, bap_state_changed, + /* Register BAP stream state changed callback. */ + dg->state_id = bt_bap_state_register(dg->bap, bap_state_changed, NULL, dg, NULL); + dg->io_id = g_io_add_watch(io, G_IO_OUT, big_info_cb, dg); +} + +bool bass_bcast_probe(struct btd_service *service, int *ret) +{ + struct btd_device *device = btd_service_get_device(service); + struct btd_adapter *adapter = device_get_adapter(device); + struct bass_delegator *dg; + GError *err = NULL; + + dg = queue_find(delegators, delegator_match_device, device); + if (!dg) + /* Only probe devices added via Broadcast Assistants */ + return false; + + if (dg->service) { + /* Service has already been probed */ + *ret = -EINVAL; + return true; + } + + dg->service = service; + dg->bap = bap_get_session(device); + + dg->io = bt_io_listen(NULL, confirm_cb, dg, + NULL, &err, + BT_IO_OPT_SOURCE_BDADDR, + btd_adapter_get_address(adapter), + BT_IO_OPT_SOURCE_TYPE, + btd_adapter_get_address_type(adapter), + BT_IO_OPT_DEST_BDADDR, + device_get_address(device), + BT_IO_OPT_DEST_TYPE, + btd_device_get_bdaddr_type(device), + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_QOS, &bap_sink_pa_qos, + BT_IO_OPT_INVALID); + if (!dg->io) { + error("%s", err->message); + *ret = -err->code; + g_error_free(err); + } + return true; } +static void setup_free(void *data) +{ + struct bass_setup *setup = data; + + DBG("setup %p", setup); + + util_iov_free(setup->qos.bcast.bcode, 1); + util_iov_free(setup->meta, 1); + util_iov_free(setup->config, 1); + + bt_bass_clear_bis_sync(setup->dg->src, + stream_get_bis(setup->stream)); +} + bool bass_bcast_remove(struct btd_device *device) { struct bass_delegator *dg; @@ -317,6 +550,16 @@ bool bass_bcast_remove(struct btd_device *device) DBG("%p", dg); + if (dg->io_id) + g_source_remove(dg->io_id); + + if (dg->io) { + g_io_channel_shutdown(dg->io, TRUE, NULL); + g_io_channel_unref(dg->io); + } + + queue_destroy(dg->setups, setup_free); + /* Update Broadcast Receive State characteristic value and notify * peers. */ @@ -904,6 +1147,7 @@ probe: dg->device = device; dg->src = bcast_src; dg->bcode_reqs = queue_new(); + dg->setups = queue_new(); if (!delegators) delegators = queue_new(); @@ -912,8 +1156,10 @@ probe: DBG("delegator %p", dg); - /* Probe device with BAP. */ - bap_scan_delegator_probe(device); + /* Add Broadcast Audio Announcement Service UUID + * to device and probe service. + */ + btd_device_add_uuid(device, BCAAS_UUID_STR); return 0; } @@ -947,7 +1193,7 @@ static int handle_set_bcode_req(struct bt_bcast_src *bcast_src, /* Set the Broadcast Code for each stream that required it. */ while ((req = queue_pop_head(dg->bcode_reqs))) { - stream_set_bcode(dg->bcode, req->stream, req->cb, + setup_set_bcode(dg->bcode, req->setup, req->cb, req->user_data); free(req); } diff --git a/profiles/audio/bass.h b/profiles/audio/bass.h index 845949117..678532168 100644 --- a/profiles/audio/bass.h +++ b/profiles/audio/bass.h @@ -12,11 +12,9 @@ void bass_add_stream(struct btd_device *device, struct iovec *meta, uint8_t sgrp, uint8_t bis); void bass_remove_stream(struct btd_device *device); -bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap); +bool bass_bcast_probe(struct btd_service *service, int *ret); bool bass_bcast_remove(struct btd_device *device); -bool bass_check_bis(struct btd_device *device, uint8_t bis); - typedef void (*bt_bass_bcode_func_t)(void *user_data, int err); void bass_req_bcode(struct bt_bap_stream *stream, From patchwork Wed Nov 20 10:26:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 844773 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 8D2A219E83C for ; Wed, 20 Nov 2024 10:26:34 +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=1732098396; cv=fail; b=RpUZg4K3atEvyIz/xSWUH/+iDOBFtGVH8XEN2j48V7tFieswqqNigLQ2jogVVcTlwHI1l+r43lcdUzWhzVpGH5R0LFh/fcuFbfIbyK109zfDZfdV6HzFJeZVZCpOCqm/Nb9VKqQEKAeTEQtME6xqoPgmtYBvv++8xgsuzW7bCnc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098396; c=relaxed/simple; bh=e9A8adVogRYKLHOQg0wyMTii24iCAiTQAfzmt79cGo8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=TXAO4v6HUza63XK7E3JBwz7NUOlgQf4uD9wgRgis0BqzsqUrn0CN83JwRNJEgCQq0GA/J20EgdyGn1PVGt2y0AYoR7M151QkWlr563AyJ10kwBqi2Z6n6CfuQSIJfztpe6kCsaYfdGbbxbcvC3H/P2lUnHglaUn/0tQh5yOaHsE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=kwNl6F1Z; 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="kwNl6F1Z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j8Qo2V+FikhB942cv1Ch+uZgu3Isx+gyZUbGoumayyTcKxrW5sF+Us6NWAmKEP2CGNlCTX08JJ/RojCX1Sl0971EDF6RDKauGWL+rql/PLP2GhF5DILVjptxYV2H82WkfF2Qxzkz9R7fddIHumLKxVqNCJ3qTcRdgiAtyRvuagfqWALDFxI6/w3sYukLlEVGuIRnzntz8O9P5Bwv8V1J7u4nYtetIMEH8+76UMaqQNFxaZKjS00RqsjB4453ncx5zYwDsk9Lka4IHU5CHI2Eb6+VowVJ2qkV38WLGhndDk7+yc0fkxYJgkJ5UH7QOFSDXWLsmyZIisN+Lp/A+fp2GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2Mn5AcMQDTHgX25uYCRPEByq6rHWfTMpfjqIiC0wzcs=; b=IJqdr0zFoA/8bAbvEZrGH8YoXuFr3vyFdgMnuCyNwEqhif0L/0roXgxVTawjEPtPcUYgT3/qsOGXzSqP8ZnnrKN8V5ou6oiXHrii9Em6IgxNONUu0zLwrvihfqOEmCC9k0o4anK/ricXgVhqqIZU0pireSoBvBLuZl0SocpcaviIvA0SiX4+6kO4mVb0Ufrm8FsxNozoDpMtDOfkRDfMAV5PWCYiNxPEOym/N00W2Ox/Er00fZOJzvkuW4/mqr/aLbic6Vjlpt1V2FAnmrqi6yJy2izcwA6BUJvWaq6fmeLj/97wdyTVQ4cVOuEl0t4gmLDH0q1Em0OboakuM3gASw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2Mn5AcMQDTHgX25uYCRPEByq6rHWfTMpfjqIiC0wzcs=; b=kwNl6F1ZGdtXmqB0f0v13iVW7HNVvl10THBpWW7646Vmh4cRuNOtvErBXh8y72mCax3qszau27VLmwrtnuBc9caQG9AWfenk/DymervI0peRl/pqVNnS9O4GNvFoz2UkzfE72Ysf6U1jkCbCv2nj5yFwNF2xAundr4pqTZF1tKKMmtYtkDMMfrpR+XDFe30CEg1FV/9YT6h6Gbph5NU8piCKF+AXivljDx6rIfzm4eLIwqRTo00vANOIROtoYnY9APYshVpm4ZaTNdpP/6XuLJFyFW3+jnp5Qx8x+aR9wpl7lVbonPRlGs/uy630zZeF1TNEbTRVaoQIQmYFnCTpBA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI0PR04MB10389.eurprd04.prod.outlook.com (2603:10a6:800:217::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Wed, 20 Nov 2024 10:26:31 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8158.023; Wed, 20 Nov 2024 10:26:31 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 6/7] bap: Remove API to probe device from BASS Date: Wed, 20 Nov 2024 12:26:00 +0200 Message-ID: <20241120102601.38415-7-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241120102601.38415-1-iulia.tanasescu@nxp.com> References: <20241120102601.38415-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0030.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::17) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI0PR04MB10389:EE_ X-MS-Office365-Filtering-Correlation-Id: 093bd02a-ef2c-45d0-0586-08dd094dccf3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: sA+0TuoJKqVWdoctDOTVg4NWzoIeUFe0rEY64oZ0w8FOauoH6vQZoABt6CD0cjAMWLYQzJpcD1dOVzwi1towNuD5adLr5DToGBXR7nQlHebwHGCxXuqFSLfG0K2KyTbrc7srMQMwMo2ux7mNhs+zVrvxIUtIOQwBOEg3Kk6shkgIF/9ZxzBTTsbC+iP2oCCdpO2OPrR2Cr7+SjmPWwqKC/SnVbwnZQ3p/1A81DLK1ccQQ8vwpxLnjjp4Q5F0cYKXp/JnfxVKXC2gdIM2ogXSyx0yI9Gca2N1/RurFlSSNEnS0xmG7KNUGBAGlwZxVgXirvbeXf4ieJTOHXemK9gXa9HzoD9WZ3fN51gYVknP3J6+uz9PWLOlShdpsKKye4Lkg5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9zHkjcNLBJKrtoInLoMoYLHd1WQfEg6m1waQKf+BJZIWqmOJT7fkdLd/SRqv/OkaWtL5LY24dbVDIbMxI1O9O1I22aT8X5cj6fURnJfHH1yvI/X7rILOOqiSjldwajG/GcVjR0L++aytY68HY4zj4sgWIpmaC8T0MzGZXvh+26Ow6k3dG5OLbkyll1wOuVWghMkODIrjBo0bZ7SugKsQEJUzhKLn/XxZKApo41qq80EltHdpTUwh2rhvyeCVJXHWriyHji6Ryq/3VuUKDoQTeS7bfpG17885sVazy4znF78dpM/ma0nglwBLLlgZ2qkZqXmTVSAB111eocovFGOI1kMxrl99vDk61uuqcP0E2F5O4kv4sa4mzmG7iB6nkrCXGafC8P8o8tMRNobPvFb5V0kxVwN6A5kDA/9akI08zRQfupDKa6wEB1u/swtnnLVz42iXdDY1ZFqZQ5HG/clB3+gXHtmvVuBRu3Up92u4BZ5EqOqYuugmljKyRQI2kKeZdDXcIAP6SHb1EoD4irDeTqTaL7ovXNXLDkVN05tYaUHSbOKPPuRxB5laeABOLuVmnz7pFYq7lujNVvOqIrdUtIvGTawoi78y/qZVuW+82hNZ33WJWE5kGMoctY84nTf5l0SgN7H9BKUA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 093bd02a-ef2c-45d0-0586-08dd094dccf3 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2024 10:26:31.3212 (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: K5GC9zHNNXGuldHN8YgfjmP1kqzI/ll2HUNa4ssdUp1EJxZ+e8VVLa2rMFmVzJ8TmzoEKmk+qq60vU639CFEhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10389 This removes the BAP API to probe broadcasters from BASS, since BASS is now directly adding the Broadcast Audio Announcement Service UUID to the broadcaster device, and it will internally handle the probe. --- profiles/audio/bap.c | 16 ---------------- profiles/audio/bap.h | 1 - 2 files changed, 17 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index a1cb3aeae..c1111b625 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -3112,22 +3112,6 @@ static bool match_bap_adapter(const void *data, const void *match_data) return adapter->adapter == match_data; } -void bap_scan_delegator_probe(struct btd_device *device) -{ - struct bap_data *data; - - /* Create BAP session for the Broadcaster device */ - data = bap_data_new(device); - data->device = device; - - bap_data_add(data); - - /* Add Broadcast Audio Announcement Service UUID - * to device and probe service. - */ - btd_device_add_uuid(device, BCAAS_UUID_STR); -} - static int bap_bcast_probe(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); diff --git a/profiles/audio/bap.h b/profiles/audio/bap.h index fcc443dbb..522072340 100644 --- a/profiles/audio/bap.h +++ b/profiles/audio/bap.h @@ -10,7 +10,6 @@ extern struct bt_iso_qos bap_sink_pa_qos; struct bt_bap *bap_get_session(struct btd_device *device); -void bap_scan_delegator_probe(struct btd_device *device); void bap_iso_qos_to_bap_qos(struct bt_iso_qos *iso_qos, struct bt_bap_qos *bap_qos); From patchwork Wed Nov 20 10:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 844565 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 A288219E98A for ; Wed, 20 Nov 2024 10:26:36 +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=1732098399; cv=fail; b=h9/PVFmImvsK65ek+ShmP+4+oF5s5aSvrWbnOXExxiIxOPbjA168/+nNfJaqFdwJdrzUJj3fy6mJi1cpQiZixRKMq4JJ+qQZa7KIn7NOSlM2fYFAOkE54N/2ApXUvh/mwr4be+RfxNZL74Q6yx9s+ac+HJSfwKrUwx8VdXmxGwg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732098399; c=relaxed/simple; bh=/qtdb8Jj+FeNXQkzsoW4XXimA5WwS1bg1uZ9qbs9z0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=S7+uy7PUH0JtwdlB0PxTK4eDEKakC+qSx/WTaZKMP08zR7UjAergeVpmPKRQQoS9XkYUZtMRfoZzRCzcfHNWhlokilSvGVzsnu5ryk9jk9yISbf9NNprE+ZVb5b58iG4eWd6BQSSLAwQH4OasLb13tui17k2c0/CZH9I+L/SgSc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=CvBp3p7m; 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="CvBp3p7m" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VWU8oJUy1AjDAhs6B+B7Tg1bOxKHa5e8n+c0HRAi6pY6scpeamtwjUUUFMLmzXOj/qWYXyuYEbMV+TVnlhikzjOIkpu8wJqfEtgLVlu8GLEptSe6deEPkoDRNR3PLaXFXq7KrBy2jSO4yVe/DTXZs0cI3EWPKP2pdbWwkMni4oKTrLovDn/+ywhfx/Wb7yhqsLKYVZQvk/10hUtBcl2k6HIZEpNitzpOAU7gTVkVL0dIkKotQ4/oID1N4VklC7prNqHaUXEJGbijT2i5xhb9doCHccfPHwWQG8HAkmbCwRV46WZybSybLyvuzBhZ/hRZRgF2KVT9jeTV+9Tl78J0UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SE9WXiwQiItu8YcH8Gj04h82IGMYG4+RXgf35ae022I=; b=wqRq32TGp3EgCR1mU01XBxOykGUFTj/ynkVANhd6Gue6kW5ALrGtA338tGd4sCw4xzELkAsmD7hqivX28uEb3I1qqpbIPpiNIA4v5+zjW/Q5zc0jmwV+M0/oUEMEWFc6iU25CMS0Celno1eF1sucPVdbbYj/5zAazuhOObEfOge3QKbi5i57BB3qJxf+RbwAwLzVSjS8NKiTr0+RU2vaXNVD7Rda6QtvqKCnwnBLETS4XJ/qsTLZnNsNGpUnIfDsUzBaBYdvqdYSxVx9USFHzD1Cw8VaQ07mOXo8K3RbwhrSoOGLhrny/n12JPLY36I2JunKDrmaKOxj6nN8lABQbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SE9WXiwQiItu8YcH8Gj04h82IGMYG4+RXgf35ae022I=; b=CvBp3p7mC1sr2bpDrkfkqbUbzhkCs1NXDbi9m79pvLY+7UhPmYIjc4TANNe0TGyw6NDDa4kL+vmyrGXGaCcDrBwW+pv0W0kz2G7ISd67Nilq556DvOOcrAVCCjwFk/be4/OrsBk0Gq+uxhbNbVP+71XQDZ7AeCS5qo+uyOFP7e63svpeEkwzhZgUyR48M5fGw30KhyWDIwl2NRmQvc1U2VwbNbtOlSIeo5cqT/FqZHv5tMe4igvJD5QkHkyYP4GwWfyVbbd+lFwSHhZJTdvbkYz2zBr1MmT3t9tSs4vMJ9RVak4NHUnoGGjK+Sz7MOTr+52ybVqMRUR65qSMAX7eag== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI0PR04MB10389.eurprd04.prod.outlook.com (2603:10a6:800:217::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Wed, 20 Nov 2024 10:26:34 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8158.023; Wed, 20 Nov 2024 10:26:34 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 7/7] bap: Remove PA idle timer logic Date: Wed, 20 Nov 2024 12:26:01 +0200 Message-ID: <20241120102601.38415-8-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241120102601.38415-1-iulia.tanasescu@nxp.com> References: <20241120102601.38415-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P195CA0054.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:65a::14) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI0PR04MB10389:EE_ X-MS-Office365-Filtering-Correlation-Id: 441f4d00-e4b3-432f-c7cc-08dd094dce98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: VRRJXkpi/q9Jh0AoncUKZGeJMHhMs6hSCZZ8L6sVUG6yt9uJcz1p+AFJd/eIGYr3lLagxU3QkSNERfwFmXO4Tv6ZsEmkJQ1RHVtbixVZzDUyaP1T1/e6n+V48Cf6zPM1jTUFBhglEQWgDs+o3bqjysygp08Y5M1O9jnB+lkHMnv7ZF6IbnacJ53Tn6h6kJyJkkqFDtBVji6+IVFiE14t7Z/jgXHj/XKAXnbGyAoxMBO8RRUwSGwc7YImyv+IMXMcd//SbDJFsvOr1laNE8Uehbu9VuC2IRQ0K7Pmroy/Xad/BQVcqMXMU+7IiT8FjymvG2PqasRHjdt0FU7dzU3JgQWz5aua3QvK8nxprKRcHyPzoQzmKeH6m7mcDRvNQn1I7YS2Eq0hlUcUD+V5/XeKPnFfpIcmCKH4meEDPS7khq1Ndjfl4HWn5BIpSJUaibujhv5AFptjFi1L707GrrNGnhurdFpTzXHq3ySoObwLPXpgEYpBvwPvsYaEpNuaST6rTZed+MzNDI63s+N454Zmv3eFRM0PFpYSKSRcefx0g2V8JCALtzGdkhBk5qNxVW85zFnwYCN2zUORRZ0h7PqtLV2RKB1NyON9Ip2YzwgLapeSNs+lGK55eDlqBocy2ttdW/2Vggiyk8fjbXt7bvdFH4Tq4og+oOrm2dRRiKLQtXWRvh4YHBtGAsAQ1/PdugW6TAPAVM6ItS7n+eIUx1ZrB4dBb4lg6sXW8tucjhF/uj9rvxf7dY2v3YpRlgQ4MF8IhiMRwv6zfJqJbZJUHvmTPXUJNIoxwUuqEXsP94uJGFBsz9f/6BlkDW+CndJGkP2Xwfh8fYtj5TG9UcpMZbCkfNOANt/e7o17rhc+uW0FERk0pwXHLtzUu9kDtLfHyfMMqgNFCzn0NFZdtKTM7TGuyAT+WbCNkuzkjumzO4VbfH15X5w94odee46ofFohdw6IMHiM8bVRZSiU5y37nFt/BuQWqRgf9XiHypTPYOVEgpN33juBKfkeSyOOh+HT7rR9nhDxx9TjoB+wfCW0VJzb28HZgr8n0sLSuG/JYItH7TeveH3jjrUVHAoMQA+z8ri/0DwmBVcQuvuKqQ9ZSuSRxcwmhyGpepDd50ivo3eMo3zXf0uBW/AbvMjWR8/1jkzvOFA7TmGMlP4til3F8DbuU8jaHsmvMKPGsFmqD+8orjWrTVyjPGMG1J5/3dl/mZCwxH9z1FT5UrvnHOqzUxaoDW0/fxPp9TIWykwyUX+hjL5jSo/MBs4hhD1TZwDMKqv55Qx2RXgeCgYAFAVRN7uGVF/uqgli5tXe8L6ckSNA27LK3O1AYWX9E7ZbXM1BrmZh X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LnSDJrxQNY+ZM5qznpjVFE4+EJMsS8V1d/KLGJYxNsZr8Q/JBvmTiv5CyfJedCuemML8g8UAkBKgRLp5jUamb08JsMrPDhcqWalTjJFJCQYGe9cuaWIK/dKZ/tYPxsLi7b+JUBvAKLbXVhjznP5FyK32bJtWE5hl4OrMo1naHitQ6NuGKr61Vb7ZiFcNFxK0HywaJ3Ccq9Das/sEHAFZDH9METdPV9Q1NTYs7zShD/1cslBNMYdzP6nin4fYkSfk3LJpyp8pB4zozzS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/85QZyZNAlzpwOgimTePs5o6+kaIAgk2RJgHKKsIApAD3kHBpR4PNJWaVGTTtM1ZIT6RwS1Vh4fMTbgqqLKvy2QlMHNElxo/8IHb/MNylF2qCgjnF6FvfZcLrP6Ag1WQxkG9Oa03HjZgu2dtP++Mic7oBkslgGvA61IR/SlqiwxTJjLFFjmeBZyhmyy7B9qLfTw09t9aVZHC3R1RU1h4Qo1/BlLpFFx83NSwKr1Kj6T8pvDad9B/ZdEG4XlTaHPG0UawS1VZFTxoe5bM2HklaEQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 441f4d00-e4b3-432f-c7cc-08dd094dce98 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2024 10:26:34.2856 (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: fG+3dWkUZkW189ZpGvOymNRZ23Q2X8ZYMafoznPP+I9FKQu/5my4ajpOdMfA1M1ws2LEJd1GchD6A0eah79MIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10389 This removes BAP support for long-lived PA sync (added for Scan Delegator support), since it is now handled inside the BASS plugin. This also removes the PA idle timer logic, since PA/BIG sync requests are now ordered inside the kernel. --- profiles/audio/bap.c | 369 ++++++++++--------------------------------- 1 file changed, 81 insertions(+), 288 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index c1111b625..a561c446a 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -65,15 +65,9 @@ #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 bap_data *data; struct bt_bap_stream *stream; struct bt_bap_qos qos; int (*qos_parser)(struct bap_setup *setup, const char *key, int var, @@ -101,15 +95,9 @@ struct bap_ep { struct queue *setups; }; -struct bap_adapter { - struct btd_adapter *adapter; - unsigned int pa_timer_id; - struct queue *bcast_pa_requests; -}; - struct bap_data { struct btd_device *device; - struct bap_adapter *adapter; + struct btd_adapter *adapter; struct btd_service *service; struct bt_bap *bap; unsigned int ready_id; @@ -121,30 +109,12 @@ struct bap_data { struct queue *bcast_snks; struct queue *streams; GIOChannel *listen_io; + unsigned int io_id; int selecting; void *user_data; }; -enum { - BAP_PA_SHORT_REQ = 0, /* Request for short PA sync */ - BAP_PA_LONG_REQ, /* Request for long PA sync */ - BAP_PA_BIG_SYNC_REQ, /* Request for PA Sync and BIG Sync */ -}; - -struct bap_bcast_pa_req { - uint8_t type; - bool in_progress; - struct bap_data *bap_data; - union { - struct btd_service *service; - struct queue *setups; - } data; - unsigned int io_id; /* io_id for BIG Info watch */ - GIOChannel *io; -}; - static struct queue *sessions; -static struct queue *adapters; /* Structure holding the parameters for Periodic Advertisement create sync. * The full QOS is populated at the time the user selects and endpoint and @@ -219,6 +189,9 @@ static void bap_data_free(struct bap_data *data) g_io_channel_unref(data->listen_io); } + if (data->io_id) + g_source_remove(data->io_id); + if (data->service) { btd_service_set_user_data(data->service, NULL); bt_bap_set_user_data(data->bap, NULL); @@ -382,7 +355,7 @@ static gboolean get_device(const GDBusPropertyTable *property, const char *path; if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) - path = adapter_get_path(ep->data->adapter->adapter); + path = adapter_get_path(ep->data->adapter); else path = device_get_path(ep->data->device); @@ -996,12 +969,19 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return NULL; } +static bool stream_io_unset(const void *data, const void *user_data) +{ + struct bt_bap_stream *stream = (struct bt_bap_stream *)data; + + return !bt_bap_stream_get_io(stream); +} + static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) { - struct bap_bcast_pa_req *req = user_data; - struct bap_setup *setup; + struct bap_setup *setup = user_data; + struct bt_bap_stream *stream = setup->stream; int fd; - struct bap_data *bap_data = req->bap_data; + struct bap_data *bap_data = setup->data; DBG("BIG Sync completed"); @@ -1009,28 +989,23 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) * to the order of the BISes that were enqueued before * calling bt_io_bcast_accept. */ - setup = queue_pop_head(req->data.setups); - - if (queue_isempty(req->data.setups)) { - /* All fds have been notified. Mark service as connected. */ - btd_service_connecting_complete(bap_data->service, 0); - - if (req->io) { - g_io_channel_unref(req->io); - g_io_channel_shutdown(req->io, TRUE, NULL); - req->io = NULL; - } - - queue_remove(bap_data->adapter->bcast_pa_requests, req); - queue_destroy(req->data.setups, NULL); - free(req); - } + if (bt_bap_stream_get_io(stream)) + stream = queue_find(bt_bap_stream_io_get_links(stream), + stream_io_unset, NULL); fd = g_io_channel_unix_get_fd(io); - if (bt_bap_stream_set_io(setup->stream, fd)) { + if (bt_bap_stream_set_io(stream, fd)) g_io_channel_set_close_on_unref(io, FALSE); - return; + + if (!queue_find(bt_bap_stream_io_get_links(stream), + stream_io_unset, NULL)) { + /* All fds have been notified. Mark service as connected. */ + btd_service_connecting_complete(bap_data->service, 0); + + g_io_channel_unref(bap_data->listen_io); + g_io_channel_shutdown(bap_data->listen_io, TRUE, NULL); + bap_data->listen_io = NULL; } } @@ -1097,6 +1072,8 @@ static void create_stream_for_bis(struct bap_data *bap_data, /* Create an internal copy for bcode */ setup->qos.bcast.bcode = util_iov_dup(qos->bcast.bcode, 1); + setup->data = bap_data; + queue_push_tail(bap_data->bcast_snks, setup); /* Create and configure stream */ @@ -1139,8 +1116,7 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, gpointer user_data) { GError *err = NULL; - struct bap_bcast_pa_req *req = user_data; - struct bap_data *data = btd_service_get_user_data(req->data.service); + struct bap_data *data = user_data; struct bt_iso_base base; struct bt_iso_qos qos; struct iovec iov; @@ -1156,7 +1132,7 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, error("%s", err->message); g_error_free(err); g_io_channel_shutdown(io, TRUE, NULL); - req->io_id = 0; + data->io_id = 0; return FALSE; } @@ -1165,18 +1141,10 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, g_io_channel_unref(data->listen_io); data->listen_io = NULL; - if (req->type == BAP_PA_LONG_REQ) { - /* If long-lived PA sync was requested, keep a reference - * to the PA sync io to keep the sync active. - */ - data->listen_io = io; - g_io_channel_ref(io); - } else { - /* For short-lived PA, the sync is no longer needed at - * this point, so the io can be closed. - */ - g_io_channel_shutdown(io, TRUE, NULL); - } + /* For short-lived PA, the sync is no longer needed at + * this point, so the io can be closed. + */ + g_io_channel_shutdown(io, TRUE, NULL); /* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities @@ -1191,23 +1159,21 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, util_iov_free(bap_qos.bcast.bcode, 1); - service_set_connecting(req->data.service); + service_set_connecting(data->service); - queue_remove(data->adapter->bcast_pa_requests, req); - req->io_id = 0; - free(req); + data->io_id = 0; return FALSE; } static void iso_pa_sync_confirm_cb(GIOChannel *io, void *user_data) { - struct bap_bcast_pa_req *req = user_data; + struct bap_data *data = user_data; /* PA Sync was established, wait for BIG Info report so that the * encryption flag is also available. */ DBG("PA Sync done"); - req->io_id = g_io_add_watch(io, G_IO_OUT, big_info_report_cb, + data->io_id = g_io_add_watch(io, G_IO_OUT, big_info_report_cb, user_data); } @@ -1262,7 +1228,7 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, struct bt_bap_pac *lpac, struct bt_bap_pac *rpac) { - struct btd_adapter *adapter = data->adapter->adapter; + struct btd_adapter *adapter = data->adapter; struct btd_device *device = data->device; struct bap_ep *ep; struct queue *queue; @@ -2109,95 +2075,13 @@ static void setup_listen_io(struct bap_data *data, struct bt_bap_stream *stream, data->listen_io = io; } -static void check_pa_req_in_progress(void *data, void *user_data) -{ - struct bap_bcast_pa_req *req = data; - - if (req->in_progress == TRUE) - *((bool *)user_data) = TRUE; -} - -static int pa_sync(struct bap_bcast_pa_req *req); -static void pa_and_big_sync(struct bap_bcast_pa_req *req); - -static gboolean pa_idle_timer(gpointer user_data) -{ - struct bap_adapter *adapter = user_data; - struct bap_bcast_pa_req *req; - bool in_progress = FALSE; - - /* Handle timer if no request is in progress */ - queue_foreach(adapter->bcast_pa_requests, check_pa_req_in_progress, - &in_progress); - if (in_progress == FALSE) { - req = queue_peek_head(adapter->bcast_pa_requests); - if (req != NULL) - switch (req->type) { - case BAP_PA_SHORT_REQ: - DBG("do short lived PA Sync"); - pa_sync(req); - break; - case BAP_PA_LONG_REQ: - DBG("do long lived PA Sync"); - pa_sync(req); - break; - case BAP_PA_BIG_SYNC_REQ: - DBG("do PA Sync and BIG Sync"); - pa_and_big_sync(req); - break; - } - else { - /* pa_req queue is empty, stop the timer by returning - * FALSE and set the pa_timer_id to 0. This will later - * be used to check if the timer is active. - */ - adapter->pa_timer_id = 0; - return FALSE; - } - } - - return TRUE; -} +static int pa_sync(struct bap_data *data); +static void pa_and_big_sync(struct bap_setup *setup); static void setup_accept_io_broadcast(struct bap_data *data, struct bap_setup *setup) { - struct bap_bcast_pa_req *req = new0(struct bap_bcast_pa_req, 1); - struct bap_adapter *adapter = data->adapter; - struct queue *links = bt_bap_stream_io_get_links(setup->stream); - const struct queue_entry *entry; - - /* Timer could be stopped if all other requests were treated. - * Check the state of the timer and turn it on so that this request - * can also be treated. - */ - if (adapter->pa_timer_id == 0) - adapter->pa_timer_id = g_timeout_add_seconds(PA_IDLE_TIMEOUT, - pa_idle_timer, - adapter); - - /* Add this request to the PA queue. - * We don't need to check the queue here, as we cannot have - * BAP_PA_BIG_SYNC_REQ before a short PA (BAP_PA_SHORT_REQ) - */ - req->type = BAP_PA_BIG_SYNC_REQ; - req->in_progress = FALSE; - req->bap_data = data; - - req->data.setups = queue_new(); - - /* Enqueue all linked setups to the request */ - queue_push_tail(req->data.setups, setup); - - for (entry = queue_get_entries(links); entry; - entry = entry->next) { - struct bt_bap_stream *stream = entry->data; - - queue_push_tail(req->data.setups, - bap_find_setup_by_stream(data, stream)); - } - - queue_push_tail(adapter->bcast_pa_requests, req); + pa_and_big_sync(setup); } static void setup_create_ucast_io(struct bap_data *data, @@ -2952,10 +2836,8 @@ static void bap_detached(struct bt_bap *bap, void *user_data) bap_data_remove(data); } -static int pa_sync(struct bap_bcast_pa_req *req) +static int pa_sync(struct bap_data *data) { - struct btd_service *service = req->data.service; - struct bap_data *data = btd_service_get_user_data(service); GError *err = NULL; if (data->listen_io) { @@ -2964,13 +2846,13 @@ static int pa_sync(struct bap_bcast_pa_req *req) } DBG("Create PA sync with this source"); - req->in_progress = TRUE; - data->listen_io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, req, + + data->listen_io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, data, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, - btd_adapter_get_address(data->adapter->adapter), + btd_adapter_get_address(data->adapter), BT_IO_OPT_SOURCE_TYPE, - btd_adapter_get_address_type(data->adapter->adapter), + btd_adapter_get_address_type(data->adapter), BT_IO_OPT_DEST_BDADDR, device_get_address(data->device), BT_IO_OPT_DEST_TYPE, @@ -2988,9 +2870,9 @@ static int pa_sync(struct bap_bcast_pa_req *req) static void append_setup(void *data, void *user_data) { - struct bap_setup *setup = data; + struct bt_bap_stream *stream = data; struct sockaddr_iso_bc *addr = user_data; - char *path = bt_bap_stream_get_user_data(setup->stream); + char *path = bt_bap_stream_get_user_data(stream); int bis = 1; int s_err; const char *strbis = NULL; @@ -3015,39 +2897,36 @@ static void append_setup(void *data, void *user_data) static void setup_refresh_qos(void *data, void *user_data) { - struct bap_setup *setup = data; + struct bt_bap_stream *stream = data; + struct bap_data *bap_data = user_data; + struct bap_setup *setup = bap_find_setup_by_stream(bap_data, stream); - setup->qos = *bt_bap_stream_get_qos(setup->stream); + setup->qos = *bt_bap_stream_get_qos(stream); } static void iso_do_big_sync(GIOChannel *io, void *user_data) { GError *err = NULL; - struct bap_bcast_pa_req *req = user_data; - struct queue *setups = req->data.setups; - struct bap_setup *setup = queue_peek_head(setups); - struct bap_data *data = req->bap_data; + struct bap_setup *setup = user_data; + struct bap_data *data = setup->data; struct sockaddr_iso_bc iso_bc_addr = {0}; struct bt_iso_qos qos; + struct queue *links = bt_bap_stream_io_get_links(setup->stream); DBG("PA Sync done"); - if (req->io) { - g_io_channel_unref(req->io); - g_io_channel_shutdown(req->io, TRUE, NULL); - req->io = io; - g_io_channel_ref(req->io); - } - - 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)); + g_io_channel_unref(data->listen_io); + g_io_channel_shutdown(data->listen_io, TRUE, NULL); + data->listen_io = io; + g_io_channel_ref(data->listen_io); /* Append each linked BIS to the BIG sync request */ - queue_foreach(setups, append_setup, &iso_bc_addr); + append_setup(setup->stream, &iso_bc_addr); + queue_foreach(links, append_setup, &iso_bc_addr); /* Refresh qos stored in setups */ - queue_foreach(setups, setup_refresh_qos, NULL); + setup->qos = *bt_bap_stream_get_qos(setup->stream); + queue_foreach(links, setup_refresh_qos, data); /* Set the user requested QOS */ bap_qos_to_iso_qos(&setup->qos, &qos); @@ -3061,7 +2940,7 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) if (!bt_io_bcast_accept(io, iso_bcast_confirm_cb, - req, NULL, &err, + setup, 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)) { @@ -3070,28 +2949,16 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) } } -static void pa_and_big_sync(struct bap_bcast_pa_req *req) +static void pa_and_big_sync(struct bap_setup *setup) { GError *err = NULL; - struct bap_data *bap_data = req->bap_data; - - req->in_progress = TRUE; - - if (bap_data->listen_io) { - /* If there is an active listen io for the BAP session - * with the Broadcast Source, it means that PA sync is - * already established. Go straight to establishing BIG - * sync. - */ - iso_do_big_sync(bap_data->listen_io, req); - return; - } + struct bap_data *bap_data = setup->data; DBG("Create PA sync with this source"); - req->io = bt_io_listen(NULL, iso_do_big_sync, req, + bap_data->listen_io = bt_io_listen(NULL, iso_do_big_sync, setup, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, - btd_adapter_get_address(bap_data->adapter->adapter), + btd_adapter_get_address(bap_data->adapter), BT_IO_OPT_DEST_BDADDR, device_get_address(bap_data->device), BT_IO_OPT_DEST_TYPE, @@ -3099,26 +2966,17 @@ static void pa_and_big_sync(struct bap_bcast_pa_req *req) BT_IO_OPT_MODE, BT_IO_MODE_ISO, BT_IO_OPT_QOS, &bap_sink_pa_qos, BT_IO_OPT_INVALID); - if (!req->io) { + if (!bap_data->listen_io) { error("%s", err->message); g_error_free(err); } } -static bool match_bap_adapter(const void *data, const void *match_data) -{ - struct bap_adapter *adapter = (struct bap_adapter *)data; - - return adapter->adapter == match_data; -} - static int bap_bcast_probe(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); struct btd_adapter *adapter = device_get_adapter(device); struct btd_gatt_database *database = btd_adapter_get_database(adapter); - struct bap_bcast_pa_req *req; - uint8_t type = BAP_PA_LONG_REQ; struct bap_data *data; int ret = 0; @@ -3127,27 +2985,10 @@ static int bap_bcast_probe(struct btd_service *service) return -ENOTSUP; } - data = queue_find(sessions, match_device, device); - if (data && data->service) { - error("Profile probed twice for the same device!"); - return -EINVAL; - } - - if (!data) { - data = bap_data_new(device); - data->device = device; - bap_data_add(data); - - /* The Broadcaster was scanned autonomously, - * so it should be probed short-lived. - */ - type = BAP_PA_SHORT_REQ; - } - + data = bap_data_new(device); data->service = service; - btd_service_set_user_data(service, data); - - data->adapter = queue_find(adapters, match_bap_adapter, adapter); + 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) { @@ -3155,9 +2996,6 @@ static int bap_bcast_probe(struct btd_service *service) free(data); return -EINVAL; } - - bt_bap_set_debug(data->bap, bap_debug, NULL, NULL); - data->bcast_snks = queue_new(); if (!bt_bap_attach(data->bap, NULL)) { @@ -3165,6 +3003,8 @@ static int bap_bcast_probe(struct btd_service *service) return -EINVAL; } + bap_data_add(data); + data->ready_id = bt_bap_ready_register(data->bap, bap_ready, service, NULL); data->state_id = bt_bap_state_register(data->bap, bap_state_bcast_sink, @@ -3178,36 +3018,15 @@ static int bap_bcast_probe(struct btd_service *service) /* Return if probed device was handled inside BASS. */ return ret; - /* Start the PA timer if it hasn't been started yet */ - if (data->adapter->pa_timer_id == 0) - data->adapter->pa_timer_id = g_timeout_add_seconds( - PA_IDLE_TIMEOUT, - pa_idle_timer, - data->adapter); - - /* Enqueue this device advertisement so that we can create PA sync. */ - DBG("enqueue service: %p", service); - req = new0(struct bap_bcast_pa_req, 1); - req->type = type; - req->in_progress = FALSE; - req->data.service = service; - queue_push_tail(data->adapter->bcast_pa_requests, req); + pa_sync(data); return 0; } -static bool match_service(const void *data, const void *match_data) -{ - struct bap_bcast_pa_req *req = (struct bap_bcast_pa_req *)data; - - return req->data.service == match_data; -} - static void bap_bcast_remove(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); struct bap_data *data; - struct bap_bcast_pa_req *req; char addr[18]; ba2str(device_get_address(device), addr); @@ -3218,17 +3037,6 @@ static void bap_bcast_remove(struct btd_service *service) error("BAP service not handled by profile"); return; } - /* Remove the corresponding entry from the pa_req queue. Any pa_req that - * are in progress will be stopped by bap_data_remove which calls - * bap_data_free. - */ - req = queue_remove_if(data->adapter->bcast_pa_requests, - match_service, service); - if (req && req->io_id) { - g_source_remove(req->io_id); - req->io_id = 0; - } - free(req); /* Notify the BASS plugin about the removed session. */ bass_bcast_remove(device); @@ -3370,13 +3178,7 @@ static int bap_adapter_probe(struct btd_profile *p, struct btd_adapter *adapter) bt_bap_set_user_data(data->bap, adapter); bap_data_set_user_data(data, adapter); - data->adapter = new0(struct bap_adapter, 1); - data->adapter->adapter = adapter; - - if (adapters == NULL) - adapters = queue_new(); - data->adapter->bcast_pa_requests = queue_new(); - queue_push_tail(adapters, data->adapter); + data->adapter = adapter; return 0; } @@ -3391,15 +3193,6 @@ static void bap_adapter_remove(struct btd_profile *p, ba2str(btd_adapter_get_address(adapter), addr); DBG("%s", addr); - queue_destroy(data->adapter->bcast_pa_requests, free); - queue_remove(adapters, data->adapter); - free(data->adapter); - - if (queue_isempty(adapters)) { - queue_destroy(adapters, NULL); - adapters = NULL; - } - if (!data) { error("BAP service not handled by profile"); return;