From patchwork Wed Aug 2 13:23:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13338165 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 9C392C00528 for ; Wed, 2 Aug 2023 13:25:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234072AbjHBNZW (ORCPT ); Wed, 2 Aug 2023 09:25:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234053AbjHBNZU (ORCPT ); Wed, 2 Aug 2023 09:25:20 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2040.outbound.protection.outlook.com [40.107.7.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB37B199F for ; Wed, 2 Aug 2023 06:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W45+K8BISO6wsUBskgy1idfa8qdAiD82J65T+oElsMoRiXl3ermsy2Y/kGbfcZ3GvWE4Wm2u38yXFJ4yPOPSaPKE6D74kjHMFIoWj1nWhbFw3FXkPj1VY62CaI9F3qNm4fzIEecajKMIY/6p7mHmLU7CGHjm08/A98qZCM6ZczYKqkRpFegYkcODwXesRMVC7FQCpdjoPamv6OEtNXGkAIX4ghPXuB/nhPVmEeckrBcN/dkWrrxkiQAMpzXNXchvOzM51Belnpt0VuVQ6rgcSyVA+fGclA0CMhlAyT6s7PBUAm5d2BukmE8zMVq8xXnO/BVAS5oSSnqv5SZ40pcl2g== 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=cywR7JEzuV7zKrI1xonk74lSgQYfUdDI2o8FsJNsdxA=; b=doI/ij7wwriICgSSRdvo5WIxYxJoUkOJD8eoNn9sbFGxtdMcVUoWf36Aw/CxGMk2oq2xUBbO5VRu8pnTPpZVEUpL2zeViMy+XGpnlMTT0TWiAom/aSW7jBqkuqyCeiFKnmvkYYIrQlK/QiFsoLFZc+XUkeSw1XSlLQ8bI9Lj264LJUBEXisfrWmQBVJMTrK9v0DJeNGmoOBBAW60xhBgxOr4zmfp+DDwls4K7fcjW0utHi7nEattCehkNcaHtv2XToLAkvbKwVzOoDwz2kqVZ/LBVOKSj5BRi0LiegiIA13tihINE5K4z83HOC9yNsCDg7vcPKBnoNISsCvx7M0rNA== 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=cywR7JEzuV7zKrI1xonk74lSgQYfUdDI2o8FsJNsdxA=; b=chtdot5T9spLYPPpTp0V8AVK1ITUK/7XN3pW1T6WlPQM1DMkVdt350bLoOnuLuXx2XOi984v55MiU3RHT5Hjz5qJGno7+I479AAtsOxLJP+6RIfuWEKDc9u2XGrXOjrfHzEGDZiyhaLUrwCWlD0M6XjOqyf1OhGEYPJG4erijkQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by AM0PR04MB7010.eurprd04.prod.outlook.com (2603:10a6:208:199::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 13:25:17 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9%7]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 13:25:17 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ v4 1/6] client/player: Add broadcast sink endpoint Date: Wed, 2 Aug 2023 16:23:50 +0300 Message-Id: <20230802132355.4953-2-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802132355.4953-1-claudia.rosu@nxp.com> References: <20230802132355.4953-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P191CA0023.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d9::19) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|AM0PR04MB7010:EE_ X-MS-Office365-Filtering-Correlation-Id: a69111ec-4ce2-4c36-08e4-08db935be979 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kYvq2xdx/r7KK0lXYi/YDMFHfd4nXQjvsrYuj8Wb9boLlp4aw6smgECQ3N929qdIthq6H6/YLoIePg9lEOX2HLst4ED1CB5F3d4g/8aCVD+8bwp7kjtquc1s7b7hl2Qc4Y4yLQV4ikXfVnvpQUTkRICL9yuzI1Tq6TDr5bDLv+NKj2tplWmJ3oeQqKBF51cKGzwQ7iTBQF4yjE+Na58wMxr4dhcyahJihoVBAd3JXP1zXBHbcyuCUy5lFO7nNojXRnostEXArp4qF6/gVg3a0y0DJxD+PjhUHdhc0Qx4zIBj3nNDkid+NwkhGqa3y9MpI5BHKnZC3ZMUzV7fFQDRAxXG+45Cn2leqZf9mqpqGxrCIoO4Nf/Rda/DfDyOAYhNlNU4+y25Iuruwt6hpCJ1u1F2ebGvrSrKQiYBpmfOccaGCiREzUQ+r5cUvJMNDBHOLOxW6peclaiOh5za2jaGtbgZG3B3FxfHxRgrULNRr8fp+8xCkpUOyYRa4T854OjBmn+RQB+JR4LBrq6AiP/klePh/UFkZwVBzbY5O8yopUseOrvMV1cnRGnghdqhlFPkLlAwDYiAr393Bgg0qN004CfpHecdSEzyHw/KU+iF/zyk7n8H5ElxDYA2i5ot7Yk2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(396003)(136003)(366004)(376002)(39860400002)(451199021)(186003)(8936002)(83380400001)(8676002)(26005)(41300700001)(2906002)(5660300002)(2616005)(86362001)(478600001)(38350700002)(316002)(38100700002)(1076003)(6506007)(6486002)(52116002)(66946007)(66476007)(6666004)(66556008)(6916009)(4326008)(6512007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g5ZyTPaOBFKd63Ji1sAfF2/5blzzgjZM3393fWj9wcIchqRiUmDDwxd7U71xQmqOmm8btQ7wqZNY/kT5MtfUcDql05Jf1Itc1uKIZZGL3xjZv9ozFYJUyo46fiD67oNi7AsdO2AU+KzrHEdmcJlGTSE0aKlycRqwCCl/6Fw6HZXSaDWWH3g6muRUeou1EqSMH99/3EjoUSt01KSbOqOIEnrbn8g1FQGI+0LC32aUrsov/O4tj7iH2x6ilD+yMmfha0OxxL0MErrtuD1QyZt87mj6uwqJ++AF/KdqWeEsKC6WYLvN8GhyzdXC3aAVOgzRVsyY2NVtEHxme2tj1f+1G9EiMr2XV5XMLC9vb4+Y4CtUcpN+MVmP6csvSMplh9JuhGTZApyjTc+T/CcsqHO4gT4zS++OjsY130bUgOyJHqN2SELDikyvTk2344Y2ytBDQ/KmVfgChdRGjG3czZju0kLuORE7HtnEml/JHIFfnzZFlaszBgTe7AB/cWAN6nknMd/ZiBq79SBHlYZZK1Vtp3poeHqFmhgRrMRvDn+k4RQhYJMHZczuMt5cXWcjtB865x+aiVBTp0TW766Bv8uRjupVsFpL9R18xlvDkDCFwPG9sdVzz8ipk7rcYY/te8tHJDOuAFB9nTmQ0jd3nKF4HdA2R+sCPOC8GCIVIxdUrvbFG595HNUNlcSD8xQVkL+Z29H5cMmqF3CqX4ZG9rQEhf3zXgEKeToms5q67Qyp+mFC1DNhkAoaE0zxLkjSyoXiVXN+t8G16PThwYY+EXRyst/oiQh3Um0Z9IxcMica4ZBuR/ICdnQ1bKyNkzszlj/2KuCMuD1AEleVtqvnYib8T1H+MJWgy+oEHyR9BcdWlZgGeV2+duvLhFTGtHED4vVNPTYGhSGSeGKWNRMCrFjt/xD6CGs1kfgQ9X4jd8NZSI1+aEzzRsxWG4a8/JTAhG6GBmfO48DVjaRmFFeZASZ/H2vtq72ZruADyi/HUgvjaieZg9lB6Jbi1wSgb3wIDmTZUsWDFKHDv1Mmt9DyaqXZjpAjksDJgRjo80RFctHu/2JGf0LUOxfBlw1F4yKsTef9ih4Mr1Nju/eQ9aeCjv+4LUOoC6FDKcVQx5YDNOOew5/xKp2GXZDcPCD41GXcLb3sOoKEZr9BGSOIIp4DTHJNOMyVfG4MH+1osJiBnNNSW33Mqq9n3izQH4eurce/9HDmDzLISA6XTRqkEJWK3oHmcXQAbxkfsuaRNGgxi9dx+9w6TVHgTmu8T50IluYhLCGderlutvJFfScVWNx2BcH4AyWLZoKvbH3uKYvQ2cLydfkOtzPrgxLxGdW+7JhUAyKnHcy4zz3tr2KcxbMgYVOf8Kn5wdHeJEqLtS9mpFYcWneWrjGfTQCUBhju32JwtXoBzM+H8s3msdADPIAQTknMpyIVGK64acrG2STxiRfiB3eDmiZPT4ixigADQxj8EzSgUV9MZ69Ce6ElV6Y8MlR/7WnfF2wDmleC4/KRw+dilXjpmHHoGjcZeOIfEppuMNMuz7uDLmItzkgHbcmbXdVnf/gWTNPVpUv0H1h/UtJ9QgpDPpic9OqvPpvByVG1sVmS X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a69111ec-4ce2-4c36-08e4-08db935be979 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 13:25:17.3071 (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: syq5+xm1LNe4iDxh5msdOjI+fwbwGVDTur+SbfIN4o8Ggh4cwisnA8W0kfcUUb978hYiSkaxswdj3RX5S9SVYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7010 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Added support for broadcast sink registration using the 0x1851 UUID. Added support for remote endpoint creation when a broadcast source is discovered. Added support for creating a local endpoint when the broadcast sink endpoint was registered from an external application (Pipewire). To test this feature use the following commands: [bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06 [bluetooth]# scan on [NEW] Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0 [bluetooth]# endpoint.config /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0 /local/endpoint/ep0 16_2_1 --- client/player.c | 61 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/client/player.c b/client/player.c index 9bc5f2a36..3611a8dfe 100644 --- a/client/player.c +++ b/client/player.c @@ -1183,6 +1183,17 @@ static const struct capabilities { CODEC_CAPABILITIES(BCAA_SERVICE_UUID, LC3_ID, LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, 3u, 30, 240)), + + /* Broadcast LC3 Sink: + * + * Frequencies: 8Khz 11Khz 16Khz 22Khz 24Khz 32Khz 44.1Khz 48Khz + * Duration: 7.5 ms 10 ms + * Channel count: 3 + * Frame length: 30-240 + */ + CODEC_CAPABILITIES(BAA_SERVICE_UUID, LC3_ID, + LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, + 3u, 30, 240)), }; struct codec_qos { @@ -1465,6 +1476,7 @@ static struct preset { PRESET(PAC_SINK_UUID, LC3_ID, lc3_presets, 3), PRESET(PAC_SOURCE_UUID, LC3_ID, lc3_presets, 3), PRESET(BCAA_SERVICE_UUID, LC3_ID, lc3_presets, 3), + PRESET(BAA_SERVICE_UUID, LC3_ID, lc3_presets, 3), }; static void parse_vendor_codec(const char *codec, uint16_t *vid, uint16_t *cid) @@ -2285,6 +2297,9 @@ static void register_endpoint_setup(DBusMessageIter *iter, void *user_data) bt_shell_hexdump(ep->meta->iov_base, ep->meta->iov_len); } + g_dbus_dict_append_entry(&dict, "Broadcast", DBUS_TYPE_BOOLEAN, + &ep->broadcast); + dbus_message_iter_close_container(iter, &dict); } @@ -2455,7 +2470,8 @@ static void endpoint_auto_accept(const char *input, void *user_data) { struct endpoint *ep = user_data; - if (!strcmp(ep->uuid, BCAA_SERVICE_UUID)) { + if (!strcmp(ep->uuid, BCAA_SERVICE_UUID) || + !strcmp(ep->uuid, BAA_SERVICE_UUID)) { ep->broadcast = true; } else { ep->broadcast = false; @@ -2728,13 +2744,20 @@ static void endpoint_config(const char *input, void *user_data) endpoint_set_config(cfg); } +static struct endpoint *endpoint_new(const struct capabilities *cap); + static void cmd_config_endpoint(int argc, char *argv[]) { struct endpoint_config *cfg; const struct codec_preset *preset; + const struct capabilities *cap; + char *uuid; + uint8_t codec_id; + bool broadcast = false; cfg = new0(struct endpoint_config, 1); + /* Search for the remote endpoint name on DBUS */ cfg->proxy = g_dbus_proxy_lookup(endpoints, NULL, argv[1], BLUEZ_MEDIA_ENDPOINT_INTERFACE); if (!cfg->proxy) { @@ -2742,16 +2765,36 @@ static void cmd_config_endpoint(int argc, char *argv[]) goto fail; } + /* Search for the local endpoint */ cfg->ep = endpoint_find(argv[2]); if (!cfg->ep) { - bt_shell_printf("Local Endpoint %s not found\n", argv[2]); - goto fail; + + /* When the local endpoint was not found either we received + * UUID, or the provided local endpoint is not available + */ + uuid = argv[2]; + codec_id = strtol(argv[3], NULL, 0); + cap = find_capabilities(uuid, codec_id); + if (cap) { + broadcast = true; + cfg->ep = endpoint_new(cap); + cfg->ep->preset = find_presets_name(uuid, argv[3]); + if (!cfg->ep->preset) + bt_shell_printf("Preset not found\n"); + } else { + bt_shell_printf("Local Endpoint %s," + "or capabilities not found\n", uuid); + goto fail; + } } - if (argc > 3) { - preset = preset_find_name(cfg->ep->preset, argv[3]); + if (((broadcast == false) && (argc > 3)) || + ((broadcast == true) && (argc > 4))) { + char *preset_name = (broadcast == false)?argv[3]:argv[4]; + + preset = preset_find_name(cfg->ep->preset, preset_name); if (!preset) { - bt_shell_printf("Preset %s not found\n", argv[3]); + bt_shell_printf("Preset %s not found\n", preset_name); goto fail; } @@ -3172,7 +3215,8 @@ static const struct bt_shell_menu endpoint_menu = { { "unregister", "", cmd_unregister_endpoint, "Register Endpoint", local_endpoint_generator }, - { "config", " [preset]", + { "config", + " [local endpoint/UUID] [preset/codec id] [preset]", cmd_config_endpoint, "Configure Endpoint", endpoint_generator }, @@ -3189,7 +3233,8 @@ static struct endpoint *endpoint_new(const struct capabilities *cap) ep = new0(struct endpoint, 1); ep->uuid = g_strdup(cap->uuid); - ep->broadcast = strcmp(cap->uuid, BCAA_SERVICE_UUID) ? false : true; + ep->broadcast = (strcmp(cap->uuid, BCAA_SERVICE_UUID) && + strcmp(cap->uuid, BAA_SERVICE_UUID)) ? false : true; ep->codec = cap->codec_id; ep->path = g_strdup_printf("%s/ep%u", BLUEZ_MEDIA_ENDPOINT_PATH, g_list_length(local_endpoints)); From patchwork Wed Aug 2 13:23:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13338166 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 5EFBFC00528 for ; Wed, 2 Aug 2023 13:25:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234093AbjHBNZZ (ORCPT ); Wed, 2 Aug 2023 09:25:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232429AbjHBNZX (ORCPT ); Wed, 2 Aug 2023 09:25:23 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2084.outbound.protection.outlook.com [40.107.21.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EA5E1996 for ; Wed, 2 Aug 2023 06:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gqy3ViMvum7JjT0ahbKhGQcS09B2LqAVmVyBpz3wqk5KkiVo+riP4SSP8d7C1vrwyZvdHbNZl5EZERqCQn+paPMpRY9ceSw9WfgLNuum7pU6g84yG6gXyOrkDEqK639B8pZPqjpO7s8yUV6wyc5QAtHzWyeF9WDvZFYeWb2kyh/3w/1N1w156+2/iKni0/k1Tmp3ibwA/YgGRtpMSKwAmCTU1mc+tXSSmK7Bf8Agnpe19hlx9WGkLND2EbipRQD/9E2SNxJCO1MT5TUhPl9+Q9pXxKBjL78YjRLh5+PjbLjAtjCLa9SigyqBxscq3R+2Jnc0XcJAN86RH/BDEkPuCQ== 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=IrxBLncj+ZstmuJpGTINckKfaoffvLT9Zud2iiwClqg=; b=GfYfr2TDV2nMO2FRsSmv4KnPUZkg48oA6Ryx1DxpjMk7XdsF1phkkZ0bYKU8xsiR7d3/wiszDJPH/dVVWU5YLpcdzl9UW50tFhU1x970YbOy1GQsQSQ40E2F8ty7pv1XKlAGaBVTaMNdHKR/VIO7pNT3w91p9iZzPW21/IKVHhazZxg948lo8kYkp/Rp/bEijT5xN1r6aiGSzZMCkyAwqjsb9CsxlCNOpyQZ/RrDKQ2SwGalqusZ7Ca/nmVc0fXj/QxdQ5qXPkzHBUBJ5z5jSuLN15NuoNbTWSjMo5ugV1+Gj9gEntZBHwcREVskivindrdT0edBRodm6IYZ6lUD+A== 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=IrxBLncj+ZstmuJpGTINckKfaoffvLT9Zud2iiwClqg=; b=TfVlwiYU+iq3tXJrikboGXrXM5dyrmbe6fgCHWiCg7f8JgAkCGntABXLP1j5+bBX3IzN09sgMQgbpuCjrD5xbDEQQ0w61cA7xsZAGrmW5cx+ku4+qpW35OP3/vYP5wcbxzcwqwEyK7wscZLaRz++4/zBm8V823sTW0934NgcpYo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by DU2PR04MB8613.eurprd04.prod.outlook.com (2603:10a6:10:2d8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 13:25:19 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9%7]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 13:25:19 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ v4 2/6] btio: Add support for getsockopt(BT_ISO_BASE) Date: Wed, 2 Aug 2023 16:23:51 +0300 Message-Id: <20230802132355.4953-3-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802132355.4953-1-claudia.rosu@nxp.com> References: <20230802132355.4953-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P191CA0023.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d9::19) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DU2PR04MB8613:EE_ X-MS-Office365-Filtering-Correlation-Id: 20585fde-fae2-4734-c4ea-08db935beaa7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R2mkxfuP0nPC1WIhwkfkXRpknYlHMhxxx2qcN5rIVAa5K7FcQHZPk3ijqFi/WZQnJySFjbhhOuFibvnTnxrl30Nkv+kuwBsKxIuXCQl71LnGLc/+B6DPLC+7ET23aOm94ew/txW42nLF+62jEd1XggyAE1foSwMc89JNGPzwhtQ76zoIu1yJb7z4AiMl1ledF6CDgJ8hCS0DDUEb+Zfc10tVQL7Iyaq5RgTLBGE8tJmJi1H5BMDhAK9z306Yy7Nsx5KuRa/wTHL7sXZE641vs0RtpRNqdSymRgrwzzRuS2L31SyDXWyFQwrHH13FsPKm2wDJvYAmRQtlrZhB49GWnjK4FaY5KtNzALSWk2xCpTI7EFq+0C8Un9MbxKWf1YjFwjLimTVCKfHgRZOYGURe08abm+3G3lNqU8Tkf6ZqUKCEHHccImA4iIovx1jQZBN5nVbYN8aepIWhAU9XWfGC0aQBdqCeYj0/x0CyyB03eTWWl1txlQqeFqhSnzyVMHZMIo21TROZ2fZwmlHGu55KfGLp+DNNyVU+mc8TISAwh5fsa9v0bazFSwjhHd8MhVPG8NGiQQGh38cIiAJPxkBLx27Z6FdA1t3RdXzyDlC4ndb2pjjY5ODHgIJAUBR/Jwzu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199021)(86362001)(36756003)(66556008)(52116002)(478600001)(38350700002)(38100700002)(83380400001)(186003)(2616005)(1076003)(6506007)(26005)(8676002)(8936002)(41300700001)(6666004)(6512007)(6486002)(316002)(5660300002)(6916009)(4326008)(66946007)(2906002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: D0JXPupgvFkCnNp2ivhSiUizC35PNUn2WRnHYGzq9QU3J7esU8xpYqv14zE+r+2RyBflCw2Wi8mOljyb80ruPcGuva7t/RDdEjHhP2EU7SUC6l/QZTkku9MIa8SB9zX81outH6mJUVXZa1DXuIJ1026fbOlaAgafzQIPaMnXEOCDl1X/6d8RbCIBMrpG7yUi+rwPAmurdeOGN8KwfXSph22uGuXRpb3JvAmOaIH4HsiOkH31qR+DXCF6ENjq9JrCITVmlN+/z/u69lWtlo+8S1Dh4LayygMCtfm7/0vSwKcF1GEm4esGxsL4zxgz1jX/YFbLhCx1e3YZUAaIANRyxDnYMoEFxxNfqp/C4yw+TQIH6oZLclrShyfHhXcriUcl+RMQ8f8hfbgd3dkk5+6erCwqeb//ChsSaWfygv56XA2YQ0jwbxsuVxxMHR0k9xCoPSCwzWmvqoZinAr5tYpzuu0V+E3CPy+bIrSLhEWevQIcxjs053iU74U2tp1rmGUtve6K8MTyMTAoalSfp7e/1goqxKvkkGMqvX7SHcuAEMpYqkv0+5rFwHxPk/qqTy0gQiJ9eUjid7SCHzaZ7F8FQ9J9EXMPV+4pgR453WkTl6IwY25X6oUQuxcspQ5LX39yoBgVArNznqy9zsL37YH81TGQ4t0i4Wsj/AteB4LFAnyYWilmLwyI3L3fZs3fDo5oU+MLM8b5eyMmZ0Ognam9619BJXoNULacl2pDFmMbsi4WwAhjjKmjZ14vJ+CLcvd4lSJ0n/ZeLNSxGmDxcSFanU6oiV2Onbcd2ay6tnBELc5pEYWG0G7HZ3YxeKu19dXe6AYHXv6zLsgBePj3f2qYGuwK3IMQEgRUXs6uy+qrHfOranYuKdmAyZryze61c0JnhxztlkylWkGUXcoHY4S1O0vxwF/eWYHPsPowaPRvXs7bprSFALYNXESaNt2l5wNanpB0YPyU6EkVJ+QrEMOYTjg7XlopEgZRYxqO+ruhPoq3El2kFXYkJjSnIrbbftaWJeLzxf6H61YNGqjwCEnHCZzsqonzhyxzQ4ie4c5fTKrD6AEUubvINoV2hVL44ov1NTixZjV82dnHi2V7ix1d9xNixqd0hDyiKgATP/vmHj3yThumN3nfZbmg2NAm7Joq4EWoJjPZqTZXNcD0DK/4mlXDcKBlUN7J+6VtBihq1/qDqfHXDy3jvTNsUJ4imVpZhqBC8aWQz5fKYeela+d43DMp3P+LT6wPWqdgN++f/6N084xGHzEQpAOOQuycW82rgeIubyhF2MqtvwsNFFny0xTwcNgbd41B7HiGqPEyBHf2xi9Tq/iLPSBr+rGzIJOJU6gd4QaIhMJRXi43JaKKR+rV4fHi4J166/crgfD5Rzh8Q/vmmQ8e1shUNbFXynueVCx83fXLI/1wn9ksq9rfhcnHdiUbQ9F5dSeJWuNZhN3bgyq5WJ0MbuQMlYGshp8hsFfT0LiXV6e0ptbTiudbPi0zxiNgvzG/RVI02pmRfBoeG2pFHPfjLaZN0jvw4KZdZ+WTca39aUU5MBlRqsWJpmGZC8mpMAbLzWUp/4NiUQ4UiKj8WIlnL8gjM93BlLdm X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20585fde-fae2-4734-c4ea-08db935beaa7 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 13:25:19.2584 (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: Hosz1NzNY3sNEJHLS+q8vLar+9iIFb8dzyMe/OWZ37HCJ75/KXSLK8+VR5j0FzsRo8hZ0vKVIS291BLlSEMcgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8613 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds the posibility for a broadcast sink to retrieve the BASE information received from a source afeter a PA synchronization, using the getsockopt(BT_ISO_BASE) function. This needs the patch from bluetooth-next: Bluetooth: ISO: Add support for periodic adv reports processing --- btio/btio.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/btio/btio.c b/btio/btio.c index 179be6289..8178250d2 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -1638,6 +1638,7 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) BtIOOption opt = opt1; struct sockaddr_iso src, dst; struct bt_iso_qos qos; + struct bt_iso_base base; socklen_t len; uint32_t phy; @@ -1648,6 +1649,11 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) return FALSE; } + if (getsockopt(sock, SOL_BLUETOOTH, BT_ISO_BASE, &base, &len) < 0) { + ERROR_FAILED(err, "getsockopt(BT_ISO_BASE)", errno); + return FALSE; + } + if (!get_src(sock, &src, sizeof(src), err)) return FALSE; @@ -1694,6 +1700,8 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) *(va_arg(args, struct bt_iso_qos *)) = qos; break; case BT_IO_OPT_BASE: + *(va_arg(args, struct bt_iso_base *)) = base; + break; case BT_IO_OPT_HANDLE: case BT_IO_OPT_CLASS: case BT_IO_OPT_DEFER_TIMEOUT: @@ -1896,8 +1904,9 @@ static GIOChannel *create_io(gboolean server, struct set_opts *opts, goto failed; if (!iso_set_qos(sock, &opts->qos, err)) goto failed; - if (!iso_set_base(sock, &opts->base, err)) - goto failed; + if (opts->base.base_len) + if (!iso_set_base(sock, &opts->base, err)) + goto failed; break; case BT_IO_INVALID: default: From patchwork Wed Aug 2 13:23:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13338167 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 5F662C001DF for ; Wed, 2 Aug 2023 13:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234118AbjHBNZd (ORCPT ); Wed, 2 Aug 2023 09:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234073AbjHBNZ2 (ORCPT ); Wed, 2 Aug 2023 09:25:28 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2076.outbound.protection.outlook.com [40.107.21.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1972E2711 for ; Wed, 2 Aug 2023 06:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YXfIal3bmLlOOtNqYoFwQIQohtLYuuHn5kSc6+L+IuO2tSh8Gw1mMnQTB/HjluEtbZUTbfN8jEW7m3gT6mWF1tdvKTBX/z63ozHtq81khcqkPgolMv6PSA3IxNhHaKqoiJZXXRuzOkI4c/iLPlvYDxwfJrIL/zF6nglOsQSwPyPBKwdpEjWG/lnM22bYwe1HnSH2/3lSLXWlSyrA4xGvB2b3uxeovaPGb9cK1nYwup3nSgPpcmCfyvgA2RKAHdvSIwqRydSeWW+1URv24blYlN0Vm3Az0sz5KTXeTBC8kT4ZHyU7rVtCiiUaz/ofs7+4rXeD48wTr8KBIaRG4wQ2sg== 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=q2gF34zHGQhAiE+qOW3zUC6g7lbjiTV0/SimCcSCaYc=; b=mYCsE+ntxk9lZ7ytXT3gUH5Y/B8UHnPFz2arfRHRGgCLMGHDOyPExo5MbJv2W3HHHQVBB0hmqX4wigiH5l/3yZs/BLoF+WfGr3ZUCzPH3P6ouF7gIs+4M72IwRQwKBx2BJ8lVd8XkaYA9OBgJPpNLY8KVi4/hJNP9dCTWap8nZmRMwDUnZz1XL7RfZuvaBe2gKUs4Zxl/FFJZC046oj6gI8ve8gBigSB4rmK67sqAbQ+6mw2Y3YI+gHuZ7TuRhmkfxDBl+shb7+Pqt8ygK4MWO+yPnyyWyaXJojmosNSZdnkSCqzusqqYGN5Lf99kbYiuZ+fXl5MTePl26rqWqR5Hw== 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=q2gF34zHGQhAiE+qOW3zUC6g7lbjiTV0/SimCcSCaYc=; b=CMlemSmIUOEROoEYdmRX1hWxS3gLcsvFMf26kkPq6i+UbrEV6CNpPBROn375DzsC4Yy5IqawHuqhQ/FC0cbRDSh8GFQjzjG1eSyRCZu2h66NynMbqfeqM8ofbS4HHNgHIqgRlccn9t9kNClID4Jl24KftGMov6Dkh6/8mbqeGGI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by DU2PR04MB8613.eurprd04.prod.outlook.com (2603:10a6:10:2d8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 13:25:23 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9%7]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 13:25:23 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ v4 3/6] adapter: Broadcast source discovery Date: Wed, 2 Aug 2023 16:23:52 +0300 Message-Id: <20230802132355.4953-4-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802132355.4953-1-claudia.rosu@nxp.com> References: <20230802132355.4953-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P191CA0023.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d9::19) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DU2PR04MB8613:EE_ X-MS-Office365-Filtering-Correlation-Id: 4af76671-044b-45ce-efc6-08db935becf6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tL54uulogXI3VwJQM6I0K2rknKgLZIO6xsjA119eEtsnMzunJ6a8068iZZFjL2n0Jl+butLhqNFINrrj8+tYbxG0uq8dGeW5dQPdc1kscdnr7D0iOEX24wleL3WcXV9LoKMW/6xQvN+HsrTSzMMqqvUynWsj7cyMIZ6UEscYwkz0ONHRDhxj+/CtXcFotN7nsuVy/P7raeFbumWA1kVtpZ6V0pFeBx4/AMWr1M14WYnci0Gy2XtwNEmpmbT1vGlVOEXbExq5xmORfphXEq0uwyAY/3vO10Uzes5W+KF/BaEqbdwPOIPT32FqovcCb571igSEiVd9J+EVNoV36Ni6yoApMlzUMlmcb2mtFjojSJoKjn2qqloE2snFUqWO6vQmf1qL9zPMev17G9ToF7Q2zzSKIGX10sXNr9+YCvRLncnMaeuXEedWmqd2YglUoowHQbYcPWMHoK2COwaCaSLWupPz3gXKeenKLG5WsyfxQQa22bkGlrHpzVnHm14vDqL97tce9SXL79ztjO1kuw2GjxqWJzOg5Ch4gm5VRwnHv2rLJ/zwCgXm674nRBo8HfvH6j0G7r9iIqjN+IrWXK35CneYxW4KitBKWOv2lsYgz0lR5NJcooU8zo7DuNnFbVZ5 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199021)(86362001)(36756003)(66556008)(52116002)(478600001)(38350700002)(38100700002)(186003)(2616005)(1076003)(6506007)(26005)(8676002)(8936002)(41300700001)(6666004)(6512007)(6486002)(316002)(5660300002)(6916009)(4326008)(66946007)(2906002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Wz4AWJ+XpCGXLtSt2DWblQ8Jf2TiYXfw6pX/xrXdJbTnC4/5rcu8c6YVGb1BJlKQzwfz9Ix8jdscwtlVzArIZabTXOTYZnAIv6c7Ypj911Wmwe7QyKhFR6fbaJ8jTFjmaQM0YGwaTlqLnLAiYcPCleIHM2ME8nWh4aveKdlAIL0E/kkCX9YxfEU3JvQ304WroNbY4ZkVZWAN/SLb3L5CiCG7NgxCYuv+6h+tqPWp346fUJN6/siY0y32Pog55nodCIeSAmjHW/00ypMqdZZXI9VMBddj/nqxJ9+w/wfO1d5ltgS0owxSDLgjC8Gwcz6P8ly04i6kcyKPTk2jo/qk6yRBv5F+sB5lqopADkS6SSquBQacd4OzhWF6uFyhGeBbaGXuwlid3dK7yD4xYv9M8EFMR3lUQhDXfO6bxNgc1GPIHSze0gSi6L5LhL028urfG+dPnyWKBsBmuR/CD0jYKE4Z+H+qjzJsjCLRNd5AZmHulAPMOk7LNYzI4JO1YPCwv4UTrAi5+dkatHhGf1tn1bufLzzfN04iP/L0f854rxDk+P1jlRlDB6JxpQvejvnctzDMqvr2Fbyx8T4ulNhJqY4m7tFemWYy4tqhIjVA4V5qf5qOUXjpp7cpHj2NcYYhO4YFeqpKPXV0cDsdlqiHq5ptfitda6xbPf96frhrF2lAa8Pl6bw0nNTxqQHLM91wSqDpF2im7+nSHBXznPYOF/W7VbaoYQ9KakljmbPNfWlrmal5f+JHnRMGJxJOf+HXw8qNEXVXXqAC6erouOuuKw8RPfbkn3+BLE4bXoIFd8AG1b6DC2xJsyEfEi/XIzFohg+/Iv/kgf9fLV3ld1Zcxv27Lf+G79tOrqAnLTcAXARdL6z5g91G2MdgGqqAkyDwIvQyD8ywzmtSQtDZwnRv6e53Dt2NqJACaPtPVw/6Z18CrwtVySUk1WVqjuAxcF0baZGRmtonNtaQcVStv2Szzc4Y6PxLKbL330UUvxxzpMJG3t4QWwEzlh1qLCwq/AcCpuahJbwK0hN0LZ8B/UO+Xd7j2x7QIqomLDfzbsJDsNMX9rNJqrZw/MaRVA231FodCq7S1uY9WpRpsZgE8geUQo4ZAcXvfMLBxomifWCcHkUWRSmcz5lncdPQM73XeKJiVnJSlw080voPH+tbYT0mXKRkvLyoAbPzVQm6SD8/ANHjeRf8CjvjwclkawAnEf66bXNc6poqBf4gb6/evDdvdrArUPX7+dH7lvOuTlc3MpcgBN4i4VGmuRZDd64Ako8n2jKbKFf17o67B8JBDZMj0YvRvK8Z9PfAv6JoxT8XqGHVvaPDjAeIw1E+Z9F7xdrRlD9GlpgBktWlacbowuWY26AGX/HJ+iJ1BC52/cWUMeqA1QUkMjThh8/ZMvSO/VtKqVFkTT7gf3RrW8pzdhHhfWUJh9EWxJfanOmDaX9Nwn0D8NE+u7uL0YzOwMpDIpI9l1rnNR9+hWFxKlO/zcxuhuTrVTauP5JoorQAmK2H1lCl6EavdXLL7Oth0oaTKngJ9D3r+0/dPXqrfPr2C8z/LKfUpBPtWz8+kn56EiLG1iNvwcGlwMyxqlez2MjBcTLZ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4af76671-044b-45ce-efc6-08db935becf6 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 13:25:23.1736 (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: 7pMJddyB/+j+DL9N2KJsN9HBRup5jz1929NHIjJ/LR86jo8pR6N1DaY36keHDkFjacSLQHeu+Cct3JA13Ji2gA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8613 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds a new method in the adapter driver, device_resolved() called when a broadcast source that advertises the BCAA_UUID is discovered. --- src/adapter.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/adapter.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 491bd7031..29c6a576a 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -7029,6 +7029,45 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data, return got_match; } +static int find_baas(gconstpointer a, gconstpointer b) +{ + const struct eir_sd *sd = a; + const char *baas_uuid = b; + + return strcmp(sd->uuid, baas_uuid); +} + +static bool accept_bcast_adv(struct btd_adapter *adapter) +{ + if ((btd_adapter_has_settings(adapter, MGMT_SETTING_ISO_SYNC_RECEIVER))) + return true; + + return false; +} + +static bool is_bcast_source(struct eir_data *eir_data) +{ + if (!(eir_data->flags & (EIR_LIM_DISC | EIR_GEN_DISC)) + && (g_slist_find_custom(eir_data->sd_list, + BCAA_SERVICE_UUID, find_baas))) { + return true; + } + + return false; +} +static void bcast_new_source(struct btd_adapter *adapter, + struct btd_device *device) +{ + GSList *l; + + for (l = adapter->drivers; l; l = g_slist_next(l)) { + struct btd_adapter_driver *driver = l->data; + + if (!strcmp(driver->name, "bcast")) + driver->device_discovered(adapter, device); + } +} + static void filter_duplicate_data(void *data, void *user_data) { struct discovery_client *client = data; @@ -7152,12 +7191,21 @@ void btd_adapter_device_found(struct btd_adapter *adapter, return; } + if (accept_bcast_adv(adapter) && is_bcast_source(&eir_data)) + monitoring = true; + if (!discoverable && !monitoring && !eir_data.rsi) { eir_data_free(&eir_data); return; } dev = adapter_create_device(adapter, bdaddr, bdaddr_type); + + if (dev && is_bcast_source(&eir_data)) { + bcast_new_source(adapter, dev); + btd_device_set_temporary(dev, false); + } + } if (!dev) { diff --git a/src/adapter.h b/src/adapter.h index ca96c1f65..ee32f7110 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -125,6 +125,8 @@ struct btd_adapter_driver { struct btd_device *device); void (*device_resolved)(struct btd_adapter *adapter, struct btd_device *device); + void (*device_discovered)(struct btd_adapter *adapter, + struct btd_device *device); /* Indicates the driver is experimental and shall only be registered * when experimental has been enabled (see: main.conf:Experimental). From patchwork Wed Aug 2 13:23:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13338168 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 D77E3C001DF for ; Wed, 2 Aug 2023 13:25:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234053AbjHBNZh (ORCPT ); Wed, 2 Aug 2023 09:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234094AbjHBNZf (ORCPT ); Wed, 2 Aug 2023 09:25:35 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2076.outbound.protection.outlook.com [40.107.21.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB43272E for ; Wed, 2 Aug 2023 06:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eY7iCeP2NgsWORDdEVrjCIadT0RHol9oP3AfC3Dsh9UxFiZxnbGzz62W1FZfHJEagP6/r0f8/H3+bQoiUwK0dbNNADJ0E46QNY0p5NbWftoADL0D+t5YqcCGmGqv/g3bTNzZW0bwaeemirvSnwYL1Ayp+SkojtuNeZ7zht/G2hYiahkm+jHX5Hv2NTi85+S0e6c+R/vhFJiIguNdtWCnQ0m+OcbBkJ3HbIe3SAVUzpcjJRkxJE3lx6b9CPVFneHLGppLrfwiXbw3WJeda1DUH3EYadcl5N+bpSDeNkuOOs3Mtyv3F+Ng0hU3TvxAdReVOCctbxdixI5pvQvt1MsSjA== 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=tXurX6/IGj9cdHlcT27XEtDx4sKvvr4iziIlLiiRhPk=; b=eADJ5pfLvx7dCANSPdptcXcbVfzDjfxRoep55IoeS+H0GAr7DNi2vXKGEOVmvWyxD4vGNeLpFNrARlg7y8z5070NznvQvuR3i4D1j7Fi6ydYBvK+OnAne+XoDfmJrDDuCQBQlVtzVbTMlDpArXi7w9ZnHsFa0qqNk2Nc9HKr0sD74hj4qlqtvT78y02EooiOUf8ZcC4kYgE+4AQlPekVctncu97bFjL7+S19zYej/94xcgSqu+BlhZP24qv/ptDNRnxazQnJ8mpkLz2zrNP4hMZHeXihXpOie6Zvjp1ouX+uB9aPTg15yEc7VWnj6dNVxglKl4GurkFTlWPeoM4liw== 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=tXurX6/IGj9cdHlcT27XEtDx4sKvvr4iziIlLiiRhPk=; b=RAPhtQQGvrcH/M/PE1kFVoxM1ipIyokU8mM/oI9Gn+KxnzsYo4mASslBJBv+P4OK0BvPdi+YsuFqdZ2AM5aIPzOR8uIYZltIDrb989CCFHtDikxczHZ+7bQEexkI+AzyYEWJNgmg8bVtMqM/mWi22yAZObxpFcKeHFkawqXFhvU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by DU2PR04MB8613.eurprd04.prod.outlook.com (2603:10a6:10:2d8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 13:25:25 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9%7]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 13:25:25 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ v4 4/6] bap: Add support for BAP broadcast sink Date: Wed, 2 Aug 2023 16:23:53 +0300 Message-Id: <20230802132355.4953-5-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802132355.4953-1-claudia.rosu@nxp.com> References: <20230802132355.4953-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P191CA0023.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d9::19) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DU2PR04MB8613:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d37a9e9-6d05-4cc2-bdb7-08db935bee38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L71ENgstsbwjXOhOh2fmCK3Ifsds92i/jVd92Ie2woCpylPDiip0s/x62wC0Tc1l5mmb6tz20jw0bUBUC4y/yfppxzH78AlR9puDzG/1Wlg+ncO5rC+J0acSoZ6PowYtyVEanHXKWxkP0QCI3V8RmN+DM7x/WkSyJaUY8Rq0y0vAGG3ur3QSOd7Z6400BFVhOmbA2qp35ib2t8l1/WbNh+XmyrSvcQ+yZw48Zm+w9l79BW94A3PPj9VwLFpnGhcL+MLHNEq6gPD+GQBFBXauuJb1RZ72voTYK77pPak26aXv99WYuqVC4eCdUEMYSkW0DYo2ec+2YoSiJ1sYdt3oG+vz/a5Lds2KXbSRtH47hl9PsIEhPxyuy4tldfWt+bQqhc0tibiQ895zE39cosP0xkWMEyL44kWzUCm569O5ZuWW4Y4VoinjSMsUC1qaAx29L69P1p68dBCWQNOXFKkfz+lX2bZAN530VLTZwW73oFdPfXp8UNa3VxMotCP4MWixoPeoZl4YHPgw+IBkrzdT0Q7zQxLe+bbcwHilngt0oPFa/NNVNqPid6jeB2bNjgayGRbun28tCdT8EO25URy8Q8hngJ9vHb9DKvd/XOs5Rn5jYRCVHclcA/xqUyeojOOE X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199021)(86362001)(36756003)(66556008)(52116002)(478600001)(38350700002)(38100700002)(83380400001)(186003)(2616005)(1076003)(6506007)(26005)(8676002)(8936002)(41300700001)(6666004)(6512007)(6486002)(316002)(30864003)(5660300002)(6916009)(4326008)(66946007)(2906002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cLA+4xCE8Fg/YUYrhDOgenmG7aJ0/66hTaU6finy7acQCJxKFDWQWFu6aDZavPAjAHnst0a4rmmdjznz4Gr6EEsweA/kCa+ct+DfGV+HdtHqsFtj181FxXUum6j6UtIgteXh4Dj450vjHz12LJ7P7tfx0nrgfFj2/0YCK9k9oQc4IfsBQ076VVAPk/mBJI6vSOvl33YNewUPnKrc3CShXN4WGZLe6pTR2MMpD7rCxIdJwV2HKdd9WzOgwG+sQCB0GWHLh8A3XtbOzAdueyUiIAZCO7RKH7AwHQV8kbAdfiXJXsHxUu0uVhB8EipWKUVUEKH/JcfrIOPg7KOkrs4aaE9+Gu7SWBPipRgVVekt5hj+8dHoBylYXdruGK6UoHPszUXI92Rz4AM+KpbibFE7PkzWkFHJ58h6pDP4AiRECEBbR61TWFUrHaqUHu2qbJONjgbYN+YoRAFeUq7Wysr+t3M6jDswoRTdOCL7sdI6XHxr2P2SdzgjNWfVYl3+IHLCUCpQmhf74wCiof9bVhfTesJCoGGqh+KMEn9DFholDlU9OlqgCzAupfFOI6m4ONcCT7RV2n7JAjV/J6upxBrHXkVVmhSCHMp+S5eaq0i2PhGbn2Jvf1ZNNVfrPejep0pMiEY7BkGv6jD+bqwJ5wPIvcdo9W1Hi3cAApYZqxnSJSHXpAWGMtGqkiJjIeopJTiaIgPIKOxfqIGcMcRqcdhHccEH/pu78W+a3vzZ3b8fDRJhWNBYQqiihSMdXtfQYHZXmXLBSlryhr9pTFU1S5ndJGAYKUh7F/D7meY4IA8s0+A2rMN6FwhnY4uIqaOssGEMpgMH4Gw6K3oma0IdT2wuQi81CPhBep1kUs/H3Hyx5qhdLAMxkcZR2OfRobT+N/LVF5W2hsnoiUDIehYMCBmLrMubDGv+17GNenWYGFJ/3/Yln/I6UDdI006rdtXKbGcOlKuUBoC6tqar+9v6zVrA6HNHQkUWqa8t1vQCvu4RLWCfx95ugcG6hHJXuXb2MKMQVqjNH1MMUCJYoTDox5gbfZAcbr/+2mmjQ79Mak5Xw5dlyYb2K/E64R7klrw60d/YkV9H5xsw4qrkskklQ7Rdg3rtmB4nuzP929qbc9+wNJputhLQp6T62kEEFh9ISa1CiqAEtL48XvB49p+QEkO7g0UJUGSw/wTFlMxbBPPUxT4eFZry9bOQIMiCNrzlRYhPAVmwCIhRwQTGZgjA18hCN4c1/xH8hSeJdsnjW3FCtCuZN4ImTjqzbj60F0SrZEOGmCxgyNuGlO36OlbMQvlFE5qWRqu0SChF24pb12aYQpjcehU5g6cfpPMfc3IQPnfBRK69MoKEsLvwcOF0TUbHwDoBaTPjmCTjic0TmU3f14QWlISi9nJ5Zqe4FUpAhi10FKJAgJ+SEFOTZ03F7GTkNwXSnSJX/4sFvjRa1w6JahJi/I/DymIN+fEZmumvI6JcLuQrmcpT6tKAnqxUV0IYa2drxpFKOzKr62oXU+a9N/3Ws6Dt18revMtiyXC+XE7xQ6va2S6G1ayIo3oDaz1tPVFRwzuL5JnCODhsIvLGG+4OazU/Dq7RTWoRWmFNX+cN X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d37a9e9-6d05-4cc2-bdb7-08db935bee38 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 13:25:25.4476 (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: 2HnY3zfTJwCeSTsucRA0opgNlR72A/WUvYmwZHbQ/Cq6jSuPB5xbT15ANqRDBnk8WChm9AQGPIIjbeeSepygFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8613 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds support for BAP broadcast sink, creates a remote endpoint when a broadcast source is discovered and synchronizes with the source upon endpoint configuration. This feature was tested using bluetoothctl with the following commands: [bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06 [bluetooth]# scan on [NEW] Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0 [bluetooth]# endpoint.config /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0 /local/endpoint/ep0 16_2_1 --- profiles/audio/bap.c | 300 ++++++++++++++++++++++++++++++++++++++----- src/shared/bap.c | 153 +++++++++++++++++++--- src/shared/bap.h | 11 +- 3 files changed, 410 insertions(+), 54 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 8cbb238ef..112e0673d 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -34,6 +34,7 @@ #include "lib/hci.h" #include "lib/sdp.h" #include "lib/uuid.h" +#include "lib/iso.h" #include "src/btd.h" #include "src/dbus-common.h" @@ -58,6 +59,7 @@ #define ISO_SOCKET_UUID "6fbaf188-05e0-496a-9885-d6ddfdb4e03e" #define PACS_UUID_STR "00001850-0000-1000-8000-00805f9b34fb" #define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1" +#define MEDIA_INTERFACE "org.bluez.Media1" struct bap_ep { char *path; @@ -186,8 +188,11 @@ static gboolean get_uuid(const GDBusPropertyTable *property, uuid = PAC_SINK_UUID; else if (queue_find(ep->data->srcs, NULL, ep)) uuid = PAC_SOURCE_UUID; - else + else if ((queue_find(ep->data->bcast, NULL, ep) + && (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK))) uuid = BAA_SERVICE_UUID; + else + uuid = BCAA_SERVICE_UUID; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &uuid); @@ -341,15 +346,18 @@ static int parse_properties(DBusMessageIter *props, struct iovec **caps, } else if (!strcasecmp(key, "PHY")) { const char *str; - if (var != DBUS_TYPE_STRING) - goto fail; - - dbus_message_iter_get_basic(&value, &str); - - if (!strcasecmp(str, "1M")) - io_qos.phy = 0x01; - else if (!strcasecmp(str, "2M")) - io_qos.phy = 0x02; + if (var == DBUS_TYPE_STRING) { + dbus_message_iter_get_basic(&value, &str); + + if (!strcasecmp(str, "1M")) + io_qos.phy = 0x01; + else if (!strcasecmp(str, "2M")) + io_qos.phy = 0x02; + else + goto fail; + } else if (var == DBUS_TYPE_BYTE) + dbus_message_iter_get_basic(&value, + &io_qos.phy); else goto fail; } else if (!strcasecmp(key, "SDU")) { @@ -556,7 +564,7 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, } if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) { - /* Mark CIG and CIS to be auto assigned */ + /* Mark BIG and BIS to be auto assigned */ ep->qos.bcast.big = BT_ISO_QOS_BIG_UNSET; ep->qos.bcast.bis = BT_ISO_QOS_BIS_UNSET; } else { @@ -577,8 +585,12 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, ep->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, ep->rpac, &ep->qos, ep->caps); - ep->id = bt_bap_stream_config(ep->stream, &ep->qos, ep->caps, - config_cb, ep); + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) + ep->id = bt_bap_stream_config(ep->stream, &ep->qos, NULL, + config_cb, ep); + else + ep->id = bt_bap_stream_config(ep->stream, &ep->qos, ep->caps, + config_cb, ep); if (!ep->id) { DBG("Unable to config stream"); free(ep->caps); @@ -597,13 +609,120 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, break; case BT_BAP_STREAM_TYPE_BCAST: /* No message sent over the air for broadcast */ - ep->id = 0; + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) + ep->msg = dbus_message_ref(msg); + else + ep->id = 0; + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } return NULL; } +static void update_bcast_qos(struct bt_iso_qos *qos, + struct bt_bap_qos *bap_qos) +{ + bap_qos->bcast.big = qos->bcast.big; + bap_qos->bcast.bis = qos->bcast.bis; + bap_qos->bcast.sync_interval = qos->bcast.sync_interval; + bap_qos->bcast.packing = qos->bcast.packing; + bap_qos->bcast.framing = qos->bcast.framing; + bap_qos->bcast.encryption = qos->bcast.encryption; + bap_qos->bcast.options = qos->bcast.options; + bap_qos->bcast.skip = qos->bcast.skip; + bap_qos->bcast.sync_timeout = qos->bcast.sync_timeout; + bap_qos->bcast.sync_cte_type = qos->bcast.sync_cte_type; + bap_qos->bcast.mse = qos->bcast.mse; + bap_qos->bcast.timeout = qos->bcast.timeout; + bap_qos->bcast.io_qos.interval = qos->bcast.in.interval; + bap_qos->bcast.io_qos.latency = qos->bcast.in.latency; + bap_qos->bcast.io_qos.phy = qos->bcast.in.phy; + bap_qos->bcast.io_qos.sdu = qos->bcast.in.sdu; + bap_qos->bcast.io_qos.rtn = qos->bcast.in.rtn; + + bap_qos->bcast.bcode = new0(struct iovec, 1); + util_iov_memcpy(bap_qos->bcast.bcode, qos->bcast.bcode, + sizeof(qos->bcast.bcode)); +} + +static bool match_ep_type(const void *data, const void *user_data) +{ + const struct bap_ep *ep = data; + + return (bt_bap_pac_get_type(ep->lpac) == PTR_TO_INT(user_data)); +} + +static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) +{ + struct bap_data *data = user_data; + struct bt_iso_qos qos; + struct bt_iso_base base; + char address[18]; + struct bap_ep *ep; + int fd; + struct iovec *base_io; + + bt_io_get(io, &err, + BT_IO_OPT_DEST, address, + BT_IO_OPT_QOS, &qos, + BT_IO_OPT_BASE, &base, + BT_IO_OPT_INVALID); + if (err) { + error("%s", err->message); + g_error_free(err); + goto drop; + } + + g_io_channel_ref(io); + + DBG("BCAST ISO: sync with %s (BIG 0x%02x BIS 0x%02x)", + address, qos.bcast.big, qos.bcast.bis); + + ep = queue_find(data->bcast, match_ep_type, + INT_TO_PTR(BT_BAP_BCAST_SINK)); + if (!ep) { + DBG("ep not found"); + return; + } + + update_bcast_qos(&qos, &ep->qos); + + base_io = new0(struct iovec, 1); + util_iov_memcpy(base_io, base.base, base.base_len); + + if (ep->stream == NULL) + DBG("stream is null"); + ep->id = bt_bap_stream_config(ep->stream, &ep->qos, + base_io, NULL, NULL); + data->listen_io = io; + + bt_bap_stream_set_user_data(ep->stream, ep->path); + + fd = g_io_channel_unix_get_fd(io); + + if (bt_bap_stream_set_io(ep->stream, fd)) { + bt_bap_stream_enable(ep->stream, true, NULL, NULL, NULL); + g_io_channel_set_close_on_unref(io, FALSE); + return; + } + + + return; + +drop: + g_io_channel_shutdown(io, TRUE, NULL); + +} + +static bool match_data_bap_data(const void *data, const void *match_data) +{ + const struct bap_data *bdata = data; + const struct btd_adapter *adapter = match_data; + + return bdata->user_data == adapter; +} + static const GDBusMethodTable ep_methods[] = { { GDBUS_EXPERIMENTAL_ASYNC_METHOD("SetConfiguration", GDBUS_ARGS({ "endpoint", "o" }, @@ -650,14 +769,23 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, struct bt_bap_pac *rpac) { struct btd_adapter *adapter = data->user_data; + struct btd_device *device = data->device; struct bap_ep *ep; struct queue *queue; - int i, err; + int i, err = 0; const char *suffix; struct match_ep match = { lpac, rpac }; + if (!adapter) + DBG("adapter is null"); + + if (!device) + device = btd_adapter_find_device_by_path(adapter, + bt_bap_pac_get_name(rpac)); + switch (bt_bap_pac_get_type(rpac)) { case BT_BAP_BCAST_SOURCE: + case BT_BAP_BCAST_SINK: queue = data->bcast; i = queue_length(data->bcast); suffix = "bcast"; @@ -675,8 +803,24 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, ep->lpac = lpac; ep->rpac = rpac; - err = asprintf(&ep->path, "%s/pac_%s%d", adapter_get_path(adapter), - suffix, i); + if (device) + ep->data->device = device; + + switch (bt_bap_pac_get_type(rpac)) { + case BT_BAP_BCAST_SINK: + DBG("sink"); + err = asprintf(&ep->path, "%s/pac_%s%d", + adapter_get_path(adapter), suffix, i); + DBG("sink path %s", ep->path); + break; + case BT_BAP_BCAST_SOURCE: + DBG("source"); + err = asprintf(&ep->path, "%s/pac_%s%d", + device_get_path(device), suffix, i); + DBG("source path %s", ep->path); + break; + } + if (err < 0) { error("Could not allocate path for remote pac %s/pac%d", adapter_get_path(adapter), i); @@ -685,14 +829,13 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, } if (g_dbus_register_interface(btd_get_dbus_connection(), - ep->path, MEDIA_ENDPOINT_INTERFACE, - ep_methods, NULL, ep_properties, - ep, ep_free) == FALSE) { + ep->path, MEDIA_ENDPOINT_INTERFACE, + ep_methods, NULL, ep_properties, + ep, ep_free) == FALSE) { error("Could not register remote ep %s", ep->path); ep_free(ep); return NULL; } - bt_bap_pac_set_user_data(rpac, ep->path); DBG("ep %p lpac %p rpac %p path %s", ep, ep->lpac, ep->rpac, ep->path); @@ -824,6 +967,7 @@ done: queue_foreach(ep->data->srcs, bap_config, NULL); queue_foreach(ep->data->snks, bap_config, NULL); + queue_foreach(ep->data->bcast, bap_config, NULL); } static bool pac_found(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, @@ -1310,6 +1454,46 @@ static void bap_listen_io(struct bap_data *data, struct bt_bap_stream *stream, data->listen_io = io; } +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; + + 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(iso_bcast_confirm_cb, NULL, 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); + g_error_free(err); + } else + DBG("io created"); + + 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) { @@ -1364,10 +1548,10 @@ static void bap_create_bcast_io(struct bap_data *data, struct bap_ep *ep, memcpy(&iso_qos.bcast.out, &ep->qos.bcast.io_qos, sizeof(struct bt_iso_io_qos)); done: - if (ep) + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) bap_connect_io_broadcast(data, ep, stream, &iso_qos); else - bap_listen_io(data, stream, &iso_qos); + bap_listen_io_broadcast(data, ep, stream, &iso_qos); } static void bap_create_io(struct bap_data *data, struct bap_ep *ep, @@ -1417,6 +1601,11 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, break; case BT_BAP_STREAM_STATE_CONFIG: if (ep && !ep->id) { + if + (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) { + bap_create_bcast_io(data, ep, stream, true); + return; + } bap_create_io(data, ep, stream, true); if (!ep->io) { error("Unable to create io"); @@ -1424,7 +1613,6 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, return; } - if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_UCAST) { /* Wait QoS response to respond */ @@ -1480,6 +1668,10 @@ static void pac_added_broadcast(struct bt_bap_pac *pac, void *user_data) 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) { + DBG("sink pac %p", pac); + bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SINK, + pac_found_bcast, data); } } @@ -1596,14 +1788,6 @@ static bool match_data(const void *data, const void *match_data) return bdata->bap == bap; } -static bool match_data_bap_data(const void *data, const void *match_data) -{ - const struct bap_data *bdata = data; - const struct btd_adapter *adapter = match_data; - - return bdata->user_data == adapter; -} - static bool io_get_qos(GIOChannel *io, struct bt_iso_qos *qos) { GError *err = NULL; @@ -1854,7 +2038,7 @@ static int bap_adapter_probe(struct btd_profile *p, bap_data_add(data); - if (!bt_bap_attach_broadcast(data->bap)) { + if (!bt_bap_attach_broadcast(data->bap, BT_BAP_BCAST_SOURCE)) { error("BAP unable to attach"); return -EINVAL; } @@ -1901,12 +2085,62 @@ static struct btd_profile bap_profile = { .experimental = true, }; +static GDBusProxy *media; + +static void proxy_added(GDBusProxy *proxy, void *user_data) +{ + const char *interface; + + interface = g_dbus_proxy_get_interface(proxy); + + if (!strcmp(interface, MEDIA_INTERFACE)) { + DBG("proxy added %s ", g_dbus_proxy_get_path(proxy)); + media = proxy; + } +} + +static int bcast_server_probe(struct btd_adapter *adapter) +{ + static GDBusClient *client; + + client = g_dbus_client_new(btd_get_dbus_connection(), + "org.bluez", "/org/bluez"); + + g_dbus_client_set_proxy_handlers(client, proxy_added, NULL, + NULL, NULL); + + return 0; +} + +static void bcast_server_remove(struct btd_adapter *adapter) +{ + DBG("path %s", adapter_get_path(adapter)); +} + +static void bcast_new_source(struct btd_adapter *adapter, + struct btd_device *device) +{ + struct bap_data *data = queue_find(sessions, match_data_bap_data, + adapter); + + bt_bap_new_bcast_source(data->bap, device_get_path(device), 0x06); +} + +static struct btd_adapter_driver bcast_driver = { + .name = "bcast", + .probe = bcast_server_probe, + .remove = bcast_server_remove, + .device_discovered = bcast_new_source, + .experimental = true, +}; + static unsigned int bap_id = 0; static int bap_init(void) { int err; + btd_register_adapter_driver(&bcast_driver); err = btd_profile_register(&bap_profile); if (err) return err; diff --git a/src/shared/bap.c b/src/shared/bap.c index 72ce67c08..ae3f64730 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -633,14 +633,18 @@ static struct bt_bap_endpoint *bap_endpoint_new(struct bt_bap_db *bdb, return ep; } -static struct bt_bap_endpoint *bap_endpoint_new_broacast(struct bt_bap_db *bdb) +static struct bt_bap_endpoint *bap_endpoint_new_broadcast(struct bt_bap_db *bdb, + uint8_t type) { struct bt_bap_endpoint *ep; ep = new0(struct bt_bap_endpoint, 1); ep->bdb = bdb; ep->attr = NULL; - ep->dir = BT_BAP_BCAST_SOURCE; + if (type == BT_BAP_BCAST_SINK) + ep->dir = BT_BAP_BCAST_SOURCE; + else + ep->dir = BT_BAP_BCAST_SINK; return ep; } @@ -667,22 +671,27 @@ static struct bt_bap_endpoint *bap_get_endpoint(struct queue *endpoints, return ep; } +static bool match_ep_type(const void *data, const void *match_data) +{ + const struct bt_bap_endpoint *ep = data; + const uint8_t type = PTR_TO_INT(match_data); + + return (ep->dir == type); +} + static struct bt_bap_endpoint *bap_get_endpoint_bcast(struct queue *endpoints, - struct bt_bap_db *db) + struct bt_bap_db *db, uint8_t type) { struct bt_bap_endpoint *ep; if (!db) return NULL; - /* - * We have support for only one stream so we will have - * only one endpoint. - * TO DO add support for more then one stream - */ - if (queue_length(endpoints) > 0) - return queue_peek_head(endpoints); - ep = bap_endpoint_new_broacast(db); + ep = queue_find(endpoints, match_ep_type, INT_TO_PTR(type)); + if (ep) + return ep; + + ep = bap_endpoint_new_broadcast(db, type); if (!ep) return NULL; @@ -1317,6 +1326,8 @@ static void stream_set_state_broadcast(struct bt_bap_stream *stream, struct bt_bap *bap = stream->bap; const struct queue_entry *entry; + if (ep->old_state == state) + return; ep->old_state = ep->state; ep->state = state; @@ -1348,6 +1359,9 @@ static void stream_set_state(struct bt_bap_stream *stream, uint8_t state) ep->old_state = ep->state; ep->state = state; + if (stream->lpac->type == BT_BAP_BCAST_SINK) + goto done; + if (stream->client) goto done; @@ -2379,6 +2393,10 @@ static struct bt_bap_pac *bap_pac_find(struct bt_bap_db *bdb, uint8_t type, return queue_find(bdb->sources, match_codec, codec); case BT_BAP_SINK: return queue_find(bdb->sinks, match_codec, codec); + case BT_BAP_BCAST_SOURCE: + return queue_find(bdb->broadcast_sources, match_codec, codec); + case BT_BAP_BCAST_SINK: + return queue_find(bdb->broadcast_sinks, match_codec, codec); } return NULL; @@ -2518,7 +2536,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_brodcast_sink; + struct bt_bap_pac *pac, *pac_broadcast_sink; struct bt_bap_codec codec; if (!db) @@ -2545,11 +2563,19 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, bap_add_source(pac); break; case BT_BAP_BCAST_SOURCE: - // For broadcast add local pac and remote pac bap_add_broadcast_source(pac); - pac_brodcast_sink = bap_pac_new(bdb, name, type, &codec, qos, + 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_brodcast_sink); + bap_add_broadcast_sink(pac_broadcast_sink); + } + break; + case BT_BAP_BCAST_SINK: + bap_add_broadcast_sink(pac); break; default: bap_pac_free(pac); @@ -2579,6 +2605,14 @@ uint8_t bt_bap_pac_get_type(struct bt_bap_pac *pac) return pac->type; } +char *bt_bap_pac_get_name(struct bt_bap_pac *pac) +{ + if (!pac) + return NULL; + + return pac->name; +} + uint32_t bt_bap_pac_get_locations(struct bt_bap_pac *pac) { struct bt_pacs *pacs = pac->bdb->pacs; @@ -3996,7 +4030,7 @@ clone: return true; } -bool bt_bap_attach_broadcast(struct bt_bap *bap) +bool bt_bap_attach_broadcast(struct bt_bap *bap, uint8_t type) { struct bt_bap_endpoint *ep; @@ -4008,7 +4042,7 @@ bool bt_bap_attach_broadcast(struct bt_bap *bap) queue_push_tail(sessions, bap); - ep = bap_get_endpoint_bcast(bap->remote_eps, bap->ldb); + ep = bap_get_endpoint_bcast(bap->remote_eps, bap->ldb, type); if (ep) ep->bap = bap; @@ -4221,9 +4255,19 @@ void bt_bap_foreach_pac(struct bt_bap *bap, uint8_t type, return bap_foreach_pac(bap->ldb->sinks, bap->rdb->sources, func, user_data); case BT_BAP_BCAST_SOURCE: - return bap_foreach_pac(bap->ldb->broadcast_sources, + 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); } } @@ -4382,6 +4426,11 @@ unsigned int bt_bap_stream_config(struct bt_bap_stream *stream, return req->id; case BT_BAP_STREAM_TYPE_BCAST: stream->qos = *qos; + if (stream->lpac->type == BT_BAP_BCAST_SINK) { + if (data) + stream_config(stream, data, NULL); + stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG); + } return 1; } @@ -4446,13 +4495,19 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, if (rpac) type = rpac->type; else if (lpac) { - switch(lpac->type) { + switch (lpac->type) { case BT_BAP_SINK: type = BT_BAP_SOURCE; break; case BT_BAP_SOURCE: type = BT_BAP_SINK; break; + case BT_BAP_BCAST_SOURCE: + type = BT_BAP_BCAST_SINK; + break; + case BT_BAP_BCAST_SINK: + type = BT_BAP_BCAST_SOURCE; + break; default: return NULL; } @@ -4913,6 +4968,18 @@ struct io *bt_bap_stream_get_io(struct bt_bap_stream *stream) return io->io; } +char *bt_bap_stream_get_remote_name(struct bt_bap_stream *stream) +{ + return bt_bap_pac_get_name(stream->rpac); +} + +bool bt_bap_match_bcast_sink_stream(const void *data, const void *user_data) +{ + const struct bt_bap_stream *stream = data; + + return stream->lpac->type == BT_BAP_BCAST_SINK; +} + static bool stream_io_disconnected(struct io *io, void *user_data) { struct bt_bap_stream *stream = user_data; @@ -4944,6 +5011,14 @@ static bool match_req_id(const void *data, const void *match_data) return (req->id == id); } +static bool match_name(const void *data, const void *match_data) +{ + const struct bt_bap_pac *pac = data; + const char *name = match_data; + + return (!strcmp(pac->name, name)); +} + int bt_bap_stream_cancel(struct bt_bap_stream *stream, unsigned int id) { struct bt_bap_req *req; @@ -5132,3 +5207,43 @@ bool bt_bap_stream_io_is_connecting(struct bt_bap_stream *stream, int *fd) return io->connecting; } + +bool bt_bap_new_bcast_source(struct bt_bap *bap, const char *name, + uint8_t codec) +{ + struct bt_bap_endpoint *ep; + struct bt_bap_pac *pac_broadcast_source, *local_sink; + struct bt_bap_codec bap_codec; + + bap_codec.id = codec; + bap_codec.cid = 0; + bap_codec.vid = 0; + + /* Add remote source endpoint */ + if (!bap->rdb->broadcast_sources) + bap->rdb->broadcast_sources = queue_new(); + + if (queue_find(bap->rdb->broadcast_sources, match_name, name)) { + DBG(bap, "broadcast source already registered"); + return true; + } + + local_sink = queue_peek_head(bap->ldb->broadcast_sinks); + pac_broadcast_source = bap_pac_new(bap->rdb, name, BT_BAP_BCAST_SOURCE, + &bap_codec, NULL, local_sink->data, NULL); + queue_push_tail(bap->rdb->broadcast_sources, pac_broadcast_source); + + if (!pac_broadcast_source) { + DBG(bap, "No broadcast source could be created"); + return false; + } + queue_foreach(bap->pac_cbs, notify_pac_added, pac_broadcast_source); + + /* Push remote endpoint with direction sink */ + ep = bap_endpoint_new_broadcast(bap->rdb, BT_BAP_BCAST_SINK); + + if (ep) + queue_push_tail(bap->remote_eps, ep); + + return true; +} diff --git a/src/shared/bap.h b/src/shared/bap.h index 50b567663..cf98ec8b7 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -163,6 +163,8 @@ bool bt_bap_remove_pac(struct bt_bap_pac *pac); uint8_t bt_bap_pac_get_type(struct bt_bap_pac *pac); +char *bt_bap_pac_get_name(struct bt_bap_pac *pac); + uint32_t bt_bap_pac_get_locations(struct bt_bap_pac *pac); uint8_t bt_bap_stream_get_type(struct bt_bap_stream *stream); @@ -186,7 +188,7 @@ struct bt_bap *bt_bap_ref(struct bt_bap *bap); void bt_bap_unref(struct bt_bap *bap); bool bt_bap_attach(struct bt_bap *bap, struct bt_gatt_client *client); -bool bt_bap_attach_broadcast(struct bt_bap *bap); +bool bt_bap_attach_broadcast(struct bt_bap *bap, uint8_t type); void bt_bap_detach(struct bt_bap *bap); bool bt_bap_set_debug(struct bt_bap *bap, bt_bap_debug_func_t cb, @@ -289,7 +291,7 @@ struct bt_bap_qos *bt_bap_stream_get_qos(struct bt_bap_stream *stream); struct iovec *bt_bap_stream_get_metadata(struct bt_bap_stream *stream); struct io *bt_bap_stream_get_io(struct bt_bap_stream *stream); - +bool bt_bap_match_bcast_sink_stream(const void *data, const void *user_data); bool bt_bap_stream_set_io(struct bt_bap_stream *stream, int fd); int bt_bap_stream_cancel(struct bt_bap_stream *stream, unsigned int id); @@ -305,3 +307,8 @@ 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_source(struct bt_bap *bap, const char *name, + uint8_t codec); + +char *bt_bap_stream_get_remote_name(struct bt_bap_stream *stream); From patchwork Wed Aug 2 13:23:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13338169 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 44A93C00528 for ; Wed, 2 Aug 2023 13:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234064AbjHBNZs (ORCPT ); Wed, 2 Aug 2023 09:25:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbjHBNZq (ORCPT ); Wed, 2 Aug 2023 09:25:46 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2076.outbound.protection.outlook.com [40.107.21.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99579271C for ; Wed, 2 Aug 2023 06:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AGQmBvLGLBPvLKcCopWK+7ePoPWH3Hx/x67nFn1eEz22pOqiT5+Mo2RY92GTLCfNNGJpLJon+/UWIbqXJnF8WfgWuKPLlQG5JkyTL7Yb5TPRi8N4sTpsHGQi9PxyQ46OAN0h9iO4r+78GMXgEMjDbzpdhpr/x7p/qi0QUU9Bdri5xj1kLgeyIqjMkAsL6rPCHnuJhHyfHXLWHpcw9lg4qs04lj/1YMbOm/8aDEXrHTbv1++oZUN6yQnK23X0JVRU0idTc5wWmJoHZee90DuFuyiHNLxl5uIPr+CkrntRC2fN5OiHmjoTa1ei0oRAAie7v+hPbPOLpzM5VXW6dkqCtA== 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=SUb/B7vqA04fju93O5LRm4gQoV704vH6jrWak2+g+ns=; b=IAzdPAMPBvZtakJch8xzXpp/JovFfF/w+uglTthq5IqM2itV1Aj9/y4QoBBg6GHf5tK0af3T6DJLUcFxHBx5azLUj1agYhbdGm4XKB85i0suTPVwauL2P+wEpEMChYwSlqhxeVLRQB5gxJ9alHFCRWuAJa0En6mTaBGMvCdkhr0ZPZBu8YJoxV+L17JsyXhBEcYrPDiR8l27nOEXom94QHkfIiUp122Ml7/ZreDxV/QzDMKIP0vmOoLLUZTs5mobz/Q/8f3xjK5TzLHvwFywtjvc2fm88knIIxeE7hcVB5IGc4Uvx1pkW8nO8YvZvlL2YcBDOvdJZL6MADEndkHPtA== 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=SUb/B7vqA04fju93O5LRm4gQoV704vH6jrWak2+g+ns=; b=hImo/ESRgnvxyvsiaQIqY+87oQRZb0KBhSZkhPOdv6RJ/xxt4zRe9io04OJBVr2thplpYGjqs7j8tF61rH2pbVV6N08M8lhzO8Rj47nkIrc2y8CSghQl/LHH1F7lxJ4Q5LgVc+5z6C7L0waknyjOuqDrfxS+KV0AiPmroPaB2rs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by DU2PR04MB8613.eurprd04.prod.outlook.com (2603:10a6:10:2d8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 13:25:27 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9%7]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 13:25:27 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ v4 5/6] media: Add broadcast sink media endpoint Date: Wed, 2 Aug 2023 16:23:54 +0300 Message-Id: <20230802132355.4953-6-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802132355.4953-1-claudia.rosu@nxp.com> References: <20230802132355.4953-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P191CA0023.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d9::19) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DU2PR04MB8613:EE_ X-MS-Office365-Filtering-Correlation-Id: 69a9ab1e-8f08-493b-6548-08db935bef73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JaF+aZagjwSfAja6FIjrEzEJU5lPqFu9dlwY/wjSIFhnUoOJ1zQ6CNLMdv5hRFEqXun0TL3vdJhuaqwRLBt7ks5Gw33ctMqG+Wlh/6fcOHo1DV4t4YoKIDpNkO80gfkbalmbjvQH5txj01oAyCJyE9fF1TCy4C+71tgd2wLyAwLOTPkFW4FglNfqvVSg+rKErjXQYzDsIBOoNG415q87jyz+p12Uu77lXjnWZ/OC8uqwpGSFspJPq9eUxspWvYsfFz/YRB4V5dsjzpmo4uxlWrJBhcBpRz+IG2sAWYMTaQwXQP4p14dg9MrMTyEi+qFCYo7Wvwkq3ES2/Kfiwk/qmFMuBrXMh5FkmmKMCRqPHEWnKwmuLi0/+T9DiMpTHKNArMQBOgBs2mJ0oWJAIRfQGaSlxFQgUz1PX9rm4bGGx4A4zWZWxyahDfGGO5kqr5kdoNVBJL6r8DfRERkBzJQ/5HTFXeaq4ladJTQCMtwED9MzLA7dzsPBB48Uo69G8DunuqcV8Z+JgVP83wSgCtSBCdg8YxFzIcems04QIoWT9k7oxYZn2r5xBx+brcUoEgMQlrh90h8Ti0LQQhy4UZiWxpeZaoUtkswmxpM571kUGvzJ0rWsfnmtuoJY3bXqDmCp X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199021)(86362001)(36756003)(66556008)(52116002)(478600001)(38350700002)(38100700002)(83380400001)(186003)(2616005)(1076003)(6506007)(26005)(8676002)(8936002)(41300700001)(6666004)(6512007)(6486002)(316002)(5660300002)(6916009)(4326008)(66946007)(2906002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QPqgY+V2GBCds9bMuyG+G8DqTyccARe54oQxuAW3tm4WVGNgETxcZ3P3qmvHnZCX82n8w8qlE2sIuaD1ioi+Y0Y042LEMrBlYNfMDNmqu0nFf5rWYdDtze7rTdkvPYml5yEDli9cpA7VqwPy2uJO/DSActykSCutzSTn0Qw1/YC8JzHjKC3qfybbg2xXkj4v6atl2IhI3B9YjdiZLQ0slAswYx5/UP2ktKsTpqbW3OPnDblIHNWgkTrkf/HAVH8MTFQjAnBkVAhnVQ6dT2q2wE4Cq5su52728TEhdnKAa9tUHHS+uvMkpOXfF22YkDk8GSKfaKL4e64Xm0ArSk3pPqYwCPi6gVaEehEe5ToErpS/7bi18ode92zqiJSh4KmWwYN31Zu/EYxStfvK9+G/hLxn0lfGV/RLFlFDjHb0PE6uT8iJAY94f93qmG8KAvST6ut/D8QxL5cIGDmSCUpGd5e2I9sjg75860osLr0PAD23dIhtmAs3wyuNtMWDxGtw51yZcayNnbyYDeIVKhnc7t22KcbMLqAwAvK33+8sxeNm4pw4VWCQ5YBeJMlzu6E1NINgZ4MkIF3kyYCousqWRGuy6F/sqzdArOAHxUranDynrIacUar7uiCYHbUgPofuIV1tqBeRilZ2B9F9TV4e6iVCpFNo+Y/Cv53/CHTq2xbjhDt41OHkfLq/T27lp66UZrSX0vPKzqI2tpUPamDCZdce3WfAb2xcwZxoU/S1nV9L8tBoPB/NJT6eYS+AAaNNS8rfHdDIywnAn5bhzBXY3q6+Gm/BywWpLeeAIgJ0aBG4SkOm6xlkYrMlFD/WGjW0WN+hKpOymMgER4jkHDGedIT+5E8iEnSrARFghxPZSr/Oqs0u/ZRQAunNyWvrOFZOy4II8nscmQZFC6LtxXA/BIirvYty+eq0Wl6+I20QgLCv4AhMWdWMz9rHh5QOKTaULYNA57bpvcHc3PP2m9lJiFhDuqCN8xhFagV75a5IYV1eGZVFCnl5Kd0vL+pprQdrUTi2YNG07bA31X2i34qWEBJVMVlzr12yz/VowyNFWNFtIvQU0PonFOJQwDB+f83T/NvlxdarP8KekD7oMHZghCuAsE5NgIki19kecMHKcr0NMrME53yrzi5hGL+xb2X0dGZlqaF+9faB2kZnISC2FenASCywgByROf2o3QyODzZHvwsBhd0ctmbk8Xz1NqSwDHEtxhCepLawNiW5yWAbZHYUKeqrtU47OAg2rfXfulMedYOtbwy8qh1kpjPK+rn3hKYhJiRB9JwBBJ+bChBW5UKSaYkqjDI1E/QEa4WEGtQuhorECP/Duqd0LoTvgd1JC3XJ8e+1ufErzVg71u/6FyxjIh9BnK/y2BtVcialz4AxyeZvLYCqc5wAWl5Xn7/vqTD4Wpj6bDEwmFTotpgk5SrvHWzMSm/E1UnZylw87xpl9nr0zZDDVtd+RWaMjO4T29j6hBGc3zN5KdCN42YA8/GSztzdqC/IjCc17acum14X/GTUa0DsTFIEW5fXz3VfvPuNrmSt++XmiUoPB+3SYkKqLkribfN9Gd00JwZftwRC83DQiB+Q62zIctfBjXfF X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69a9ab1e-8f08-493b-6548-08db935bef73 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 13:25:27.3587 (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: tcyiSfbsGpSqc6U/t8W9D7YUxIGsjfuehn4vru1xHwAdHBz+d/rBr0CT+dZEN87ALw118eolpE/ciNGw5agyww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8613 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds the possibility to register a broadcast media endpoint if the controller has support for ISO Sync Receiver. --- profiles/audio/media.c | 81 ++++++++++++++++++++++++++++++++++-------- profiles/audio/media.h | 3 +- 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 15c64c8d6..edf106a12 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -105,6 +105,7 @@ struct media_endpoint { GSList *requests; struct media_adapter *adapter; GSList *transports; + bool broadcast; }; struct media_player { @@ -1059,6 +1060,9 @@ static struct media_transport *pac_bcast_config(struct bt_bap_stream *stream, { struct bt_bap *bap = bt_bap_stream_get_session(stream); struct btd_adapter *adapter = bt_bap_get_user_data(bap); + struct btd_device *device = + btd_adapter_find_device_by_path(bt_bap_get_user_data(bap), + bt_bap_stream_get_remote_name(stream)); const char *path; if (!adapter) { @@ -1066,9 +1070,17 @@ static struct media_transport *pac_bcast_config(struct bt_bap_stream *stream, return NULL; } + if (!device) { + DBG("no device found"); + } else { + char name[30]; + + device_get_name(device, name, 30); + DBG("device found name %s", name); + } path = bt_bap_stream_get_user_data(stream); - return media_transport_create(NULL, path, cfg->iov_base, cfg->iov_len, + return media_transport_create(device, path, cfg->iov_base, cfg->iov_len, endpoint, stream); } @@ -1238,6 +1250,12 @@ static bool endpoint_init_broadcast_source(struct media_endpoint *endpoint, return endpoint_init_pac(endpoint, BT_BAP_BCAST_SOURCE, err); } +static bool endpoint_init_broadcast_sink(struct media_endpoint *endpoint, + int *err) +{ + return endpoint_init_pac(endpoint, BT_BAP_BCAST_SINK, err); +} + static bool endpoint_properties_exists(const char *uuid, struct btd_device *dev, void *user_data) @@ -1351,6 +1369,17 @@ static bool experimental_broadcaster_ep_supported(struct btd_adapter *adapter) return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL; } +static bool experimental_bcast_sink_ep_supported(struct btd_adapter *adapter) +{ + if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) + return false; + + if (!btd_adapter_has_settings(adapter, MGMT_SETTING_ISO_SYNC_RECEIVER)) + return false; + + return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL; +} + static struct media_endpoint_init { const char *uuid; bool (*func)(struct media_endpoint *endpoint, int *err); @@ -1366,6 +1395,8 @@ static struct media_endpoint_init { experimental_endpoint_supported }, { BCAA_SERVICE_UUID, endpoint_init_broadcast_source, experimental_broadcaster_ep_supported }, + { BAA_SERVICE_UUID, endpoint_init_broadcast_sink, + experimental_bcast_sink_ep_supported }, }; static struct media_endpoint * @@ -1382,6 +1413,7 @@ media_endpoint_create(struct media_adapter *adapter, int size, uint8_t *metadata, int metadata_size, + bool broadcast, int *err) { struct media_endpoint *endpoint; @@ -1397,6 +1429,7 @@ media_endpoint_create(struct media_adapter *adapter, endpoint->cid = cid; endpoint->vid = vid; endpoint->delay_reporting = delay_reporting; + endpoint->broadcast = broadcast; if (qos) endpoint->qos = *qos; @@ -1458,11 +1491,11 @@ struct vendor { } __packed; static int parse_properties(DBusMessageIter *props, const char **uuid, - gboolean *delay_reporting, uint8_t *codec, - uint16_t *cid, uint16_t *vid, - struct bt_bap_pac_qos *qos, - uint8_t **capabilities, int *size, - uint8_t **metadata, int *metadata_size) + gboolean *delay_reporting, uint8_t *codec, + uint16_t *cid, uint16_t *vid, + struct bt_bap_pac_qos *qos, + uint8_t **capabilities, int *size, + uint8_t **metadata, int *metadata_size, bool *broadcast) { gboolean has_uuid = FALSE; gboolean has_codec = FALSE; @@ -1546,6 +1579,10 @@ static int parse_properties(DBusMessageIter *props, const char **uuid, if (var != DBUS_TYPE_UINT16) return -EINVAL; dbus_message_iter_get_basic(&value, &qos->ppd_max); + } else if (strcasecmp(key, "Broadcast") == 0) { + if (var != DBUS_TYPE_BOOLEAN) + return -EINVAL; + dbus_message_iter_get_basic(&value, broadcast); } dbus_message_iter_next(props); @@ -1569,6 +1606,7 @@ static DBusMessage *register_endpoint(DBusConnection *conn, DBusMessage *msg, uint8_t *metadata = NULL; int size = 0; int metadata_size = 0; + bool broadcast = false; int err; sender = dbus_message_get_sender(msg); @@ -1587,13 +1625,13 @@ static DBusMessage *register_endpoint(DBusConnection *conn, DBusMessage *msg, if (parse_properties(&props, &uuid, &delay_reporting, &codec, &cid, &vid, &qos, &capabilities, &size, &metadata, - &metadata_size) < 0) + &metadata_size, &broadcast) < 0) return btd_error_invalid_args(msg); if (media_endpoint_create(adapter, sender, path, uuid, delay_reporting, - codec, cid, vid, &qos, capabilities, - size, metadata, metadata_size, - &err) == NULL) { + codec, cid, vid, &qos, capabilities, + size, metadata, metadata_size, broadcast, + &err) == NULL) { if (err == -EPROTONOSUPPORT) return btd_error_not_supported(msg); else @@ -2627,6 +2665,7 @@ static void app_register_endpoint(void *data, void *user_data) int metadata_size = 0; DBusMessageIter iter, array; struct media_endpoint *endpoint; + bool broadcast = false; if (app->err) return; @@ -2736,12 +2775,18 @@ static void app_register_endpoint(void *data, void *user_data) dbus_message_iter_get_basic(&iter, &qos.ppd_min); } + if (g_dbus_proxy_get_property(proxy, "Broadcast", &iter)) { + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN) + goto fail; + dbus_message_iter_get_basic(&iter, &broadcast); + } + endpoint = media_endpoint_create(app->adapter, app->sender, path, uuid, - delay_reporting, codec, - vendor.cid, vendor.vid, &qos, - capabilities, size, - metadata, metadata_size, - &app->err); + delay_reporting, codec, + vendor.cid, vendor.vid, &qos, + capabilities, size, + metadata, metadata_size, broadcast, + &app->err); if (!endpoint) { error("Unable to register endpoint %s:%s: %s", app->sender, path, strerror(-app->err)); @@ -3245,3 +3290,9 @@ struct btd_adapter *media_endpoint_get_btd_adapter( { return endpoint->adapter->btd_adapter; } + +bool media_endpoint_is_broadcast( + struct media_endpoint *endpoint) +{ + return endpoint->broadcast; +} diff --git a/profiles/audio/media.h b/profiles/audio/media.h index 1de84a8ff..0eeb5746a 100644 --- a/profiles/audio/media.h +++ b/profiles/audio/media.h @@ -22,5 +22,6 @@ const char *media_endpoint_get_uuid(struct media_endpoint *endpoint); uint8_t media_endpoint_get_codec(struct media_endpoint *endpoint); struct btd_adapter *media_endpoint_get_btd_adapter( struct media_endpoint *endpoint); - +bool media_endpoint_is_broadcast( + struct media_endpoint *endpoint); int8_t media_player_get_device_volume(struct btd_device *device); From patchwork Wed Aug 2 13:23:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13338170 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 3A492C04A6A for ; Wed, 2 Aug 2023 13:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234073AbjHBNZ5 (ORCPT ); Wed, 2 Aug 2023 09:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbjHBNZ4 (ORCPT ); Wed, 2 Aug 2023 09:25:56 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2076.outbound.protection.outlook.com [40.107.21.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51B11DA for ; Wed, 2 Aug 2023 06:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hf9srrJVNlXWfrMF2RodjBMPcbjvibe23T0gwYdxuf2I8OqSrK294vYuKA27xJLGKkwdYFx9TjgwS6otIK8dATFMzindLA3MYgF/KlvJKkwdbL8+6d6pHyBTvwzWn9KrBg2uzi5P4L+L87Cb50gLfpvkdhsipQnKCJ6KiWhuOvAJ4Tq139BVfqUSWVLkwYrF6RcVOCyumqugCA41hyHNHvkJX/H92Pdsjgvz7yd8MBJPngyZ2yZNENCu5q6UoVPOKIIMfRYR2eBbSImi02F2oPgDv1oo0hbYRbynqDKhmQmxo46nfjYprsMW6SIVZubSo4Eg7dQYlfaADFbaGkA4ag== 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=9oY+xZPrqsqIaUQOLZK2UcZgv8MQLra9GUE9X0JkM3E=; b=Gu9oxF820J7oGBWldMFBAihe9qx5a1RQMwExg+9IDIBoMlge70oR5H7gQRcRNg7/oUKo5sFfKj1UsTor+kgtPkeNBvS+v87BFp2C82/BbSUIbKZC7zEHqoCqRUZpRtWlzBjXb8M2Sz3h1gLRabxdQtipPmZqCUujWNGYQ1x+9jah7yHvxoananEXNFYEIbwLKIdrQWpeDr/l+ZkuLoEU0soEY9vtFVQ+X2t0mlwBiEknZWyUjXHkDwPadlWiS2Koeg6veQTaO9/pCnYPFK27Nk/4wY5o2QdEasNIWtc3tC6q2q/Kd/82FNEpD9/C82GaVcS+++tl8HqLESs5nF8xqg== 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=9oY+xZPrqsqIaUQOLZK2UcZgv8MQLra9GUE9X0JkM3E=; b=KkXI28mCoRIVQslNiA/dTSFAns6+U1IsNY/JI0HsjPZXQteCuMgb7HpYHgekdPasNTflCEBOLbVuNITkFX1C95GpbCmQbdjfnm7t3j00KzWvovzDl1mCd1/gjtExD0OioPtYqzIdrjcKBcMcpmp2hXxXZHrz0uk9LBl4ncegaWI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by DU2PR04MB8613.eurprd04.prod.outlook.com (2603:10a6:10:2d8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 13:25:29 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9%7]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 13:25:29 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ v4 6/6] transport: Update transport properties for a broadcast stream Date: Wed, 2 Aug 2023 16:23:55 +0300 Message-Id: <20230802132355.4953-7-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802132355.4953-1-claudia.rosu@nxp.com> References: <20230802132355.4953-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P191CA0023.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d9::19) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DU2PR04MB8613:EE_ X-MS-Office365-Filtering-Correlation-Id: e7c0634e-00e5-4bd7-5cb5-08db935bf09d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sG5Nnbh2h4Bz7HCP6ZW4UuanGmlBNJIMfo6srHb5uJRpyMMLP/TViykLTqcdDpE8HY8Ond47Aubfh0dPAmX4tvtRCDCf9slIhuVFnmTBEp8ck1tHJoZoH0upItSVkmYmkNXgCAzlPIx5KnS0jMSb8Z50j6CYN3HIFwBVeoX7oFKXP93sV32sDoDdyJ+8/3C3Yy2umq+/CVLY2Ln1Vh6ukf311LHS/3HTXx9K7KVu0qz3VZgsJd3xIy0pwNU6rUIR8f0T0mNTHamIhUnC9rHB5c4ebHVZ66GFjmgS/jDyl2y/RJ9z0ngJYsLUHdp/gu6ESiuGAoWESzZXuOUS1PwAuLsrCv0cPHP3SzaRV/2EtkZWI9QytWlDvPVeyK1NwBprKMQkYn3/lO5OMDGc68uUJYOlpEYqrBeFcHy+xjtGYM5NJUw8iKb6HF7X+w9seAn326AB/twO8m6ma0Bycwp3ywGwi3bSAv/awbBUgk8K4BxeZAs+/0OfrsgEvwaDT716ePt/dE6xIKLbMFz1dY5u2J0rKyV/Dc+T4KSD9U+XswL/jEqiADK3VajOL2GjfwlI/Hj/envuYul3SfqU/tJNNm6YQnLA+klfQvn1mowQrBeqfSuMrfXxtruVTsFQGID9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199021)(86362001)(36756003)(66556008)(52116002)(478600001)(38350700002)(38100700002)(83380400001)(186003)(2616005)(1076003)(6506007)(26005)(8676002)(8936002)(41300700001)(6666004)(6512007)(6486002)(316002)(30864003)(5660300002)(6916009)(4326008)(66946007)(2906002)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0e5vDYZGhge4GOchLiFRwgC1mrgJLgdnk5e2NyD3p1sIhB0Pnea0z1wVet9rzxdZxI5hL2VzPExzO9adUa/IFQSxzZfeKEQve7Ba5l6V9AsUJFBgKkWRXdJvOC5UgsZQhRacrH0S6Ktz82h7jvfz0W/lsQdfRZc+S6KyfaDx1dhFEkUX5TE7JQfa0JyDN7EsPMw6BfDwyg8TEYtQRgMvGLEZ8akHMDBpWhSPe+P4lg7PPWtO2fBNId5Z1NBgGWZsAVze169yKMEoOrPqB+uSCa3b+1p92P3Eq6eDhwYfwcdVUOsLpLVyB0DFVjXp6pkX9tCJ/hpP1+SUpstWw+5udgNAb/Z8iG9vfslpNbQnLEUOu21MkTWqnfFETj0kWoy0paHdRtQHnZ2/uPaqbdqoavrbKB/lgNS8ZctG+9TrTRe3WR6VZsUshQFCBnM01Z5M9RrRHGtzWmEYnpD9bMYI16R++kMIIRVvPh4PRnHPSIosHC4oPOKgMOi/+6SYasqNjtSedV6FNPt5yTVvflf20huYrNtZFo0mFllm5hxPpDLzWrU6oUqmcGWDRJjAidX8JPo7tJd47XrShb3t/Pf+wqhdGxjk5JXg9+JUAutSOiX5hmiG8BcTTM7mhJEnmOSn4NeB7rPglgiMSMK6YpGZHHwLJxTugKtMUVkBlJXhDgPmxNFjKhs2zSPVJ6aSESnyuNzDjI+3KhQ390+NPazA8czDVChg4ATZLpus7BK2IA7QiAK9xVYC84OPFFoENQFB0Sy7cP7K0A4P4Fw4U1bCcdT1Fiv/xzGZ7gADlQ4BmNowQ7wVGT67lWHDm9FsqTxoWRJyntX3M6mJfstFKhgwXGo8VpNA7fL86x5FR0N6euWPAwlcVO6jCQPWs1/I3Ma6tL6MhxsWfxTOlBJQnHh8Xg4DC/zduMtQT4QRanIoYBHheLeP5GPIWZcUJzqH8JP60kdPXhvQ8OLEV2tNQlhO1Uc8siZX3TMCmzxYNFCg1k26Enakgmbk/y0dHEuZf1Md+JvRVidnJv+92DLTR2o3TOLPCSpC0iWLUJILubpqD2s/PxHCDOQdNzrDFcpDVnXJzEp4FHNf7CC70jU++meWS1qcieqdsi4ayG82cAO3ghOs6RC/FzVo1SDBnc3zVTUrPdHqq7sja8TUs2yDMu2PV2bqwHtUaP4RcRDmh7HJOaJ4LKD6fe6/eiQ6o37p8JTMHwn2WHIKVcwyHn+4lXfAgvPzXMfn4IURzg8z71rASVB+12rYaAA7TtSDpcA2GjYlMhOAKbgPNMK7icQfjZDdjHub/l4uCLCR1EGS/ZzI+pqO2kSnGAOznaPJe23sWcFm0N/tP8ORSYEls0MBVeqDC/6MM/DofMO4GaQTft5tREfMaVxLgelRC90eauxmtn/O9adlIPqH8LacE+vecn94ON5h9TCgPaRvb6wUug5MsfDrHyquiqdB8TL8l1hdk7hlPCXcpspYgJFiEape04Wj6Cw+bLInyC91kZHI1qTU0k282TNlmhjkAY2aRYVzVWVeWTgb81eJhZ7guyjAu6VTbsbqdsq5YOXqHSoWbsEwSQz79mrGuJ7F9GGEiyuvlT5D X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7c0634e-00e5-4bd7-5cb5-08db935bf09d X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 13:25:29.5135 (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: 9OQ4dVuFykUyrMkn7RsRP4HawI+Mgqo5hLpOgwALHVdNie4kyZ7fkA2bxyhWUtVzV89cloDxHMf+r0kFxASy/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8613 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch gets the QOS broadcast stream parameters and passes them to upper layers. --- profiles/audio/transport.c | 245 ++++++++++++++++++++++++++++++++++++- 1 file changed, 243 insertions(+), 2 deletions(-) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index cf5662d1d..aa2fa4397 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -552,6 +552,8 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg, owner = media_owner_create(msg); if (!strcmp(media_endpoint_get_uuid(transport->endpoint), + BAA_SERVICE_UUID) + && !strcmp(media_endpoint_get_uuid(transport->endpoint), BCAA_SERVICE_UUID)) { req = media_request_create(msg, 0x00); media_owner_add(owner, req); @@ -853,6 +855,9 @@ static gboolean qos_exists(const GDBusPropertyTable *property, void *data) struct media_transport *transport = data; struct bap_transport *bap = transport->data; + if (media_endpoint_is_broadcast(transport->endpoint)) + return bap->qos.bcast.io_qos.sdu != 0x00; + return bap->qos.ucast.io_qos.phy != 0x00; } @@ -868,6 +873,18 @@ static gboolean get_cig(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_big(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.big); + + return TRUE; +} + static gboolean get_cis(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -880,6 +897,18 @@ static gboolean get_cis(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_bis(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.bis); + + return TRUE; +} + static gboolean get_interval(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -899,6 +928,9 @@ static gboolean get_framing(const GDBusPropertyTable *property, struct bap_transport *bap = transport->data; dbus_bool_t val = bap->qos.ucast.framing; + if (media_endpoint_is_broadcast(transport->endpoint)) + val = bap->qos.bcast.framing; + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val); return TRUE; @@ -910,6 +942,12 @@ static gboolean get_phy(const GDBusPropertyTable *property, struct media_transport *transport = data; struct bap_transport *bap = transport->data; + if (media_endpoint_is_broadcast(transport->endpoint)) { + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.io_qos.phy); + return TRUE; + } + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &bap->qos.ucast.io_qos.phy); @@ -922,6 +960,12 @@ static gboolean get_sdu(const GDBusPropertyTable *property, struct media_transport *transport = data; struct bap_transport *bap = transport->data; + if (media_endpoint_is_broadcast(transport->endpoint)) { + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.io_qos.sdu); + return TRUE; + } + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &bap->qos.ucast.io_qos.sdu); @@ -1040,6 +1084,121 @@ static gboolean get_links(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_sync_interval(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.sync_interval); + + return TRUE; +} + +static gboolean get_packing(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.packing); + + return TRUE; +} + +static gboolean get_bcode(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + DBusMessageIter array; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, &array); + + if (bap->qos.bcast.bcode && bap->qos.bcast.bcode->iov_len) + dbus_message_iter_append_fixed_array(&array, DBUS_TYPE_BYTE, + &bap->qos.bcast.bcode->iov_base, + bap->qos.bcast.bcode->iov_len); + + dbus_message_iter_close_container(iter, &array); + return TRUE; +} + +static gboolean get_options(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.options); + + return TRUE; +} + +static gboolean get_skip(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.skip); + + return TRUE; +} + +static gboolean get_sync_timeout(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.sync_timeout); + + return TRUE; +} + +static gboolean get_sync_cte_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.sync_cte_type); + + return TRUE; +} + +static gboolean get_mse(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.mse); + + return TRUE; +} + +static gboolean get_timeout(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.timeout); + + return TRUE; +} + static const GDBusPropertyTable bap_properties[] = { { "Device", "o", get_device }, { "UUID", "s", get_uuid }, @@ -1059,6 +1218,17 @@ static const GDBusPropertyTable bap_properties[] = { { "Location", "u", get_location }, { "Metadata", "ay", get_metadata }, { "Links", "ao", get_links, NULL, links_exists }, + { "BIG", "y", get_big, NULL, qos_exists }, + { "BIS", "y", get_bis, NULL, qos_exists }, + { "SyncInterval", "y", get_sync_interval, NULL, qos_exists }, + { "Packing", "y", get_packing, NULL, qos_exists }, + { "BCode", "ay", get_bcode, NULL, qos_exists }, + { "Options", "y", get_options, NULL, qos_exists }, + { "Skip", "q", get_skip, NULL, qos_exists }, + { "SyncTimeout", "q", get_sync_timeout, NULL, qos_exists }, + { "SyncCteType", "y", get_sync_cte_type, NULL, qos_exists }, + { "MSE", "y", get_mse, NULL, qos_exists }, + { "Timeout", "q", get_timeout, NULL, qos_exists }, { } }; @@ -1341,6 +1511,71 @@ static gboolean bap_resume_wait_cb(void *data) return FALSE; } +static void bap_update_bcast_qos(const struct media_transport *transport) +{ + struct bap_transport *bap = transport->data; + struct bt_bap_qos *qos; + + qos = bt_bap_stream_get_qos(bap->stream); + + if (!memcmp(qos, &bap->qos, sizeof(struct bt_bap_qos))) + return; + + bap->qos = *qos; + + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "BIG"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "BIS"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SyncInterval"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Packing"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Framing"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "BCode"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Options"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Skip"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SyncTimeout"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SyncCteType"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "MSE"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Timeout"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Interval"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Latency"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "PHY"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SDU"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "RTN"); +} + static guint resume_bap(struct media_transport *transport, struct media_owner *owner) { @@ -1493,7 +1728,10 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, if (owner && owner->pending) return; bap_update_links(transport); - bap_update_qos(transport); + if (!media_endpoint_is_broadcast(transport->endpoint)) + 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); return; case BT_BAP_STREAM_STATE_DISABLING: @@ -1503,6 +1741,8 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, return; break; case BT_BAP_STREAM_STATE_STREAMING: + if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) + bap_update_bcast_qos(transport); break; } @@ -1631,7 +1871,8 @@ struct media_transport *media_transport_create(struct btd_device *device, properties = a2dp_properties; } else if (!strcasecmp(uuid, PAC_SINK_UUID) || !strcasecmp(uuid, PAC_SOURCE_UUID) || - !strcasecmp(uuid, BCAA_SERVICE_UUID)) { + !strcasecmp(uuid, BCAA_SERVICE_UUID) || + !strcasecmp(uuid, BAA_SERVICE_UUID)) { if (media_transport_init_bap(transport, stream) < 0) goto fail; properties = bap_properties;