From patchwork Tue Aug 8 11:50:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13346356 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 920D5C001DB for ; Tue, 8 Aug 2023 16:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232520AbjHHQ21 (ORCPT ); Tue, 8 Aug 2023 12:28:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232821AbjHHQ1N (ORCPT ); Tue, 8 Aug 2023 12:27:13 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F0A211F52 for ; Tue, 8 Aug 2023 08:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZwP6G8ujXkXSS7oRIWcO2SD2znPi+3wsi3xBxWvD4QirY7PbrTk4vxacfcwDyVDQfx5dv7RvAR/LHyNVOwSV/Zj4OAQLkuMqWVuII4hxkQF/vxi61vQh2dOKV987pA0L9S07TdHkXcIQgaA99w4DnBP9kQ0eotEJJAqaFdJBpNevHUekvi2cb5f2zpxjxS5+/6Y2mxq0WAyCAdyf095mxnBZekK0wImrZeXxp4grodlKfmSg5a06hDFGDL24J8Oyb4n7PodDBYN6i6hH4RHlEQ0mkDf667AsC5i01SoXr6xKVadGYfbP0YXZZVWwc/qTDNWSdyWhvFPIf5MQcEqmfQ== 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=lZ0vj9Pn+dlPlw6GjfFfhsMK5a+zjGE47Y52hxTALflhVD+eQ4XpAkcKwaxMBVwj9o3sSzxh7jO9KarGFt2eYmSsPYHV/gQd9MfyvVZ5xnBPNkWBxpZofg5M3IvmkcfWScEG5Nf4rb1/GR7pvjhgYlcQYWppNSWZ+i9PChOtSwLMCeDAvjE1EfE5IddJslFOLQgK7WzlOgPbZi1dvoaGejiNyCyx98/XHSqVl2qGfu7HY2iJVgr/0PrNUcUGFG9Lm2N4fGSpoy0CadKGkPY5acrVkkxAutZ6htEzIaJKFJ+HqrOyjgbz57mtVzOgTkve0QeUxjDaVqjbuQxHFHaa4g== 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=ZUkVXWkYG7qf+F74XV9yUENreQz2BaWsHXsFXp1BJ4h/ghP1s+7EHsZNkw7NxcTZQCA74LEpcN0Mzhamr/ZGcuAGB/JJxtEp3X/umBkHHu6AWJRnX+UO4DID5OIH347U7lCqh8TBqTNjthZ8kvWRIbNm8cvO11FB7MjzZw1IE8E= 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 DUZPR04MB10062.eurprd04.prod.outlook.com (2603:10a6:10:4e2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Tue, 8 Aug 2023 11:53:01 +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.6652.021; Tue, 8 Aug 2023 11:53:01 +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 v5 1/7] client/player: Add broadcast sink endpoint Date: Tue, 8 Aug 2023 14:50:34 +0300 Message-Id: <20230808115040.4403-2-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808115040.4403-1-claudia.rosu@nxp.com> References: <20230808115040.4403-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM9P192CA0001.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::6) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DUZPR04MB10062:EE_ X-MS-Office365-Filtering-Correlation-Id: f52b11ad-9c11-4499-a41a-08db980603f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S6FuORQhlXchA3mqJb8YxkkPyKWEr6e4e7oHRQZ0sH4LLXp+2FAvnJdyyh1yDeGCERo2PY34C0hGw38XUYjx6wTpnht1CvKWossrNzZz+r0BWaP+8Zg/TAd2ayQshb6myKfAHFBW2dyrqp5Gn7aUIEqVorF+ByVP/ZDqOZhjm6FPn5+mRgMQaakzoXbI/DZszvVfY/71go9wg+xchPaLLYN2Z80i2Yvwo4LFQYyB/rPpFCvTKL1hcX1Sr2kPXq931Q+z/qJUBs1PyCOar6bHy8TNJcjrHs/dMGw5kx2KtI0/y/Je7y00FOdB/qarSpm3U8+nM3ZtMk27vATHfuqfi6IRRvNqxjNaiGJ2bCRsujfS/3dOHA1MvMI2Ukx4dv3OY3cka19hOBxL4jSvch8QvKj58wRxa9eEATGNEEdII8H3d3y1aACinGfdHvQevf4lAaCD40+hvSzvukxvDwEVfQMjMBzDkm/EQl8hGRdt3BqrtX8UvmqRpQwNnmIBCfuazW7RotFXT+1sgaq4TMmzuGLNxJmqI/074Zz+MVZWVd77RN3nWrtIxQHY0CKRSkWrTU6oVHqjsMJdYaN3oaQMwrb2JK3nkNrxBhwskAP77F5Ini5Y2jmSOoKR1NWb96uN 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)(376002)(346002)(396003)(136003)(39860400002)(1800799003)(186006)(451199021)(83380400001)(2616005)(52116002)(6916009)(38100700002)(38350700002)(41300700001)(2906002)(4326008)(5660300002)(316002)(8676002)(8936002)(66476007)(66946007)(66556008)(6512007)(86362001)(478600001)(6666004)(6486002)(6506007)(36756003)(26005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ozfJTpdOmdGJ4T0+3WY9lg5MZaNp4eAKpzc1mxtr16WgzHRI1AO9hq0LCSj4+B+rfSnh7VgprWUv/oxrgeu0K89Non+8xtusdI7iQ7XZTz8UEqznD6A/rqXMhTAOwPIRXyntaOb76INaebT0lOB8Qp1gfm/SqwBatVpeYSrIThGv0O7r1AATYY7ZhASc2AxncuCiSEpso22NDJ0jdF3z4D1eCgqd2I8IO/OszYLXEf2s8GTmd4aNDKA/kU059hjWwL77C3zjM3S39QnJO3Isk01eQbmsfi4H5wIrKL/E7edwFr5Zo0TBr66YSAZ5U8YLqT/2APn1NVr/sTIuu9dIjmUik7GwHrG0BZeHKKyXTSDCTWoOS6ZEC0bJnsm9be8dd+vie/3fMrSpvotcj+hDKrFEIFnJcOjDeXeXvOdvLQ6jFfi7tah11guMBcvM3E6npUsw3OhYOJF6yNoKBNuFf3zl1vTqsDM/HVmoGqzZgMdTxebGHeEoc7SfDJ+v700onK5MGZKzQ+JuRV+BtHIuXrcqOp7kjLr7+KgkV+WeEWB6iDA6PsKmInO2Mv2bfxL1HQvb9qnl3+eXB3EBYVBRMeLcKqVxxiOx6HBKC3cKDoBRCXsqG/uAqp32jjBv7ERQ2WsMFc2n98MOyfQ14TOA+mmN4X1mCaFGjGfMVmCHBcERA7s/hH/c8LcLpuYUeDcRTCZCmx8e5UCII9f6vF9hbpIOMsnJ01TMS0Nk25jq+n8/6ka9LKpbL6Fo1sZsqS1PO1hd7VtBq/YraqKk7wKeIIdKujYN0eldTbW0gyYBZgcngC3oAa5CGigkoNqwQOmIww5RrvBIAdZiHc3D8WW3L0l7F/9uV4cMkgzy9y9qbRmgDkgzw6ojixm9lhb7oecEtA2w/FMmxrw70Wl9F1+YVfn1Eb1dV3L00XS8pQZz2dZxhYoPK50+DRDLIFDBBzBnX6m1zEI8u2PGNgSG6pHj+e+fG3FlFiPRX+5IUewj3aP/y+tw/3c3ehb3bXKQQwMayEyDv1wEs7Q7lWH+/kPMujX65CjWmHe61k1dRecjS8UN9XnPPkvJmooIJP+M3XGgfPz4qG8Z2efXa9CpzKxsm7OkALw8qNtngJGiA8AiyxRw3m/+vnZwqDJHQwG0rIYr3za01h2076PnKx0u9U/axcG78QYg9lNamXcpLKaNx6409TgnTGqOu8Oahojae4s/dnA8Nj9EwGGhc/28cocjv/y/nLgh5ZRYc5i6YvUtKpODKKCHk9ST4pd5hakNRcx+F/Un0vKcYKLtFxg3ThPfMzK0bHyOidVlRGlAiK7fGQQ8uMoZ1ZUeIWidIrmtpcpgg4R1cZRG7Ld2Ot2PPQ6I5EN2nvkhrfo4HuempD3G6aFBh/p+CocJu7xp0maxUmsFqpZEEzp4NRX3mvU0Z9T++FXkzX28STQBDywtoeAv1NjI8Jv7Az5yGIit90B0yFMoBdHpGhTe96AW52tqEyP9SXvL1z+IvP+73BP1ByWoDrt8sGz0JYYU4+l8HYpACC8Q6UF1/l8JLpsFpzRkFjiDfm2hFBI4YQLlVAD8M5gvEiRjCFTSeA5867/PuWtOjqYSifEKuAYxlvWrsZQwBExhww== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f52b11ad-9c11-4499-a41a-08db980603f6 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2023 11:53:00.9485 (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: 5imGn6p+ES0YKZAhc5qQU6fJpdtF8D3MfgDmPrPNIb0WOjG5sTvBxGt4IYdCXzJn2SDFGm5zUft6ac0+Zo4Inw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR04MB10062 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 Tue Aug 8 11:50:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13346357 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 43D15C001DE for ; Tue, 8 Aug 2023 16:29:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231464AbjHHQ27 (ORCPT ); Tue, 8 Aug 2023 12:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232625AbjHHQ1V (ORCPT ); Tue, 8 Aug 2023 12:27:21 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2072.outbound.protection.outlook.com [40.107.8.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 031FB11F5E for ; Tue, 8 Aug 2023 08:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dby5z8trP3SRp2DCrj46TQhPvroAkLgscEHTMnsuehWobDZ4NWynSY1mf4ArnE8DPQzh9ekk7ptpwTZx7mclyLFF1r+y+REIIrJdIiOIguT+KM/FYV0zCpBVLhGvCjjwdEgCE68OQxNKZPUpidkRCaFkNKxk6iFcUhOYntGd8bbH8SlLpjiteYfyEFJ3KFAdbGvW8XnV5m5LJbIwM/ezN+g6DZpbJSs50xpn0Xd/x9pJSiyY0wIsw/6vdfEfn/YhdWwncspsY+FTsfrKPt33w8EiFzSawXpUYGIbPzIIygawxxV4Ef6e0iXqVKRmL31ozB6UN2Jsa44mPPDDnbfGvQ== 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=iY4J6/NtqeMi4HJWrn9cHQWEAZRin4LvL53kZhDkIc2QOlwyveuKBkIAtBAeLxspFkkMsTUGLpxcFkysxfPVneAOxAa8xf+AC5hcgfQOBFXBykcbVTSFl8jXCXnAu4Qn/m3ZN2PZDhb/Y9DEn2uzXlTSXnauyv836cvDbfOAfHz3Hwu/IaaIkTU4DAZfkU7bNB3LZ0zIsMf4aSGRJZ94KGBtDn0+yENEE/IZ0HFveo7Y3eELvVqG7wSEb3sad3wPwDH3tInxbzbR/nEomt7kO1M9sUok4r8hlmgUDW9UZkR/1lrj1fn9C9l60sBREv/4nBjSHVcO8xUNOGToX+6WRQ== 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=pPWcJECbqOINy1tBjLXPKFDOfyxuJMnXEjBMAm2TD99BARw4PO9+g85ZzgJ3QQuAfJe4Vu7PmFtulwfwsqOvvgeh948bL/lTpFLE89k0AAvQLujgmwGNnhTJeXxGwPUP8CN6xPZZkE3EQfJRhylUIWrbZ07G33kxnv6h29qjTiM= 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 DUZPR04MB10062.eurprd04.prod.outlook.com (2603:10a6:10:4e2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Tue, 8 Aug 2023 11:53:04 +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.6652.021; Tue, 8 Aug 2023 11:53:04 +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 v5 2/7] btio: Add support for getsockopt(BT_ISO_BASE) Date: Tue, 8 Aug 2023 14:50:35 +0300 Message-Id: <20230808115040.4403-3-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808115040.4403-1-claudia.rosu@nxp.com> References: <20230808115040.4403-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM9P192CA0001.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::6) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DUZPR04MB10062:EE_ X-MS-Office365-Filtering-Correlation-Id: cc509657-7464-483b-e9b0-08db980605fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eQSyhgyfwlRPkBF4fhVKOuDCb2h/kD31xCCbFncA5m2NZOeTjgTBdgPWf+cm21kda6acivCAOBuC1O9gnor5YfqQOu1DXptZTGpkdtPB8c/vd9Re39m+90Qkyg221NZOusfFQPhM27UME8dHjYuFZIXnqOL/niX7IvwT87JekVuJPz6ZMhuNr8C3OpaW0s8DE402SpI8TmVUILJ/tkYOX9GcTvpIu7owQ59mNn0VkW4OdwWEBCFfJSfCmODXlsda7wcTaFqsat0nkN8KFbK5GGbLkRQ4rumkPcailrpo/BQnmtRTImrSecxg6NbaRDxt2FmfHST+3oxCq9AF74r7l7aM1C8u7a4KjWPJ9Im1QZiUzb8nZNZjR7hNcM7/2X1GWLjbF9Ej9/JW9MO3d12OhuyiA55eRy07a7oNzSDujhOH4w8ZKGR7iMstrUqKlVugDpKUeUene4oo7QPnsi16FN4pF1j8p85t6G0YEb2HLJfGzvTc7sJASsI8J37psiChGRY+e8FiJ5Bj3lG/KY5xrcMZNP0C10ZNS7PsuzvraDOsbZF7hLufkN8Jn9AFzsBPYRWxjkMIcvP/I6HBMPMmCoU7IehzLnOog2kKVFDIHgC/Df+tHrzlMi5QijnXAJtY 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)(376002)(346002)(396003)(136003)(39860400002)(1800799003)(186006)(451199021)(83380400001)(2616005)(52116002)(6916009)(38100700002)(38350700002)(41300700001)(2906002)(4326008)(5660300002)(316002)(8676002)(8936002)(66476007)(66946007)(66556008)(6512007)(86362001)(478600001)(6666004)(6486002)(6506007)(36756003)(26005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xT6DDSDbWMcVjBsOmTsZ+Di+5L+KRb+quyWX22YJGyMviJNtELn/teIC/UD2L+cKHGvFypEgpO1urRzQ7OE47tJ30+ss1xjPDgpsNzwzkJMUkfsYlQy7JLB8kaU6swjD6Eznz6/hipRQIUPzG3AGbQgELwY95Pv6L9aUFOmDZmfcpcwBN449BgN4WwzOCNmicu2p9P7M4zIuswhwi9RmoLESVsZHXLex3s1xdXdESz0+BImtkmNqznRFYEBWS7pKGONhS1Jnq6vCG61FeiWeF66vn8tvlXtCtpbOe3cL27Ts/ZMNENDf2cAwU8tqVtkqbiSUzuYxWTzwQFq1BHGKSJYmOME6N1hn33ymg1C8sBglIXWzkmnkEH04Vw5ya08E0em9mhHh+9wgaWkTK48zzyC4qoYiBMDrs6QUZcqvWgMJ6r72mU2GVY5e4BKzg5SJNcT0npP+eK/r//SZGe5yfZPRz+iLVbsO8cfKgXeZHZ4sS74oT76B0YVyRlAbCBOtYQGy/bzTHjJrUj6meoGKwTq0zAL6dSVAAQxK3toIQKSL9ma3jmIX+1D1ziZXiH6m+cMPP3O6/3VaOIJngPVCcY9rFpoW5i7X7vMMw783uTZWY9lWhWEnl1N+f9/BXBsAGey8qOwtxMxkiPekuYRjGnEEIif8u4M0X9z0hvzJvf8N8i4f+Ge1y4Z4gtChJuukxqmvnzXmyEPpZIcCh64B6npopbpuc/TBN2Vo094RnZZrDDcxuhGzQzd1y2EmOw1FC4b3F0jjLremFWmgGQlgEeUChE3f0ygo1dT7xhbPP0fOV4yMx71eTcLKZOGYgYhJzsd51Yx+iD68XSTBmrKjNPt6MZU5rKh9YpPgp+q5dfNhX5l16kxq9GJow1CWO9/Smkz7BQtb8ADnVKwbPlhpO3XYkkYOfcnxyJQJnxyWeMv80c28VLSDm4x7Tu0MpK05tlc/HQFFAyxd/mZJvBdXvcXz+HLryMXkjzlvswU/3CknYT+fhx+v8nExOug32l5aSYCqTNgExXyG4kwsnw6HHXjU1FIuhRnaFxGkNGUY4c8NMPdNCUeNJK+9qWEVH3HJu+Zt+nS09Ml93J28SjfIVSuIyrmpOMTzYuDky38PN5tJrgTCITRNLMW9C3ZouBxQd63msZQGNnEZaU12j/DyhloxDTvYM+Agza+We0m/+GxeVdonaTWTMyDPO7N+8PIAl1bAeNyskeEsxWGMvy7IXvRitMnmkIORHCSN0zuDs7+nxb34I+NLE3QEkQFnxO0ybw02QBtsjdEx6kD+W6YQywk6CYHE7h2bIvWRgVufG79GzRywhd4ST+2esEw0ABgOZb349VSrKPRffnHlIPiSF5D6KHryjz0bHPZ34e109Ng46aHsBAbF6z84retC70jOEbXI/+NgEiDHr02+7T4uvjtHYw8imcNXtSEoIYqSO/g43fhD3G6RV0UGz3IDOQfw4L6MyUg7Nxxw0kozj+evGOFz1gmsuOEqLYNbIj5a99gDhn7I7W1aazTPKqjZS0grHDfIPPEMfwRr0F4E71vRosToG2g/SVDco/KjEAL8P0xMUtsv5R/lc8v52WubWp2BhJm0i1ldO9daip8SkskMRA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc509657-7464-483b-e9b0-08db980605fb X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2023 11:53:04.2606 (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: Tn4HJ35WiRqb93QvEn71gbuLn53bwGJX/QNDB8dxX4T2gMXbR3H0F6FbMCNbysSembEQzETvACZL1Albi4OTJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR04MB10062 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 Tue Aug 8 11:50:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13346338 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 B975FC001DB for ; Tue, 8 Aug 2023 16:25:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232554AbjHHQZp (ORCPT ); Tue, 8 Aug 2023 12:25:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232569AbjHHQYd (ORCPT ); Tue, 8 Aug 2023 12:24:33 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71A58A5CC for ; Tue, 8 Aug 2023 08:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S0loXT0qo8UfMM111pB+oIFBi9/cMKfulQTxko5VbEs7lVAfZGiQo9thWnp3Nz59/smcwA6JPthGhN5LPS1nfs8lIGEZ/I+ZA04tUwo8XQ10264MnpeZzG8bVPvdPNXT6ZXE9ELhDhmtmqzgh0xtbgTgE8Ous2mT6Djr/xaMvIyleHh/KqVSDrJFNtrXQZgWyMHWjRYIk79Nbb2VJdb4zcLEuAJ2dADEp0BN/gOw04SGFEtpfb7ziZG2N6oOjFtjWyzMfzIKR3wunCTPS9LcZ+0iU0n0pvNk86SEoNV2kCpHj+E74/17j+oj07IeotfZAJB8j9vwN81ZhZZ4CtDNug== 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=K5bHrovpbdzfJp3RkXhHxPtOX7ZHh/SFYq7JwevtJlc=; b=R7SBuJYKADZJQKJ97CzWSXz+ak8orTCc0YfIQhI17ake/00ALK4t3Ikiun1T39tvFMxJVC2BenLexqvMKi4p4EaNOo6ah24fzS5KBo5hB67yEFCchL6ka6baGBYXw1bAu2jqrqWFc6RVdIckcjVxPDSLnIlDn5a7qw8DTerS89y4e26M7y2w+SnkGPYz0dZsiPQtqhb6+sIYVGcVKcx0/N0PkhVKAJc5BijUvMpuRRzPP4+zHmDWMJrLqmCMbi5ovAf5HphAVHKMchxTdce4pxxPRDDLrCD5nHJe/HwyqLOBTU64HjAELy6NXRImiZp8TF4qrJJUrXt1zNH1ysZAtw== 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=K5bHrovpbdzfJp3RkXhHxPtOX7ZHh/SFYq7JwevtJlc=; b=INyWMedVTfmVwpIB9COS5A+wiQL3m9AMTA661Y8J9nL8UbdzmpStKVj6stjmk4BNgKPGoFDVxHPAcSYX/kZ93XmJ22M3GvUWUaUPJLjCV14+DM82ldzPmWRC9fAQl5q3vzoh8UOOvHdgEM5DpB3dkSYvpUpjo1S2B3UQzIOpiqU= 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 DUZPR04MB10062.eurprd04.prod.outlook.com (2603:10a6:10:4e2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Tue, 8 Aug 2023 11:53:06 +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.6652.021; Tue, 8 Aug 2023 11:53:06 +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 v5 3/7] adapter: Do not filter out broadcast advertiser Date: Tue, 8 Aug 2023 14:50:36 +0300 Message-Id: <20230808115040.4403-4-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808115040.4403-1-claudia.rosu@nxp.com> References: <20230808115040.4403-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM9P192CA0001.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::6) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DUZPR04MB10062:EE_ X-MS-Office365-Filtering-Correlation-Id: ca60772a-eb4d-4ea8-c99d-08db98060750 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K9DZ5F1WayevU8KvHtehuGrJRb6UQSc+AM30CMc9i9PEfCLNDmpeaBEY/TBIc1aYRzLYNpaL1LcmfsGiMEyrSHHO5ReNlCBSKOvcKC3sPPbc62iBN8qrfkbO0tWIDyWD/bdCm5MyFkp82mo3y35Zw0o1dxzQXy7Aw1yrgWt7PJrWLdrbE1A1LXwzwXy29LqLHuMlMXG9Jjc8ttDIAfiDBWt1gfH96XsDbI8fs5GtCbf4lISdq917r8PQRbgdLW/RGxF/SOQdQCkEQmuOc8BAZbWpWSh5E01P7qwDn/Xo1iG00Mqc0SJjdBAPQi+ukM/g5HxY7bPVVFIOUPdgvxS24wbMOqhc+tlTpwhbCLRbf8cOH1SsYDz77IvUS/N0JjLmspgfsb+i7SzO00GFvcGqmqCviPujkaKDy6rNAzrA6lUicPC62N4Nt7Bxg4zrWsAdR6tsNVUPNsPqKy4jlPsRpGrmwdhmtlwICbQ+unmA3731mi7VnYlLczjURvDAM2hgqHEEO/ZmCyL3sLj1Jwd02rC+thojsx5T+/zozj3TMMipCWfl5pgck4abZrLOiI+Em9Knd/IpkeMaNnGuNxv7LTXS2nNfG/ayi2LOa0M21frWyGIdvmBj1ZpOGfNXsQWg 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)(376002)(346002)(396003)(136003)(39860400002)(1800799003)(186006)(451199021)(2616005)(52116002)(6916009)(38100700002)(38350700002)(41300700001)(2906002)(4326008)(5660300002)(4744005)(316002)(8676002)(8936002)(66476007)(66946007)(66556008)(6512007)(86362001)(478600001)(6666004)(6486002)(6506007)(36756003)(26005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rOoIoqG/UN9uiEKJYUqV0vNp9G/dN5uE1421JnNvVnF5iiaEYx5B4YAGBRP9994P3YMyc/DX30yamdp3f//PsGTiosa+xW4tQwzBBzV7lNyNIT6TNdzX43GvsGFZbRM3mgDoji+UYuoj1a1SoaUm9fg2xpymeXzLslMnLG+0wkClnORgyAj7ZXcrmfFi6QXrSBXEk5yAmk9sKmPMh16dVMtrvJQi+1LmNvWWgcwYZRzXeW3I2KPbAdxI3xDLskKbYHR4TfHIA6BqgvBPUsW3MPZ+vjrYnfLA675SLbaBq3b+fiJwc+gVuad3u0OET+f56tKZcYvwm/TnALci20x/eGCbsxbrqidK/PgBCRVqeM1Asfs3DV2PwTlmyTvD2gyiGLBtjBdJqWeDyhjjYG24I0S7/Z03/BLrkJWpeyrtwe2+g2aAaSQFjEMKabKZ0XoWXKRT9YUVUf4vK4vwiGz2WloACkB7+C2W/2w2UIhtqTJ8YlwBHvIX+qfSZ75K/dkpYTFUjitnVL8Nwmsfd4xEK9Rdz+48ducPZxv0nGrtENAsuWWirexUEmFyxAE2YIfhjxNvqNz78BhH8Py0uHvO8ZDaaKtBpdYyvshhcLdpgyVqdUCKPmvCql/8f88GeQ050vrHrXDNcrEAp8oyifKFaM4DFBYilvgVVroCMX3FsBStaXSupL3a1cNnvsdYx00xnR6uv6HOnbZG89JavvCO8IXpyQFSUuxAV6iCvn51Rjq8RgsVaCEW0Fr0nM+oGnzkvNEZ2YIFiyhXMGdmGpREi8CHbBrdAsqUlTxW2QaJthMt+3XRGuLgykci+XLk3bPEURHHple22B5lpKHSvgBnMQTTRhu/r8dp7+IC4jPltXAXkBzPMoOt2PrQ3MszAq1gF0fQsp/7P50U4Rm+llVhIY5GHu41DS29RCQkLXWvTh143+WMClk0RxIE4I3Hwn78Xg+dh2ah8N0/iAJvENAAmtsTU6q30uiCOMMrqmlLy4iTZAm8J87E12i5kw6jUDlc48/ZdkXLIyiKiV3HNQegMmIw2pknhh34XcwnPilN5KhYGXvNxkYTnKSZHOxcnwjt4nKRIq+MtC6KIZO45HlbF7vtDHU/uZbLdDHeG+WZxFxAGCWZUn/CS0K84KD/1S+AORw8Bcq4PbQVmS9HKgtYamLTKZoL4gPWXHxItPkNkYC6oxbx/fivlY2gCb4UM/bYOBnSqtWVS+SibK9sSIwPAnc3jpZ9ZDOmiHPEaG+lEH45oJhq3ougkcb67K5iep+fdKxjQ8PxB2s2xXAt75GyE+1lwW1xeIsPgWkCuMahWqcqyQAjxy/QITwVPjUHxwc6mpxRgiBD5YGwHaRwvpmVYIibhf3nzQ4vNRqgS08jU35K1M7mlo8xOf1FsMFD+D+STwhDn5672dakzWw6qJZle7sgOLvJPJZGnutTZSncHdzS4qdWQS50XPzzzeAyoyCQwcLO5d0IE4JJ6jVTEywQtxS4pOHdTl7JC/Txrvb453Jw721Fgqn7UCpQExsKokc+9LVoyccOKW4Qo4akt28i/ra3iOQG7C14sHPVlXnkOxXzrPpS3NvEi/nTkRQhjijFf0b3I+EGlw0giPqClR5VuA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca60772a-eb4d-4ea8-c99d-08db98060750 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2023 11:53:06.6291 (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: z5/AQbwEEE0H82kHY1UEStEEnUAlAaOAajUn7MNmrT3mFGrDjMI3l5ONrc+STQxOhJMdlmfxInRURiT2jmcGcA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR04MB10062 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This allows a broadcast advertiser to be passed up to application, if the adapter has the capability of being a Synchronized Receiver. --- src/adapter.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 491bd7031..fa15030e0 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -7029,6 +7029,13 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data, return got_match; } +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 void filter_duplicate_data(void *data, void *user_data) { struct discovery_client *client = data; @@ -7152,6 +7159,9 @@ void btd_adapter_device_found(struct btd_adapter *adapter, return; } + if (accept_bcast_adv(adapter)) + monitoring = true; + if (!discoverable && !monitoring && !eir_data.rsi) { eir_data_free(&eir_data); return; From patchwork Tue Aug 8 11:50:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13346339 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 407A3C04FE0 for ; Tue, 8 Aug 2023 16:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232653AbjHHQZz (ORCPT ); Tue, 8 Aug 2023 12:25:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232578AbjHHQYi (ORCPT ); Tue, 8 Aug 2023 12:24:38 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2072.outbound.protection.outlook.com [40.107.8.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFB9044BA for ; Tue, 8 Aug 2023 08:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C4zwYhyhvddoKXPcuQevpeicDiGS4W1lJ8ITXstbcIc9zD4auC1ZJCuxF0bPxUw23EHZnydGRdP+R3Sn7uVpDWrPFDmydsOo/tpkUdLNiwwwejoX540wgMrwOF/JU9QM3FZZQ1g1CQ5b2SlMMpu3Gvj7PM30zo58lcNEGgI4NutyT9XjZnvHpvZzAfT+AAXGXqGsJ3PQ4+FBmUpKn52LPAN4DWyIWJdvgg5EWVy8E1ChLPovFrHj+IvGCWKPpF2CAU9FRF0YQ9A62ZKLUCy3EpaRpZm8fpzTheN+LN8/X98/SnI/24V1Ow60Hn1poH5BRaS1gxziUpbziGB/urRxNg== 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=JxMoU9EkIJYeRYuv9CedGg9/Xy7p0cCOhujKOR5XX84=; b=c5mz32pU6MYH25k/9Zo3EQzL1Sw3qFDi6klAPQr4L6YNVbsuD15pQrT6gpitgxVyP/QPAqloes9obnEm0diwIQC8LCMgF2tuYF3iwWr9xmvoqteYNxhgUzx3nm8gDtzseGKg7e0R4eRpU23Zv5riZpezf2NdGJGSpV7bVs0oGZB7PX5nPU0wBzU5RfV3kxL6azyu7+1s3qnAQCGLAda6xSbh8MgcpTuz8YYdYm37DM3fwjBBAzeRvFfL7J3qw0pimSmqKAWYkyOBFkBKL/mp8n3cjSPrMpLG8QBMNk1b253ju3nhnXfibEwh2J9vbqKHYOnLfygLg5upr/T+DM5YkA== 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=JxMoU9EkIJYeRYuv9CedGg9/Xy7p0cCOhujKOR5XX84=; b=Pi97i54EkL1fZXVwRBNVlKYZ8miPkWkEdShxuLTaX5rRT8Lj3rH10RbU37m9mm2tnf00Nb+tzqEUWuQpIEg5Ra82++5r8ZqBcafZStvUZsouacY2PCt2ZHNqFyvKeZWlfeqFDeX7lRWqvEwngPzz6bgxFnyw+i3gTQYtQj1Z52Q= 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 DUZPR04MB10062.eurprd04.prod.outlook.com (2603:10a6:10:4e2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Tue, 8 Aug 2023 11:53:09 +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.6652.021; Tue, 8 Aug 2023 11:53:08 +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 v5 4/7] profile: Add probe_on_discover flag Date: Tue, 8 Aug 2023 14:50:37 +0300 Message-Id: <20230808115040.4403-5-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808115040.4403-1-claudia.rosu@nxp.com> References: <20230808115040.4403-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM9P192CA0001.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::6) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DUZPR04MB10062:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e91332c-1d61-41ab-1dba-08db980608bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bceOBA6Ing5i0sk5qAQlMFcGZbHoIoTaWXcj8QPxXEEu9pXqHq6mKFE2PdXkSi3JaFCEwYQw3n8C6Wg5rUzpDWkjZ5BhC95T2k6OgOIghP6vGFd81l0bMcrHkHprBlrwDmqhMEN1Qsb92zBvT+K1SgS+IRzU+HZWomdkQexkwc0kg4kfA+kPnNIKHxYstFl2kEbOE7sDz8nYxkopd53wZpcZWyHbHJBJY2kgv6Dkb6Eu5gCDVBb72erTuS5NAB+sJCP2IwD1AvfNGvLZTqKh3bjoZL4btmm3n3Pbu3jYoFSbOwmE1OKrJCriIH/KiCH2U2Qm2Lv8LqbbSyu3GQiwMgLecdqS7QpVVFQluoZSzhKPb0zhiNnA7Cq0duGxXzPlDCLZyXEsWJYPp/KoJEsKEgDluHxUCfLSXP3xaE4OgWP4GNUczJGIjACof2xszL7ezW7mLOdWM5XqE9B4SO4AJjv3kPDPguxXvUj5g9QjfpogwkxBMcwmkIst5gf0/Cauj0LIpA1JA88+vMzAzzquZlcZJHd45Qo8g8vnuma+9sknGX0Wte3dPPJKcq0xRmwt8VpNDWmmklTTEK0AFGSQ7vkWp5TKaSuDDXVaGMi2e94TOXHns2jLO3u3AbH/oFp/ 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)(376002)(346002)(396003)(136003)(39860400002)(1800799003)(186006)(451199021)(83380400001)(2616005)(52116002)(6916009)(38100700002)(38350700002)(41300700001)(2906002)(4326008)(5660300002)(316002)(8676002)(8936002)(66476007)(66946007)(66556008)(6512007)(86362001)(478600001)(6666004)(6486002)(6506007)(36756003)(26005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TcIIuuM+b/KuhPNT+OsjmICwKz6CQkXxqVqb428GHK7WC4qRst5DOIaue1FpP9LGtz19cSQjkT8fTAKOZvde6Ll/sZpDKrWnPjGN/91dXaPqt7gvy6agbgLu5lcV1GPOZOYWnLxmIP6JdyN8+hLc7mKIgZtSHBwxRNhF4uLYe1U9crA4T9QS2g3POQfpdNE0xdStJJ2uxvYGIZqVBKf44Mtgcq5i7IKta/ubiOkKKmzw1AgsOxaFzzl3mpSshhIfNWiA3Ya3DdXXJrtzC/owJL5jhOX5zU9lzDOncDuKz8yvcBfJhW+T7hrvpVMywZPScOS6bacs4pBWm+iW2KKHG5buNK+pm+Hw+kNegE8G1Uk2/1yCdvaelfWlP2VCl3B7kQlgLrmjqkl2xm+zs2ALLwW86LOKsTNElq+7X8GcJwW0HqSKX0SjfcHi9p2ApfWOcYnU7d8bs85VqClq3rSV9lRZKj1nUYph6cDleebNOxDJZUH0BBhtqwlxcEghW0V3rmkGtCsnAVrH3L+qqoBIS9nRl6u1GQ87PSahpvI8dpUeRs2fDQfyCWO94ViaLdG46U6zFaJlKsjgOQOV4NTL+Op/anbtMkrLNi5Sycsi6ovucpFRJCBteMTIDNgZ1iUQp3WRgxqDpdUga/WVyMNWq6F88Xxtc7RZ2aQGgGHHbzASmcfijlyXmto1GOiR21wVqrfqo616PjOX0FLvngqZPMcTLGDpbvYzcqzO8ZyoxF2spQuhz6Pu+2M8ncAl3psq5D16FM4zBg/3aIpKGXXxpkVF/EVij8as5SPkVznJW4ixA1sOtzNI7UJaofJO+bmRlnWN8PHgnv1B/l/ybG1oniUBBymF5ZKc++VByrE1mmem1n8WpP9tNWfijIVlfvKTnKXvr2ou9ljE+5wEkLHoQ4WrrYg4FdGhqgCl5pRgv4yFOghGxKhbt3d3wAFjKqRq88/Mq50948BA+nAFh8JdoCajLNBFGijKUi3J0U2wQkMgb7nnhnt0huO5vfR0R0ojCEak4uRF2UPu+cNcFKmg8TMqKS2nEqzD2L2Ci4zj/L0VXETX0P1eKv54hrvfqxviFFGtndj+JxIacQ1n9A+12vkSm6Q+J4g2zSVTxTmJ57EX+lYHCMys0rN4+zMos+j0y8QextwADLCiTEOo2fEqQhN4cqiXYYjeqw0i/oDL5PUSD/jWAlImvvDlluglkLZRpgTrbF5jH4TYTMvYtRyRcwp9Afl1VgQ2LHzy4vy6zWe+Bq01rwgl6qqHDa8sk2qO+rQyqOBg5H58cKc5tUBWb0cBlxuZclf7SNRy/D/FnAaL6PNKVaZarzDWUR0OeTppQtL9C07m/Z6XHZFHAUmM/CRg1+DYkqJosYSFIYNGtQaBWb/sGj4sZqqA3XYY4UgKSQH6QC0Foc+le0806Wu+bdCJ6iKq/1FTpcvwf8HJHaN/QmSrG6ImwMDzOlEF9tw/A6cDFw2/GK+YvTGIMHqpjTSPN9gXFOyhEIf46njFzoDUy6pJMdnIeHlEFkNUWBSTx8d9DGkHXyMBAh4/56lWWFjh9UPOT5X6rNg9aPEuewRmpMxBgAnmw1c9vVCNke0T7N0T8Sl8ud2SHiFBs8+Xhg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e91332c-1d61-41ab-1dba-08db980608bb X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2023 11:53:08.8640 (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: 1uk66GtBjz/heDjGgQNU0lzA631lHBTwNj1HSljvxUKpvd7KTibolYqo7DlUtaJ2qdlC9GzS/cNB4l0O1beSAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR04MB10062 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds probe_on_discover flag which indicates if profile needs to be probed when the remote_uuid is discovered and changes device logic to attempt to probe driver when a new UUID is discovered and probe_on_discover is set. --- src/device.c | 22 +++++++++++++++++----- src/profile.h | 5 +++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/device.c b/src/device.c index b43ced8b5..19ae03f7d 100644 --- a/src/device.c +++ b/src/device.c @@ -2156,7 +2156,7 @@ done: void device_add_eir_uuids(struct btd_device *dev, GSList *uuids) { GSList *l; - bool added = false; + GSList *added = NULL; if (dev->bredr_state.svc_resolved || dev->le_state.svc_resolved) return; @@ -2165,13 +2165,11 @@ void device_add_eir_uuids(struct btd_device *dev, GSList *uuids) const char *str = l->data; if (g_slist_find_custom(dev->eir_uuids, str, bt_uuid_strcmp)) continue; - added = true; + added = g_slist_append(added, (void *)str); dev->eir_uuids = g_slist_append(dev->eir_uuids, g_strdup(str)); } - if (added) - g_dbus_emit_property_changed(dbus_conn, dev->path, - DEVICE_INTERFACE, "UUIDs"); + device_probe_profiles(dev, added); } static void add_manufacturer_data(void *data, void *user_data) @@ -2201,6 +2199,7 @@ static void add_service_data(void *data, void *user_data) struct eir_sd *sd = data; struct btd_device *dev = user_data; bt_uuid_t uuid; + GSList *l; if (bt_string_to_uuid(&uuid, sd->uuid) < 0) return; @@ -2208,6 +2207,10 @@ static void add_service_data(void *data, void *user_data) if (!bt_ad_add_service_data(dev->ad, &uuid, sd->data, sd->data_len)) return; + l = g_slist_append(NULL, sd->uuid); + device_add_eir_uuids(dev, l); + g_slist_free(l); + g_dbus_emit_property_changed(dbus_conn, dev->path, DEVICE_INTERFACE, "ServiceData"); } @@ -3930,6 +3933,12 @@ static bool device_match_profile(struct btd_device *device, if (profile->remote_uuid == NULL) return false; + /* Don't match if device was just discovered (not connected) and the + * profile don't have probe_on_discover flag set. + */ + if (!btd_device_is_connected(device) && !profile->probe_on_discover) + return false; + if (g_slist_find_custom(uuids, profile->remote_uuid, bt_uuid_strcmp) == NULL) return false; @@ -4884,6 +4893,9 @@ void device_probe_profiles(struct btd_device *device, GSList *uuids) struct probe_data d = { device, uuids }; char addr[18]; + if (!uuids) + return; + ba2str(&device->bdaddr, addr); if (device->blocked) { diff --git a/src/profile.h b/src/profile.h index 6871f2f0d..cfc500588 100644 --- a/src/profile.h +++ b/src/profile.h @@ -33,6 +33,11 @@ struct btd_profile { */ bool experimental; + /* Indicates the profile needs to be probed when the remote_uuid is + * discovered. + */ + bool probe_on_discover; + int (*device_probe) (struct btd_service *service); void (*device_remove) (struct btd_service *service); From patchwork Tue Aug 8 11:50:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13346396 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 12747C41513 for ; Tue, 8 Aug 2023 16:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233448AbjHHQqR (ORCPT ); Tue, 8 Aug 2023 12:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232586AbjHHQpW (ORCPT ); Tue, 8 Aug 2023 12:45:22 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on062a.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CB724444D for ; Tue, 8 Aug 2023 08:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bMtZQSaR0UQZKdRWLo+Eqm5qJRzxa7hqm+9YcCue+AUWyj7tvfW5pMufylvdmM4+K0BiymW2ioQIhVtZH78TSGvySYx7qtXRTq6cN0XqXtdBdEjeSAOfaf3j/2qFX3kjEYcdQcu6hBeg3eFMA/lxJKyWVXth43dMbTz0EgdvHLkSb7p2+qSNwdFMNpbt3lV2e5sI8VhyZ4i6uNsj/532Z8nfPcfZ58WSs18XyTJLREZcz36u/5udG5XSvmepNyHA2KGfiU4b4DnGt/wtasaWibBhVnCxmdtxVI/ifoK2+dBbPFBfJgDvFmHuSFjXFTP1D4JJmDTIz6BMDZrJU4xBRg== 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=2VRw6SfC8dBjk4f4k5FAMDWrIhNSRIRyky8IF1zy9r0=; b=eBdhVWsUi6xwOQl+tchrAgPsKsKs2vixle3h8fFhgps8A23Z2P0m1MZG1U0jAy06SaaPJJYhXYZr5RwY0TdbhpZ8iIce5dfX5mrFqqiS4JWWQ19WHEw+RTvSUMvdhARtZ5C7igo53h9+bN1lICev7V3DXKOEo1OZS6Ntq8DxCvKQzD6nx0ZhSJ6wOxFdTrWjRR5977PlvH50SZVBTeCVmXI9FlxlACLOXF/zh/rlc6JWTDFg0A149lhARjWxtWgaukjCPF/Mt9W7aNLBFFg9Yczyqp5qyfzJOd7694Zkbj8wTLqSfSOZZzq8/OnhZzK0wBJGNTaw8k956mCdPBd7DQ== 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=2VRw6SfC8dBjk4f4k5FAMDWrIhNSRIRyky8IF1zy9r0=; b=BwvvKtGWtDgsWfMVzeYIsRF0fBkSJ56ZnO+YYgRtNh/danr13UCSUJGFH9hptK8is9JCQHAJCMoGXU8E5tO+IlJ57E54bnE4k9oK2aJbFzAOfdUlWePbF3bXGzA8KvnK4xwvvaQuaUri4+ABpTNGJ3BSWczVT71THaNTf6XqOwI= 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 DUZPR04MB10062.eurprd04.prod.outlook.com (2603:10a6:10:4e2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Tue, 8 Aug 2023 11:53:11 +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.6652.021; Tue, 8 Aug 2023 11:53:11 +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 v5 5/7] bap: Add support for BAP broadcast sink Date: Tue, 8 Aug 2023 14:50:38 +0300 Message-Id: <20230808115040.4403-6-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808115040.4403-1-claudia.rosu@nxp.com> References: <20230808115040.4403-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM9P192CA0001.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::6) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DUZPR04MB10062:EE_ X-MS-Office365-Filtering-Correlation-Id: 7518b616-9eb0-4b60-3941-08db98060a0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MkRwgwmt6Cp+aRXD2VNTh6uwtxuhA3Njd4ZQ+9bd3tRp7mKepOe6yV80/C9/4cDf6KnIrAHYZfPiSk++TT6kG7IXYamr9LMAsQQDbH0Je1Ef8UCy8BzuMerAnctvNtpIhu2sVDQpgyZLh1LNOjn7rBfOZqnbziMAUxAvpyW1C3kv2c1KV/jFFSqIIhfnzegn2w2D1FtoZc9hy24A2rjyWz0CXyL6lnIOqTyGjXxdbW5xd1O7jPJaUzmj9EBz7pUt6MdvIx6Mh8N4O7yixlFzKhhqt/tIvDnBLrjq6y2bQhcoXGttDBCkiX3EUPaAPmfkpAWGgLm1g1yyRnbA5ZRcffk3BTUznym7QvYp4K5vWZwx6jHwikcM0usbbzKhYp1izptPtAEdAaL2YCNyk7jcLYPHWbL1LK/Nb3o/AVE1HFAmhByYHq8Lnf5r+fm/t/Cus6ZQLDC9RNagnoJG3bQ/9VU+tozlfBItC2WVphzwe+Qri0HvuUpozKyW541odv6ERfgimI1qY31mTwOeq0daEte3g8FZS+g/MtcpiZ5xHu2+6+EnJYTWjp95tOv0HF9wAjxGHdhjI/vXLWavvwhEvJJvKDPva4Zdq7zTBrmgCbtnHryUU4qdGwADPuH33vPP 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)(376002)(346002)(396003)(136003)(39860400002)(1800799003)(186006)(451199021)(83380400001)(2616005)(52116002)(6916009)(38100700002)(38350700002)(41300700001)(2906002)(4326008)(5660300002)(30864003)(316002)(8676002)(8936002)(66476007)(66946007)(66556008)(6512007)(86362001)(478600001)(6666004)(6486002)(6506007)(36756003)(26005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sWRq+6G25HyUuvBVIDOgYwl2sXDl2EUHVF0nWhg29gKDBje0/57M7X2PoipKoqewCJDiLeNZpmep9Jpd3iuf/dsRpMf6xXo8Cq7CXsFkAy1lhADouHcazvAIQZKkrxREHjVWpJyeJMCGfkfCxWNEYyOf00uLP5IaHptO8NTDyanIHpnByqKxLQacH7j6GMLSZFsgFSDFfbM1pnhaJ6IYCiYeg+xlbCKOO6is++7Icm9TxFql8YnhnbNJ2g2N1o4cyahLlNE4SfbwFmK4ioUauDWbG213H3+s7yK1VPrD48hPE7peUdH7YQkLHn0FJ7QBKuvzd+pcxjFidrgE72qAHD2MRhz1ipn0YugLOzXbs9kd/6ZpWmQk4/lZKHgAm0QK5nrwWZmJ7FOHVIqMBxF/PBatOBPq82gEKqzeP90gVEFKv6N8bGuRywK16zX0XnQj7nR4Axaveck22cSLklGMHTCtWBXeX/ffJK7M3C8sTB2sweOLrJREDgheq6jBVvUkuNpEZgbprQ0feLh5CRVoziN7EpLPb82TwRYTDQ8KgdqXuTXi11rfjxmPmL0pK9GfF/TJuAEFFNVey9yjBcQw+uvgylBw5zndmY8ZtCr/6oAG0B8CdbjT6m8LK4mAqKPleuNO3gApvNSNSWFtJGTXC5X3wwhg+jExXv7MDTBBw72TbBjm8rXlPo8ih8wDJ2j2vht/pNASRsKMoExYz2oQkyTX5RjjQTl5vWsyJxL+QKdgxH4la7XSITgQpg5NX453zZiotoQ+dUZ5wyzSf3VNnmu1SPWzM0baskLgeZUFTTlJIX9BZpRPaSwNd3Wu8MmBKS6lUCQUq8NvjRd2IQ1VrM+RNQLVpgPBWUa9CP/XcVzDtmDHuSis6o2SYZMunYU2wULhWpyJHUbU4hWath9oYe+H01LHAuEogin0oUNlQZUbjUelUzdKCY1LmbjFqN5gnK+zpdkAjYFeZNhQIQ1RcXHzgYfUGzS5EF7JOKID5XK4SR36hPLKH2LSS6ceD8cz4Lx/Aou3COFCZh6yFuOBhXWjbeT8Ivgpysdgpx20cKIDf2sFImq01c/tWT/sQoMZJThNy+H1QtUAQ5D3SzjUsn1TlKBgcSwnLuXfNQlaivsato5+57/hedfevaV6YIrGhuo0XMpgcEgn7frJG6dzBIT3G/EbCc3uXIGy1CQS1Uwjw95lEtknoBkXggGXmStAc0b/0kbrdIJ7uIY4Aa9S1lJQeojlVfqnjihXb51ZGcPqwqiXGBi+B5ZIm7zQbhb/CJriEUV4y93rm3rTCx7WdacxwqUaW8dgvwUSuF23k4Z26Dk9U726LBaPaN6AUxFDpmngLVIItjFg4OzoQlLvzg6p+sJ1pQMPZBxE4tKtS1Eml1yKl6n0NEqEIq+v4ZIClXf9t8zH9tn2CcK7UhLXID4YtL/bMifvmnPKNAbinWeDeCx3H1L7SQS128FbFUW5OAPCesd7sRqWW0TSzRxFiGPXQfexwF1FX7k8GaBDbSKTGv+jvw69sdZPqA4/WjHRnHj5PSiGIcoid9hpBOH3SQwbI31T1M4FtAxn3FbzOuqwtkCBNqL6L5EihXehSNF8 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7518b616-9eb0-4b60-3941-08db98060a0b X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2023 11:53:11.3260 (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: sMqN+D84gxynMDGD4K0VV1LRBQdXdWmF5OITRlXLLaH1Gxc+3HojlOembxtg5Eb0g0XODgeOdrQVWkuThFu/rQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR04MB10062 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 | 334 ++++++++++++++++++++++++++++++++++++++----- src/shared/bap.c | 139 +++++++++++++++--- src/shared/bap.h | 6 +- 3 files changed, 424 insertions(+), 55 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 8cbb238ef..a0ac642f3 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" @@ -57,7 +58,9 @@ #define ISO_SOCKET_UUID "6fbaf188-05e0-496a-9885-d6ddfdb4e03e" #define PACS_UUID_STR "00001850-0000-1000-8000-00805f9b34fb" +#define BCAAS_UUID_STR "00001852-0000-1000-8000-00805f9b34fb" #define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1" +#define MEDIA_INTERFACE "org.bluez.Media1" struct bap_ep { char *path; @@ -186,8 +189,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 +347,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 +565,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 +586,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 +610,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); + btd_service_connecting_complete(data->service, 0); + DBG("BCAST ISO: sync with %s (BIG 0x%02x BIS 0x%02x)", + address, qos.bcast.big, qos.bcast.bis); + + 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" }, @@ -649,15 +769,23 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, struct bt_bap_pac *lpac, struct bt_bap_pac *rpac) { - struct btd_adapter *adapter = data->user_data; + struct btd_adapter *adapter = data->adapter; + 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) + DBG("device is null"); + 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; @@ -1733,6 +1917,73 @@ static void bap_detached(struct bt_bap *bap, void *user_data) bap_data_remove(data); } +static int bap_bcast_probe(struct btd_service *service) +{ + struct btd_device *device = btd_service_get_device(service); + struct btd_adapter *adapter = device_get_adapter(device); + struct btd_gatt_database *database = btd_adapter_get_database(adapter); + struct bap_data *data = btd_service_get_user_data(service); + char addr[18]; + + ba2str(device_get_address(device), addr); + DBG("Device %s is a BAP broadcast source", addr); + + if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) { + error("BAP requires ISO Socket which is not enabled"); + return -ENOTSUP; + } + + /* Ignore, if we were probed for this device already */ + if (data) { + error("Profile probed twice for the same device!"); + return -EINVAL; + } + + data = bap_data_new(device); + data->service = service; + data->adapter = adapter; + data->device = device; + + data->bap = bt_bap_new(btd_gatt_database_get_db(database), + btd_gatt_database_get_db(database)); + if (!data->bap) { + error("Unable to create BAP instance"); + free(data); + return -EINVAL; + } + + bap_data_add(data); + + data->ready_id = bt_bap_ready_register(data->bap, bap_ready, service, + NULL); + data->state_id = bt_bap_state_register(data->bap, bap_state, + bap_connecting, data, NULL); + data->pac_id = bt_bap_pac_register(data->bap, pac_added_broadcast, + pac_removed_broadcast, data, NULL); + + bt_bap_set_user_data(data->bap, service); + bt_bap_new_bcast_source(data->bap, device_get_path(device)); + return 0; +} + +static void bap_bcast_remove(struct btd_service *service) +{ + struct btd_device *device = btd_service_get_device(service); + struct bap_data *data; + char addr[18]; + + ba2str(device_get_address(device), addr); + DBG("%s", addr); + + data = btd_service_get_user_data(service); + if (!data) { + error("BAP service not handled by profile"); + return; + } + + bap_data_remove(data); +} + static int bap_probe(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); @@ -1854,7 +2105,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,6 +2152,17 @@ static struct btd_profile bap_profile = { .experimental = true, }; +static struct btd_profile bap_bcast_profile = { + .name = "bapbcast", + .priority = BTD_PROFILE_PRIORITY_MEDIUM, + .remote_uuid = BCAAS_UUID_STR, + .device_probe = bap_bcast_probe, + .device_remove = bap_bcast_remove, + .auto_connect = false, + .experimental = true, + .probe_on_discover = true, +}; + static unsigned int bap_id = 0; static int bap_init(void) @@ -1911,6 +2173,10 @@ static int bap_init(void) if (err) return err; + err = btd_profile_register(&bap_bcast_profile); + if (err) + return err; + bap_id = bt_bap_register(bap_attached, bap_detached, NULL); return 0; diff --git a/src/shared/bap.c b/src/shared/bap.c index 72ce67c08..ebeb713d5 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); @@ -3996,7 +4022,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 +4034,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 +4247,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 +4418,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 +4487,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 +4960,13 @@ struct io *bt_bap_stream_get_io(struct bt_bap_stream *stream) return io->io; } +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 +4998,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 +5194,42 @@ 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) +{ + struct bt_bap_endpoint *ep; + struct bt_bap_pac *pac_broadcast_source, *local_sink; + struct bt_bap_codec bap_codec; + + bap_codec.id = 0x06; + 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..fcacfcbed 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -186,7 +186,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 +289,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 +305,5 @@ 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); From patchwork Tue Aug 8 11:50:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13346340 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 446E2C41513 for ; Tue, 8 Aug 2023 16:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232523AbjHHQ1O (ORCPT ); Tue, 8 Aug 2023 12:27:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232526AbjHHQZf (ORCPT ); Tue, 8 Aug 2023 12:25:35 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6C9F8913 for ; Tue, 8 Aug 2023 08:50:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ccKw1sN80LvCnqCaXQeMOOFo8QwqP6uKGtK/jXt/XmiYGXzbUd4nrDByUd9svizSIL+H+tOLF7F9P4j+9lyIZ8cao70lPvSdEyJGw31G+opgErWx00pmPJpMH/K2tkgBMbRqBCU8b8XS7liJOKssD1nhBxXNY8k/dSu2CUawYfXVINw0MyV8zpSoIBmp6lok493S/fOmT7qnsBv+xFVqWFNsSU3N4U3vyuKmHjAryKVLnAN6/zUgi0XJl+OLTlZuMC/kV1t3WKKXm47t4dGmGlpNK5/H8PPIGAjcACSASECs+GVVWV3B3DMaO37tD83dClrrMK0fY+IzeIAoUq0/sA== 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=R2SsJNzKeLyeWtZJcwJttj3Ap2P5iRVqwXMOgdA2cEM=; b=kaJiv0Wm4bA45fwiyJ/9YIxBz78iiXN5sHoUJGpdI0OrSG11aDzunAdziKhKhWCt+WxlsQJ6YVEJ59PBu4sOnlMjyRhL9Qw6/VZ7l84jvIbyk5aeBQdthxLnTwOezXKoLtPJJJMWy8k9Hz39xlc4RqJ1aEtgXMdYA8gDMB3mRCuoPLmx2SozfjTnpCx/9P22+oiySP1lwVyn729iiqk+znzcBWR22SAjIeXfnPifrTmo0im3UTtZcP6w8IJ6fzE9SM3k73jPvT9pKQeHZ9OBzG1815R8um/E2G40aGPACGqkCwfdIzP5ybRThGakPCglI6Z1JNRybolQYIYgQl1s5A== 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=R2SsJNzKeLyeWtZJcwJttj3Ap2P5iRVqwXMOgdA2cEM=; b=EEfbEU1VhJ+R07mW8ZXISZoXfqz6vBCuRrprCRcvD8bgVVwpa/i40C0eQvlHMBt25swRqsJetTI+k3roAPfAnL8Yxyzbl2SRcS4mr+GOFFj1CJasPkMXOKOaF1SUOOidI+uLSkwmZPIdw5aKhREosx2VWW9TC9g2ZjjWiknayYU= 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 DUZPR04MB10062.eurprd04.prod.outlook.com (2603:10a6:10:4e2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Tue, 8 Aug 2023 11:53:14 +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.6652.021; Tue, 8 Aug 2023 11:53:14 +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 v5 6/7] media: Add broadcast sink media endpoint Date: Tue, 8 Aug 2023 14:50:39 +0300 Message-Id: <20230808115040.4403-7-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808115040.4403-1-claudia.rosu@nxp.com> References: <20230808115040.4403-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM9P192CA0001.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::6) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DUZPR04MB10062:EE_ X-MS-Office365-Filtering-Correlation-Id: 16227c0f-c31d-46de-e6d5-08db98060bd4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q7A0hJ8SO3mFdXveT18P4G+wxYbmRz2rYa8SpfwIhDiDtvqsJETC/UNFnlvFmEh0w3LpUErEq+G3j0ZDQnFrupXcIxt9p/2Z0qzOXaZmvIQiooSCZ0QdE01ZHyXxdqqiTuGzugXzkfU0fiL4tTd/hMMrbBt2WtBoQ/2EfqpixkuzL9tZ4ze/GmMAeN6WW6c8x0ftmX/Tn7p1q5VoD2cvKyO4GfDJiWNdKI00qIWr+Nxd+4t6u3Wclz5smMsmEWhrsDOkf+OjmBZNLAckLpmN5qK6/2SDMwOJtdrpKMAby6vX964L2lgnRKjZI22IecPW5JkmXGc7RAyFQID0gVCXyEJtWa8X3ML7QaJMwRS30zA7uJ/p3aQPlAwzFIErgvdZlbuceF/tAw7vVbLRxD4GKSPz7XM2jm/doNmDBMJjwVajSVNRAAXkLg+nvOJBLc0LyR0sSXppZFoaDYBVnea6BVDVnUPRZBZVF5uxfZzUEMXpNACKRBwaklnoF8t6636ILyOFeobKHTi0P1l2A15eKH3Tnxdqe7EkNeYRGJM8QasUcPkhjhJeJkbtyBOsvKyoYC3Us4t5ZhIgLT3XoTlzof9raKjESRC1rkySjFbJo2J3XikIUx68fC/sJuNjpcPO 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)(376002)(346002)(396003)(136003)(39860400002)(1800799003)(186006)(451199021)(83380400001)(2616005)(52116002)(6916009)(38100700002)(38350700002)(41300700001)(2906002)(4326008)(5660300002)(316002)(8676002)(8936002)(66476007)(66946007)(66556008)(6512007)(86362001)(478600001)(6666004)(6486002)(6506007)(36756003)(26005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KhcJMOGZhDELWQQIf/8cWeogvPpXyx4rrjRqOBT46R8X/JC5y6g8+SDyAmCVbLXWTkJTxpd9ddsqlNCVSAzSC3qU0cYAd8yRhVn/zStlUgNJ5aCbPBcVab1w4dP73G33J/20OfgIUF0fp9a716bqE6ob+1blo9NUaCgCQZz/N4MlWf8ZHzS+v97lnQdIlAmooqmwXnnxmPBbETnJkHw1bWlvfNYxs1sp5z9s5RLCDDFPfW/za+QSj/RmHmwwhqTqPXPmPgSQzjXzQCiU/zLXMk4gI/qUYj/G03dheiDOrNAwE8UWCKTaheumOEg63fBRpjiER2diuKIf5/Ii00PNRTcQGLACbFaBrdtIOWnU3jW+e+JMXjtpPd9Atf2nEDHTxzFVRpSMb9ujaEbi4Ycvf9QRXV0PWE9nSDJd//KanV77He294qOeJp4FLDNh8JChRAm4O82o7vbcpOYZ8i3taVYS4CEV5rMNTS39Cmm4a7BFw/pKMKvLOin7cvCsmVtL9i12KxaNC/kKwHErRju/kF9ErnTrnwkzXNbEuzsdwLn6Y87noOXsADNhu7ppN6YXkEJ4oScPdAB9I8HMbLMbYQj0WAXDmfm1D1aqKSNXhAAJ2swiPRXaC2qiOfFbgNRbXC3aMRa7kg+3sNoAyRDoUziDNcH09rmSS8Qw1BHbdw1HvjgfnDwMJwEVkaPcBZLnMLTy7OfmkEqvOvUHyhbjf2VtfQcTTaKexChZNZf5Zp6nl9XZ24XxEtOcC9IfjBWz39o4fbWMsPMBpCj3BsG9jMz0r9xHiTyEz30/axGOWHnHF+v6FSZMPV19C7vss4jv+VO80AuDtYA2l6A+v0qoVgZD7K50SQ5MeL8fahCLaFEW093QpEIwQreFS07E6hrd0Ya/XDruwiY0mBVILwUHQvNoSegJTNkckXeOP0aDlITr69ZZp+JM1/tys0jZSZmNT6Ay8hS2enSJ8gShnWw7l+aBdEwrrjTg2j3UhDw0DhMfDgYhfyd4+cW3RsMrez1x0eZE0uhIVcKjGwdLioCTpX9yNgn//HbA71on9eysB0GYKyvBlu37UVe+AGMLjZkfH5LPL9QuF8EBrAHK21pf5POo0qqdCgT8Dt2blU+Yoa/eu56GZpndZJYpBgUNpXPQjmh0by2CNoIzGFkjmbiTm9Y6MW7AuYhz62nMi/Y4E8fMQ8susr8/cK+kGMmivZOaEjJknE7gCHcSypo3r3Ya6rmrUmRPGpVvvlLpIoJkYLZI69lmIXnqgObBDMDveWeN9mPlrpYlgS/QSR27/lGLAqYhQIlh11PRYhbYpbkzr3WKLXKtEw4dxdA6Rx0Anm+9RYsWZXeit30hWgCR3hm3uBMHn83POrE0wtumiKlGFVMpEcn6jRjepio8zZeLYsD7G9MG/dVmsVkC6qMmr32HGFgDbcvLFVvbBoHK/F0rs+8e/W/vQIpqDr6jCd2zk8Q1qNBtfXpvkoMc0qaSLAGaHnYkcEvtapYzQB64LoC3CvQ9pPdjI2ewCziHKaAEbeaONcOm9944+lWst7vOg0LoBlAidslJc0RbtufHEwiEAXJdFTRBbrbWGjdoD2n1LF/H X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16227c0f-c31d-46de-e6d5-08db98060bd4 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2023 11:53:14.0511 (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: /xWT6j3nUV+tmbaLJVkbwSZGIh9mlJUf7pP/IdA64wc6Lr7JaOhKE2ffCvAEIuFAvhdAw6/UmiSh0DA1QWMwlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR04MB10062 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 | 82 +++++++++++++++++++++++++++++++++--------- profiles/audio/media.h | 3 +- 2 files changed, 68 insertions(+), 17 deletions(-) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 15c64c8d6..59143060b 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 { @@ -1058,7 +1059,9 @@ static struct media_transport *pac_bcast_config(struct bt_bap_stream *stream, struct media_endpoint *endpoint) { struct bt_bap *bap = bt_bap_stream_get_session(stream); - struct btd_adapter *adapter = bt_bap_get_user_data(bap); + struct btd_adapter *adapter = endpoint->adapter->btd_adapter; + struct btd_device *device = + btd_service_get_device(bt_bap_get_user_data(bap)); const char *path; if (!adapter) { @@ -1066,9 +1069,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 +1249,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 +1368,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 +1394,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 +1412,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 +1428,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 +1490,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 +1578,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 +1605,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 +1624,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 +2664,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 +2774,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 +3289,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 Tue Aug 8 11:50:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13346358 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 C0BB0C07E8A for ; Tue, 8 Aug 2023 16:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232691AbjHHQ3d (ORCPT ); Tue, 8 Aug 2023 12:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232696AbjHHQ2S (ORCPT ); Tue, 8 Aug 2023 12:28:18 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E01A711F4E for ; Tue, 8 Aug 2023 08:50:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OiT6MRUdaRbO9Q4sZMoXsRnVnPDQTGso+JyLOpgeJj9D2mFtlWpnqSdIFZzDKq4t7NwLtfWAg/nflogDQTYkkqn3ncsphF09yYEbbwezJvksqw9s3QHf7N0Nb6i31tfetvzl8lYEbMUTu9Rh8aOHodecSglhe7K0Kw4W2wDrAuimomKZKSuja2rcwVWcBpJuEg89teLOna6XJE453JU6zx1OQ7mOXNQ0xgNV+1o5Uk+/XsKVuRR8ffI1xFOgnv8t319Pos+We49/mTFEGD724EGecICB4QSQ5Wwipr382aqGsbx4zplsLQnV60deQstNbfFeAJ8w309QrcIIQB4vOw== 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=aMZibo8oTTBfrrSl5yHrHjSbPOBpGDQwYeaiIVD8alk=; b=nscZVy5hZ165DAcQdiSVXyBW43JRamC3z35nz+VoluIPQz2IZmgmst0x9VPilJ2J8jci+Qy0lUqe9YfQIK0OflxBgqeWT2LszkZ6UHEPREzLBjVLdr21TAdOS4rTJRv4sokilqRb1F+ctjmM/MOCxN0MTWubaidSfQy/T0HCBzCLmEuAsAW7L1WC5vgMtOdwIXGcex+DRsQSDH/7GV9iQuKy+v7sWWf6/TYgwU0VVLllvtzs+w8poEit3cS+UpJLa3HAnhLeJ5zFf85iJ3wRvUi0vcGrefxBM2HDh1kys9kMzNBaw+cSi8JmaOfHasbIqr8+TdYq5DzgvKuYLBi1fQ== 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=aMZibo8oTTBfrrSl5yHrHjSbPOBpGDQwYeaiIVD8alk=; b=FhT28QKKwQXAIIOKj3HirWM18JIcbt8y+vDrotpS3x3DHQNqNQ8Xy/kmhudkqPUQmUERN1J2tHqkB1jhZL74TDUbaA1ooy+xVc0BOYOfPjS/D6PRqHi28vObulICTJ42d3ls3UFOqwc/mMLvbmYX/Ic5N9495MxwZCKiBFJF1Sk= 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 DUZPR04MB10062.eurprd04.prod.outlook.com (2603:10a6:10:4e2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Tue, 8 Aug 2023 11:53:18 +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.6652.021; Tue, 8 Aug 2023 11:53:18 +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 v5 7/7] transport: Update transport properties for a broadcast stream Date: Tue, 8 Aug 2023 14:50:40 +0300 Message-Id: <20230808115040.4403-8-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808115040.4403-1-claudia.rosu@nxp.com> References: <20230808115040.4403-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM9P192CA0001.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::6) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DUZPR04MB10062:EE_ X-MS-Office365-Filtering-Correlation-Id: 7107bb93-6e8b-4fb0-6b38-08db98060e83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B63/7g6GOXiYycd9nr4gzHfHvba3xS45oOpImJXow0hsdtbjh8Oz2TDlPVd6zo6wSOVy4Jz70Tj/nIot1ZwsMb1H0sqdf4liLvf60xQmGtK21cQSZYoOUZLAFlRIkezHyR56NMkgHZ42R+cNQLbiABEMkogfcBPKm4QpNGRrsY0ej3n57kNMrISrQJNwerXdwjbAyT3yHEnLDy90jEvKMv6RMcmAxI372Pp+w5r6XkZSFTsUexF7b2lrjhXchnCS9TrvRMP5GgQc+jR1Bqc0wrsJkgOikGP3YMSxsAE6iYsyBD7iCicRLU6bVPq3LrS3wx6RE3mu3/Lhl89EEP31iunHnTGtyneVZAI5Gm2RbwchmtAAobdbFYGu1r7W3q1xEF8YEKGJUb4hdgn0u1gr9wrZAUGYF9DNleYwQOsN2Y7awuN6b8GlfjXDfO1SPRyRxABiCRyajBKtjrUncxOZFFw2FjBDkZZdMDYvCgZAEjcneg90hAMYdiBnQtepv+F2PUIRoq6WLY4kxwrhz4RMqT1RUh1vqVp8dAuGBPlelfVEatwRRLtspdNVGmN4fqcM/XfVeccmnpc2EGmj433J1EbHzY+mzCm3Fp7BvKvKZ/76Gvntz8dcN2dCaCAUrS74 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)(376002)(346002)(396003)(136003)(39860400002)(1800799003)(186006)(451199021)(83380400001)(2616005)(52116002)(6916009)(38100700002)(38350700002)(41300700001)(2906002)(4326008)(5660300002)(30864003)(316002)(8676002)(8936002)(66476007)(66946007)(66556008)(6512007)(86362001)(478600001)(6666004)(6486002)(6506007)(36756003)(26005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I+G1kekKvjljIB2Ufh/lFZF0p+Vvm7CrIsJ0L6no3nFVpeerUhyb1j5HOEhBt8T8oc6fgFnAH8xtviQdq3YedAEXuwEUwTyIfzdUnXg9LCvP4Zf8cNNEU47eG6Uk7fdbTMPy1VIIpqBe0Xc1jPqEbaEIkxd3xe3pKUwLveF2eFxs7EYvkPRhOsnEKjigmGl7LAGJZy9V4h1XPifk2T2UhO0n8KCwkChAAq9RHJMWNUdhyMq292lq727zdsVqC6/gIN3yFQ9/DJMr1x/pehf1W45mLCMtkM232SbysABomW4JLjLDEEgNxYdSwmCB432dBZhYdo8Dx0y6C9sXqC299jtd8yxlhQS2103/1UiY3KjaXTVlSTSgnI38KC6DJ/bp0bi6paA0S28mooFrm5PYrkeQD7ML5uF4BDttESKlLB5gnxIiBA9u79SBV3hds63YgXkyBzlgtol5lXGx2N6rv3v/CccSQUrCj3XETOg8KLZFlHA2Chv+58Y8jDVsspTbKcNYkIlVtiHogKh7Ap62sHeepxLDmisgLUPi/QXAlCWE6l8gu5xD6AO4xn3wKXrVQxkzwrVhfNj7t+/ivVcRbIb+vHMgYRuGDLDbrWajzxy60rWUW5kXG2acXcc1Vgg2F9SEA1AWASEiR2Bx0uLw56GvvWAXOaRyhtN92bY0zd+0PqsUAutE/DO0wybDPRdOFR3qHO0Q09LuR60l+z024k+DX8wMnETM3w6pAQHAF83lTrrfgdWP8HJAPcLjzlGBBnW7xbW+YLMvmye3pu8FjEbnWHsKA2dRVZI3dmN2xUBWztWLwfTM+RsJy9+Iyxml9PQh4n8YfFWJoTIGXSyxtF6ICtTjToC6BQMjK9/7+GYWOOcXLhHyl6MAqr78NcJIDhENjLwqN+nWadJpLRKuQHI7bd3BymoSJrBmEmifk5B1MHlJgSQnvSrI96z9C56lN3XXZVNP6uOUb1dS4QhrS6vb0J56zloTokIp+RtTgkb++sUbnYGPBZbqjkc2GSeYI0wz8mtTkP465OXv/2Oz2GZSMLMjTr3B4E7XqaxOuQW1S4+l1PXXqHJDC/42klsP6/Iz6PUBBCZeITpBVPomENrYw4s3mfehmfrA+xFIzrQrQJI5a2tn11i2WEv0+z4U393VM41oOXe+jiyaDR9KUVmKZXZ6xN8JzQe3G6cRvXvUPYpVaYqpszpTPSwMZKS8LkWhBsBl+ha+8hkuWdZCF9VZSG88Bf9L7PaErAQWODdUosm0W3PtkHoDJBXhFLpGpj/UaMVQxX688HsEINzKwrt+h7if73g/YNmzdJ25qgZjUmGTKs9eQIxvaJunXaA2uy0SboZkGfbRa1E4y9me6ywpevIas9jcX4rN0X2ibRBnfWTDnui5YxPVUkEnebFCFtBL70zR8plwPZiTEyazLrUnpaRILSDuORjao7fLgw4XHAK1bhbI6Ize25l+kl7ofKNKnuZQZwf8ggrXm6JDg+NUZVR4fIkgsawBcQLE6cLojuOJv0re7c1w471K08gBMxqYGZSqRDqc56CPWq6kYWn1mPS0c6k8wksO/RvcZKzW7/LQg+X9x6dbP1hsoPSA X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7107bb93-6e8b-4fb0-6b38-08db98060e83 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2023 11:53:18.5746 (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: XmavRUxkl5dRvswkU8cGAMuJgE8datcvJZdGSAojWmu52lvmb2tvFq8aFCntWvHLmt8e0WV/iByEm0i9r/SDfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR04MB10062 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..107339520 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;