From patchwork Thu Oct 26 14:50:42 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: 738479 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 1C088C25B67 for ; Thu, 26 Oct 2023 14:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235101AbjJZOvK (ORCPT ); Thu, 26 Oct 2023 10:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231442AbjJZOvI (ORCPT ); Thu, 26 Oct 2023 10:51:08 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2085.outbound.protection.outlook.com [40.107.7.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02C62B9 for ; Thu, 26 Oct 2023 07:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nbiXRbNlEsMho2TxnarYwJK6zQ1R/9YiH3dO73TGj0gGAR4hkUQB5rOCGrYuLh4eChdazWbh21vXzhyZozH+0F2Di4KhAC5cxRSKYZ0apz/3XvN37ja/Z0mDFQCm+rkfbkcy1EgbHwqm4op+rPIQLIkQBEAosASE2JMCKkrvk9zbCudj8s8RyFPm+LWh7UUruwz6iKVVofQxmMtUaHfmu819TobC2krasLuu/v8oFl67mCam4BWlgYkM+eeqyT1LZ/244O+YXlGO51t+WKDlHFnPQhscBgdrUL6ge5HcanCv1b3vVLu4tH5vNqRVOQAo4PG4GZymzGcAupBfMWO1Pg== 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=9QjCybU9bqY/HBQXwZu43Koktypo3+IfWCGMVt09/94=; b=CFB9hb9xif2/AAB3/pnPQv9NyE5lT5x/XrEQRsIxMt0Ab5Mcbp2G37wx9IC0gwiCIAB5VF3CbVQh21dUNc2j2MimS215H9P/XICB4LXhiaHoptpKZ/CW28QQGLSqnicotMDB11suP6i806jU5MZwQF44tVQ4+cEJy9BJ3SD/i/TG4G/u3CAhZIW647lM705S/cQ2kzlS3IcwXIbbyHf9rUN5Q2Iz0MSXIOjT8toDtPTUjCuwcdwkPHz7+u/nK28xFxLJmzjM4r9U44pHcKcTHNYW8PJDRq/MuT/xY8Dx2noQJ/WdlY2VghefGZdyj8DUgPHzpBnoASY1adf0wCAElQ== 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=9QjCybU9bqY/HBQXwZu43Koktypo3+IfWCGMVt09/94=; b=XtzYA2IHSPSoAlxRdQW9Y9LCnv6zNKFUhVmNXeeGPiYy6txrWMVxo6p0+MiUvekiWqf0s1HavQmXimK6Zx1lXlXUsRsjcGk5tjdnBFB8E280yQU1K21sEJiimQzqt63YiHCPzxk7Y5mvbtzAOvZ+ArEAnWlCFRGwsUdCIQDdBF0= 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 DB9PR04MB9939.eurprd04.prod.outlook.com (2603:10a6:10:4c4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.10; Thu, 26 Oct 2023 14:51:02 +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; Thu, 26 Oct 2023 14:51:01 +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 1/6] bap: Fix source+sink endpoint registration Date: Thu, 26 Oct 2023 17:50:42 +0300 Message-Id: <20231026145047.4637-2-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026145047.4637-1-silviu.barbulescu@nxp.com> References: <20231026145047.4637-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VE1PR03CA0010.eurprd03.prod.outlook.com (2603:10a6:802:a0::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_|DB9PR04MB9939:EE_ X-MS-Office365-Filtering-Correlation-Id: 42f23f7d-392d-4b2f-0d25-08dbd632f89b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ybYWRhjTq7ONXjCU61eEswLqGTJrEIh9OFlAVCjmpnwcF6M+ZgOoOKMkCupSqxj9aA7YIjDsQ3tPTngzkXh3DphlLPFgvKWDfrfpy841NFe88HQ5X7g/nAM3BGEI1ByRBVL8p6/HKd2kQnx/XOUXeNmEQHIgsXbFnf4Iy144Z9G84rMtAfW7tzQCH4SHTPSkdgtKDte8UlaDg8A/RHBS8YUSp/M65jYAv64CNC5M5l8Ga/KkSbKySdLBAaEjCF72Xg8rHYSlJH6Sby5qukosfg6fOHsORJDamRMQL32c4tUC0WkE5/Sa6JiCgF3Nwxcb6cKmy39S56ReiMTp+G7pPQDVzKDL4Pz2JAEgUZuryC7HPYZ2aHk3nZwe0M7k84FhANH/q1oqhNo+nWBFNQEEkDzSE3EzUud+CzqEa9RGK6SW9DwlL5wX65845Zfp/M7jZAe21zRqae3KrGWPWHW3KsP7bV6TMKuhzc5v0IMensQ8oAnI+3YtUl7nRFKjJqoHqA7C9wm2RQsJmkusMazJ3t9Rdx1zH8q22Q7zogac5gFzZbKubZmHORcKThRIq3nq 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(186009)(451199024)(1800799009)(64100799003)(66556008)(66946007)(316002)(41300700001)(66476007)(478600001)(6916009)(4326008)(6506007)(6512007)(6666004)(8676002)(8936002)(6486002)(1076003)(26005)(5660300002)(2616005)(83380400001)(2906002)(38100700002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2SdU3jFNUHKbU5WTQOTwUpBESA0tn5AccvC9RbP0gAfqquLNGCWpj+A2kbEwOoBf7vKQjqf6AVE+hRotdCUzP3j4Lzsyp4r5Rwch0sv33TsO+5qd7pHgXy+u03Opf1l4w/H3SZEUNJJAHDJZnGZ6s5Vx9DZzJyJ75dNgCdEGNYkAnJDDwG5MJycsUvDbWipEYgpYpCYuUP6jKEnVde0kDfxa1SfkMx6Hl6QKzORqn4I+CZswpJ5frCM+s8kjipzt+7oqHn5aq86ImhN/qBef8Nt1QXa+U1ZI+BgGbVT45V3e0dNNSxvwRgrOlHm12D8Ekxsa/65DurFPHKwb/C1OqQo/Z4fyT+jRMCO++5OCRo2HqviiciY76FmX77digFLspYRwgrPP4nB3XbhzTkYFJLO8e8NTb8B9RK7IblteIfre47V9KYQDmxW941224Zty7ji+w9KJrBNsEl8E56V3tE+h0kiOoDzmMYL5peBlHdBWU0XR1ONeW+Rv1exidDN1Qv/sIBN75AVKhiidsVzdMnERcyMcmY4Zzn+Y+WiwDMfIbFuA6r1gg/M314C1bqb5VXLVNl8EoD0rLAAAovQNSFQ3xEWIzgvAY1zPztrViSYu9TB3PW8Lrm7f7mVtCOPz6f39P0RvE9omkgd+FhPToX46HVQiAX5S7CoBpkDNsMBnX3F82kHLLmxi+0D+QkJ9KpoBNkNwVKDNiAWs+ZTw9tprxFKLL3n2sXxXTndhg1m6qi1PNjMvC/mxcL2GdHT7Xw+TbhCie1nlpBH8OulH1V5VNA82L/sOVHxvMiEOHmnTOvfXT6z6WZB4s3yJiRjVg/JiQC8MZ+CRekRsXXxPGkb/fZtwVPUlNy8s5IR/KlZarbTt/BOdhIR3soxzQ/ch1wyaFkak37aDplhQUVuW66e5IVrnYX0YLSG5MalhkeVAXVeCPP02i3+tpEHTTl0raSmJ3u0drZpACEB7drGvvwpGgbOmvdT7M8+O+AdIm7sVJ0Hge/1lAqeEfzZiKEzh0IrayN+DwJqIYzNhbr/QAwQLu3aWy0AWTauQmRovQQarMoUAHH/mKP7qsqxvvXpwgJyBTSk5zt5Dm76pKAal0ggI5fvC2myPIumkx5mg/IIdVNFAP+bqrBu58KlH1IBv+XiRMJFd3AlXhd62B4FFXJCKLSU0AO317fqkJbcs7cJ+by8kwISx5GelogNCDrE2p6YxY/lANv0CIFnvgjagIvQ41uQxCabj89P5GEv5TOPKeJA8+BkWK8aTECCMV/yyR1VzhZJyQHMWpZUo2aJ1NxiF9uRk5znsF0pfh7GDkMjZI3a4lpkK07QFFEnQAVMUNIolR8wks6Gc+o+PfgMgwYyG9CB5GnkBexUK/fWi5PCkQux2XsIJWQ38CE/AONCNnG8m56sJjFGaZRrLcK6bwyjetYiLWZOOk7HXY46NzdEMSBYYPBFex+ODIh4lppKZaf5GcZ5MSel4cLILTpAkk1Q/yKnVTXi03YYtxJo1tr5AkxXq71RVYLK3AKZKdbhQF5RCDTbV55N/oXfxCCmcQfjXuGC8KWMLTvFOZa3ioZndB10m6MODBJ1qcdfg1Qhzg7pD2j8Y6XlaKjWdU3nfyQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42f23f7d-392d-4b2f-0d25-08dbd632f89b X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2023 14:51:01.2382 (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: +GDXtoAZpNvm6efKOwfiOpdJso/zNVLSLQGRnOHQ3FX7PdXjXngce8bc819PBH99HLxjU6LTNPZTJOODA1J5pH16sxtHCojJFzpGHc87YO0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9939 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..54ad713f2 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 && (match.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 Thu Oct 26 14:50:43 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: 738767 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 D5E76C25B48 for ; Thu, 26 Oct 2023 14:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345326AbjJZOvL (ORCPT ); Thu, 26 Oct 2023 10:51:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235105AbjJZOvJ (ORCPT ); Thu, 26 Oct 2023 10:51:09 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2085.outbound.protection.outlook.com [40.107.7.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9998A1A7 for ; Thu, 26 Oct 2023 07:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CImvOEWWgxAvFNWA4MnSszfCCUKW2E55DResBIufzpqdYCbjCtO8DsIjfGGsKIR8v5v8DDvu8up5MXQTHws6Jo2ik4+ZexurpfSKt4iwmnW+iVZr0fcppbVJpkXi1acyh6pwHBPAXZzTDRCZygCZo0+VVH6yRm9Cb1smCf2ebc+rBKRmuhehg96yG6CEDy06eGCpAGaYKOnU6pz9Yhc8gBmH3VqVHJutMbRBzxTVzgmZaxqHkldR2g8A9LX8hbHBC4GjB2PdT7Myzpe9paAX8fQo4Jt8BS3TVL4GSOSg5lgWYSzc4v9XFRanm0BbH2cqTHwUV3sJ8Y/rF0wFP8yOGQ== 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=i3D1XnVnDTa6VLUTi8bbSA6go8Lr5EG6/FNSP2AvqOg=; b=mM6kZ66D57fBqwvImekiqOcxDIqcHh3r8frMHtWUBWHgWJNYQ+b6/tUtN+MEVsCMOVe+PgBSmoC1xI2x7xDhiq4qFPXFEPQDnwLKkZR5dAdzkOymDL/ogxkczMMm5A9FE+H7ZKMoO0Mir+ja/9TZ7ZVSiYhSwdgxrZe6FrALAvyDAAyzJOEKWokJZ5xDrcIlYdgyrZNVIEW+Ro55K6Hc8lvaq2OMl46M+P/WPVvD2SpOfcsKgPBEFI/OYv+3SWsczZsBOEYtMOkqTr9yoUtCFGhg+nsk7RSuurveXsvyEwPTgdJEpnMdSObqrOJ1POBXpfXEB7tA/z1qggiIkiNv4Q== 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=i3D1XnVnDTa6VLUTi8bbSA6go8Lr5EG6/FNSP2AvqOg=; b=mzWiXWi6PYwM7zwJc9q6uSfhuMjud4IBWvcZxJIW9GB2nhlUmQVqKQmED3Kz5CBJrhM2I7Mi4k+t27ZKkkR++CLf8OQn0UiBSfKsksbgnO7DnAsxxGllP087GYg8/sXcl/ct9A5S7fT5ARDLSv/PNALV/lyfBCFJ98E7EeR98pw= 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 DB9PR04MB9939.eurprd04.prod.outlook.com (2603:10a6:10:4c4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.10; Thu, 26 Oct 2023 14:51:04 +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; Thu, 26 Oct 2023 14:51:04 +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 2/6] bap: Fix source+sink endpoint registration Date: Thu, 26 Oct 2023 17:50:43 +0300 Message-Id: <20231026145047.4637-3-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026145047.4637-1-silviu.barbulescu@nxp.com> References: <20231026145047.4637-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VI1PR03CA0051.eurprd03.prod.outlook.com (2603:10a6:803:50::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_|DB9PR04MB9939:EE_ X-MS-Office365-Filtering-Correlation-Id: 8675c23c-e4b3-4612-2fa4-08dbd632faa5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aRrC+ehfMUFy6hGJZOtHDlR8YmS+KJYax4PkYKGMzwxzIdC2NjoM7niqzomTRgO9fjKnZvRYc7Bm1R8fEfLfpkvsGAvwOmnCfB4eqe00e2XAI9xmiPFm3GEPSr6ajQzWZRXGOa7oO8rAuXVFJF9WbT7XM1JxSjCBz6cthLCCRur1r7FCRsypELOpJ9fIdhaqQAk7xvGU5EENGxjfqqsLn1Ja5dF+zs+6UUM/DMaHctTfPQpPfYZBvzu43Umji/qhRrqz3/d2FmrV1nvQ5AArkG/vOp1w87d47bYryVeTiBisbGexBv55Hewe+PYd0RKGuAQ+QHc5I/q7FE3b4zC6I9iX611toqFHo1+CbFDrQUR737/sOPToWQBypDzSoxyeie8rRLMMPjR4awsS66eov8Vu3VEOH9zeKC4c+gMYyZLAyafzUd5JJ6d6Fyyh/RBGb58SteEjgkJd9KUXieL/aH5lCDCOvuzTBij2jSor1z0rrIbq0W86UyYC0l0AHKxbTxDyE1MYioqjfqLWYAFJJRzXpp2IQpnGIvfyjibTLL12GuKVQElRtfcDM1oY1sv2 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(186009)(451199024)(1800799009)(64100799003)(66556008)(66946007)(316002)(41300700001)(66476007)(478600001)(6916009)(4326008)(6506007)(6512007)(6666004)(8676002)(8936002)(6486002)(1076003)(26005)(5660300002)(2616005)(83380400001)(2906002)(38100700002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aJe0GP0WkCPUklWK95yjbaggKnZ9ZuZDKr+KWrgoHhHyCGMiOcgb7bxAbQf/cQ4bfJUivL93oIeZTkAAur9yK2089t7eAcQIddiT8C6N8Ojuib4XLT2DKvCX5p8giiWocxM25Y5+ErXsJS686sPLK06kQ3TI6c/Egbe6A72LGnR+eQzvAlnmPpeDK8f45tCd/OvUwqeSfvkB7COBB1/j8iMM+WArGrku6XXh1i1dW701ndDdq23PqoCgAJsMRKAYjAcZsI0MbMDXvWszCZx4cyEFo2Ht43zGeYkTj7ipb0bMI/lUWyRYe0PC37/4DzpegSf4YrV7TEwqRews+jkKjfzjofChbhaP4Te5OOqglItopfmNq3ynik0Mxu1afHS08GTOqTNNFZ0/ZyXMKVL3tpmhqj661dUCgj+xt6FGyPOyGdXuZRZvP28wOedBFUnSJr9FtGzaDGUKDSz2rFrpl0X6iDYvjRaxujihQ8vDZL9d2FXiXA/K8FchGUy/zysPS2JT/ro3uK3XbirH184x4yZPL+HAYkRGhO5h/Y6nkmj6gNeWtWysclG1HUMmEP954YgimXTBMC2DDs5N5ZK5trtEN+Tkl0GV8JawAQAIirB09f1njnou0y94VfZlVerfKGDxk5qTG48wh07tfZuUEUcMNr88QQLR3l74aGuIgEKz2hXcniCqkWMb0nKGzMht0Vf5Fduct5Hzq2ZXnlQzPBHAMvYD882f1odX7+Y4yThlC+tYr2DN/nDp2razjkGn9MC7u7OkJojBXfzu1R4KRjQYelbRLk6o/cms2CY54W5ZkAxqsfZ2WZqAtf+c3n615SALJh2TxXcd4aSUHRbBprgYgsRwH0fHYFBCfgjC/A1MFCektvHoQfdEIe+C2vyaHdwCmvmm5EPozwkbS40589lDUHFIK6fZBbe1qkOJ7NT+odXf8yaB+eS6Wtk3bcfCrqlOVbL/MUrGSVJ6Rse6cVmOj037C88xakJM2pis34bmK+BeCU4WX7qq2jq31O/8j154hbSB7CJjRR+LOdl/M+gigyQDFunpAIcnv/+V+i6cVvCFCX6kwswaE4Zpxrp1Uw0CJvsFEDOXAeKQ5lrpGyEkxSieff7g/W4YLGygvkTsxE8hAPQ2LkHFySd/ikYSF87BVBewMY7abLJi8zPuhXkaAmEwLYDD8m7BHIUq6nCz8BGu8OpBKi3m6op47H3O4scD82i9hMuEc4yV9dKCTvi0FnR7TKiS+8CG83FgRvynDHOtnEkfiIjuOTGUkGtXrFGZ5RLjWYBpHunMcVY+ZvnrhqHl2voLaOwaX3Usm9e35iVMIyuSp6D4+KBqbrWfx2zMvOfAsC1Sz7W74vhoVkC2he/JBnO/xWt1ER1L7HH+jBQ4PRAWtulLfl6SPbyqxnU3z1G44TdEq6pyXnJINsNMXiCTcOZOiSwxhklCBuYHgkxlJXgGFlkwSRT903Meo8AUgMGDLuUgZVg16ZSctnruqLaMc7ACLF9VRUEt+uSi5QemF0bTojrB3vtrdXb8JEiGcWCnX4EvxK8ViPy78W9yH5uajfU1Mb68G35Sf5OuUdKLR1ta8QFmjcgBJDzsgl2KZmDOIui1fKij3U1zug== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8675c23c-e4b3-4612-2fa4-08dbd632faa5 X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2023 14:51:04.6370 (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: MlwkjxzrHQH/2F3Lp/jDMsyKPk9c92pak8g4qgyZiC9xTTrPM0f5mI/Z34G5ug39z2OYIFWLI2q4yiEecaILKJsEOMY7EJiNnl+GWukWGj8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9939 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 Thu Oct 26 14:50:44 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: 738478 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 B2D65C25B6E for ; Thu, 26 Oct 2023 14:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345328AbjJZOvM (ORCPT ); Thu, 26 Oct 2023 10:51:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345305AbjJZOvK (ORCPT ); Thu, 26 Oct 2023 10:51:10 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2085.outbound.protection.outlook.com [40.107.7.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2734B9 for ; Thu, 26 Oct 2023 07:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W+HKWJ9cEcHAo72CGEv9+HjetwUd8qXmkfeLATTPx61pKIuPNyylIOQxHxOWal9mlE8C7mSwfn9oTAgPjSlw9LpFaylo73r1KSv5lwZ6Cn+Q69thZyQmDf5f9GnWvd29Qd2ej/t71iP5A3L9kIeTuAYCzC69ogX9gmmbSTZXHJcoYUlqiSgfHsU1hU37h8x6ARznIwDqK8F7gbcsWAC3sMlYSLUiqXhgRjdyPImblBHbt7UZEv+qBm38ItEljbu9WtNnLacfNjHWWQB/+/1HfNsDygDC0hWw1WcIOxkscQSD31zm2RX362Wlmi0ZpiJz6HXHADOqQgMI4hjpbFbhSg== 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=QezM3gJIZfcElwYAqnIRxFG0PSytrfSC+ovU3cpPRgQ=; b=fHLZ3iLfVjWdkzOch8zjp5k1tjS2u32aElFHpxYTPDDj2LeaxAdv9GxTTGvSDzK3VmJWAeHia5YOo+n36QXxwmZFdypUYRiL7dvjezdeer8b1E5X6vRWuTA18K4C3/WsGxBukCFmySxciI2hR6W2k/vJp5qDWq8fQDbLq049/p5My1IsCYGYGcIDBu7YbkGRNgjBqRFdP873OZ2eMvB7HLhNbEVKQs9YW8qy50W2YaGMMFhlf4asnCpRqZPtAkB9wE70gq/ONYv+GFukWsnk4p6szxd0V/+W7TGTJblITiS+hTAv3ShVx4XjGNGptbNUAUJ5K1W7MX8faz7NySd4uw== 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=QezM3gJIZfcElwYAqnIRxFG0PSytrfSC+ovU3cpPRgQ=; b=kFJrJwgx/QQHN7K94z8irIe78vvzM7bMSbPfjOBavVl5/DRRTIFMY5DGFx2dD+hXcKkzEAAo5ITm2YcoI5kPhmxMXBYz07bL/rJ8KWAc3ak+ZCXqVJintR1UV3RoKQ6QhB7T8G2gp5z46TEXgj9r4P8Y1d8q75ecHnpXt6QpUfg= 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 DB9PR04MB9939.eurprd04.prod.outlook.com (2603:10a6:10:4c4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.10; Thu, 26 Oct 2023 14:51:07 +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; Thu, 26 Oct 2023 14:51:07 +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 3/6] src: Add support for the number of BISes in the main.conf Date: Thu, 26 Oct 2023 17:50:44 +0300 Message-Id: <20231026145047.4637-4-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026145047.4637-1-silviu.barbulescu@nxp.com> References: <20231026145047.4637-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VI1PR03CA0063.eurprd03.prod.outlook.com (2603:10a6:803:50::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_|DB9PR04MB9939:EE_ X-MS-Office365-Filtering-Correlation-Id: f20c6aaa-765a-4bed-b92a-08dbd632fc54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L6q3biRFuBWwRaTVtbgH9Cj2zLyCQ9hMzx3UXM8f9XbDlwys+0YdTUiHAwCQofCKY2Kmz9orSgNv7/4pslwtS7FOik1+slE8B60OOqn9s5x4V7mW5fWz5tNRfPI9XNehjkthfP/DKinzbfqt2HRhmtWZGZn/L5MGqgcKJkunLmlqb953mUs7/hyqP82muKdcOMHylNkoleIh7v8FWUkyPBv6rybvBlHIxKHDMYdkE8Lt7D0IOeSy9s6XIc7yerhCenzP2cTQQW0xEoPTzinmDuTceoLYcc+JaEz1BrRrjDAIEdGe9BFHUysfCweXOS99XGdDHKaeko5wXOq29rGkrb3MvK+thb2ZgU53C4+FYI7TTvDbH2Fxqs8PfdbR/4SqJw2o51bMC0VltVoEuMgYEycZRHO0kPx6VIthReJcIHysI7YmiXjvKYquMi54uG5OxPRF7CMHwGolk9Bi9vGBCvg6c3wm9GGUV061jte0m7VIqD87UfvG9tzGF6cuc8RqgzN8zfCKIDP3rcT0B8FvxNm+Tyzz2EZ/B9IhAaNdo7ZVth6CHYfEqgFZc71hwe1f 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(186009)(451199024)(1800799009)(64100799003)(66556008)(66946007)(316002)(41300700001)(66476007)(478600001)(6916009)(4326008)(6506007)(6512007)(6666004)(8676002)(8936002)(6486002)(1076003)(26005)(19627235002)(5660300002)(2616005)(2906002)(38100700002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GfFQWvEzrSYOWZyQ5TEJp7OSlTFLAwALTGaIcbGjTD6LeIPoMJVNxk732lV0JKQS+8iTD6RgyUxvnRODMbF1K90m/0TQ4sO+aToivB8j84bDts4avQnia+DaKXmt4n6P+4HjS5nZsf/6b9Dmzd6A4GIMr+IDBehgrnTxF4BLOcotUoH1R7wvLlu7xNzmNXADtOFEgCe9123VRM2UaSHEeYp/yIseYEPtIuiB7OI5vX+6sEAwlfiTgCaOcAm9yeRJBV/a22xVqBRd/EAooHpr4FlW6kAYdu1ty6KIl5lcmxireRrooesY1KoRAZ55PQ6RbL731MbP3FUV45mZdGWScUcK3QX0h6+Y8lucOsJUVzo3b0DGdHb762NlMDvbzN5PkZHtCdCTbpLhC9diTH6cQ+TC95uG//mQ4ic9bHlaIxbGIKNen7J71heIRp5HR2KvBNWPi9IMJlks06Jai8MFtppO2/0CLv8dVmNzoQG8V0IV855Aice4ZIvbbXwQd4xABhjqg5+MVwGFo8ftPOZ2UU8cc5xqmjf7jB6Ef7am11r0Bs24vrxrxB3Mz3PrimQ3nlzzW/hnt8rd0PhmgMHH6ROSfcKj8dUIdEIcIzN+2qtK9MyILgUHFGPQwuYIGwA47OI/g9j7TIWWEwakI7m2ccbd6V2RQNJx0VQ00vYL5IR6IFudtwW2n9UANNQWvsAgy4j0kmodlaiN9L8b0rye4k37QSXfxssudxLpnUYOL3bSUZ4c0TurVOBYhzadzuTRJ+ncccUfCCTnsbA07PAIlvvRv3gcYMfUc8mgCAwvDBO/T6k272P5t0lFNrWYvZ4dA1Y0vS10xex1q9gbQt4sQQQ1kZUuJdE5DC8OWAHUAR2IbM6Q2bO75M9clU4yn4nCcABeIe4gqD0EjubM7I2lYj9C0gcc2WtVX2JaXfsbeoZ62M72oZQTTbw6bxyVLctd/bq0FbVKkpXuMpnf/zF0lHfv17hhrF4IYAISY0mOaHb8RSVkxhlB1XG3RUzx7shyNebvfxxKil65HJtNz/UJpSAoGfMi25/XQo0f154thoFSZ6QfbeDNsovaTPPC/SUmXkkJE0bOe09gDghZT3IVTEiYcKpmw9SHJXzCgpmaq7NxZXtI8JpT+3EEsGpJtT7IwL+OL3dc08AKpnApe0PSYu4aQzm9BZqyMdbX3LXfPq4fDxiRTuNF89LjjoeCp/ot6dsWet+GY0+jaTYS82yEO5oJNeJ+f4/FC4hDjOaEMvV+Rzpn9M/Ex9QeSDPRtQrDSJYPhR1W1r6JvK73CwOos41HUUACkhu5ioSgOJiDIhrDdxk+crhs6ipNvlHtSQMUn8Yd2ha3P3ko+0cZzFOgcxB7oOgE9W7MPibVM3qLvvm+dQkqyDcIvuzDzcQOHNw81qApnapZvBtOPH2QJqXwPqPfhL7SN4ijzDvmu/IW2JmodRHqEnSRwxHUKq0fNKmsnAmyut+6TcsvwyUwos8aFBTia/OKsLyz0EjH3ZE48MbFZDZts1sFhbiozuIqgpUzX9teh8cjGAuYF4NIO/k+AdXyAlxZ0kvlRgJjDZyLtYnGxlVNZtsA/3TPxnaDHuATeensVLarqhwQjQgSMjcV/w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f20c6aaa-765a-4bed-b92a-08dbd632fc54 X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2023 14:51:07.4692 (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: v0w+326K/ZuncVwOWzg1d2/SRn1NbPOkIgi0zsUQO1qdokU/sTO5NLBJp+tDtV9MwDiC8BZYXKzu7vKLY8A9vFLwoSkZyr1zfprbM/LqQ+A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9939 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add support for the number of BISes in the main.conf --- src/btd.h | 6 ++++++ src/main.c | 10 ++++++++++ src/main.conf | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/src/btd.h b/src/btd.h index b7e7ebd61..2ad494008 100644 --- a/src/btd.h +++ b/src/btd.h @@ -108,6 +108,10 @@ struct btd_advmon_opts { uint8_t rssi_sampling_period; }; +struct btd_bcast_opts { + uint8_t nb_bises; +}; + struct btd_opts { char *name; uint32_t class; @@ -151,6 +155,8 @@ struct btd_opts { struct btd_advmon_opts advmon; struct btd_csis csis; + + struct btd_bcast_opts bcast; }; extern struct btd_opts btd_opts; diff --git a/src/main.c b/src/main.c index b1339c230..364f899c8 100644 --- a/src/main.c +++ b/src/main.c @@ -1137,6 +1137,13 @@ static void parse_advmon(GKeyFile *config) 0, UINT8_MAX); } +static void parse_bcast(GKeyFile *config) +{ + parse_config_u8(config, "Bcast", "NumberOfBISes", + &btd_opts.bcast.nb_bises, + 0, UINT8_MAX); +} + static void parse_config(GKeyFile *config) { if (!config) @@ -1154,6 +1161,7 @@ static void parse_config(GKeyFile *config) parse_csis(config); parse_avdtp(config); parse_advmon(config); + parse_bcast(config); } static void init_defaults(void) @@ -1195,6 +1203,8 @@ static void init_defaults(void) btd_opts.avdtp.stream_mode = BT_IO_MODE_BASIC; btd_opts.advmon.rssi_sampling_period = 0xFF; + + btd_opts.bcast.nb_bises = 0x01; btd_opts.csis.encrypt = true; } diff --git a/src/main.conf b/src/main.conf index 085c81a46..119d27a7b 100644 --- a/src/main.conf +++ b/src/main.conf @@ -337,3 +337,11 @@ # 0xFF Report only one advertisement per device during monitoring period # Default: 0xFF #RSSISamplingPeriod=0xFF + +[Bcast] +# The number of BISes. This is used, when an application registers a +# broadcast source endpoint, as the number of BISes in a BIG. +# Possible values: +# N = 0xXX Number of BISes (range: 0x01 to nb of maximum Controller supported BISes) +# Default: 0x01 +#NumberOfBISes=0x01 From patchwork Thu Oct 26 14:50:45 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: 738766 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 AD5B3C25B67 for ; Thu, 26 Oct 2023 14:51:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235120AbjJZOvZ (ORCPT ); Thu, 26 Oct 2023 10:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235107AbjJZOvX (ORCPT ); Thu, 26 Oct 2023 10:51:23 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2042.outbound.protection.outlook.com [40.107.7.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62C1C1B9 for ; Thu, 26 Oct 2023 07:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K1kop7+ai/o5901VKRAQ7uDU0Gb3kF2K7Dv7AKXtPYhT3SM6InAj05d0KeeENZTvlwQQT0hmTOdJ4/CEb+5f5KNSKwAs42j8g/5iCuvudKP2Kzov4O+i2u3sleEpDfHeXQftCTu8iXCkS7dbFln/ZwtUjEQjoTnGsdR7mIFoJKpWpI2RSBNDAXGlpHKoXma0PXnG0AtAN74TKf4wE2IjclHDYEh2D03e+YQXfiDLuPZoTCfZfxMWT3fhUE9o/KHrFIlb8Wc16dVzsACTRnGjc+ozFHsvLJYo11TePM0Ag9oLxfHZeNckzTT938KIgp1bgfHxIGXa34fspI4+DnCs6g== 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=S0xisGD6BvHBMp8NuW6IS3MMUI1rVYg7+s7Oe9UZUYU=; b=IKEeruvaCZR+9VSbPcnUeukuhARfmSYvnux/FOtLfHfYvdQ+au1lq8zzDcXbBUxQxX8dV2qsbJVbeFJo8ESHKrhVR2v70blVk701BUsE7T8c96Er82x6HoHtuXBqBqM9oMjauPMzLDbCpIk53kdhBMW9qZKbZDzIrqHdg7TBgtIQrS3NG/bpaRj9KohqK9t1J1ZWiICf0YHW1ldyts7ihDkZNlQ/IXEqH/n80aHr4q37A1VX6GQvjNMYRdRgu+kY3V0x2kOfMIVGPTbC5lJKlxvFnkkJp2USxKmGR4hptsBx9gbH5uSiFYc2c0GiwpnqDNT2tOLDPrZjC02T3lKspA== 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=S0xisGD6BvHBMp8NuW6IS3MMUI1rVYg7+s7Oe9UZUYU=; b=FNikXaz7+J+jIwn4fP1zH1HyujLUaDzkL8L0UaNQ7LsOljpJBKza2JKzN2pUll0yGfk2IbT5fxg1zk7B6sfLX+ycWHNQm5hgn1CORtk7c6fxYC0oOUzSb7/K8OAASuRh7rv2Zzf7+Uqgp5YUF8ndr/hxJR15T9WarJhnCGPA48w= 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 DB9PR04MB9939.eurprd04.prod.outlook.com (2603:10a6:10:4c4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.10; Thu, 26 Oct 2023 14:51:10 +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; Thu, 26 Oct 2023 14:51:10 +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 4/6] Add support for multiple BISes Date: Thu, 26 Oct 2023 17:50:45 +0300 Message-Id: <20231026145047.4637-5-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026145047.4637-1-silviu.barbulescu@nxp.com> References: <20231026145047.4637-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VI1P195CA0059.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::48) To DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR04MB6331:EE_|DB9PR04MB9939:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d8928ac-ecd5-4db4-2e6b-08dbd632fe10 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ydr+uoSsy5/DfzWEmCz2JXs+GqAn2nQQ4Kcuo4OrjBj8gTrVqs4TlCl4tcNwaaUMIjD0WuysiAxzpEQxc3MeRKTW3MRKkxIiSXmXHPPxvpYA5uwVzMGjMT4Et3LjC1I4Zpo8sxdDwX7ZWostbg7CWN8edCPpDym5rNbp/sxU6vovFx/A6s7rEtrkkZnbP5Q3g5zUy5GjQ7ZUmuP7NV5UslNxM8df0MHY3FlJXNZRcCBmhLWthANDAume2jCaFb7bJBFytiQOvlcrjvdKCEZPasZ44A6Vu7Y38hRdcau8Nu9SXlThoyPTncVy0suMg9nE4AzgOXjWAhq/XWlTD0Gcylxosv5Hc2qbP1GlIXS1bXb1f+vTmAmLdGp4wPYzCh+mXdy/yUH/qFGJA79kHeU+wOLFFmm9293CCffiPW5KJTARGkQfD9BxP1EZoG+9uECB72z0lehIApxEvmA7d5/MiSjzviaeQMeQAxR4CuCXSBFLlB8YZDStEfAYqmmQlejYj6sUemwR1sOU/i8YGbsqVin7IYF+7AS13hYqGls69KnZvvgaEE0k7I3TTfHt3HqO 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(186009)(451199024)(1800799009)(64100799003)(66556008)(66946007)(316002)(41300700001)(66476007)(478600001)(6916009)(4326008)(6506007)(6512007)(6666004)(8676002)(8936002)(6486002)(1076003)(26005)(5660300002)(2616005)(83380400001)(2906002)(30864003)(38100700002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Kqag1Ppux2loeNYKL/25gJAoB27rqB0CfhItbfwEwiZfPcaS3FmH2GT/89BQSDb+/ZH3e4EzmpZkD0XyhmRXnd2ahpz6MZWGVzgxWp1e7BW7mFXSzLyyTl8jSc3RfeOZElnBgSYVgKhlc1wkCE+qaF7FSSqGZfKz9t0LcJKWgcVwucdGsahJv3iKckxwMbf9dKGX96j7A8sSyR/Cm4S1VsYW0FAJcMJazHVBtrQi6kOqY2CWHjBvCKInfroBTwJ9iZA2eSaz6BdpojyLmEMpmcy65fBeYykxcE+5LfG1ErBjSVXhdz6XY3vmGwI7W1hjvNeiMVXYAGJ+DB9h9saSnN5OpVRCaVPzDIfWChrJT6OJNJXAZmtrTrvKaw4E5LAWAfzzyoCrip1PslFnn1Pf+9nxHoIi9NiNJqaw1HOs0uTShSCKyfTKfZ/tny1QmjSUzADdoRqBFns2dEfuKbOLmZroZ4jsuFXnoHkwEiyhbhZ7R6qN2xB1MMkbuxNb092B2lT7X5k8uHsEfaMGLJ4yezL2//BkvkBPYnY+VHD7vInTaNO5BqvPlJ4Ag976wdFF78UmR709HUOSdrq/onMkEVnWzebaSE2mMkgHw4AbgA1x973JVouMEadhdO/wNp6vicaWMX8eZni3WcAMiESV0tI4OMzUG0+lbN3BMOrYzALxi7SlPL9dh5sznsbRlm5WAP9ryNjpHsgj8SMEpoFunPzUOHUxLJ3s7k70TGmSrg0qJxMdhSMfpHYgDtP4XH2bccwqv1bATX5SiKhaKJE5XG1RGhi7FRp5Pzw1iYDQlzRuIV/bpZVg4+Jv/y1viq/QgabMWhs0NNOAOTcNYheduDnJGRPqmiJexJUw39S6+xedw6ifFAeKcoOfIzcAhF3QONK/+Rir+gcNExNilec6YRSBeuHZAcQVn5Kx1U2jlvVYQ7nLUDwzALLb48c0MkUrvNp1nOz9AmcnSXVyzjlpYEuy9VZu9fwn8W9GTNJHO0Vja4ZL5AQ+i+B0NKWd5MYjwBS2hryWxD3/Qwmxs8Lfp/NDDUcfOlMn9U8GfaDZVji5MANK0asj0qisIX4XZm2UIJAz19bXT3o39EpiYmpikjWpLmkDEuMPjTE91VDG1AP8r2H4mgo7DZOq7QYTW6Nkthh8s0WNMZtFa1bLDAr7dsLUZkgBigDW2CjWamj/LLT5W294BqwW6dN9TckiRKXmF+C7BFY6c/4cfELeEAE7LgiHXUfwfYl+PYvRT/NjttSPOo7pWmlWp2mxvlqZ0QxKgBVRtGy+KDBh8pdIyyWRE7jNNhNnuLLRVVn9tC0sdyAiaJ6b3NGVn2fzS+Al+ZXmvaklxarQ1pNpMrSyn5thnNMcNqx3ojMJOZs9D3IXPx+Y29ChoC118UvRFsD/HPYvvH9CG3Bs1XHyy8JZPodRcU8AOT7UIfiBcWAKrn23tFKY2TpeFB9Z88RAH54p0is0Rcpw1ENEvgXkGxnHRZ3fybaeJ6Qs8Nz6lKx3zrWI+skr0sAdObhA4E4rl33xaBtCDDYPMg3pOYBGe6B1l2Mf+OPRsY4ExjJbUG3x/mui6Dmt+6GoSybiPHN3OIbJVUvS362jSpjHGAQcnaGpM9OKmg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d8928ac-ecd5-4db4-2e6b-08dbd632fe10 X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2023 14:51:10.4647 (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: haHtYZbKtYZUHRALxJpffnUb4RJIdP7nl5DW3M+qmRFhzfjU7GuOKAnyKqYJMU3J5NNYP3DAh4UIYx55tbV4lMdITXXSVOlevDbOjCWKXv4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9939 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add support for multiple BISes in broadcast source and sink --- btio/btio.c | 4 +- profiles/audio/bap.c | 458 ++++++++++++++++++++++++++++------------- profiles/audio/media.c | 3 +- src/shared/bap.c | 191 ++++++++++++++--- src/shared/bap.h | 36 +++- unit/test-bap.c | 12 +- 6 files changed, 521 insertions(+), 183 deletions(-) diff --git a/btio/btio.c b/btio/btio.c index d30cfcac7..ec6b6c4ab 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -247,7 +247,8 @@ static gboolean server_cb(GIOChannel *io, GIOCondition cond, GIOChannel *cli_io; /* If the user closed the server */ - if ((cond & G_IO_NVAL) || check_nval(io)) + if ((cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) || + check_nval(io)) return FALSE; srv_sock = g_io_channel_unix_get_fd(io); @@ -1654,6 +1655,7 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) return FALSE; } + len = BASE_MAX_LENGTH; if (getsockopt(sock, SOL_BLUETOOTH, BT_ISO_BASE, &base.base, &len) < 0) { ERROR_FAILED(err, "getsockopt(BT_ISO_BASE)", errno); diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index a84181e1a..8dabd06b6 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,100 +412,150 @@ 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_subgroup *subGroup = new0( + struct bt_bap_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; - if (codec) { - codec = util_iov_pull_mem(&iov, sizeof(*codec)); - if (!codec) + util_debug(func, NULL, "Subgroup #%d", sg); + subGroup->bap = bap; + subGroup->bises = queue_new(); + + 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)) + return false; + util_debug(func, NULL, "CC Len %d", capsLen); + + subGroup->caps = new0(struct iovec, 1); + subGroup->caps->iov_len = capsLen; + 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; + + if (!ltv) { + util_debug(func, NULL, "Unable to parse %s", + "Capabilities"); + return false; + } - if (!util_iov_pull_u8(&iov, &capsLen)) - return false; - util_debug(func, NULL, "CC Len %d", capsLen); + util_debug(func, NULL, "%s #%u: len %u type %u", + "CC", i, ltv->len, ltv->type); - if (!capsLen) - return false; - if (caps) { - if (!(*caps)) - *caps = new0(struct iovec, 1); - (*caps)->iov_len = capsLen; - (*caps)->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"); + return false; + } + util_hexdump(' ', caps, ltv->len - 1, func, NULL); - for (int i = 0; capsLen > 1; i++) { - struct bt_ltv *ltv = util_iov_pull_mem(&iov, sizeof(*ltv)); - uint8_t *caps; + capsLen -= (ltv->len + 1); + } - if (!ltv) { - util_debug(func, NULL, "Unable to parse %s", - "Capabilities"); + if (!util_iov_pull_u8(&iov, &metaLen)) 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) return false; - } - util_hexdump(' ', caps, ltv->len - 1, func, NULL); + util_hexdump(' ', hexstream, metaLen, func, NULL); - capsLen -= (ltv->len + 1); - } + 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, &metaLen)) - return false; - util_debug(func, NULL, "Metadata Len %d", metaLen); + if (!util_iov_pull_u8(&iov, &crtBis)) + return false; + util_debug(func, NULL, "BIS #%d", crtBis); - if (!metaLen) - return false; - if (meta) { - if (!(*meta)) - *meta = new0(struct iovec, 1); - (*meta)->iov_len = metaLen; - (*meta)->iov_base = iov.iov_base; - } + bis = new0(struct bt_bap_bis, 1); + bis->bisIndex = crtBis; - hexstream = util_iov_pull_mem(&iov, metaLen); - if (!hexstream) - return false; - util_hexdump(' ', hexstream, metaLen, func, NULL); + if (!util_iov_pull_u8(&iov, &capsLen)) + return false; + util_debug(func, NULL, "CC Len %d", capsLen); + + 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); + + 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"); + 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"); + 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; } @@ -556,6 +639,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,7 +746,8 @@ 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; @@ -702,14 +796,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 +886,23 @@ 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 DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, void *data) { struct bap_ep *ep = data; const char *path; DBusMessageIter args, props; + struct bt_bap_base *base_s = new0(struct bt_bap_base, 1); + struct bt_bap_bis *curent_bis; + struct bt_bap_subgroup *subgroup; if (ep->msg) return btd_error_busy(msg); @@ -832,11 +933,36 @@ 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, base_s) < 0) { DBG("Unable to parse configuration"); return btd_error_invalid_args(msg); } + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) { + subgroup = queue_peek_head(base_s->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); + ltv_merge(ep->caps, subgroup->caps, false); + ltv_merge(ep->caps, curent_bis->caps, false); + } 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); + 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. */ @@ -916,11 +1042,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 +1066,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 +1080,42 @@ 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); + + DBG("BCAST ISO: PA sync with %s", address); + DBG("BASE len received from source %d", base.base_len); + 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 +1211,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 +1712,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 +1808,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 +1844,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 +1896,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 +1952,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 +1968,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 +1995,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 +2047,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 +2374,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 +2418,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; } @@ -2406,6 +2581,9 @@ static int bap_adapter_probe(struct btd_profile *p, return -EINVAL; } + for (uint8_t i = 0; i < btd_opts.bcast.nb_bises-1; i++) + bt_bap_new_bcast_sink(data->bap); + data->state_id = bt_bap_state_register(data->bap, bap_state, bap_connecting, data, NULL); data->pac_id = bt_bap_pac_register(data->bap, pac_added_broadcast, diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 4d9a6aa03..30658ebaf 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -37,6 +37,7 @@ #include "src/uuid-helper.h" #include "src/log.h" #include "src/error.h" +#include "src/btd.h" #include "src/gatt-database.h" #include "src/shared/util.h" #include "src/shared/queue.h" @@ -1250,7 +1251,7 @@ static bool endpoint_init_pac(struct media_endpoint *endpoint, uint8_t type, endpoint->pac = bt_bap_add_vendor_pac(db, name, type, endpoint->codec, endpoint->cid, endpoint->vid, &endpoint->qos, - &data, metadata); + &data, metadata, btd_opts.bcast.nb_bises); if (!endpoint->pac) { error("Unable to create PAC"); free(metadata); diff --git a/src/shared/bap.c b/src/shared/bap.c index 54ad713f2..45fd6df59 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -1111,7 +1111,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 +1324,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,7 +2364,7 @@ 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) +void *ltv_merge(struct iovec *data, struct iovec *cont, bool add_delimiter) { uint8_t delimiter = 0; @@ -2367,7 +2374,8 @@ static void *ltv_merge(struct iovec *data, struct iovec *cont) if (!cont || !cont->iov_len || !cont->iov_base) return data->iov_base; - iov_append(data, sizeof(delimiter), &delimiter); + if (add_delimiter) + iov_append(data, sizeof(delimiter), &delimiter); return iov_append(data, cont->iov_len, cont->iov_base); } @@ -2377,13 +2385,13 @@ static void bap_pac_merge(struct bt_bap_pac *pac, struct iovec *data, { /* Merge data into existing record */ if (pac->data) - ltv_merge(pac->data, data); + 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); + ltv_merge(pac->metadata, metadata, true); else pac->metadata = util_iov_dup(metadata, 1); } @@ -2619,7 +2627,8 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, uint8_t id, uint16_t cid, uint16_t vid, struct bt_bap_pac_qos *qos, struct iovec *data, - struct iovec *metadata) + struct iovec *metadata, + uint8_t nb_bises) { struct bt_bap_db *bdb; struct bt_bap_pac *pac; @@ -2650,7 +2659,17 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, break; case BT_BAP_BCAST_SOURCE: bap_add_broadcast_source(pac); - break; + queue_foreach(sessions, notify_session_pac_added, pac); + /* + * Add a new broadcast source pac for each for each new BIS + */ + for (uint8_t i = 0; i < nb_bises-1; i++) { + pac = bap_pac_new(bdb, name, type, &codec, qos, + data, metadata); + bap_add_broadcast_source(pac); + queue_foreach(sessions, notify_session_pac_added, pac); + } + return pac; case BT_BAP_BCAST_SINK: bap_add_broadcast_sink(pac); break; @@ -2668,10 +2687,11 @@ struct bt_bap_pac *bt_bap_add_pac(struct gatt_db *db, const char *name, uint8_t type, uint8_t id, struct bt_bap_pac_qos *qos, struct iovec *data, - struct iovec *metadata) + struct iovec *metadata, + uint8_t nb_bises) { return bt_bap_add_vendor_pac(db, name, type, id, 0x0000, 0x0000, qos, - data, metadata); + data, metadata, nb_bises); } uint8_t bt_bap_pac_get_type(struct bt_bap_pac *pac) @@ -2701,6 +2721,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 +2811,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 +2849,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 +4518,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 +4734,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 && (match.lpac->type != BT_BAP_BCAST_SOURCE)) return NULL; @@ -4839,7 +4891,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 +4927,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 +4995,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); + break; - if (!bap_queue_req(stream->bap, req)) - bap_req_free(req); + 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 +5261,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; } @@ -5245,10 +5318,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 +5455,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 +5513,58 @@ bool bt_bap_new_bcast_source(struct bt_bap *bap, const char *name) return true; } +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_subgroup *subgroup = user_data; + struct bt_bap_pac *pac_source_bis; + struct bt_bap_endpoint *ep; + int err = 0; + + 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_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..74f0effb0 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_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); @@ -141,13 +162,15 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, uint8_t id, uint16_t cid, uint16_t vid, struct bt_bap_pac_qos *qos, struct iovec *data, - struct iovec *metadata); + struct iovec *metadata, + uint8_t nb_bises); struct bt_bap_pac *bt_bap_add_pac(struct gatt_db *db, const char *name, uint8_t type, uint8_t id, struct bt_bap_pac_qos *qos, struct iovec *data, - struct iovec *metadata); + struct iovec *metadata, + uint8_t nb_bises); struct bt_bap_pac_ops { int (*select)(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, @@ -168,6 +191,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); @@ -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, @@ -312,11 +338,11 @@ uint8_t bt_bap_stream_io_dir(struct bt_bap_stream *stream); int bt_bap_stream_io_connecting(struct bt_bap_stream *stream, int fd); bool bt_bap_stream_io_is_connecting(struct bt_bap_stream *stream, int *fd); +bool bt_bap_new_bcast_sink(struct bt_bap *bap); 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 *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..80838d813 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, 0x0); 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, 0x0); 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, 0x0); 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, 0x0); g_assert(data->src); } } From patchwork Thu Oct 26 14:50:46 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: 738477 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 B56A1C25B48 for ; Thu, 26 Oct 2023 14:51:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345342AbjJZOv2 (ORCPT ); Thu, 26 Oct 2023 10:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235108AbjJZOvZ (ORCPT ); Thu, 26 Oct 2023 10:51:25 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2042.outbound.protection.outlook.com [40.107.7.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EC571B1 for ; Thu, 26 Oct 2023 07:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B+qe3UnUI96hi7kFS0kimAfG0k9YI5Q54Kqy2zAemzU3H8eCjrJH7pAXhFVDUwifuHl8b+rMNqNC5ECqg4uadkkOMAqrBNhZXDemTM83h7Qf7JDKq18IvOLnM8lFrU7NoM3FLR3VYQGAmD5YgMgjJMYP/ZcQ+UiXT9ljE2py+3/Qebng+mcb9DzEt0Gmcdat/aE2gQ4EQnkJANcwdNabYnduhwTJNBz61GFzvd45QFbRkzOHusxgzdcC8IfeIC4xuH6gehnYbJG073yrqQ9LXryUan5Jmcf1DKXFMao0J+Y9VY4IaPgdhsoRYs/WKJYJeVvWOfFG8qunNCvGVjABuA== 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=PStRI6Sc+im+fV1R3VxEWQmhdSb+AUVAfa0PshTOKY0=; b=VzwO42HCjwmeSs/3OAC4c1M4OjhpDMnQvLZlcfUl1RY1qaHXTmHiWjh7PlBL6YH1woT1uSbfref8xne1xHzG8iaeqxfTYkwek7YEwC3ihPVwuFMi5PNizkKB75U2IHG7jwlTyupYoUmM4NV9QECR8UiCyaAughi9zUyUDkcHDgrE2I9HtLSv9gva+/g5oYqJ0Nq1Wafd1mXKHs331uXVxQI1uJBZWhKO0oS/HOj+J6jpqZVz9B65xmW6waKYsEIcZu4OlaggZvdBzAHOPWp59MoiCpv188cQrysYHSqoBQWFTEnRHNLJif3Vfh/CWP50eGwWJN1uPvqZ6pTDFQs+dQ== 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=PStRI6Sc+im+fV1R3VxEWQmhdSb+AUVAfa0PshTOKY0=; b=CF67fyFTK9i4DsltYPg6s1+kzJt0A+WzOVSkRw+U4rHVjpr8CBsxu4HwjndGb3vjUHNfhmdfAcJMC0n6VguvaeoCi1FQ2KRN+boo1ScTeMa1YcF45+XwXJKm0s17yASiQY5s4Nwd6QGC4lk4YBBwHGzlbI5cBNhf/blPkNrXgg8= 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 DB9PR04MB9939.eurprd04.prod.outlook.com (2603:10a6:10:4c4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.10; Thu, 26 Oct 2023 14:51:13 +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; Thu, 26 Oct 2023 14:51:13 +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 5/6] profiles/audio/transport.c: Add support for multiple BISes Date: Thu, 26 Oct 2023 17:50:46 +0300 Message-Id: <20231026145047.4637-6-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026145047.4637-1-silviu.barbulescu@nxp.com> References: <20231026145047.4637-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VI1PR0102CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:802::15) To DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR04MB6331:EE_|DB9PR04MB9939:EE_ X-MS-Office365-Filtering-Correlation-Id: eb1eeae7-7c05-4061-c95c-08dbd632fff1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aWwvXnMHxga5h0KuefkoMbums9F/E6zRifRSGSRqRtG3c6p3ptW/hRGMTnUipRc1hRm0RDS2kD9m+ZaHfokeT1brEMXpis5g4gfAwKrXq+BGrOAlVOpzCVDj5wMallryupVfFXjd65UUum/TZfFfnXljm0frsBJNaTa/wJHCkHbIHyer9SS9GZMrouzAXk7+jafvqWFW9iIYIAh2s161xWraiH174rU5ijNlk34ju4PjaUKufSb2Pcfu4I8SlUBRyJ8BHGaTgKgxl+6EUpheAxMDRzuSU8dx9f4zogi3/V2VmcbCMWtfV0zPjbRtgOOWjMHuDVUqE2nBQo0pIaRcQGDozZZaIVs0gIj7kOgurxAmw9XfYmAlkrEYIm7+OC9LyIhOzCLyJv8/GmH/rXkfFSHFXOvIAX6IxnQ7v6Gwi+it653Qj+pDC7LUFSCPozek2e5dCbWgZoE492DaxhN+s6C0ZtGi4zI02n/Sd4QXY9BZiYI9v/me1GjDheOlGy/F5G+IkvoZBvDKcM9LlVfk7+ZUL62PZ46TmpfR4/e7VIsiKaQDvaI+1V/nnrcsT/j5l7P0dcOQW0LQpEiIpbw2Yd7h7ebsHKocqsqiViKhVTsASIrSbz11F7PVljhu+wE0 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(186009)(451199024)(1800799009)(64100799003)(66556008)(66946007)(316002)(41300700001)(66476007)(478600001)(6916009)(4326008)(6506007)(6512007)(6666004)(8676002)(8936002)(6486002)(1076003)(26005)(5660300002)(2616005)(83380400001)(2906002)(2013699003)(38100700002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: emXqsPv3Rw8p1Zl5kqmE6zrXQ51cZVh9nbpcRKeG3A03bGfUGR3o70pLa8T2yxikJ9ezItaBUgrY+7m4HGj+dE7TIenoQtz0g+k3cpNmLsUsPNKns85VLMZUFTdYA9k7e1IibG4UCF3G1iEfkpnpth3q3W/5KSSZKkKSVtIw+MHbtdY4iNEgtM2GptS5steJ0TVpH2h0AKitvs8FMX31R5Tzwc2Pydj6Ih9exAKqmf9JPwW16ZT7yC0CZS09g6PmpUP56Jcwwa+IXOjrk+yAW5IJ375C0tlG0NrJo0s1f9PlCNHzPB6EltysqUZJXW5GLHV/wBtmFBYsSiidd39gUauYZN+0YhhShxF7a5GLz0tpueJP4EBNa7X/hl5R5LGmm83DrUZThzMzmZLhWUvk5StKwzlhvd0AoVM92ztMUzKCDbzjrmJNWBlUIgDe6p7/YTmg8PKYnNiTQcpvHvWWBVeLDGIgGtA4/yTn/SthB/N6RxS3TAyTNj1BLrtoDla4aL1mh2fxxWV3zMgbDaLfbE2Asg4FZzFE8RpIs3GLBpnk40+KjYEPCwUsoe4i5t6sM0iz1s51Zhxb1cnP+mUeFqHv1DcFuXx3VaBvNAXXPjRvK5A44mhmEpdsJt9CbnbO2uAuOh5hxHQzC01emZPAbbnpD/UF+wYy0MtrVXemsjqRwOp+EgQJibFIyzGLPeQkwNAj4slezmfLRhfj94QqBjIDdth2zxTJO6XetfU//7xVQpQpdFLu3LEr79yzvn9jWlRU/n2Kwk9psxpOLnJPAJi0ZRz5g+vq4M5sCXl6MHK22rAignNaHK0DhJ9TjFyjAGSGrO1ZUM07qdL/e2BpNo5G/RainN4hMpejs6LfYwM0bkxqxWytDKUC/9WpBlDU013sNcB2uSFzRcd18nRYPwpJwZq4py4MSlUK2MLJqek1ScyzpDAIvyNFl78YLx5FIpPOlXSpDG7qPgsOSoOW4wJJ1IKuh83p3vjWPMPVXI4B27Ob7cB/2cBWMu9dMyHoqyKpZR2dxBdguMr4T8M3FatYN/NDx0PKSz/k1zTiEFtRsziNS/bqr79DDlUTQ8ZjzXVePSCAhBO0jc8STl96Z5HLiBecFuYPqE4x1vUdSYsMPYBmpShGClUZSkIstSbetPuEzczOK0qk6Zh/rCo17/kMZbu6ruL4VsyJCbmbZf/CbWHjlMb4z1tAdnp7fbkwm0I+Uf4qYr9BUwSiAg1UMWbJDp28z6vxTznhXyl7VJ9x2ysA6bZP49AQTxdjy43RyM+DJ2rVVDayh0GNJ/HgUqF9cEjDJd/yxXfPZk5KXjtVRCrperZdx0GygMy4yTizo17us2OD7Cpx4P3nzHfdM/i6/Fz8cwEcTa/y0hc1lij+1Mrs3OuQWMoF+m7taqXNs4g7D4rqVIrI2kplL0ZdclLbWpktUN/7hfWDWh0ltboVIaM4AU2DlOh+RbgEmM7Bk1cHt1S4ylkHHe7RnOmByF8fUv/MR5u/8TaK5EFIUXEeT9iHOYAl8D1VFpKAVGyKiNgdc5Q91+DFRPd7NzrlLBoKOkFVRtmj0/qEu+hSdG5m/f0d8gVLe+DjPi2aWZgw3+ROcN/gPEdd0/9i4iKy8w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb1eeae7-7c05-4061-c95c-08dbd632fff1 X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2023 14:51:13.6934 (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: 6GqbuOlZVUUcCxtzvbiKBkNPnkt89fcCCUmnEaYALPdXjWsblXMpU6Qwa04+iufxcHlbcmgr6secdg9NZyWBvEDpxFjzwPK7L6hTRcMqkrs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9939 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add support for multiple BISes in broadcast source and sink --- profiles/audio/transport.c | 49 ++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 23ea267f6..dff73e0f7 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(), @@ -686,7 +692,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 +1282,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 +1390,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 +1430,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 +1507,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 +1527,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 +1572,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 Thu Oct 26 14:50:47 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: 738765 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 CF910C25B6B for ; Thu, 26 Oct 2023 14:51:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345339AbjJZOv3 (ORCPT ); Thu, 26 Oct 2023 10:51:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345330AbjJZOv1 (ORCPT ); Thu, 26 Oct 2023 10:51:27 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2042.outbound.protection.outlook.com [40.107.7.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E1391AB for ; Thu, 26 Oct 2023 07:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P31p8JFC/NS9oSSXb0apH2I9lHfPunGrSjce8qkosRpRGlK3z4aJPAtnUFgRr0VMW4FKPigEbp1tnwIJaLDKbDL6++qyognDtAS95whPlzzpuKXkfM/erQuAhPrqPIZMLnL3VqhbS34/Nq+qD2L+NB9lnY3nyIvQbRFVIcWh+LEulDSMQFgStKcHuRDaqAaKEjufRL3kpHSRtdfMzARaMJ4HGr88wJO4vjX2T2Kz5ZD/h6UIcsgH+xNEKw7VxxiXOeuyzB/LUniVyFhfhTSOqYDIwaiQUagWvOTeFo2xeIH3R6Q6w22C79oHtgdZgaZaPYBiWmvnfEv3Yx8/Bp3BJg== 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=46UoylzRrssOQO0M/LJs8Mju8Ky/Xiiz74VnLZawUig=; b=nGJZHM1QIJstKz2kbGadQQ8SikBhQ+yby43IOnaPVYMHvupsCN2r4OvVSDolyC/RG4xYbDpat05MY+r7S7yrJ0fzjpXkG1AgK8jTGbr7RpmSYBNMBuaAZC4z2EY/gsDVqJuCYEQ7aXalrhRfFziqd2t3BuBQduSB27umjS39wQoZiA5Y/gnjBnp0J8H43R9tTXbpUPC9GcJRf3ip11oriNgFqKShrGr+706sM9xNkGDjMPqGvpHLtZTi1hPylaQzgbhSyHAkIWPZk0tCjdZgJ/MKUmSV/B6ImqRMDfjyc6wolrf69abX+wenzRDoqVuKw2TIUFjawCOQ/OsV7tIVTg== 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=46UoylzRrssOQO0M/LJs8Mju8Ky/Xiiz74VnLZawUig=; b=h720WVacku37xPfy769UMX4GmMrCaYylnx2f97fdjofxb+WvOFYevWMSP90A9+9H1wvEMw4tBTheuIxW6glJDiZWNQRoPgzVtOPLPap6eI84raWYL5xdadQsx8V8/gjKaLH3UcKNsONTwhJmlJpHoTN+bxqXIzsFfXpSyf5kxwI= 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 DB9PR04MB9939.eurprd04.prod.outlook.com (2603:10a6:10:4c4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.10; Thu, 26 Oct 2023 14:51:16 +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; Thu, 26 Oct 2023 14:51:16 +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 6/6] client/player.c: Add support for multiple BISes Date: Thu, 26 Oct 2023 17:50:47 +0300 Message-Id: <20231026145047.4637-7-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026145047.4637-1-silviu.barbulescu@nxp.com> References: <20231026145047.4637-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: VE1PR03CA0001.eurprd03.prod.outlook.com (2603:10a6:802:a0::13) To DBBPR04MB6331.eurprd04.prod.outlook.com (2603:10a6:10:ca::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR04MB6331:EE_|DB9PR04MB9939:EE_ X-MS-Office365-Filtering-Correlation-Id: 519c5b50-cb31-45db-3e98-08dbd63301ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +6nzozVq5jU0QJZBn4GOdKOlEoy+jy4aFDDEcvhjQGn1ez4sUNctmRa0VOJ+Ee41PoZ7l2eXFoUgReJnwVdFCtPzjzyTyIp0AiuYIqM/djts9JTsDpMujr9zPjV896Qynfz9oCjWso/Qk7gBIU+xar/0b6Hui9lW5mDHJQ90fTVLjy00INuny6O8iDFJK7CpZ69ZhXSNjLlqE2ZEa2iUD3ub9WTBE8JsLNdQWDjtCcm29tD/mWsYCrldApwSbQqf2dn2jc1q3fCq3TZik3OkVZZjxTn7kTbx4ZVk4cZZiF8UrlLBb/Cm9ovkWNWsEmV4FbS6nPm47Vt1hivkKkvlb7HyhjPNF2UV2HZsTZ7+06wXSTe9rNOKDxtvekAXLhH7ktN9NRxbg3efkcziIn6jCXGJNdSByLd8qS6QqS/0cCxafgEGPr6m7lT9ymXUdgBYJJMr5dQNHHDtdZ7UJ0TM0E28BZQDjtfUZePGZrz2fsLwNHy13miYBwkI0ZiYpcBHE/ZJB6ZoAo2z3+AdErDQVEXsLeY3X5C2nwG6GKuIBQGLI3+6oBlxJQ+utuoL3Xe8 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)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(186009)(451199024)(1800799009)(64100799003)(66556008)(66946007)(316002)(41300700001)(66476007)(478600001)(6916009)(4326008)(6506007)(6512007)(6666004)(8676002)(8936002)(6486002)(1076003)(26005)(5660300002)(2616005)(83380400001)(2906002)(38100700002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vrzgiOEeeM+gkmDP0CDccfk6ccl8M2rjuzm9lktOy4VUgNEApHVQ2Vcyx9EPqbhPmgcMXgtrzElT+Qg1uiDZDyJ31Uk6oJqjuc75F6owyEQmAF9KRGlrrf+kI1rp5mL/X5c4J+qU+h05XyXP98KMUwAy/z4smjnRKrXHbtegd6laIqM9G9VnkhpsgEQCgLlMIQnaTcXj8EkDWih599AYBiMbpHxbTrFV/BXpJf4zB7rI7H05hY/bUsb5kM8+GVefeKfc5Hg5Gp/SElvrDMUJBj7QE8ZhvHoq0yOznU0ldKRH3ZQk0GTxANSz1ZNBGT5nhp9JN1g79Etx/blljMSoW5TUs+cvzqIsihcfVeDB2I22KRGxyIYZ4WhBFF9A/lzqqE29I23oQwup7uDsXBKD7PBEBLvYPS1+zcuFUOWCBIMuSmbYO41aSRb7D6sn3R6aZIALsvIQbyln3dZnKG4qWmac8YfQOmeSLKlpHe0VF9iIQEZ3R0dDAId3gqzQx/YSVym8dcdl/9bLHRuRvtdJfhsNBl8gWFC3Cx/UkctT/ORkjKXDkdwaZ9OC25ODKDc4uXFqFmP3HxoSUVbF30zudFlqUk+Fp/RUv1ta+1/3Zu8zdDT1aflzOZG6p/0XCjMrPbt3SykGOuZVo6Uvu0A3tN2F3FVxNSy5MQbXvRwVXpcI2paeoOS2JfWgLXfgD5RrnPLgrky1Cth1gawwJkLb6o5u9KC+6s3NC6Nousuhm90P6pQEg5sAyhJsqonL2lcUNZ4vcp2DKHfg9uGBi4FNN47un2KbnzVDwOkXboMiBS1+D9iaV2QMaVMxnQ5W4h0yWSQjv9qEv+HYT6MsEoQFN37FO3T/LLpjskhbMlc4PpTD6z2+kZjb5NXhjEFWFjz7Xvsdhnrw5kdzELNcebWv9ielTQekmrwNu+d5qOmrhlaEnpmLZ5TsBtaed84+FkP+G/FJacEBdwr9DLX5TCIEs6+aiMjaP2Stb2ESAdkf5fH9hiu4Yo8hwMu2qY3hqmJWyKKijQRW38KrR3l6bW1ZSCXyN/1FuW8mnhkpuIaPBkVbfJNEXQIdSVS4Er/ppmon0fFBd9Ffa5WiPwFYsFPbftcf+ZOYOQNTKy3PrnjYT9nmP0PAwh42lrDqbrh/9g3Wum1iTA+z9ewO39oyN8L3nM/05CSZVLeaO6soFPupGVKFSE1eo6XDf0dq6z0aklaiv6bRcdOQWuaM9y8N+SEuvaZtTOE1kSyKGQJuZNmPiBH00Vm4r4MHBrPNq3oUPsnhaoPOXDpWRuVPvKhU7tCmvhky9EGG7VbabBY27lyFedRnKOiSUG9jr4cJNApX9Li3aCKCL/1dFnNOg47H1Rku5O228hw1wK4kjk/AUdnunk/Lx+evXRaLCNle51C/G4+Y6NACBprE5stIykwbEq+SwLGiD6VpvoQKT068P9Apb2KWCkstUANMYUmKAN28wWDxSEd4TUJuIkQpf8f4vFR8AckxTNRuIvceuF4oQNXEG2k6uBy0J8OPo8Pv4L8qYf3c+vPiRksEyQi+9xwVdtlyIOnpwXBKxnDq5+CcHzvtoekmWNsJn8Z7l3dvAnFUBXvnjvULTPBY3hdesrqKfoGPpg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 519c5b50-cb31-45db-3e98-08dbd63301ad X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB6331.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2023 14:51:16.4648 (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: CO2Jmis/ZfKfFN0Y8u2z3Lv4GscZssH0Ggj8/Ysh/ggAMxwirHd80Z702J11VIJGTbUYeBaqbvCKdwa7bvjI7llJIsjGnHpyOF0qzxCCNJg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9939 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add support for multiple BISes in broadcast source and sink --- client/player.c | 57 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/client/player.c b/client/player.c index 715598aa9..bf0338dfb 100644 --- a/client/player.c +++ b/client/player.c @@ -118,16 +118,16 @@ struct transport { struct io *timer_io; }; -static const uint8_t base_lc3_16_2_1[] = { +static const uint8_t base_lc3_48_4_1[] = { 0x28, 0x00, 0x00, /* Presentation Delay */ 0x01, /* Number of Subgroups */ 0x01, /* Number of BIS */ 0x06, 0x00, 0x00, 0x00, 0x00, /* Code ID = LC3 (0x06) */ 0x10, /* Codec Specific Configuration */ - 0x02, 0x01, 0x03, /* 16 KHZ */ + 0x02, 0x01, 0x08, /* 48 KHZ */ 0x02, 0x02, 0x01, /* 10 ms */ - 0x05, 0x03, 0x01, 0x00, 0x00, 0x00, /* Front Left */ - 0x03, 0x04, 0x28, 0x00, /* Frame Length 40 bytes */ + 0x05, 0x03, 0x03, 0x00, 0x00, 0x00, /* Front Left, Front Right */ + 0x03, 0x04, 0x78, 0x00, /* Frame Length 120 bytes */ 0x04, /* Metadata */ 0x03, 0x02, 0x02, 0x00, /* Audio Context: Convertional */ 0x01, /* BIS */ @@ -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"); @@ -3057,8 +3096,8 @@ static void cmd_config_endpoint(int argc, char *argv[]) iov_append(&cfg->ep->bcode, bcast_qos.bcast.bcode, sizeof(bcast_qos.bcast.bcode)); /* Copy capabilities for broadcast*/ - iov_append(&cfg->caps, base_lc3_16_2_1, - sizeof(base_lc3_16_2_1)); + iov_append(&cfg->caps, base_lc3_48_4_1, + sizeof(base_lc3_48_4_1)); } else { /* Copy capabilities */ iov_append(&cfg->caps, preset->data.iov_base, @@ -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; }