From patchwork Tue Jan 23 12:51:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 13527335 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2075.outbound.protection.outlook.com [40.107.21.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08B8F5EE6C for ; Tue, 23 Jan 2024 12:51:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706014317; cv=fail; b=dn4zEeyxNivO0IpDq8WjijHrSI1iCKGHj9oghfRypmhcN219e5Opb4b4ERIfwSO/+vaL9h6TwsLgAjhVUXqUd4YtwRegCbl/JdoTgITrYZGxwoUnPS/zzkqT3cC/2V4/CCSEJg6I0hb1MBYsjLDD0cohcZDCU9WU0jCFw9DGcG8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706014317; c=relaxed/simple; bh=cMAJaDBZu7Km7mOtvkEnwMMLXr1jPaXj0mN53UJ/fMc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=P0vR1jDrRiwSq5d5cqypi5zm+cCvADRA24ExpbhpPTsTmonFVQhWCGpKKH8SAbcU//chFpTK873YUxiNh0qf8J6G9ASiN9nOzmRInT1p5U69ecv1UbuHBlfAZg0dJ2Af3BjfS64te3evU4PagGcw2DZGaSCCU3NULwq6Z4vbytw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=WDs8tx6j; arc=fail smtp.client-ip=40.107.21.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="WDs8tx6j" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fVWUmF59+u1dyXsrKYku3jBa7EEJJOdIAM7cfc5DQoHxSFxxEO/KMmDQRDP5se75yEGJnDTn1w89C3S6eTq4siWJ0pVbs67JVi0g79CyU/Xwww/y2m7OVwDAWleeGR1Uhpxw9HY+OftBKkAJZc6vUwMvNyivCj4RRQrfBTvRP5YGYxwJHEp3ZZkl/nPZWDxxcYCl1WoUFDD2m442Pq7G5SQdAm4ahzJuOMvBzDp/fhXF5HwW1wlLlfUt5vy2R1HohXgvZdlf3Xc4FbjXjVsHQGqDXSw3m8nqSiAn7j9jlW+OVjUEaeQqVh09WWvqWzXzSXgaBUkvUxYGcp3490oyXg== 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=7f6c4Q8qv3ZGAvuUU9bSqmuj7/tms4VlI8e8roSkM/U=; b=YN1EGzbmTfLYHcfblPMExSsb+lnAP8yaX0FBewRHIMTuUH0oHVvtOPierA4Smy05XwuUFv46GxpYKE3xKkILEZgHa728chb8Q4RwwcNe+FxhBtxwgmNQt9TCmQvaPfPjpoeRykDNTqDjcws5atQN7ySPLJXUXc8+JyAMbCNu7iaKAWwb4Ay9T1EHBwfzeAF8FezWfrPJYJfWKOU42Dt1PVCX31msUG+dc3HvbTdzrxgxktTCXcoOoWnJf7llxWURglvS+0NxwzbZOudGEy3x4YhI5AO8fEXwIjAbogNjhH7F1gnHgg49rx9irWqt4qO5wJb4Tk/HFyqrIGAxaPZGsg== 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=7f6c4Q8qv3ZGAvuUU9bSqmuj7/tms4VlI8e8roSkM/U=; b=WDs8tx6jpipRtgdZOp02yAqRDN/M8jAkQ0corpuOhX2Tc3SstOFKATDz0v8aH/kT6ahv+V/fveK6KyGjlz7mOvoxcZGY7Xysh/mPnPjD11PqnA13hYAWnYXUJbrwX32KNCi9sOie2XfKJQ5DTwjNqSCdsbXqIctImnpB1zfsS1Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) by AS8PR04MB7864.eurprd04.prod.outlook.com (2603:10a6:20b:2a4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.36; Tue, 23 Jan 2024 12:51:52 +0000 Received: from VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81]) by VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81%7]) with mapi id 15.20.7202.031; Tue, 23 Jan 2024 12:51:52 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: 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 BlueZ v4 1/3] shared/bap: Code to generate bcast source BASE Date: Tue, 23 Jan 2024 14:51:43 +0200 Message-Id: <20240123125145.70371-2-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240123125145.70371-1-silviu.barbulescu@nxp.com> References: <20240123125145.70371-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: AM0PR10CA0039.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::19) To VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB10073:EE_|AS8PR04MB7864:EE_ X-MS-Office365-Filtering-Correlation-Id: b4fa05eb-3056-483c-5d9e-08dc1c12126c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Eyqdzgr2/kAPxspkAX82vn0eSpAihRI9GU0xSVcscJoxWFZePnfGC3i+riG2yqFJ2ItWXgvm+2vEL+EZyBgQ7TfnWnxAqIBCjAHA+GktIscKkS81CXVdMTqy4amn3C2N/yTY9VooiPqvxj55wuQ4YDFueHilsa+Suv7YqAld52DpEpQGtI8Z0tF81Ecabis6JlAjxMH505XGxBcRabqZ4n5a4go/bTDLlaHUbCT1zgmAOe7gfPAV4fonmP/YVobZcIxI1gwHUndWuz9+eQcmioXLC/V0dX5ExrT4z5QVt0TtCf6riM1v+XjP8syhXKSLt5rF8Nb3fzQJf1ze5iy4fUlXrJSQ4Qr4ayNcKSh7kNZ+zPjY/ohK5jXHIZbAHHLqc3A+exzCVDMm3LBlTzReXnMIxhqqFS470dEpeBAEH0EF/GsGKApn5jjYo9O/weLGuy38D2HzAVmA1cVRLLzziROkitEtDdB59+AuTUepnKvpuOvlec2zqNmXVNiq06TZW87XWUiCgGvmOUezIANVoWLZFt+Uo+doB0ESVDAbtMoUKbiX/QpSy2xmILB6kvm6 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB10073.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(376002)(366004)(136003)(346002)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(5660300002)(8676002)(8936002)(4326008)(2906002)(41300700001)(1076003)(83380400001)(6512007)(6506007)(6486002)(478600001)(6666004)(26005)(2616005)(86362001)(38100700002)(36756003)(316002)(6916009)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HnLkgpevYIAY/QUmOfx8qu6dK1+CHFWyS8Veo+ZMAWzDuzC7kP2FLoYt++47iWkHjDs3gp6PjJGAeuooaHWOEVRY5uvHEsbl88Tn5rzE8aWIkTM+V3yMoNigp6M1K2J9UflpBULVBKQat5wbIPjHxKd6T1wox1G78HfZKbHa8dUIP5q73WbzYqsyrEE5KK5dNNeCqWE/P4mm/z4eIvXdsZ89ARRgIAW6lT/TpvBApeExVXsXHT+bTY6RGGuqfwfSQuqGp/+wAV/OX7yK0IS3SyB1IWClcgsRZmBdKLe8loTISCKEQ/9C+Snx518FVXbqAufzRi06CVhX0PrFES/sTqmKlTOtD6+2CwaS7zSnqk5NJ/WuNyg3pBF1VyucJ825w9nEmD9CyS/MnEwJEe6fXAefkLVBnYmdfQwcvY3V6cfuEjOx1NeXl2CxROwU02FOhDQIbq8vOCvwASU7or4ZzcUg62/eCc52nTmmh4DjlsNkP9H1DJqru1JHLslv24LeSCON7Z5lrLUxqTyBzW1HjudbmYqwsTA3TtWfUCnoFJ9TnCGU3G04wVvx4ywXI25wAE5xzU3CJqvjgmyxQ69Uds9RYc2ObfzmRUsEJVR5ALIWcvbm+qmx8opHG59wLFYAGH+nXOeVzyxj+FJjjXc3zm2P3pFWCGTFE69P0ZWmlnUxTUjAPMLv1u+XJzdhe5C8DBdMU9KhqDQAilfMSOrYyeoY0uKhHtkN+v7+8buDIzxGSK4Ele+WXmvXOlr9otj0K8VXk7kkECb93xn7/OdHs8Iud9u9hezdSli21CqFfEpxX0qQgy7gqeNZSH/Y9XRRO44ozLGLThdXrO+uEIHs4myI0QZbnC3DhAt9mXIA8qFH9c+Net2mOUTIJFx8OZsPJ2eygIkr8er0g2QUurCgN62aSFICg+3sTNDEYTYZLdGXb11Rljk6SGf/a8bdDKKQwkR1aF19jMMzF9uKnUn8eds9vN5UntsDhwSxpJAwxM+KPKQxAutehYZ6UQ8MI0P9/x/Dk7A5TvvwQz+e5ce26yOpN24YSQl7r9+UXoeCeFNysGiWiXGCMUiFDedsinzI+9N97PlA4vqlgAgHXnvKViGtthCQ1EIMlesCkI97hsPlTiBmwOG6Uy8qNrDAn6KXyL77x9/af7Y22i5ZCyLmXdGseIgmbxIzFtwk00dUCJ00hBGCzekcUSD3lebmKx7XaeIMl7Th5M+3UKiCvynCbhZOhDO8rGOMlcoj8H1d540nq68CYVvtKAGDeeiaDL9zzE/EzoCysB5zHgOG8uIS6kgR1dmkA3hrNhgfuZkaNUqh2FO+0eOb/j3dJBCT8oQfFRo0fH3681jSmFXazRcMce4JZSjr9f7+O8y/IhCyNB+BEH2u2X4NzhWgOF4pOU33mMAUAb4aLEw/pgFYw/MsNk7xzPWOQaW2a0pQ2CEGWtJbTsmBcn8+Rx8245iJESramDA67R8HxnCmbe9KAMC/yXQ1yCIT8dP1QXijvujPoTEYMYUIODdIpITijDg5Bo+Cg/RjXW5JyAksoDa5X/Zkc9PiGou7qniEjzUcUJr6W2oPwKp3r+sj360QOyePH8F0Om57ADtmIDRdyGmA0BZ1TA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4fa05eb-3056-483c-5d9e-08dc1c12126c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB10073.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2024 12:51:52.4962 (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: /8dGSzZkx3kC7qR0fxWHmBfHCsykeVWXwML5LJNF5wrkb3wDtZu9ud1Ce9mOia5ou/UD+Dxeg9j8B3GWJAVBhpcreLvmvo/3ghcend1j//U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7864 Add code to support dynamically generated BASE from endpoint configuration. --- src/shared/bap.c | 364 +++++++++++++++++++++++++++++++++++++++++++++++ src/shared/bap.h | 2 + 2 files changed, 366 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index 49eb8d057..d56911e6b 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -255,6 +255,26 @@ struct bt_pacs_context { uint16_t src; } __packed; +struct bt_base { + uint8_t big_id; + uint32_t pres_delay; + uint8_t next_bis_index; + struct queue *subgroups; +}; + +struct bt_subgroup { + uint8_t index; + struct bt_bap_codec codec; + struct iovec *caps; + struct iovec *meta; + struct queue *bises; +}; + +struct bt_bis { + uint8_t index; + struct iovec *caps; +}; + /* Contains local bt_bap_db */ static struct queue *bap_db; static struct queue *bap_cbs; @@ -5492,3 +5512,347 @@ void bt_bap_update_bcast_source(struct bt_bap_pac *pac, bap_pac_merge(pac, data, metadata); pac->codec = *codec; } + +static void destroy_base_bis(void *data) +{ + struct bt_bis *bis = data; + + if (!bis) + return; + + if (bis->caps) + util_iov_free(bis->caps, 1); + + free(bis); +} + +static void generate_bis_base(void *data, void *user_data) +{ + struct bt_bis *bis = data; + struct iovec *base_iov = user_data; + uint8_t cc_length = bis->caps->iov_len; + + if (!util_iov_push_u8(base_iov, bis->index)) + return; + + if (!util_iov_push_u8(base_iov, cc_length)) + return; + + if (cc_length) + util_iov_push_mem(base_iov, bis->caps->iov_len, + bis->caps->iov_base); +} + +static void generate_subgroup_base(void *data, void *user_data) +{ + struct bt_subgroup *sgrp = data; + struct iovec *base_iov = user_data; + + if (!util_iov_push_u8(base_iov, queue_length(sgrp->bises))) + return; + + if (!util_iov_push_u8(base_iov, sgrp->codec.id)) + return; + + if (!util_iov_push_le16(base_iov, sgrp->codec.cid)) + return; + + if (!util_iov_push_le16(base_iov, sgrp->codec.vid)) + return; + + if (sgrp->caps) { + if (!util_iov_push_u8(base_iov, sgrp->caps->iov_len)) + return; + + if (sgrp->caps->iov_len) + util_iov_push_mem(base_iov, sgrp->caps->iov_len, + sgrp->caps->iov_base); + } else if (!util_iov_push_u8(base_iov, 0)) + return; + + if (sgrp->meta) { + if (!util_iov_push_u8(base_iov, sgrp->meta->iov_len)) + return; + + if (sgrp->meta->iov_len) + util_iov_push_mem(base_iov, sgrp->meta->iov_len, + sgrp->meta->iov_base); + } else if (!util_iov_push_u8(base_iov, 0)) + return; + + queue_foreach(sgrp->bises, generate_bis_base, base_iov); +} + +static struct iovec *generate_base(struct bt_base *base) +{ + struct iovec *base_iov = new0(struct iovec, 0x1); + + base_iov->iov_base = util_malloc(BASE_MAX_LENGTH); + + if (!util_iov_push_le24(base_iov, base->pres_delay)) + return NULL; + + if (!util_iov_push_u8(base_iov, + queue_length(base->subgroups))) + return NULL; + + queue_foreach(base->subgroups, generate_subgroup_base, + base_iov); + + return base_iov; +} + +static void add_new_bis(struct bt_subgroup *subgroup, + uint8_t bis_index, struct iovec *caps) +{ + struct bt_bis *bis = new0(struct bt_bis, 1); + + bis->index = bis_index; + + if (caps) + bis->caps = caps; + else + bis->caps = new0(struct iovec, 1); + + queue_push_tail(subgroup->bises, bis); +} + +static void add_new_subgroup(struct bt_base *base, + struct bt_bap_stream *stream) +{ + struct bt_bap_pac *lpac = stream->lpac; + struct bt_subgroup *sgrp = new0( + struct bt_subgroup, 1); + uint16_t cid = 0; + uint16_t vid = 0; + + bt_bap_pac_get_vendor_codec(lpac, &sgrp->codec.id, &cid, + &vid, NULL, NULL); + sgrp->codec.cid = cid; + sgrp->codec.vid = vid; + sgrp->caps = util_iov_dup(stream->cc, 1); + sgrp->meta = util_iov_dup(stream->meta, 1); + sgrp->bises = queue_new(); + + stream->qos.bcast.bis = base->next_bis_index++; + add_new_bis(sgrp, stream->qos.bcast.bis, + NULL); + queue_push_tail(base->subgroups, sgrp); +} + +struct bt_ltv_match { + uint8_t l; + uint8_t *v; + bool found; +}; + +struct bt_ltv_search { + struct iovec *iov; + bool found; +}; + +static void match_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, + void *user_data) +{ + struct bt_ltv_match *ltv_match = user_data; + + if (ltv_match->found == true) + return; + + if (ltv_match->l != l) + return; + + if (!memcmp(v, ltv_match->v, l)) + ltv_match->found = true; +} + +static void search_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, + void *user_data) +{ + struct bt_ltv_search *ltv_search = user_data; + struct bt_ltv_match ltv_match; + + ltv_match.found = false; + ltv_match.l = l; + ltv_match.v = v; + + util_ltv_foreach(ltv_search->iov->iov_base, + ltv_search->iov->iov_len, &t, + match_ltv, <v_match); + + /* Once "found" has been updated to "false", + * do not overwrite it anymore. + * It means that an ltv was not found in the search list, + * and this should be detected back in the parent function. + */ + if (ltv_search->found) + ltv_search->found = ltv_match.found; +} + +static bool compare_ltv(struct iovec *iov1, + struct iovec *iov2) +{ + struct bt_ltv_search ltv_search; + + if ((!iov1) && (!iov2)) + return true; + + if ((!iov1) || (!iov2)) + return false; + + /* Compare metadata length */ + if (iov1->iov_len != iov2->iov_len) + return false; + + ltv_search.found = true; + ltv_search.iov = iov2; + + util_ltv_foreach(iov1->iov_base, + iov1->iov_len, NULL, + search_ltv, <v_search); + + return ltv_search.found; +} + +struct bt_ltv_extract { + struct iovec *result; + struct iovec *src; +}; + +static void extract_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, + void *user_data) +{ + struct bt_ltv_extract *ext_data = user_data; + struct bt_ltv_match ltv_match; + uint8_t ltv_len = 0; + + ltv_match.found = false; + ltv_match.l = l; + ltv_match.v = v; + + /* Search each BIS caps ltv in subgroup caps + * to extract the one that are BIS specific + */ + util_ltv_foreach(ext_data->src->iov_base, + ext_data->src->iov_len, &t, + match_ltv, <v_match); + + if (!ltv_match.found) { + ltv_len = l + 1; + iov_append(ext_data->result, 1, <v_len); + iov_append(ext_data->result, 1, &t); + iov_append(ext_data->result, l, &v); + } +} + +static struct iovec *extract_diff_caps( + struct iovec *subgroup_caps, struct iovec *bis_caps) +{ + struct bt_ltv_extract ext_data; + + ext_data.src = subgroup_caps; + ext_data.result = new0(struct iovec, 1); + + util_ltv_foreach(bis_caps->iov_base, + bis_caps->iov_len, NULL, + extract_ltv, &ext_data); + + return ext_data.result; +} + +static void set_base_subgroup(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + struct bt_base *base = user_data; + /* BIS specific codec capabilities */ + struct iovec *bis_caps; + + if (bt_bap_pac_get_type(stream->lpac) != BT_BAP_BCAST_SOURCE) + return; + + if (stream->qos.bcast.big != base->big_id) + return; + + if (base->pres_delay < stream->qos.bcast.delay) + base->pres_delay = stream->qos.bcast.delay; + + if (queue_isempty(base->subgroups)) { + add_new_subgroup(base, stream); + } else { + /* Verify if a subgroup has the same metadata */ + const struct queue_entry *entry; + struct bt_subgroup *subgroup = NULL; + bool same_meta = false; + + for (entry = queue_get_entries(base->subgroups); + entry; entry = entry->next) { + subgroup = entry->data; + same_meta = compare_ltv(subgroup->meta, stream->meta); + if (same_meta) + break; + } + + if (!same_meta) { + /* No subgroup with the same metadata found. + * Create a new one. + */ + add_new_subgroup(base, stream); + } else { + /* Subgroup found with the same metadata. + * Extract different codec capabilities. + */ + bis_caps = extract_diff_caps( + subgroup->caps, + stream->cc); + + stream->qos.bcast.bis = base->next_bis_index++; + add_new_bis(subgroup, + stream->qos.bcast.bis, + bis_caps); + } + } +} + +static void destroy_base_subgroup(void *data) +{ + struct bt_subgroup *subgroup = data; + + if (!subgroup) + return; + + if (subgroup->caps) + util_iov_free(subgroup->caps, 1); + + if (subgroup->meta) + util_iov_free(subgroup->meta, 1); + + queue_destroy(subgroup->bises, destroy_base_bis); + + free(subgroup); +} + +/* + * Function to update the BASE using configuration data + * from each BIS belonging to the same BIG + */ +struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream) +{ + struct bt_base base; + struct iovec *base_iov; + + base.subgroups = queue_new(); + base.next_bis_index = 1; + base.big_id = stream->qos.bcast.big; + + /* + * Create subgroups with each different Metadata and Codec + * Specific Configuration from all streams having the same BIG ID. + */ + queue_foreach(stream->bap->streams, set_base_subgroup, &base); + + base_iov = generate_base(&base); + + queue_destroy(base.subgroups, destroy_base_subgroup); + + return base_iov; +} diff --git a/src/shared/bap.h b/src/shared/bap.h index 51edc08ab..2c3550921 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -88,6 +88,7 @@ struct bt_bap_bcast_qos { uint16_t timeout; uint8_t pa_sync; struct bt_bap_io_qos io_qos; + uint32_t delay; /* Presentation Delay */ }; struct bt_bap_qos { @@ -321,3 +322,4 @@ void bt_bap_update_bcast_source(struct bt_bap_pac *pac, bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac); +struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream); From patchwork Tue Jan 23 12:51:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 13527336 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2075.outbound.protection.outlook.com [40.107.21.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82FFD5EE97 for ; Tue, 23 Jan 2024 12:51:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706014319; cv=fail; b=O5p8aBXOKRdvxCJ95nN62SDRUUmywVKpxt6E2h2OQlSwZpvHZg27wnTan5R0E2XCyETle95Yoc2cTRhRd38TWhslQHHqze62RpeHXMuuH3qbOdseqh53RM0fSx/bP/MM5J7n+UN9iamPh6tlAoMdRZSa3IAGwzNQvNgMZBNDAKU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706014319; c=relaxed/simple; bh=ZJ2GS3wokN043gPS02tPZb1yXmr/6o7okwFRjJM2nwk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=JjpnhAj7aCAqZGS/b18OY18BuM/0TnHDLcgwLEQs2UsPFWC3W50QsHBznx4zllOnEugnPtBbbtD3bu3pjHxW0JjM70+zw/QhRSxU55YdIEmT2zTCwnPAOZvUQ8HSBAKOOvWEj23BZFMPiYRbS+kDCcGnpIUdeKT9sg6ubRSSyq8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=CU+hp47c; arc=fail smtp.client-ip=40.107.21.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="CU+hp47c" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JlpkB9y4QNtcOC0H4wgAL78eBSCwMivbhmi8E49cY2LpM7Y6R6QSyoEioZ4p3ZEjJkro0vRt4PRmvQHy34BikMT/Dcw3XkTE7lAU5U3ZNi66t/9g9GWsht7NvOcK9KxImH/poZOaniFK4elMH0o3ddD8gddh9i70bERbCiLhzSRHOSSyjPBIs3Z9PUeBXLwCasJilUKN1mdJRK85fTfZgEyD7Ju8IwNiljkEoFb6TlZzaF0b3LKSe8hKgVFEifw6Bn1It7ZwRHBqmlw9D1dRIh9tRE9lVFPsuZdUoDYFDrO0Re440OULGpoVsBUmfSvJgXnRgI1Nsm1wJnjxABhjdA== 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=l2TuUu37+KUMc1GodPeNEpXticwqsZbzRNnx8msHobA=; b=YUow1VnogQdLzQfTK9+mFMZgQ+8rAvceU8A4qkN0VyitIXlQwCEjkAty4zznycbLGdFN+78b8nU5pH9qsdaQq2t9hAf0q1Sdr8EN3xSKdqF3stbnWL9i42b1eRJmIjHLb7TOrISgXoBUNJ+qHJKMDAK2D6dv0h1Vi/YL3aTBxSK6Y0b2OLhX8k+8blIjBvjgta7cgEkTUng7pmBaTh469REqQmccd9JBAIWKnWfuWGUygMp8ySrfuqXq8HluIopDovCJ7sUiweqZsh+n05DxieG0Qol8HVwwBfyVqbiWmwycT4gDLK4NZUSnU+mnUyTMjslpPhlHxTAxVUrAa760XQ== 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=l2TuUu37+KUMc1GodPeNEpXticwqsZbzRNnx8msHobA=; b=CU+hp47c4l1eI9feaxdceFSt1c8/voM3nSSNiW6ZkOY/WUKpS7i9HDdguaHnuX566E8wyJ68gnCjh3bis72svhv16fjHMRf8C5KLaOwLTAdTAhOrfZiBcdIhKDUg2YhDsOYpVirisiHtJ/NKQU3Wj5NeF2Aps+dcgwv2dCwkfZg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) by AS8PR04MB7864.eurprd04.prod.outlook.com (2603:10a6:20b:2a4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.36; Tue, 23 Jan 2024 12:51:54 +0000 Received: from VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81]) by VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81%7]) with mapi id 15.20.7202.031; Tue, 23 Jan 2024 12:51:54 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: 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 BlueZ v4 2/3] client/player: Remove hardcoded BASE from player Date: Tue, 23 Jan 2024 14:51:44 +0200 Message-Id: <20240123125145.70371-3-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240123125145.70371-1-silviu.barbulescu@nxp.com> References: <20240123125145.70371-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: AM0PR10CA0031.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::11) To VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB10073:EE_|AS8PR04MB7864:EE_ X-MS-Office365-Filtering-Correlation-Id: 11c437a3-ae9e-4cb8-3e99-08dc1c1213b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aWCEKzXrfuNKTe4ry0Z5xma0Nd73wiFxv9FfGkFzTcPjaayk1YiaGM5vH+aREOrpz9AyZ5DDCBG7ockMuWEQv4/Y6n1nmg/DffT04snZnvB24rBXEPjsFo9GkO1Ie/aXbpWP/txzZZV9cZvVFVD92BIyeMJVQFFylGxRq/elSZJk/HUOpj8/SIJ4fYQVUemTk6FzVQmlqy4MW4qtd5ILcKu6kNLydyvn4SNT4CvYlgTto6I8TLVIQd90RAu+kPiUB8XOGaTq3e8E3sN+EyzIgMGsWRtIIrrdpTPOL2xmA8SaEgR6pd6uWzuNBOq8Ia99ma59I6LKPvDb2Pw3EFkyzLGOqojvuDwNnha1IgQ63Ca4gl96Ez4EG70cZoGoSrqIJ4kzro+9Dy+NFlTkwLblnhMbUP/Y+OI5b682qgEvlFcVKMUl6wlGeizaI24bLU1Oepxg+FBBerJECCsFqovq5Wj2K3Gx/2Z56ZAuhmzuUUulGnKK3r2baJAhmOuTRV1eu5TQF5MYSJZZNkzuZOVaA8GWGzeS5sndRVL/7fOGDROjjivQHWcjnEYAG0qEAo14 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB10073.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(376002)(366004)(136003)(346002)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(5660300002)(8676002)(8936002)(4326008)(2906002)(41300700001)(1076003)(83380400001)(6512007)(6506007)(6486002)(478600001)(6666004)(26005)(2616005)(86362001)(38100700002)(36756003)(316002)(6916009)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0XXFGE8osNu3e+QHVlj2bd1jdBvfNfX1g+YuWwDxUda5dsVkbtfjYUd3U3HAxFLPX3tfc2eWlXpVCo6NZBVKSHpugqda+B7lshjFdOfpZZhDGOpR+BouKMAEC2Z9f3tnpf2cK70aPq3nIYEDY6pp4w4bxS7ITCpvDIwIdGKvJU5/6tIJ3CbQ/S6XTJG805PQJV7x6Bj2eUWBMeodXjkPVdvZt1HJ7Vm//NZ237Gt74qV7ZCmqpNk0duI+O+cDhr1WG3Q7B6AuJEXawwYTunU4D1gVCqL9yyBwxZZ05Q9vjq6ZcC2lHo8elDl/owgI1UEW3Gkg98L8xtuz6e6B9i/3aA3VXt65ZdG30mp7bt1tzABOBbbQ6Qy61EoU5jC7909Q83EfyAQT4Aoz7eTUJlvccnouprkPd/k1bypVQptZSPvWyO5a8I18QXd0oaW2qlembRoZUsnZcvYjSl8Fx7u8Ehpg8D6WY43wjjohFlUo2pnIbCEhyzyvL/FQR/BeSS5OsZnnhSLcko+2ECKRLZkULcisB0IVvJ5kbimHVJ2RfOTAH9oTuajgXxQH1LGi0X/5fp7M3CQ+au58ixoCxWInhoZ0vT3lgW1tHE0QfvrDNuVTUuNPg8Bmz3U+Afe/1MKH4uxeV0LCZ203Fr1nJboOBe1gSrPhoJFHp2PS45a8c9xOChjele3akRl/bW2EEsqhkycdNed7R6ksUUT12iXzcAzBmaayGoKK9Dg87GKg1ivMqL8jbAd5iVyWNR56XPDFQxBSh+I4+JFj0Szmc9d6rrO2+e1DvayzMt49bBFyV0NeRdsoKlzt+yETz1ADcskbHojLeNMTlLpH6+M/nl3GpGXWuK3s3vaz12wK8DM4boeQGREEaaNXL3GGU6OiCKLGjB4OBrdCUFa3FjxbUL4ziRXI97utb0b9Z1wf9SRrephXArFgGNuFVsOSGdX8bA1a3ZgME/RO5ihhPUpZE6/a360O2bOcM6teh1QS1uTn4lBQCGHdnT12IPeUjUJmqfCJwhI/HBaTCKQ39si04BWWXgjkG/2q6d1iGz0l+68vwd5xlXp10PdL82KnSn2UujwVjMYzUfOxkDA1xEEbNKYnc9jSrwHTRdjGnBw7UcTXEB/CWfP3d7txDAZgNeY5OiHx7+lp48OXa+sH24G9mpGiNi+UTVO2kHN0ZlzOLjLuTjORpoYFA7S1DDxN4lS2YlOeQmQqiVcfvAx4pK2qI35AODGdf3t1SOAevr4QEcfyTNtmTR+z8So/Z4WcnM+DMvm/Q3yudWWio6ppXBQqkJgAAupBfbGkMO3PQmKAe8kT3M94bZrFgsrG0J+iknalUs6soUzTXjV/B32+OcEwWtFWXE+ZHWDZVHi+wwMG/0a7TzcbEL4ViJfOZQ+tQWPCIA1rN5uT+Jjk3xCyQFlvQTDyANpMHpm7lPrGUVtokr9JoNPtxC3Qe90TQ2c4wUXE63aKK8a0GlQXk2wi2LVaYXPt0ljwSLQsLZeyFJ63PC+w2PFg4k6wt4wPSaifUZOrFMMlBGbMh4RCsjVp4kEiLrgQFxTvXYAskaTL56srH1cjiCmsk7NFTVCv32eatB31Pt53N+dgIL5FB9Erfo+whFNfg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11c437a3-ae9e-4cb8-3e99-08dc1c1213b8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB10073.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2024 12:51:54.7037 (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: VJArlVx0D1H/WIuVumQv2Ce8jIt0ouyXanQvDPrGyotobzK3px006c+H2DNZSbLMyCOFSKI21CvGdjUBBOyQSFWV4go7J72m4Oq19E+5FME= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7864 Remove hardcoded BASE and QoS for broadcast and use the information from the preset instead. --- client/player.c | 153 ++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 78 deletions(-) diff --git a/client/player.c b/client/player.c index 1bc64af3c..623519209 100644 --- a/client/player.c +++ b/client/player.c @@ -94,6 +94,17 @@ struct avdtp_media_codec_capability { #error "Unknown byte order" #endif +/* BAP Broadcast parameters */ +#define BCAST_SYNC_FACTOR 24 /* PA params */ +#define BCAST_OPTIONS 0x00 /* PA Create Sync */ +#define BCAST_SKIP 0x0000 /* PA Create Sync */ +#define BCAST_SYNC_TIMEOUT 0x4000 /* PA Create Sync */ +#define BCAST_SYNC_CTE_TYPE 0x00 /* PA Create Sync */ +#define BCAST_MSE 0x00 /* BIG Create Sync */ +#define BCAST_TIMEOUT 0x4000 /* BIG Create Sync */ +#define BCAST_CODE {0x01, 0x02, 0x68, 0x05, 0x53, 0xf1, 0x41, 0x5a, \ + 0xa2, 0x65, 0xbb, 0xaf, 0xc6, 0xea, 0x03, 0xb8} + struct endpoint { char *path; char *uuid; @@ -127,6 +138,7 @@ static GList *endpoints = NULL; static GList *local_endpoints = NULL; static GList *transports = NULL; static struct queue *ios = NULL; +static uint8_t bcast_code[] = BCAST_CODE; struct transport { GDBusProxy *proxy; @@ -140,22 +152,6 @@ struct transport { struct io *timer_io; }; -static const uint8_t base_lc3_16_2_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, 0x02, 0x01, /* 10 ms */ - 0x05, 0x03, 0x01, 0x00, 0x00, 0x00, /* Front Left */ - 0x03, 0x04, 0x28, 0x00, /* Frame Length 40 bytes */ - 0x04, /* Metadata */ - 0x03, 0x02, 0x02, 0x00, /* Audio Context: Convertional */ - 0x01, /* BIS */ - 0x00, /* Codec Specific Configuration */ -}; - static void endpoint_unregister(void *data) { struct endpoint *ep = data; @@ -1879,37 +1875,33 @@ static DBusMessage *endpoint_select_configuration(DBusConnection *conn, struct endpoint_config { GDBusProxy *proxy; struct endpoint *ep; - struct iovec *caps; - struct iovec *meta; + struct iovec *caps; /* Codec Specific Configuration LTVs */ + struct iovec *meta; /* Metadata LTVs*/ uint8_t target_latency; - struct codec_qos qos; -}; - -#define BCODE {0x01, 0x02, 0x68, 0x05, 0x53, 0xf1, 0x41, 0x5a, \ - 0xa2, 0x65, 0xbb, 0xaf, 0xc6, 0xea, 0x03, 0xb8} - -static struct bt_iso_qos bcast_qos = { - .bcast = { - .big = BT_ISO_QOS_BIG_UNSET, - .bis = BT_ISO_QOS_BIS_UNSET, - .sync_factor = 24, - .packing = 0x00, - .framing = 0x00, - .encryption = 0x00, - .bcode = BCODE, - .options = 0x00, - .skip = 0x0000, - .sync_timeout = 0x4000, - .sync_cte_type = 0x00, - .mse = 0x00, - .timeout = 0x4000, - } + struct codec_qos qos; /* BAP QOS configuration parameters */ + uint8_t sync_factor; /* PA parameter */ + uint8_t options; /* PA create sync parameter */ + uint16_t skip; /* PA create sync parameter */ + uint16_t sync_timeout; /* PA create sync parameter */ + uint8_t sync_cte_type; /* PA create sync parameter */ + uint8_t mse; /* BIG create sync parameter */ + uint16_t timeout; /* BIG create sync parameter */ }; static void append_io_qos(DBusMessageIter *iter, struct endpoint_config *cfg) { struct codec_qos *qos = &cfg->qos; + bt_shell_printf("Framing 0x%02x\n", qos->framing); + + g_dbus_dict_append_entry(iter, "Framing", DBUS_TYPE_BYTE, + &qos->framing); + + bt_shell_printf("PresentationDelay %u\n", qos->delay); + + g_dbus_dict_append_entry(iter, "PresentationDelay", + DBUS_TYPE_UINT32, &qos->delay); + bt_shell_printf("Interval %u\n", qos->interval); g_dbus_dict_append_entry(iter, "Interval", DBUS_TYPE_UINT32, @@ -1971,59 +1963,54 @@ static void append_ucast_qos(DBusMessageIter *iter, struct endpoint_config *cfg) static void append_bcast_qos(DBusMessageIter *iter, struct endpoint_config *cfg) { - if (bcast_qos.bcast.big != BT_ISO_QOS_BIG_UNSET) { - bt_shell_printf("BIG 0x%2.2x\n", bcast_qos.bcast.big); + if (cfg->ep->iso_group != BT_ISO_QOS_BIG_UNSET) { + bt_shell_printf("BIG 0x%2.2x\n", cfg->ep->iso_group); g_dbus_dict_append_entry(iter, "BIG", DBUS_TYPE_BYTE, - &bcast_qos.bcast.big); + &cfg->ep->iso_group); } - if (bcast_qos.bcast.bis != BT_ISO_QOS_BIS_UNSET) { - bt_shell_printf("BIS 0x%2.2x\n", bcast_qos.bcast.bis); + if (cfg->ep->iso_stream != BT_ISO_QOS_BIS_UNSET) { + bt_shell_printf("BIS 0x%2.2x\n", cfg->ep->iso_stream); g_dbus_dict_append_entry(iter, "BIS", DBUS_TYPE_BYTE, - &bcast_qos.bcast.bis); + &cfg->ep->iso_stream); } - bt_shell_printf("Framing 0x%02x\n", bcast_qos.bcast.framing); - - g_dbus_dict_append_entry(iter, "Framing", DBUS_TYPE_BYTE, - &bcast_qos.bcast.framing); - - bt_shell_printf("SyncFactor %u\n", bcast_qos.bcast.sync_factor); + bt_shell_printf("SyncFactor %u\n", cfg->sync_factor); g_dbus_dict_append_entry(iter, "SyncFactor", DBUS_TYPE_BYTE, - &bcast_qos.bcast.sync_factor); + &cfg->sync_factor); - bt_shell_printf("Options %u\n", bcast_qos.bcast.options); + bt_shell_printf("Options %u\n", cfg->options); g_dbus_dict_append_entry(iter, "Options", DBUS_TYPE_BYTE, - &bcast_qos.bcast.options); + &cfg->options); - bt_shell_printf("Skip %u\n", bcast_qos.bcast.skip); + bt_shell_printf("Skip %u\n", cfg->skip); g_dbus_dict_append_entry(iter, "Skip", DBUS_TYPE_UINT16, - &bcast_qos.bcast.skip); + &cfg->skip); - bt_shell_printf("SyncTimeout %u\n", bcast_qos.bcast.sync_timeout); + bt_shell_printf("SyncTimeout %u\n", cfg->sync_timeout); g_dbus_dict_append_entry(iter, "SyncTimeout", DBUS_TYPE_UINT16, - &bcast_qos.bcast.sync_timeout); + &cfg->sync_timeout); - bt_shell_printf("SyncCteType %u\n", bcast_qos.bcast.sync_cte_type); + bt_shell_printf("SyncCteType %u\n", cfg->sync_cte_type); g_dbus_dict_append_entry(iter, "SyncType", DBUS_TYPE_BYTE, - &bcast_qos.bcast.sync_cte_type); + &cfg->sync_cte_type); - bt_shell_printf("MSE %u\n", bcast_qos.bcast.mse); + bt_shell_printf("MSE %u\n", cfg->mse); g_dbus_dict_append_entry(iter, "MSE", DBUS_TYPE_BYTE, - &bcast_qos.bcast.mse); + &cfg->mse); - bt_shell_printf("Timeout %u\n", bcast_qos.bcast.timeout); + bt_shell_printf("Timeout %u\n", cfg->timeout); g_dbus_dict_append_entry(iter, "Timeout", DBUS_TYPE_UINT16, - &bcast_qos.bcast.timeout); + &cfg->timeout); - if (cfg->ep->bcode) { + if (cfg->ep->bcode->iov_len != 0) { const char *key = "BCode"; bt_shell_printf("BCode:\n"); @@ -2036,6 +2023,7 @@ static void append_bcast_qos(DBusMessageIter *iter, struct endpoint_config *cfg) cfg->ep->bcode->iov_len); } + /* Add BAP codec QOS configuration */ append_io_qos(iter, cfg); } @@ -3667,22 +3655,31 @@ static void cmd_config_endpoint(int argc, char *argv[]) goto fail; } - if (cfg->ep->broadcast) { - 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)); - } else { - /* Copy capabilities */ - iov_append(&cfg->caps, preset->data.iov_base, - preset->data.iov_len); - } + /* Copy capabilities */ + iov_append(&cfg->caps, preset->data.iov_base, + preset->data.iov_len); /* Set QoS parameters */ cfg->qos = preset->qos; - endpoint_set_config(cfg); + if (cfg->ep->broadcast) { + cfg->ep->bcode = g_new0(struct iovec, 1); + iov_append(&cfg->ep->bcode, bcast_code, + sizeof(bcast_code)); + + /* Add periodic advertisement parameters */ + cfg->sync_factor = BCAST_SYNC_FACTOR; + cfg->options = BCAST_OPTIONS; + cfg->skip = BCAST_SKIP; + cfg->sync_timeout = BCAST_SYNC_TIMEOUT; + cfg->sync_cte_type = BCAST_SYNC_CTE_TYPE; + /* Add BIG create sync parameters */ + cfg->mse = BCAST_MSE; + cfg->timeout = BCAST_TIMEOUT; + + endpoint_set_config(cfg); + } else + endpoint_set_config(cfg); return; } From patchwork Tue Jan 23 12:51:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silviu Florian Barbulescu X-Patchwork-Id: 13527337 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2075.outbound.protection.outlook.com [40.107.21.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 192885F54F for ; Tue, 23 Jan 2024 12:52:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706014321; cv=fail; b=HKXa0qF4xhp3ZBGhHI31wIyIYwln+slx4UNKArC2Xfpi7SdN4pZrzeUSgNq1bIydGjTKdpCEdxtSOdMAvzKVcaA9mM4Sg6XoKJ3OfTF00ySk0kS4TK7RUvWZw1Ul+sOs1RpFXz3/IEs2MWSlLxlgO176Ra2j8ZYSEZTwQIkXLG8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706014321; c=relaxed/simple; bh=wh6h/IuEpt+P2DTNpIf5fQuuR01n1aDe91PSuob159E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Gsww45uN2GNhn6HkFX9pR2tXefN2kdh1icrazoTaUwsiqlBGGLiSGTmgawByN7cHuONKr09flVPz3sEFrXhA6iUc7ffCGLkJ5kw2ECeVjAWGX/Kbk8/ohUN5vI2n2SpzwHaVF/zhky24G0pGZaLaGsLG4oMgBV4rroVRdpRLnSI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=G2vySLr7; arc=fail smtp.client-ip=40.107.21.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="G2vySLr7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jf7BHVoJhdiO1G0a7bZMxKWSmq9j6oUwgnBU1nt0jE+etCA5VMA5Tl47tExEsW8EAYpBazeGEp4iGNClIkFfWaFzjMnkB44IGCiV9kPo9t8JYL//QEezeADHwcS+nfZ/INLHq/GwngD8Zb6hnynXUngnSeS1Ih2m13qO3/kBaO2FP0jMrPAWAb7RwCOFgRK4mN1NY3DwwcOfWd1R6beMok53E2EpzZ3aqV0b7mpKT7DpQeYMJIXW/yoLZ91hYuT6uiMJXShja5HrriDRbGNTnTHQgR0UKXwM8tXuIuR5JfuoWTi9wiuI4R7hqt624IGddgoLyVDk6gbojnCeSnyJMg== 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=nJ8BuVhcVHgIjL8L0RHqr+AdFwZqyvpb1wBaB2Z/t1Y=; b=ZyoQfVjbB21z/eiXCykfpx9XmGmybaEmVIcB87pvh82GyiPyvnGcWSIlL8R7SrzHtqodcexgKHUiY9DuuAaPpqs9R+8NLqL7t9y89Qxby7Isdlw1ab7AWxaKu6V82yBqM96HmilkUnyiRSH3cYR6yRsMebVg7xGlqBqCRMsbagvuBziKI1vGha8odVn65FEaFugab2mWctyunUNe1hz41zF4eEUsDw/G54JpL5NiPhv0cdhjeC1uNiPS5R3K7bg9vhkxMLAeb9rqeYvre105R9+rJ/9NMFQ9e18iIyph9F9gykrsBttLsELlrtkwPZuwTnt4co9enAzvlFYI8lNo8A== 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=nJ8BuVhcVHgIjL8L0RHqr+AdFwZqyvpb1wBaB2Z/t1Y=; b=G2vySLr78ySsuYSacv1U/hwvZePO6RGGYGuyFQOe/CgAZzRftNvXe+zxKRcSdchkvztEOdE1SnHYJJzzlboTcjEsI0oStTlyBc+JcQK2awMIqGBAoyOoYhqiIJdecvt2xHuc/6KQQ22BtRZYR5ePhMSZmb/orM1NaMB2NygK1t0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) by AS8PR04MB7864.eurprd04.prod.outlook.com (2603:10a6:20b:2a4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.36; Tue, 23 Jan 2024 12:51:57 +0000 Received: from VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81]) by VI1PR04MB10073.eurprd04.prod.outlook.com ([fe80::c5e1:5be0:c78e:5d81%7]) with mapi id 15.20.7202.031; Tue, 23 Jan 2024 12:51:57 +0000 From: Silviu Florian Barbulescu To: linux-bluetooth@vger.kernel.org Cc: 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 BlueZ v4 3/3] bap: Use SetConfiguration info to generate BASE Date: Tue, 23 Jan 2024 14:51:45 +0200 Message-Id: <20240123125145.70371-4-silviu.barbulescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240123125145.70371-1-silviu.barbulescu@nxp.com> References: <20240123125145.70371-1-silviu.barbulescu@nxp.com> X-ClientProxiedBy: AS4P190CA0057.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:656::6) To VI1PR04MB10073.eurprd04.prod.outlook.com (2603:10a6:800:1dd::8) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB10073:EE_|AS8PR04MB7864:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b9e3378-1401-4fc9-ede9-08dc1c121536 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7+IYcKFwYeSGQFa+iMxfYO3Gxz5Ob5U3JBrW/FfO+vEOdHKYPX0jHvUf/Bui88hQAo7M8O7P2v3GL/8gu3A8Ld1iCC6hzPG7OBGEtnLo/1oYwY02GAMb1YkSIhaQx8DWEnvurYPbtRbWO4JDnhEXgCjV5fE4X21DTEP6yHvZD1VpbuCjmtiLwaRtTGNNTVEEAuLsYyKDFGqrlQU5Ea70lCE5YHcMU/bEJpVGBd4vtdIaAo8C0qgXJnOgAOfFHrN6fYRPmf4SEvXgNHEKXqxQ1jzWBONW0J2F2h5kHPi6BlhACn7bPsTzGMU0FeknfIIVnl8Ky0GWCOanuP4PZupmpHywvhrH4e4SppZ5nTsqDalRoYc3rmQb009KfIObCvPfab9/3tkJTDRsecPgQghTsMjCGPCIuslqVEPOSx4eA9Qw5HdhXhQIknic+wpB2t2ttgffbYIW5UrT2B+3uTZMiOe+E24rKd4FZBxxjYfACOrcUKD8L3qJnA3Sc9LkA0m5QbQZZFTGirFxeFDkPd+yV22hVii+MYXCnjk9EipfDcqsNaTaFpLh8/E53CLPoboR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB10073.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(376002)(366004)(136003)(346002)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(5660300002)(8676002)(8936002)(4326008)(2906002)(41300700001)(1076003)(83380400001)(6512007)(6506007)(6486002)(478600001)(6666004)(26005)(2616005)(86362001)(38100700002)(36756003)(316002)(6916009)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 26YpWIU4DFCsXgOaddtNrxNM5stj/VrqiBXl3lIc8GmK2FkQyGh2k9uYwcqELlAYIKVUxE/XDkSFZNY77NMlr455vCH4ClZ4zyu7eTm9FXbr0MP+AjNLx80FTo40J41zfZWzwYAeXsk9rqJCtWTD7uJR3tXi5A2gI1N7XF+858sErq0o14FqZi15h9eUR5qlsCdCP8WMb8YCcSjgqLfVcC3ZBRbLEGplre0MrfBERCxgqOX8Mw3JVQvMfRXP6AoCRDT+AKqEZEWqb8UYsOeOV2IqJfFhubkYmBZZCc6F2aHdHawga1pq7VbMCKXM61h1xQCZ5gqIkdAHRa3ZOasbKjo1Puwoj6TlE6j76MJgLUDjKnJz4cDGVsURIZ4W4JEST+/oWRKe8n1qOeDIIq0SZfbjeQ2KMtRHVuzhVqEVAaWzCdLKNFbU0UcysC4iFY5qCMKKDA/1sMbXEYNt1dNpKQnj518iBYOp3S+k7KEl8j8EezvJrAW3AyW0GDTtjT0k2+jKzSOdlMV0AE1KO+uEo9gYcrBy7tjtScc14GxI4nB+sqOflkb49+QtqdKFPiGuZEIIcdhT636dzQRe6J30exRZYqWmtTQhWE7d1NQkN+jtJOOoK8CxI2Tg3pngivlMJ6gTNkQ06LHuXxvm2NbzS1xg/zgen+zXkKArTxmhx08IfxbYibgO+MkHZuHl64fUxxl+4C/bM1P7bjJLJq4w/SzKSTu1pJ1xef1vI/KjGRg0WWTyMJZj+BOzhhM16G1PcqgrKo3Or8ZmovWdWiiPArb3j+sg/xphT/3xcGK9boUIADMkm722wTAepdhLHNQ0dWVxqcRXpB5wjOYGvvcG3wOryFVD8Fbvsm/VBN5K6Q5lojURUBG06MdEqmZM0xNiAKDooTN2BPbquty2osmuYVojCsGnbrjhQcrc4EEeCpLz0D5fJi6Gmt8gmI4GqLZm2hqm4xsoHptkn7NNOOZo6FBVOjPCY021Aoi3SI2Mqi4AznmsCnHpoFnRG9pJaB4ZFJr5gyvf07GYLr938QZYwfht9HBw4MF13BCG5iJFH7WIYIFUrRHGSmQ0kEkBgqqqjAU255+RwmawQZHQGhFP/V+mcjSvY73uN0C9FX5MAEk9er3l6WatxWXp/YasAOYcVs97jG5vy4tcZz+AHL2Zx+SNgZejUP8caIGRKt2L38ljDJbjLaYgRddmwr7Q+bawuRGcNttwSKSgoiIqeZDlYJxkGO78ifkXHqGmeP4Oc2BZ7+5VauTyRO5JZOyj5phm4EMGQpzRu11b7pVx8rEKweR/e66Jc7f/jvzq52pGphDWiXpNd66AGvI9YfZc0RoFvtHn2USh1s8wCQzTzk4rqF15l3nu3a6leqSXGW+PjA893ZqBR6MSUjLkr+T8o3KMCeBbY8YAY6WkBAtnNHnQ852g4WiWk1iu4ayNl5WWkrCipPouciHG+divWAFf1dvS6w5a12tmWD1qyrsIc0fpijo6G24V6vLjhxaSpMqP/uhannjlHRXghQXn48QC7djszhuurU/eUsS+Q3q9H9yYNLt6He7+bew8mAmvfsurFmn7WkNs8F5+9IlIUmJra9xw8wVn05JA8v06zcvECH3xcg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b9e3378-1401-4fc9-ede9-08dc1c121536 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB10073.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2024 12:51:57.2081 (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: PvB9EvxmtxWrXxWC3mBYwDez+DiQpJTR4XsY+zjP0/lMOFWTKFp2bqePlpHs7aMB+gFls3dy/A5SC7a+ym3sMMMGjTydaVspI9Drg98CfQ4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7864 Use the preset information provided by SetConfiguration to generate the source's BASE and not receive the BASE over D-BUS. --- profiles/audio/bap.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 8d44e48fe..63bdbb52a 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -610,6 +610,11 @@ static int setup_parse_bcast_qos(struct bap_setup *setup, const char *key, return -EINVAL; dbus_message_iter_get_basic(iter, &qos->bcast.timeout); + } else if (!strcasecmp(key, "PresentationDelay")) { + if (var != DBUS_TYPE_UINT32) + return -EINVAL; + + dbus_message_iter_get_basic(iter, &qos->bcast.delay); } else if (!strcasecmp(key, "BCode")) { struct iovec iov; @@ -666,18 +671,6 @@ static int setup_parse_qos(struct bap_setup *setup, DBusMessageIter *iter) dbus_message_iter_next(&array); } - if (queue_find(setup->ep->data->bcast, NULL, setup->ep)) { - uint32_t presDelay; - uint8_t numSubgroups, numBis; - struct bt_bap_codec codec; - - util_iov_free(setup->base, 1); - setup->base = util_iov_dup(setup->caps, 1); - parse_base(setup->base->iov_base, setup->base->iov_len, - bap_debug, &presDelay, &numSubgroups, &numBis, - &codec, &setup->caps, &setup->metadata); - } - return 0; } @@ -924,8 +917,10 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, /* No message sent over the air for broadcast */ if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) setup->msg = dbus_message_ref(msg); - else + else { + setup->base = bt_bap_stream_get_base(setup->stream); setup->id = 0; + } return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); }