From patchwork Fri Mar 1 15:00:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 777560 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2062.outbound.protection.outlook.com [40.107.6.62]) (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 5A7FF3A8E3 for ; Fri, 1 Mar 2024 15:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305242; cv=fail; b=uj7JrhF4BNNp21FNkKGme795hCidVuywN9YJQeN7j3/vIFlZ2pwzy74IIls+ns5eaQ08aFfb07Y/ncemXNzqLeI3W3oAlafz6lWPnkzSom8Ii+8H2vmDr2TmfHFeSaxOTvfEAp+h6q/OSpvPGtDT9sDyNNEe8I6jvk0GOLKyeLI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305242; c=relaxed/simple; bh=8T76MGvqt67Sf/OVv4K4SqtghoUeF6SC+QjyHT1o+fs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SPzCfRTV4w7bMBFMO26Rg+cSHNKP/yREtbP6BY8fVflcBI/K4r/OsXmcOvtpnVEstq8h6L/JIVrVy7CDkzlPtXs+9OdEuMi0C2peZVILCaKwIbHop6Eei2N4m2TwD1+gLDXoHL50lLVvZAijymQpNgCOEIl3SfB7tjB/kQf3oK0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=seznnjDY; arc=fail smtp.client-ip=40.107.6.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="seznnjDY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KAqM3mZVlsPnR3kDwyR3Anyl3ZX42LA18a9beMYK0uufnFuMnUGf0MiUEFxTsQJJ+MLTJ7uU3loQGeWtmFLi0ncOIswYDsApPtXqzhEYoVUS1vEAy170KEw4VoDKBeaqCelhECOuq6b6+sbkiR73f7yPkMVrcdROzhQF3pAXwgbgHtkugjj1YuaZZ+8jw6h5kjX5a4ArqBmkwCROVh+1yzhJAE/kw6cyuv4KJ2WNUFLaYOTmqc5MfIKYAH3HWJsf7qd3Onzn/de9vTJzn+Jmo1jz5iN22lTO+kskZH3MFwdR6bgC2fBZPD9VAGkfpUb20MaN50hjC0UmqD/qTI5RVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w+Rcwz4uaTYx9IrPIeI4AHpPq55Yy2Eqd1RPQvkHC4Y=; b=l7luS0FlxKoLaMDK8RvJ36mA2XqWbx3A3PCKGhVDVtNaD5XL9lTqw8f+eN+EB3gDCJjCCU5cLq5I1lKlli0p5UxOW0o4sUaTE/uqUzUZWSqWAVY9IBXpIdzqseEwf6BWvYDzl2UQeKMZCqVZhwrCgMmS1f2z4ioq2F07NT/8us4ZIM469K4Q0UePtQPEOPn4ABFTD1fAqFB7j87qdm+rC5J3jXsrPO9hYlfiFXPybCakG2MVgTd/C7aV1qrF0zPylGNuL1eDZZjJit3OoMlIaCjeH570OLBnev7mjv/XfLZfeb4mBtJ6kF7czdjqPTR64eqf5I1Dr/G6KtnyJALnGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w+Rcwz4uaTYx9IrPIeI4AHpPq55Yy2Eqd1RPQvkHC4Y=; b=seznnjDYRqDWp3q49fYh/xWevc/zR9LCyPZe3XZYJdUgMWE+G4XNjFtOH23ZPxTh4AWLvgsDzzdwpvl9NlSYt9gbljz9tvafPz47N8fLytJUzIGUdDrf1ny5q6c8OMbJzOsIBi7FId+29ii30hYlefjzBNaCC/qq8oZUw8bDwLI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by PAWPR04MB9837.eurprd04.prod.outlook.com (2603:10a6:102:385::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Fri, 1 Mar 2024 15:00:37 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f%6]) with mapi id 15.20.7316.039; Fri, 1 Mar 2024 15:00:36 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ v5 1/6] shared/util: Add push LTV utilitary function Date: Fri, 1 Mar 2024 17:00:24 +0200 Message-Id: <20240301150029.14386-2-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240301150029.14386-1-andrei.istodorescu@nxp.com> References: <20240301150029.14386-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AS4P192CA0008.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::6) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|PAWPR04MB9837:EE_ X-MS-Office365-Filtering-Correlation-Id: f69ac3b2-8b99-4059-9e92-08dc3a005a3a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AuaHsNJV2agFJWThMauhVEh1HRahbRq6yO9ahUBlEKx3Y92JAFAZZ/u1cO9l5tlfMwrGVJtJH4kxB0v5p+g3Qdmay0ZsCQnnkTnscTRJ+GZzqOK2HzF15DBY5mpnY0D/gJ3DI+nzww2I55Bz9jBSG+fMQ0P65Bv362tZ3tou1fbNDzOffTpl8Q0G73lf6HTTtdU5x3qkeSAdalaTKFg8rsD1GkUWphOoySwGqFymThntC8yvVbrrILqERKMGJLJSh+BhNsBbgoyRdaZKhgySrAcsuJCG4uCV/WeUAQWfEaLK3/71VxCzy5plq0S1Cxpx04oL3tXVcJb/y48+zlUkdzxyhLA0ySkyLNXDuCphCO7ODZHUS1AnMP3cRwwIMEhJD0kRfXEhXqKVV8vio3uNbl8IvCJ3fDqyL45Lto+xTtn89m8lEG1FizDMwltaJh2NM4v+H63yIay2W4TBaZPLkxRk2vHM9a9TkgHvRZWvvAhXoc374e2tZAweBkOgeqanOHArf8I0DFQp7xgozEYRXm942lN+PeH8PoWgM1W8I7IRSgAvmWK/NhI8CpuDlpbAiJ0A8SyfWDgeAnlPIMRXB4JrJwC6pM8sq0T81oDvaC93M5hYzFe/PzAICM3bz1+T7LRdgrn2WSypfSwswaOQKg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8938.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KK2wOdEBbo9fiOCucrTEskGUnaD4Q17STTEUBimRoMouQhHCS4fDH3d9z3qgcFsMifdjKQSnaeoVSIvJvDp+dl57vq3CLBWF/FxXQ22YyaduDx9fIrv2bQE5kRDtYrgxVxZGEy1u6QWY8ITHgCo3RjjaVGY93+4elbiObdy2Rf0Mq4x/tfvS198M/OQntIcy4IknNTQjLgOehB/ffdyZHW1lhLMjdkoxL4OQrd+S6OI2wy8CfmY2emvAo7UHidKentXfTSWFzX9HALEn7lNJCuDyJZv6qvQW/hbzuEDPOElkFQl1ES5Q+3wTbqeBgw1GQU2jmIVO1VF3YLjRrQJ0FepykNkh6vaMrKpA+GNSLkOlETaLXm1Xl+QujH5qbKT3O1V5Dh+RPBPdiznXYL3w6SH1Q18rIukgQJeCZNucoMAsjw4MkG3jks9vuXJWEfy6xJIa0Up3LGerZGeGhl/+0MUwR2WQqeKFzHi0kqWFoEOrwFgGAe4ilLLVZDs02Bb+GDEtlQYG2L0dWwq2w2FyPZdxjVXgkqgFVCpjJ3JE1AIcd0RVladWU9JbA6Hpehx8+gBcOFMi/QS0TeoteTQ0Njk8yB6IPQdDQAXto7a6oBkMves8deMlTRH7KTvaP9ZWUAR/iK7IYBmFkimUa7qlEDFLlUQXssjS11MunaRAPQ/+v5mwcxs2lzI+qk7QQ19BUgxvNG9WjKeLgss1pSNOkhu/3IbImxQyVp63i2UrfoQSP9bDk7YknfyvAPQ4hbv1heDyh1P1OOJMpAWJYzIIdh4S+VL04EZReHexta0hH+IeynBUvrV5M4fFb2ha4pC8w+G9hfjy+D6P/oVzRFfSBdFkdHJd1/ea3wEhnSXP8DnDChA7gLpWWPEFs7X84Q2zC1lTbD848QqWQJgY5WZvWR/nzwZmKp/wYhFC7FtOo3UzV22yna8gzJA3zI0pkpEXeoT42OyyNS6Mb24Jk1WqS97EvDSd7z3Y0ovkfs/YHmfrupc8vqALmBOPMvrvSBDlxnyIcBVgnnHWuQ5pdkUMugUNCfdgQPHRJHiHz1YxNVEaSQJSKXuquDXr1Vv34v8OF63NzMI98NPFUcBguAoV+zwVwGIRbT4yogwVGLSwoDJRvCvhA6bqxc4PaaI8bt3BT9dSS4aH2n0858E1O0iAN28MqQ9VdtibjK9P1W0unFKy9vFAvzEVGmXV4vpNEW6561EUQlyo7YAT61N9e2Eew5xI3nsO4/bxVER5iQJnR6HW53FCH31L5Yt8rYwHtVkwS6ATL5hP/UhhKFl3+eMQmfcXQcAsYZ9J1FmfUNnMLtjlcVLUzy4NwETpd0L9O9ymzpqLL50r7+kb7NSvEd4bUzB+5gvrqPQTv6dnMa39v+wh1WeMgQGOqSDXnyV+Z8T+bkW2n8VpqKPY2DvuSbQxNnY3JwLTvHMje7W6BsoO4Q2i3DEIeuTtJ7XncO8VTxZjmGy3HUrD+xK1tpzXzRIIb7KlB84/EodKtTGHfmKaBVI9U85N5XhK4c+CcJeAqCzfCU50KtIrfc+DjufLJpD0ruHlxhTs55RnETifvSAG0fgrpzhEHP8Db0AG60cBLmzyHxfXwj8utbDBiAZfaGmieA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f69ac3b2-8b99-4059-9e92-08dc3a005a3a X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2024 15:00:36.9446 (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: FOCSgiP9Gp5htdDukglPJwU0v3c/WAztLVxXdD2LlNDg2MTICUVmlFX8N+R69DXgghoBarAfj1woHON6CTv8WdvIb7nWAaan2EBz8R/SAt4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9837 --- src/shared/util.c | 11 ++++++++++- src/shared/util.h | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/shared/util.c b/src/shared/util.c index c0c2c4a17f12..74d43671c108 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -4,7 +4,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * * */ @@ -218,6 +218,15 @@ bool util_ltv_foreach(const uint8_t *data, uint8_t len, uint8_t *type, return true; } +/* Helper to add l,t,v data in an iovec struct */ +void util_ltv_push(struct iovec *output, uint8_t l, uint8_t t, void *v) +{ + output->iov_base = realloc(output->iov_base, output->iov_len + l + 2); + util_iov_push_u8(output, l + 1); + util_iov_push_u8(output, t); + util_iov_push_mem(output, l, v); +} + /* Helper to print debug information of LTV entries */ bool util_debug_ltv(const uint8_t *data, uint8_t len, const struct util_ltv_debugger *debugger, size_t num, diff --git a/src/shared/util.h b/src/shared/util.h index 6322b13d612a..accacc79ee8b 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -4,7 +4,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * * */ @@ -134,6 +134,8 @@ struct util_ltv_debugger { util_debug_func_t func, void *user_data); }; +void util_ltv_push(struct iovec *output, uint8_t l, uint8_t t, void *v); + bool util_debug_ltv(const uint8_t *data, uint8_t len, const struct util_ltv_debugger *debugger, size_t num, util_debug_func_t function, void *user_data); From patchwork Fri Mar 1 15:00:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 777177 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2062.outbound.protection.outlook.com [40.107.6.62]) (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 B9C253A8FD for ; Fri, 1 Mar 2024 15:00:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305244; cv=fail; b=X6Z7oJKFz+NV6o+z2fLst8h2lpw9on60eAvOQnQpdlCTbj8hny2OxVwNucQhaX9D1lat5nQrI6Y7Y/cLO2E0gq50R6aYIkImJlLH8dzXkmYDQPIj8cR6IMRzf7MLo8FAdljbAfJ5Ts9sMinZ/eian3kXMX3PD5PpmONr3Dc+Phg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305244; c=relaxed/simple; bh=G0ApxJKqEdsmqRQek5FpK8jEP+SiHXemOgK/YoaKAyw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=bUjWmnzhCt2GLpodaIeX0uL9eTikyqZ3B4Av4yM0LJmAQRubLaSc5/Zk2pmc+UbC7N4ohxoskDGQ3R6S9SFmuS1ayP2dCQpc0SsT87jZI+vUDiB6KWiMfx15d5/mnECnjV24WtlqC5lElWhNwJcJCF3a/pyJrTSNaN5B6HPeJyg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=UpPKHLvV; arc=fail smtp.client-ip=40.107.6.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="UpPKHLvV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GbjYoBGT5RlJgQoNC57V575t/KYQ452hpvIIKnucArKod6Y81ofQ2Aj9tQxccUaeMjIWw01gHMOLiDfYEKbgMB6hgfY1IlqQtb+6Mmha9PLyFXh+chVdNtmIevRKerIMED+ZFQ4P+AW6w/PvrtUB8lP/OIoWyBhNvX1VvKQ/4q2iEzFa7iEEkJKqIcVEoubPyMGjyFmCpNAr8VAbXz5kMCvZdxleXBzvEfS3N854tzdk6rcNTAOwD1LUsp5ch1qII3Gkguz2iT0EcTIq9f5VtgUOiyM0I1pfTUgjyiLrUC05UAfYCPIePT6sgAaEEqbmC6FcSAFBJMDaHw77IwvbJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HcT+cC31PBJwlNnSj/hC7KZanpB256aIxem2zdG6PS4=; b=RHrwBYGfR8yJTxP2shvhigLO21eDwk/L4uqQue5RE2+qaUvOJsz9qlle93AMaMghez8ezAy4tXsdTjClRZ8azLwUwI3aAG7nUrck0gR05H+euBSjEsN0Id9WHgSnQ3bEGQp+dPBdjrwoL1U6Ww4O7xeD4sWNVH0d5ZCLrcFPImvhO9ZGkBwH0XYorHhCCulHyFjjGd756bCfviL0AEKKI660orgRx9pyVMSB85E7eDdS5qxqejUt17nwelnEnzSMeTtRbyqH/1ZivC8OPxyq/8P623Pn20skBO9l687DiVHvsc7v58TcducvQakkbM9KAT6KjlSas/mdZvisJEUuig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HcT+cC31PBJwlNnSj/hC7KZanpB256aIxem2zdG6PS4=; b=UpPKHLvVpITOguL90FHgxCszfqn2qFqEr6dUyour6FeqPJFTZJMr8ByMnSml3EGg7o7yRk92QiDH2k3RwI1GZzN3e7qDLiGelfMz7PW5QR7WCD3bePakOSFbKh0X2JSLgOkVvvmVhmXgXoB2ChhOHLv6jyrFk4p+r88kQg4sAjc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by PAWPR04MB9837.eurprd04.prod.outlook.com (2603:10a6:102:385::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Fri, 1 Mar 2024 15:00:39 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f%6]) with mapi id 15.20.7316.039; Fri, 1 Mar 2024 15:00:39 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ v5 2/6] shared/bap: Allow reading endpoint metadata and data Date: Fri, 1 Mar 2024 17:00:25 +0200 Message-Id: <20240301150029.14386-3-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240301150029.14386-1-andrei.istodorescu@nxp.com> References: <20240301150029.14386-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AS4P192CA0003.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::13) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|PAWPR04MB9837:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d170d23-ca11-4846-c6aa-08dc3a005b6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /XQl9DyiFgnsiWvDPYI4v4sYEbmmbIZP6x0+k1EfSjysyDGoK1Vr21Ov7Xwyh/k0M0USLFC/Q5leZNBHi49pqrt2PYd2vOeUQYC5srufodu0jhfveTXPHKYATAfs6pl2OKftD37rL+egSh/KAi7Xnbpq9c7d0033941kBWe16i1VDKX/5vYO6mjbF0pzLqJ37q7KZPvHdc/iaASvXXXml2PFPQH+LjXY8DdSOLq6OI8hugR38CiuTiCnhlot9j9oT81YhxEG3M3+xOfxLCum2lYbK1VWFQ+F0Cl/hsj8SaS3y73B+qmM7dhYdJMkaMzPckuxR16lOIAXgz9+JWI4+5HDTxb1zQXBaHWChG1o363Oaj1lyzyyqDB61fP6R33eDj7PuHIrdmEP39fp0zoyTq5VUi7NqemEQh23of93AHHrNZWJ52E50vXHAOaOXD9q2kyBwmJhh4UfEl5jLdQihqRTqHol5IevrfNdaTl+/nGzlAIBOA6CkYiua63HhAazxge1A+QtVuMuf2lDv9Kl8Mx6vt0trMmHZ/SG/+/SH6tjxmMVkubGEgGaevVD7TtEVEsOs14zLhKMIKUSnKX59KAzH8R6FSy7A47zF0Q4xe6AOjqKBxWEUHkOWjAzxPYo X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8938.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Sdsol0iJgUWddKEXZiaWPc6l+M7emd6rfzIdj1KOFtXGsmNcRgqtMLK34tFKa9sZxGOuC5sCnRUp5i9p/jMqcE1FsfWvsXWF3iPLyqqGcGtmCmw6IkblYf2iADlq6JloNLb1R5YMqDr9wkzaOAvZBy85Ri65Ipm+HKsEggo6I8RPVmBhTW4YHR5ZVN0ggFQLKxNGRDBt2dqV6VMHLLffHBNLJuSf7lJwdeuBtmhK1QsWXfrODOC3GglOG+CgXMgdL15jg7Eapw6SgZthu6pWFYnXZnBQp0CwvfPDWHFzf97tkbG4L2Y7PA4qtlM5g2Oz6yPmnqm9WRt29lKEZLCPiYb8DZKWqcFYwGFV6Ua/DFQof1tyYsu/T75Zr339OeMKaQ7+FH5iO1XUWvbkoOdQnzRyTpG/g/NEErfIBvoSf2ijnbzUdQpEsEl+EDYZG6KkyXggfMmnR+CLNfp1YI9/tAXVa+Cr+R9MX0NhTeCs0N7OpiMOPEIvSu68yy4ybT1tMF/dpst6wwWqXGi3rOBPWqs8YDz8u7P/c/aQkuzuAgAErq2eLsT4Ks+u2wYDt99KPlpn7D4d1Cf+wfk9j1vXbPoNE/HHN6Ji/OC+0h+witzpk+syBmvU8EheJcXubJboN2y1v2d4TF2te9gNA4hobqIa2SiVIPzNorm1pulmZkibkpyyY+54WTaqK7aj6d6DmoJ/5szSZHhAphP0oYgbAAMp1gfB0FFgmVJSOXdAuLnHVdfK4GCuPz/695ikFOA7EqtWNPQvsAdKDEc/2yTfOo00LhxMMqgSrHmTPfLyGT/7hOrlznygvKSE9XkckdCGrt/WKws1Eqh2xmtCzIVUR1EPyZcMGS5lbsOoewUjlqDPEzgEFzrjDZuVWeNjJ/zmcfYXJeZyEZtdIYa4rI8nw9m6XgfjwBBf+6s34KU3evVHO1NSn5bRVvIZHjmlI/OdWVQHoNzQpX3zYuCduOv1Y7enZjvA1gRq9t4VPzgDHz3eagsmZRXpJF1l1pS+9oyPvELdNYYiUYyKzltOwvbGhI38cVggFV9DInkNdlI/RVPYM1SXHDZsxfTdpAa0oUN8cgbRik3b7nspArJ4bTvP6uGMSbUZuVhJM8+0+nY20yPdYTY/XGKdbBmxVFQGBEJX4GEe7E0Yrkt+5xxIjTAHVV+Sk4gqAb14xEGar09lIDD716XuugFs+eNVIWqODGlSma4pHQwzsr5B+1w/4FGlYChmv2sf5d27gcMEu+tpjz75C3izg6V4eJjxELvbzQ6rAaJtnrhZHzr/iI2JqNeDp8yXfAPKprFO2w3EetZVK6v+VLuH/8MJzT1WbYClJ5ORNns+Sr/ntYGXGQCifYPptRXUC+nXnNjUW8PVgT0+ZXyHRc4u/dkoFLOVCNo7pBgvTrkLQ8pYBptb+IPj8LXR5YyyMoKiWBC37v6Ajaec3JztLcdF6sFb4owRTy6AFJ8fzypCByl4ln+7DPsT3vqWqWZ+VmGOAk23qQBvl1WKykaQQHASifmDj8Pz4M03NNiSox+NOwX7bIqO4Y+DIVWzq39eMoL76kKwFTdfcjXi4CSYunXWDH/vAYsKf2Scf2DSqzjEi/HqOXoCrbImh8hTIw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d170d23-ca11-4846-c6aa-08dc3a005b6b X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2024 15:00:38.9883 (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: aaLjE+Fi+7vVeIKTZOlV/ZkCQp75kks8lqrLvMFRWHpIXEqlDTMOW2VcZNjAwqTleJ3sFyn635u9diuSuj4EAdb1/6oMFRnw4TFTHxeXRC8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9837 Add utilitary functions to get endpoint metadata and data. --- src/shared/bap.c | 10 ++++++++++ src/shared/bap.h | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 0931c8fa249f..a44b5534805e 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -3457,6 +3457,16 @@ struct bt_bap_pac_qos *bt_bap_pac_get_qos(struct bt_bap_pac *pac) return &pac->qos; } +struct iovec *bt_bap_pac_get_data(struct bt_bap_pac *pac) +{ + return pac->data; +} + +struct iovec *bt_bap_pac_get_metadata(struct bt_bap_pac *pac) +{ + return pac->metadata; +} + uint8_t bt_bap_stream_get_type(struct bt_bap_stream *stream) { if (!stream) diff --git a/src/shared/bap.h b/src/shared/bap.h index fa0d4b524ffd..e4785b587e3a 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -4,7 +4,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2022 Intel Corporation. All rights reserved. - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * */ @@ -175,6 +175,10 @@ uint16_t bt_bap_pac_get_context(struct bt_bap_pac *pac); struct bt_bap_pac_qos *bt_bap_pac_get_qos(struct bt_bap_pac *pac); +struct iovec *bt_bap_pac_get_data(struct bt_bap_pac *pac); + +struct iovec *bt_bap_pac_get_metadata(struct bt_bap_pac *pac); + uint8_t bt_bap_stream_get_type(struct bt_bap_stream *stream); struct bt_bap_stream *bt_bap_pac_get_stream(struct bt_bap_pac *pac); From patchwork Fri Mar 1 15:00:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 777559 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2062.outbound.protection.outlook.com [40.107.6.62]) (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 EE2C941A81 for ; Fri, 1 Mar 2024 15:00:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305247; cv=fail; b=HJ4T2X34dGP6hBeglDstIyfQoyTkKI29R8uvJ0Gqel/FsxRNdPvEmvuQRzCIAXPDZAg5API0WOAYEEdIdCv1fVUttK2SqwOs924X8a//fMUlvC1JGG94mFflvfLTPEWKM27arfODbjR4Z/EjgEtsosgXZBn7RF0oR/nkX8Olu8Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305247; c=relaxed/simple; bh=roLM+/eEFxg8jca7hhFgE6SYnbS3E5Mg55iaDK3LgBw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=grRvHWnYwisAJ22263JNd6C+rUxp/71j/oTyRxU/rciUu2ZkX1omBQ+SgUii3GB6ug+woM+dFGOLcLzaX6K0bQab8uLml1AEvd3nQTqdjtyHm/8w4Vh1Fq03Sbchn/lJEoKLC3u49B/9p4474O/uV3fOXi3S6VWFzGikBfk+Zps= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=lPzpo+mf; arc=fail smtp.client-ip=40.107.6.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="lPzpo+mf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RhM3O+njGY6dKEU2Sh/xosCq4eEXKjTtiJd5UixF7QhlxSG5oPrvjiJ0ynjMK1D4dajzRyP2AOquBTmn0pIdWLcFsOSFQhCTH5czI4RUfnLvzSQe4BixQ3tfnwprvWeYt8B7/BnvKb88m8I13+DWzNdIO8TkS0VNP24ItFJcj2/+XyDHhLi9FR4AalByGmPDNxpzF8kARUObaYTuBqDsNOVEAaxMeNV2j/1EGkhAmkVJYP9Bu/u1tPct5icQ+BoUj9ANzLwEjaKF2l9I08trI9WhfvZq4h4KPC3HuYku/Sa3sIbM4OzZ8MF8t6GWzcDJ3C6B9xbEG3QTHK//Fa0q2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xfdQb7yClhH3S70tYz6UQMFjCcTS/F7iwUczdWemp5k=; b=ElG9l5m65lt9C+GZfAjvxsIGnaALEvJ0OTrjvhUTdKs19JbGtnjHu02KGCK/Xqyj09h+GZp9vT1zn8Ixrdkuq8/b9s2k3KjLDtJM4HLBOmxihmGVVy+iiLyJIb6qyfZwqgjVi5y5d/yKQAwWM/ihlo8UQlfqmATed/ITbuNmxOidzQvaDgEXzZoeMHsLthTwsCkPmEVaNgerEUIyht8KVodRvuA/++LJKXR2N2Os8PfzmdH1kqyQ8M2gXz9zbM/1JkN2b8nEpghAAJ5iMY7hmzkRX2+kFSzSuvO8jwwVrDcGdjBx92BlL68KnWXvb5mJ+co5+ol+kMP2dqXZQKA50g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xfdQb7yClhH3S70tYz6UQMFjCcTS/F7iwUczdWemp5k=; b=lPzpo+mfSzkeYSww6fBta/vdjpct82GEK0Z4lZweDcXkalJ8yDV6StDTQF/gGboZ/O6f1TlUqJuboHeUj1Nz0WUHoODacb8O4q5peWE/xhv1nmG3zx39S8OVPdnGbK7tFtIwXltxI6dgr1RAE1orMuv46P70/rYNhqq4iSGwM70= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by PAWPR04MB9837.eurprd04.prod.outlook.com (2603:10a6:102:385::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Fri, 1 Mar 2024 15:00:41 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f%6]) with mapi id 15.20.7316.039; Fri, 1 Mar 2024 15:00:41 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ v5 3/6] shared/bap: Update local PACS for broadcast sink also Date: Fri, 1 Mar 2024 17:00:26 +0200 Message-Id: <20240301150029.14386-4-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240301150029.14386-1-andrei.istodorescu@nxp.com> References: <20240301150029.14386-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AM0PR01CA0139.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::44) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|PAWPR04MB9837:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f87a278-e873-4a3d-1f65-08dc3a005cbf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gHxfb8DwM/2gGj2kSC/xFvkGhUWH9XB4bHT6qG6fGfyadABmXP3IB2HC4WE28Yh4BlA0ULa2DsDvjY3LUwOmcVGDQWvJM9Y/luHhFHplNcWUlWQ4DplZhQxXJAFg2iLVIoVrorARD8Q1KpK5xaUHbbvUxTd6JhMaZMuwmxZ/5K5mcXHDAmTtO2Ku+mRd+8hYnLHSCe0imtsYYidUEBAfmBiyTvPXC4wWA8rwP7Tts6Wi3fTzDIfZYUyNB6GZnnz6Jda7OkWg/YbbMp5ppeuuVF5lLMvuTxHeFDvQOWhpbwz3FauFsrXEC+nr3JBnl/b66VLOSO81XjvFvwjkC+VyYY9nwKvglgq3S4rHayTO1/aojFfhnmvtjE4tTPp6gTWcuHw4npqhlL+XrHaDI4/GfKyOKaK0FHV1OdwXAhkzkj6TSYBYYA6DntGT/8IG/MvDUWXtIAar4Xdygo1JxIDqdRNDrc52hQLe08CQQ9uW7nnTk1v3WuYikpMrTOtt19rnv433J+AUxoR+INzt7ZPp/XKbUlqd9swUZMfhalO3i9U4cMkq4Nuck+Su0KYIuFQmIceL7tisNMB48jPwUMfch1/xOsVQw+FkO+DbIZyn66ebGYyX0tAbMadO7kmMgvN4 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8938.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RgwE6DHJ0nbxuOgOtpGaLkUzJQDti7cSiMKT20I9ElgRRRwy30bPc9DvOCB7NklxWe5LSXf0QAvOqRg1HG3+qO7p8C3M1bzFy1RZ+Y8r9vFmQPYOeYv4iLlMEfNAvYMXpmInBu7EJibvoFvNx8pXt2fCCK53c8YU+eETYCxyeDRCh8W9T3lgunc4Gn5ksHG2RrWh9YBa5IcldZ5qZFvEpdA3r+knIlv0nFqk2/Z+8ETN9UzVLDKzB/TndDIF3Q+6GKx1taIFCrLSzpGvQC9HPlzyY4I9oFGD/PJ2hpUCt1ybLM1Gs4OwBcCaEiLiXNFaTB3QBrCpSXNJf1YvR/prZf2rcLrEBzQ/HCW0yPXS14tkXNyU8EJLU+fBn7e7ITs47v8DrsNg4T9X6cp3okSuqu7C9saBCo07yB3VCFq6IhpjYHtnRWacnNTM9TKdjPGAEqDLh+T9mLbFfQbtDlLPPdqF0IBfZf7I4C6HpzbIR+LxCloxXIfaHdcFOBhptsNY1y8Jen0eOww1VRotoR0zOhflaR3Li1TFTcz1xF/pCAoGqToGe/sSwsGI4vPtPfrS+PZ4aHXq970NNGXyGn/S3RF70NaREKW6IaaAPGYXSbIrIelPSBTONpu2et11hlSJNi6agDt4ShTcvCA1p3HJFTDQL1wZPNnVp2hNtTUFjzVeq1cUJPaJBUeOMSffiZOgE/zUAAX7eceBF/HBHd9f8ftIGoxjP2j0CiYwUsjP2CRQ0LmltYARlobhVs/AdmCeToy8n74L4eKSajrL6ZrgIh/o0CEXNXMJoiP4F+bIm5JF/vZ6fiIb6b1Izbpz6B5dh2/MZNG/IU5q9dvvV2Z5/+DnP/ANtESeJTet+69wUQiT5Dwf8s1OldvEuVHyeVDdXBclWBYQvsINwL97PO8YQX2gLtYdIkgub9W92J6YwGfhyCraWVV9UUG4WvZuhgZoGAxaSSaGaXTp3TUm9XRHFzs86gqmKdEr4p4mdfaDe7ZCwcfMk66qopV9tGu6Jsvsfz1EnygrL/l31n9Am4ogMII1BVVrvGbwbetmjn12unc02JSxlV9KAstoqr80JGcDib3gl5UYnTyDwgBbp/O9ki+d4FMdYJHlD5WJ9piNcVClfF51E72EeF/9wjr/E2VHfaade56csT5zAX1Vj/zgOj/4Oc1KFurZ7KDV5oexx2bx66HdIDuZ6sW4ZkaZaWKMtUtzu1n5XvZySRm3IQ39sCYxskvvyQoTlFRqAn6fGJdkQXhZP8TS7urlcc3oTqDGPf0hyw+bgymwWZCdPCQnFxL2v4+h6LW8Os9ArBrwHIe2BmzjBVGTYgNBSIYIH1sv8TxGSEC6lMYa3rGiqS0h6UejRS4tQJwC6hHOxwi9g80C5QXRmWszPWPGlMn6fjJcR6f76Cg0MGjZkReMzBXBR/ste/YHz/X+4j/OWNUzZmOd/rRqw8VAVVkOsM+USexj2pKRePIyq/8Kge8Vgkrq2gecWT8Ga3MpSoONUVE3ZcXwlGuW8h95R/QPO9Z32S68FoqEQG8PCBHg8dRAIn88OsgsMCK+6h8S6UCUlZoNBQn50FQc9y5Fckmlj54El+OCogVRbDjaXk0px/X4KNcsLQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f87a278-e873-4a3d-1f65-08dc3a005cbf X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2024 15:00:41.1444 (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: efR6wb9e+CfJeqjUhv00qlGED/UrbY1RRUbvaM3warxlV6ZK6PsxGdoxQgftsNxrTu/pWKNHQ5bBb7aWJK35W/+XRbdZACUVkTwAwm1ORXs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9837 --- src/shared/bap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index a44b5534805e..638c6f8a4947 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -3306,6 +3306,13 @@ static void bap_add_broadcast_source(struct bt_bap_pac *pac) static void bap_add_broadcast_sink(struct bt_bap_pac *pac) { queue_push_tail(pac->bdb->broadcast_sinks, pac); + + /* Update local PACS for broadcast sink also, when registering an + * endpoint + */ + pacs_add_sink_location(pac->bdb->pacs, pac->qos.location); + pacs_add_sink_supported_context(pac->bdb->pacs, + pac->qos.supported_context); } static void notify_pac_added(void *data, void *user_data) From patchwork Fri Mar 1 15:00:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 777176 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2062.outbound.protection.outlook.com [40.107.6.62]) (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 51FD63A1DD for ; Fri, 1 Mar 2024 15:00:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305249; cv=fail; b=sf6gb6rA3kvmzj2kUfc1H69xEr3AGolsJyBjaoU2zRNI2Im6n6n065BrUMLg170ZqPRdn2w/YTbhfwn1P3pIiobuSDTMDwtJoulmaRxBjCABKRxCLdL7FUoIoUPomsB/SfRk62AyWgxzNq6tncVIDFpt8yikwdYES45+MqjhzPk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305249; c=relaxed/simple; bh=RDkTpM2gwI9Fbz1IDzazKlMdyV/wLgsDSEciXbi3czI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=p+9+872ZnPEOd4LJjTuAT/ZFaYxyFz7KRTQYbBAPUrzZezZKXXvQd/gidk8hYoeZ3FmVjMkflgImdIBJQQAOJOIarJ+mu7R1z+enGR6jN3KQrtuk00MfQK2aoxz9MfCkwyWyLmU0ey/1ygBFkuLZjZN8a5yU/hlZFXPIz4WhuSk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=mh+h7lmR; arc=fail smtp.client-ip=40.107.6.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="mh+h7lmR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lqnLpCZAPZ7QAOM4SVagbg/m3qFB4F/9Sg5q9xYeUU6unZzekzzFQlgyNUl63sImT2MqzWQzrOjvW6u57xT6NZjcOZ1V6r/Q1xKXEhjqSlstCqrGc00zZIJ0TkLZus6/GyFiOIre6+swhHx8TlquErvRSMgMHJ69C00LxdR8Q1h4DOKkQ+eCI7Jhf0Ft9i2ngZ7B6tsSlaepLGzcYsdhuZj2GqSDv0ICYWt7KtIrnuZOEZUlP3fBJVEJqkmkZUFe2jlS3nWfP5a8RRFCFILgq6uLNc0mxlpxhLyp+iLZpb+YG6muknIAn8WRYm3Zdi3O1Z2v4L4+szAWjpaMeRd1jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xA/z1w52hREgpfJFCJJhX3SJcqWvgdEuALg1eX1zhuo=; b=JXPvrXxxZvySj/4PLi0A/kfwbYap1FVxnafd48CizXQlpFqXh++Wl8aeh6JkcoRJy2lyenccIRdtTT8wnXQj0t79BxHGwIniVHVop0AzhoDBmlQXEuDaV04EKUYxD28xW73ZUy4aHG1yuM9jCGhoy+NRxoAsQUiuZ4Cj6P0buoFZMAELmhgyVk8u+He3IwfhsPX1GVxY2YDj7O34dQOe3mU0x1txax/vKlRzNaVsAP+mfr4SlK03NPixxxMntZHLB+kTLqiZKA0Ys75xJbIZokZz4z31axjJNblKrPGKu62j/GMlnpiwIQz7r6U8Z8F+SQ4Jh+fRrGGxgVgfail6DA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xA/z1w52hREgpfJFCJJhX3SJcqWvgdEuALg1eX1zhuo=; b=mh+h7lmRZipr9U1j30WTQ2paFYjpmmMyywc4OEY3iv6ErFl+hhFb5fF1Ok7FJR82XS2csrdJ9G/LAxbJ5ergEhYlE+NdV6h9YSa4X1Nr1qDWBeB553emBUxs7W4wYCCHQUjcJi/V0XZPXxTXKIkRXZpuBfmYZ5zBnfFiIAKGldw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by PAWPR04MB9837.eurprd04.prod.outlook.com (2603:10a6:102:385::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Fri, 1 Mar 2024 15:00:43 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f%6]) with mapi id 15.20.7316.039; Fri, 1 Mar 2024 15:00:43 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ v5 4/6] shared/bap: Do stream configuration in bap_bcast_config Date: Fri, 1 Mar 2024 17:00:27 +0200 Message-Id: <20240301150029.14386-5-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240301150029.14386-1-andrei.istodorescu@nxp.com> References: <20240301150029.14386-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AS4P251CA0017.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d3::6) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|PAWPR04MB9837:EE_ X-MS-Office365-Filtering-Correlation-Id: 8113ee48-1e30-42fd-7d7a-08dc3a005e0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DX3uQHsEwAUmc18rQoo1w//KIC60eWg+K1CewHsCVwbU9kZYlFnqI38wVrECoTkEWGo1w7JagDXXMAlABSAVLY5dQE+MQhOXAIadAhAaHVkno8cdlyOCLWnRlcWbCap4+f4NVlrwRSMKSr6n4Q3KT67yHDG2NJSQiDe4CjSMNTpFRvM3/WviF1HjxbybIv0v2P34YQ+ED5GFdlydjNfytbYpitpKquy67wsBnQTCp6oD+97FszDGIKndsGD1jM/dsHg+UviXuYi9t1T+omH4aFOqe/4g2nyk9X71TmcR56BfqD0rgUd8MxhIsjVZHgG63tLMxZz6Jm+STC0I/1WjWLoRgZHnL/w4+BBda5XQoKPITppgrti5JpAkSHVd3hCWAnF+3sm0BPX8v68i+s8MnOrr77ban7N0f39Pj7hul4q3FO0q0GyI/ZX6Al/ymSj/ZIeU9A8LJRxMg+cWTUvoCOuqp2oNZvM3Ob6Vhg8nhRFkV7Ea9nvJw0cQVbXNTtnYyxS2AsC1cG9CJ6r7ti45eJNTUswWrhkd1PLWANfFpTqTyLg8LMmFO3Gdhd0uR0BirIRUVwOf+5nzoc8JYrnZOi5VQtEIQ0m4s0M825ulKZrJCWgCqoxVV31z+8Mdb5zlv5qYjFfsl9Y0+8TkSblAiQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8938.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SX+1iuyVNbc2WOWqpmemvSVUEhSeOx2fN2iRuoak3aKtdLnyTaXCppDl2RX/QnmTbKhweh342KM7xumlACA6wCr94SdhTcxn7etT53t/TFlcqNQUZl9kK55wqJpLaxXoRs5r+WqZ/VvGqi5FidGtr3xWwqABn61SQjDhFv1o2e6WmDFDRz7Ax2qJpXvrlAlbyOmT48z4mJix5mdoEuIJkAazA/VGHfrtH3mqseenWWiqgBCn2LEGxYCXB4muyisA1GJtzCoB0v1RmU3jp+g5qA/FR+7Xe/Znp+MEIV0gY+OJQ6SSDtZxlWKqYep1ACqWTtu88yB27pjSbqmuuOp5X+jj8Xpxao/JvP/6wqs7Z3f8NwSSwkKnm5EFEZcibELPZRAehFbpReVDlnEKiYbWm/bJDAp4H5SrRLLa9frJMKD2wvwHxRXMy73mFnffNl84KH84y2nX8zFgCpEI0MRUJrg6M592i8FpMGrV2doUONkqK5XPeXyRWcm5cKbMji9GFUv7T+J5ePx4SKIipQHdTmD7UHKTYi74ySPl8oz0mVw+bME0kpSXtQoNUxm8hSwU9ymH0HPDsmmnixKnhMcTyqAEKgh0M/waWiOXxOkw+Hyha2M2hjv6hsq8KqXItDuH7N9HeP9OhOMEjmGzkZ2NUhR422HrXDn1oHZfLKhBEa/cC3ZOTibyKM6gC5p82NUn4JWiJp+MhuX4rOCS+yDiFj1ApydFeiLCxktsog/kisLo7mTJONOc/+x6bbhyOYslpSzWb+FVnZMoFygm1Y4hvf/FUnLUYnjQHl6jTTbDDiTS2QABeVDfNEaEXqG/rb6sqguZloXfIM7ChmqiAPD+vCr0RFgSAGEK3wRwKKnbq1W8dbXEyABgvAoo8R2FfNJMSoCk2aXhuJV/TVvnGkODWeIDcP9cegBFSAjtLNSJ+TO3puNInbgy4mn3MXQjj1P/+Y0SgXxDD+KvSTul3gmx5rwtmLeenl27diFW9W9yvW1YZASVOaWxle6v5LH7bUOOKygAI3WHHzJoF5mglVtuqbExL3G6+nA9oKzYDQdqVZbmE6nUuB3hdnSuZaMjssZYFRyjkIW5cjNkDZ5CiV9XWgZryPn/REnLVbgHehcnOhm6+LP0b2LD6hJcbK3j34qFbeD+WjJQC8p1XUEhQRHbjmZ99sb+L8Qm63DozagpXUVewICIcYJk39qqMx3s48LacTb+fbWuOPJNngG9sKhL7ZiPYBoOMnTPRocsO9Z25YckKnO7/lUG100WhDUdrsUhUeK1lzHnrAN2jOgfHIK3P6oOcsJpPUWDu6ycDj+HSQhIXKW30glBuPUP0AMCuT37eXkHzqxNHF0dUbswBHFOcCC31sKVY8GBruaqPSOciFQAx71kIA6hDQKoEOBsbDfgYOFpQTyfBuAM11Vh0bQhZbo74aKHFQVBfpeUny2W8srZPwWJSgCyvpOvB70O6dozi5dxVs6WVEvfmnTOq93Pwvdra8CPV86DESAF9DIMKu5+0An7NfGioBSiKlqV4x6KRwbeyMVm4sh3mfgU4WtXViUMels1aDme9g/7tXTIvL9T2IIANvU7oQbZq/Qpicw8cMBsFYQnNeiCUWf9JKjPWA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8113ee48-1e30-42fd-7d7a-08dc3a005e0a X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2024 15:00:43.3011 (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: YXITEvptE7TIbEawdCJK1DYCkY7FbO++alw0ro3Uhik35WeAdzkL93Vlmk8brzCfmEjbrTNtey7HD1KCf20Np4XCoOhlh//jpVKXPGfZUW8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9837 Stream configuration for BAP broadcast streams should be done inside bap_bcast_config and not when setting the user data. --- src/shared/bap.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 638c6f8a4947..50d03456e6cd 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -1693,11 +1693,8 @@ static unsigned int bap_bcast_config(struct bt_bap_stream *stream, bt_bap_stream_func_t func, void *user_data) { stream->qos = *qos; - if (stream->lpac->type == BT_BAP_BCAST_SINK) { - if (data) - stream_config(stream, data, NULL); - stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG); - } + stream->lpac->ops->config(stream, stream->cc, &stream->qos, + ep_config_cb, stream->lpac->user_data); return 1; } @@ -5369,10 +5366,6 @@ bool bt_bap_stream_set_user_data(struct bt_bap_stream *stream, void *user_data) stream->user_data = user_data; - if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) - stream->lpac->ops->config(stream, stream->cc, &stream->qos, - ep_config_cb, stream->lpac->user_data); - return true; } From patchwork Fri Mar 1 15:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 777558 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2075.outbound.protection.outlook.com [40.107.6.75]) (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 02A5A3AC01 for ; Fri, 1 Mar 2024 15:00:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305253; cv=fail; b=fWX3xzkUKERut2v+DzR5ojV/NF0Lzy+FhOCFw0IyJs7YkNj26t5dVuYPDepAfNp5Jw63Ccm8cFbaLzKPWGKIOuL132jADXIXaNCKuhk/+U37zH3Eton7S+Te+KlTePzX8wM18wsxmH4Kwf1Z3zRTgMu/xt4lUARk8Amp0iWWI8s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305253; c=relaxed/simple; bh=vIJr5CKY13VoHZl/OpCexULoDfA2jYB2X4mAsGWKzpg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=aIJQodS/dHxn2+CQlYI2S/p2t/bi5HMnFGw512CflaLNl6avVa9dXLrl/q2TRc8iFZcI7tA9fe4YHQ5upkHb9FwWfLH7Pw6xnw0BlKGEP/Jmvq48IaIrY4AHN9jHsdZODjIzC7XyiPBUdfgn/rx+ez/LgKD93NB0pNbxm2ySXwI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=OnaVlArC; arc=fail smtp.client-ip=40.107.6.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="OnaVlArC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L+smavjGocfgvn1KVQqKFrXp206kRFcmXH24GJ1qTJ3qW13EsIdxGpZT+ChOhOPb35fu1In9uhiJGppK7SisvWFBAJ+w9UP70Ql8upAdc2BBsMOuz9ZAvzDmR0DKNiln7EST/+xeFjjSyONo+avklLzEuWglIh4kYoC371MgMAfrhnl8MIJ1A2lxeWWjwLz3D1Mfp/pSZ6g5fIN5tprd6vMYXX8AMX5QQbbQVPPL2F35qZey/aVZ0P/b/2IButXLjeLO0L+2XisvSPsne3nibQdOkSYHTs1oVAQhICPBugCwsAiE7LOMjv2wC2cG+tlW8cCtLqK8N1SCB0PgeRSM+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=d+QpdgqtOfBafrKzBGYOFi15cM1PwupcACoQ6fGvIX8=; b=edDMaczOdiZ/wAs8drcznFaLkMO5aEdoQk18CLZa+D2PH46xhMuZEXOmoI2nkgAmHTUIlGyIg1yZ2kIhXQ0ElZUntXviCFO930MdjS0jbaoatx/PyYxCExQsz29m/Mq2sjIDqLtu0DHsVpZ4ENyLYb2y0APMlXdUGqc2OGsF0bEeMT/PI4Gw1D37qTXolLPspafdu7BEl0kvT8fbne/4A0AsxJ5mRICJsW7/zPinujM1890OGnRVIxqGvaTg+Yx1koxlou4V1x8A45SgTAuT1bN+pSAmbdygk90s0T3NpjXvvalkj75AhSI/7s3x6EseJ8IZzIqgh/7woWNrpE1UMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d+QpdgqtOfBafrKzBGYOFi15cM1PwupcACoQ6fGvIX8=; b=OnaVlArC+u41Yowt1TyizNw9BmPAwF+xLEKlzEFB09qhpMeBLX7b6KcdBRPqlCLZBuMiFQ421hzFJ6GdBuTed1/EF25OgD0EE+wW8JgVuu3iwHE6E2cBx1MCjVjoBJ4ZDMU1wb4p5+9sfnybUoXrnWEQAXcfnKlxLEmobFltODg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by PAWPR04MB9837.eurprd04.prod.outlook.com (2603:10a6:102:385::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Fri, 1 Mar 2024 15:00:45 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f%6]) with mapi id 15.20.7316.039; Fri, 1 Mar 2024 15:00:45 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ v5 5/6] shared/bap: Add API to add an observed BIS Date: Fri, 1 Mar 2024 17:00:28 +0200 Message-Id: <20240301150029.14386-6-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240301150029.14386-1-andrei.istodorescu@nxp.com> References: <20240301150029.14386-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AM0PR02CA0155.eurprd02.prod.outlook.com (2603:10a6:20b:28d::22) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|PAWPR04MB9837:EE_ X-MS-Office365-Filtering-Correlation-Id: cdbcf355-a3a9-4b97-69f4-08dc3a005f34 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +jOq25CnrMG6E2c2RIuEVnHsbFas9kQnO9wPbukKRYwzOdzZXXnTNLSXG4qz1bvNyEOkOj7Sy3eb1hMHI1Qyarp6nOc13ZZknEyeRtD/hANJMQa6DKYq22VbIn7C+U5wKHhffCMCSCaulSkuqXTnd6YvYyrCKqVrRd9qPPVvy0b+8gmzmJifm0QyrAWDx7BcX38eyc5QjSuASe3mq8G2stZOo76cVHENNRtf9T2RstPBxGRoLrUlkdbB7RJ5KO5LNQZo31urxKzvJMpl4MwdYt7uhETY7j8ZkbO1At6X0ebDvu0CjsjID0ItNQ91FaxUb6LO1FJkpbu5IIXeiK9aadVXOFpo3pMBfrIuGkN2TF4H2BAfK8AYwSIKqazxv/A7A/QYQBFAov0u9ZlLODMBr/MIYnK4aP0DaCNUw+0ruNQp+Eh+hOH0lLFcX9g3Q5Jx8ebGPK+h4JmnP59yYlF/pOSYj3+nDadF0ywDwxmbTg1YQeoAReFfWZd5sGU8kHzcYgufpzth6cJ7Rp6p/+rJgF1ardkpKRGuPhRAaesHrq5+FAC2hKCjCISSqLwo3anN3GRKOWQ1TUMjfEiVKChNxkaCOrKg90f/RWmgKcgOpCDKmKStagZpCD+dYFISiwZe X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8938.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 86f8JAv+sdC7DchgtK7PdcqVa8HDgtjhQ9h9cGslyeyQ8Z5WiqV9Kgwv9Pr1emAIzN3pupjsW7GJeLtiZPjBfYWosUMOqFX91b8Q2ToHlvsarOKzwbxzMXqaE9wNlOx8y8XJxGRrzomBnIM9Msmd4Vb27K0Tav2E+W67YEh2ciCQBAkoqFJ5DbeJwnTz2I+F0x9tPzp/myhVzkhS+KzeSGI97sFYK/h46CtXq0YyL34QqzUCMOSHrsz1Xk02Mfnk+C0TvQ1hPCwSjJlSP2Ys6DgrDXupf+fQFVubAEuTVD3nx5+bRAkmaCXU0j+YwsJlVxKM/v3jJ4AicSgvy8R6r5L2I8eILm+cY0nx8IOKw/96rBoMozAlzKqkYT1fEbhc+iFOzJrZ3p1nUEluzcTu4w8ANsdfL7W/mkSf/Zc1nCPVmFzlM0K1BDOPUh08wkFftaGu7pHlZhhtyzBUVD4rMuL/JCVr4TBdS7BrkFDeUxZ4fxod81OFjmkuJ5igYaI0aD5iBUIj/gG1czi82aDV4JA37XZDQIO2n519Yu0JCfu+DCLs/uKAMgaAWFo5z+2qO53u05uGZO2tImNAczaeg6xei/z87b/7T7fbMW+M5kIrQgTDhhg06f+w+UzbQZghmsZvT79d2r2kO+8KqvjtgsEGgdYHn4wrBh2YNG86Afq/mIR1YLI9unJogeCOizYL8getvx1ceX4amU0CJ2BjyeYqR7moY5+NhAUsHp+UPPTabnrkEVEFRDlg2fJzFgD2XkyI2k1qRw0FD1TwWXfIUbA2fi2SMnXDWnrqA44YAdb1YFuHeVDq7SXu07LZRM/GlGdDvIvz/sNAGX9hlw1SWnHsB1+PEyuyWZtfa5yZmNjmJrtZ/P3UMzx9YAYhqIHhanf7QbGIeEDZOjXEWkWOXgz9fhrfEWQ+I5cLb9KY8CMvl2sTfIjwUJ/HiaABVXmEXnH3SyjaCgV4EDLkeU91YYIcDR+48IFEmCgZ0F4v2G4dYGIyDJiy9YGoZQQiVa4+PA2mLb9QhReTDuI26D5TwCiVLCkAmXR9MPc8ToNkqohk2KDXQt7nU6upZJH9gldE7clFhQgAaVL/oT+c5nJCZAahbah8miR4RipRL547xD8Anb6RGIUsqRTGbRVWWgUmL7vjTKOmrRHHtq8KHdVR5G7h04PP3SvqBh4aJwPT2uiCvvsj+9nKVVdVpcZLHTYsXmDaWManN7WDIxgiDt+kh49bcxo5+zfW/EyoD3P3oKywfxhrHPDUbV3zgXent/VnXGpuNrT//P7fXAjt4AoTFzKS4FQq4pEY/aOq5RHM3P02Kiu6nByK2bKysJ6t34kKW/bag4CYVOrtuxEr1Hb/Hm/iGUPzN/AB6BvcpE16DoH5qEPQBQshgQZhgjtIAzgGtiv2VFGhXbMVQZcXk/RXytkDwty8bmRCuMeTlF8CGSqu9OhRA+irpOsuUF1MEYMqYXsH1bikyjaM1dA46m4va118zwg7eUj5P46ZzQUd+kVUFWBSTk2xCX0sxSVwB1addtWxtakZcoQZoqRioMGcmLnkWlDFK46uVFTb94FK2AOnm+VgPxEI5t8KZ3lTT2wbNUTzo14OX7Gc+oi+PLUfbQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cdbcf355-a3a9-4b97-69f4-08dc3a005f34 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2024 15:00:45.3223 (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: SdmC/w1qAsF3LRWFnVY7dUpIdHkb00+ONg5KrbRJuvVcHjd7Qw329qNkxsChSa3oDSBM1WSk6IGCZQx2/Wbd8e5FNYpuJnUWQqufzL84sHQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9837 Add API to add a PAC for each observed BIS that is supported by the local PACS data. Each BIS observed capabilities LTV is compared to the local capabilities and when we have a full LTVs match a PAC record is created for that BIS. Also a MediaEndpoint is registered over DBUS and the stream can be enabled using the SetConfiguration DBUS call. --- src/shared/bap.c | 266 ++++++++++++++++++++++++++++++++++++++++++++++- src/shared/bap.h | 7 ++ 2 files changed, 268 insertions(+), 5 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 50d03456e6cd..b84760da4510 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -48,6 +48,15 @@ #define BAP_PROCESS_TIMEOUT 10 +#define BAP_FREQ_LTV_TYPE 1 +#define BAP_DURATION_LTV_TYPE 2 +#define BAP_CHANNEL_ALLOCATION_LTV_TYPE 3 +#define BAP_FRAME_LEN_LTV_TYPE 4 +#define CODEC_SPECIFIC_CONFIGURATION_MASK (\ + (1<l != l) return; - if (!memcmp(v, ltv_match->v, l)) + if (!memcmp(v, ltv_match->data, l)) ltv_match->found = true; } @@ -6034,7 +6044,7 @@ static void search_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, ltv_match.found = false; ltv_match.l = l; - ltv_match.v = v; + ltv_match.data = v; util_ltv_foreach(ltv_search->iov->iov_base, ltv_search->iov->iov_len, &t, @@ -6075,8 +6085,10 @@ static bool compare_ltv(struct iovec *iov1, } struct bt_ltv_extract { - struct iovec *result; struct iovec *src; + void *value; + uint8_t len; + struct iovec *result; }; static void extract_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, @@ -6088,7 +6100,7 @@ static void extract_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, ltv_match.found = false; ltv_match.l = l; - ltv_match.v = v; + ltv_match.data = v; /* Search each BIS caps ltv in subgroup caps * to extract the one that are BIS specific @@ -6221,3 +6233,247 @@ struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream) return base_iov; } + +static void bap_sink_get_allocation(size_t i, uint8_t l, uint8_t t, + uint8_t *v, void *user_data) +{ + uint32_t location32; + + if (!v) + return; + + memcpy(&location32, v, l); + *((uint32_t *)user_data) = le32_to_cpu(location32); +} + +/* + * This function compares PAC Codec Specific Capabilities, with the Codec + * Specific Configuration LTVs received in the BASE of the BAP Source. The + * result is accumulated in data32 which is a bitmask of types. + */ +static void check_pac_caps_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, + void *user_data) +{ + struct bt_ltv_match *compare_data = user_data; + uint8_t *bis_v = compare_data->data; + uint16_t mask; + uint16_t min; + uint16_t max; + uint16_t frame_len; + + switch (t) { + case BAP_FREQ_LTV_TYPE: + mask = *((uint16_t *)v); + mask = le16_to_cpu(mask); + if (mask & (1 << (bis_v[0] - 1))) + compare_data->data32 |= 1<data32 |= 1<= min) && + (frame_len <= max)) + compare_data->data32 |= 1<data; + struct bt_ltv_match compare_data; + + compare_data.data = v; + + /* Search inside local PAC's caps for LTV of type t */ + util_ltv_foreach(pac_caps->iov_base, pac_caps->iov_len, &t, + check_pac_caps_ltv, &compare_data); + + local_data->data32 |= compare_data.data32; +} + +static void bap_sink_check_level3_ltv(size_t i, uint8_t l, uint8_t t, + uint8_t *v, void *user_data) +{ + struct bt_ltv_extract *merge_data = user_data; + + merge_data->value = v; + merge_data->len = l; +} + +static void bap_sink_check_level2_ltv(size_t i, uint8_t l, uint8_t t, + uint8_t *v, void *user_data) +{ + struct bt_ltv_extract *merge_data = user_data; + + merge_data->value = NULL; + util_ltv_foreach(merge_data->src->iov_base, + merge_data->src->iov_len, + &t, + bap_sink_check_level3_ltv, merge_data); + + /* If the LTV at level 2 was found at level 3 add the one from level 3, + * otherwise add the one at level 2 + */ + if (merge_data->value) + util_ltv_push(merge_data->result, merge_data->len, + t, merge_data->value); + else + util_ltv_push(merge_data->result, l, t, v); +} + +static void check_local_pac(void *data, void *user_data) +{ + struct bt_ltv_match *compare_data = user_data; + struct iovec *bis_data = (struct iovec *)compare_data->data; + const struct bt_bap_pac *pac = data; + + /* Keep searching for a matching PAC if one wasn't found + * in previous PAC element + */ + if (compare_data->found == false) { + struct bt_ltv_match bis_compare_data = { + .data = pac->data, + .data32 = 0, /* LTVs bitmask result */ + .found = false + }; + + /* loop each BIS LTV */ + util_ltv_foreach(bis_data->iov_base, bis_data->iov_len, NULL, + check_source_ltv, &bis_compare_data); + + /* We have a match if all selected LTVs have a match */ + if ((bis_compare_data.data32 & + CODEC_SPECIFIC_CONFIGURATION_MASK) == + CODEC_SPECIFIC_CONFIGURATION_MASK) + compare_data->found = true; + } +} + +static void bap_sink_match_allocation(size_t i, uint8_t l, uint8_t t, + uint8_t *v, void *user_data) +{ + struct bt_ltv_match *data = user_data; + uint32_t location32; + + if (!v) + return; + + memcpy(&location32, v, l); + location32 = le32_to_cpu(location32); + + /* If all the bits in the received bitmask are found in + * the local bitmask then we have a match + */ + if ((location32 & data->data32) == location32) + data->found = true; + else + data->found = false; +} + +static bool bap_check_bis(struct bt_bap_db *ldb, struct iovec *bis_data) +{ + struct bt_ltv_match compare_data = {}; + + /* Check channel allocation against the PACS location. + * If we don't have a location set we can accept any BIS location. + * If the BIS doesn't have a location set we also accept it + */ + compare_data.found = true; + + if (ldb->pacs->sink_loc_value) { + uint8_t type = BAP_CHANNEL_ALLOCATION_LTV_TYPE; + + compare_data.data32 = ldb->pacs->sink_loc_value; + util_ltv_foreach(bis_data->iov_base, bis_data->iov_len, &type, + bap_sink_match_allocation, &compare_data); + } + + /* Check remaining LTVs against the PACs list */ + if (compare_data.found) { + compare_data.data = bis_data; + compare_data.found = false; + queue_foreach(ldb->broadcast_sinks, check_local_pac, + &compare_data); + } + + return compare_data.found; +} + +void bt_bap_add_bis(struct bt_bap *bap, uint8_t bis_index, + struct bt_bap_codec *codec, + struct iovec *l2_caps, + struct iovec *l3_caps, + struct iovec *meta) +{ + struct bt_bap_pac *pac_source_bis; + struct bt_bap_endpoint *ep; + int err = 0; + struct bt_bap_pac_qos bis_qos = {0}; + uint8_t type = 0; + struct bt_ltv_extract merge_data = {0}; + + merge_data.src = l3_caps; + merge_data.result = new0(struct iovec, 1); + + /* Create a Codec Specific Configuration with LTVs at level 2 (subgroup) + * overwritten by LTVs at level 3 (BIS) + */ + util_ltv_foreach(l2_caps->iov_base, + l2_caps->iov_len, + NULL, + bap_sink_check_level2_ltv, &merge_data); + + /* Check each BIS Codec Specific Configuration LTVs against our Codec + * Specific Capabilities and if the BIS matches create a PAC with it + */ + if (bap_check_bis(bap->ldb, merge_data.result) == false) + goto cleanup; + + DBG(bap, "Matching BIS %i", bis_index); + + /* Create a QoS structure based on the received BIS information to + * specify the desired channel for this BIS/PAC + */ + type = BAP_CHANNEL_ALLOCATION_LTV_TYPE; + util_ltv_foreach(merge_data.result->iov_base, + merge_data.result->iov_len, &type, + bap_sink_get_allocation, &bis_qos.location); + + /* Create a remote PAC */ + pac_source_bis = bap_pac_new(bap->rdb, NULL, + BT_BAP_BCAST_SOURCE, codec, &bis_qos, + merge_data.result, meta); + + err = asprintf(&pac_source_bis->name, "%d", bis_index); + + if (err < 0) { + DBG(bap, "error in asprintf"); + goto cleanup; + } + + /* Add remote source endpoint */ + if (!bap->rdb->broadcast_sources) + bap->rdb->broadcast_sources = queue_new(); + queue_push_tail(bap->rdb->broadcast_sources, pac_source_bis); + + queue_foreach(bap->pac_cbs, notify_pac_added, pac_source_bis); + /* Push remote endpoint with direction sink */ + ep = bap_endpoint_new_broadcast(bap->rdb, BT_BAP_BCAST_SINK); + + if (ep) + queue_push_tail(bap->remote_eps, ep); + +cleanup: + util_iov_free(merge_data.result, 1); +} diff --git a/src/shared/bap.h b/src/shared/bap.h index e4785b587e3a..76f3fb0adab6 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -333,3 +333,10 @@ void bt_bap_update_bcast_source(struct bt_bap_pac *pac, bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac); struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream); + +void bt_bap_add_bis(struct bt_bap *bap, uint8_t bis_index, + struct bt_bap_codec *codec, + struct iovec *l2_caps, + struct iovec *l3_caps, + struct iovec *meta); + From patchwork Fri Mar 1 15:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 777175 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2082.outbound.protection.outlook.com [40.107.8.82]) (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 D396F3A1DD for ; Fri, 1 Mar 2024 15:00:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305253; cv=fail; b=usYirnpowYmcUhxEVZimAU0Y8TL98oxf/IOttjfMK5NzkybhT3Pz9JErdxutmdv1Vwffdnp42LsKZkch7D6JCSDHvkkamWo9WCkLPeKDMU6RnKHwnKoxCmtA0HF0ovzUZUzuhmFt62ClG5ekeVYhm3hT7IwuW835aeLIM9BaNkY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305253; c=relaxed/simple; bh=tTwd59IH/QgRE3fJLbOWtwufOhUT1g37ifKdW1V9cWg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=GbZV2S8wqyhlkcJ+6O/0IzuL3zS5Y0j3C8KvHar1pQnqtsrtuRxgLaa3Gbb8jMbXdQoTSoGDJDxH/KQeAlm5xoDi5wqZE6iyDODHMySbWS8LUDiuU7xuSYTn5EMAkA4fCkG1ThMl54VjZruSXnNJ5su6AjOgn6XnUGUvmrEBD0U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=apmrSw4Z; arc=fail smtp.client-ip=40.107.8.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="apmrSw4Z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JxFU41embDzMRgEf2sWvOIE829uLcgFExGGQPsJUmdCkAcmcU6Q1y+7Dw97Fb6gF14Tws+TxEZa79DizwP018af9ix8j678yv1YwEgaqBKkvV/VdTkE8yIhxdFn4A3TctVbY6uoBT2MbOu8fZZ0V+DrBVHcRvEyAAjuPzKvi+Zj33Hv3MLx+dGD1hjg4DzD7DLGUNPdywRnzO8v71kzmmAbxcbbcXjRZkjNVRcBFfrks3ARXu9qFY2sPMcwNpA4MHb+zLyqEF3za03Bp3u9bJ8rugKzPtE0y4cmPZaUN/Sbx9TjoCnQrL4WpjFQQtZTyzbrFrkr6GonxOd/mhLP12Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vDchfjS9y/2mGc9Oila/I2o06J2MooOfFg2deK5jViI=; b=Xm54K5fJQAOd51+SJXuMF7R2nyG70rRqTlYniW2FYHYVjXxhJ2AZYFXr+snMscyzyGWOGj58RjsBXLw9yW0HTjG2wYTc3yLdTfZ7HxzPxifc4YGdJH741S3JW0OwuXO1Ul+X4f65ZIQwIOoHCqKNvIlUTYgLaW0Mk5wZB0UUh4Dw4UFfjRyZy5S+hajRB7z5F5wbW4468aJFmSnCSpYjyufyJa/EKPqVNC8IWYZGfU9Cm1GPns1cNZFVNmtO+xYRK2JB5NkRiLUnRItgGt9gnPZtxJRest2eQU8tHByYUJjUuEw+sfzbYY9oeoPhiJ2hzIB8MVFTbQ+C6wJvGw3cKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vDchfjS9y/2mGc9Oila/I2o06J2MooOfFg2deK5jViI=; b=apmrSw4Z7XbcQRu56nZRBZQu1r5j5vRvON6ZD/hNjloTGfZ54W8RmRYEY4KkjJ55dHWslF2yDra78hVvwvOK2chWlDKyz3il99gTPRn3s2pXazXSqnb0HU++vgdg1neO1qbTX5SemdhTtwEnBjZD4whXgSwCD7LHTJCcGbffUdA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by DBAPR04MB7480.eurprd04.prod.outlook.com (2603:10a6:10:1a3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Fri, 1 Mar 2024 15:00:47 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::83af:c10f:9f30:43f%6]) with mapi id 15.20.7316.039; Fri, 1 Mar 2024 15:00:47 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ v5 6/6] bap: Do PA Sync for each BAP Broadcast source discovered Date: Fri, 1 Mar 2024 17:00:29 +0200 Message-Id: <20240301150029.14386-7-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240301150029.14386-1-andrei.istodorescu@nxp.com> References: <20240301150029.14386-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AM4PR05CA0012.eurprd05.prod.outlook.com (2603:10a6:205::25) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|DBAPR04MB7480:EE_ X-MS-Office365-Filtering-Correlation-Id: d3d6eece-d74b-4817-5134-08dc3a00605f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zwRMiMaEzx5HLMaVcBycoAe5nbGx5q1c/12RfAilDdri5kICziQPEmkCxy1xCH3m6N2JTc7oW2J97VrM+IbIFed7OcTivcVWPQ4AZ/VeEJQMiYerKXBSK1OxtzU0fCWX6MZX6iLpyvr9j11stv6JaczrumbWHlrqV/NqZj31HIz0a/73q/NVDPZOB67G0GA/DzbxYRhc82uGKkI5Q5M0Fh4b7Ebc6LxIaFaNUMnWbjVZDb8BWkD0MnHgUIBCig/+lIV2pNhbv6vDf/7GYrpgwExomP3ObMVIrW2mpYxKwYpvE4bgP86diMNZExa9E9liDlgbMIkrH02qoTYI+7F9wyZou89b1f2d+Jjcom7/HG9oDew3zsjJITW51FSaK7CC0GBOg60ag8HBzYu6iWp32yAPWHchgZM75IeS1BVOiWQ3U/FXOWn7E+PwKjXKi4dlYcbF4vCiZOHJ3pN4Br7EyWZACQX/d/6WRQiMPG82I4u3haFITeyEwJz6h8KFf0nNXQ9/JDCr1RbA4DoUM1upGS3n9XnWP5Vv9aAfohR3cGCxGzVMjlWkuIylngy4UQi5TfdaW6NhePrwRQZTXPHJDKClFvsfZ/wRYbuP4qGp41dqjV85pwNvsKkK8hzgObW2XS6fDvMVa3kHEYgpNE60CQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8938.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U9sm25ohRnsGDzyirkZhkfh+BnSjX55EP8kWMUQvwNhfT4qAkkvVb6c//joRYStRnfL1ZxCdYhnWwkyxt2ICq6v1A+fDptWyd1j8i7Sgt9Axirg3u/ZhT1TenQv7e6r4fE7LksMBXn1RwDP36mmVI3Wywb81C/piNQWbtsicvUCI+EXrtqjcpAO6TIchVQV/C42VAnXh231cKOPMadPxLZwbJ+cMMdRRUbbc2TIHsTCp4sgbs7X3gdXYEcJzcynp+0Hn9vV4nL6Rtywk/WJzLE1yYikvNiqVKv3fi7lrnu/ONHZtbFX30jWMkaFLdcnxpZYXXcFw5P3Pmk22sGZvjqXD3HknmqJ7Aq9NZuZufW6u7n693KwB1kf5DYnwIcmXb01P9r242fleAC/H/PVeJrBVrIWT5uOBq+PkQEuADM+AqjcwZXeOUFYPeYnMuuWDfxacYk3kayjAzwmkelBjMbwo+4zJ8NqBLMfUsBD/DKrAN9o8vbwOCTNyBu7sy8va++OGExoSyGugplxN8gZbffT/D3fOnYBKIIKHdZosoc9UB6cDCBanskjsoO1fP7M86aQtst/+5xhCoIohbgFt7q6dteoQ3Hz8tsR2Zxrr8kfvbr+fUB4wyCbwOI12BR/hot8IlEsmZpav0/UIet4N0eSOBB8PVNtbkJ82xv0V0I294nSBW2VtmWQTSSZTcGQbCc0AQfCKNyUG6vSn2ns+JQmgZoSoxD/y2Q31p8JAd1k7sEwf8h0Wa+OPwB2n0hKMF0Icyu6wYdtrcempYkAySntdc5RHNDb3ut9/6/zTezD4mrHYektfV6lc/BL3L2IGFkKHP1lEOQifmfA/ikP/XhvRoS8ay11rEHgCogPWWXHC4d9SrFfTkKnRJzmL+Ow1SpT9XBgemhIyN+dmOE4l8n4D8dSjSURzTu5ei7CcaPPuZCFdbqqfBO7Rgn5cmZ2oMJCTsmEIaqLpQip0NJhemQOBjIabUvHq41choFk5Y1otKwlpN8GQ/Ujp4JZFJxTUCqpSP2osZJQf+jUo8WEL/RunoQrI/9YIzGwTfTVhIpG15B/NnYL0PZt/K7Napxce9VOqZPBIgx6G3D9Fs/PVbYAPdlZOhtuGhqAitS3HyjsYDvBJY7j8Tso9UYr21r0lnqgjUKHKSK6XWCoazJJkZ08/8MX1qDHQ2CdsmGAUyw9//VPbXoRBqb2YUncKi33y1M7enpsxpClbocrqvTP92/15BxFeV/BBa6UG+2bNtu99H4hAhpMb3r8BXp3VK2tz/haiQi+qWo5Y/LmWEAQQXDjqCLg/TQMq3velh19mCIdsHjKcuUi+y6uwZDHzqZHeJZg0afBQ86Z459c0+HUlK8Dggqk4PeLwR/iZUeBegStmb+BSbQIvSX+EV7ddjm1gXQuCmGjIAcj/rhix4BGEVfe/bvVQLYgd9tulcgOrktWeloxNP1WEyR6uvCIUesy+F85QqLXxOE+Guotl+S2Rmuo02BBUYJ3eZcRvKA8Np9nYjFG+/w8BoQbq7kW8pKAMey1sjHWrnG6Wgh1rKcqtPmBoPrMk5URUIe+cbQMszwycAKxY4xX49Fm9qKixvyadwLVHmDfHpVjI+md2DUdMRw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3d6eece-d74b-4817-5134-08dc3a00605f X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2024 15:00:47.2979 (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: XOcAe1DuQvofqO3UhX04kmatsmJfThzG5EJY3x7o4p3MEzennJKrUm8aKY+ljjXPpfM96+C04n2AGYC5zf7ohEPh1QcA2ZKJC5EYPddfveo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7480 After discovering a BAP Broadcast Source do a short PA sync first to learn the BASE. After discovering the BASE check how many BISes are matching the sink capabilities and create endpoints for them. Allow user to configure one endpoint using "SetConfiguration" causing BIG synchronization to the corresponding BIS; also this results in creating a stream and the corresponding transport. --- profiles/audio/bap.c | 656 +++++++++++++++++++++++++++---------------- 1 file changed, 410 insertions(+), 246 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 38577bcf376e..b7e1837801dc 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -62,6 +62,13 @@ #define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1" #define MEDIA_INTERFACE "org.bluez.Media1" +/* Periodic advertisments are performed by an idle timer, which, + * at every tick, checks a queue for pending PA requests. + * When there is no pending requests, an item is popped from the + * queue, marked as pending and then it gets processed. + */ +#define PA_IDLE_TIMEOUT 2 + struct bap_setup { struct bap_ep *ep; struct bt_bap_stream *stream; @@ -110,7 +117,62 @@ struct bap_data { void *user_data; }; +enum { + BAP_PA_SHORT_REQ = 0, /* Request for short PA sync */ + BAP_PA_BIG_SYNC_REQ, /* Request for PA Sync and BIG Sync */ +}; + +struct bap_bcast_pa_req { + uint8_t type; + bool in_progress; + union { + struct btd_service *service; + struct bap_setup *setup; + } data; +}; + static struct queue *sessions; +static struct queue *bcast_pa_requests; +static unsigned int pa_timer_id; + +/* Structure holding the parameters for Periodic Advertisement create sync. + * The full QOS is populated at the time the user selects and endpoint and + * configures it using SetConfiguration. + */ +static struct bt_iso_qos bap_sink_pa_qos = { + .bcast = { + .options = 0x00, + .skip = 0x0000, + .sync_timeout = 0x4000, + .sync_cte_type = 0x00, + /* TODO: The following parameters are not needed for PA Sync. + * They will be removed when the kernel checks will be removed. + */ + .big = BT_ISO_QOS_BIG_UNSET, + .bis = BT_ISO_QOS_BIS_UNSET, + .encryption = 0x00, + .bcode = {0x00}, + .mse = 0x00, + .timeout = 0x4000, + .sync_factor = 0x07, + .packing = 0x00, + .framing = 0x00, + .in = { + .interval = 10000, + .latency = 10, + .sdu = 40, + .phy = 0x02, + .rtn = 2, + }, + .out = { + .interval = 10000, + .latency = 10, + .sdu = 40, + .phy = 0x02, + .rtn = 2, + } + } +}; static bool bap_data_set_user_data(struct bap_data *data, void *user_data) { @@ -427,113 +489,6 @@ static int parse_array(DBusMessageIter *iter, struct iovec *iov) return 0; } -static bool parse_base(void *data, size_t len, util_debug_func_t func, - uint32_t *presDelay, uint8_t *numSubgroups, uint8_t *numBis, - struct bt_bap_codec *codec, struct iovec **caps, - struct iovec **meta) -{ - struct iovec iov = { - .iov_base = data, - .iov_len = len, - }; - - uint8_t capsLen, metaLen; - struct iovec cc; - struct iovec metadata; - - if (presDelay) { - if (!util_iov_pull_le24(&iov, presDelay)) - return false; - util_debug(func, NULL, "PresentationDelay %d", *presDelay); - } - - if (numSubgroups) { - if (!util_iov_pull_u8(&iov, numSubgroups)) - return false; - util_debug(func, NULL, "NumSubgroups %d", *numSubgroups); - } - - if (numBis) { - if (!util_iov_pull_u8(&iov, numBis)) - return false; - util_debug(func, NULL, "NumBis %d", *numBis); - } - - if (codec) { - codec = util_iov_pull_mem(&iov, sizeof(*codec)); - if (!codec) - return false; - util_debug(func, NULL, "%s: ID %d CID 0x%2.2x VID 0x%2.2x", - "Codec", codec->id, codec->cid, codec->vid); - } - - if (!util_iov_pull_u8(&iov, &capsLen)) - return false; - util_debug(func, NULL, "CC Len %d", capsLen); - - if (!capsLen) - return false; - - cc.iov_len = capsLen; - cc.iov_base = util_iov_pull_mem(&iov, capsLen); - if (!cc.iov_base) - return false; - - if (caps) { - if (*caps) - util_iov_free(*caps, 1); - - *caps = util_iov_dup(&cc, 1); - } - - for (int i = 0; capsLen > 1; i++) { - struct bt_ltv *ltv = util_iov_pull_mem(&cc, sizeof(*ltv)); - uint8_t *caps; - - if (!ltv) { - util_debug(func, NULL, "Unable to parse %s", - "Capabilities"); - return false; - } - - util_debug(func, NULL, "%s #%u: len %u type %u", - "CC", i, ltv->len, ltv->type); - - caps = util_iov_pull_mem(&cc, ltv->len - 1); - if (!caps) { - util_debug(func, NULL, "Unable to parse %s", - "CC"); - return false; - } - util_hexdump(' ', caps, ltv->len - 1, func, NULL); - - capsLen -= (ltv->len + 1); - } - - if (!util_iov_pull_u8(&iov, &metaLen)) - return false; - util_debug(func, NULL, "Metadata Len %d", metaLen); - - if (!metaLen) - return false; - - metadata.iov_len = metaLen; - metadata.iov_base = util_iov_pull_mem(&iov, metaLen); - if (!metadata.iov_base) - return false; - - if (meta) { - if (*meta) - util_iov_free(*meta, 1); - - *meta = util_iov_dup(&metadata, 1); - } - - util_hexdump(' ', metadata.iov_base, metaLen, func, NULL); - - return true; -} - static int parse_io_qos(const char *key, int var, DBusMessageIter *iter, struct bt_bap_io_qos *qos) { @@ -965,9 +920,20 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return btd_error_invalid_args(msg); } + /* For BAP Broadcast Sink, the capabilities and metadata are coming + * from the source's BIS, which are present in the remote PAC + */ + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) { + util_iov_free(setup->caps, 1); + setup->caps = util_iov_dup(bt_bap_pac_get_data(ep->rpac), 1); + util_iov_free(setup->metadata, 1); + setup->metadata = util_iov_dup( + bt_bap_pac_get_metadata(ep->rpac), 1); + } + setup->stream = setup->stream_new(ep->data->bap, ep->lpac, ep->rpac, &setup->qos, setup->caps); - + bt_bap_stream_set_user_data(setup->stream, ep->path); setup->id = bt_bap_stream_config(setup->stream, &setup->qos, setup->caps, config_cb, setup); if (!setup->id) { @@ -976,8 +942,6 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return btd_error_invalid_args(msg); } - bt_bap_stream_set_user_data(setup->stream, ep->path); - if (setup->metadata && setup->metadata->iov_len) bt_bap_stream_metadata(setup->stream, setup->metadata, NULL, NULL); @@ -988,11 +952,7 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, break; case BT_BAP_STREAM_TYPE_BCAST: /* No message sent over the air for broadcast */ - if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) - setup->msg = dbus_message_ref(msg); - else { - setup->id = 0; - } + setup->id = 0; if (ep->data->service) service_set_connecting(ep->data->service); @@ -1003,79 +963,18 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return NULL; } -static void update_bcast_qos(struct bt_iso_qos *qos, - struct bt_bap_qos *bap_qos) -{ - bap_qos->bcast.big = qos->bcast.big; - bap_qos->bcast.bis = qos->bcast.bis; - bap_qos->bcast.sync_factor = qos->bcast.sync_factor; - bap_qos->bcast.packing = qos->bcast.packing; - bap_qos->bcast.framing = qos->bcast.framing; - bap_qos->bcast.encryption = qos->bcast.encryption; - bap_qos->bcast.options = qos->bcast.options; - bap_qos->bcast.skip = qos->bcast.skip; - bap_qos->bcast.sync_timeout = qos->bcast.sync_timeout; - bap_qos->bcast.sync_cte_type = qos->bcast.sync_cte_type; - bap_qos->bcast.mse = qos->bcast.mse; - bap_qos->bcast.timeout = qos->bcast.timeout; - bap_qos->bcast.io_qos.interval = qos->bcast.in.interval; - bap_qos->bcast.io_qos.latency = qos->bcast.in.latency; - bap_qos->bcast.io_qos.phy = qos->bcast.in.phy; - bap_qos->bcast.io_qos.sdu = qos->bcast.in.sdu; - bap_qos->bcast.io_qos.rtn = qos->bcast.in.rtn; - if (!bap_qos->bcast.bcode) - bap_qos->bcast.bcode = new0(struct iovec, 1); - util_iov_memcpy(bap_qos->bcast.bcode, qos->bcast.bcode, - sizeof(qos->bcast.bcode)); -} - static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) { - struct bap_setup *setup = user_data; - struct bap_ep *ep = setup->ep; - struct bap_data *data = ep->data; - struct bt_iso_qos qos; - struct bt_iso_base base; - char address[18]; + struct bap_bcast_pa_req *req = user_data; + struct bap_setup *setup = req->data.setup; int fd; - struct iovec *base_io; - uint32_t presDelay; - uint8_t numSubgroups; - uint8_t numBis; - struct bt_bap_codec codec; - - bt_io_get(io, &err, - BT_IO_OPT_DEST, address, - BT_IO_OPT_QOS, &qos, - BT_IO_OPT_BASE, &base, - BT_IO_OPT_INVALID); - if (err) { - error("%s", err->message); - g_error_free(err); - goto drop; - } - - g_io_channel_ref(io); - btd_service_connecting_complete(data->service, 0); - DBG("BCAST ISO: sync with %s (BIG 0x%02x BIS 0x%02x)", - address, qos.bcast.big, qos.bcast.bis); - update_bcast_qos(&qos, &setup->qos); + DBG("BIG Sync completed"); - base_io = new0(struct iovec, 1); - util_iov_memcpy(base_io, base.base, base.base_len); + queue_remove(bcast_pa_requests, req); - parse_base(base_io->iov_base, base_io->iov_len, bap_debug, - &presDelay, &numSubgroups, &numBis, - &codec, &setup->caps, &setup->metadata); - - /* Update pac with BASE information */ - bt_bap_update_bcast_source(ep->rpac, &codec, setup->caps, - setup->metadata); - setup->id = bt_bap_stream_config(setup->stream, &setup->qos, - setup->caps, NULL, NULL); - - bt_bap_stream_set_user_data(setup->stream, ep->path); + /* This device is no longer needed */ + btd_service_connecting_complete(setup->ep->data->service, 0); fd = g_io_channel_unix_get_fd(io); @@ -1084,26 +983,157 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) g_io_channel_set_close_on_unref(io, FALSE); return; } +} +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); +} - return; +static bool parse_base(struct bt_bap *bap, struct bt_iso_base *base, + util_debug_func_t func) +{ + struct iovec iov = { + .iov_base = base->base, + .iov_len = base->base_len, + }; + uint32_t pres_delay; + uint8_t num_subgroups; -drop: - g_io_channel_shutdown(io, TRUE, NULL); + 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; + struct iovec *meta; + + util_debug(func, NULL, "Subgroup #%d", idx); + + if (!util_iov_pull_u8(&iov, &num_bis)) + 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)) + goto 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)) + goto 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; + + if (!util_iov_pull_u8(&iov, &bis_index)) + goto fail; + + util_debug(func, NULL, "BIS #%d", bis_index); + + /* Read Codec Specific Configuration */ + l3_caps = new0(struct iovec, 1); + if (!util_iov_pull_u8(&iov, (void *)&l3_caps->iov_len)) + goto 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); + + /* Try to create a PAC using this BIS information */ + bt_bap_add_bis(bap, bis_index, &codec, l2_caps, l3_caps, + meta); + } + + } + return true; + +fail: + util_debug(func, NULL, "Unable to parse Base"); + + return false; } static void iso_pa_sync_confirm_cb(GIOChannel *io, void *user_data) { GError *err = NULL; + struct bap_bcast_pa_req *pa_req = user_data; + struct bap_data *data = btd_service_get_user_data(pa_req->data.service); + struct bt_iso_base base; + struct bt_iso_qos qos; - if (!bt_io_bcast_accept(io, iso_bcast_confirm_cb, - user_data, NULL, &err, BT_IO_OPT_INVALID)) { - error("bt_io_bcast_accept: %s", err->message); + DBG("PA Sync done"); + + bt_io_get(io, &err, + BT_IO_OPT_BASE, &base, + BT_IO_OPT_QOS, &qos, + BT_IO_OPT_INVALID); + if (err) { + error("%s", err->message); g_error_free(err); g_io_channel_shutdown(io, TRUE, NULL); + return; } + /* Close the io and remove the queue request for another PA Sync */ + g_io_channel_shutdown(data->listen_io, TRUE, NULL); + g_io_channel_unref(data->listen_io); + g_io_channel_shutdown(io, TRUE, NULL); + data->listen_io = NULL; + queue_remove(bcast_pa_requests, pa_req); + + /* Analyze received BASE data and create remote media endpoints for each + * BIS matching our capabilities + */ + parse_base(data->bap, &base, bap_debug); } static bool match_data_bap_data(const void *data, const void *match_data) @@ -1942,47 +1972,58 @@ static void setup_listen_io(struct bap_data *data, struct bt_bap_stream *stream, data->listen_io = io; } -static void setup_listen_io_broadcast(struct bap_data *data, - struct bap_setup *setup, - struct bt_bap_stream *stream, - struct bt_iso_qos *qos) +static void check_pa_req_in_progress(void *data, void *user_data) { - GIOChannel *io; - GError *err = NULL; - struct sockaddr_iso_bc iso_bc_addr; + struct bap_bcast_pa_req *req = data; - iso_bc_addr.bc_bdaddr_type = btd_device_get_bdaddr_type(data->device); - memcpy(&iso_bc_addr.bc_bdaddr, device_get_address(data->device), - sizeof(bdaddr_t)); - iso_bc_addr.bc_bis[0] = 1; - iso_bc_addr.bc_num_bis = 1; + if (req->in_progress == TRUE) + *((bool *)user_data) = TRUE; +} - DBG("stream %p", stream); +static int short_lived_pa_sync(struct bap_bcast_pa_req *req); +static void pa_and_big_sync(struct bap_bcast_pa_req *req); - /* If IO already set skip creating it again */ - if (bt_bap_stream_get_io(stream) || data->listen_io) - return; +static gboolean pa_idle_timer(gpointer user_data) +{ + struct bap_bcast_pa_req *req = user_data; + bool in_progress = FALSE; - io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, setup, NULL, &err, - BT_IO_OPT_SOURCE_BDADDR, - btd_adapter_get_address(data->adapter), - BT_IO_OPT_DEST_BDADDR, - device_get_address(data->device), - BT_IO_OPT_DEST_TYPE, - btd_device_get_bdaddr_type(data->device), - BT_IO_OPT_MODE, BT_IO_MODE_ISO, - BT_IO_OPT_QOS, &qos->bcast, - BT_IO_OPT_ISO_BC_NUM_BIS, iso_bc_addr.bc_num_bis, - BT_IO_OPT_ISO_BC_BIS, iso_bc_addr.bc_bis, - BT_IO_OPT_INVALID); - if (!io) { - error("%s", err->message); - g_error_free(err); + /* Handle timer if no request is in progress */ + queue_foreach(bcast_pa_requests, check_pa_req_in_progress, + &in_progress); + if (in_progress == FALSE) { + req = queue_peek_head(bcast_pa_requests); + if (req != NULL) + switch (req->type) { + case BAP_PA_SHORT_REQ: + DBG("do short lived PA Sync"); + short_lived_pa_sync(req); + break; + case BAP_PA_BIG_SYNC_REQ: + DBG("do PA Sync and BIG Sync"); + pa_and_big_sync(req); + break; + } } - setup->io = io; - data->listen_io = io; + return TRUE; } + +static void setup_accept_io_broadcast(struct bap_data *data, + struct bap_setup *setup) +{ + struct bap_bcast_pa_req *pa_req = new0(struct bap_bcast_pa_req, 1); + + /* Add this request to the PA queue. + * We don't need to check the queue here and the timer, as we cannot + * have BAP_PA_BIG_SYNC_REQ before a short PA (BAP_PA_SHORT_REQ) + */ + pa_req->type = BAP_PA_BIG_SYNC_REQ; + pa_req->in_progress = FALSE; + pa_req->data.setup = setup; + queue_push_tail(bcast_pa_requests, pa_req); +} + static void setup_create_ucast_io(struct bap_data *data, struct bap_setup *setup, struct bt_bap_stream *stream, @@ -2043,7 +2084,7 @@ static void setup_create_bcast_io(struct bap_data *data, setup_connect_io_broadcast(data, setup, stream, &iso_qos, defer); else - setup_listen_io_broadcast(data, setup, stream, &iso_qos); + setup_accept_io_broadcast(data, setup); } static void setup_create_io(struct bap_data *data, struct bap_setup *setup, @@ -2281,19 +2322,12 @@ static void bap_state_bcast(struct bt_bap_stream *stream, uint8_t old_state, if (!setup || setup->id) break; if (bt_bap_stream_io_dir(stream) == - BT_BAP_BCAST_SOURCE) { + BT_BAP_BCAST_SOURCE) /* If the stream is attached to a * broadcast sink endpoint. */ setup_create_io(data, setup, stream, defer); - if (!setup->io) { - error("Unable to create io"); - if (old_state != - BT_BAP_STREAM_STATE_RELEASING) - bt_bap_stream_release(stream, - NULL, NULL); - } - } else { + else { /* If the stream attached to a broadcast * source endpoint generate the base. */ @@ -2657,32 +2691,23 @@ static void bap_detached(struct bt_bap *bap, void *user_data) bap_data_remove(data); } -static int bap_bcast_probe(struct btd_service *service) +static int short_lived_pa_sync(struct bap_bcast_pa_req *req) { + struct btd_service *service = req->data.service; struct btd_device *device = btd_service_get_device(service); struct btd_adapter *adapter = device_get_adapter(device); struct btd_gatt_database *database = btd_adapter_get_database(adapter); struct bap_data *data = btd_service_get_user_data(service); - char addr[18]; - - ba2str(device_get_address(device), addr); - - if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) { - error("BAP requires ISO Socket which is not enabled"); - return -ENOTSUP; - } + GError *err = NULL; - /* Ignore, if we were probed for this device already */ if (data) { - error("Profile probed twice for the same device!"); - return -EINVAL; + DBG("Already probed"); + return -1; } - data = bap_data_new(device); data->service = service; data->adapter = adapter; data->device = device; - data->bap = bt_bap_new(btd_gatt_database_get_db(database), btd_gatt_database_get_db(database)); if (!data->bap) { @@ -2707,7 +2732,146 @@ static int bap_bcast_probe(struct btd_service *service) bt_bap_set_user_data(data->bap, service); - bt_bap_new_bcast_source(data->bap, device_get_path(device)); + DBG("Create PA sync with this source"); + req->in_progress = TRUE; + data->listen_io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, req, + NULL, &err, + BT_IO_OPT_SOURCE_BDADDR, + btd_adapter_get_address(data->adapter), + BT_IO_OPT_DEST_BDADDR, + device_get_address(data->device), + BT_IO_OPT_DEST_TYPE, + btd_device_get_bdaddr_type(data->device), + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_QOS, &bap_sink_pa_qos, + BT_IO_OPT_INVALID); + if (!data->listen_io) { + error("%s", err->message); + g_error_free(err); + } + + return 0; +} + +static void iso_do_big_sync(GIOChannel *io, void *user_data) +{ + GError *err = NULL; + struct bap_bcast_pa_req *req = user_data; + struct bap_setup *setup = req->data.setup; + struct bap_data *data = setup->ep->data; + struct sockaddr_iso_bc iso_bc_addr; + struct bt_iso_qos qos; + + DBG("PA Sync done, do BIG Sync"); + g_io_channel_unref(setup->io); + setup->io = NULL; + + setup->io = io; + g_io_channel_ref(setup->io); + + /* TODO + * We can only synchronize with a single BIS to a BIG. + * In order to have multiple BISes targeting this BIG we need to have + * all the BISes before doing this request. This request is triggered + * by an endpoint "SetConfiguration" command. For multiple BISes + * we need another way to specify which BISes user is requesting + */ + iso_bc_addr.bc_bdaddr_type = btd_device_get_bdaddr_type(data->device); + memcpy(&iso_bc_addr.bc_bdaddr, device_get_address(data->device), + sizeof(bdaddr_t)); + iso_bc_addr.bc_bis[0] = 1; + iso_bc_addr.bc_num_bis = 1; + + /* Set the user requested QOS */ + 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)); + + if (!bt_io_set(setup->io, &err, + BT_IO_OPT_QOS, &qos, + BT_IO_OPT_INVALID)) { + error("bt_io_set: %s", err->message); + g_error_free(err); + } + + if (!bt_io_bcast_accept(setup->io, + iso_bcast_confirm_cb, + req, NULL, &err, + BT_IO_OPT_ISO_BC_NUM_BIS, + iso_bc_addr.bc_num_bis, BT_IO_OPT_ISO_BC_BIS, + iso_bc_addr.bc_bis, BT_IO_OPT_INVALID)) { + error("bt_io_bcast_accept: %s", err->message); + g_error_free(err); + } +} + +static void pa_and_big_sync(struct bap_bcast_pa_req *req) +{ + GError *err = NULL; + struct bap_setup *setup = req->data.setup; + struct bap_data *data = setup->ep->data; + + req->in_progress = TRUE; + + DBG("Create PA sync with this source"); + setup->io = bt_io_listen(NULL, iso_do_big_sync, req, + NULL, &err, + BT_IO_OPT_SOURCE_BDADDR, + btd_adapter_get_address(data->adapter), + BT_IO_OPT_DEST_BDADDR, + device_get_address(data->device), + BT_IO_OPT_DEST_TYPE, + btd_device_get_bdaddr_type(data->device), + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_QOS, &bap_sink_pa_qos, + BT_IO_OPT_INVALID); + if (!setup->io) { + error("%s", err->message); + g_error_free(err); + } +} + +static int bap_bcast_probe(struct btd_service *service) +{ + struct btd_device *device = btd_service_get_device(service); + struct btd_adapter *adapter = device_get_adapter(device); + struct bap_bcast_pa_req *pa_req = + new0(struct bap_bcast_pa_req, 1); + + if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) { + error("BAP requires ISO Socket which is not enabled"); + return -ENOTSUP; + } + + /* First time initialize the queue and start the idle timer */ + if (bcast_pa_requests == NULL) { + bcast_pa_requests = queue_new(); + pa_timer_id = g_timeout_add_seconds(PA_IDLE_TIMEOUT, + pa_idle_timer, NULL); + } + + /* Enqueue this device advertisement so that we can do short-lived + */ + DBG("enqueue service: %p", service); + pa_req->type = BAP_PA_SHORT_REQ; + pa_req->in_progress = FALSE; + pa_req->data.service = service; + queue_push_tail(bcast_pa_requests, pa_req); + return 0; }