From patchwork Wed Aug 2 08:41: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: 13337848 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 6FC9EC001DE for ; Wed, 2 Aug 2023 08:42:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233798AbjHBImF (ORCPT ); Wed, 2 Aug 2023 04:42:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbjHBImD (ORCPT ); Wed, 2 Aug 2023 04:42:03 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2057.outbound.protection.outlook.com [40.107.20.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9242B2 for ; Wed, 2 Aug 2023 01:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UBZSI02o75BQPS6RAjVS/ZETXm9iVNqW688MkIEUyewaLavgClbv41aNb4gqZ5ufZwBDv8tmy5VqVMsBCnF+ZRbmJ7gjr5ZZ1Js1+ScPvbUFZAfX0ZsazV1RJXrRYZZ+4FEqRSVAtPo98D8x0T0jlz0pt6UYJdXGAhyXF2XDA/l52jGYC/Q0oRzT0SSCXiTnTQx2q7IFKh2LwUqe3F2Vn08LBerqfJPfl1oh0R9XaVKYux4FkguAOm2xX3zJWT228lKcmBAbx0DTTWv9p7x+y8GwuR7phsizoH9mzSLTEjxRLPNcv0BRUXiUIiahJm4f/XftH0OM1twZ0m6UHQX9lA== 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=gVBYSeKEBlbJxkpJizQ7QkJSwbhs73CmvHd6qrlktmq0y7qByz69iCbr8zEJcuy5oFW5u46ZThg/cHAaS+7RiWDA99aQe/zLQNrFzH03B0YnOcljiNOeE+6rfwXmyIFc4g/1r+1azxi+Xdx7+LE5yfG37RdEM1Vw//hzjxbC7KkkTNlzR3+l+Ch26LsiUQPJq/W8FCmAiEmvEKd5SZS2rpvFAiYhsxN4UlSSp+0zVsAbfTsAdkTS6Nun2c31FB/Sezsz5nSBo0I8JpocqPoeLPDXCyFcJoD8XXr1fUOGEsVUz+rf9zHKiWbqBT2uc4ZkhZu/cPGruH0QBITMXEp5Fg== 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=ms4lMWEeKDtRUx9SqKtjFY+a8tSr3pBwTtgKi3LcO9q1HFBe3vca5O89LQKbeXasxSrKru9BA/KduyMiMxyABSKT7oiLQwA/SQBdQ+4U4wffulxuTrCpXh5EXco21AfUEKZ39CyZ2J0wZafRypTEJwg+i/EP5IJM2+7EKkdVABU= 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 DU2PR04MB8503.eurprd04.prod.outlook.com (2603:10a6:10:2d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 08:41:59 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9%7]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 08:41:59 +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 v3 1/6] client/player: Add broadcast sink endpoint Date: Wed, 2 Aug 2023 11:41:35 +0300 Message-Id: <20230802084140.51105-2-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802084140.51105-1-claudia.rosu@nxp.com> References: <20230802084140.51105-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR07CA0003.eurprd07.prod.outlook.com (2603:10a6:208:ac::16) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DU2PR04MB8503:EE_ X-MS-Office365-Filtering-Correlation-Id: b5418301-863a-4868-43e3-08db933455f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WFDq/p0kNto0kFtGn9LkVNwcuwq9yEVavbfErpugSqMkJQpOYjodNugr/IinWKgvTb2rIIkhLM8JulXoB0+fqyXVfpymivh9ENlxfQQIx/rBzvYCWNz0BnGb6OReKgLDF4S+p+5GOyIQxBovOp7HY05F8odVd/k9ghlK+1MZtpe/TGOfLu5vKgbnV7j3EwbpqYj9hpUWoJ1gN4El+WhvecRfymnPMjFJp5SEOMKc4GwI6W3PW/sbIf/m4QLVOCiatSsNedVIt6duK4ko38YSa3Bm0yaQVM1bnyu7isNYgqMBqtPsXw3Q9inXxVYuIoaUTGysx+k0E6zWm3BLh5oBHoxdCk4d7jGE7d+sYn5H+q4PQ4EPm//qZpUuovtdtwdLpKAeYpDjdhBJL6tZ2mvbAJ3IslwQfmdmO+V8DiprhnhyfOKgLdjECXEtz/yKZANHgSo0fk4urbWp+YTY8ICBzjZm1Pui8iJse7KCJY3eA0Ygoi7qZaAexivlshOi2ZMFoYFfvr2vQ3RAR036F3zHuhV3jHwuDg3HfPbcsxLxCeXfjerKT6ZzZ/zd17U2e4TTPJkkx8GuBgsOsqf2Ne52b8/hcbsGDLH2P/DHQSDGLFYHaU2OzTmT+EMMYkvIsY+x X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(376002)(136003)(396003)(39860400002)(451199021)(66476007)(66946007)(4326008)(6916009)(66556008)(316002)(6512007)(83380400001)(2906002)(86362001)(186003)(26005)(1076003)(5660300002)(6506007)(36756003)(2616005)(38100700002)(38350700002)(41300700001)(8936002)(8676002)(6486002)(52116002)(6666004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QakX3LsPRCGe8/lmnzpfeOVuIqx4KJs7sZ6eEc3DKikDI3fAr1rUcCNFNEW2v1RNMmmLiTFXW21Qic/MuA+Yl4IPSI2PWjti5UrEcDX+5wP7DGnh6n55g9MahDhWi8ZSz+eHD0YerQfmeOAa8m2zi6i+xiGiqywN3Ew4qvKT4jlLj8HO5OexfQKiVQyhFgLaQaSi8MrPtWH8vo0BPCH1sFEKJjWyGdpkc9ofLM7GLdwlsi2LUZpd6lDGOFz29Qe0t1PKUaf54gDHpR034Z8ZxpUvRw0ezcGmgY5tdWSfeJGipNVEpwcX4tulVyoxxL8pF4eyaju38yVS+gzg4rf9WldnxHLjg+4yBjgUaoHIFsWYUSIyFpX//Gg61PZp5H57OFGre92r7ZMT0y9aRANnXCeGVouy1kJq7anul3PHqI3l0C6l9U2TYupBG9wgeFRVI3BcJJOW54ic+eOSdSS7X37SlYk9cPjw6N4PEdWKUH3mOmfysoZkdTH14cmpic4CIiAg3K8pEeLFl+35zOaC3iUCQASq1YQS0cI5aDLXbjIpygVaSxnjYGJrnpARHJhEobCDUCNXWBQvtf79DyLBze5xgVMX0VrFwM5IM6XINgVJBMba8dZvte3xN5ln6RufkIBDuyGq1D+Hrf/hFJSI+3fIjSMrLIjzH4KtekcXkCJECGJEWYpcTt8clRSO7mS1DQKoC0CM/quLg9XINzl9BL1uMkh9u+QhTHeOs0fKqqqz/yY+OicdWtpJ6H3T0yiyq/Qx4lSp/UlI4Jfv3mWhW/WjluxaIxDIjh9EMIcN571dh4S/KzadOagsuf0gVpozv59bbsIMqHI8Pai98YoFhy62Gd03XgK6IU9Yrn8aOVMymi2QbpJ3OyYYDeEaAfNKIG5wpzkTCjVLIyYXl1ql/dPKVyxRqUoWnXDw6tm/rvaqIYtuooJ5HE5vctsRiS6vyCNtwmi2T/oRgh+aLNPijoiRyBojuGI3Xnd+OWRwjTYqdp5nAnUVsUXB+/kkktD4q1/IfIm82rvb8yb498pn8N2Jb1s2wL3o+TZ3fEh5qhWqg8XNJPjFzS2NFoCGIv7zyd7W1nBM6c9UGIvT+/4pRXMq29qp1i+YOJmBsppMQ8LTGofp1PSIWblvMcu1728VMSr2RqCiSEiPaatjJ7pb3B2ri64HqP9EZRuHQeCOc8DqKy0hH9hd66h6Bu2td0G3dgTSGQGfkCEk8T6lBHB2L0P7+inRd2Tma2C+vrh3cvakN54flHPQMlmuFU56RbF76WJ0kTChshkcalhOYY/qeFj7SUPcFBWYB/XhmJGZugUc7Dhvb6BVV0GpM/yAEWnwtbed1YKpacj9jRUfLwVcqysE8B5brdYXVqVWG05brtzlUj2WikUyPA7WLU+5SWh5P6iGyLb4Zc0ZdB7ErM5e8b4mC/QCgnmhZL8e2wvvZMpBH+ttkN/YenTeaudLScoA3QEqg8XlLkgd66is4WF4vfcg4UPAF09S3IL6K0eswyIyrWWUcUTfzVk6QXbXTpO5eepM8b6XFId8Lv4zT2XZOtsWswVq5EJgOA5SZeW+R/sAO+k+WXvGLjfXcMGcsl4b X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5418301-863a-4868-43e3-08db933455f0 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 08:41:59.3931 (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: c8ZfM+0X3QujGZT8BRzrwOD6Wu0LHLCh9eIexc0KxML4tb0CWq5S7neWTKxLrqzPhr4ZloTETBdHnWQkOjIINA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8503 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Added support for broadcast sink registration using the 0x1851 UUID. Added support for remote endpoint creation when a broadcast source is discovered. Added support for creating a local endpoint when the broadcast sink endpoint was registered from an external application (Pipewire). To test this feature use the following commands: [bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06 [bluetooth]# scan on [NEW] Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0 [bluetooth]# endpoint.config /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0 /local/endpoint/ep0 16_2_1 --- client/player.c | 61 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/client/player.c b/client/player.c index 9bc5f2a36..3611a8dfe 100644 --- a/client/player.c +++ b/client/player.c @@ -1183,6 +1183,17 @@ static const struct capabilities { CODEC_CAPABILITIES(BCAA_SERVICE_UUID, LC3_ID, LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, 3u, 30, 240)), + + /* Broadcast LC3 Sink: + * + * Frequencies: 8Khz 11Khz 16Khz 22Khz 24Khz 32Khz 44.1Khz 48Khz + * Duration: 7.5 ms 10 ms + * Channel count: 3 + * Frame length: 30-240 + */ + CODEC_CAPABILITIES(BAA_SERVICE_UUID, LC3_ID, + LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, + 3u, 30, 240)), }; struct codec_qos { @@ -1465,6 +1476,7 @@ static struct preset { PRESET(PAC_SINK_UUID, LC3_ID, lc3_presets, 3), PRESET(PAC_SOURCE_UUID, LC3_ID, lc3_presets, 3), PRESET(BCAA_SERVICE_UUID, LC3_ID, lc3_presets, 3), + PRESET(BAA_SERVICE_UUID, LC3_ID, lc3_presets, 3), }; static void parse_vendor_codec(const char *codec, uint16_t *vid, uint16_t *cid) @@ -2285,6 +2297,9 @@ static void register_endpoint_setup(DBusMessageIter *iter, void *user_data) bt_shell_hexdump(ep->meta->iov_base, ep->meta->iov_len); } + g_dbus_dict_append_entry(&dict, "Broadcast", DBUS_TYPE_BOOLEAN, + &ep->broadcast); + dbus_message_iter_close_container(iter, &dict); } @@ -2455,7 +2470,8 @@ static void endpoint_auto_accept(const char *input, void *user_data) { struct endpoint *ep = user_data; - if (!strcmp(ep->uuid, BCAA_SERVICE_UUID)) { + if (!strcmp(ep->uuid, BCAA_SERVICE_UUID) || + !strcmp(ep->uuid, BAA_SERVICE_UUID)) { ep->broadcast = true; } else { ep->broadcast = false; @@ -2728,13 +2744,20 @@ static void endpoint_config(const char *input, void *user_data) endpoint_set_config(cfg); } +static struct endpoint *endpoint_new(const struct capabilities *cap); + static void cmd_config_endpoint(int argc, char *argv[]) { struct endpoint_config *cfg; const struct codec_preset *preset; + const struct capabilities *cap; + char *uuid; + uint8_t codec_id; + bool broadcast = false; cfg = new0(struct endpoint_config, 1); + /* Search for the remote endpoint name on DBUS */ cfg->proxy = g_dbus_proxy_lookup(endpoints, NULL, argv[1], BLUEZ_MEDIA_ENDPOINT_INTERFACE); if (!cfg->proxy) { @@ -2742,16 +2765,36 @@ static void cmd_config_endpoint(int argc, char *argv[]) goto fail; } + /* Search for the local endpoint */ cfg->ep = endpoint_find(argv[2]); if (!cfg->ep) { - bt_shell_printf("Local Endpoint %s not found\n", argv[2]); - goto fail; + + /* When the local endpoint was not found either we received + * UUID, or the provided local endpoint is not available + */ + uuid = argv[2]; + codec_id = strtol(argv[3], NULL, 0); + cap = find_capabilities(uuid, codec_id); + if (cap) { + broadcast = true; + cfg->ep = endpoint_new(cap); + cfg->ep->preset = find_presets_name(uuid, argv[3]); + if (!cfg->ep->preset) + bt_shell_printf("Preset not found\n"); + } else { + bt_shell_printf("Local Endpoint %s," + "or capabilities not found\n", uuid); + goto fail; + } } - if (argc > 3) { - preset = preset_find_name(cfg->ep->preset, argv[3]); + if (((broadcast == false) && (argc > 3)) || + ((broadcast == true) && (argc > 4))) { + char *preset_name = (broadcast == false)?argv[3]:argv[4]; + + preset = preset_find_name(cfg->ep->preset, preset_name); if (!preset) { - bt_shell_printf("Preset %s not found\n", argv[3]); + bt_shell_printf("Preset %s not found\n", preset_name); goto fail; } @@ -3172,7 +3215,8 @@ static const struct bt_shell_menu endpoint_menu = { { "unregister", "", cmd_unregister_endpoint, "Register Endpoint", local_endpoint_generator }, - { "config", " [preset]", + { "config", + " [local endpoint/UUID] [preset/codec id] [preset]", cmd_config_endpoint, "Configure Endpoint", endpoint_generator }, @@ -3189,7 +3233,8 @@ static struct endpoint *endpoint_new(const struct capabilities *cap) ep = new0(struct endpoint, 1); ep->uuid = g_strdup(cap->uuid); - ep->broadcast = strcmp(cap->uuid, BCAA_SERVICE_UUID) ? false : true; + ep->broadcast = (strcmp(cap->uuid, BCAA_SERVICE_UUID) && + strcmp(cap->uuid, BAA_SERVICE_UUID)) ? false : true; ep->codec = cap->codec_id; ep->path = g_strdup_printf("%s/ep%u", BLUEZ_MEDIA_ENDPOINT_PATH, g_list_length(local_endpoints)); From patchwork Wed Aug 2 08:41: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: 13337849 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 A4999C04A94 for ; Wed, 2 Aug 2023 08:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233829AbjHBImG (ORCPT ); Wed, 2 Aug 2023 04:42:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232701AbjHBImE (ORCPT ); Wed, 2 Aug 2023 04:42:04 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2057.outbound.protection.outlook.com [40.107.20.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45A21194 for ; Wed, 2 Aug 2023 01:42:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VztLM2f4XI50u8RubpAnUInF2gokYNR/8023zkoT04HGM7xJk1fpOWRVgCgieIDTcTN2vS2tC5McnRVd5rVuXjRtd0HhhGCsSkc6qB1fKgP/i1uNECCOPb6TOcHS4BBakvANcIihDSw5CUgoY0xCh14zJHBsk1kfrv9odLlPUGuxTkUhPNPm47IvEaG6QLLmiQiYj+YVkyhpdLiSUrGKSxM+O0Nj/+u0fL692HVdHP25cXW6zYXRMJh8VTxH89Jt1nPPM0lPLDd6+3RzQb0VID2Yg8QI2SOoJ7dvpWAeQIkPHhN+isN7b7LVnG2ITegdPYvsQvitlTAdrR9/msKFQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SUb/B7vqA04fju93O5LRm4gQoV704vH6jrWak2+g+ns=; b=aragRxi/Ncd7QsoMhXT4IwFD+zZxUfO3Aa6WwimhVlnEwKXvSsSnU+szOXTE45SNu0BQfUHuQefBLmnSt6LqdNIBt2UJ/eZVsrd8xm+cDnPdhORqhDlOlvbKoj9QCkP1byaPcIlioD8zL8ElQq2XkfXegpPVe290dQVGxsgqia8NgxQiXgb1f+7wTHff6aQOMB7dGv0gefWpHRUMfrQ+RJF/FiFs/FifimHEvjPuHcVSLKEx4NXG7xT109XdFriC4VJ65rLQ9mGmwYoreUiJvOe42NBjaHV7VF75MjTuR193CNzvN6S+76+b360EzWffFPqYQhZ/Xcjmj1O6e0RLFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SUb/B7vqA04fju93O5LRm4gQoV704vH6jrWak2+g+ns=; b=nKHd3xPmfaefIXj1gs8zaHStmhysEK7GdaXUfD1Rpznu37HJKEk7yY2alOqEHNw6F/HeMfEY7vKDMgHMUJgyxPNEFRiNec6Dc1zysrt8DsLt3szXDqsS6GzR3lHDrAxXSLnbf/isJmon2lQmM96nk/SnqhaQt+NL0X3bJgcxCjw= 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 DU2PR04MB8503.eurprd04.prod.outlook.com (2603:10a6:10:2d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 08:42: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.6631.045; Wed, 2 Aug 2023 08:42: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 v3 2/6] media: Add broadcast sink media endpoint Date: Wed, 2 Aug 2023 11:41:36 +0300 Message-Id: <20230802084140.51105-3-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802084140.51105-1-claudia.rosu@nxp.com> References: <20230802084140.51105-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR07CA0003.eurprd07.prod.outlook.com (2603:10a6:208:ac::16) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DU2PR04MB8503:EE_ X-MS-Office365-Filtering-Correlation-Id: bd585023-661c-458e-d659-08db93345736 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FHmJD/EvzZK/7byYfmWyB5Np/4Im0uUAv83n4kra76tiMrcTbUa4G2cnFNpB0QePtyNJqwbiw0YMGwX7cZ8834XnYBWcXZTf4mS6fdjmBsGodQWpvKIsPX4OeltxkP3ZsC9Mc8uKmqxfB+l1SfZOnzXXx5k00L+dXvaRzBL0f5Wvb/RKr/tXIAiXb3E1IKplosZrsCVrzLDCQolaQ0Y4KBJGKO6kM+qU5INvZG0gqcFcEofO+kLy2Z1eoDKyy320hasni3ayG24v0/1c3Aqy0FzGioy28dQXDMJLzrxWRIyN2JSl+2wu21DyPn75Ui2MswnPwsfGWUVvGsYNWjcJfHbcCfU8SijSItXGD+xsNjwzvJ+UzyHQChmwjDplsHnQ0VUIBwLRu3PMOmihc7nrpyCRxGq3YN2L4CGfClq/HJsFLcPmIG+ilmDxl3D14JkfYMACnpF6a3jcgYSFQwduGfHEukKa5ey7FhA6jh+KkE80cY6StbF2J+mrhbcRvp/7WDzruiaTxy+8n1+KK9F8h0gzUIoSkIfLnpzBYCBalOrBBCstM/JOnHsr5HGxXNCm3e0+p//0P+PuscYabxKb0GVhjOadyP2IYUMKI7CvIM0KuqCrMjfdS+T6XFtOlC2U X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(376002)(136003)(396003)(39860400002)(451199021)(66476007)(66946007)(4326008)(6916009)(66556008)(316002)(6512007)(83380400001)(2906002)(86362001)(186003)(26005)(1076003)(5660300002)(6506007)(36756003)(2616005)(38100700002)(38350700002)(41300700001)(8936002)(8676002)(6486002)(52116002)(6666004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SO13S1nLve3XgT3+KYt/cALzoetB3sxMqo4qZTUCqrHaDXDNoAb0KK2Ryx64Fop7SwEYtu3MpXsXoIyKkVNR+PtJ/L/e3q/82hAU5Jnuz2Fj7eGaBy7ZNeyIgibcv6kO/kZZn8B5XZQRextj2LVrww70CXLnsPdrCFGFvSJvG6nB8SM9vg6r0zi+TuICZFUuCcm6z2Bn2vTig7P+YrfhQAceIqijGmlTKnZpXQp0HN+4yGNW9dsOmrIHC3HNcG0L5D6h9hlrOvDGNxC54azuDDFZqa5JM7tHmrrhRIZEedZpG0wM/gB7b/ZuZ/PaFsYlSUMUhy3/wPva1zcaCTZS05LTDa7PCxoh/mA0DtdBW8eSbxIl6rp+2dw4KARP6iPXvuBwI+zotBDZ8mLOQzyZIdYrRrAJygmTUV7Q+D0MDz+DkKf/8nW09+27oFJYz5yqMsEzwysyrJf+dQs9LaV5BwWNB3r0LucUuJHiU5b9mTQW08fhQsrQt3VTSdyrPCWVyksWLVP59Rktq5wsGAanD8LdzkXwkuknrMA4G4K/eBuuQ8EbQ7gcgfNXwUq59ZluIAA6r6pkvo3wbpwFYILkabAkRsXe2o85yzHve0aVVqHv28WoGAYIBFRjEp86lcDfOu/qaGydnH92+Ojx0OE40kNLIug9ktuOmJ4ILj1XQXgQNoocFXNEDEJSmAZ7iJ6wxmgQ9db7JPbAfnyEyV+5kvN+uBLJ9NORIypEqw4e/hYKS4jhPqSs+cXsdZhiFpS70Cv4DyYNKmWezZoHzu1Nf281/JE/XEJyZ9NBFajXX41hLnEXl9k6dLOM2tuGPaRHN/qAjJmm5KME/hI8kaScomnSq3j5aibCAK3M61YIvsoEasTddQ+hQk90XMoy/OJBM1ApaaHprqolj9ZK45yc/w4wE431H/Rp8Jq3X2Mlq8nAgnoxu2qO9o1oM2QoP32GTKG+3dhLjA/eT9kzsZicmAio/XoeIEfYyxbqa/bQSSAqAhnBvdJPTZQ3WO6B53j9uUH+8FF5WRwuKjfU4S7bHVSoGcrao3xDZe+MYMMmYAKUHOIADgJEL7o/wGajzYvZnb3FXOKx1tXDEy4KPXERdNqOovmRqjcDWo2884kj3JQ78AJE54sxi7T0/E4Mbm+TDMcEUCoMD7Q6fWt39dXKnd18wkKBNqALLQI/62ruknlGHU5MuqFwZ6g+EkgtDww2ZNxVUAZVosJCECZPwrrqI2n0nkJ4LGEY2qCWo7oSnAn0EgofDrjXDjUcoLtarrTztuCjEJo7n5JpR6jbwqVFaPzeRexsa0+yx8SSoq2HWOVVENLSVt8tK+c/2u2f80kbNC+yNVEPk9wSC55qjq5LrmC6fDWJ3MZJAuYt8Z2LkTG5Hbrq08TvoKqPyC4MDejo2UKNn/b+z33NCcclyLX9Pik7ecaskfS26sSDY87BiP4CAM4MK4copXliPxvoBrZvTAHtR1szzs64d/avplZGmomPt8jF2dVgcgmrYYI4kHf8sE5H0KYUmbh+Hc2454wMN+4jI7HeFyptpkWQGstZ1BptnYKXvm1p5SZamoNGEz0YLrUz+RirvhnwEsyFBtVS X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd585023-661c-458e-d659-08db93345736 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 08:42:01.5120 (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: 9mXAQbu2e5OJGlnDnz7iBJMZxhsZs3xRxaM074AVfD7zKv0+Rc9rnMMTQeCo9lIr5/faE0z3EH1/r5+NtlkIiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8503 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds the possibility to register a broadcast media endpoint if the controller has support for ISO Sync Receiver. --- profiles/audio/media.c | 81 ++++++++++++++++++++++++++++++++++-------- profiles/audio/media.h | 3 +- 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 15c64c8d6..edf106a12 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -105,6 +105,7 @@ struct media_endpoint { GSList *requests; struct media_adapter *adapter; GSList *transports; + bool broadcast; }; struct media_player { @@ -1059,6 +1060,9 @@ static struct media_transport *pac_bcast_config(struct bt_bap_stream *stream, { struct bt_bap *bap = bt_bap_stream_get_session(stream); struct btd_adapter *adapter = bt_bap_get_user_data(bap); + struct btd_device *device = + btd_adapter_find_device_by_path(bt_bap_get_user_data(bap), + bt_bap_stream_get_remote_name(stream)); const char *path; if (!adapter) { @@ -1066,9 +1070,17 @@ static struct media_transport *pac_bcast_config(struct bt_bap_stream *stream, return NULL; } + if (!device) { + DBG("no device found"); + } else { + char name[30]; + + device_get_name(device, name, 30); + DBG("device found name %s", name); + } path = bt_bap_stream_get_user_data(stream); - return media_transport_create(NULL, path, cfg->iov_base, cfg->iov_len, + return media_transport_create(device, path, cfg->iov_base, cfg->iov_len, endpoint, stream); } @@ -1238,6 +1250,12 @@ static bool endpoint_init_broadcast_source(struct media_endpoint *endpoint, return endpoint_init_pac(endpoint, BT_BAP_BCAST_SOURCE, err); } +static bool endpoint_init_broadcast_sink(struct media_endpoint *endpoint, + int *err) +{ + return endpoint_init_pac(endpoint, BT_BAP_BCAST_SINK, err); +} + static bool endpoint_properties_exists(const char *uuid, struct btd_device *dev, void *user_data) @@ -1351,6 +1369,17 @@ static bool experimental_broadcaster_ep_supported(struct btd_adapter *adapter) return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL; } +static bool experimental_bcast_sink_ep_supported(struct btd_adapter *adapter) +{ + if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) + return false; + + if (!btd_adapter_has_settings(adapter, MGMT_SETTING_ISO_SYNC_RECEIVER)) + return false; + + return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL; +} + static struct media_endpoint_init { const char *uuid; bool (*func)(struct media_endpoint *endpoint, int *err); @@ -1366,6 +1395,8 @@ static struct media_endpoint_init { experimental_endpoint_supported }, { BCAA_SERVICE_UUID, endpoint_init_broadcast_source, experimental_broadcaster_ep_supported }, + { BAA_SERVICE_UUID, endpoint_init_broadcast_sink, + experimental_bcast_sink_ep_supported }, }; static struct media_endpoint * @@ -1382,6 +1413,7 @@ media_endpoint_create(struct media_adapter *adapter, int size, uint8_t *metadata, int metadata_size, + bool broadcast, int *err) { struct media_endpoint *endpoint; @@ -1397,6 +1429,7 @@ media_endpoint_create(struct media_adapter *adapter, endpoint->cid = cid; endpoint->vid = vid; endpoint->delay_reporting = delay_reporting; + endpoint->broadcast = broadcast; if (qos) endpoint->qos = *qos; @@ -1458,11 +1491,11 @@ struct vendor { } __packed; static int parse_properties(DBusMessageIter *props, const char **uuid, - gboolean *delay_reporting, uint8_t *codec, - uint16_t *cid, uint16_t *vid, - struct bt_bap_pac_qos *qos, - uint8_t **capabilities, int *size, - uint8_t **metadata, int *metadata_size) + gboolean *delay_reporting, uint8_t *codec, + uint16_t *cid, uint16_t *vid, + struct bt_bap_pac_qos *qos, + uint8_t **capabilities, int *size, + uint8_t **metadata, int *metadata_size, bool *broadcast) { gboolean has_uuid = FALSE; gboolean has_codec = FALSE; @@ -1546,6 +1579,10 @@ static int parse_properties(DBusMessageIter *props, const char **uuid, if (var != DBUS_TYPE_UINT16) return -EINVAL; dbus_message_iter_get_basic(&value, &qos->ppd_max); + } else if (strcasecmp(key, "Broadcast") == 0) { + if (var != DBUS_TYPE_BOOLEAN) + return -EINVAL; + dbus_message_iter_get_basic(&value, broadcast); } dbus_message_iter_next(props); @@ -1569,6 +1606,7 @@ static DBusMessage *register_endpoint(DBusConnection *conn, DBusMessage *msg, uint8_t *metadata = NULL; int size = 0; int metadata_size = 0; + bool broadcast = false; int err; sender = dbus_message_get_sender(msg); @@ -1587,13 +1625,13 @@ static DBusMessage *register_endpoint(DBusConnection *conn, DBusMessage *msg, if (parse_properties(&props, &uuid, &delay_reporting, &codec, &cid, &vid, &qos, &capabilities, &size, &metadata, - &metadata_size) < 0) + &metadata_size, &broadcast) < 0) return btd_error_invalid_args(msg); if (media_endpoint_create(adapter, sender, path, uuid, delay_reporting, - codec, cid, vid, &qos, capabilities, - size, metadata, metadata_size, - &err) == NULL) { + codec, cid, vid, &qos, capabilities, + size, metadata, metadata_size, broadcast, + &err) == NULL) { if (err == -EPROTONOSUPPORT) return btd_error_not_supported(msg); else @@ -2627,6 +2665,7 @@ static void app_register_endpoint(void *data, void *user_data) int metadata_size = 0; DBusMessageIter iter, array; struct media_endpoint *endpoint; + bool broadcast = false; if (app->err) return; @@ -2736,12 +2775,18 @@ static void app_register_endpoint(void *data, void *user_data) dbus_message_iter_get_basic(&iter, &qos.ppd_min); } + if (g_dbus_proxy_get_property(proxy, "Broadcast", &iter)) { + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN) + goto fail; + dbus_message_iter_get_basic(&iter, &broadcast); + } + endpoint = media_endpoint_create(app->adapter, app->sender, path, uuid, - delay_reporting, codec, - vendor.cid, vendor.vid, &qos, - capabilities, size, - metadata, metadata_size, - &app->err); + delay_reporting, codec, + vendor.cid, vendor.vid, &qos, + capabilities, size, + metadata, metadata_size, broadcast, + &app->err); if (!endpoint) { error("Unable to register endpoint %s:%s: %s", app->sender, path, strerror(-app->err)); @@ -3245,3 +3290,9 @@ struct btd_adapter *media_endpoint_get_btd_adapter( { return endpoint->adapter->btd_adapter; } + +bool media_endpoint_is_broadcast( + struct media_endpoint *endpoint) +{ + return endpoint->broadcast; +} diff --git a/profiles/audio/media.h b/profiles/audio/media.h index 1de84a8ff..0eeb5746a 100644 --- a/profiles/audio/media.h +++ b/profiles/audio/media.h @@ -22,5 +22,6 @@ const char *media_endpoint_get_uuid(struct media_endpoint *endpoint); uint8_t media_endpoint_get_codec(struct media_endpoint *endpoint); struct btd_adapter *media_endpoint_get_btd_adapter( struct media_endpoint *endpoint); - +bool media_endpoint_is_broadcast( + struct media_endpoint *endpoint); int8_t media_player_get_device_volume(struct btd_device *device); From patchwork Wed Aug 2 08:41: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: 13337850 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 1FD15C001DE for ; Wed, 2 Aug 2023 08:42:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233841AbjHBImL (ORCPT ); Wed, 2 Aug 2023 04:42:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233873AbjHBImJ (ORCPT ); Wed, 2 Aug 2023 04:42:09 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2075.outbound.protection.outlook.com [40.107.20.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBE16E61 for ; Wed, 2 Aug 2023 01:42:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ErPkds7PMdjOpvQriH36oUssIBYaJO+3i3UzHWNcmwBPqdtgS8BwYidlEybsJmFL2WYeXoCti64+d1YzrmQgk2e3CR3KUA9blRzfg22Y2/NoGAc21F7zc532xVeqDp+nbZT50aLtTHkgAaLXjY2rh86b06wVJ8gsZo3yEZMVX1xpM5NUzZ7yjECqwrZMDy8gVFpLqFe4s6uZuDPIkFZwJyS0ogqI8lEsUQYfQ3j9pcCkg8AOC8HtjG1rTQM2p2ahBQvKNv0NbM7thv1Xo08qMY4A3s8J7YHcLs7P6F3XCSR6sQAImgkmH5e2GBBlyLdiQHyfwcg8kBrqobBQjedmfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9oY+xZPrqsqIaUQOLZK2UcZgv8MQLra9GUE9X0JkM3E=; b=Zd30X4GN5+rPLeOExP01FHITgFZvg8br/yZEHi1SObKmsJEXjxF8QeR6PUdOkYBA8QTTxNsyh7ukm1Bj4lJufLIMWWxaPGVwx/VKQ4VUkoelSuheWAMmIOvCrJMrdNO9Rx8XQSRcREZLrCxpM9Fml1TPA8wftObR6ysqFz975hGcab7XPdkeHZKuvCNKwYYWg67kQphC8I2nNRzBfnDSFZkFjEKGCdDQlAByrOljCHH9Y2UfUiWWgfBw/lmlmH329xpWB9T5tCznbK2PkkweJzUC3WpTkwqXGfH42hL974gNpxBUAqdze3mVuUnYBHPjHji5DVoCSD6MYkVBSFF1Rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9oY+xZPrqsqIaUQOLZK2UcZgv8MQLra9GUE9X0JkM3E=; b=O41v6Ie5uQKOBizRCpqdkTGSEg/2IvWu/l7iChhabkPXFkKpJvgYAiYKrRQaHokNLOrcKwFGCJ6NyT9uAmabA5FUBxLxW1V3mbznto0oeIpyj4yp8DtFiyQQJbr3/wh7T0yilUgKyNL5XrQ5k+oy+JRFVyeyssu7r1XFDlJX+zM= 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 DU2PR04MB8503.eurprd04.prod.outlook.com (2603:10a6:10:2d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 08:42:05 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9%7]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 08:42:03 +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 v3 3/6] transport: Update transport properties for a broadcast stream Date: Wed, 2 Aug 2023 11:41:37 +0300 Message-Id: <20230802084140.51105-4-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802084140.51105-1-claudia.rosu@nxp.com> References: <20230802084140.51105-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR07CA0003.eurprd07.prod.outlook.com (2603:10a6:208:ac::16) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DU2PR04MB8503:EE_ X-MS-Office365-Filtering-Correlation-Id: 5746c741-f7f4-482d-a46a-08db93345878 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x58UNHauHKUD5abRZNmG98MP38CLG1H0PIPbb6+HTNtSL/2DsmlI1X/EjgeTmOatgTKBL6ecHnNMk2do8XfBSomHlff/cxNnLOrey7M/tMxQks41AbYtW4+kCxPoIx9TicrLGOVFh+1DMljQGGBbqpRcUXJ84c44l4Vw9JEYy2iqjv+dSY3URpLz+p/3rzcdq4Uo0gFYBb5Nv+r5Svw9O9PcT53OVgyESSDeH6t4P2xgbp+SKhfYhpy7L20oFwsGbm2svDdfZBBiHxt3C1RvhQ3CMnkqhM57OrvigwGYjNxUUbp5ejn/5YNu3k7Ja+bLewO3IgKVlDBst4k9FzXvQixPFV+L7iAFIRlZekekLtkZEMJ0Fci4EZ9yIRWf7LdwUbePML5elzqNDB4m5mDPu0e2Nyk0/Ge15FCiGhdd03NgD4gQDui6xpKmWi09WpvP8KV3oHjBjvcWs13dL2vfH5vf2gp7PYiN7K6qICmEheS7IdfC/fyXlGz9bEqP+MLn3Cv5IjYXp15g4/X1VRY4f5WD1AtSHU5hcLsdJLwpeOumOdXTWPVJbuEiHWBuRNtHR+YmazJb8trvRX0ZdtC0Rv3lyefxzwlN+6suS0ZWrsZM9zQrhqPIaZmOXUP1TtlT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(376002)(136003)(396003)(39860400002)(451199021)(66476007)(66946007)(4326008)(6916009)(66556008)(316002)(6512007)(83380400001)(2906002)(86362001)(186003)(26005)(1076003)(5660300002)(6506007)(36756003)(30864003)(2616005)(38100700002)(38350700002)(41300700001)(8936002)(8676002)(6486002)(52116002)(6666004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a7XCTOv2blM8j/Q/X1EbaAXKv9HhCGqfj4l+jsz6mIerulyvMu2nR153nbAGZ/CEzZ7TMi+Gc7cQS9Gpfj9MbatPqyrOxdoVbw5UvhTkA8odrMp6GxiYo1drUKAWaQw5FfXH5A1LxVkuiIC37sY1Fmy57ipz4UDeBexCU9Lhew16CnqBX9iQq+YhZDmjqWXIxcVPmQIxzYgQqPDRpFf8Kl+UDeyloohXlemmrq7VmXKx1LRqpbZ1q93beVQfOw8LW59owL9D0y9PBmETUlqAJmreDdawV24hPSW4dYkmBMbrKTgCk5fyR9PQuTUSIylFVUQWeoEJ2bt700Suc80DWeYTIPs2gSXFpi+7I5dT02jYvv64x/eXla+t4ywRi/2ulxnHf3ODnKpfTtlavjdUE/TI34d9KifnDPERprBG8EEPn9uzpd3fmOHMU54Z9M2zPYJyC5qKzq3tItvVpQ3AfS96Wu+vv43nKv6xwiAVpH9agPFDwYDYndD8fdcDR0cAsSSXwLn6oiJZ/3Nx7jcv9SARnBGiDaSHhqYgnz2WjO6fyCf8r75Njm8nsaghX08NKs0dEkcvzMahfgGS/A3UXGXD7UJ2BR4Gx23bmsCZa5mplRkG3LsRY0QAgJEBy5wktgqwPGRCk/hAfVtaM4ncVNcq5i6lFQNBrynY9k3GA7fq27oC39K+HKte5THw8bS4DfRZu1IWXqfpGm6Ljdvn9jyxmGvinTZ8kN48FAU1yfM0AlgOZeDJgNFGpcBB0J1ggUpui1Og9K03lJRKiSc71PTmkJhoFWI574hxcS2TCvA3+9dJCALVhPjQeUwcOrMW2qeuCHIgzno77D0bg2dCDIpPufjnyV0PsVD2VPXF7BO+gAnyFnLHhP742zBfS/qR4s2AyzoHBpwKw3Rpt+8Y9U0TD2tsSGkRrioUUg1CQBb64UaG9ePa55BVDF+x369IgfRXzMtYmgjKFRqFNN27aw77/Fm0ImO9vfllqqm+ZX9+UqJcFos1rxcmiCGJN641Tz+hwxdshgAmDT4+945ncMIAVeGUerc4HfRNwQflurFLHOsJOm9coUOyQWt37UjHuWgpiOujwx9LoIMqIrveJFSR8PuCDoLTwARjOJyZQljmVzBuWrirgnIXA3S0K90yhcdVKM7PYbiLQlIni0o/wh3oBX2gsP0TkBKM8Mvo75ZYMRnuttiHMQgtdI9H9Fyk9kJ3d21CmWZlWSt3kKjhOPgqR29yjjwbQCEaUkWjulHVf8DcOs1AcqeXgQLNU0p/+m23aRknDxQZRWhPvF95VdWfTV2JOToZ9V+herV0o+V34QqWWL61TX5xCP/fId4lqTWD5MGQTmnxHaZIIaXx+XlgEjqFdtM1nEW2bkT9SNuU1as2k/xDz7aIT3m9xWJsEjImQEZYVoet54Z+U4iaKSBH8d7mG/6RcKS/n5nh2dt8PVOT/cKMbL3TpNMlwEWk2IeW1Ml0lOolRwn4AzMtkY0UzUWlUiEFKzeuOukiNDkT6ZA71ppk8sw0FzW0xUDgAVA4BeMLPDD+GSa+HLD4VwYYJGPJUKEpnjhDwHfz+R/9uIGiaVARIgKh3heNOpL3ltpUXx9L3erkmnu8tzz2nw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5746c741-f7f4-482d-a46a-08db93345878 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 08:42:03.6116 (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: PkmYNG+SYh0GedP96jvU4gTvkIHaBSg3s9fdGEXKJAnuX5UUkhX/HQLMY+Ctbr8eHEc9DfMtnq0MX1NoaP0ozg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8503 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch gets the QOS broadcast stream parameters and passes them to upper layers. --- profiles/audio/transport.c | 245 ++++++++++++++++++++++++++++++++++++- 1 file changed, 243 insertions(+), 2 deletions(-) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index cf5662d1d..aa2fa4397 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -552,6 +552,8 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg, owner = media_owner_create(msg); if (!strcmp(media_endpoint_get_uuid(transport->endpoint), + BAA_SERVICE_UUID) + && !strcmp(media_endpoint_get_uuid(transport->endpoint), BCAA_SERVICE_UUID)) { req = media_request_create(msg, 0x00); media_owner_add(owner, req); @@ -853,6 +855,9 @@ static gboolean qos_exists(const GDBusPropertyTable *property, void *data) struct media_transport *transport = data; struct bap_transport *bap = transport->data; + if (media_endpoint_is_broadcast(transport->endpoint)) + return bap->qos.bcast.io_qos.sdu != 0x00; + return bap->qos.ucast.io_qos.phy != 0x00; } @@ -868,6 +873,18 @@ static gboolean get_cig(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_big(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.big); + + return TRUE; +} + static gboolean get_cis(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -880,6 +897,18 @@ static gboolean get_cis(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_bis(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.bis); + + return TRUE; +} + static gboolean get_interval(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -899,6 +928,9 @@ static gboolean get_framing(const GDBusPropertyTable *property, struct bap_transport *bap = transport->data; dbus_bool_t val = bap->qos.ucast.framing; + if (media_endpoint_is_broadcast(transport->endpoint)) + val = bap->qos.bcast.framing; + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val); return TRUE; @@ -910,6 +942,12 @@ static gboolean get_phy(const GDBusPropertyTable *property, struct media_transport *transport = data; struct bap_transport *bap = transport->data; + if (media_endpoint_is_broadcast(transport->endpoint)) { + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.io_qos.phy); + return TRUE; + } + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &bap->qos.ucast.io_qos.phy); @@ -922,6 +960,12 @@ static gboolean get_sdu(const GDBusPropertyTable *property, struct media_transport *transport = data; struct bap_transport *bap = transport->data; + if (media_endpoint_is_broadcast(transport->endpoint)) { + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.io_qos.sdu); + return TRUE; + } + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &bap->qos.ucast.io_qos.sdu); @@ -1040,6 +1084,121 @@ static gboolean get_links(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_sync_interval(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.sync_interval); + + return TRUE; +} + +static gboolean get_packing(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.packing); + + return TRUE; +} + +static gboolean get_bcode(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + DBusMessageIter array; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, &array); + + if (bap->qos.bcast.bcode && bap->qos.bcast.bcode->iov_len) + dbus_message_iter_append_fixed_array(&array, DBUS_TYPE_BYTE, + &bap->qos.bcast.bcode->iov_base, + bap->qos.bcast.bcode->iov_len); + + dbus_message_iter_close_container(iter, &array); + return TRUE; +} + +static gboolean get_options(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.options); + + return TRUE; +} + +static gboolean get_skip(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.skip); + + return TRUE; +} + +static gboolean get_sync_timeout(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.sync_timeout); + + return TRUE; +} + +static gboolean get_sync_cte_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.sync_cte_type); + + return TRUE; +} + +static gboolean get_mse(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.mse); + + return TRUE; +} + +static gboolean get_timeout(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.timeout); + + return TRUE; +} + static const GDBusPropertyTable bap_properties[] = { { "Device", "o", get_device }, { "UUID", "s", get_uuid }, @@ -1059,6 +1218,17 @@ static const GDBusPropertyTable bap_properties[] = { { "Location", "u", get_location }, { "Metadata", "ay", get_metadata }, { "Links", "ao", get_links, NULL, links_exists }, + { "BIG", "y", get_big, NULL, qos_exists }, + { "BIS", "y", get_bis, NULL, qos_exists }, + { "SyncInterval", "y", get_sync_interval, NULL, qos_exists }, + { "Packing", "y", get_packing, NULL, qos_exists }, + { "BCode", "ay", get_bcode, NULL, qos_exists }, + { "Options", "y", get_options, NULL, qos_exists }, + { "Skip", "q", get_skip, NULL, qos_exists }, + { "SyncTimeout", "q", get_sync_timeout, NULL, qos_exists }, + { "SyncCteType", "y", get_sync_cte_type, NULL, qos_exists }, + { "MSE", "y", get_mse, NULL, qos_exists }, + { "Timeout", "q", get_timeout, NULL, qos_exists }, { } }; @@ -1341,6 +1511,71 @@ static gboolean bap_resume_wait_cb(void *data) return FALSE; } +static void bap_update_bcast_qos(const struct media_transport *transport) +{ + struct bap_transport *bap = transport->data; + struct bt_bap_qos *qos; + + qos = bt_bap_stream_get_qos(bap->stream); + + if (!memcmp(qos, &bap->qos, sizeof(struct bt_bap_qos))) + return; + + bap->qos = *qos; + + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "BIG"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "BIS"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SyncInterval"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Packing"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Framing"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "BCode"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Options"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Skip"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SyncTimeout"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SyncCteType"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "MSE"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Timeout"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Interval"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Latency"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "PHY"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SDU"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "RTN"); +} + static guint resume_bap(struct media_transport *transport, struct media_owner *owner) { @@ -1493,7 +1728,10 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, if (owner && owner->pending) return; bap_update_links(transport); - bap_update_qos(transport); + if (!media_endpoint_is_broadcast(transport->endpoint)) + bap_update_qos(transport); + else if (bt_bap_stream_io_dir(stream) != BT_BAP_BCAST_SOURCE) + bap_update_bcast_qos(transport); transport_update_playing(transport, FALSE); return; case BT_BAP_STREAM_STATE_DISABLING: @@ -1503,6 +1741,8 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, return; break; case BT_BAP_STREAM_STATE_STREAMING: + if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) + bap_update_bcast_qos(transport); break; } @@ -1631,7 +1871,8 @@ struct media_transport *media_transport_create(struct btd_device *device, properties = a2dp_properties; } else if (!strcasecmp(uuid, PAC_SINK_UUID) || !strcasecmp(uuid, PAC_SOURCE_UUID) || - !strcasecmp(uuid, BCAA_SERVICE_UUID)) { + !strcasecmp(uuid, BCAA_SERVICE_UUID) || + !strcasecmp(uuid, BAA_SERVICE_UUID)) { if (media_transport_init_bap(transport, stream) < 0) goto fail; properties = bap_properties; From patchwork Wed Aug 2 08:41: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: 13337851 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 E3DE3C00528 for ; Wed, 2 Aug 2023 08:42:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233955AbjHBImN (ORCPT ); Wed, 2 Aug 2023 04:42:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233944AbjHBImM (ORCPT ); Wed, 2 Aug 2023 04:42:12 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2075.outbound.protection.outlook.com [40.107.20.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041B4194 for ; Wed, 2 Aug 2023 01:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=izfjZUEw7YWx5N3lzvGsa9WhMsY+yXx3z90BzfCQ4fm5mobVIoSAZOqBaYcLwsp5BBzZZPnwIXGBcaQcNYUDI+hFycOLfqAJq+UBJdcLek9HbbDctjg4Vv878wpkA1PvL3rSWkQEIyXLkwSJfDgTQhUHr2BYfO+So2hZej89EuiduFnoDVwMbJD/nb6H56VAKRvWjqOgX8TgIuSNPivbfpY5L0d2KAGmPPafrNSu+kMvW9wwxk/LHaFecJusZkKSghLPrFlHy3lwHjLVbNAJcZPCK5+rL8ddf0YqB+rt67YmXABxSdEoD4p0WCi1cDzT6JL52R6ETXZ/VpyzZ3lOuw== 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=T7LkF5wvMLM/H/Zc7PqXIA//4RHszL+KIoRdBEz0tZmb3OWeMzq2cMHzjmAJW0j5vCorLcU5yFI84rlqPtyaB2JtBZk2R9ybNsiM2pqjnAJeEjcU+GFOk+fdg5DRZ16KNo+/+Ov5Z53pii4LCRPT6E2QNLTA4XEUWLZuenLgozidwYjajv4CKcUTKoVch92j1UWzRLsgCufOybR7S1R0tUTeuHFJdsVAqxHLXK5Ikvnds4BU9Pjg3//0MvN2+AyhPd0qoYQC5yPbCHVK65TK/sS3WcwaGWS31hDwcr5dfeIZ7PWs60JQf59d8DSw5trSf0TT8wtIZS7mLrgoIPih2Q== 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=ceeOzJ9b6GW9beqA5iCVZetKCbRP3ddmdvqXoAfeDh4/ZTG0RyR0jD+96e2B2jeRFzIgPBzOg9m/u+J+M7f8scF1/ktNhRk033RKsL8DmsWMO5s7IpzN0jvyYJUM0a/g3X63TmafBGK5WXB6F0chzCrbDH5NKu4wesdKUC+yU5Y= 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 DU2PR04MB8503.eurprd04.prod.outlook.com (2603:10a6:10:2d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 08:42: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.6631.045; Wed, 2 Aug 2023 08:42:05 +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 v3 4/6] btio: Add support for getsockopt(BT_ISO_BASE) Date: Wed, 2 Aug 2023 11:41:38 +0300 Message-Id: <20230802084140.51105-5-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802084140.51105-1-claudia.rosu@nxp.com> References: <20230802084140.51105-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR07CA0003.eurprd07.prod.outlook.com (2603:10a6:208:ac::16) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DU2PR04MB8503:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e2947e2-e9ba-44df-fb5f-08db933459c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TMsMK4RniP0ijoOyrG/s1ZDrx/zun//41/2GLP9yeoflwWk3/pSUFRTUeaxn0FrO1dIy51akBSNi2FLMXcXYBwaSpmI1CpGdCvSgDyxrHPU8P6o4B7JzvTUqeqDTK4oeUYGuiJayOyrFGg2UWKmbmtf58yHEPDWr4dIO2EG6jT8wk+KGjdEWAdej52LhDDXkxJa9Ya7NzOKHx5ZiSUKkTC3rzgjSXtk3BP4wuCHJwq1WgEG2qHDCeCmHsnaEh0B6+clT/SJnDZYQAyQgvZ73D+S3d8H8FalXtf7ZA/gRFR5Sf7W/ETKo7DBJhv0n/qanoPgidIKmCXkGYGQIsvS93/jFpZoSjn9C5dzyqulmmzlXBYW5F4RkDe3OxnTnxehmjFu0c3w+NKE9VZlwyD/PqyxQWe0d1vMzgWKYHJepEO8uzas2OLfafz0qhx3Bse5ZH7cLf5ZGVOXzd0LXlq+jL6+IHAyG4mKYPhlyxjX0CKOcfk2MfD+vagycr1OjcL9s1VSYtWPBQbPhexkH4SZyQ/AFjxPZ3/WUQB2TY/mZzClM/i3ILijnSKDz0CHbgQ2I1Elsgzshyh44vgzT63xzv7pvIsXW9sD3rPeDJGvUQucbgQjpPGqO4qVj20IGyQcw X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(376002)(136003)(396003)(39860400002)(451199021)(66476007)(66946007)(4326008)(6916009)(66556008)(316002)(6512007)(83380400001)(2906002)(86362001)(186003)(26005)(1076003)(5660300002)(6506007)(36756003)(2616005)(38100700002)(38350700002)(41300700001)(8936002)(8676002)(6486002)(52116002)(6666004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NjvGYJYsIvH47nlJTlt8jd5crlEW2DYMIEJhZSOOYtrVpAoscTHOPEZSmpkJlZxJJtpk1UVjzOVwYSQuGZFQ0+ZXE6X30mZrjJgWPAEvcK76u0B958vWAID0udCO1IUejkN2IpjUcMvlPystTbS73UnHwbA6fZ7KHAa6ELYJlaOj0e4xnXpeEiMMISfnB144cbgeR46sNMj0wJ54D2tYR1VRz5JJO5zoG7OKttPgcHIngpFF40nZVYl2SsCddrMt99rH/fowXw8DRYC1r+r8arbLIkvAGp3O67tVb2ySwxQyz8nHkPGSNAhRM724WIXCfCDKxxFZtzhAZAHZbvo2HiO72/pssI+A3Bi7ZpsehavLiiOTzxy/JwJyS6MHfb1QZlQk4B4GrIVab6zRNO1xEnM7RrUrgHVbWcuXsFIkwHfbZFAdiublXO+fYtzEzTu0tmYXHXGMEfQqFsYqyPZpijL1XIMKB8k89mAKL0eI3nj28+e0jHJtjc35gHTi0AT071ovTyHEomJIlHZj1gCAek5H/LcCgDZTOnDfQZRbbdCBbyDxCSnJo0ihAnkP0JJCoGJA9o3j1p9pX0Tq0yWOJW32QghgnC/nEn5M02hvrPbswJqumIsRIwYf/3fIRAZetfpe8iFqzUio41OlSOGzR3wBQ6wK7m/RZrY5NTwPKc/gwDQYN3C651I1ZLmJiZVpV9i8RWJszoAgqWV39T+cbk2pej86OOraOAU6dhN1bbnoOSYIcVu1UprBd+kK+VqjEMh9b7ZMyL+ovd9PONLAs0MPnpYA1c4o9cjNCZ8wX9VauOmyDn71pyAwwc1sVFcJe+UdjhiAQFH4hcp3Ol9+qqgz6EsfWHHIDkH9BX7giuQA/1t/sHZQuCenNGdbWXVqpUwGyeU8clUUr4E01hddryv+BeGip7XPEa7AGtcNh1nwNm5WS3wVc4h2n/eZloRO00upVgrE/fOtVIb7vqkEeIN4IJJngRpxnfu2l2urM6SQqz/7qmjzVPLDS8hggS6mJ3RWfl/LyEJKIsJ21twWCx55Ra5DU3DjjrSl8HJ4n7SRvMqsbfDG3St7LmO4yMty6hTYzswei1BXnMAXp/9J+/N/uhSltSnEaO4wAp6v7w4CJKSNC0I6q8sgTJC8TzxJl68RGofch4Al3/Ngd8GlXpC7OQXhYZp/H0d0W8Z7VEsumZlDzAPSCF8oKyh3MKuSdmxHsnXA64aIMDEdHMFeuWEhr9WfNqybE9FpWrGcB+9rPKDduEHPTkrRGUDg7AXoHduLU3agx51JScaDPxaa/i8WXBat7t6PQo3XWrpmrqi6ayWYyRDKpC7AMkFfAhiRN+VsyVhgE99aOP4UeIASKAIhKSuuENbXZGGqdMQNOqDY4C+2xpyGlfrYnu0I8B71D0ctahvF24CEcptzEXEdv5Y4BIf4Cl1BjwkZi9Slvcmv2ViU3edvia7ZqwkCfN+jMIPa0PqMmnGHNNaXJxTo+qrTyla5CcP3WXQzHJMwKCjRzTLJ39pU5niv0bUzu9qcGwlMVXbBqmrnedXUt+UutdDDO/h9KMDlYPtBVbYbXNFo4+XdhegNZZnAK5helQf2+Py47vqBG/3uJkL0W3bGtg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e2947e2-e9ba-44df-fb5f-08db933459c3 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 08:42:05.8099 (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: 5586IOoXVR8otNV5VKBh2TptH77e8QF6OUq5HB/clsUkeGXlOR0/N9uUIG9QvdOygEJywJP64swBlwZC9z+V2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8503 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds the posibility for a broadcast sink to retrieve the BASE information received from a source afeter a PA synchronization, using the getsockopt(BT_ISO_BASE) function. This needs the patch from bluetooth-next: Bluetooth: ISO: Add support for periodic adv reports processing --- btio/btio.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/btio/btio.c b/btio/btio.c index 179be6289..8178250d2 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -1638,6 +1638,7 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) BtIOOption opt = opt1; struct sockaddr_iso src, dst; struct bt_iso_qos qos; + struct bt_iso_base base; socklen_t len; uint32_t phy; @@ -1648,6 +1649,11 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) return FALSE; } + if (getsockopt(sock, SOL_BLUETOOTH, BT_ISO_BASE, &base, &len) < 0) { + ERROR_FAILED(err, "getsockopt(BT_ISO_BASE)", errno); + return FALSE; + } + if (!get_src(sock, &src, sizeof(src), err)) return FALSE; @@ -1694,6 +1700,8 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) *(va_arg(args, struct bt_iso_qos *)) = qos; break; case BT_IO_OPT_BASE: + *(va_arg(args, struct bt_iso_base *)) = base; + break; case BT_IO_OPT_HANDLE: case BT_IO_OPT_CLASS: case BT_IO_OPT_DEFER_TIMEOUT: @@ -1896,8 +1904,9 @@ static GIOChannel *create_io(gboolean server, struct set_opts *opts, goto failed; if (!iso_set_qos(sock, &opts->qos, err)) goto failed; - if (!iso_set_base(sock, &opts->base, err)) - goto failed; + if (opts->base.base_len) + if (!iso_set_base(sock, &opts->base, err)) + goto failed; break; case BT_IO_INVALID: default: From patchwork Wed Aug 2 08:41: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: 13337852 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 D7497C001DE for ; Wed, 2 Aug 2023 08:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232278AbjHBImT (ORCPT ); Wed, 2 Aug 2023 04:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233882AbjHBImR (ORCPT ); Wed, 2 Aug 2023 04:42:17 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2051.outbound.protection.outlook.com [40.107.20.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FB90269E for ; Wed, 2 Aug 2023 01:42:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dWF9DOVNGJcGPDP/Pl/DVGssY+/r+XRX8miNu4psN0P7pCyQHUZc7pZv+IEEso85FH/HCDmLCHRFIW9V9Lb5c85vbugEb1D72aqo6AfYHMX4rLGEmb0bOfEvKNkNGBJn3snKdjgOPRKmBQ/rk230XeuF7YI8PSKmTAwdxfLGzPsjXEbhEz96syj+3Uia64qsN/o+vymvWOApvEgAsRQM0zIB4wg10EAzc9U1cqOsEVRdKwjjPgnBED+hnOz67UQm9fxG9Sz35SuyClyXeLUC08zM0PvNpFmuJMpaADN+azZmuAm6u3pM7u6yZotUnYNjua60gfeSPd4RP4ofVEumpA== 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=ctYEuIXNY32ZcwHVBkVD9um6Pt3ZWL4hHSelmkX3SHU=; b=j4GGfOIoj6s6gvCszhyPRkQD3sNkUDQPeJqGr+e8KfMtKZuZaCr4IaTTtYeeEhz/jBB7YhWe2xlHLENJA1wvSAATyzZHFYAj4SRpbSpTs9hGV/RR2E9LexlFDWLB/hpv4J08no9kbGOtuXOqT0WD5hH+vbijGreolHRxGuAIwh8hBOOtbTJy7+u+hcaKDx+G7BVnEoeQfR1coQ6byPrhvvcQS5NJmXOdFMYrrLnevKc0OvdjCU1jYPgA9JtetET0fl56nnes3ci/9T7s36ME0R/tL1qE7jngxS7WoUxAn4RcHMAsB4d9AkX1SRsILJY5o1ZAeXWALbM1ZZ1NzbPngQ== 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=ctYEuIXNY32ZcwHVBkVD9um6Pt3ZWL4hHSelmkX3SHU=; b=SEMeSSYwgGthHiWDxhn7qjr6LwFXSwNqcR5IKJmv0WcNXU48mZb00wP4l7wOj463LnNY06V4d9rfQ7WqhNKYpSEZLX1rgu1eFXfJsum/EuZJ2Sqr2m2WZQV7LjSa0VQll6V3T1byLMDBNiaDNYI/7kPMH9lzcngX1trUaNoegMA= 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 DB8PR04MB7162.eurprd04.prod.outlook.com (2603:10a6:10:12c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 08:42:08 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::c2fe:9eef:61ea:36d9%7]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 08:42: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 v3 5/6] bap: Add support for BAP broadcast sink Date: Wed, 2 Aug 2023 11:41:39 +0300 Message-Id: <20230802084140.51105-6-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802084140.51105-1-claudia.rosu@nxp.com> References: <20230802084140.51105-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR07CA0003.eurprd07.prod.outlook.com (2603:10a6:208:ac::16) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DB8PR04MB7162:EE_ X-MS-Office365-Filtering-Correlation-Id: 9868da03-5a96-4590-b79c-08db93345af2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jlKtuOGGc3XmGIRtc4CuTLfBdDQManqEyyZjVl934qbIemYLGRNTerm9kVFnGV+85lpCVO3hqIDMWNCfMJPyRnfSJ22YccINI+53i6AwBwyoauCivC+9BBLisv9qUFj4mJldG59JG1/5uWDRGEk8OlWES7zvTSzsb0/yh8RlW8fjBSuWgYTBvI1i9VZ+uW9PFG3l4Zob/xyUEoGro4/KSxIYu6B+Avk8IM3yIdH00xKoNX58VtjtLAzLtraIetuU8LzW0rQWlZ353+kHEs9eMCcRKHJFuXD4dWZl/NEyXe12/JgP7c6lVanHuf+fK0J1BI+V/cX3Wp1y6w82ZxqYzqeJwse5fjxkNAXxHAtqmf5AsH2hgTogBY6bmlKKlywzi8PbkBd64wc6YV5Jv0sM7dccUR+vvZE0Cq7b8QCTMtJ9MaUZHMsWcoAq3oxPlt/GiNCmfc8lnSODdKknPwg//mqgopPnaHMTLtMxAhYScHn5UPtxASVBqwqE3rSxX+uxh6q9Cwrwh8SnuCiQIROEiSk4+/D5IM2IkVXNEcLEViJfnjFVvtDstJTnqjWaEV4ipUfJuGCvQDaa9xS+wKcn6LECQTGOlpjHH5lyRDgkrC2P8/TlleFxtvUrS8RENIex 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)(39860400002)(376002)(366004)(136003)(396003)(346002)(451199021)(2616005)(36756003)(6512007)(316002)(478600001)(86362001)(38350700002)(38100700002)(66946007)(66556008)(6666004)(66476007)(6486002)(52116002)(6916009)(4326008)(1076003)(6506007)(41300700001)(26005)(186003)(83380400001)(8676002)(8936002)(5660300002)(30864003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: go8N9yLiN1bvEpWzAnYGsI+QbqGRDgtK0bDpIQafxukBOQcpFmMAgPpVmS5vKRDqBfJFnxWOyXeNZ9hzdYXkZVv+V/OXgdVZvDB9/NKicDFYUK03IYRA/2NQN1+gwoYETMXWzxyp/K0FIqDs/NRjQ86rGzoLLhCY+3gfLmmr15ppV4fSMtTqMl2RAwsZKPgKnMSbRAVV9DDNVAcOlVji4pbJFsY4XFrNLMMI5AMHkUL3er2bxRpzsBAdG55GLRs5pg2WT1SsEHacC5KpGiLILDCRcrrU6GMYPFolKRx8YkGSJ4IpFllCiYfg61QD7ZjflvGgu245zBXKDYV5NsKj8gmXzU4SCaEDa+pQ2KPnh60xKCQ1swG/eJOkWDAU1AptRKHHVVFAcdosOfwVBNG14ntivHnJTXzx2901dDaC521cFkmPcr2RmJKkySalGkK0So9fn+VQ3GIE/OHBXZMHDrSzp06btbBfAN0hYhpk1yZXt1b4hFsftZfdUVvRGKofgX/6O+H0PchgnTaabMiCwY0IO4McDVEFBpJvXHQYJCuX4uJgPDftBZczGbKjjW2HLCN1BfrdfElR32WxhdtKrKQtFJdv3YEqJ6WumSMHX6InN28IlC1xtI6ThvDfQJOFeVidouiRTLEKFyO0oSulvbX6FsTy+n+d89lIq1q5liHvKTnNvVmQtKZsf1TrmlEp0ikpfXB71aXbC0xx3lXvXEMEq4RdWL1CzxILseXeuMBoIsOvspxF6uaUpTIGa3Ad3lhPgseiJhRCZvfQ1oIfySwPztrd/O7+KAQ0j2NnUbfKGxkkArTPy+XcpMoHk945Tcw0x3nEb4bAXHLTwJ18pMLOmHYOLOG4N1qYsKUibC7prtyHcyT1IVpldRqDwpRPqew4LaJnXh3wu03v4ZziJOUkwDzMkDTDiIhbKHJg+1WIDuHQQvu5w6dOQ2yqZ9w/CDToAVLT0BoiTGFBI0hlChZZDRLVq2WoqCAax8Yk7U8JE0kkkrepVXbn4Ca8Q7TEgoT+Yh++bjjpYVAK4S5knB1au8kjFU+bN4xTdwQCa9Qm8o/gP3ivlzBMQSYhg8rh9UiEmkGUyDBSM1tNS/JKjfYmsCl7zkepYSwnRoLHRStdJ0YBgQIHrw0OEJ/rzgwF+wz8W5UJ2hJW2Fe3IIzSy6MaetzvkiXobJ8ikriaoXy9qYApyQmZ43+01WFjcgUKP9dAfdOYag/4z+kZuEGjerGe1+4XzhfFPDvaWKP8ySeYBx4JcfoV3D1lfJq2yQoOW3LGiuhiJHyLbPOD23lkqB9hEwhXXI0VBtu4jFuoWdgfAn36vM8exvl5EE81uUlWHZkTBEAioXFN11AwKIsFM8nsfm1dH1622pQlh4Z4q3RZUlxtg+Oz/j+hFa28Fv1c8E6ZmZbA/upZnCzGwVJjYKw4tQJoL66TJNEyXS4SgH1Ui+yPMSd4g9I70pL8qA2HTnecIZWZYeu5+ZyOqTvorhD7wAZ2CUIcZm7EQxUkvfRE3dynfer1M6e0QQkm2JZYJ5Hran06Dh5sddwVuDydHhS4bgee3I9RgpQcw2zIuVSv9/z8l6/j1RHpXPkT6ZTp X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9868da03-5a96-4590-b79c-08db93345af2 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 08:42:08.0181 (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: Me5k2k9dzDcCmtZen+xehJof9DuhPn1Mj2vpck7veDqhBcLrr4UIOSMZ4dk4F9ebhiakO/4azPdsQahOo2m6CA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7162 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds support for BAP broadcast sink, creates a remote endpoint when a broadcast source is discovered and synchronizes with the source upon endpoint configuration. This feature was tested using bluetoothctl with the following commands: [bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06 [bluetooth]# scan on [NEW] Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0 [bluetooth]# endpoint.config /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0 /local/endpoint/ep0 16_2_1 --- profiles/audio/bap.c | 300 ++++++++++++++++++++++++++++++++++++++----- src/shared/bap.c | 153 +++++++++++++++++++--- src/shared/bap.h | 11 +- 3 files changed, 410 insertions(+), 54 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 8cbb238ef..112e0673d 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -34,6 +34,7 @@ #include "lib/hci.h" #include "lib/sdp.h" #include "lib/uuid.h" +#include "lib/iso.h" #include "src/btd.h" #include "src/dbus-common.h" @@ -58,6 +59,7 @@ #define ISO_SOCKET_UUID "6fbaf188-05e0-496a-9885-d6ddfdb4e03e" #define PACS_UUID_STR "00001850-0000-1000-8000-00805f9b34fb" #define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1" +#define MEDIA_INTERFACE "org.bluez.Media1" struct bap_ep { char *path; @@ -186,8 +188,11 @@ static gboolean get_uuid(const GDBusPropertyTable *property, uuid = PAC_SINK_UUID; else if (queue_find(ep->data->srcs, NULL, ep)) uuid = PAC_SOURCE_UUID; - else + else if ((queue_find(ep->data->bcast, NULL, ep) + && (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK))) uuid = BAA_SERVICE_UUID; + else + uuid = BCAA_SERVICE_UUID; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &uuid); @@ -341,15 +346,18 @@ static int parse_properties(DBusMessageIter *props, struct iovec **caps, } else if (!strcasecmp(key, "PHY")) { const char *str; - if (var != DBUS_TYPE_STRING) - goto fail; - - dbus_message_iter_get_basic(&value, &str); - - if (!strcasecmp(str, "1M")) - io_qos.phy = 0x01; - else if (!strcasecmp(str, "2M")) - io_qos.phy = 0x02; + if (var == DBUS_TYPE_STRING) { + dbus_message_iter_get_basic(&value, &str); + + if (!strcasecmp(str, "1M")) + io_qos.phy = 0x01; + else if (!strcasecmp(str, "2M")) + io_qos.phy = 0x02; + else + goto fail; + } else if (var == DBUS_TYPE_BYTE) + dbus_message_iter_get_basic(&value, + &io_qos.phy); else goto fail; } else if (!strcasecmp(key, "SDU")) { @@ -556,7 +564,7 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, } if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) { - /* Mark CIG and CIS to be auto assigned */ + /* Mark BIG and BIS to be auto assigned */ ep->qos.bcast.big = BT_ISO_QOS_BIG_UNSET; ep->qos.bcast.bis = BT_ISO_QOS_BIS_UNSET; } else { @@ -577,8 +585,12 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, ep->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, ep->rpac, &ep->qos, ep->caps); - ep->id = bt_bap_stream_config(ep->stream, &ep->qos, ep->caps, - config_cb, ep); + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) + ep->id = bt_bap_stream_config(ep->stream, &ep->qos, NULL, + config_cb, ep); + else + ep->id = bt_bap_stream_config(ep->stream, &ep->qos, ep->caps, + config_cb, ep); if (!ep->id) { DBG("Unable to config stream"); free(ep->caps); @@ -597,13 +609,120 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, break; case BT_BAP_STREAM_TYPE_BCAST: /* No message sent over the air for broadcast */ - ep->id = 0; + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) + ep->msg = dbus_message_ref(msg); + else + ep->id = 0; + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } return NULL; } +static void update_bcast_qos(struct bt_iso_qos *qos, + struct bt_bap_qos *bap_qos) +{ + bap_qos->bcast.big = qos->bcast.big; + bap_qos->bcast.bis = qos->bcast.bis; + bap_qos->bcast.sync_interval = qos->bcast.sync_interval; + bap_qos->bcast.packing = qos->bcast.packing; + bap_qos->bcast.framing = qos->bcast.framing; + bap_qos->bcast.encryption = qos->bcast.encryption; + bap_qos->bcast.options = qos->bcast.options; + bap_qos->bcast.skip = qos->bcast.skip; + bap_qos->bcast.sync_timeout = qos->bcast.sync_timeout; + bap_qos->bcast.sync_cte_type = qos->bcast.sync_cte_type; + bap_qos->bcast.mse = qos->bcast.mse; + bap_qos->bcast.timeout = qos->bcast.timeout; + bap_qos->bcast.io_qos.interval = qos->bcast.in.interval; + bap_qos->bcast.io_qos.latency = qos->bcast.in.latency; + bap_qos->bcast.io_qos.phy = qos->bcast.in.phy; + bap_qos->bcast.io_qos.sdu = qos->bcast.in.sdu; + bap_qos->bcast.io_qos.rtn = qos->bcast.in.rtn; + + bap_qos->bcast.bcode = new0(struct iovec, 1); + util_iov_memcpy(bap_qos->bcast.bcode, qos->bcast.bcode, + sizeof(qos->bcast.bcode)); +} + +static bool match_ep_type(const void *data, const void *user_data) +{ + const struct bap_ep *ep = data; + + return (bt_bap_pac_get_type(ep->lpac) == PTR_TO_INT(user_data)); +} + +static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) +{ + struct bap_data *data = user_data; + struct bt_iso_qos qos; + struct bt_iso_base base; + char address[18]; + struct bap_ep *ep; + int fd; + struct iovec *base_io; + + bt_io_get(io, &err, + BT_IO_OPT_DEST, address, + BT_IO_OPT_QOS, &qos, + BT_IO_OPT_BASE, &base, + BT_IO_OPT_INVALID); + if (err) { + error("%s", err->message); + g_error_free(err); + goto drop; + } + + g_io_channel_ref(io); + + DBG("BCAST ISO: sync with %s (BIG 0x%02x BIS 0x%02x)", + address, qos.bcast.big, qos.bcast.bis); + + ep = queue_find(data->bcast, match_ep_type, + INT_TO_PTR(BT_BAP_BCAST_SINK)); + if (!ep) { + DBG("ep not found"); + return; + } + + update_bcast_qos(&qos, &ep->qos); + + base_io = new0(struct iovec, 1); + util_iov_memcpy(base_io, base.base, base.base_len); + + if (ep->stream == NULL) + DBG("stream is null"); + ep->id = bt_bap_stream_config(ep->stream, &ep->qos, + base_io, NULL, NULL); + data->listen_io = io; + + bt_bap_stream_set_user_data(ep->stream, ep->path); + + fd = g_io_channel_unix_get_fd(io); + + if (bt_bap_stream_set_io(ep->stream, fd)) { + bt_bap_stream_enable(ep->stream, true, NULL, NULL, NULL); + g_io_channel_set_close_on_unref(io, FALSE); + return; + } + + + return; + +drop: + g_io_channel_shutdown(io, TRUE, NULL); + +} + +static bool match_data_bap_data(const void *data, const void *match_data) +{ + const struct bap_data *bdata = data; + const struct btd_adapter *adapter = match_data; + + return bdata->user_data == adapter; +} + static const GDBusMethodTable ep_methods[] = { { GDBUS_EXPERIMENTAL_ASYNC_METHOD("SetConfiguration", GDBUS_ARGS({ "endpoint", "o" }, @@ -650,14 +769,23 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, struct bt_bap_pac *rpac) { struct btd_adapter *adapter = data->user_data; + struct btd_device *device = data->device; struct bap_ep *ep; struct queue *queue; - int i, err; + int i, err = 0; const char *suffix; struct match_ep match = { lpac, rpac }; + if (!adapter) + DBG("adapter is null"); + + if (!device) + device = btd_adapter_find_device_by_path(adapter, + bt_bap_pac_get_name(rpac)); + switch (bt_bap_pac_get_type(rpac)) { case BT_BAP_BCAST_SOURCE: + case BT_BAP_BCAST_SINK: queue = data->bcast; i = queue_length(data->bcast); suffix = "bcast"; @@ -675,8 +803,24 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, ep->lpac = lpac; ep->rpac = rpac; - err = asprintf(&ep->path, "%s/pac_%s%d", adapter_get_path(adapter), - suffix, i); + if (device) + ep->data->device = device; + + switch (bt_bap_pac_get_type(rpac)) { + case BT_BAP_BCAST_SINK: + DBG("sink"); + err = asprintf(&ep->path, "%s/pac_%s%d", + adapter_get_path(adapter), suffix, i); + DBG("sink path %s", ep->path); + break; + case BT_BAP_BCAST_SOURCE: + DBG("source"); + err = asprintf(&ep->path, "%s/pac_%s%d", + device_get_path(device), suffix, i); + DBG("source path %s", ep->path); + break; + } + if (err < 0) { error("Could not allocate path for remote pac %s/pac%d", adapter_get_path(adapter), i); @@ -685,14 +829,13 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, } if (g_dbus_register_interface(btd_get_dbus_connection(), - ep->path, MEDIA_ENDPOINT_INTERFACE, - ep_methods, NULL, ep_properties, - ep, ep_free) == FALSE) { + ep->path, MEDIA_ENDPOINT_INTERFACE, + ep_methods, NULL, ep_properties, + ep, ep_free) == FALSE) { error("Could not register remote ep %s", ep->path); ep_free(ep); return NULL; } - bt_bap_pac_set_user_data(rpac, ep->path); DBG("ep %p lpac %p rpac %p path %s", ep, ep->lpac, ep->rpac, ep->path); @@ -824,6 +967,7 @@ done: queue_foreach(ep->data->srcs, bap_config, NULL); queue_foreach(ep->data->snks, bap_config, NULL); + queue_foreach(ep->data->bcast, bap_config, NULL); } static bool pac_found(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, @@ -1310,6 +1454,46 @@ static void bap_listen_io(struct bap_data *data, struct bt_bap_stream *stream, data->listen_io = io; } +static void bap_listen_io_broadcast(struct bap_data *data, struct bap_ep *ep, + struct bt_bap_stream *stream, struct bt_iso_qos *qos) +{ + GIOChannel *io; + GError *err = NULL; + struct sockaddr_iso_bc iso_bc_addr; + + iso_bc_addr.bc_bdaddr_type = btd_device_get_bdaddr_type(data->device); + memcpy(&iso_bc_addr.bc_bdaddr, device_get_address(data->device), + sizeof(bdaddr_t)); + iso_bc_addr.bc_bis[0] = 1; + iso_bc_addr.bc_num_bis = 1; + + DBG("stream %p", stream); + + /* If IO already set skip creating it again */ + if (bt_bap_stream_get_io(stream) || data->listen_io) + return; + + io = bt_io_listen(iso_bcast_confirm_cb, NULL, ep->data, NULL, &err, + BT_IO_OPT_SOURCE_BDADDR, + btd_adapter_get_address(ep->data->adapter), + BT_IO_OPT_DEST_BDADDR, + device_get_address(data->device), + BT_IO_OPT_DEST_TYPE, + btd_device_get_bdaddr_type(data->device), + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_QOS, &qos->bcast, + BT_IO_OPT_ISO_BC_NUM_BIS, iso_bc_addr.bc_num_bis, + BT_IO_OPT_ISO_BC_BIS, iso_bc_addr.bc_bis, + BT_IO_OPT_INVALID); + if (!io) { + error("%s", err->message); + g_error_free(err); + } else + DBG("io created"); + + ep->data->listen_io = io; + +} static void bap_create_ucast_io(struct bap_data *data, struct bap_ep *ep, struct bt_bap_stream *stream, int defer) { @@ -1364,10 +1548,10 @@ static void bap_create_bcast_io(struct bap_data *data, struct bap_ep *ep, memcpy(&iso_qos.bcast.out, &ep->qos.bcast.io_qos, sizeof(struct bt_iso_io_qos)); done: - if (ep) + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) bap_connect_io_broadcast(data, ep, stream, &iso_qos); else - bap_listen_io(data, stream, &iso_qos); + bap_listen_io_broadcast(data, ep, stream, &iso_qos); } static void bap_create_io(struct bap_data *data, struct bap_ep *ep, @@ -1417,6 +1601,11 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, break; case BT_BAP_STREAM_STATE_CONFIG: if (ep && !ep->id) { + if + (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) { + bap_create_bcast_io(data, ep, stream, true); + return; + } bap_create_io(data, ep, stream, true); if (!ep->io) { error("Unable to create io"); @@ -1424,7 +1613,6 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, return; } - if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_UCAST) { /* Wait QoS response to respond */ @@ -1480,6 +1668,10 @@ static void pac_added_broadcast(struct bt_bap_pac *pac, void *user_data) bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SOURCE, pac_found_bcast, data); + } else if (bt_bap_pac_get_type(pac) == BT_BAP_BCAST_SINK) { + DBG("sink pac %p", pac); + bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SINK, + pac_found_bcast, data); } } @@ -1596,14 +1788,6 @@ static bool match_data(const void *data, const void *match_data) return bdata->bap == bap; } -static bool match_data_bap_data(const void *data, const void *match_data) -{ - const struct bap_data *bdata = data; - const struct btd_adapter *adapter = match_data; - - return bdata->user_data == adapter; -} - static bool io_get_qos(GIOChannel *io, struct bt_iso_qos *qos) { GError *err = NULL; @@ -1854,7 +2038,7 @@ static int bap_adapter_probe(struct btd_profile *p, bap_data_add(data); - if (!bt_bap_attach_broadcast(data->bap)) { + if (!bt_bap_attach_broadcast(data->bap, BT_BAP_BCAST_SOURCE)) { error("BAP unable to attach"); return -EINVAL; } @@ -1901,12 +2085,62 @@ static struct btd_profile bap_profile = { .experimental = true, }; +static GDBusProxy *media; + +static void proxy_added(GDBusProxy *proxy, void *user_data) +{ + const char *interface; + + interface = g_dbus_proxy_get_interface(proxy); + + if (!strcmp(interface, MEDIA_INTERFACE)) { + DBG("proxy added %s ", g_dbus_proxy_get_path(proxy)); + media = proxy; + } +} + +static int bcast_server_probe(struct btd_adapter *adapter) +{ + static GDBusClient *client; + + client = g_dbus_client_new(btd_get_dbus_connection(), + "org.bluez", "/org/bluez"); + + g_dbus_client_set_proxy_handlers(client, proxy_added, NULL, + NULL, NULL); + + return 0; +} + +static void bcast_server_remove(struct btd_adapter *adapter) +{ + DBG("path %s", adapter_get_path(adapter)); +} + +static void bcast_new_source(struct btd_adapter *adapter, + struct btd_device *device) +{ + struct bap_data *data = queue_find(sessions, match_data_bap_data, + adapter); + + bt_bap_new_bcast_source(data->bap, device_get_path(device), 0x06); +} + +static struct btd_adapter_driver bcast_driver = { + .name = "bcast", + .probe = bcast_server_probe, + .remove = bcast_server_remove, + .device_discovered = bcast_new_source, + .experimental = true, +}; + static unsigned int bap_id = 0; static int bap_init(void) { int err; + btd_register_adapter_driver(&bcast_driver); err = btd_profile_register(&bap_profile); if (err) return err; diff --git a/src/shared/bap.c b/src/shared/bap.c index 72ce67c08..ae3f64730 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -633,14 +633,18 @@ static struct bt_bap_endpoint *bap_endpoint_new(struct bt_bap_db *bdb, return ep; } -static struct bt_bap_endpoint *bap_endpoint_new_broacast(struct bt_bap_db *bdb) +static struct bt_bap_endpoint *bap_endpoint_new_broadcast(struct bt_bap_db *bdb, + uint8_t type) { struct bt_bap_endpoint *ep; ep = new0(struct bt_bap_endpoint, 1); ep->bdb = bdb; ep->attr = NULL; - ep->dir = BT_BAP_BCAST_SOURCE; + if (type == BT_BAP_BCAST_SINK) + ep->dir = BT_BAP_BCAST_SOURCE; + else + ep->dir = BT_BAP_BCAST_SINK; return ep; } @@ -667,22 +671,27 @@ static struct bt_bap_endpoint *bap_get_endpoint(struct queue *endpoints, return ep; } +static bool match_ep_type(const void *data, const void *match_data) +{ + const struct bt_bap_endpoint *ep = data; + const uint8_t type = PTR_TO_INT(match_data); + + return (ep->dir == type); +} + static struct bt_bap_endpoint *bap_get_endpoint_bcast(struct queue *endpoints, - struct bt_bap_db *db) + struct bt_bap_db *db, uint8_t type) { struct bt_bap_endpoint *ep; if (!db) return NULL; - /* - * We have support for only one stream so we will have - * only one endpoint. - * TO DO add support for more then one stream - */ - if (queue_length(endpoints) > 0) - return queue_peek_head(endpoints); - ep = bap_endpoint_new_broacast(db); + ep = queue_find(endpoints, match_ep_type, INT_TO_PTR(type)); + if (ep) + return ep; + + ep = bap_endpoint_new_broadcast(db, type); if (!ep) return NULL; @@ -1317,6 +1326,8 @@ static void stream_set_state_broadcast(struct bt_bap_stream *stream, struct bt_bap *bap = stream->bap; const struct queue_entry *entry; + if (ep->old_state == state) + return; ep->old_state = ep->state; ep->state = state; @@ -1348,6 +1359,9 @@ static void stream_set_state(struct bt_bap_stream *stream, uint8_t state) ep->old_state = ep->state; ep->state = state; + if (stream->lpac->type == BT_BAP_BCAST_SINK) + goto done; + if (stream->client) goto done; @@ -2379,6 +2393,10 @@ static struct bt_bap_pac *bap_pac_find(struct bt_bap_db *bdb, uint8_t type, return queue_find(bdb->sources, match_codec, codec); case BT_BAP_SINK: return queue_find(bdb->sinks, match_codec, codec); + case BT_BAP_BCAST_SOURCE: + return queue_find(bdb->broadcast_sources, match_codec, codec); + case BT_BAP_BCAST_SINK: + return queue_find(bdb->broadcast_sinks, match_codec, codec); } return NULL; @@ -2518,7 +2536,7 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, struct iovec *metadata) { struct bt_bap_db *bdb; - struct bt_bap_pac *pac, *pac_brodcast_sink; + struct bt_bap_pac *pac, *pac_broadcast_sink; struct bt_bap_codec codec; if (!db) @@ -2545,11 +2563,19 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, bap_add_source(pac); break; case BT_BAP_BCAST_SOURCE: - // For broadcast add local pac and remote pac bap_add_broadcast_source(pac); - pac_brodcast_sink = bap_pac_new(bdb, name, type, &codec, qos, + if (queue_isempty(bdb->broadcast_sinks)) { + /* When adding a local broadcast source, add also a + * local broadcast sink + */ + pac_broadcast_sink = bap_pac_new(bdb, name, + BT_BAP_BCAST_SINK, &codec, qos, data, metadata); - bap_add_broadcast_sink(pac_brodcast_sink); + bap_add_broadcast_sink(pac_broadcast_sink); + } + break; + case BT_BAP_BCAST_SINK: + bap_add_broadcast_sink(pac); break; default: bap_pac_free(pac); @@ -2579,6 +2605,14 @@ uint8_t bt_bap_pac_get_type(struct bt_bap_pac *pac) return pac->type; } +char *bt_bap_pac_get_name(struct bt_bap_pac *pac) +{ + if (!pac) + return NULL; + + return pac->name; +} + uint32_t bt_bap_pac_get_locations(struct bt_bap_pac *pac) { struct bt_pacs *pacs = pac->bdb->pacs; @@ -3996,7 +4030,7 @@ clone: return true; } -bool bt_bap_attach_broadcast(struct bt_bap *bap) +bool bt_bap_attach_broadcast(struct bt_bap *bap, uint8_t type) { struct bt_bap_endpoint *ep; @@ -4008,7 +4042,7 @@ bool bt_bap_attach_broadcast(struct bt_bap *bap) queue_push_tail(sessions, bap); - ep = bap_get_endpoint_bcast(bap->remote_eps, bap->ldb); + ep = bap_get_endpoint_bcast(bap->remote_eps, bap->ldb, type); if (ep) ep->bap = bap; @@ -4221,9 +4255,19 @@ void bt_bap_foreach_pac(struct bt_bap *bap, uint8_t type, return bap_foreach_pac(bap->ldb->sinks, bap->rdb->sources, func, user_data); case BT_BAP_BCAST_SOURCE: - return bap_foreach_pac(bap->ldb->broadcast_sources, + if (queue_isempty(bap->rdb->broadcast_sources) + && queue_isempty(bap->rdb->broadcast_sinks)) + return bap_foreach_pac(bap->ldb->broadcast_sources, bap->ldb->broadcast_sinks, func, user_data); + + return bap_foreach_pac(bap->ldb->broadcast_sinks, + bap->rdb->broadcast_sources, + func, user_data); + case BT_BAP_BCAST_SINK: + return bap_foreach_pac(bap->ldb->broadcast_sinks, + bap->rdb->broadcast_sources, + func, user_data); } } @@ -4382,6 +4426,11 @@ unsigned int bt_bap_stream_config(struct bt_bap_stream *stream, return req->id; case BT_BAP_STREAM_TYPE_BCAST: stream->qos = *qos; + if (stream->lpac->type == BT_BAP_BCAST_SINK) { + if (data) + stream_config(stream, data, NULL); + stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG); + } return 1; } @@ -4446,13 +4495,19 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, if (rpac) type = rpac->type; else if (lpac) { - switch(lpac->type) { + switch (lpac->type) { case BT_BAP_SINK: type = BT_BAP_SOURCE; break; case BT_BAP_SOURCE: type = BT_BAP_SINK; break; + case BT_BAP_BCAST_SOURCE: + type = BT_BAP_BCAST_SINK; + break; + case BT_BAP_BCAST_SINK: + type = BT_BAP_BCAST_SOURCE; + break; default: return NULL; } @@ -4913,6 +4968,18 @@ struct io *bt_bap_stream_get_io(struct bt_bap_stream *stream) return io->io; } +char *bt_bap_stream_get_remote_name(struct bt_bap_stream *stream) +{ + return bt_bap_pac_get_name(stream->rpac); +} + +bool bt_bap_match_bcast_sink_stream(const void *data, const void *user_data) +{ + const struct bt_bap_stream *stream = data; + + return stream->lpac->type == BT_BAP_BCAST_SINK; +} + static bool stream_io_disconnected(struct io *io, void *user_data) { struct bt_bap_stream *stream = user_data; @@ -4944,6 +5011,14 @@ static bool match_req_id(const void *data, const void *match_data) return (req->id == id); } +static bool match_name(const void *data, const void *match_data) +{ + const struct bt_bap_pac *pac = data; + const char *name = match_data; + + return (!strcmp(pac->name, name)); +} + int bt_bap_stream_cancel(struct bt_bap_stream *stream, unsigned int id) { struct bt_bap_req *req; @@ -5132,3 +5207,43 @@ bool bt_bap_stream_io_is_connecting(struct bt_bap_stream *stream, int *fd) return io->connecting; } + +bool bt_bap_new_bcast_source(struct bt_bap *bap, const char *name, + uint8_t codec) +{ + struct bt_bap_endpoint *ep; + struct bt_bap_pac *pac_broadcast_source, *local_sink; + struct bt_bap_codec bap_codec; + + bap_codec.id = codec; + bap_codec.cid = 0; + bap_codec.vid = 0; + + /* Add remote source endpoint */ + if (!bap->rdb->broadcast_sources) + bap->rdb->broadcast_sources = queue_new(); + + if (queue_find(bap->rdb->broadcast_sources, match_name, name)) { + DBG(bap, "broadcast source already registered"); + return true; + } + + local_sink = queue_peek_head(bap->ldb->broadcast_sinks); + pac_broadcast_source = bap_pac_new(bap->rdb, name, BT_BAP_BCAST_SOURCE, + &bap_codec, NULL, local_sink->data, NULL); + queue_push_tail(bap->rdb->broadcast_sources, pac_broadcast_source); + + if (!pac_broadcast_source) { + DBG(bap, "No broadcast source could be created"); + return false; + } + queue_foreach(bap->pac_cbs, notify_pac_added, pac_broadcast_source); + + /* Push remote endpoint with direction sink */ + ep = bap_endpoint_new_broadcast(bap->rdb, BT_BAP_BCAST_SINK); + + if (ep) + queue_push_tail(bap->remote_eps, ep); + + return true; +} diff --git a/src/shared/bap.h b/src/shared/bap.h index 50b567663..cf98ec8b7 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -163,6 +163,8 @@ bool bt_bap_remove_pac(struct bt_bap_pac *pac); uint8_t bt_bap_pac_get_type(struct bt_bap_pac *pac); +char *bt_bap_pac_get_name(struct bt_bap_pac *pac); + uint32_t bt_bap_pac_get_locations(struct bt_bap_pac *pac); uint8_t bt_bap_stream_get_type(struct bt_bap_stream *stream); @@ -186,7 +188,7 @@ struct bt_bap *bt_bap_ref(struct bt_bap *bap); void bt_bap_unref(struct bt_bap *bap); bool bt_bap_attach(struct bt_bap *bap, struct bt_gatt_client *client); -bool bt_bap_attach_broadcast(struct bt_bap *bap); +bool bt_bap_attach_broadcast(struct bt_bap *bap, uint8_t type); void bt_bap_detach(struct bt_bap *bap); bool bt_bap_set_debug(struct bt_bap *bap, bt_bap_debug_func_t cb, @@ -289,7 +291,7 @@ struct bt_bap_qos *bt_bap_stream_get_qos(struct bt_bap_stream *stream); struct iovec *bt_bap_stream_get_metadata(struct bt_bap_stream *stream); struct io *bt_bap_stream_get_io(struct bt_bap_stream *stream); - +bool bt_bap_match_bcast_sink_stream(const void *data, const void *user_data); bool bt_bap_stream_set_io(struct bt_bap_stream *stream, int fd); int bt_bap_stream_cancel(struct bt_bap_stream *stream, unsigned int id); @@ -305,3 +307,8 @@ uint8_t bt_bap_stream_io_dir(struct bt_bap_stream *stream); int bt_bap_stream_io_connecting(struct bt_bap_stream *stream, int fd); bool bt_bap_stream_io_is_connecting(struct bt_bap_stream *stream, int *fd); + +bool bt_bap_new_bcast_source(struct bt_bap *bap, const char *name, + uint8_t codec); + +char *bt_bap_stream_get_remote_name(struct bt_bap_stream *stream); From patchwork Wed Aug 2 08:41: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: 13337853 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 9E7D7C001DE for ; Wed, 2 Aug 2023 08:42:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233610AbjHBIm2 (ORCPT ); Wed, 2 Aug 2023 04:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233873AbjHBIm1 (ORCPT ); Wed, 2 Aug 2023 04:42:27 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2051.outbound.protection.outlook.com [40.107.20.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87F682121 for ; Wed, 2 Aug 2023 01:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ML12gTEXMzonxiBtHJOsiMvcjlCjpUG2K45jIWMzRHgkjvtGnTxxllomx7dRj6qLqE6mQPgrso0qIapz02QGZZbp9vLoGD8kQP6ScKIUou+M/YtPTvmirh2T1TOYSys0bvc/6I/8WrChDEDgb7nZtPJlmobTIAt0/NdkRemYxkm6aHCKBf72ifkgeI7gU6t/JsT99IY3ME5Wavgf54091PIh1LNoEeAnt+yhw+c541pN6xGb+y4kYb7Up6q+wiUFuz2xhB1fFa0BfkY4xea8JrehY1ROT2RiPHMzPV/AzW3oZYNH1KfylG7ggU7qx4JGN/eAonq8/AUk8ujei+YeGg== 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=5OqfCzjm1oA7lEogXlD/Y2Pi7RYif+KEFmg09y5U7KI=; b=TNw8KYiuC6IRmIiVAeSdz9ovWWNMk/s3cpCi/PFyCuKTfoBd2VVAE4HAMOR0pu/Mqts6fxQUifL0F+ahjUGG2L5sL9Ueu1w7UHpX0n+dX1vrYItlp+9p7ebNGi+WdY1elfyu14pXqH5qmoAwi7MRBEaa5GyMpQpd5ontKVs/XTMoyUu6jrqpkYdaBTEbUT7aBJ4DXSGDsMp9r+OoYCle4XJtxVDD76MIgSm2jJpAPOCoEQcjz9VmBICsEqeV/6Pc8yawydvQExCft8BN+G6GpW9i4o8wfbcgVxgcLmCLklHIV5se1MJrm8yO6Ybwnu07Ffwe9JRPWIoDXihJ5s5eng== 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=5OqfCzjm1oA7lEogXlD/Y2Pi7RYif+KEFmg09y5U7KI=; b=qO7cQ/VcgnSZ+EAblfFX2hhMl/dELIeKDd40wW8x9+3F+HSDuAKiqPzIlXAxcnlrDCpW931u/lzmZkB39RLxbHXhuoxACS1H22spHU+WM/kP68Tbxv2Ygr8aoyy4a/v0J75bUt3AIH+LFfNTypKuJCB1D3wibKDBm9c6RfQuFnk= 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 DB8PR04MB7162.eurprd04.prod.outlook.com (2603:10a6:10:12c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 08:42: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.6631.045; Wed, 2 Aug 2023 08:42: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 v3 6/6] adapter: Trigger adapter driver when a broadcast source is discovered Date: Wed, 2 Aug 2023 11:41:40 +0300 Message-Id: <20230802084140.51105-7-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802084140.51105-1-claudia.rosu@nxp.com> References: <20230802084140.51105-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR07CA0003.eurprd07.prod.outlook.com (2603:10a6:208:ac::16) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|DB8PR04MB7162:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f062a7d-e262-4c80-38a6-08db93345cf3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0zeqnDjXcKYRIr0qj1r0gAcK0t0gxLZDwEbUvlXKquqojESBK/d4TvkqxHZxNMQN5PVNSaew3Ho13e8T8im2c1kZZWypigRbmQOKhG/GgKPAuhJrXgz8XsrLzX2t7aqrF+mhe1/1jU71rBFbACYsZ4ifW8BLukMlvR/h0jiSQWtHuUeyxhhfcf7bzCS5OBVFV3b6h+6w6yfp9FvzgD3k+ek1eZ3qCBNeCJK+xqZaSmSCtqegxPcBmYxtpR4Skpn+j0PRFv/OwonZVgyM7iP8PaNTJkJ2s4KBfpKrPHpalK+MGenn9vsMsdcnekAmYqIxNsa3MfIJxD9/Fidtx/8UXEAeqazJDpajFpqCme+n6+/EvUmDTeIzBW63cTtSshuMc0sSGhaA2MdA2cwAgyz194QxN36I1ms4JrQzNdAKDlIfqqfwpyeJg6vikfPKiBS+Ez1B1vozT4wo3ci0TeJUT6FnKu+G4pEbfbF5QTGIJuT4o21rR3eBVwcYXiaZdFNHxXGDT1q6EfAJ5fOkCqTTAMe2nv4mFXs6x84oyJjL+d+dAq61ORzF6XwP5Am5Ne2vNPHrqFwfefWV5Uav3WwYzk60ix8YhuGlgILeDWoFbUWB18wIUwGjUTUx2JgPSS9a 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)(39860400002)(376002)(366004)(136003)(396003)(346002)(451199021)(2616005)(36756003)(6512007)(316002)(478600001)(86362001)(38350700002)(38100700002)(66946007)(66556008)(6666004)(66476007)(6486002)(52116002)(6916009)(4326008)(1076003)(6506007)(41300700001)(26005)(186003)(8676002)(8936002)(5660300002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3Y+6LTysr9HLDOsr38dFx5zWuzY2tLlW2BDnjCLfMkuNW4AnrfFpPXpHPbJxgLf6NjcF4IN/eQ9XwmZ2InV3bAlpCdjjgTYZLTW3GoUn0Zp/+Rtfhm308YXOm9rbers03Bcfa/IZDm+ivkGrcLdwDUYMA8U9Bvp9VhQn/0hduJ338stk5Vx03loos3eoAgSvzsvGK7uc0zYh8fAg2HEZYy8hqNfvsYLOfVKnYhCJhc16gklrZlvD3wuPUiTEbXe+uGFtJtHFh8jUmT84HuIhuPi8MDOL7XnIlPNx5GDOcJhwkE56WMT9mkf4TmtHZy3+BAcmdI3qC5tP/4Jb+eAjDHyMaLcJfT7r3LbGuPb0WkDO7z71C+ptGIn2tMFiaWdw8PevvnVng3eX5KllqCNw2t4ibPzVCXhcb/cLuF35mrS+weNx9Eq5+VcS4DtQGHxdejYjTn3QdoJEcl4GD7vW9EykIeaJilj3Tl8kfFS5cVJKzqBScTTlWbIHjwIGN4kIVhJWwvE05hbWzpSkQobIuy8fZubkVb8ZbJyzyG1fFVEhsVVGPiCncy+DMEgHvnEDFQiFGT6x2Ti7kS2r0utVnvnysG2rL313nb13MDMw9arCNeUJLE8s8YQHe3a0sy829GlsaOx832lKNBLQNF/oh2ruTKSy3mK5ebb4zFrBUyzSCakcQWV0G0vhjq6u5Hwf3T62l8UhTb3wq2Gfgc5saaGcTwoko73VR7td1DBtyyxxR/8+y8tOPuotsFXazsNoqA/vCy+ERSUWIYeH2ugGB1SqSJz5TcKl1q2S5G7/sw2lgc4QUikQ1becplDgq/r4dneMoPRCQhWBO0GZvpqwVnaFXJKoZTgodUeCncFSfp0KC3yY0pInP4yb9v+l1HnwTNrztbtNX42+h3EitsjtOkwwMrTOF2Zwn7mX08AthW3joU3qOB2R4UTN/DGIWLQMpUdktl1G3lmIczFkwjJzsjzTCDc5fS9t1A3oFMSl60/WT5IGmfThyOgJtlUDhDM1jN/Krf87nfMjdKpUa5LiwOZGJJtKBhLikVY4hExo8Kbwd5zciC/nf0sH870M3TfZBhVjAGa7F5lLiO3VVCcO5obwRB5WWeV8FVIQXtTyR3q3VvjFJqUZFJW2dD5LRvhVEit8yKSOLHVoHz33GCbJIMCzsrYU2O/EEzinbJuwstAO/yFKdIk3+7w6mzl9r7hM6jQ4Tmhnad2Gb+ocyaQcdSrvw7bf/9q4tkirppkoZAwdpe/SVKuRRkhWq+g2X5dp8p4dzPAgw2zRBqEq1CdtvTBwo4xCPZYNVQ7mLaslyUHEsQ7bVSvamBn754CB3Xv79U8eNPYZ0tyttEgYJHok1d0HSImrTJxtGlGbnXikyj6DUp10wazUS3nBdJAjDIAwDGo9QfUm3onl3+CVV47yYpDKjkJYRvv6jq6Koe4QFyavMT1ohoJXZ2wsrFwTq5R90I8mJ0mwKO8spspn/JkhKPYUVowjyyGIiuU1d3YoeVWlP9sOt5FhQAZCtdCVWwQcjUWPTSjp6EvRSvoSsMue5dl1kCUz163ljFeAyPXcuC92Bzy0PqTv/dtFbgpPDPD5 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f062a7d-e262-4c80-38a6-08db93345cf3 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 08:42:11.4327 (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: rkygVqZCj9xMyUYU/H3pXUO9Txr+YGZvXQ2X2mlrLP907g50aAjY/I3H7XPBXOr3fEOpn75Q9uRQc1MfuZ1LXg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7162 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds a new method in the adapter driver, device_resolved() called when a broadcast source that advertises the BCAA_UUID is discovered. --- src/adapter.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/adapter.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 491bd7031..29c6a576a 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -7029,6 +7029,45 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data, return got_match; } +static int find_baas(gconstpointer a, gconstpointer b) +{ + const struct eir_sd *sd = a; + const char *baas_uuid = b; + + return strcmp(sd->uuid, baas_uuid); +} + +static bool accept_bcast_adv(struct btd_adapter *adapter) +{ + if ((btd_adapter_has_settings(adapter, MGMT_SETTING_ISO_SYNC_RECEIVER))) + return true; + + return false; +} + +static bool is_bcast_source(struct eir_data *eir_data) +{ + if (!(eir_data->flags & (EIR_LIM_DISC | EIR_GEN_DISC)) + && (g_slist_find_custom(eir_data->sd_list, + BCAA_SERVICE_UUID, find_baas))) { + return true; + } + + return false; +} +static void bcast_new_source(struct btd_adapter *adapter, + struct btd_device *device) +{ + GSList *l; + + for (l = adapter->drivers; l; l = g_slist_next(l)) { + struct btd_adapter_driver *driver = l->data; + + if (!strcmp(driver->name, "bcast")) + driver->device_discovered(adapter, device); + } +} + static void filter_duplicate_data(void *data, void *user_data) { struct discovery_client *client = data; @@ -7152,12 +7191,21 @@ void btd_adapter_device_found(struct btd_adapter *adapter, return; } + if (accept_bcast_adv(adapter) && is_bcast_source(&eir_data)) + monitoring = true; + if (!discoverable && !monitoring && !eir_data.rsi) { eir_data_free(&eir_data); return; } dev = adapter_create_device(adapter, bdaddr, bdaddr_type); + + if (dev && is_bcast_source(&eir_data)) { + bcast_new_source(adapter, dev); + btd_device_set_temporary(dev, false); + } + } if (!dev) { diff --git a/src/adapter.h b/src/adapter.h index ca96c1f65..ee32f7110 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -125,6 +125,8 @@ struct btd_adapter_driver { struct btd_device *device); void (*device_resolved)(struct btd_adapter *adapter, struct btd_device *device); + void (*device_discovered)(struct btd_adapter *adapter, + struct btd_device *device); /* Indicates the driver is experimental and shall only be registered * when experimental has been enabled (see: main.conf:Experimental).