From patchwork Tue Oct 31 15:55:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 13441680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79960C4167B for ; Tue, 31 Oct 2023 15:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344813AbjJaPzu (ORCPT ); Tue, 31 Oct 2023 11:55:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344808AbjJaPzt (ORCPT ); Tue, 31 Oct 2023 11:55:49 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2073.outbound.protection.outlook.com [40.107.6.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F544DA for ; Tue, 31 Oct 2023 08:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bV3UY+5aqagrdYFN+PCSIkqLFVvNJqHFJurahSLliKw5R0JyQ36CyMew44HIuKeFFG7zzqjvI5a230aKiYKoZJD3GPKxdV69SnH45KUlxnSgolTowgre/ccPmsqlPO+THt+XyL8+R34tpNGT+xQqjvlWU610Mo+AUCoc1bYBhsZX/eNADcUcUnr72YDcRT5qKAKmodEhlUAlO1NtawJ/AXCblbfX7EGeEFwoso/khetRwPD5K1EfolcUXFa1xxatAT4TfGFf4h4ViI4yolKb8q8RojRiteGEzjSM8qsf58Akb9h98/TPsjaIUeL8t48oJMTjaVtTcbbtrQn919sYKg== 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=hWM/uQZU9RxfJdKvLLiJrUcg9hwoKwESBKE1PIF6FLo=; b=e+mXmXAtu1TS9fIQTvZ9e9iTA3niuWtFBEhqyHAxatpHPnOTT+Kh7KbPcZCRnpus+vttYYoF+FFFIxYjBb3x8rGQXM4Sx4e5b6Jmu8u8EGvR9ZdtkUejQsH0OMnOBMxDltODVvxdGJL7ricuIt5LMDyyBI+2QLxqrNaB2fuc5aECKS5bpJkGBl5fEfLqZWDHulh1cT+wbJXOEj/oSgwZLY/sUMtC+qUbnqX3g3QcgCUSQT0aKnlww8uOfTCFsCE9COtzEK4L466Y0Afv6zwRnSjweVRYIm4uxmZGCm6rfuKw7KbaG+R2z/NKHMrX585GvqoIuPiOj/G7gm3po2V6WQ== 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=hWM/uQZU9RxfJdKvLLiJrUcg9hwoKwESBKE1PIF6FLo=; b=DoKZBCmrtCgWSy2kCqSuIyn6TT/ZIwxUjbGcLrcjuo5d5DRh39JGzQIxRkD05pz2cCKNyJ/WQZVLGHMrAlRONmYDz6pk3qp9karJnvb/VDCl9KE4i7HeePvngbwQaTH31b9G1FKBDU/AytCaeP98aGgDp1/DcqKkDdRE/IerV6A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) by DU2PR04MB8613.eurprd04.prod.outlook.com (2603:10a6:10:2d8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Tue, 31 Oct 2023 15:55:43 +0000 Received: from DBBPR04MB6331.eurprd04.prod.outlook.com ([fe80::7c8a:c8da:e6a5:8a4a]) by DBBPR04MB6331.eurprd04.prod.outlook.com ([fe80::7c8a:c8da:e6a5:8a4a%7]) with mapi id 15.20.6933.009; Tue, 31 Oct 2023 15:55:43 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, iulia.tanasescu@nxp.com Subject: [PATCH v2 1/5] bap: Fix source+sink endpoint registration Date: Tue, 31 Oct 2023 17:55:31 +0200 Message-Id: <20231031155535.228994-2-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231031155535.228994-1-silviu.barbulescu@nxp.com> References: <20231031155535.228994-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VI1PR07CA0137.eurprd07.prod.outlook.com (2603:10a6:802:16::24) To DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR04MB6331:EE_|DU2PR04MB8613:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f73d4f4-8e74-4b2b-6ff1-08dbda29d6c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0OaUVcAizB85Avlp9W6kNSlGn1/24fBAAaB+Aw/+XSaj4SOctCnEEColZO0FwCJxgDy1W5TwcZODOwkjcrmtJPC5FmnR542B+ouNIPGhUxNP/KwAXQgZQ2n4sAz51hzpA+toC/r0UDMM+3X0rLUTmRP9IPZsmFszCgSdATgsBserPPPpcjLiI3PxO63vkw1n65Tjauc5+gVFLoiIUIoH7Y0K/YFIoJX+Oe4EhN6wBnk1AQFeV1Bn7vvtM6ZWxqPRmP1pIidS39aTUKs3bbjJio45joiMoC+3EQLDSetjM6ls8ElEWzBNO8ms1XSjzGkDOESI4/jp8y7wNv6yMbPYzEHbKuEctPdjfo1a/T8K27zQjjOLMwhmnTiaWhrpolBLJYVAhdJ4Ocj+0vFJQZ2cz2fB/ZfIDGKuPWCTrJyjMcPYLioriqVHznzi3gpY5MoBxshDcfGdkeRIvYkW7e3RyOal3hU1RuAnKs2eyNBPQqIHnA7kzj1jghqkMOpj2ikq3xFc3WJLaH4Vhi5hZjMCtCDiNyfaVTued8JrR9WhzQ2qyOEODLOGXoNO2iFoUWaA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBBPR04MB6331.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(39860400002)(396003)(366004)(346002)(376002)(230922051799003)(186009)(451199024)(1800799009)(64100799003)(38100700002)(5660300002)(86362001)(2616005)(1076003)(26005)(83380400001)(478600001)(36756003)(6506007)(6666004)(6512007)(6486002)(2906002)(66556008)(66946007)(66476007)(41300700001)(8676002)(8936002)(316002)(6916009)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TnH761cS9IV/iDyZXQJFjW3CtqLi1lt3WHr131jMOy3kGvnZIwPMzvKQ6MonOWvkzUMB3bNOr1YblGIYi89K87vWrCZRyuFJPEpdvao90isldb+4EOaY8tP6quWGruqxR7mMkfG4EByuQwTs70FUXXa+vi5z6OoRbzFyDWmmRjQgR0rID4ebPnNrHed4hb7UT25fpGi///xn4sETPznSBaRjeRULL3WLmGUy+73I0vezROfoTEL2mp2c1XwxL2HpqEZjKDk4UjlHchPuigvNEeG7u3L3L2gvLX/alIM5H/4QXlfdOwj+EjmFvFECT3jOMHgcklCdawScgrLrkGCf54GNdGmcnIk9IKkjdSw3R2NhBs72GTszPGX5IcUrs8aVxDfvdcfRwAaU1FTGSzIJfH9cGNkeugHT4vi0whLiZ0zizGrbLHU5o52wjNq7ksg62SzaVZbjrQBf2TdW3hMrzvquG5RSlwg2psVgG7RziVgZJ1emZV5cewV38u+fUK6GNYbILP3D51VD8dxn4icCWq4ZuCQdknypfTqj3Y76tqzurp9atXoz3hXxjKQQ+cDbtSRCT7p7n8Sq1UUnuBJBrpnx5jEGx+M0fad0Q8HPrxbTRybaINHGXGC1/8yWOsM7OmhsqEqcJaHjwOnjIRLgF8/PCM2rEE+idHEqDGNcMqnr+xLPhWEJIe7D8xIRapeNDlfT4fyNloDTfkweFMfDRKGkmJhXIaWMzKXkHMY7mkBLgySf9llVebCR/3UN2c/y6rLHbAyn6uZuyj9y+g9LEGAFrT4yPkHA2KlRRXt5CLDRuozRG7bMgCKfKgf3LKcKAQrEZl5z51X5gJcvAeAffyfqyQ9enSnlxO4yb0nrR0Y1Xn0dKal8CzRUrBdgEKerdtwi6AxnD6cnwN8niUdPbuhWuViTExb5CFF7ALzc+qtgnYg1hHPdkQW1Q0Eu/Fc/uhLTgpz3T1Wv5QnQpbe2v2zpgauapAu61K3KSs1Dtsa/I3vpp2fjAkXo+5uBC6xafyeKUrYXqdS+Jnw6abGn7jSTFfD+DwvmkznAAOTbHGN5TK69nd/IipZ3Sif2GeEKuL1hc66Yx5ysO3AZBhuPei38dWcBBKZA7oebFgn0VnGXkUvhbhamLIcF37osq1vvXj8pkJee7lsfMky+8eeGS/LhitcY0r/d7TLBiazIxy/+9gfU79sn0auv/lfPGV0cPsipSm5tpd8jeKDWH2GrIRcjg+F2iLtjfAwKAwRiXF54z+pXcL3SvH8n+xJ2K+3//H8eakyasrLRVpNdNrWABMRjLfpyrh95Xh7del4hLGdN4HPRkWyIe63eKRKBMTWjhtZK4fjLSgsXnev9oJx5mVaWQifcj8ht2HsMg5jzSYZqSyP3SoshPzbdWdQ7OhApt56sDjBX9f0aPovL0T6VIV+wlRTlB3czb158GtrFYS/nmX5wSZPpWX7riuEqEbT6zlBDNNl16skHGidWfTyhXRB4xehEC17CNGjlNUS+0jHf5hbO77kDsgjgeVh8mtTu+ZPnX6yDI/Jsp+nkw/ULkM9S1ZRCl5Z5Rmadq0t9bYjEkpQ5TI/Zth7CvkXQGoLptji3CxcFMqRmmQDu1hAI3Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f73d4f4-8e74-4b2b-6ff1-08dbda29d6c6 X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2023 15:55:43.6375 (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: jb3S1N6XqA6VDMzm9ouwdieWZ8mc3ox8b4nT7Re7qT3AEFsValtm/kYC7bIJkJdBLaCA39vdIrTNz7kXhL3PBVmt0G0NT7xRBpKkl/69Z14= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8613 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Claudia Draghicescu When registering both sink and source endpoints, the register endpoint method call results in 2 remote endpoints for each scanned broadcast source --- src/shared/bap.c | 73 ++++++++++++++++++++++++------------------------ src/shared/bap.h | 3 ++ 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 13bbcf793..d8a3adde6 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -629,7 +629,7 @@ static struct bt_bap_endpoint *bap_endpoint_new_broadcast(struct bt_bap_db *bdb, if (type == BT_BAP_BCAST_SINK) ep->dir = BT_BAP_BCAST_SOURCE; else - ep->dir = BT_BAP_BCAST_SINK; + ep->dir = 0; return ep; } @@ -1485,12 +1485,12 @@ static void ep_config_cb(struct bt_bap_stream *stream, int err) return; if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) { - if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK) + if (!bt_bap_stream_io_dir(stream)) stream_set_state_broadcast(stream, - BT_BAP_STREAM_STATE_QOS); + BT_BAP_STREAM_STATE_QOS); else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) stream_set_state_broadcast(stream, - BT_BAP_STREAM_STATE_CONFIG); + BT_BAP_STREAM_STATE_CONFIG); return; } @@ -2622,7 +2622,7 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, struct iovec *metadata) { struct bt_bap_db *bdb; - struct bt_bap_pac *pac, *pac_broadcast_sink; + struct bt_bap_pac *pac; struct bt_bap_codec codec; if (!db) @@ -2650,15 +2650,6 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, break; case BT_BAP_BCAST_SOURCE: bap_add_broadcast_source(pac); - if (queue_isempty(bdb->broadcast_sinks)) { - /* When adding a local broadcast source, add also a - * local broadcast sink - */ - pac_broadcast_sink = bap_pac_new(bdb, name, - BT_BAP_BCAST_SINK, &codec, qos, - data, metadata); - bap_add_broadcast_sink(pac_broadcast_sink); - } break; case BT_BAP_BCAST_SINK: bap_add_broadcast_sink(pac); @@ -4416,21 +4407,12 @@ void bt_bap_foreach_pac(struct bt_bap *bap, uint8_t type, func, user_data); case BT_BAP_SOURCE: return bap_foreach_pac(bap->ldb->sinks, bap->rdb->sources, - func, user_data); + func, user_data); case BT_BAP_BCAST_SOURCE: - if (queue_isempty(bap->rdb->broadcast_sources) - && queue_isempty(bap->rdb->broadcast_sinks)) - return bap_foreach_pac(bap->ldb->broadcast_sources, - bap->ldb->broadcast_sinks, - func, user_data); - - return bap_foreach_pac(bap->ldb->broadcast_sinks, - bap->rdb->broadcast_sources, - func, user_data); case BT_BAP_BCAST_SINK: return bap_foreach_pac(bap->ldb->broadcast_sinks, - bap->rdb->broadcast_sources, - func, user_data); + bap->rdb->broadcast_sources, + func, user_data); } } @@ -4475,6 +4457,20 @@ void *bt_bap_pac_get_user_data(struct bt_bap_pac *pac) return pac->user_data; } +bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac) +{ + if (!bap->ldb) + return false; + + if (queue_find(bap->ldb->broadcast_sinks, NULL, pac)) + return true; + + if (queue_find(bap->ldb->broadcast_sources, NULL, pac)) + return true; + + return false; +} + static bool find_ep_unused(const void *data, const void *user_data) { const struct bt_bap_endpoint *ep = data; @@ -4483,7 +4479,10 @@ static bool find_ep_unused(const void *data, const void *user_data) if (ep->stream) return false; - return ep->dir == match->rpac->type; + if (match->rpac) + return ep->dir == match->rpac->type; + else + return true; } static bool find_ep_pacs(const void *data, const void *user_data) @@ -4642,7 +4641,11 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, struct bt_bap_endpoint *ep; struct match_pac match; - if (!bap || !bap->rdb || queue_isempty(bap->remote_eps)) + if (!bap) + return NULL; + + if (!rpac && (lpac->type != BT_BAP_BCAST_SOURCE) + && queue_isempty(bap->remote_eps)) return NULL; if (lpac && rpac) { @@ -4679,7 +4682,9 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, return NULL; bt_bap_foreach_pac(bap, type, match_pac, &match); - if (!match.lpac || !match.rpac) + if (!match.lpac) + return NULL; + if (!match.rpac && (lpac->type != BT_BAP_BCAST_SOURCE)) return NULL; lpac = match.lpac; @@ -4861,12 +4866,12 @@ unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream, queue_foreach(stream->links, bap_stream_enable_link, metadata); break; case BT_BAP_STREAM_TYPE_BCAST: - if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK) + if (!bt_bap_stream_io_dir(stream)) stream_set_state_broadcast(stream, - BT_BAP_STREAM_STATE_CONFIG); + BT_BAP_STREAM_STATE_CONFIG); else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) stream_set_state_broadcast(stream, - BT_BAP_STREAM_STATE_STREAMING); + BT_BAP_STREAM_STATE_STREAMING); return 1; } @@ -5399,10 +5404,6 @@ bool bt_bap_new_bcast_source(struct bt_bap *bap, const char *name) struct bt_bap_endpoint *ep; struct bt_bap_pac *pac_broadcast_source; - /* Add the remote source only if a local sink endpoint was registered */ - if (queue_isempty(bap->ldb->broadcast_sinks)) - return false; - /* Add the remote source only if a local sink endpoint was registered */ if (queue_isempty(bap->ldb->broadcast_sinks)) return false; diff --git a/src/shared/bap.h b/src/shared/bap.h index 23edbf4c6..2c8f9208e 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -317,3 +317,6 @@ void bt_bap_update_bcast_source(struct bt_bap_pac *pac, struct bt_bap_codec *codec, struct iovec *data, struct iovec *metadata); + +bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac); + From patchwork Tue Oct 31 15:55:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 13441681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 802D6C4167D for ; Tue, 31 Oct 2023 15:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344831AbjJaPz4 (ORCPT ); Tue, 31 Oct 2023 11:55:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344827AbjJaPzz (ORCPT ); Tue, 31 Oct 2023 11:55:55 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2068.outbound.protection.outlook.com [40.107.21.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42BE598 for ; Tue, 31 Oct 2023 08:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lNbjt+tMWlwDUwlS0ndyv4sLL5TK+r46hJL77ryj3DCFiHCGC06js8zvNApwFoSK5LQVdQxF8DXZnI67A1GlHCLmTiA/zcxxhsZRVXw2tTt6Nfm7lfeTb+GyOMPuUuRQKi3J6fsXYFHo3VCJteuJ62dJfWmDV2g/wPgokH1ZtKPecEP4Ku0PrGZ14GFSD9hAu0XEh6O9OVDC/MMY5hR4RWhvyloDC1xcDXkZQOVcR3g2SOyQh/mPxoQeAMGbbFjeLHLfLBZWE0PMk/zgLHJ1rL05aXoRbP+8jN6Jzr7ZQyV3BrhCjECyi+tx1ytYpp3b3PIIj8ra/5ADhdeGfLFdcA== 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=Vi/ZSLXSrUXlK01jYrePfFEPvoRv24/Uft1lOdUvYOE=; b=P2QMngOKtZ+XtFmUtpQX2R/iHAP3OKrvy3mQoclYMSeWhZH/x5s+bmR2mTRMMbSG+RNWIOmUTnz9tPPOqcXI6tU1i+lN15YUgIW+Qyr/ey3lOuZIw0pQ02YeyJEcT5b6/nHX7PVSGx78qmxMig2P1ybr2+vpX8mLdQEu2t4WjiQjTloWYXQLdHG0WlT07+TlE5UetCp6nYdgSDV6g/emL1TIe9xESkA0HrZYNbz2Rf2EdO2Q8szakSQywoETve0LvqCVS+7qMqOxGcTcw0tr1f6QVoeEcPcjmjfiAXmFNEpOvX057LN4tPM90v/PeSrzEmm/Ie9jFepgD7eGJQMcuA== 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=Vi/ZSLXSrUXlK01jYrePfFEPvoRv24/Uft1lOdUvYOE=; b=hw3uShMJZu7YWqoZqyoxdpnEnaPx1MuIVL+NFdTUfwQVCvvCjmYYXPFTLC1oerjxpHpL9zt/iMn7VNA9WcJCEJsyagWcS7LtS6Y+M4O37vq1yYr2Dv7DS6ymz2+gOPSRPo16aze614IyT+HU0n1RokYqSv1+1kCluJOvLU19iFE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) by VE1PR04MB7440.eurprd04.prod.outlook.com (2603:10a6:800:1b2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.17; Tue, 31 Oct 2023 15:55:48 +0000 Received: from DBBPR04MB6331.eurprd04.prod.outlook.com ([fe80::7c8a:c8da:e6a5:8a4a]) by DBBPR04MB6331.eurprd04.prod.outlook.com ([fe80::7c8a:c8da:e6a5:8a4a%7]) with mapi id 15.20.6933.009; Tue, 31 Oct 2023 15:55:47 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, iulia.tanasescu@nxp.com Subject: [PATCH v2 2/5] bap: Fix source+sink endpoint registration Date: Tue, 31 Oct 2023 17:55:32 +0200 Message-Id: <20231031155535.228994-3-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231031155535.228994-1-silviu.barbulescu@nxp.com> References: <20231031155535.228994-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VI1PR09CA0150.eurprd09.prod.outlook.com (2603:10a6:803:12c::34) To DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR04MB6331:EE_|VE1PR04MB7440:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e1a9f8f-a71c-463f-8fc5-08dbda29d92d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uWEiOp1vug3eWSlKbqbgIVniZkrjyBYxlBMTykhbRbUiXBmIXzvBufQJaZoYcbZBy7OgkdUj+1VjAiaWvoJ+4xqwWCmPIfMdIicBUnOoz+WyiCBzjv1mRzD0pLJNbkKWjbkdvH32XqKyvoX3th+wO8Kb+VYLhtH2SCYn7ovVti6JYginrA2kvcR24Nzh72iAxYBDQziROybdTM4jJq6R0Mju8ZsQLUZ34lomdsW8grBvASJOXqTzEebTJo46HR8D6f5UvMvVBVoi8N5vLcVsHFAHr9JkWxFePpfIJZQy2VoRQfsWg127iq/ADHES4dq5PDuGboscAu7DDzLHKzGhnQ1O62h7SSY3yBoRrc3FK3bY+Eul5Dhy7018V+eHCmk4eWjnV+6UJ6sbfV8SSWpwaw5/nGxeMBExIFciEhNV8zqD0P0FyTIVYjEIcS+4M1/KAywyTxv8hGGRYLEiDosOMpxnU2DyoEKsNaZ2SZlQYCJwfVdQOAYi9BVjm3zDZ9cMdRUKBLy3VEeZuK/WxYrjnF+DtoKWsblN2YI4vyxmj+rcrpZnftcLbbRCeIvr6I8t X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBBPR04MB6331.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(396003)(376002)(136003)(39860400002)(366004)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(8676002)(4326008)(8936002)(83380400001)(5660300002)(41300700001)(38100700002)(6486002)(478600001)(6506007)(36756003)(2906002)(6512007)(86362001)(6666004)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 963wjS3M8FnpRuLBJBgnzbDG645Z0LSSAzfOAN8M5IU69r0T0oYW8iGzfI35/vxwVfQZb7BE8/76+8jArK7uqFgqhPsXAm81DUgc+MZFXlPo1rpgGVEPmS1/R6qV79gY5YAGAFrZPRBgaGdU1fDun8SiYurbOF+aiq/rptqU3gTE4I7Fn9nXF0GndCwh4VlsfGwunxa06CA42HOoh7LGlpA2Ww4nQB57b6i66Ic1iHRv7w5mIinFuLA1cd7Lp54btLd5tDCpWY/Xk4xu0RGXMv7DmyW8dJFg3CRyY1GIoFz0T50wOF949/XhKdUmaPTo40LeTidz30qqHtCWDh8EVUu/PuMN0F9WIMdgHMmVo6gyEey4Hq3+koMgdkmHFAuPntRVFxkDISbpPpOrv/MZlTa+0h6zLg7ZDOQ0zm48AJ98pn3tgFDEhEeQg1ocnDbpH79TzuMZvvcTVG4CBiDCjAUxjs4LZx5B4VEGmo8E+NdB9VDc+ae//cI98eaFDuhTCseHVahb7PkQh6b+4Oh88Usob1LG/bxTIk93Wrl0B8iWikJ2rofxlsXNasGweHwVL9NTjqSvf+9SBHs7qP1aYYyMB9TJS5ilwbZNpWmVNIZ35kMZ9zcTDRPpZ8r5lvXdek+sJvnAWS6y4oCBCrkRFPhp88XlvxdSdskahFFvcdHxYlckcj0fKZuxZgO4PIoeQWD+0sxYrebeZA8BrV0QjbG/BWo3hg5t6XUw6OEKgPdYO2yADpdHgStCS6vytR/mAkgLxVcgNhonUi9ZIjjnNadm3kawW81YMbu1pui/CyGkAF2/74UFaQSOuBvCx71k9QgIeVVHeTe0uE0MpjTVeLX/roBPHUkZGpw/vcdF4IXfZNR3GJrbFjt1m+T1fXBaMf9zIlFtafVnzbDu5hw3BY63vbtVRSspXP7RVippbml8b2eYasyhPDi+xKQMtENG19rnKqNnAqocYaAXNzZAumMJkWY/0h2bHat0Ce8jwGH2BgrENuGtNkYH3kVWQzDVfuzLIasZtmQ9wcGHXTdsxwmNwCRSshJuF8f5k+jJ6YQAnKUuC6fOu0nk0Ux4iTMKTdedrc17Wfx7arpq8EyC1JHp8rgNgkiUyZYnQpUep7w4Mnh2Kd+VVmqsA/hU7pnfpPsPDaZiWEWK/w3D7u6N3Ldqm4stUVLOsL4aigQRqP4ZQt4ryAPIq6I+ROx9MkDHB6+S05L53aBZgYpUeGHEijAs+MEmZ80QBw22OYX2NuIgamnB6WdowqeInr4U9INH6/IFIw2FUjKeawZhFc16C1aMoeY3Rbvu3pxe5jMc4JW7XUNQ1FA3cjFULhCfWSHQtejgklgXQpePjQGe02cnRXEjU3rOEBPowJdrhZfN+VAoAVjORuHGFZtti8UDTFNR1SCzU3IKOflOGzdwhFe8IGmiHt7aGRtVLf7Xg0H7Atd6BChDDusIWILzje2RTSOnDrA066YlVTekWcf0kj986aEQirqaHLbYZ2u2fxsMfy4QK5WBMMNtslvgTywpNCvEWSWhmV3iwAgP8iC1kGQt21pRB9s79XBkbgTv6pnSHRzLerN2CmI+FJNt66Otn1yA9sW3+0/P3I2qZHPFK9AGuA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e1a9f8f-a71c-463f-8fc5-08dbda29d92d X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2023 15:55:47.6372 (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: o14Msj4BPrv03sU8YVhGzNObR2PY7qsLYWUh+FJzuxdSXGXul1UcTeG9pe1IWh61uLaPaD9w717/kQQ9s0o/zVZ9zDp1jW7axfpI1vto2Is= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7440 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Claudia Draghicescu When registering both sink and source endpoints, the register endpoint method call results in 2 remote endpoints for each scanned broadcast source --- profiles/audio/bap.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index b74498c4c..a84181e1a 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1050,7 +1050,7 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, const char *suffix; struct match_ep match = { lpac, rpac }; - switch (bt_bap_pac_get_type(rpac)) { + switch (bt_bap_pac_get_type(lpac)) { case BT_BAP_BCAST_SOURCE: case BT_BAP_BCAST_SINK: queue = data->bcast; @@ -1073,13 +1073,13 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, if (device) ep->data->device = device; - switch (bt_bap_pac_get_type(rpac)) { - case BT_BAP_BCAST_SINK: + switch (bt_bap_pac_get_type(lpac)) { + case BT_BAP_BCAST_SOURCE: err = asprintf(&ep->path, "%s/pac_%s%d", adapter_get_path(adapter), suffix, i); ep->base = new0(struct iovec, 1); break; - case BT_BAP_BCAST_SOURCE: + case BT_BAP_BCAST_SINK: err = asprintf(&ep->path, "%s/pac_%s%d", device_get_path(device), suffix, i); ep->base = new0(struct iovec, 1); @@ -1101,7 +1101,10 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, ep_free(ep); return NULL; } - bt_bap_pac_set_user_data(rpac, ep->path); + if (rpac) + bt_bap_pac_set_user_data(rpac, ep->path); + else + bt_bap_pac_set_user_data(lpac, ep->path); DBG("ep %p lpac %p rpac %p path %s", ep, ep->lpac, ep->rpac, ep->path); @@ -1792,7 +1795,7 @@ static void bap_listen_io_broadcast(struct bap_data *data, struct bap_ep *ep, error("%s", err->message); g_error_free(err); } - + ep->io = io; ep->data->listen_io = io; } @@ -1958,12 +1961,12 @@ static void pac_added_broadcast(struct bt_bap_pac *pac, void *user_data) { struct bap_data *data = user_data; - if (bt_bap_pac_get_type(pac) == BT_BAP_BCAST_SOURCE) - bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SOURCE, - pac_found_bcast, data); - else if (bt_bap_pac_get_type(pac) == BT_BAP_BCAST_SINK) - bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SINK, - pac_found_bcast, data); + if (bt_bap_pac_bcast_is_local(data->bap, pac) && + (bt_bap_pac_get_type(pac) == BT_BAP_BCAST_SOURCE)) + pac_found_bcast(pac, NULL, user_data); + else + bt_bap_foreach_pac(data->bap, bt_bap_pac_get_type(pac), + pac_found_bcast, data); } static bool ep_match_pac(const void *data, const void *match_data) From patchwork Tue Oct 31 15:55:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 13441682 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E12D2C4167B for ; Tue, 31 Oct 2023 15:56:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344844AbjJaP4B (ORCPT ); Tue, 31 Oct 2023 11:56:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344827AbjJaP4A (ORCPT ); Tue, 31 Oct 2023 11:56:00 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2068.outbound.protection.outlook.com [40.107.21.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C945E109 for ; Tue, 31 Oct 2023 08:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gQpwhaIpF/bGzfPCxEMA4XhwQcSr6g6TOOXpFSKaJkCpM4onwldLbwQYxDl2T2lRb7RlDWhQ7nPRn9+wtdCc/maPaTnZNLJC8Y/h0xhgSnNF0eqISprY4LVp+KB/CEG6gyXUb/H3fb+fGF832mMjGdmGzHEYvu+9D6318r2OjJ/G+LX7+vx01k7ntJoikYskSy4FRNxK2sOwkYKiNW7DYZvBWxWCNZDwUoYA7TBuYCbldHTZU9juJ294+CS+6bliXpi3wbSgEBwydulaSaxIAHbS005vxGgHv1437bEaTaSpsJBcXcqxIUh+ppalYXZ29r2NSNnPzOa3YQvT/3kQxw== 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=wzPnZ9PnDHsHFqPX1Dzc8vSd7iVAtpQyYuMFSndwo6E=; b=T1hw6eCDLMvzbCHzj38ogMjizk4IcoKXkoPRiCjC1dkIPrfUEmOFs/JWU2Lga07kFEZT9yOUEPwlWV5Q/kGKLYYWuRRr3PF/GcNrV3UMZ3JoDjy4SioVps7ecNHWIIZ8g8AiVGmyMYAs7pLfjUtntqY0mYaz8zclLPGJVP7nEw/Wa6Y7zRi/PWC+znPNwyx/z1ZJ7wrbZTbxUwM2fLssvYCeBjBr0Q0HobXWvVx6olCuNPDByCp0FyhZ3ZjzYtZ83kiUH58DYDQwe5n3NsGJ+GpxLYjm++JTg3VWv0YklAjMTIaXZ+A9ZOMdEFMf91SbevBLRZF0060pnL1c8KbfVw== 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=wzPnZ9PnDHsHFqPX1Dzc8vSd7iVAtpQyYuMFSndwo6E=; b=BmkNPRbEBVfeXDav46io0euEl3+PsZrsGr/B7lbQhRclmfH4p7zAW00gbhfSw2KKO0xaASLeue/liWLMnSGpJs3BFwhQBw1+/JWgSa8vTJg9x13ly/Q73M/ZWxfIiJgzs8J+tjicoPV5Z/cqwq3A8bEb4z+ShAPDzlb8REd/iWg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) by VE1PR04MB7440.eurprd04.prod.outlook.com (2603:10a6:800:1b2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.17; Tue, 31 Oct 2023 15:55:51 +0000 Received: from DBBPR04MB6331.eurprd04.prod.outlook.com ([fe80::7c8a:c8da:e6a5:8a4a]) by DBBPR04MB6331.eurprd04.prod.outlook.com ([fe80::7c8a:c8da:e6a5:8a4a%7]) with mapi id 15.20.6933.009; Tue, 31 Oct 2023 15:55:51 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, iulia.tanasescu@nxp.com Subject: [PATCH v2 3/5] Add support for bcast multiple BISes Date: Tue, 31 Oct 2023 17:55:33 +0200 Message-Id: <20231031155535.228994-4-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231031155535.228994-1-silviu.barbulescu@nxp.com> References: <20231031155535.228994-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VI1PR07CA0135.eurprd07.prod.outlook.com (2603:10a6:802:16::22) To DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR04MB6331:EE_|VE1PR04MB7440:EE_ X-MS-Office365-Filtering-Correlation-Id: e5ca7b6b-fe19-4f70-1732-08dbda29db1b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2qAYUN1YgYDlPXDNbLuKWEtQboT+Ry2W4egdAxC5IImNaUXsxGJbM9n0A9cBu7sT3mnvTS6Evf78JUPSsjqib7+pEGLsw5jgJJhCvCpN3bTSOyT9c9DFUrzq4Mccm2O3GoRuduVEzs8Qbr47KWyeSAlPVGQMIVlZjWBpVgcG78fBxGd98x8P4+dvgHIEbCSViIPYcXRUdNcePha+dlM4DeTManBH35SOYjweDq7+pDyXcmj2xBeXaRwCfb8lmE6GwvEpeNylebE4rr2y1IUk8ZK/MpdiRYKC5w3CKrm6Vl3waNJjBEyRQDZmC4kJWBzVaoi1qPEhgH3dMfgK5KGG+c8CRXyQoTSV7MnbgxtiSa4WE+T3OFjPu3CoIA4YpkJmb0I53VEN+H+hyy18Vc48YCU6CGsFOuqd+MA2Qe4ESD8sudKTj9colA79H0vYkdMbroT/TqpnyNdzBydcmqD1QBYcufWNOUHmjwzhzlk2DGIPNOqIS1veDj+nO8obDjnQReu2SEcXMBp7rBS2TgrGr3bFVr8jhgFPc9SHQ3piStuK8kxtVDrKH0S4kSG8QtYl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBBPR04MB6331.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(396003)(376002)(136003)(39860400002)(366004)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(8676002)(4326008)(8936002)(83380400001)(5660300002)(41300700001)(38100700002)(6486002)(478600001)(6506007)(36756003)(2906002)(30864003)(6512007)(86362001)(6666004)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Zi5TGNiau0kpWDa+UK6fXpCDBdOUbGTvdGglxt99Vn1hLFXQV1QdUTtrilhOEM16z4P88tI/dfRo4qKvczZcHmTk/L/eC7GTSGPK55mJaGFKGo6/L7I8b0mZ4G3608Cgdtt7LeAxGZdahYZZHi5cVrohRQQi1U7DnrCT65A3Tp1RGUqciyUdEREIrRLg3gODPWU4hXXIYpIr3UsRcb4Syv7FZKRinK23xZxGFSuE8TmOUN8ui8Ox/fcpykDChPrwJ+sS/G1Cb6rOKQbT7o0ZYwV/fkw693agudj30mZHjHbhDVfcK8JbSHurnrSPlpVxoQepeP7U3ohJXDV+3n+3+aqZkU+kOGkI7En6CNYYwbfBeJ5RdAe4KfZopCdQSJAdsHgvIDlfPR43X+kqFpigCjkXEDh4vDOqjb0vi9an9c/GciScXHJpP43Tu7lb4h6bWu1vFNtmkjRz1BXAnOsRHHeicFPevJKo2Ygp9uZ9Gh3Uciqf/y2HQ3v3wAYiMbWgxxjjjRimg/pzr9NnS0PMqXwC6jzPWYwrkDuqPyU5hxTD+FsQjfB85pxoyw26On7Sm3GXR4L/GVwjHRn5Mh2e2KmCguQTxTF2rkji0uNDpq+gh7bv0mMXn9TihwSoub8KvQmmYsw9sEocpaktP9K5dx0hu7GUcvFgt24rWi67mdnvA6/lg177BE6d1C5pvI6pUiigsShOjrHDW8NpqJ6AXQbQpFi0ogYj9i+EfaxsiDVO9++Srn3TJXOQMSrKdCIslJKwHDwui9IJohGmBAkYSMhLIcNFCJ53UofcMnyugnyd77fel5j0r3xlpAQ2ItEhNqA8aQsnRD97UibCAEpRUd8YQZS/dfSYCif/wT8tqYnbXDsc8WYceKX9heNWVSVUkHyA5MDmWE0dWXiNAgoIw44+cs0yEft7DhpHi+DA8RfhSecgq/AOfWV8JZZ+QjCKjvW1i0Xt2t8iaMP1OAE7QsWyIhIB/eEBp5bleiIi4EFihrQBdQq+EIuN+tULwpMqvyUKmuvF1cTJRXGjy0DYFMVUQFLfEHTsabDlM6m6sNvpt3pqHPK69uU+aqFJFdBZFH9IP2AllkhHTSeEXx5A4pvTwDrIAtODLApyANI2FesX2aJtZQ8yRDe/2uynLpih6LRE+9hcB2NPC0vXOqjuI7iKjZBGhyJWCX7ruhhuoW46QhNsanzAI6Q+1ZNWcKPr+hYo0pQKeSH65EjzX0FO8gk4j0At9+VPuMDkbctLfde60xcdaUF7CUHxBn70/IvMec/X6vA+M3IfsVtLAC/b2ctftbTEM2CvZnpxH0UpF+KQCeKxaXzYeoImf89k4/lXixLAaKlcpOdqNiVCMmQ2/vJI5V5oHsY8O44w3JFiPjv6P2EfZik5VkFdcuKt5j4dTQ3zzrklEp74TjdT6x3SNmDqpFWnSywqPf0aOrdkcUHWq7s8dGboFBweDwJWJCiDGPrKjdlOBjkoi/rO/8ybMl9dLT35Cpbj3xOKjEny+nUNx9lJ6Vpbz7zp/5sNZkAFJ8997CXvgsWWgzuXquYOGRzTg/nIeR2xI9y3uslEULrYhSUHcz2rx6kMdtl1vJzXVs8gcLhUkJwgTMymPU115w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5ca7b6b-fe19-4f70-1732-08dbda29db1b X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2023 15:55:51.0268 (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: 3Bu8mnPiizuSmW8H7lD48c3wma3oC62K9KhTtr3m/LnjRr26YNS4MyoI/Rs+PDXNtBNGQN0yYVAOHeMeG7DXZN+aGy5nmxbAI5o562Pcrs8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7440 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add support for bcast multiple BISes --- profiles/audio/bap.c | 512 +++++++++++++++++++++++++++++++------------ src/shared/bap.c | 226 +++++++++++++++---- src/shared/bap.h | 32 ++- unit/test-bap.c | 12 +- 4 files changed, 593 insertions(+), 189 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index a84181e1a..fcc0684fb 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -97,6 +97,35 @@ struct bap_data { void *user_data; }; +#define DEFAULT_IO_QOS \ +{ \ + .interval = 10000, \ + .latency = 10, \ + .sdu = 40, \ + .phy = 0x02, \ + .rtn = 2, \ +} + +static struct bt_iso_qos default_qos = { + .bcast = { + .big = BT_ISO_QOS_BIG_UNSET, + .bis = BT_ISO_QOS_BIS_UNSET, + .sync_factor = 0x07, + .packing = 0x00, + .framing = 0x00, + .in = DEFAULT_IO_QOS, + .out = DEFAULT_IO_QOS, + .encryption = 0x00, + .bcode = {0x00}, + .options = 0x00, + .skip = 0x0000, + .sync_timeout = 0x4000, + .sync_cte_type = 0x00, + .mse = 0x00, + .timeout = 0x4000, + } +}; + static struct queue *sessions; static bool bap_data_set_user_data(struct bap_data *data, void *user_data) @@ -254,7 +283,11 @@ 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); + /* + *Use remote endpoint path as fake device path + *for the remote broadcast source endpoint + */ + path = ep->path; else path = device_get_path(ep->data->device); @@ -379,101 +412,184 @@ 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) +static bool parse_base(struct bt_bap *bap, void *data, size_t len, + util_debug_func_t func, struct bt_bap_base *base) { + uint8_t numSubgroups; + uint8_t numBis; + struct iovec iov = { .iov_base = data, .iov_len = len, }; + util_debug(func, NULL, "BASE len %ld", len); + if (!base) + return false; - uint8_t capsLen, metaLen; - uint8_t *hexstream; + if (!util_iov_pull_le24(&iov, &base->presDelay)) + return false; + util_debug(func, NULL, "PresentationDelay %d", base->presDelay); - if (presDelay) { - if (!util_iov_pull_le24(&iov, presDelay)) - return false; - util_debug(func, NULL, "PresentationDelay %d", *presDelay); - } + if (!util_iov_pull_u8(&iov, &base->numSubgroups)) + return false; + util_debug(func, NULL, "NumSubgroups %d", base->numSubgroups); + numSubgroups = base->numSubgroups; - if (numSubgroups) { - if (!util_iov_pull_u8(&iov, numSubgroups)) - return false; - util_debug(func, NULL, "NumSubgroups %d", *numSubgroups); - } + for (int sg = 0; sg < numSubgroups; sg++) { + struct bt_bap_base_subgroup *subGroup = new0( + struct bt_bap_base_subgroup, 1); + uint8_t capsLen, metaLen; + uint8_t *hexstream; - if (numBis) { - if (!util_iov_pull_u8(&iov, numBis)) - return false; - util_debug(func, NULL, "NumBis %d", *numBis); - } + subGroup->subGroupIndex = sg; + + util_debug(func, NULL, "Subgroup #%d", sg); + subGroup->bap = bap; + subGroup->bises = queue_new(); - if (codec) { - codec = util_iov_pull_mem(&iov, sizeof(*codec)); - if (!codec) + if (!util_iov_pull_u8(&iov, &numBis)) return false; + util_debug(func, NULL, "NumBis %d", numBis); + subGroup->numBises = numBis; + + memcpy(&subGroup->codec, util_iov_pull_mem(&iov, + sizeof(struct bt_bap_codec)), sizeof(struct bt_bap_codec)); util_debug(func, NULL, "%s: ID %d CID 0x%2.2x VID 0x%2.2x", - "Codec", codec->id, codec->cid, codec->vid); - } + "Codec", subGroup->codec.id, subGroup->codec.cid, + subGroup->codec.vid); + if (!util_iov_pull_u8(&iov, &capsLen)) { + free(subGroup); + return false; + } - if (!util_iov_pull_u8(&iov, &capsLen)) - return false; - util_debug(func, NULL, "CC Len %d", capsLen); + util_debug(func, NULL, "CC Len %d", capsLen); - if (!capsLen) - return false; - if (caps) { - if (!(*caps)) - *caps = new0(struct iovec, 1); - (*caps)->iov_len = capsLen; - (*caps)->iov_base = iov.iov_base; - } + subGroup->caps = new0(struct iovec, 1); + util_iov_memcpy(subGroup->caps, iov.iov_base, capsLen); + DBG("subgroup caps len %ld", subGroup->caps->iov_len); - for (int i = 0; capsLen > 1; i++) { - struct bt_ltv *ltv = util_iov_pull_mem(&iov, sizeof(*ltv)); - uint8_t *caps; + for (int i = 0; capsLen > 1; i++) { + struct bt_ltv *ltv = util_iov_pull_mem(&iov, + sizeof(*ltv)); + uint8_t *caps; - if (!ltv) { - util_debug(func, NULL, "Unable to parse %s", - "Capabilities"); + if (!ltv) { + util_debug(func, NULL, "Unable to parse %s", + "Capabilities"); + free(subGroup->caps); + free(subGroup); + return false; + } + + util_debug(func, NULL, "%s #%u: len %u type %u", + "CC", i, ltv->len, ltv->type); + + caps = util_iov_pull_mem(&iov, ltv->len - 1); + if (!caps) { + util_debug(func, NULL, "Unable to parse %s", + "CC"); + free(subGroup->caps); + free(subGroup); + return false; + } + util_hexdump(' ', caps, ltv->len - 1, func, NULL); + + capsLen -= (ltv->len + 1); + } + + if (!util_iov_pull_u8(&iov, &metaLen)) { + free(subGroup->caps); + free(subGroup); return false; } + util_debug(func, NULL, "Metadata Len %d", metaLen); - util_debug(func, NULL, "%s #%u: len %u type %u", - "CC", i, ltv->len, ltv->type); + subGroup->meta = new0(struct iovec, 1); + subGroup->meta->iov_len = metaLen; + subGroup->meta->iov_base = iov.iov_base; - caps = util_iov_pull_mem(&iov, ltv->len - 1); - if (!caps) { - util_debug(func, NULL, "Unable to parse %s", - "CC"); + hexstream = util_iov_pull_mem(&iov, metaLen); + if (!hexstream) { + free(subGroup->meta); + free(subGroup->caps); + free(subGroup); return false; } - util_hexdump(' ', caps, ltv->len - 1, func, NULL); + util_hexdump(' ', hexstream, metaLen, func, NULL); + + for (int bis_sg = 0; bis_sg < subGroup->numBises; bis_sg++) { + struct bt_bap_bis *bis; + uint8_t capsLen; + uint8_t crtBis; + + if (!util_iov_pull_u8(&iov, &crtBis)) { + free(subGroup->meta); + free(subGroup->caps); + free(subGroup); + return false; + } + util_debug(func, NULL, "BIS #%d", crtBis); - capsLen -= (ltv->len + 1); - } + bis = new0(struct bt_bap_bis, 1); + bis->bisIndex = crtBis; - if (!util_iov_pull_u8(&iov, &metaLen)) - return false; - util_debug(func, NULL, "Metadata Len %d", metaLen); + if (!util_iov_pull_u8(&iov, &capsLen)) { + free(subGroup->meta); + free(subGroup->caps); + free(subGroup); + free(bis); + return false; + } + util_debug(func, NULL, "CC Len %d", capsLen); - if (!metaLen) - return false; - if (meta) { - if (!(*meta)) - *meta = new0(struct iovec, 1); - (*meta)->iov_len = metaLen; - (*meta)->iov_base = iov.iov_base; - } + bis->caps = new0(struct iovec, 1); + bis->caps->iov_len = capsLen; + util_iov_memcpy(bis->caps, iov.iov_base, capsLen); + DBG("bis caps len %ld", bis->caps->iov_len); - hexstream = util_iov_pull_mem(&iov, metaLen); - if (!hexstream) - return false; - util_hexdump(' ', hexstream, metaLen, func, NULL); + for (int i = 0; capsLen > 1; i++) { + struct bt_ltv *ltv = util_iov_pull_mem(&iov, + sizeof(*ltv)); + uint8_t *caps; + + if (!ltv) { + util_debug(func, NULL, "Unable to parse %s", + "Capabilities"); + free(subGroup->meta); + free(subGroup->caps); + free(subGroup); + free(bis->caps); + free(bis); + return false; + } + + util_debug(func, NULL, "%s #%u: len %u type %u", + "CC", i, ltv->len, ltv->type); + + caps = util_iov_pull_mem(&iov, ltv->len - 1); + if (!caps) { + util_debug(func, NULL, + "Unable to parse %s", "CC"); + free(subGroup->meta); + free(subGroup->caps); + free(subGroup); + free(bis->caps); + free(bis); + return false; + } + util_hexdump(' ', caps, ltv->len - 1, func, + NULL); + capsLen -= (ltv->len + 1); + } + + queue_push_tail(subGroup->bises, bis); + } + + queue_push_tail(base->subgroups, subGroup); + } return true; + } static int parse_io_qos(const char *key, int var, DBusMessageIter *iter, @@ -556,6 +672,16 @@ static int parse_bcast_qos(const char *key, int var, DBusMessageIter *iter, return -EINVAL; dbus_message_iter_get_basic(iter, &qos->bcast.encryption); + } else if (!strcasecmp(key, "BIG")) { + if (var != DBUS_TYPE_BYTE) + return -EINVAL; + + dbus_message_iter_get_basic(iter, &qos->bcast.big); + } else if (!strcasecmp(key, "BIS")) { + if (var != DBUS_TYPE_BYTE) + return -EINVAL; + + dbus_message_iter_get_basic(iter, &qos->bcast.bis); } else if (!strcasecmp(key, "Options")) { if (var != DBUS_TYPE_BYTE) return -EINVAL; @@ -653,10 +779,12 @@ static int parse_qos(DBusMessageIter *iter, struct bt_bap_qos *qos, static int parse_configuration(DBusMessageIter *props, struct iovec **caps, struct iovec **metadata, struct iovec **base, - struct bt_bap_qos *qos) + struct bt_bap_qos *qos, + struct bt_bap_base *base_s) { const char *key; struct iovec iov; + base_s->subgroups = NULL; memset(&iov, 0, sizeof(iov)); @@ -702,14 +830,10 @@ static int parse_configuration(DBusMessageIter *props, struct iovec **caps, } if (*base) { - uint32_t presDelay; - uint8_t numSubgroups, numBis; - struct bt_bap_codec codec; - util_iov_memcpy(*base, (*caps)->iov_base, (*caps)->iov_len); - parse_base((*caps)->iov_base, (*caps)->iov_len, bap_debug, - &presDelay, &numSubgroups, &numBis, &codec, - caps, NULL); + base_s->subgroups = queue_new(); + parse_base(NULL, (*caps)->iov_base, (*caps)->iov_len, + bap_debug, base_s); } return 0; @@ -796,12 +920,40 @@ static void bap_io_close(struct bap_ep *ep) ep->cig_active = false; } +static bool match_bis_by_id(const void *data, const void *user_data) +{ + int32_t bis_id = PTR_TO_INT(user_data); + const struct bt_bap_bis *bis = data; + + return bis->bisIndex == bis_id; +} + +static int get_number_bcast_source_ep(struct bap_ep *ep) +{ + const struct queue_entry *entry; + struct bap_ep *current_ep; + int nr_ep = 0; + + for (entry = queue_get_entries(ep->data->bcast); entry; + entry = entry->next) { + current_ep = entry->data; + if (bt_bap_pac_get_type(current_ep->lpac) == + BT_BAP_BCAST_SOURCE) + nr_ep++; + } + + return nr_ep; +} + static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, void *data) { struct bap_ep *ep = data; const char *path; DBusMessageIter args, props; + struct bt_bap_base parse_bap_base; + struct bt_bap_bis *curent_bis; + struct bt_bap_base_subgroup *subgroup; if (ep->msg) return btd_error_busy(msg); @@ -832,11 +984,46 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, } if (parse_configuration(&props, &ep->caps, &ep->metadata, - &ep->base, &ep->qos) < 0) { + &ep->base, &ep->qos, &parse_bap_base) < 0) { DBG("Unable to parse configuration"); return btd_error_invalid_args(msg); } + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) { + unsigned int nr_ep = 1; + + subgroup = queue_peek_head(parse_bap_base.subgroups); + curent_bis = queue_find(subgroup->bises, match_bis_by_id, + INT_TO_PTR(ep->qos.bcast.bis)); + if (curent_bis == NULL) { + DBG("Unable to find BIS"); + return btd_error_invalid_args(msg); + } + util_iov_free(ep->caps, 1); + ep->caps = new0(struct iovec, 1); + bt_bap_ltv_merge(ep->caps, subgroup->caps, false); + bt_bap_ltv_merge(ep->caps, curent_bis->caps, false); + + nr_ep = get_number_bcast_source_ep(ep); + if (nr_ep < queue_length(subgroup->bises)) { + for (uint8_t i = 0; + i < queue_length(subgroup->bises)-1; i++) + bt_bap_add_vendor_pac_from_pac(ep->lpac); + } + } else if ((bt_bap_pac_get_type(ep->rpac) == BT_BAP_BCAST_SOURCE) && + (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK)) { + util_iov_free(ep->caps, 1); + ep->caps = new0(struct iovec, 1); + bt_bap_ltv_merge(ep->caps, bt_bap_pac_get_data(ep->rpac), + false); + } + /* + * Kernel uses bis id as advertising handler. To open all BISes from + * a big on the same advertisng handler set the bis + * to BT_ISO_QOS_BIS_UNSET + */ + ep->qos.bcast.bis = BT_ISO_QOS_BIS_UNSET; + /* TODO: Check if stream capabilities match add support for Latency * and PHY. */ @@ -848,7 +1035,7 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, config_cb, ep); if (!ep->id) { DBG("Unable to config stream"); - free(ep->caps); + util_iov_free(ep->caps, 1); ep->caps = NULL; return btd_error_invalid_args(msg); } @@ -916,11 +1103,6 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) char address[18]; struct bap_ep *ep; 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, @@ -945,15 +1127,6 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) update_bcast_qos(&qos, &ep->qos); - base_io = new0(struct iovec, 1); - util_iov_memcpy(base_io, base.base, base.base_len); - - parse_base(base_io->iov_base, base_io->iov_len, bap_debug, - &presDelay, &numSubgroups, &numBis, - &codec, &ep->caps, &ep->metadata); - - /* Update pac with BASE information */ - bt_bap_update_bcast_source(ep->rpac, &codec, ep->caps, ep->metadata); ep->id = bt_bap_stream_config(ep->stream, &ep->qos, ep->caps, NULL, NULL); data->listen_io = io; @@ -968,25 +1141,40 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) return; } - return; drop: g_io_channel_shutdown(io, TRUE, NULL); - } static void iso_pa_sync_confirm_cb(GIOChannel *io, void *user_data) { GError *err = NULL; + struct bt_iso_base base; + char address[18]; + struct bt_bap_base *base_s; + struct bap_data *data = user_data; + 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); + 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); - g_io_channel_shutdown(io, TRUE, NULL); + return; } + g_io_channel_ref(io); + data->listen_io = io; + btd_service_connecting_complete(data->service, 0); + + base_s = new0(struct bt_bap_base, 1); + base_s->subgroups = queue_new(); + parse_base(data->bap, base.base, base.base_len, bap_debug, base_s); + bt_bap_update_bcast_source(NULL, base_s); } static bool match_data_bap_data(const void *data, const void *match_data) @@ -1082,6 +1270,7 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, case BT_BAP_BCAST_SINK: err = asprintf(&ep->path, "%s/pac_%s%d", device_get_path(device), suffix, i); + ep->io = data->listen_io; ep->base = new0(struct iovec, 1); break; } @@ -1582,9 +1771,12 @@ static gboolean bap_io_disconnected(GIOChannel *io, GIOCondition cond, bap_io_close(ep); - /* Check if connecting recreate IO */ - if (!is_cig_busy(ep->data, ep->qos.ucast.cig_id)) - recreate_cig(ep); + if (bt_bap_stream_get_type(ep->stream) == + BT_BAP_STREAM_TYPE_UCAST) { + /* Check if connecting recreate IO */ + if (!is_cig_busy(ep->data, ep->qos.ucast.cig_id)) + recreate_cig(ep); + } return FALSE; } @@ -1675,7 +1867,7 @@ static void bap_connect_io(struct bap_data *data, struct bap_ep *ep, static void bap_connect_io_broadcast(struct bap_data *data, struct bap_ep *ep, struct bt_bap_stream *stream, - struct bt_iso_qos *qos) + struct bt_iso_qos *qos, int defer) { struct btd_adapter *adapter = data->user_data; GIOChannel *io = NULL; @@ -1711,7 +1903,7 @@ static void bap_connect_io_broadcast(struct bap_data *data, struct bap_ep *ep, BT_IO_OPT_MODE, BT_IO_MODE_ISO, BT_IO_OPT_QOS, qos, BT_IO_OPT_BASE, &base, - BT_IO_OPT_DEFER_TIMEOUT, false, + BT_IO_OPT_DEFER_TIMEOUT, defer, BT_IO_OPT_INVALID); if (!io) { @@ -1763,42 +1955,28 @@ static void bap_listen_io(struct bap_data *data, struct bt_bap_stream *stream, static void bap_listen_io_broadcast(struct bap_data *data, struct bap_ep *ep, struct bt_bap_stream *stream, struct bt_iso_qos *qos) { - GIOChannel *io; GError *err = NULL; struct sockaddr_iso_bc iso_bc_addr; 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; + iso_bc_addr.bc_bis[0] = strtol(bt_bap_pac_get_name(ep->rpac), NULL, 10); DBG("stream %p", stream); - /* If IO already set skip creating it again */ - if (bt_bap_stream_get_io(stream) || data->listen_io) - return; - - io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, ep->data, NULL, &err, - BT_IO_OPT_SOURCE_BDADDR, - btd_adapter_get_address(ep->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); + if (!bt_io_bcast_accept(ep->data->listen_io, iso_bcast_confirm_cb, + data, 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); + g_io_channel_shutdown(ep->data->listen_io, TRUE, NULL); } - ep->io = io; - ep->data->listen_io = io; - } + static void bap_create_ucast_io(struct bap_data *data, struct bap_ep *ep, struct bt_bap_stream *stream, int defer) { @@ -1833,9 +2011,6 @@ static void bap_create_bcast_io(struct bap_data *data, struct bap_ep *ep, memset(&iso_qos, 0, sizeof(iso_qos)); - if (!defer) - goto done; - iso_qos.bcast.big = ep->qos.bcast.big; iso_qos.bcast.bis = ep->qos.bcast.bis; iso_qos.bcast.sync_factor = ep->qos.bcast.sync_factor; @@ -1852,9 +2027,9 @@ static void bap_create_bcast_io(struct bap_data *data, struct bap_ep *ep, iso_qos.bcast.timeout = ep->qos.bcast.timeout; memcpy(&iso_qos.bcast.out, &ep->qos.bcast.io_qos, sizeof(struct bt_iso_io_qos)); -done: + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) - bap_connect_io_broadcast(data, ep, stream, &iso_qos); + bap_connect_io_broadcast(data, ep, stream, &iso_qos, defer); else bap_listen_io_broadcast(data, ep, stream, &iso_qos); } @@ -1879,6 +2054,31 @@ static void bap_create_io(struct bap_data *data, struct bap_ep *ep, break; } } +/* + * Function test_linked_streams_state will check if all linked streams + * have the test state. + * If all streams are in test_state returns true; Else returns false + */ +static bool test_linked_streams_state(struct bt_bap_stream *stream, + uint8_t test_state) +{ + const struct queue_entry *entry; + struct bt_bap_stream *linked_stream; + struct queue *links; + + links = bt_bap_stream_io_get_links(stream); + + if (!links) + return true; + + for (entry = queue_get_entries(links); entry; entry = entry->next) { + linked_stream = entry->data; + if (bt_bap_stream_get_state(linked_stream) != test_state) + return false; + } + + return true; +} static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, uint8_t new_state, void *user_data) @@ -1906,15 +2106,26 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, break; case BT_BAP_STREAM_STATE_CONFIG: if (ep && !ep->id) { - bap_create_io(data, ep, stream, true); - if (!ep->io) { - error("Unable to create io"); - bt_bap_stream_release(stream, NULL, NULL); - return; - } - if (bt_bap_stream_get_type(stream) == + BT_BAP_STREAM_TYPE_BCAST) { + bool defer = !test_linked_streams_state(stream, + BT_BAP_STREAM_STATE_CONFIG); + bap_create_io(data, ep, stream, defer); + if (!ep->io) { + error("Unable to create io"); + bt_bap_stream_release(stream, + NULL, NULL); + return; + } + } else if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_UCAST) { + bap_create_io(data, ep, stream, true); + if (!ep->io) { + error("Unable to create io"); + bt_bap_stream_release(stream, + NULL, NULL); + return; + } /* Wait QoS response to respond */ ep->id = bt_bap_stream_qos(stream, &ep->qos, qos_cb, ep); @@ -2222,6 +2433,12 @@ static int bap_bcast_probe(struct btd_service *service) struct btd_gatt_database *database = btd_adapter_get_database(adapter); struct bap_data *data = btd_service_get_user_data(service); char addr[18]; + GIOChannel *io; + GError *err = NULL; + struct sockaddr_iso_bc iso_bc_addr; + + iso_bc_addr.bc_bis[0] = 1; + iso_bc_addr.bc_num_bis = 1; ba2str(device_get_address(device), addr); @@ -2260,7 +2477,24 @@ 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 source"); + io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, data, 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, &default_qos, + 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); + } + return 0; } diff --git a/src/shared/bap.c b/src/shared/bap.c index d8a3adde6..8ba0320d6 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -254,6 +254,8 @@ static struct queue *bap_db; static struct queue *bap_cbs; static struct queue *sessions; +static bool bt_bap_new_bcast_sink(struct bt_bap *bap); + static bool bap_db_match(const void *data, const void *match_data) { const struct bt_bap_db *bdb = data; @@ -1111,7 +1113,8 @@ static struct bt_bap_stream_io *stream_get_io(struct bt_bap_stream *stream) return stream->io; io = NULL; - queue_foreach(stream->links, stream_find_io, &io); + if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_UCAST) + queue_foreach(stream->links, stream_find_io, &io); return io; } @@ -1323,6 +1326,12 @@ static void stream_set_state_broadcast(struct bt_bap_stream *stream, bt_bap_ref(bap); + switch (stream->ep->state) { + case BT_ASCS_ASE_STATE_QOS: + bap_stream_update_io_links(stream); + break; + } + for (entry = queue_get_entries(bap->state_cbs); entry; entry = entry->next) { struct bt_bap_state *state = entry->data; @@ -2357,33 +2366,18 @@ static struct bt_bap_pac *bap_pac_find(struct bt_bap_db *bdb, uint8_t type, return NULL; } -static void *ltv_merge(struct iovec *data, struct iovec *cont) -{ - uint8_t delimiter = 0; - - if (!data) - return NULL; - - if (!cont || !cont->iov_len || !cont->iov_base) - return data->iov_base; - - iov_append(data, sizeof(delimiter), &delimiter); - - return iov_append(data, cont->iov_len, cont->iov_base); -} - static void bap_pac_merge(struct bt_bap_pac *pac, struct iovec *data, struct iovec *metadata) { /* Merge data into existing record */ if (pac->data) - ltv_merge(pac->data, data); + bt_bap_ltv_merge(pac->data, data, true); else pac->data = util_iov_dup(data, 1); /* Merge metadata into existing record */ if (pac->metadata) - ltv_merge(pac->metadata, metadata); + bt_bap_ltv_merge(pac->metadata, metadata, true); else pac->metadata = util_iov_dup(metadata, 1); } @@ -2614,6 +2608,20 @@ static void notify_session_pac_added(void *data, void *user_data) queue_foreach(bap->pac_cbs, notify_pac_added, user_data); } +struct bt_bap_pac *bt_bap_add_vendor_pac_from_pac(struct bt_bap_pac *pac) +{ + struct bt_bap_pac *new_pac; + + new_pac = bt_bap_add_vendor_pac(pac->bdb->db, pac->name, pac->type, + pac->codec.id, + pac->codec.cid, + pac->codec.cid, + &pac->qos, pac->data, + pac->metadata); + bt_bap_pac_set_ops(new_pac, pac->ops, pac->user_data); + return new_pac; +} + struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, const char *name, uint8_t type, uint8_t id, uint16_t cid, uint16_t vid, @@ -2671,7 +2679,7 @@ struct bt_bap_pac *bt_bap_add_pac(struct gatt_db *db, const char *name, struct iovec *metadata) { return bt_bap_add_vendor_pac(db, name, type, id, 0x0000, 0x0000, qos, - data, metadata); + data, metadata); } uint8_t bt_bap_pac_get_type(struct bt_bap_pac *pac) @@ -2701,6 +2709,14 @@ uint32_t bt_bap_pac_get_locations(struct bt_bap_pac *pac) } } +struct iovec *bt_bap_pac_get_data(struct bt_bap_pac *pac) +{ + if (!pac) + return 0x00; + + return pac->data; +} + uint16_t bt_bap_pac_get_supported_context(struct bt_bap_pac *pac) { struct bt_pacs *pacs; @@ -2783,12 +2799,26 @@ static void notify_session_pac_removed(void *data, void *user_data) bool bt_bap_pac_set_ops(struct bt_bap_pac *pac, struct bt_bap_pac_ops *ops, void *user_data) { + const struct queue_entry *entry = NULL; + struct bt_bap_pac *pac_entry; + if (!pac) return false; pac->ops = ops; pac->user_data = user_data; + if (pac->type == BT_BAP_BCAST_SOURCE) { + for (entry = queue_get_entries(pac->bdb->broadcast_sources); + entry != NULL; entry = entry->next) { + pac_entry = entry->data; + if (pac_entry != pac) { + pac_entry->ops = ops; + pac_entry->user_data = user_data; + } + } + } + return true; } @@ -2807,8 +2837,13 @@ static void remove_streams(void *data, void *user_data) struct bt_bap_stream *stream; stream = queue_remove_if(bap->streams, match_stream_lpac, pac); - if (stream) + if (stream) { + /* Mark stream->lpac to NULL, + * as it will be freed in bt_bap_remove_pac + */ + stream->lpac = NULL; bt_bap_stream_release(stream, NULL, NULL); + } } static void bap_pac_sink_removed(void *data, void *user_data) @@ -4471,6 +4506,11 @@ bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac) return false; } +char *bt_bap_pac_get_name(struct bt_bap_pac *pac) +{ + return pac->name; +} + static bool find_ep_unused(const void *data, const void *user_data) { const struct bt_bap_endpoint *ep = data; @@ -4682,7 +4722,7 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, return NULL; bt_bap_foreach_pac(bap, type, match_pac, &match); - if (!match.lpac) + if ((!match.lpac) || (!lpac)) return NULL; if (!match.rpac && (lpac->type != BT_BAP_BCAST_SOURCE)) return NULL; @@ -4699,7 +4739,15 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, if (!ep) { /* Check for unused ASE */ ep = queue_find(bap->remote_eps, find_ep_unused, &match); - if (!ep) { + if (!ep && lpac->type == BT_BAP_BCAST_SOURCE) { + bt_bap_new_bcast_sink(bap); + ep = queue_find(bap->remote_eps, find_ep_unused, + &match); + if (!ep) { + DBG(bap, "Unable to find unused ASE"); + return NULL; + } + } else if (!ep) { DBG(bap, "Unable to find unused ASE"); return NULL; } @@ -4839,7 +4887,16 @@ static void bap_stream_enable_link(void *data, void *user_data) struct bt_bap_stream *stream = data; struct iovec *metadata = user_data; - bap_stream_metadata(stream, BT_ASCS_ENABLE, metadata, NULL, NULL); + switch (bt_bap_stream_get_type(stream)) { + case BT_BAP_STREAM_TYPE_UCAST: + bap_stream_metadata(stream, BT_ASCS_ENABLE, metadata, + NULL, NULL); + break; + case BT_BAP_STREAM_TYPE_BCAST: + stream_set_state_broadcast(stream, + BT_BAP_STREAM_STATE_CONFIG); + break; + } } unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream, @@ -4866,13 +4923,14 @@ unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream, queue_foreach(stream->links, bap_stream_enable_link, metadata); break; case BT_BAP_STREAM_TYPE_BCAST: - if (!bt_bap_stream_io_dir(stream)) + if (!bt_bap_stream_io_dir(stream)) { stream_set_state_broadcast(stream, - BT_BAP_STREAM_STATE_CONFIG); - else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) + BT_BAP_STREAM_STATE_CONFIG); + queue_foreach(stream->links, bap_stream_enable_link, + NULL); + } else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) stream_set_state_broadcast(stream, BT_BAP_STREAM_STATE_STREAMING); - return 1; } @@ -4933,17 +4991,27 @@ static void bap_stream_disable_link(void *data, void *user_data) struct iovec iov; struct bt_ascs_disable disable; - memset(&disable, 0, sizeof(disable)); + switch (bt_bap_stream_get_type(stream)) { + case BT_BAP_STREAM_TYPE_UCAST: + memset(&disable, 0, sizeof(disable)); - disable.ase = stream->ep->id; + disable.ase = stream->ep->id; - iov.iov_base = &disable; - iov.iov_len = sizeof(disable); + iov.iov_base = &disable; + iov.iov_len = sizeof(disable); - req = bap_req_new(stream, BT_ASCS_DISABLE, &iov, 1, NULL, NULL); + req = bap_req_new(stream, BT_ASCS_DISABLE, &iov, + 1, NULL, NULL); - if (!bap_queue_req(stream->bap, req)) - bap_req_free(req); + if (!bap_queue_req(stream->bap, req)) + bap_req_free(req); + break; + + case BT_BAP_STREAM_TYPE_BCAST: + stream_set_state_broadcast(stream, + BT_BAP_STREAM_STATE_RELEASING); + break; + } } unsigned int bt_bap_stream_disable(struct bt_bap_stream *stream, @@ -5189,7 +5257,8 @@ bool bt_bap_stream_set_io(struct bt_bap_stream *stream, int fd) bap_stream_set_io(stream, INT_TO_PTR(fd)); - queue_foreach(stream->links, bap_stream_set_io, INT_TO_PTR(fd)); + if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_UCAST) + queue_foreach(stream->links, bap_stream_set_io, INT_TO_PTR(fd)); return true; } @@ -5210,6 +5279,23 @@ static bool match_name(const void *data, const void *match_data) return (!strcmp(pac->name, name)); } +void *bt_bap_ltv_merge(struct iovec *data, struct iovec *cont, + bool add_delimiter) +{ + uint8_t delimiter = 0; + + if (!data) + return NULL; + + if (!cont || !cont->iov_len || !cont->iov_base) + return data->iov_base; + + if (add_delimiter) + iov_append(data, sizeof(delimiter), &delimiter); + + return iov_append(data, cont->iov_len, cont->iov_base); +} + int bt_bap_stream_cancel(struct bt_bap_stream *stream, unsigned int id) { struct bt_bap_req *req; @@ -5245,10 +5331,15 @@ int bt_bap_stream_io_link(struct bt_bap_stream *stream, if (queue_find(stream->links, NULL, link)) return -EALREADY; - if (stream->client != link->client || + if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) { + if (stream->qos.bcast.big != link->qos.bcast.big) + return -EINVAL; + } else { + if (stream->client != link->client || stream->qos.ucast.cig_id != link->qos.ucast.cig_id || stream->qos.ucast.cis_id != link->qos.ucast.cis_id) - return -EINVAL; + return -EINVAL; + } if (!stream->links) stream->links = queue_new(); @@ -5377,7 +5468,9 @@ int bt_bap_stream_io_connecting(struct bt_bap_stream *stream, int fd) bap_stream_io_connecting(stream, INT_TO_PTR(fd)); - queue_foreach(stream->links, bap_stream_io_connecting, INT_TO_PTR(fd)); + if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_UCAST) + queue_foreach(stream->links, bap_stream_io_connecting, + INT_TO_PTR(fd)); return 0; } @@ -5433,11 +5526,58 @@ bool bt_bap_new_bcast_source(struct bt_bap *bap, const char *name) return true; } +static bool bt_bap_new_bcast_sink(struct bt_bap *bap) +{ + struct bt_bap_endpoint *ep; + + /* Push remote endpoint with direction source */ + ep = bap_endpoint_new_broadcast(bap->ldb, BT_BAP_BCAST_SOURCE); + + if (ep) + queue_push_tail(bap->remote_eps, ep); + + ep->bap = bap; + return true; +} + +static void bis_to_pac(void *data, void *user_data) +{ + struct bt_bap_bis *bis = data; + struct bt_bap_base_subgroup *subgroup = user_data; + struct bt_bap_pac *pac_source_bis; + struct bt_bap_endpoint *ep; + int err = 0; + + bt_bap_ltv_merge(bis->caps, subgroup->caps, false); + pac_source_bis = bap_pac_new(subgroup->bap->rdb, NULL, + BT_BAP_BCAST_SOURCE, &subgroup->codec, NULL, + bis->caps, subgroup->meta); + + err = asprintf(&pac_source_bis->name, "%d", bis->bisIndex); + + if (err < 0) + DBG(subgroup->bap, "error in asprintf"); + + /* Add remote source endpoint */ + if (!subgroup->bap->rdb->broadcast_sources) + subgroup->bap->rdb->broadcast_sources = queue_new(); + queue_push_tail(subgroup->bap->rdb->broadcast_sources, pac_source_bis); + + queue_foreach(subgroup->bap->pac_cbs, notify_pac_added, pac_source_bis); + /* Push remote endpoint with direction sink */ + ep = bap_endpoint_new_broadcast(subgroup->bap->rdb, BT_BAP_BCAST_SINK); + + if (ep) + queue_push_tail(subgroup->bap->remote_eps, ep); +} +static void parse_bis(void *data, void *user_data) +{ + struct bt_bap_base_subgroup *subgroup = data; + + queue_foreach(subgroup->bises, bis_to_pac, subgroup); +} void bt_bap_update_bcast_source(struct bt_bap_pac *pac, - struct bt_bap_codec *codec, - struct iovec *data, - struct iovec *metadata) + struct bt_bap_base *base) { - bap_pac_merge(pac, data, metadata); - pac->codec = *codec; + queue_foreach(base->subgroups, parse_bis, NULL); } diff --git a/src/shared/bap.h b/src/shared/bap.h index 2c8f9208e..ea49b13a4 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -97,6 +97,27 @@ struct bt_bap_qos { }; }; +struct bt_bap_base { + uint32_t presDelay; + uint8_t numSubgroups; + struct queue *subgroups; +}; + +struct bt_bap_base_subgroup { + uint8_t subGroupIndex; + struct bt_bap *bap; + uint8_t numBises; + struct bt_bap_codec codec; + struct iovec *caps; + struct iovec *meta; + struct queue *bises; +}; + +struct bt_bap_bis { + uint8_t bisIndex; + struct iovec *caps; +}; + typedef void (*bt_bap_ready_func_t)(struct bt_bap *bap, void *user_data); typedef void (*bt_bap_destroy_func_t)(void *user_data); typedef void (*bt_bap_debug_func_t)(const char *str, void *user_data); @@ -168,6 +189,8 @@ uint8_t bt_bap_pac_get_type(struct bt_bap_pac *pac); uint32_t bt_bap_pac_get_locations(struct bt_bap_pac *pac); +struct iovec *bt_bap_pac_get_data(struct bt_bap_pac *pac); + uint16_t bt_bap_pac_get_supported_context(struct bt_bap_pac *pac); uint16_t bt_bap_pac_get_context(struct bt_bap_pac *pac); @@ -176,6 +199,8 @@ struct bt_bap_pac_qos *bt_bap_pac_get_qos(struct bt_bap_pac *pac); uint8_t bt_bap_stream_get_type(struct bt_bap_stream *stream); +struct bt_bap_pac *bt_bap_add_vendor_pac_from_pac(struct bt_bap_pac *pac); + struct bt_bap_stream *bt_bap_pac_get_stream(struct bt_bap_pac *pac); /* Session related function */ @@ -231,6 +256,7 @@ int bt_bap_pac_get_codec(struct bt_bap_pac *pac, uint8_t *id, void bt_bap_pac_set_user_data(struct bt_bap_pac *pac, void *user_data); void *bt_bap_pac_get_user_data(struct bt_bap_pac *pac); +char *bt_bap_pac_get_name(struct bt_bap_pac *pac); /* Stream related functions */ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, @@ -314,9 +340,9 @@ bool bt_bap_stream_io_is_connecting(struct bt_bap_stream *stream, int *fd); bool bt_bap_new_bcast_source(struct bt_bap *bap, const char *name); void bt_bap_update_bcast_source(struct bt_bap_pac *pac, - struct bt_bap_codec *codec, - struct iovec *data, - struct iovec *metadata); + struct bt_bap_base *base); +void *bt_bap_ltv_merge(struct iovec *data, struct iovec *cont, + bool add_delimiter); bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac); diff --git a/unit/test-bap.c b/unit/test-bap.c index adade07db..d308d42f9 100644 --- a/unit/test-bap.c +++ b/unit/test-bap.c @@ -377,11 +377,13 @@ static void test_client_config(struct test_data *data) "test-bap-snk", BT_BAP_SINK, 0x0ff, 0x0001, 0x0001, - NULL, data->caps, NULL); + NULL, data->caps, + NULL); else data->snk = bt_bap_add_pac(data->db, "test-bap-snk", BT_BAP_SINK, LC3_ID, - NULL, data->caps, NULL); + NULL, data->caps, + NULL); g_assert(data->snk); } @@ -391,11 +393,13 @@ static void test_client_config(struct test_data *data) "test-bap-src", BT_BAP_SOURCE, 0x0ff, 0x0001, 0x0001, - NULL, data->caps, NULL); + NULL, data->caps, + NULL); else data->src = bt_bap_add_pac(data->db, "test-bap-src", BT_BAP_SOURCE, LC3_ID, - NULL, data->caps, NULL); + NULL, data->caps, + NULL); g_assert(data->src); } } From patchwork Tue Oct 31 15:55:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 13441683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C45AC4332F for ; Tue, 31 Oct 2023 15:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344827AbjJaP4D (ORCPT ); Tue, 31 Oct 2023 11:56:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344832AbjJaP4C (ORCPT ); Tue, 31 Oct 2023 11:56:02 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2068.outbound.protection.outlook.com [40.107.21.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A494FDA for ; Tue, 31 Oct 2023 08:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lkjaHDuEn9G6QLDuOUy8EZsS/dOjgeKk+MdGjyJZVM210STTeoQJfSlBjsbT2jpr8Sxt+icvvSvoH5Nw51/aqzBRSdy76pgP57ACHicIfdEYqu7WX5WYRXoT9TVAmYp8ntP7VlVyNRsWiPwKN6SU9QmQtxRwoOFKDcHMzErR6aNpRIU2/ahykiOzFQWt/eUAitwGTnm2ZM69OyxpTm/DCIu7r8G6fBb6/S5/xe1/Xt5SgH2UoWZcclkOX3w3n/D+vRl3gwRnZBdthuOEH+m0DdUn4Ul0xUOA5Rj/J18BCiiVPGw7Yo2UXu2AqKyDyoRa/2ZiXcDL9AbhH9brXlb6Bg== 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=K/MoR3CeKgusR4AD2j8Im/7Sgya094xGwNBknJJYytk=; b=iM8w8NtueqLWbPiCpICz9PmZdx0DvF7BvpUPh/u8cHMk3zSHGn9ipAF5ebmb8L5llh2NdzWDRZ69U9fnXvdU5eBYvPyZ6waJAB7eoXEu22a23a/37Nnbhc4gt/SUOUyEjo7VjuphZ7bJw17/mYQZI98s6sAO8YyYPcRdDMuzk/QyvqTbIZaSkYrHFBkgvRAh+BDe7x/iviV+7UEzSmwfQXkVI3JdA/RkFwQ8Ov9I28nJ4aIw5NcEzbuFrqhfEOiNLI+rJDYWmKbUNpqv/q+/THL9FgsHAnqfLvKrjQTKedDkr3yYrsWr0bFssWkHu2BIhWI2tgKPhYjFoxNE0LLvvQ== 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=K/MoR3CeKgusR4AD2j8Im/7Sgya094xGwNBknJJYytk=; b=GvLuNyj88jp98KV/G1kyw8IlwWOod9oavh2bwOsu4cYFaPvc/Mk5sjjMR7bP//7iJRQ8+uUbizIt1hf73nY+v9c/WJeSdB9ljsWhQblfmHTc/L6TyWHVGcDEu8x0UAduqCSP0o0wBPjjSDEDgOoznyIi0HciNyYJTuVnF8wNUgM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) by VE1PR04MB7440.eurprd04.prod.outlook.com (2603:10a6:800:1b2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.17; Tue, 31 Oct 2023 15:55:54 +0000 Received: from DBBPR04MB6331.eurprd04.prod.outlook.com ([fe80::7c8a:c8da:e6a5:8a4a]) by DBBPR04MB6331.eurprd04.prod.outlook.com ([fe80::7c8a:c8da:e6a5:8a4a%7]) with mapi id 15.20.6933.009; Tue, 31 Oct 2023 15:55:54 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, iulia.tanasescu@nxp.com Subject: [PATCH v2 4/5] profiles/audio/transport.c: Add support multiple BIS Date: Tue, 31 Oct 2023 17:55:34 +0200 Message-Id: <20231031155535.228994-5-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231031155535.228994-1-silviu.barbulescu@nxp.com> References: <20231031155535.228994-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VE1PR03CA0046.eurprd03.prod.outlook.com (2603:10a6:803:118::35) To DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR04MB6331:EE_|VE1PR04MB7440:EE_ X-MS-Office365-Filtering-Correlation-Id: 429f8c25-27ae-483c-8a9f-08dbda29dd14 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F9WgL+8ycw+8qOf4JMsd9Rj7mbYc/SxXIW4jJmjkCfE8Oa6KT6Drq0xx6z09qbufIoPyTphU/6lPaXJBcRa65aVwML44i/lX7IpXP6/HbraCygaR2Us/8d9kXn4kQ8+iaqgJUYtdK7pdEIuPW8RnmxHRW0z/3yLUSVgfR3e1qKbdU7L8CxNRqhftmFkNonMDJsNkc7apIhgGAemRwLZfBxiMyCr+DTrlQUasFlT5d6tLxq0lZKtd2bsJBjX0wFJB0YBS3VLUkDicPHoeRDd2Q9DFUEbahLK3P996aeoctU23HVdFqk2YVzhvET3ZEHPMkX6ODEOtBHL2M3QkEJ2DWlyVq7CYMu1MWUrsrAW8LDzowlhHbCIKXaYRtkSxbIIAO47YMHOMUQ2HxwnOBlc7oUB+8VdKAXeZytJJQa/SKO7W+8OAfNdAAOZyJqs0JuGPOFlb+BX4u+s+6WRi600X3S2I/XqaxSzraDCsN59gO03SQhR8n1KlYpBegUv+DUMBg4r5+BPYsimexhOMZfIjZRqzPS0YmwPKqSMM/nYC9p5h8e7j9fS6UzsWId2IiZ4LHeh7hX8BMmDKSyY5sL0wmoJ53gaNDcV2xJHM2l1xJ8P6PLqp7bshBrKRgTCMTKXS X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBBPR04MB6331.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(396003)(376002)(136003)(39860400002)(366004)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(8676002)(4326008)(8936002)(83380400001)(5660300002)(41300700001)(38100700002)(6486002)(478600001)(6506007)(36756003)(2906002)(6512007)(86362001)(6666004)(2013699003)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HdLewdWByl9hFmFsuJKuFh+zbYcWPttEmix9DoYIWaLzBzTpXi4dUJfQoyTr2gqOAn0cI7wFFe/4lqySkB1lEmR3xQf/S9FS+JFHhvwdwNUdh1V6xSJXQEntUoNaQDIWb9j40Oci/iW+RoCjHKBxPl85pPvgmsTLbabnmPOAJzQYjKBIwhryX2ZaGUeANhQEX7dPSgTqB6yPKBdNLmGi5eSoZHeRLUMw1UOBiGnYAMXoXvVoYhhW13xTNBXmFzmgrChWTJprgbXSG1X2cQf/EUgjYpOOYSPZcpf1ulgX/3E6fGg3otrkAGvrnao3IWQKwza3MluS9W5YuHFc+9XYA1FaY+5xkX7GWb43u4x6QFaSpgZfDZZnMsrTObeR7b/tg9HpppgeFMb1Hfmtifs1BOwzq4KNUSCF5TFJT/ChkG9WTgOuWHKkAv3o8RNO2fJkX6sNnhfx7WITt/93v2102TjsTEWjS/dINl+t5Onqg9zsVIJwK/FDG8B7SQP/ToJM2EzA2t6OTxpwauPkuhMHeV5cBMc3bAGlaXr/iUix2ipN+0msZRW5bOFpMAN92JNq+yj/no2K1TuuExsFxHIkPWE5vycz8yWbkK/qA8EXhbkn2fFVVbD6mIDD846P1ZVrj2OLQVuDDM2dSAkDJUWRvujVg/hKqIK58DyZu0EjxByNnoIu+LIJXqiiTKLQTpLip/YLA1DJ/ryNBEaEC+003kpNycM8eT8uxWw2YwYIlJ8nsdA3ST2GtO9x4YRks0QHyGdI8Ew7ufWEOVg3Mi8oAS+U9rBfn7OaBkT+mwTu/AQJTwtXcmURXvEJ5Exei3jP5rXxpFsWYz4Jz8t4kzhZDzuOLau7bSbUL5TmG/1qdjtOruLtokkmfxUQPDK0EzTjIIj1yDozsmHyqndzQaxuF4uzg6lzsZ3+pow+wMt4wzA3oEjORN4Lg3kKad4Rpz4GueUlHTyUkrUalKkrmKIQ6YtRFVZ4X5sZ4bJF1HCjJXxQAFyu0rSUkOqXrzPIAPsDHuGOjjkvtty8GUTOYjFWsfpxXLVvvwhsspbx05e9ZC7Y/VQzRJQ9rtY6XJREm3tl4o22eXVaOro0Z7bEY4TlWRZ+Y9dh9d2yL8+JnW5ATDI1rewptayMJAIX9dvdk0rY0cPGdAqKXiJPlyxbEGLVJ8NXJ04+c5RD3ii3g8efLBIXOrZmEYjiup4e5wxzzY76TyV60bjxSLA4a97lMhctZk1dv70t4bhOYicE6x4BHYQH1e3Iu3JbMHFaNbMn2hE2eIp9BVObdtdpGHj917YKEeDM9GsiP61ZTt92/ceGer0RHUd0fNK4EVdBXbBdW1v9xn+BsKP3lT3KneqeVj2I/Poyj5uqmklPrsXa/tMpYq7vZF8uuuzpfwix9L0yFzh+ZBkeY1OQk3+VkWtMN2ptoQECJmcHtjaReeV4EqbbGCAWts7xaayaY6zGvXCCF6Mxi1a334zn53AdWRRUly1JMiPfLGIOU5TJhEXzQg19aSF+9oi9Z1++UNQOtatK2elr6G/HjLo3yJzNpcFlIvI86iCqLH/Es1hSkM80YBov6seLkCN+SG5zRZPNP0fA1d/ILdqjsQgwHg7GpYAwONreCg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 429f8c25-27ae-483c-8a9f-08dbda29dd14 X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2023 15:55:54.2273 (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: RCKrQ6FEAATZsFtaPIx8crjlRZw6IeWa51eokz+7fCpqBIjiO6cM2X0L7cqTOPLRumaONCUua7LE3FQhDuBchfxWfp4BLgQ/mQMAzPT7GDg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7440 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add support for bcast multiple BISes --- profiles/audio/transport.c | 59 ++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 23ea267f6..eaafd8a35 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -163,7 +163,9 @@ find_transport_by_bap_stream(const struct bt_bap_stream *stream) struct bap_transport *bap; if (strcasecmp(uuid, PAC_SINK_UUID) && - strcasecmp(uuid, PAC_SOURCE_UUID)) + strcasecmp(uuid, PAC_SOURCE_UUID) && + strcasecmp(uuid, BCAA_SERVICE_UUID) && + strcasecmp(uuid, BAA_SERVICE_UUID)) continue; bap = transport->data; @@ -312,9 +314,11 @@ static void media_transport_remove_owner(struct media_transport *transport) media_request_reply(owner->pending, EIO); transport->owner = NULL; - if (bap->linked) - queue_foreach(bt_bap_stream_io_get_links(bap->stream), - linked_transport_remove_owner, owner); + if (bt_bap_stream_get_type(bap->stream) == + BT_BAP_STREAM_TYPE_UCAST) + if (bap->linked) + queue_foreach(bt_bap_stream_io_get_links(bap->stream), + linked_transport_remove_owner, owner); if (owner->watch) g_dbus_remove_watch(btd_get_dbus_connection(), owner->watch); @@ -496,9 +500,11 @@ static void media_transport_set_owner(struct media_transport *transport, DBG("Transport %s Owner %s", transport->path, owner->name); transport->owner = owner; - if (bap->linked) - queue_foreach(bt_bap_stream_io_get_links(bap->stream), - linked_transport_set_owner, owner); + if (bt_bap_stream_get_type(bap->stream) == + BT_BAP_STREAM_TYPE_UCAST) + if (bap->linked) + queue_foreach(bt_bap_stream_io_get_links(bap->stream), + linked_transport_set_owner, owner); owner->transport = transport; owner->watch = g_dbus_add_disconnect_watch(btd_get_dbus_connection(), @@ -641,6 +647,7 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg, const char *sender; struct media_request *req; guint id; + const char *uuid; sender = dbus_message_get_sender(msg); @@ -669,9 +676,12 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg, req = media_request_create(msg, id); media_owner_add(owner, req); - if (bt_bap_stream_get_type(bap->stream) == - BT_BAP_STREAM_TYPE_BCAST) { - bap_disable_complete(bap->stream, 0x00, 0x00, owner); + uuid = media_endpoint_get_uuid(transport->endpoint); + if (!strcasecmp(uuid, BCAA_SERVICE_UUID) || + !strcasecmp(uuid, BAA_SERVICE_UUID)) { + if (bt_bap_stream_get_type(bap->stream) == + BT_BAP_STREAM_TYPE_BCAST) + bap_disable_complete(bap->stream, 0x00, 0x00, owner); } return NULL; @@ -686,7 +696,11 @@ static gboolean get_device(const GDBusPropertyTable *property, if (transport->device) path = device_get_path(transport->device); else - path = adapter_get_path(transport->adapter); + /* + *Use remote endpoint path as fake device path + *for broadcast source transport + */ + path = transport->remote_endpoint; dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); @@ -1272,7 +1286,9 @@ static bool match_link_transport(const void *data, const void *user_data) if (!transport) return false; - bap_update_links(transport); + if (bt_bap_stream_get_type((struct bt_bap_stream *)stream) == + BT_BAP_STREAM_TYPE_UCAST) + bap_update_links(transport); return true; } @@ -1378,7 +1394,9 @@ static guint resume_bap(struct media_transport *transport, if (bap->resume_id) return 0; - bap_update_links(transport); + if (bt_bap_stream_get_type(bap->stream) == + BT_BAP_STREAM_TYPE_UCAST) + bap_update_links(transport); switch (bt_bap_stream_get_state(bap->stream)) { case BT_BAP_STREAM_STATE_ENABLING: @@ -1416,7 +1434,9 @@ static guint suspend_bap(struct media_transport *transport, else transport_set_state(transport, TRANSPORT_STATE_IDLE); - bap_update_links(transport); + if (bt_bap_stream_get_type(bap->stream) == + BT_BAP_STREAM_TYPE_UCAST) + bap_update_links(transport); return bt_bap_stream_disable(bap->stream, bap->linked, func, owner); } @@ -1491,9 +1511,10 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, /* If a request is pending wait it to complete */ if (owner && owner->pending) return; - bap_update_links(transport); - if (!media_endpoint_is_broadcast(transport->endpoint)) + if (!media_endpoint_is_broadcast(transport->endpoint)) { + bap_update_links(transport); bap_update_qos(transport); + } else if (bt_bap_stream_io_dir(stream) != BT_BAP_BCAST_SOURCE) bap_update_bcast_qos(transport); transport_update_playing(transport, FALSE); @@ -1510,7 +1531,7 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, bap_update_bcast_qos(transport); break; case BT_BAP_STREAM_STATE_RELEASING: - if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK) + if (!bt_bap_stream_io_dir(stream)) return; break; } @@ -1555,7 +1576,9 @@ static void bap_connecting(struct bt_bap_stream *stream, bool state, int fd, if (bap->stream != stream) return; - bap_update_links(transport); + if (bt_bap_stream_get_type(bap->stream) == + BT_BAP_STREAM_TYPE_UCAST) + bap_update_links(transport); } static void free_bap(void *data) From patchwork Tue Oct 31 15:55:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 13441684 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65A99C4167D for ; Tue, 31 Oct 2023 15:56:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344839AbjJaP4E (ORCPT ); Tue, 31 Oct 2023 11:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344856AbjJaP4D (ORCPT ); Tue, 31 Oct 2023 11:56:03 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2068.outbound.protection.outlook.com [40.107.21.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D06D7107 for ; Tue, 31 Oct 2023 08:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mkMoQN9K76opQ9M3+IssosrSj0Q6NcZKr6zqaMDH8GdSzn2uYw2tqncSUU/ZZ02RRWa/dXW9kq/5hX5Uuw4PAj+YSEAraGPRSiNasVVujLZKJczbOSexHdAd4IzKvU6wnYDvg7Xtmqh5GpPx1P/Q2G/OASUxAxUb/kQghjrXow0Yh6+HxAlvhbs0N8KeahGcIuvmh2AZgyryVBNFCRUP0hrYadDYWvk6SAEaPbIbLOHXENxICM6FgkdijNS+N0GhORFiKQEg2i6GPsQeLzpBmpyflZP2YlZkGz+/kSnRagFdRWi1QSRdmmLRLH88KO919aWhcD9KXtuGyDfovnKSLg== 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=uYp93LFk/IG/8TjGxqth6o2cTLM7cttKDKRWExlXMWs=; b=MJnF/FXt8T1XV5Uu0CajaKrvE5sNNSV0M3qu7S60ukhTADtLehNaY3KcDMhqpJef49DCHKaWmwV0IsfFNP5baA1hd9tthzcwaLbD2Jbej1yEIflEC7jIyJUlnGvongQznpQV0rveuUI5OiYMZCle9uF8gOqqe+uR/Fr6eMCThSH7N3+cgK0ic8KAGFb1sH1I4Orzt8894JN+8TPauWntANOOk4Kb5/emppoh64RiZR2PuwDL/5fEdxElkWxyph0mO83wpvoqcjYSuJ5O2j2snHUNNjxwtln3oQ1O9jmAgU+6mCjSA1R1ba8E4L5ziCQ/D+/otKwVI/Dg73+OITojcg== 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=uYp93LFk/IG/8TjGxqth6o2cTLM7cttKDKRWExlXMWs=; b=kKsewdE2+S+Ywc0eEwD3/PXLWmKKjlCdFazRvDKXFqBlpb4+xGTe+jruRR9ljET88S5n7QcD7JJrUsZa4rbcRZvVuoy8ZRdF+2FDaJ6JeceS/U14pB65C3iowfMJJI2WSGfcDcLfD1/txcnBaBUd/42xB9xYFllj9VmqZzrUcB0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) by VE1PR04MB7440.eurprd04.prod.outlook.com (2603:10a6:800:1b2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.17; Tue, 31 Oct 2023 15:55:56 +0000 Received: from DBBPR04MB6331.eurprd04.prod.outlook.com ([fe80::7c8a:c8da:e6a5:8a4a]) by DBBPR04MB6331.eurprd04.prod.outlook.com ([fe80::7c8a:c8da:e6a5:8a4a%7]) with mapi id 15.20.6933.009; Tue, 31 Oct 2023 15:55:56 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, iulia.tanasescu@nxp.com Subject: [PATCH v2 5/5] client/player.c: Add support for multiple BISes Date: Tue, 31 Oct 2023 17:55:35 +0200 Message-Id: <20231031155535.228994-6-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231031155535.228994-1-silviu.barbulescu@nxp.com> References: <20231031155535.228994-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VE1PR03CA0042.eurprd03.prod.outlook.com (2603:10a6:803:118::31) To DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR04MB6331:EE_|VE1PR04MB7440:EE_ X-MS-Office365-Filtering-Correlation-Id: a9ac98e5-bcf1-4e12-a116-08dbda29de8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R7CCV3Ic1D4WNUGb8GrmDIqWc0jzGOCjyAqvdQIWZ+z/mQyIN8D3W3DhOp65HAOPXoHQs8juPWqc9O/+38pm9fg56tU18n2BE9SKC8yIka6h0Ggui0PtqydRBUV3WKIZz0UWTfBtkj4BsPKDt6OnmKRO7d3nD4gbXo+A0BLyFttGe+JksEkqX+ujmyxxtIZyFqhx0/eSNXxOPjdUjN9Aca1dwFOjw+zERgISUUH/rwypJ0bTzNusVRdmDJ+S5kz2JFVP/69XvnGe9zL19x2u0D8ztGNmqLUlRdbSy4gvpUqVsZnM8K8qQGXP9xvqcGvqF790m6uMN26xu+XYTCyRxED2z8m0/NX8IQAq/ZXyltIxQIIwgSYZcliXe37cLJkAQ9iYICesdmbSMc/AC27mNac/kXQpX0/Ugdw9odBdQExTZ93HfYzKdleDl4mC0wxeoV8uezhaMB4wuqZqCK4Omp6dk2mb2oAbAU8CZoHmlOnr8xps2MIgHUSIfncYGq4VvBwqxSAvAyjTnRW+TyleCPScaLPMT0uaIKyXHsksMNweQ4jTfrzB8Kxhgc4jpzL3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBBPR04MB6331.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(396003)(376002)(136003)(39860400002)(366004)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(8676002)(4326008)(8936002)(83380400001)(5660300002)(41300700001)(38100700002)(6486002)(478600001)(6506007)(36756003)(2906002)(6512007)(86362001)(6666004)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /jsKX4WKsHCiXHo0XOYA4+5xef31WvJsQBFAnASpBO44UqV7dILHpggIiXPR4ZI+fIGSJQ+9ERTOkO4Hib7Ffbik1G/qagbPNlkHsz+8Wag7VYVUYVkbjLT5ZLliuevr8n+S1uOExI5L8h+GgF2fi7xWeRbdEvwjKyWpX3Gvs2s+j3aT+GVEXLWsqar9w6Rel2BT9qpMFacxNTThDW+vi6V3tgxOwBkr5esK7Hr0WsAXJr1TXE1rrBeaJ5yVRxz8nn3l/6xhM1s5axLWrC3dIZm4GYJxAdVxCbuaQltTOr3fQVs+76kZeHN6cjvFtEbF5A9MhuBuf5PQGQR5a62zKvVvGflAYpfl4OnxDSdU+X4E4PEuhNaUcLdYCU09kDwhWEadXa0kuZCCU7zKaC0vIouq3RQoJ3qKh/Al2YgWCjdUlCHutCCbruDsMgYtToWsRmqfu1jpG3LF9K/eYK8AIzZfHjC831QgDg9dPeMHCOUg9EPX6gb2XD6HZxDecR037D1x47wyThzz8BsZvtGmvFl53nO1PKPXLvYtsA60yzv7PWRrCwAt5wNVqDKvbJkyN7PElkuhG43XGBykiuFvprWrsFHbnr9ZA2w5PpSb2rAgTd5RcdUjs2UFhxzNbE0PnK0/rKu92i2NPKiWrhNPQE9qhKE3UhYkDK1v8YiyRClg+bT5veBYh6LQ7DtUoLfdm9D1TdJ6UTWmwVUHWdGBGRiBTW94eVTL4lysldC6cQfNd4CoCLvjY/BfDz8byOEZ3MxMaCx4tK/fN7pN+qd/bnKjwuH5bPNN1Ns3xEljc3agvM3PxIlZfKXXBfR9Pgu+vapCC68P9qUyANt3+nVGlRxY5r77CsBaAbOJqJPJmZch4UfdfcgItA46JgfL8CXwa3byrb8BmeBygckaFbP+gIEWg5l7icwsHaLxP9B+ynn3nuqI5sETnRP7zk7NfvkjnMPK9QtikIZ4GcXiPLc+xd6LPQZvHwME9ljGd3nKmx3C+MYtp4JkBPjtAhsE5HgR4/STQpg7Ju/dBg+39AtzPuKDM0nHZWJNpmDqRGr0oAaIYj8OJj/XVBCcuBLuqic9fQ30dPVR1qhQE6M+ufD6mm8n/KIzqWhuqwweWuNC1zoG1/qM/4P73avhDVNrOl3EWAbX1JbERDFUFqHPJ26wcpEWxeiOFMcSrb05BjAY1pLizU9SFGfCQfaFy6EMqZXuZq2YwOyH4pK4gAn6IkI/ARTxR2D2FQ3t0BsFOFswZrPJ8Cuc1Y8tBAm45iGFCVKV1z+jWFBlk2PWtDJIU2l/aI9F8k65BVG/KyCJFyh8B7YcUeLpZEWC2CZPcNwr9fIrjESpqboh9uH8RIokMFAqmMyhbhecvAcYKQFGkhjma9wrrC+8liU8qar+dKBQBSYTenz4Tz9ZUP1yRNo8PIcu1/AvK3koYpnpQadJBCbxk1zkEk4YtHHgH0EeeZmPmJAfJPqN6kLAVRjYmZyM4VwryRNep78SvOjXufZCaPtgRrSNV0sCic19OTVZmFtjQGGzbrU6U+fpfJRx2XIvoiG5glnxQFyTGXvSlj5bRdeUuf1xpGt9TnaOPE/97p4YuqpyPm34LMr5dkTk82JUPXUpTw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9ac98e5-bcf1-4e12-a116-08dbda29de8f X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2023 15:55:56.7214 (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: B/OWBZxma7O1P9WpmHeo4oEz7eoCpVqkgAv18rdgoXhGI5k3ga1BCRLZsO+8Ce7os6gujepbsih0Xboge6BddIj2ubWXFdQVVGfFTpVtwQo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7440 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add support for bcast multiple BISes --- client/player.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/client/player.c b/client/player.c index 715598aa9..7c517f80a 100644 --- a/client/player.c +++ b/client/player.c @@ -2999,7 +2999,45 @@ static void endpoint_config(const char *input, void *user_data) endpoint_set_config(cfg); } +static void config_endpoint_iso_stream(const char *input, void *user_data) +{ + struct endpoint_config *cfg = user_data; + char *endptr = NULL; + int value; + + value = strtol(input, &endptr, 0); + + if (!endptr || *endptr != '\0' || value > UINT8_MAX) { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + bcast_qos.bcast.bis = value; + + endpoint_set_config(cfg); +} + +static void config_endpoint_iso_group(const char *input, void *user_data) +{ + struct endpoint_config *cfg = user_data; + char *endptr = NULL; + int value; + + value = strtol(input, &endptr, 0); + + if (!endptr || *endptr != '\0' || value > UINT8_MAX) { + bt_shell_printf("Invalid argument: %s\n", input); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + bcast_qos.bcast.big = value; + + bt_shell_prompt_input(cfg->ep->path, "BIS (value):", + config_endpoint_iso_stream, cfg); +} + static struct endpoint *endpoint_new(const struct capabilities *cap); +static void endpoint_init_defaults(struct endpoint *ep); static void cmd_config_endpoint(int argc, char *argv[]) { @@ -3033,6 +3071,7 @@ static void cmd_config_endpoint(int argc, char *argv[]) if (cap) { broadcast = true; cfg->ep = endpoint_new(cap); + endpoint_init_defaults(cfg->ep); cfg->ep->preset = find_presets_name(uuid, argv[3]); if (!cfg->ep->preset) bt_shell_printf("Preset not found\n"); @@ -3068,7 +3107,11 @@ static void cmd_config_endpoint(int argc, char *argv[]) /* Set QoS parameters */ cfg->qos = &preset->qos; - endpoint_set_config(cfg); + if (cfg->ep->broadcast) + bt_shell_prompt_input(cfg->ep->path, "BIG (value):", + config_endpoint_iso_group, cfg); + else + endpoint_set_config(cfg); return; }