From patchwork Fri Apr 19 18:07:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 13636706 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2044.outbound.protection.outlook.com [40.107.8.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92AC413A871 for ; Fri, 19 Apr 2024 18:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713550087; cv=fail; b=BLqIsvtcv/nyFQEV8K+CWWiA5M16c5ep+Kop9GOKPcHVCwBZ5dOmIBRb/tropIq4uBHDPjLFo81P8BBPNeFu3Ykiet4USljCsrfDLp2EU86MJhHV4GoGFwWhDe4FCirQASGOpleKBCNpUGpbVC8JTTPpYUVtYSVXRuwhMqSJqOI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713550087; c=relaxed/simple; bh=MafsYK6ls0hz0gTSs0VWUg0K1SxAjbCQIcFc7AL1u+s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ROHXyzk4W9sCSgjeAwyzH4cMCTk5c7nidsK9H05SIha/hDsYymYa3MEv5nw9Z3SOOELIWELTFWElwZVvFEYGdxjUwq+sRLxcpnfQKJNPVKAvO71qbG6PVVkQ951YpxEDUyliNPjJ/7cYeknitqF2BY1i6UXi7YCFkmkBESKT/mg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=DobPPSyB; arc=fail smtp.client-ip=40.107.8.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="DobPPSyB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oe9LtGAzsqOVmslkXqV/irDhcXc6C7lKZaQP6R0bTk139yAlVuBJZb93//k8Va6FA/PhddgAZddKIZhQdIdhiBTWPnq4qCFZNMuBGkWj39lQpXKw0EpL+KgA3diElpKb+5aTOuXGKXVJ6jb/RY0VL85NddTEYxk0/9SvT5mhNDsWeD3htoyMu3GHZ1jNz8fSJDfRpgSlmS5gpk2zLwHB0g97OhjrZA/BgyBp51SuuR5LaisM+rHmfKjvZ/ZGy7nuBs5tw3AvwJy92aAk5TXyuKlUuSr8fvmzECcqVCZKPCHZTjIDybIF3hkwMfBt7iCtMhxDTz7taE6Ugz66Ymp49w== 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=Hy2A4NSuCLkPBDBldkkhYHsBtbphNfKet7P8yGw2z5I=; b=IfhH/G0V26LHJ4ckEbmrt7iT14wBVJZAwscg2PrqF/MKH4aZSP6/+B9nnWh2n+aSB8xCixvdDhqKxSyRc45VyRYSCODbWRJfAOX1MXI2iIDTxmK8DNtPW1pCHzjuzofc0SekU+XdqdL6HlUAycUrJNX2hQK+5rFmPN/GREeU4cC45ZEeupxaiIuY/IKutYrv4xAmSt3E3HEiLuetOSGlISAyelCj188LKENdQNwqQII78fHtQbKMaKL1Ert9Z/64ctYduyjfSqSx2AT9FUKJmQ2rPHowgUhNKI3mNiwgcMvpGAdkjujJGxF243GF+eKtQcrJNDyjMM64u706U2ki8w== 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=Hy2A4NSuCLkPBDBldkkhYHsBtbphNfKet7P8yGw2z5I=; b=DobPPSyB+KtVLyZdO0LudYwU2USSJeXJqHflWGAHzVv4o7SSjOEZfWSigcpuLiGck/bqtyL9v8r/xfuaqQSS47v2LdIJnv/Xz/+coeL5bHrANOvA6tXYfbILdLuHW7qsXXBmdjWwqSdSXhZ0ctBEiq0MWNfzY4JpyUO1xqXxsBg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by DBAPR04MB7381.eurprd04.prod.outlook.com (2603:10a6:10:1a2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.43; Fri, 19 Apr 2024 18:08:01 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::fa84:407b:3889:82a2]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::fa84:407b:3889:82a2%5]) with mapi id 15.20.7472.042; Fri, 19 Apr 2024 18:08:01 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ 1/5] shared/bap: Allow NULL bap endpoint in streams Date: Fri, 19 Apr 2024 21:07:48 +0300 Message-Id: <20240419180752.96699-2-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240419180752.96699-1-andrei.istodorescu@nxp.com> References: <20240419180752.96699-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AM4PR0302CA0022.eurprd03.prod.outlook.com (2603:10a6:205:2::35) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|DBAPR04MB7381:EE_ X-MS-Office365-Filtering-Correlation-Id: 6403d382-6521-48f9-6007-08dc609ba697 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8L/m3bS2R7oSjHXiJ2s33h4V4bVquMl3uEQqYmGFmwdyYoPTDtTbI3k+J4DQtTsuMtrV9K6um6rH7i79LxFmrD52QA6QGAmcpxvAkzG7YPL7WOKaIySLD7RGW9MPuAnRJQIWO5vD1gQLxtNma6VkGyfK5ufRCVlGpCDTUUl2CiD1In+EdznGkZ9CxSakGEamiu6usNKCd8ZdS7zBeXKgcXk2h2dJoMEWvyWbWaVNmg5PWCTMKilardR9Nnv+wFlg4aQxgVZDAChSYQCZJ1xblzgsN8GgsHYc0zrSRJgNhHZswCTuZxmPwa6Rvk2Ke32bHkRRPf0mGbYx9oqDWvTl3RGVZXJq3/TgNEJUlvJmBV/ReCgxK2tPTi61PtDAz4WXb/gHGJOG86DuJLh/KZ6sj5MFvPfWfAPosTPjFYpOF0K5Td5qtprUjqCcn2PSF3uZF+PyIE5T/iL0l56G8USDZ2RwbdKZGrT0+zxCMM5DcyXX2Ezz+HI+zLnsQr9lljMHdmfXSCMbIPP7vf199ySjEpzBRAh9FDxiOU/wNgAu/UipNQyhW6ho2aO5scEUzOXR0q/1L7T/n6E/DhrNO8UivHqLGSnHag4I6E5CKEIEzKhsd9JI3zSdPaVQ6klBLxylGw0Y85eaGY0ZOuEuPDGjUxfnemjwG+1IygczR0EI/XI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8938.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iBQMvasjYFd7ggb2JoaoxikZuOdFpeZK4AEl9R95iQbhI3qXoxfbDPQO00hnGBTHtgW+aQsDDWrF9rT1Lr7tG6L1xG3YbdQsqKTGrovaTM51uK7WbrxKSnDW/EK0XDfKuGpMxE9EhK8Cup0D830/O0VncrfVoLrpl1qI+o925X4u+Kx1Q0qPNMBLrpUqNEyEpdi6sIasuG5668DFO7D+zlkrYl9rzle1SV/DG6CnjrKY3xkJQlFWwBwgCt+3NhTk8GQx8whhUNcwqVfDyL1wmjBO3ZvloEmI8YbPSlwW7vxDyQ0uzIsJu623JhXTxzQ6qcjWOiTjsFCkeqDtsdwa3few6lT8TyDixZvoDb7zmTD4T7znZgPL26MhjYy8l6+gAGOSm0raeGEyl/KXjLHBuT/NaFm4s4gGf3xGnwRQ+YwmJ3FGp4Ala6Yc63E6S5hpcLH5eVVQm5QVOjRZr/pN0HFFJh1BX7yCo9ompPrFk30UdhITX+/wuN50Q0lsSca4l8J3as9yO9sEuGeH3J2yprZyeQSqvFbzM+iMbqfed4a7w8PX4U/Ub60TLXk38B45vHpZMHrkHWq7KAGphKTYyoZ6ba28rY3Afj1Po049uVOPVc2PZQPiFsev3qk9dp7f9j4Fbp+Qy1zCkxZOcxlWCsRNKVWvfWoC1jK76twzC0/PTaNYXeQ8XN7CIAU7GnVZSuXgdMhzP2RJadwhsGMN4c4iGh4b4BNDbj7eqfamFqF2ynDrcd1J/F6SHxc57FBUaka3JeYJuLs8lpwJ8AFSmIdZmI1sB3yfZXR1hg/nAkMraIyTCQPm8aN/mmOuEVvtceVB0JvZI782tO10fUTXaFhsS1htjY0LoR99qHyCAMy/rYxHTLt4td2IIjMR08YW0oUBfLMHVTEGgGCzbr0zSe4z5+wl+Bta9cgywxX7oyk3cH8Es/KNlT2xW/KF4PAttQWLmoqEcMp1qp9gksezw9j/G/dag5bkNgpcwzzkf6UpZXLMeHV6QK+x4WklmxGEAibNtYLQVYDLYFZDWTlLWTKVgrR0I9XWwiMIRuZZjiPorWOshcLq5QrNX/41/aYVoYGmpImZj2sXWReMIX9pqKQ2QX9zGIcWoe2vi1qik0SI43vQ86U7RmjmmDq/ZA61dLgnClZIBxerLyBPxMU5EQmGFZQSYmR07IAtzUY+5UQ5DkeDN5N4WVZcw4s1BpHZgGokW57dOz+tbprjGdLw+bqpMuKsyNkQmxB7I04vuDf6B/B6JLiK/adXLOgopghdYMDk2lGbv1bCfTHB1m1vE6NY6RWyrK0Lx21afVPJ2Gj0mO8hfdylFYxK6VK8xODTKuyN7mr6Wq8Ur6KVc+BjdExn6rb9387PQCGjW+w2dkoAlv5GQ2EkYyqoarTJyaVMDVebwEE9scwBP0cFmciIgKuue1Im4DUZ3NaUgYOugUaOZht9LXf8vtkIXQjjxbtAa/u8UuqIDS/ZcLS8VW/7Ca+Y5Ch96gWztfz8mltUZLvMEm7jpEd7E6/yWhMgfi3uAM7LOrqw0BT3JPi9ZGwkKIAS2goiujpZxPWGJnDrH2tHviZ/CgvzykvjyFJON+sSyVxzhpZ9sp4I91t9b2Hv0g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6403d382-6521-48f9-6007-08dc609ba697 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 18:08:01.2921 (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: v1vmMaMyx5SOvMfimJiC/VMcmjCfYKKaAdpMagy8cNbMWpKLfVKVVXV+53cSgwn5syOkE0/CUMISH/uCO897+SAtg6qgIp63Fsdq3zSYoe4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7381 --- src/shared/bap.c | 54 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 71eadbdb68b1..6328ff35f3c3 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -2115,7 +2115,8 @@ static struct bt_bap_stream *bap_stream_new(struct bt_bap *bap, stream = new0(struct bt_bap_stream, 1); stream->bap = bap; stream->ep = ep; - ep->stream = stream; + if (ep != NULL) + ep->stream = stream; stream->lpac = lpac; stream->rpac = rpac; stream->cc = util_iov_dup(data, 1); @@ -2209,6 +2210,7 @@ static void bap_stream_set_io(void *data, void *user_data) struct bt_bap_stream *stream = data; int fd = PTR_TO_INT(user_data); bool ret; + uint8_t state; if (fd >= 0) ret = bap_stream_io_attach(stream, fd, false); @@ -2218,7 +2220,12 @@ static void bap_stream_set_io(void *data, void *user_data) if (!ret) return; - switch (stream->ep->state) { + if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) + state = stream->state; + else + state = stream->ep->state; + + switch (state) { case BT_BAP_STREAM_STATE_ENABLING: if (fd < 0) bt_bap_stream_disable(stream, false, NULL, NULL); @@ -5424,7 +5431,8 @@ uint8_t bt_bap_stream_get_state(struct bt_bap_stream *stream) if (!stream) return BT_BAP_STREAM_STATE_IDLE; - if (stream->lpac->type != BT_BAP_BCAST_SOURCE) + if (stream->lpac->type != BT_BAP_BCAST_SOURCE && + stream->lpac->type != BT_BAP_BCAST_SINK) return stream->ep->state; else return stream->state; @@ -5611,7 +5619,13 @@ uint8_t bt_bap_stream_get_dir(struct bt_bap_stream *stream) if (!stream) return 0x00; - return stream->ep->dir; + if (stream->ep) + return stream->ep->dir; + + if (bt_bap_pac_get_type(stream->lpac) == BT_BAP_BCAST_SINK) + return BT_BAP_BCAST_SOURCE; + else + return BT_BAP_BCAST_SINK; } uint32_t bt_bap_stream_get_location(struct bt_bap_stream *stream) @@ -5623,15 +5637,17 @@ uint32_t bt_bap_stream_get_location(struct bt_bap_stream *stream) pacs = stream->client ? stream->bap->rdb->pacs : stream->bap->ldb->pacs; - if (stream->ep->dir == BT_BAP_SOURCE) - return pacs->source_loc_value; - else if (stream->ep->dir == BT_BAP_SINK) - return pacs->sink_loc_value; - else - /* TO DO get the location values from metadata - * for brodcast source and sink - */ - return stream->bap->ldb->pacs->source_loc_value; + if (stream->ep) { + if (stream->ep->dir == BT_BAP_SOURCE) + return pacs->source_loc_value; + else if (stream->ep->dir == BT_BAP_SINK) + return pacs->sink_loc_value; + } + + /* TO DO get the location values from metadata + * for brodcast source and sink + */ + return stream->bap->ldb->pacs->source_loc_value; } struct iovec *bt_bap_stream_get_config(struct bt_bap_stream *stream) @@ -5841,7 +5857,17 @@ uint8_t bt_bap_stream_io_dir(struct bt_bap_stream *stream) if (!stream) return 0x00; - dir = stream->ep->dir; + if (stream->ep) + dir = stream->ep->dir; + else { + uint8_t pac_type = bt_bap_pac_get_type(stream->lpac); + + if (pac_type == BT_BAP_BCAST_SINK) + dir = BT_BAP_BCAST_SOURCE; + else + dir = BT_BAP_BCAST_SINK; + + } if (stream->link) dir |= stream->link->ep->dir; From patchwork Fri Apr 19 18:07:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 13636708 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2044.outbound.protection.outlook.com [40.107.8.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D33D713B5A1 for ; Fri, 19 Apr 2024 18:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713550089; cv=fail; b=b8G7Eh7VW3i9+WGTMxC1O0Y5D/SCMA6RyJxlAaLbBRlgKPSpmBDsULalG6LOOA0xIrMWOfq65gmvwi5dJh+FEpnH59I+ZvViyQH0pB3EKJM7RTrUiCb3txh5IC06VYts+LKK8WXbgQfS5BwjtzWSGb8MgLGixQ3ip5p4zlt2Hzc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713550089; c=relaxed/simple; bh=jkbwJi2SQc17Rw1eLoH2X08k9wXWrLtYgXmVtB7UnHQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=D67MT1fh47/fV+eQoPeBe572YXRKMap9Tkle2v3wJjr/4DfTFXxeODd6PCFCz8fronDIzvwC9jRdoV/MevtJGomEwFYMYqaEc3VHTIK24FoweMJH25zaLNjvASkklYVzbQrq8IFEQr1hFaERuez9gciJ4RiDTjbfhyq74IdsGBk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=DpHJH63V; arc=fail smtp.client-ip=40.107.8.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="DpHJH63V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UoYsb55ZlzpqEXO92ORqwyVyG+BP2ZhL2FdGSzMy/TZiRfSz9UIQc/9V4Rpv1iPtNWc6K/Z7cXBZd6X5XegSMWr4RbbBGJZGKQxfXK7oLE446IZNZlOeU6P5bfQNEDUQjOtIB+eqY6h2uTQaI6xzZ/HAdaTIc0kv0tsEGA8WzTfKI2ud+E/lbqXtpcYPH0hJrbHqviXyu1+9QAxS/giIBN2D038SJRAz1p4CNoX6vqkcwUnOTBzR4UxIPSRDQj67wa483VARbUjB5D10FKPC4VVhYohOWGWxKf1vx6HxqWnKsIeFCjTS74npR+hqNYW+v/2wJsVfZAOaVIOY4KOxlg== 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=n9dRVVUaxw0rUVqyqZIPgVHskNDy5ki8Bj4YJ0bSl3g=; b=UNm77vgGPg0vpukQJi51nFMqf25s4p7TfAifNpzMmRULN2FQhfN+bxVX0T9ooN/rhD/dw5yoxSmJHJ44QRJLx3lLI1DxPt96zF5kYVSaXTqwXRJ0SwTJtMveoNgjRYwFNEi+Acwa5TJMom1kqb7+ZUPP2HyskcToS+k5wVBT/cFIZZ03WybWqVQ0GazcEcZ/VrJ62Pi5rjL/3MQ6jbhDh0uPNwfBzKWSHvM7ICtnPnct/G9S4jF6Xhic8+XoqHYJhSlYsX2oYQ4ormpOt06EwZzSqbDRtw3yxJ0W2AuzTyG9gqotQb12l31GnMYBJe61rYeEgUl4x/Ew0Rlh7hUk6Q== 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=n9dRVVUaxw0rUVqyqZIPgVHskNDy5ki8Bj4YJ0bSl3g=; b=DpHJH63VCOfLotgInxway2p0/8YItqjCgVrEsWcMsBaryXz9I7Q5ewjePV6ZtKeszT5TqoVAAomgOomnPyDqtLreLbr5niZspnuEwAK4hI0FC2RAdaZtmSUWSzNBrvx8ewYMjP2ObCJPUkY5AC94J3cbya/x9aQgBEXv7/8YJrs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by DBAPR04MB7381.eurprd04.prod.outlook.com (2603:10a6:10:1a2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.43; Fri, 19 Apr 2024 18:08:03 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::fa84:407b:3889:82a2]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::fa84:407b:3889:82a2%5]) with mapi id 15.20.7472.042; Fri, 19 Apr 2024 18:08:03 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ 2/5] shared/bap: Get broadcast channel location from stream capabilities Date: Fri, 19 Apr 2024 21:07:49 +0300 Message-Id: <20240419180752.96699-3-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240419180752.96699-1-andrei.istodorescu@nxp.com> References: <20240419180752.96699-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AM4PR0302CA0019.eurprd03.prod.outlook.com (2603:10a6:205:2::32) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|DBAPR04MB7381:EE_ X-MS-Office365-Filtering-Correlation-Id: 7aa0f8ca-5128-446d-c713-08dc609ba7af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QDA36O5RdJO+g9H/8l9i/UwlkRIZGJyZ8kTNFWWNd+mHSxhjBlOk35AkabxZl03KEwPfsQ822yqNvtcIWu9O+aBWmN3hcVVL8V9R7H4UbWo3aXiuuelq9wUXk6UmCrDWvbz23op3ZVmilxMaz0QNzknS1Ixc/K4svxlgPXsSNVHjG0Jcx33Ps2NjOyh0gMpr6NqMXGWF2/KFZxOwLI5QCQoTyu2tNVG6tH64erd18cjFmhmeGP5s4c6uajzydw+MgKuvCDLlbQp07S4Jgg/dXYYUSpHmEIpOCLbqf8pYJa+rIUDnL0HRs1vYecBekTcEXsJlDSrG4f039uVJwYFDXQzP+R/ctDylVYNUsL6MyX9ToqJkADCKHumjwVwTJqiYUG3DMY88HKsleJly2A9+4JIdsDAjvbKDbcWgtvmLL1d/oKH5GMvYYL65xy4jJ9WfNPkzlrq555oio+CZUA05yjEwjScTYhWcOk/SQpmbBBTLq+PWKRGTPw96AzzxX+ApWDDryNkvYaGvSt6tyWoYr2xzDeKSu8YZ40YDajgOdro6BQNu+4ysDdBXH25AzmAPpvGPGj1KG/ojBQNUn2ED7Y4BS0IkvFUQNXa4lJKZG//Mq0beVBVkzUt+sOYDLpEtuXDyWZ2c/oR4/7WINv1ylCW/hBix9xyqtUwhXczKoeg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8938.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8z2IOJkrVTfs7vsmokUOObkM5FPLsNCCw5jnwsHmKC3IGe9ClfjHfLvjN33UsKFReCIEXSF2IOQawaPGEoxL2AGqNfEVYyXROnwlckd2hL9Qmb8WsOqd4MkI8+r5Akh2aUWz3d/2BUI/TNuYc/vMdeX37jCuwXzMKHPKu91h7E0KVLbrFYzracu1oy0/91Otmq9WM249LlJgXY//r9NCFHswAM4RcSqkcWCLqiNaoTcNVOeGWAI63eUgdhnrq8xBZXGFBoi+sT2LckZKoBT86GYhMrBd0UPow++4BRa6L84KLLwGg2ILWZpO1d7Qq7cRaLCpo3ufiyeskAbNsfEWFNhraI/dA8E+qPd0YfPierCkgmTLw5WgzmWAfmItddqhOkntQFLGOQ8ubgtu/ZYPP4QQXEZ8+E8mFuTc3qZbpsu6VsiD9CUYHtQJMOIDXRkFdYjJ+h5IW5QVyO3og6pXpJeG2TL8oKjbYJH2TUtZDWTgaGETrokeFucJrgFQjOI4PbVjvDNmDfx8M1Tvsj83re3qVO1lNokSNOsCotqhKcbBhbLbdjvXPkDSX3cvN34h0VsJ3NYgpD7Z7KecsZyC3S3sMTQdOXJLf+fR/MRX47fuW3dxKB5Z6PQ+KHzLHWVYf2mOiAo3ibQbCyCYyzgTNQF+r6nHY+NuEAudr1Z1ajYXHX4bf/NNj4f6u0ehqDbctqsnmF5GWdq/ZD/n1apn3NyMsTf31KFwOL2h79Tdy21ST0fAt1N2TOC1ajFwfqJvm5K8ESm/q5RRE0t3SYlIYgca4c7uXfAGTmsbTMl74PxfsbTEKdmsTg7BR11SbdY4v4OFvWuuFJ+XtUx+13+jjHu5R8yDph6gNOtNCFW+TvSzrkLc79vYHpaPQa4HX57SWuR9kqu/V9P2dhcZA69AsfvoACqP7Ir+jj2/3oT1AyOUIC6diuaNjkElgX85PG+4dhj9peLqFyV1isKG3Jv41ZymvGMafvgNHYHbOZC/LtOp9hIFTYJ+gfFA+0+z47mQbM3hXvfutTA7xa2y4A89Bmqdb+VZ0PL2bQJVige1vWDWnquecppBFjXrn9qjknzzxt1VLAWF2+Ln/dZjXHC8fCjYDStkFxxqOv+Gl9hXqbQyvbN1qyJ/o6t35DiRd5oeGcfoSyX2ty6u04SXdOXMuH0Geo2fASJm1sS353fhXXyQr8sHa8gWGpRAplILwY6vklVrC6k8a4bTBC7/flv/FqdKfOoKCICcAvXp+ZyPYbZkzxk7zdM4XMkSEzBC350gc3sool4m3gogVbxBVqYswYE+73YuNFcGxk/9zo2RoGgKa6tjbgs/YRN+qUb21OfXOXXPqlEE8l3keifs2EKAtaIhQPICk+VbdIekiM6XOebbrXzDhtuWl0mu16brpKvVbe7+dhCZ4jPiS/tCtbCuU3Wy7FvPU3UpgqAQ4vBkBM7mWhoEMKhTxX/q9fo+xNm0o01KxaSMsu6pd+jM2k4claXraCYCmwRycgI7RqCP3y1tKKP52DyKuFkbGs7mzZOaB/Ygm0CbuCBZkIXzfazD9U67+XR2WfzPPPMveX5xPvqiNWFZW7NPgbQON4XjrBL3ruefM7QOFnviCqnGGwyaGg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7aa0f8ca-5128-446d-c713-08dc609ba7af X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 18:08:03.0482 (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: OoLPd8xUJ3bM5twWhxKIrxzU334oxHXMI4i07qGmW8HugTl1dveBYSg1bUC86k4MPM1KVUsYbvsXpbo+ubrqw/ie/mbTAo8q5gUIN9BR7IU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7381 Get the channel location from the stream's configured capabilities, rather than from the local PACS database capabilities. --- src/shared/bap.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 6328ff35f3c3..36f0b0a3b50a 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -5628,9 +5628,24 @@ uint8_t bt_bap_stream_get_dir(struct bt_bap_stream *stream) return BT_BAP_BCAST_SINK; } +static void bap_sink_get_allocation(size_t i, uint8_t l, uint8_t t, + uint8_t *v, void *user_data) +{ + uint32_t location32; + + if (!v) + return; + + memcpy(&location32, v, l); + *((uint32_t *)user_data) = le32_to_cpu(location32); +} + uint32_t bt_bap_stream_get_location(struct bt_bap_stream *stream) { struct bt_pacs *pacs; + uint8_t type = BAP_CHANNEL_ALLOCATION_LTV_TYPE; + uint32_t allocation = 0; + struct iovec *caps; if (!stream) return 0x00000000; @@ -5644,10 +5659,13 @@ uint32_t bt_bap_stream_get_location(struct bt_bap_stream *stream) return pacs->sink_loc_value; } - /* TO DO get the location values from metadata - * for brodcast source and sink - */ - return stream->bap->ldb->pacs->source_loc_value; + caps = bt_bap_stream_get_config(stream); + + /* Get stream allocation from capabilities */ + util_ltv_foreach(caps->iov_base, caps->iov_len, &type, + bap_sink_get_allocation, &allocation); + + return allocation; } struct iovec *bt_bap_stream_get_config(struct bt_bap_stream *stream) @@ -6322,18 +6340,6 @@ struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream) return base_iov; } -static void bap_sink_get_allocation(size_t i, uint8_t l, uint8_t t, - uint8_t *v, void *user_data) -{ - uint32_t location32; - - if (!v) - return; - - memcpy(&location32, v, l); - *((uint32_t *)user_data) = le32_to_cpu(location32); -} - /* * This function compares PAC Codec Specific Capabilities, with the Codec * Specific Configuration LTVs received in the BASE of the BAP Source. The From patchwork Fri Apr 19 18:07:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 13636707 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2054.outbound.protection.outlook.com [40.107.6.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF71813B5B5 for ; Fri, 19 Apr 2024 18:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713550089; cv=fail; b=fCyD9KSXxHjJG1DkkAZUB3JkdaqFYPmIxWWL6+7ilkibHxsRRGsUnbLHSCGes8mBMcm3JSQyg1rI8k2dEBxbSFx0TrPNb6s/+ztLnhC2EYSniW0jqDrmshs02VyfJkyr+vPy85mdpZNlVw9b6ku9J+frJxkUKfqa4qbGN64VZgA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713550089; c=relaxed/simple; bh=epB83WXDzDRRwwg04pkoF6XG4xVuJw9LgMcc+sDEDH0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fSSgJk6Yuzs0TCZ5WpuTQl5ySAeb6PUQqUPNPxMymLP8riCXjc/yGAtkOp3eCd06FWWfq/+l4EgRFhStOnYPCBFLUTt2E9LA7A4PKfC0L6Qgx0ts29PLChRiGmDExW6Odkt11BMuda2HVbi5+OEF6ueNlPMKWGDb3s9GsmxvYfk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=BhmiochT; arc=fail smtp.client-ip=40.107.6.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="BhmiochT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gkDYcvcDP9fzVOACMD4uZepM2fJpYGHQU6y5vBd5REawf2h/c6n8Xtp3WkS/R/LrjPqsZCOk/CaGCh0HqpEEOIE/nEpWgnvUgUV2M88R3ILs2YYgDK4XCy02iZDMcfR9WBaxem+Ba8AP3Ao+swLlD1qLi28gst9BPKR5RatQQhxqV0edvuijwQi3EcxM+axhb3X1hUTBE6bhQ7Eu2IHXKBtopDYTn+g1d0cxVrwPIEvQtv/GD7T4hvJa5cejNPJcqKV132IctM9qGzoaTaNp8XIQFe0CWiiC2jsSVDrvoDVzRTf9BppRDrMC8BE5mI0JNfilo6ubiqOg3QBM21d6YQ== 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=K1Ds/vQuWsCzab4E21263OEA3BhKPOsrKcZN9uH5jJI=; b=KA6ccbW5aWSIflUlrMGk+IvM/KDhcGfmb9+PwS0Tc04MfTypF/aFjTXyakm7Fgy0Ro639kOs+b4WhfG677zZ4AA4giNhSGo44zgscJc6D9QmdEV9p+m50oOZnoQewMFzNg+0xvEZhBwn6cZkYkaBuoUa/vO1Z8RlbzgOJ3VDJ6hFTWbU7Yoxvv7pndZszXsdrPykh2KCMvQFPHlhYn/7nKNroSRI0u6/U3Vkr0m3na/qVqBlWfnmQgXMoilMQzSzSy/NjnF/4PlOXWPrJ5UGDVOIRW7fqGvHhNO1QO/5HFMMb4/rEerEXsMdWrK3ZsO5hIm4vJgqLa8O1oH6bSzt5g== 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=K1Ds/vQuWsCzab4E21263OEA3BhKPOsrKcZN9uH5jJI=; b=BhmiochTk2paQE45kWySTC9Twxc3HbPuQzokz/OS6jdOrglMp94jn4Dx41xsy0ThIqfIXGRTItmcA5P83UMrXzRm6ah5E5zm8if4UsRIrPNEl/xkuLpEdl7BtmLVuILpICWxA9zxxjO3W5bIPIChw768k100+MnCOdz77S9uYEE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by PA1PR04MB10261.eurprd04.prod.outlook.com (2603:10a6:102:467::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.48; Fri, 19 Apr 2024 18:08:05 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::fa84:407b:3889:82a2]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::fa84:407b:3889:82a2%5]) with mapi id 15.20.7472.042; Fri, 19 Apr 2024 18:08:04 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ 3/5] shared/bap: Update stream management to avoid PACs Date: Fri, 19 Apr 2024 21:07:50 +0300 Message-Id: <20240419180752.96699-4-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240419180752.96699-1-andrei.istodorescu@nxp.com> References: <20240419180752.96699-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AM0PR10CA0087.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:15::40) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|PA1PR04MB10261:EE_ X-MS-Office365-Filtering-Correlation-Id: 0def9772-d7e5-4501-517f-08dc609ba8c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kx5v5two4xpfiDfA5rqhWuEr50geuQyELo5YBJC31Cf/pKmwEn50RQCTA3i6Rkim689/Mx3I1/3ZvHvlGZpcdVdmQagk8geQjbBApvn/uv/1wJckR1x6cT8kwbw90GhG6Jso2VwgmilayYd6wKNVbcVaUp/cmohoM7w3CyzxrSslput2HSQy9j4KqvYx+maUrKMiquL35fIxRyPfXAh8E/YbNm+CVk7oAKrDiEZ7GpanpgUCZu9iEbzotzMyMZcOaLzEO4g6Y/jDJ6E0CWFIut7xuLNlSVSRdeAAGHsUMo49azv15Rb3UoBDxJg330qetlJjGM5U1U+fgdxT0/KtgebjRMdEe4ieIN8Pm2BMjH/QornuiFrc/CW/S/8iBsOJIWsqZM1WjwZk9BbptdvhkjA+kK8Zj4nGh2rmIWvjDz0Fn+GXUr3oKRn2BfR8dS47Kzg9Ty1+vRzvfm6iuEsFzBIuKMy7JHB5isUffTiXxuI/WpJOvysiAUteWNW1L5auhT3+3+yGNs6Taep+rra+4CBZ/PkC1BwZZvsvItvkjpcg7hztU5+BAgbkHUCa0mxufvCJHaPFYsTZbLHWdlOvsJfiNfpwzK9j/WtcNZq72zKhNECAu5BnJqpwWwQjKlBFPDwVee/ZLSzx12R9VuLWaadN65HAheCLqdndKV7XOLsdliWLM+1v70eTkZMG2oqrbyyM6nWRStdf5oiT9i2m2wSxhfsxyv7tFZwVqewXu0DVMjzo/fWIFrblYRQHypCL/PXZXtO5YJuB/Rs2PraJ2oqA8KmGWkmUT1rRFMFtAhnaY4aKm1aHD99jS0b1ORlyNbi6RpACxi+YDieyu2dZjIwCNZMvajXRwNxlfA4MTubs+ZFIuP81PNcs1/3+gkmU+iURYFYb+2imdz2DAa16Ipiw0pRPRnAQ5d+M4hjFByQ0t6FZfWuCtuXI55nl97uvIxp1JpGrs940A11+N0kqSAHimphMTgsihl4b2PLWYCPTdWc7snknK4JR24zEORNMPQPUdaxK3wjbzMR4SUv9lDVOtYkYbAQz5pe78qjlSt5jqVugqGcD//0c3xpdRfroKUuLDvih6+tZSRyn0BUUD7oeBgTXsK5XFtNs0rFe3Z4fBjePL6cP+eeFbakZRDfBqO7E4RdkYTNtqzxLcxAIEc/t0sQHtPtabKUKQDOvxUK1e/Vtp7bmjgCeRB8+fWqAmBi3KdQmhEaP7hwM3lXRQyUFEBbxanWFd+Y6cJ9PRGNUG7Kz+u50SlgeS/8ACw9IYhlEygDRPaf1w4qlOKPQFg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8938.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jJJq1HK/eCvicnh7TCCudKpd/KY/konrtuS/dWnUFJbIYvBtSM3MLRmK0IMz5t+z4SKLVynQ5qqrsp/HZb9Iy2sHu5zkLr+MXpKkoHMzlA3NGS1f5G/Wu7ITLptJXZ/TB4fIq2Vj7sknNGbDaO1kv3g0GNm0y28cycEoDChsV/a5ubzdySclQFhHq77UhvQhUzcJ+rCmo5M8ote69xz9/v+G6gI85QXDb0I04IlpPU8jQBSQUA1L59X3DBG8806CNV6GTmA+5pDe95qY3/QPon7Zgjxd4n7PWOjtG1ZdYzfQHsm1uvTbt6U5RoZDtwc95gRfho3RyidawyUrfDK5jyJiVH2yiy54ncqCYxhM4n7ElVGPLK74Ef8agqWxlyJPYYIRH1eFsKEljwwJqsAdH8LKW+QDfAHnN0FDeDJjrtP+8luLmf2xQYllp1cLs5cBIoAcRHjzCKAvD2XVl1vTRIErVzMMRApGl7sp90BSH4LP6UCi3r+ZTmUEUleiruadrbboD29q64RiyCDd1Dk+b2vw+C7G5Lbg4+1H30UTSeGVqnMHx2jEk2wwOR5BbE3AffD7NacsWMLvaa6UwVQ6Me/SF+ZgJVDxKI2OEj0SQvzcVhfS8p6woDHwRMTpITNnrzowhOyShBRW9HTmvPMhcITAMIFFNn2d15JLh+LJ1Zfxfd6SFi37fAnhBV57rA6G1c0na1FqOTDI0+yKeWI7a7W2To5stUbrGxHiUggbFP/AoWhVYJM3XUw/7qQysZhHDWQgUgSI1Welxm6T55lbyS3aYkNvv7NtTI+t47Uvxt3C6z1P4i22C7JXuK6ma93NDHK/1TcwLWFutBVGvpoZkCqU6ZUl+qenHxyfRIDqMhm1a37tvbWfKvRDPKu2BMjC+7vEU7NE3tW1AaY5masOIPFUoWDxSgUK3G4GybeuQqMa+YMkNpeyzfLJ5pOgkxISk8CCASKHBWMNMdxO1l++588hvfjXEvmQNFMosw/eCnfU5xBqJQkmrMPhbj9AgErTWTrRe+/kR2jCwhzk6kbyv+ZbPPUajVUVr+7Xq2E9PxqgK2cyKvpaQXGSmSxMiEj/B8kyoduSUd4vEbQdudPP0BB1azSSY6KXotdCXKL8v4BePkWDol/g6HVHAj6c14PZiUy16sYIaOAUlxAZW/FoAOBD3oZAKkqVrAl2RVC+t7IMd40aSsOi+kZ6xZCQF8OiONTcSBHi2seezIwb0WymFZW/WADNeCW/UHupdFX5AJSyQYNsqRSKC40PlCx2tRNoZ8BGh19Uc2T9MjRQ9LlrnY9OA9kmvyDOo9KsFphhkxqJPACs4QA8ctV/QuQmXXAltyvMwYllYmF4MBNNlV6Y+w81wuY6br6X1yh1Peaf3Qb9kh0rbZQxy0lSTlWoHC3tVmcFL8onBSepm0/AqBTkZhjv5whks61zIFIN7C8RbVf4ZmbnxV7Cq2+v8gZHj85tAU1XRIF3uPWx4+dE1zw2KzKvkkcRrBZDDvZFbLMDxHInEPTcFlC1aNvDdLDOFMzAR0o7R9tECr2ResH4SrNK1u3Suo7n1xXaHON2cRNkJZi+iD3TLqaE7b+u943IS/BvQEM9TDTdK03EYrLzDyJOzg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0def9772-d7e5-4501-517f-08dc609ba8c6 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 18:08:04.8962 (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: zn2Gdfr9HZV6xEPnco2+vSejSkgc4L+kv6KsS9197TqRR9wr3gjyYwbff7IVyHkTFTlTQ5kjXwJtMn+LUTtQv22q0K+eJ2OYSOdxakKK32Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10261 Set the stream to enabling for BAP Broadcast Sink, when the transport is acquired. Remove PAC logic for BAP Broadcast Sink stream creation. --- src/shared/bap.c | 60 +++++------------------------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 36f0b0a3b50a..d7a2f9381c53 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -2006,7 +2006,7 @@ static unsigned int bap_bcast_enable(struct bt_bap_stream *stream, void *user_data) { if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) - stream_set_state(stream, BT_BAP_STREAM_STATE_STREAMING); + stream_set_state(stream, BT_BAP_STREAM_STATE_ENABLING); else stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG); @@ -5287,7 +5287,6 @@ void bt_bap_cancel_select(struct bt_bap_pac *lpac, bt_bap_pac_select_t func, static struct bt_bap_stream *bap_bcast_stream_new(struct bt_bap *bap, struct bt_bap_pac *lpac, - struct bt_bap_pac *rpac, struct bt_bap_qos *pqos, struct iovec *data) { @@ -5298,71 +5297,24 @@ static struct bt_bap_stream *bap_bcast_stream_new(struct bt_bap *bap, if (!bap) return NULL; - if (!rpac && (lpac->type != BT_BAP_BCAST_SOURCE) - && queue_isempty(bap->remote_eps)) - return NULL; - - if (lpac && rpac) { - if ((rpac->type != BT_BAP_BCAST_SOURCE) - && (!bap_codec_equal(&lpac->codec, &rpac->codec))) - return NULL; - } else { - uint8_t type; - + if (lpac->type == BT_BAP_BCAST_SOURCE) { match.lpac = lpac; - match.rpac = rpac; + match.rpac = NULL; memset(&match.codec, 0, sizeof(match.codec)); - if (rpac) - type = rpac->type; - else if (lpac) { - switch (lpac->type) { - 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; - } - } else - return NULL; - - bt_bap_foreach_pac(bap, type, match_pac, &match); + bt_bap_foreach_pac(bap, BT_BAP_BCAST_SINK, match_pac, &match); if ((!match.lpac) || (!lpac)) return NULL; - if (!match.rpac && (lpac->type != BT_BAP_BCAST_SOURCE)) - return NULL; lpac = match.lpac; - rpac = match.rpac; - } - - match.lpac = lpac; - match.rpac = rpac; - if (lpac->type != BT_BAP_BCAST_SOURCE) { - /* Check for existing stream */ - ep = queue_find(bap->remote_eps, find_ep_pacs, &match); - if (!ep) { - /* Check for unused ASE */ - ep = queue_find(bap->remote_eps, find_ep_unused, - &match); - if (!ep) { - DBG(bap, "Unable to find unused ASE"); - return NULL; - } - } - stream = ep->stream; - } else { ep = queue_find(bap->remote_eps, find_ep_source, NULL); if (!ep) return NULL; } if (!stream) - stream = bap_stream_new(bap, ep, lpac, rpac, data, true); + stream = bap_stream_new(bap, ep, lpac, NULL, data, true); return stream; } @@ -5415,7 +5367,7 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, if (bt_bap_get_att(bap)) return bap_ucast_stream_new(bap, lpac, rpac, pqos, data); - return bap_bcast_stream_new(bap, lpac, rpac, pqos, data); + return bap_bcast_stream_new(bap, lpac, pqos, data); } struct bt_bap *bt_bap_stream_get_session(struct bt_bap_stream *stream) From patchwork Fri Apr 19 18:07:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 13636709 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2054.outbound.protection.outlook.com [40.107.6.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0823613BC37 for ; Fri, 19 Apr 2024 18:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713550091; cv=fail; b=BJoh9azVWKqQt4CUrw60N6gMw6+dSg5HOwIA700r3NySAapTW7cgVeTCRQLqFD39mHiW//mWZNkZ1vT7mJ6x2d9R1n0VGJ/Wt9uuuCEH1707AOJO8PqLxwOEYWYtfKjz43eMBd1zXXqRZ947Of/r3T/EO6anLTFtvUhPz1rlZJU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713550091; c=relaxed/simple; bh=VWnUxMoA+a17nkbOg25taYBD1jlQPmJbpFjf5SMSStA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QGiedsAslGu3fAYJeLMCTsVXTKunc8x8Up6jwhxrBSo0bNm6HPzZdI/MViNfA+ZbPhLKPQJlXghnE98IdNkighnzyH5fPmENdGAr+T3KmxYcHE+hcQ/rEnTiikcbN+LIuh2txmLuiwOIPl+OGUKkna1YWbK9J7Qyd6+TmngB54E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=pgtuiOyd; arc=fail smtp.client-ip=40.107.6.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="pgtuiOyd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MyzGe2OI86lQKe3573LeZp/EZf69dQZH9zjo/lOZWt+jLV9tmdW8BtWJfDGtylgNaEx82uhtro7n/4wMr57cTTvAr7H7wfdumgUL367ck/rXLAuJRENDncmxzxIMgKKW3AT6YH9s12M8JC7UjxnHKEzWFikwmTZAY6pGJMrjVGDtsPPImW2OTA0uJU3j0/4oiVi7FY8HIY2uNLy+U0uPevHSCaUq/qjwCreWTZHwQYX3w8EDoJAwOGWGSlNRDSQ5ZWLDjJhPQREyRWWwyHKrHf/s1FX5SXuspO0IVQKPmbn6FKtsLYMFEhNl8XLtzmqKwIA189sPRiZ6hjkrbitEmA== 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=0zVIfJg7ks9P2uyYIlFfEPRR2GWX9WMRZGAzSy42Jwk=; b=FFrIdmteERS596jkKmAFp3JziXeIro5eFY8SwVyogWinUoV4eKWusbsy3SlR5UII9r8+CnLrmzvjsFKv+gN9fVrNy7PX7BerN713LdkCU+6Q9QspXzo6aq3RNlzgfDFFrKnROTvRcIPkj0Iehi0kIJDCweu/NowD/mIDk2H5POGCC8XofKijZoRBO6kG2MrVqgoP4Sj8KXdrL5x3FDf4jiFrKqhAEIJrGFIDN/qtWq/aQTZc2IwtAQTt/Mvk98xJhNLlUB89ay6FUFAZgVceRJW+wunQp8NiysdlVj0Kwjy+X2Ft+6XFvWZxyr50DYNxb2hV2EpgKbdh+L9qUdahMQ== 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=0zVIfJg7ks9P2uyYIlFfEPRR2GWX9WMRZGAzSy42Jwk=; b=pgtuiOydibxSffRDeG0ezSKPOt7mYVTb5qXRdnpC3SEPrnLjDKeFZ7BTr6BP39q3XRZ/nETT/hcI794vykneY26D3ERQgisBedIX7HgQh2/Q/uAV+BudxIeHStX7b197KowKNhXhoDox3840lp0rsKhQYtUm36UMooafN44kF8c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by PA1PR04MB10261.eurprd04.prod.outlook.com (2603:10a6:102:467::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.48; Fri, 19 Apr 2024 18:08:06 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::fa84:407b:3889:82a2]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::fa84:407b:3889:82a2%5]) with mapi id 15.20.7472.042; Fri, 19 Apr 2024 18:08:06 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ 4/5] shared/bap: In case of a BIS-PAC match return also the local pac Date: Fri, 19 Apr 2024 21:07:51 +0300 Message-Id: <20240419180752.96699-5-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240419180752.96699-1-andrei.istodorescu@nxp.com> References: <20240419180752.96699-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AS4P192CA0034.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:658::13) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|PA1PR04MB10261:EE_ X-MS-Office365-Filtering-Correlation-Id: 8bced618-a16c-4577-2001-08dc609ba9f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KBcfKzO93AgPglTV3q/CCxtCB2aG+oeoRMlXtHs93XLfk2fwFwMjLx2olBF4A70yTdLqbn2k9X/V2xd8WbK8MHjWCQaon//4H+gZFn8c9cVxLXC+suyg2JNGA329QMOBHNQB2rJAJfY6x0TyANu+mKbBq6LU/eGBH3EAN77yzk/oLER9VuUXf8k9uqjCvQCz+COMhtbHcdWKQv86DFRzRcewQHNBzzwtbX6YlJAB0CnOQD3ij76cak+n3Kh7OV2SmPZsupzXfAXg1e0zU+fDlKTgeCM1xS5/OyQMTWoyWIx7koFXbtC1DsAQE4bpAygNn6r/ruk17vGWeLc6i0LjMQdxcmD2axJWXOl+exvJeZQ3K+Gg2kH8DQSzhzFyQB6zzDt2Lz9sjGuk0KTaaU3eFeewQE1ahlcKLZopVzinNxF6J8phhwO14GKXfyAM/Fe+wnbyTJMY/nq1IRmmZITrPcXHfz4cbgN0R9iwdhchkMzVehM4w1GHi91rfH66EsBySugU4cJcd9OQnpWlAcTfDigxervymEukQLaRDAGEqmlT8WJKsfxt3rChg7FdqdkWwfcLdB2c8p6GU9/TEN773nK98JCZ9gx2z5BuQl3jQ2SD0HkkZDTJIxuwiMbbTat1Ozr/PUl8oWq4reomYcUedVlRKiU1L+iKBLO77HSaTbdpVVBDIf9RfuMBYx7h7amj/flH+akbU8MrCSWVjvRcmTc4ki72a2BL8yKmDFvWLO/v8+NN49nByETLYFa2Joyyurpa7UYCdKqqZkvZKYbbTCpPgbHYIvURXyVLobqloPrHBW9IYSleciNaDkUn5I/uGEcwFnonU7oyckyzG73t/P3URlBxH9UcMw+5Wzle4aKWnnEQE9UWGAkRzN8DBggvyEMm2EiIX0qA7GP9dB/wjBMNcO2+ncG4EcEg6XfJAv8clOUiCi2OTH9+BwyQnzZP0bCJ53DrPT1Nm8x0qiaC15v2mygv9YS/r03Gi6q+7u7ol2ZryXuhGfJ3Z+JIGEAzBMmkPO0LYI6rpOdb1GyyQGFK8IZSDTBL9vRxVf0ch4yxQpOHESe0Vu56GljjHWKRWQ5Vdc9nnBQIvtZpCjc/6UlSFsJqQAFyQDLYmffmdU4P6a8wdWMjFCcZMeGUS9dypes/cigMMtkr1/PUUZOzIyi4okzjsubU5iGo+HWqqP/DGQ9j1/tWfB1KFhdcIYVdu3vxj78aqjtNCBc5N/J8OvGdvqTT8wkwi4TM4VUngHhO4QrilccotFuVYPwjUvj9axgEW+nE9LXtlca0GH5X1A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8938.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XFdThSswGE5vjkB73iMQ9DkPn/o2BWHHM7ug9pDZgAwj0mNOOWDdo/bRBkz/AoHwgZDRiH2p8BNNeS39IeqX5BfsYfCCG4P99TjOphnGRLvw0rzRZMzPEE+kzG1Z6KDbGQPOg1glXZK2w1az8QgiSAMOs2zQYH6sf2fMd8HWkFw5qFskyfzBqW9T/SYlL1aaIbpkLe9HJnVb79JExjwhHEhSFnMyv050pN3wKWM0u3+yiCFWydf9Sr+tiWOsc9a3sZ2Ri3CiVYjSw1MxZ+M1a29Knd2qSrDsKgVD4Ol77RyTHK0tLGiyGEsGCUfcg/sSRSKLNmSRe/ct1L3dQgVXmErjhmnH64IZik9t9x75yQVbho0EuyqwWBtURUiw755zSWO6Yq84wSCOsImu4B+pCoArP8QG5VuxXVc6im31V6NJDaw+qEJAyqEWt2FIfPZ/05drDLXuTQoWYobgqhbyJDjpDxTMEPQMQoUyn6ltEzO1F537zx1D31vZTBM4hQv4Dz9/PGO8AKOimRRgxAQpnyyXEL9jSDOLIVfZnQrCZ6C+kZcjpnJPwIagFdzHjxMYzYS0HOzC4nJlWQ9sjH2CB7N3QHQDojonxrd8WPObv297Ny/uWKcObMDQBVCZo7bKPH1EXzCfUq1H7U/7Disek7vzr9N2rmlodEk0ZzCjucwImZPKnSsPucGC4DamIVN8YATd4Th8j5q2xa4VU2kgftLm5BeLHIByPtYtqkVlQzHtQHNEywtS8iaP4Bz6DoI+w+8xiGEvGeYKVFbxjOI7haMV2QqWaKaoXCEDCtMOXSi7h42VhikvKNrjcQV8g9YlIR6up43t2fpTypOcvxwqXjvBZB9q2G3iKvqr3OnxKJ6u7KbuumU8xrsxKQc6De+t1CGwTVNr3ke2xPixkjpEB6U2SMAuEYKsUKnh7PVBAdwxWxlFVj3+XyQcU3FCv1AYQdISWe1S346QbbxDcqdAPI9GhIdQZqXnN6R/M+3EWT8hfZkSLdzk8vDy61GOO7ZZjP6C/mx7fmVGkOxLPnswEWYfkg8qktfUwZkH/W74n9Jr/nJ43FE8eclxijRI0gdW/sCpz3Dn+Xx5C4ofvCh9qrh6jRSVDSIO5CQZMJF89mZr2VFVTEdpLkmI7W5i3c4hQbmz5fUpf5DFCKkj21FxDuGGRctqdAwcM35OZagHIG3kOlSzPk1/bEolw5GBSrSGeQSNGt15yT+JZsChHWovzt9tNYH1LgBOlSkTFqphJEga+8qM2BUJIFKGg397bO3ELfoJ5jVnfh1oWJpXQzgJ6TrBS0CdpnOIMA1vl3vFDcoY7j6gdCS/zKV1hI4YUke6BER5FS/XYYwJz7Zh9hqXxi/3PAasMhPV1pLmceUYOvB+/hJbG1pCx5DDH8/4/VCtEucRvFr46yNBsRIIMSfoGd7LDwzgCTHmcI0L7HuPl2VndbARpODGE28ep5VNYA/f/+2cqTZUOevv5Un/RNpFM5wzfXwWV+te0GyX13gjMaokNYo7QuzUrt+Kok1EUUBD5F6izUzWVGp2roYqHQDI7dfTkxyILf7bf0k2AFwQfGKLR45znDulx09GgPr1BojXtNzNpEvsZP42eHk7W/Bd7w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8bced618-a16c-4577-2001-08dc609ba9f9 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 18:08:06.8534 (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: cYd/asv8mfgoAn7p70zEmUgybjM9JQff2DMSoiWKbRs/aVlgnUlBKc5hBtP7Ic6eHbiVQa62EWQAB0RW5LkWNW1IQkGzDSnIo7s++4OYzEE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10261 When checking in local PACS for a BIS match return also the local PAC, along with the status of the operation. This information is required later when we create the stream. --- src/shared/bap.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index d7a2f9381c53..8c4868f4bf9f 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -6400,9 +6400,11 @@ static void check_local_pac(void *data, void *user_data) /* We have a match if all selected LTVs have a match */ if ((bis_compare_data.data32 & - CODEC_SPECIFIC_CONFIGURATION_MASK) == - CODEC_SPECIFIC_CONFIGURATION_MASK) + CODEC_SPECIFIC_CONFIGURATION_MASK) == + CODEC_SPECIFIC_CONFIGURATION_MASK) { compare_data->found = true; + compare_data->data = data; + } } } @@ -6427,7 +6429,8 @@ static void bap_sink_match_allocation(size_t i, uint8_t l, uint8_t t, data->found = false; } -static bool bap_check_bis(struct bt_bap_db *ldb, struct iovec *bis_data) +static struct bt_ltv_match bap_check_bis(struct bt_bap_db *ldb, + struct iovec *bis_data) { struct bt_ltv_match compare_data = {}; @@ -6453,7 +6456,7 @@ static bool bap_check_bis(struct bt_bap_db *ldb, struct iovec *bis_data) &compare_data); } - return compare_data.found; + return compare_data; } void bt_bap_add_bis(struct bt_bap *bap, uint8_t bis_index, @@ -6468,6 +6471,7 @@ void bt_bap_add_bis(struct bt_bap *bap, uint8_t bis_index, struct bt_bap_pac_qos bis_qos = {0}; uint8_t type = 0; struct bt_ltv_extract merge_data = {0}; + struct bt_ltv_match match_data = {0}; merge_data.src = l3_caps; merge_data.result = new0(struct iovec, 1); @@ -6483,7 +6487,8 @@ void bt_bap_add_bis(struct bt_bap *bap, uint8_t bis_index, /* Check each BIS Codec Specific Configuration LTVs against our Codec * Specific Capabilities and if the BIS matches create a PAC with it */ - if (bap_check_bis(bap->ldb, merge_data.result) == false) + match_data = bap_check_bis(bap->ldb, merge_data.result); + if (match_data.found == false) goto cleanup; DBG(bap, "Matching BIS %i", bis_index); From patchwork Fri Apr 19 18:07:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Istodorescu X-Patchwork-Id: 13636710 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2054.outbound.protection.outlook.com [40.107.6.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 062BD13B5A1 for ; Fri, 19 Apr 2024 18:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713550094; cv=fail; b=KJTK4OXbRQclBp7LWR4slwRsDKiqBF+X4db1Ke4kwBfzvKCZvHj6UmDuo7TBdI7deABRqPAAxPpIUkjGNNkyUSvcanZpyQg4O6em1ne6mbz7QaQCWZMpeuJWZICIMP5GoH+/Bhlr732hGpYkWXCF0fSwoXLiM65cyoiKeWv4E9Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713550094; c=relaxed/simple; bh=PAcz4SD+EYh2NgK3WzNEn9o5pEJx/HGVmNXgnE7Vlic=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=JUhCxxwfFNS5RSh9YwdjarpH17+slg2hBiRSlTmYlT52cW9F1bpbk/AADEsr3b2rnAPNtL2iH3ii68ulER+/LhCOTU5qrRj5pm0ow7zP3fy1ztbqcENnmFVTPs8VStqRqOzenLP2BnnWouUCE0TmUxf65SbrU9VSvZxqMMfoNHg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=pzUNDGi/; arc=fail smtp.client-ip=40.107.6.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="pzUNDGi/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IN4UmTZzLu9yLIZXQpEXxcXoALQVUlfC8qOrTackCl5KO2sYgtE29KHohrP7s/C1IJmN7JP88juqVjTTSF5Izd0WSVQviHgp62fAnyRbxw/qMZcLwXVDEf9ViPgBsb//GJWhu5LBPZm6ZP2chedLjLNqCRmSGudChreLD4J4zy8c9/506Fjzcg+/NWQpqgBtOo+a0nANecHFXv/Br3zTIWM63nTMu88EwgvRSXlWWmBZTq3rjJsn9iGnKxLFA4cZ6O2T5xE54JEH9k5oDajhI7L3Cskrnaj0IOGkLGRnagp4YUNhoVxgZxe+ZJz6hIozcvyLskWMNlPkr5TyOZBdAg== 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=ObXBBNDfSPC9j6DJ7bl/wgve1yTyqqGY6oZQCClD84U=; b=DP7RTvx6k4RiOOH2YT/LMJ+sd+rhrqEZYi9Le94tSymbC6Y1qY/LyWptDy2W1BsCI14zT2nWlInT3kgznOnveE3BbQKuVlJZDNuCjMSCtb6gx0BVFdKer0nUO5TSBIKrD4SKzmk+8aMvqBx1wQICwY7s06i0G29FCSZDTvtm8ceKSBGqUCBk2qR4v+b+pGiAQ/88n06QR+pFkQ5pNpXKOsiGIlzhLbWx73Vv42fvIQmReZXjuATW9JWsql/isd3Ood6Z7rRSMRFMxCBJowgzhWendWWHTaFLXP1uW1bJN1pilolIWnA7Zk74rdOYemnAn7I3VPDkB8DcAuuDPzkhBg== 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=ObXBBNDfSPC9j6DJ7bl/wgve1yTyqqGY6oZQCClD84U=; b=pzUNDGi/z9jEcV8MaWyoyNF+MTqxKSXUvxwfA02gkT0QdVji0DTi8y/NpiDKY3eFDUMHm2RwTy9UfdfkyV9qGDGEjI09THNrjZWndzDIs6ChyC8LOBa/5d+MkZRlRUVHTkYlyDap4ihgFM27lKyv6O/xCD03U5c8QelQdFEddpU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) by PA1PR04MB10261.eurprd04.prod.outlook.com (2603:10a6:102:467::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.48; Fri, 19 Apr 2024 18:08:08 +0000 Received: from AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::fa84:407b:3889:82a2]) by AM9PR04MB8938.eurprd04.prod.outlook.com ([fe80::fa84:407b:3889:82a2%5]) with mapi id 15.20.7472.042; Fri, 19 Apr 2024 18:08:08 +0000 From: Andrei Istodorescu To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, iulia.tanasescu@nxp.com, Andrei Istodorescu Subject: [PATCH BlueZ 5/5] bap: Create streams and transports for each matching BIS Date: Fri, 19 Apr 2024 21:07:52 +0300 Message-Id: <20240419180752.96699-6-andrei.istodorescu@nxp.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240419180752.96699-1-andrei.istodorescu@nxp.com> References: <20240419180752.96699-1-andrei.istodorescu@nxp.com> X-ClientProxiedBy: AM9P193CA0005.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::10) To AM9PR04MB8938.eurprd04.prod.outlook.com (2603:10a6:20b:409::20) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8938:EE_|PA1PR04MB10261:EE_ X-MS-Office365-Filtering-Correlation-Id: ffc2c155-6c2a-4528-9bc3-08dc609baaf0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4sgUFAWAjp3eMLL0opxuPCiA+lrw+3C7/Emp3VeiOw0pFk6jEYJbOdU6cZODAAP0ieNY37akghpi1BhJST4mokJCZ5q15u5t3GyU0+sRa1Wh1c6qRQv0ZthpASOcICEWh5CkBrqNScF8vtbuL6D2YsBWZVtWHVpYnmBAQjEjknm9ka/f2qU8lTRW0q6vWzR9V0R32EBzyK/vg+XoEc24ARCHv9AZtLyYp2JDNvP3wwdXnXXKXFv8+jbXPkx3Vl/YEiN2zdNcUv1m3pf/gzy80xpc58SR38HJTJuIfDVnrYWv5X7GnIL2tuyuag2rOecYZbO5HvUGZ3zWSkBVrypeXqrdthkO8uibwGAZmkbahwq5AoBzgisK5y8toduLLD/19nLo0KxpXFws93EyOW7T+uriiEg4W1+Wx/dleoMkBNpfTh4M42MD0XdYqrLIp8ZSwo/+IynJOILcgJld+zuRfyOIzn7Vzhozr0qeEDxPqAOmkjs013937cjbF5+cQe3GDyRnAXg7FZUf0BI56TT6qD/7+NaPwG0fX05Zedzbw1To1yG/UE+z47jpVPSLNZRkggLmW8bs2kW7zhNK+ADeoiV8aUzMV/JQGqeg1snGOPikIuaGELFCXWrAQ6kXksuZCQlh1TKihfZCUgdrfloVEf796F4moAQmzWi3u9i1SQ1pasuMcS3WP2+mzSdT4bix3Gzr+f/urNKEoV6W3yHXXPjtRY894SZGIzr66qfX2zVA1QPQeKcZI5YINtZ6ZrMUHtI10WyqfYrefilSzUg8XgcX4UNjB3zvG0VLOWd2y/4hJ7Cg4CD2ie0isgYHAAf3fIVmexwqST9gBFFS2+BZdXISexDhtN5aoWxpsrXnnzM/ZvkQcsrF6hHL1QED3MiD+3jWCrMGdhKWW40ismBqUqD3AuBUiLigWuBP9pYVtgSOH1xBGAouHMCqz1vLRv4skT63Bino7gLo2xQBhaaJjGxM0Ku5IGQHARciqMPWMnEHUyq3kfEbFC8T22HQPSJVdmUzZRe6SUA4PGUX4aBp0BRNgy1zlON53XK5T4lEFZP1DpeTa1X02GkS87tuVRULwk65751IX4KpH1+K/7mFm42f7x0Qh0wLf3nyOpeHDA9VE7JSvyIThoNTfPnC6k8WlxSBZ8yuzNBFKOkdo66VcG+FDUD57i8/Rkvi9V2OBCf5he9S8UCLd2h/8IhQfZB6mKwPksYCdVJbJJrIpB95y0d7WJ0z0mmM+gcBwkICOLVWrUXclQQWQvk3+ziDr7SoTryL3Dm6mccYq9yWR2ppbg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8938.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vBi6X02rXDtmorVZHtmyh8gm2yit7ST/XCiSZDHxzUc5Xh85yHqzQvHiafVpQr7HVA+GlNr9W+Ay33hXsCjKPW/ZAT4yqfoxlwb4FD7YAqJVW8fMDSf80YLaon4nAYgj3QX5Hh/LzQAKp+D0BaR8oHSHiUGws7W+7t1UDIwpFjgqg0L7TPEt9kOW6t1roUf61esDqz626OVPRbFI/IPoVMx6h+z84VD0pgt57ZVB71zXN8x4ACQ5pWQMdq0Jj795nFTxNEY7TcTALzEsO8uZ7ya0LQppvUrs5BmRi7+0PmeFa+7Hecj22geomuRiYJCLLPWzYh1mJZHOSOEuEbRU/NiDz7GQQf7gTEuiBWc45BNQJwHivJuEUfeySjSjhqZALosVTahTQktNbsanqffvbFACOYX6JiNaIO7PUsjfmHHtloUa/2fTJ4wDniBWYJGJ/Ak3JBy24f3L0aLxne3FrBH+vHt75KZdf78hmLpZC1EfDlWJf2basMKqj1oTdMFy6DgZ/PxEYgbS1U/iJrpqVydVc5jRVO64X1dKLv0W7DDO7VFZko2G+DbKn69w0Ji2P6gjLZxTmEcyNlUr0wxF70JF/8jejW10gyBge6ds8YdO/zzjpd8RexcEx6fb6JrrAsXHbGetbwp8BkO8dEQwoz74Vujw7TF7x/01e07aAjil+cjRXya8L57QVyQB5JUqSieLtp1IebQCCZlX2weIHf90pZRu81I5j+idMXwaPeCUPZ0zncQVt+CvRtFlSwfMiIwhKa2mdGAjCCPZta0hqqd+kuZs71nxz9O9cr/AQWY1lEUgKe0Upj/WJgkVzWwvwxlBTXqZUDtJC+eR9yHebglW9J4s1evfogYTDpnC4CTs3DkvMVC+XyvbJlu4aSegX7h+q060inwW5O8/08KXzg5FGt0irahF7dXu2UA1fqNpxg4vEW0okUNE6ybXHoNsPOEan4tA0aWFdhZF8A2gOtRAu2FFfpcqbQmGvYEEC1GL6awfwbuEFPDmSuJAIITSYcVc2rVzErTUkDaS3eNo6lEQsRXxWIdeYlIkWYGkiUS37aArD58D7pcIgxk9wnE2YVtLbWoUMxACPJis2cnMZuyfG+69RvnSzSLozUN2lzVhVsiRuTUOI1SAL+UMTL97EY1phSPy7AtetCR9iDl/2/OiR04xqtM2oBKtxbq/SzJiOjJqbwJzaBIAr3avt/oIQIOweqpLB7xQEwZUjigOeoAoT2VmUwXTgnlVq7oy5tSTXI7yVjsBYNXmNDczvTX1Lh0+9uLq+wu6EwPyJ8SEav+h7zQvuns8DmlATlLiB8+Ofyt/UgGIWTsdNSS3QzlgtOJeWlzLf9+3GhqizjhzI6y08DT43dqj15YXyvfYWlAKTPNyITxlktbMl7+2UuZXTY2YWW9YKbjHj3RAPC9QL9oFEMNO1lQ1Ney1JmB2mQARGd8Rm6lOvKEGCZfdCzKnaSSiN4VvSD9/myhXM4Tb6XO20vv1PqJ/LPRVrymZvkqhOk4Xe/gh1av4MoOZjKgGi6Jsms7ZA2v2ExewyhEI7hO400MO6xQhbW7zQ4wT7JTB4zU0rgCHvmJ/twoWSA/BsV5AvNtb+5s5g3QtP7ijPw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ffc2c155-6c2a-4528-9bc3-08dc609baaf0 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8938.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 18:08:08.5663 (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: bnnMRdyqHjMQgB16voZ/S99Snx+eerc9BUvUbQ0vH9NtPedkcPz5ozF/d4QKExCq5Yv8kae73hI88nawCeYqlMn8f0WufIi7nb10S+lzTrg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10261 Rename bt_bap_add_bis to bt_bap_check_bis as its scope has changed. Use the BIS index received in the BASE to synchronize to the BIG. Allow bt_bap_endpoint to be NULL. Remove the Broadcast Sink code from set_configuration. Update BASE parsing so that it creates streams and transports, without a remote PAC and endpoint. Update bap_find_setup_by_stream to find the setup in case the stream does not contain an endpoint. Update BAP Broadcast Sink state machine: * BIS matched over the air -> create stream and transport and set the stream state to BT_BAP_STREAM_STATE_CONFIG * transport acquire sets stream state to BT_BAP_STREAM_STATE_ENABLING and do BIG Create Sync * BIG Sync Established received sets stream state to BT_BAP_STREAM_STATE_STREAMING --- profiles/audio/bap.c | 184 +++++++++++++++++++++++++++++---------- src/shared/bap.c | 199 ++++++++++++++++++++++--------------------- src/shared/bap.h | 6 +- 3 files changed, 244 insertions(+), 145 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index ff6d6d881346..b59ef405ab74 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -109,6 +109,7 @@ struct bap_data { struct queue *srcs; struct queue *snks; struct queue *bcast; + struct queue *bcast_snks; struct queue *streams; GIOChannel *listen_io; int selecting; @@ -125,7 +126,10 @@ struct bap_bcast_pa_req { bool in_progress; union { struct btd_service *service; - struct bap_setup *setup; + struct bap_accept { + struct bap_setup *setup; + struct bap_data *bap_data; + } accept_data; } data; }; @@ -197,6 +201,8 @@ static void ep_unregister(void *data) MEDIA_ENDPOINT_INTERFACE); } +static void setup_free(void *data); + static void bap_data_free(struct bap_data *data) { if (data->listen_io) { @@ -213,6 +219,7 @@ static void bap_data_free(struct bap_data *data) queue_destroy(data->srcs, ep_unregister); queue_destroy(data->bcast, ep_unregister); queue_destroy(data->streams, NULL); + queue_destroy(data->bcast_snks, setup_free); bt_bap_ready_unregister(data->bap, data->ready_id); bt_bap_state_unregister(data->bap, data->state_id); bt_bap_pac_unregister(data->bap, data->pac_id); @@ -850,7 +857,11 @@ static struct bap_setup *setup_new(struct bap_ep *ep) setup = new0(struct bap_setup, 1); setup->ep = ep; - if (queue_find(ep->data->bcast, NULL, ep)) { + /* Broadcast Source has endpoints in bcast list, Broadcast Sink + * does not have endpoints + */ + if (((ep != NULL) && queue_find(ep->data->bcast, NULL, ep)) || + (ep == NULL)) { /* Mark BIG and BIS to be auto assigned */ setup->qos.bcast.big = BT_ISO_QOS_BIG_UNSET; setup->qos.bcast.bis = BT_ISO_QOS_BIS_UNSET; @@ -866,12 +877,14 @@ static struct bap_setup *setup_new(struct bap_ep *ep) setup->qos_parser = setup_parse_ucast_qos; } - if (!ep->setups) - ep->setups = queue_new(); + if (ep) { + if (!ep->setups) + ep->setups = queue_new(); - queue_push_tail(ep->setups, setup); + queue_push_tail(ep->setups, setup); - DBG("ep %p setup %p", ep, setup); + DBG("ep %p setup %p", ep, setup); + } return setup; } @@ -942,17 +955,6 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return btd_error_invalid_args(msg); } - /* For BAP Broadcast Sink, the capabilities and metadata are coming - * from the source's BIS, which are present in the remote PAC - */ - if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) { - util_iov_free(setup->caps, 1); - setup->caps = util_iov_dup(bt_bap_pac_get_data(ep->rpac), 1); - util_iov_free(setup->metadata, 1); - setup->metadata = util_iov_dup( - bt_bap_pac_get_metadata(ep->rpac), 1); - } - setup->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, ep->rpac, &setup->qos, setup->caps); bt_bap_stream_set_user_data(setup->stream, ep->path); @@ -988,20 +990,24 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) { struct bap_bcast_pa_req *req = user_data; - struct bap_setup *setup = req->data.setup; + struct bap_setup *setup = req->data.accept_data.setup; int fd; DBG("BIG Sync completed"); queue_remove(bcast_pa_requests, req); + g_io_channel_unref(setup->io); + g_io_channel_shutdown(setup->io, TRUE, NULL); + setup->io = NULL; + /* This device is no longer needed */ - btd_service_connecting_complete(setup->ep->data->service, 0); + btd_service_connecting_complete(req->data.accept_data.bap_data->service, + 0); fd = g_io_channel_unix_get_fd(io); if (bt_bap_stream_set_io(setup->stream, fd)) { - bt_bap_stream_enable(setup->stream, true, NULL, NULL, NULL); g_io_channel_set_close_on_unref(io, FALSE); return; } @@ -1014,8 +1020,54 @@ static void print_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v, util_hexdump(' ', v, l, user_data, NULL); } -static bool parse_base(struct bt_bap *bap, struct bt_iso_base *base, - util_debug_func_t func) +static void create_stream_for_bis(struct bap_data *bap_data, + struct bt_bap_pac *lpac, struct bt_iso_qos *qos, + struct iovec *caps, struct iovec *meta, char *path) +{ + struct bap_setup *setup; + + setup = setup_new(NULL); + + /* Create BAP QoS structure */ + setup->qos.bcast.big = qos->bcast.big; + setup->qos.bcast.bis = qos->bcast.bis; + setup->qos.bcast.sync_factor = qos->bcast.sync_factor; + setup->qos.bcast.packing = qos->bcast.packing; + setup->qos.bcast.framing = qos->bcast.framing; + setup->qos.bcast.encryption = qos->bcast.encryption; + if (setup->qos.bcast.encryption) + util_iov_append(setup->qos.bcast.bcode, + qos->bcast.bcode, + sizeof(qos->bcast.bcode)); + setup->qos.bcast.options = qos->bcast.options; + setup->qos.bcast.skip = qos->bcast.skip; + setup->qos.bcast.sync_timeout = qos->bcast.sync_timeout; + setup->qos.bcast.sync_cte_type = + qos->bcast.sync_cte_type; + setup->qos.bcast.mse = qos->bcast.mse; + setup->qos.bcast.timeout = qos->bcast.timeout; + setup->qos.bcast.io_qos.interval = + qos->bcast.in.interval; + setup->qos.bcast.io_qos.latency = qos->bcast.in.latency; + setup->qos.bcast.io_qos.phy = qos->bcast.in.phy; + setup->qos.bcast.io_qos.rtn = qos->bcast.in.rtn; + setup->qos.bcast.io_qos.sdu = qos->bcast.in.sdu; + + queue_push_tail(bap_data->bcast_snks, setup); + + /* Create and configure stream */ + setup->stream = bt_bap_stream_new(bap_data->bap, + lpac, NULL, &setup->qos, caps); + + bt_bap_stream_set_user_data(setup->stream, path); + bt_bap_stream_config(setup->stream, &setup->qos, + caps, NULL, NULL); + bt_bap_stream_metadata(setup->stream, meta, + NULL, NULL); +} + +static bool parse_base(struct bap_data *bap_data, struct bt_iso_base *base, + struct bt_iso_qos *qos, util_debug_func_t func) { struct iovec iov = { .iov_base = base->base, @@ -1087,11 +1139,20 @@ static bool parse_base(struct bt_bap *bap, struct bt_iso_base *base, for (; num_bis; num_bis--) { uint8_t bis_index; struct iovec *l3_caps; + struct iovec *merged_caps; + struct bt_bap_pac *matched_lpac; + char *path; + int err; if (!util_iov_pull_u8(&iov, &bis_index)) goto fail; util_debug(func, NULL, "BIS #%d", bis_index); + err = asprintf(&path, "%s/bis%d", + device_get_path(bap_data->device), + bis_index); + if (err < 0) + continue; /* Read Codec Specific Configuration */ l3_caps = new0(struct iovec, 1); @@ -1110,9 +1171,16 @@ static bool parse_base(struct bt_bap *bap, struct bt_iso_base *base, l3_caps->iov_len, NULL, print_ltv, func); - /* Try to create a PAC using this BIS information */ - bt_bap_add_bis(bap, bis_index, &codec, l2_caps, l3_caps, - meta); + /* Check if this BIS matches any local PAC */ + bt_bap_verify_bis(bap_data->bap, bis_index, &codec, + l2_caps, l3_caps, &matched_lpac, + &merged_caps); + + if (matched_lpac == NULL || merged_caps == NULL) + continue; + + create_stream_for_bis(bap_data, matched_lpac, qos, + merged_caps, meta, path); } } @@ -1155,7 +1223,9 @@ static void iso_pa_sync_confirm_cb(GIOChannel *io, void *user_data) /* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities */ - parse_base(data->bap, &base, bap_debug); + parse_base(data, &base, &qos, bap_debug); + + service_set_connecting(pa_req->data.service); } static bool match_data_bap_data(const void *data, const void *match_data) @@ -1558,6 +1628,7 @@ static struct bap_setup *bap_find_setup_by_stream(struct bap_data *data, struct bt_bap_stream *stream) { struct bap_ep *ep = NULL; + struct queue *queue = NULL; switch (bt_bap_stream_get_type(stream)) { case BT_BAP_STREAM_TYPE_UCAST: @@ -1572,9 +1643,11 @@ static struct bap_setup *bap_find_setup_by_stream(struct bap_data *data, } if (ep) - return queue_find(ep->setups, match_setup_stream, stream); + queue = ep->setups; + else + queue = data->bcast_snks; - return NULL; + return queue_find(queue, match_setup_stream, stream); } static void iso_connect_bcast_cb(GIOChannel *chan, GError *err, @@ -2097,7 +2170,8 @@ static void setup_accept_io_broadcast(struct bap_data *data, */ pa_req->type = BAP_PA_BIG_SYNC_REQ; pa_req->in_progress = FALSE; - pa_req->data.setup = setup; + pa_req->data.accept_data.setup = setup; + pa_req->data.accept_data.bap_data = data; queue_push_tail(bcast_pa_requests, pa_req); } @@ -2157,7 +2231,7 @@ static void setup_create_bcast_io(struct bap_data *data, memcpy(&iso_qos.bcast.out, &setup->qos.bcast.io_qos, sizeof(struct bt_iso_io_qos)); - if (bt_bap_pac_get_type(setup->ep->lpac) == BT_BAP_BCAST_SOURCE) + if (bt_bap_stream_get_dir(stream) == BT_BAP_BCAST_SINK) setup_connect_io_broadcast(data, setup, stream, &iso_qos, defer); else @@ -2399,12 +2473,7 @@ static void bap_state_bcast(struct bt_bap_stream *stream, uint8_t old_state, if (!setup || setup->id) break; if (bt_bap_stream_io_dir(stream) == - BT_BAP_BCAST_SOURCE) - /* If the stream is attached to a - * broadcast sink endpoint. - */ - setup_create_io(data, setup, stream, defer); - else { + BT_BAP_BCAST_SINK) { /* If the stream attached to a broadcast * source endpoint generate the base. */ @@ -2455,6 +2524,14 @@ static void bap_state_bcast(struct bt_bap_stream *stream, uint8_t old_state, } } break; + case BT_BAP_STREAM_STATE_ENABLING: + if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) + setup_create_io(data, setup, stream, defer); + break; + case BT_BAP_STREAM_STATE_RELEASING: + if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) + setup_io_close(setup, NULL); + break; } } @@ -2794,6 +2871,7 @@ static int short_lived_pa_sync(struct bap_bcast_pa_req *req) error("BAP unable to attach"); return -EINVAL; } + data->bcast_snks = queue_new(); bap_data_add(data); @@ -2833,29 +2911,41 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) { GError *err = NULL; struct bap_bcast_pa_req *req = user_data; - struct bap_setup *setup = req->data.setup; - struct bap_data *data = setup->ep->data; + struct bap_setup *setup = req->data.accept_data.setup; + struct bap_data *data = req->data.accept_data.bap_data; struct sockaddr_iso_bc iso_bc_addr; struct bt_iso_qos qos; + char *path; + int bis_index = 1; + char device_name[40] = {0}; + int s_err; - DBG("PA Sync done, do BIG Sync"); + DBG("PA Sync done"); g_io_channel_unref(setup->io); - setup->io = NULL; - + g_io_channel_shutdown(setup->io, TRUE, NULL); setup->io = io; g_io_channel_ref(setup->io); /* TODO * We can only synchronize with a single BIS to a BIG. * In order to have multiple BISes targeting this BIG we need to have - * all the BISes before doing this request. This request is triggered - * by an endpoint "SetConfiguration" command. For multiple BISes - * we need another way to specify which BISes user is requesting + * all the BISes before doing bt_io_bcast_accept. + * This request comes from a transport "Acquire" call. + * For multiple BISes in the same BIG we need to either wait for all + * transports in the same BIG to be acquired or tell when to do the + * bt_io_bcast_accept by other means */ + path = bt_bap_stream_get_user_data(setup->stream); + s_err = sscanf(path, "%s/bis%d", device_name, &bis_index); + if (s_err == -1) + DBG("sscanf error"); + + DBG("Do BIG Sync with BIS %d", bis_index); + 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_bis[0] = bis_index; iso_bc_addr.bc_num_bis = 1; /* Set the user requested QOS */ @@ -2898,8 +2988,8 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) static void pa_and_big_sync(struct bap_bcast_pa_req *req) { GError *err = NULL; - struct bap_setup *setup = req->data.setup; - struct bap_data *data = setup->ep->data; + struct bap_setup *setup = req->data.accept_data.setup; + struct bap_data *data = req->data.accept_data.bap_data; req->in_progress = TRUE; diff --git a/src/shared/bap.c b/src/shared/bap.c index 8c4868f4bf9f..e69f6cec99bf 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -226,6 +226,7 @@ struct bt_bap_stream_io { struct bt_bap_stream_ops { uint8_t type; void (*set_state)(struct bt_bap_stream *stream, uint8_t state); + unsigned int (*get_state)(struct bt_bap_stream *stream); unsigned int (*config)(struct bt_bap_stream *stream, struct bt_bap_qos *qos, struct iovec *data, bt_bap_stream_func_t func, void *user_data); @@ -245,6 +246,8 @@ struct bt_bap_stream_ops { unsigned int (*metadata)(struct bt_bap_stream *stream, struct iovec *data, bt_bap_stream_func_t func, void *user_data); + unsigned int (*get_dir)(struct bt_bap_stream *stream); + unsigned int (*get_loc)(struct bt_bap_stream *stream); unsigned int (*release)(struct bt_bap_stream *stream, bt_bap_stream_func_t func, void *user_data); }; @@ -1578,6 +1581,11 @@ done: bap_stream_state_changed(stream); } +static unsigned int bap_ucast_get_state(struct bt_bap_stream *stream) +{ + return stream->ep->state; +} + static unsigned int bap_ucast_config(struct bt_bap_stream *stream, struct bt_bap_qos *qos, struct iovec *data, @@ -1923,6 +1931,27 @@ static bool bap_stream_valid(struct bt_bap_stream *stream) return queue_find(stream->bap->streams, NULL, stream); } +static unsigned int bap_ucast_get_dir(struct bt_bap_stream *stream) +{ + return stream->ep->dir; +} + +static unsigned int bap_ucast_get_location(struct bt_bap_stream *stream) +{ + struct bt_pacs *pacs; + + if (!stream) + return 0x00000000; + + pacs = stream->client ? stream->bap->rdb->pacs : stream->bap->ldb->pacs; + + if (stream->ep->dir == BT_BAP_SOURCE) + return pacs->source_loc_value; + else if (stream->ep->dir == BT_BAP_SINK) + return pacs->sink_loc_value; + return 0x00000000; +} + static unsigned int bap_ucast_release(struct bt_bap_stream *stream, bt_bap_stream_func_t func, void *user_data) @@ -2000,6 +2029,11 @@ static void bap_bcast_set_state(struct bt_bap_stream *stream, uint8_t state) } } +static unsigned int bap_bcast_get_state(struct bt_bap_stream *stream) +{ + return stream->state; +} + static unsigned int bap_bcast_enable(struct bt_bap_stream *stream, bool enable_links, struct iovec *data, bt_bap_stream_func_t func, @@ -2043,6 +2077,41 @@ static unsigned int bap_bcast_metadata(struct bt_bap_stream *stream, return 1; } +static unsigned int bap_bcast_get_dir(struct bt_bap_stream *stream) +{ + if (bt_bap_pac_get_type(stream->lpac) == BT_BAP_BCAST_SINK) + return BT_BAP_BCAST_SOURCE; + else + return BT_BAP_BCAST_SINK; +} + +static void bap_sink_get_allocation(size_t i, uint8_t l, uint8_t t, + uint8_t *v, void *user_data) +{ + uint32_t location32; + + if (!v) + return; + + memcpy(&location32, v, l); + *((uint32_t *)user_data) = le32_to_cpu(location32); +} + +static unsigned int bap_bcast_get_location(struct bt_bap_stream *stream) +{ + uint8_t type = BAP_CHANNEL_ALLOCATION_LTV_TYPE; + uint32_t allocation = 0; + struct iovec *caps; + + caps = bt_bap_stream_get_config(stream); + + /* Get stream allocation from capabilities */ + util_ltv_foreach(caps->iov_base, caps->iov_len, &type, + bap_sink_get_allocation, &allocation); + + return allocation; +} + static unsigned int bap_bcast_release(struct bt_bap_stream *stream, bt_bap_stream_func_t func, void *user_data) @@ -2052,11 +2121,12 @@ static unsigned int bap_bcast_release(struct bt_bap_stream *stream, return 1; } -#define STREAM_OPS(_type, _set_state, _config, _qos, _enable, _start, \ - _disable, _stop, _metadata, _release) \ +#define STREAM_OPS(_type, _set_state, _get_state, _config, _qos, _enable, \ + _start, _disable, _stop, _metadata, _get_dir, _get_loc, _release) \ { \ .type = _type, \ .set_state = _set_state, \ + .get_state = _get_state, \ .config = _config, \ .qos = _qos, \ .enable = _enable, \ @@ -2064,26 +2134,40 @@ static unsigned int bap_bcast_release(struct bt_bap_stream *stream, .disable = _disable, \ .stop = _stop, \ .metadata = _metadata, \ + .get_dir = _get_dir,\ + .get_loc = _get_loc, \ .release = _release, \ } static const struct bt_bap_stream_ops stream_ops[] = { STREAM_OPS(BT_BAP_SINK, bap_ucast_set_state, + bap_ucast_get_state, bap_ucast_config, bap_ucast_qos, bap_ucast_enable, bap_ucast_start, bap_ucast_disable, bap_ucast_stop, - bap_ucast_metadata, bap_ucast_release), + bap_ucast_metadata, bap_ucast_get_dir, + bap_ucast_get_location, + bap_ucast_release), STREAM_OPS(BT_BAP_SOURCE, bap_ucast_set_state, + bap_ucast_get_state, bap_ucast_config, bap_ucast_qos, bap_ucast_enable, bap_ucast_start, bap_ucast_disable, bap_ucast_stop, - bap_ucast_metadata, bap_ucast_release), + bap_ucast_metadata, bap_ucast_get_dir, + bap_ucast_get_location, + bap_ucast_release), STREAM_OPS(BT_BAP_BCAST_SINK, bap_bcast_set_state, + bap_bcast_get_state, bap_bcast_config, NULL, bap_bcast_enable, bap_bcast_start, bap_bcast_disable, NULL, - bap_bcast_metadata, bap_bcast_release), + bap_bcast_metadata, bap_bcast_get_dir, + bap_bcast_get_location, + bap_bcast_release), STREAM_OPS(BT_BAP_BCAST_SOURCE, bap_bcast_set_state, + bap_bcast_get_state, bap_bcast_config, NULL, bap_bcast_enable, bap_bcast_start, bap_bcast_disable, NULL, - bap_bcast_metadata, bap_bcast_release), + bap_bcast_metadata, bap_bcast_get_dir, + bap_bcast_get_location, + bap_bcast_release), }; static const struct bt_bap_stream_ops * @@ -5383,11 +5467,7 @@ uint8_t bt_bap_stream_get_state(struct bt_bap_stream *stream) if (!stream) return BT_BAP_STREAM_STATE_IDLE; - if (stream->lpac->type != BT_BAP_BCAST_SOURCE && - stream->lpac->type != BT_BAP_BCAST_SINK) - return stream->ep->state; - else - return stream->state; + return stream->ops->get_state(stream); } bool bt_bap_stream_set_user_data(struct bt_bap_stream *stream, void *user_data) @@ -5571,53 +5651,15 @@ uint8_t bt_bap_stream_get_dir(struct bt_bap_stream *stream) if (!stream) return 0x00; - if (stream->ep) - return stream->ep->dir; - - if (bt_bap_pac_get_type(stream->lpac) == BT_BAP_BCAST_SINK) - return BT_BAP_BCAST_SOURCE; - else - return BT_BAP_BCAST_SINK; -} - -static void bap_sink_get_allocation(size_t i, uint8_t l, uint8_t t, - uint8_t *v, void *user_data) -{ - uint32_t location32; - - if (!v) - return; - - memcpy(&location32, v, l); - *((uint32_t *)user_data) = le32_to_cpu(location32); + return stream->ops->get_dir(stream); } uint32_t bt_bap_stream_get_location(struct bt_bap_stream *stream) { - struct bt_pacs *pacs; - uint8_t type = BAP_CHANNEL_ALLOCATION_LTV_TYPE; - uint32_t allocation = 0; - struct iovec *caps; - if (!stream) return 0x00000000; - pacs = stream->client ? stream->bap->rdb->pacs : stream->bap->ldb->pacs; - - if (stream->ep) { - if (stream->ep->dir == BT_BAP_SOURCE) - return pacs->source_loc_value; - else if (stream->ep->dir == BT_BAP_SINK) - return pacs->sink_loc_value; - } - - caps = bt_bap_stream_get_config(stream); - - /* Get stream allocation from capabilities */ - util_ltv_foreach(caps->iov_base, caps->iov_len, &type, - bap_sink_get_allocation, &allocation); - - return allocation; + return stream->ops->get_loc(stream); } struct iovec *bt_bap_stream_get_config(struct bt_bap_stream *stream) @@ -6459,17 +6501,13 @@ static struct bt_ltv_match bap_check_bis(struct bt_bap_db *ldb, return compare_data; } -void bt_bap_add_bis(struct bt_bap *bap, uint8_t bis_index, +void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index, struct bt_bap_codec *codec, struct iovec *l2_caps, struct iovec *l3_caps, - struct iovec *meta) + struct bt_bap_pac **lpac, + struct iovec **caps) { - struct bt_bap_pac *pac_source_bis; - struct bt_bap_endpoint *ep; - int err = 0; - struct bt_bap_pac_qos bis_qos = {0}; - uint8_t type = 0; struct bt_ltv_extract merge_data = {0}; struct bt_ltv_match match_data = {0}; @@ -6488,43 +6526,14 @@ void bt_bap_add_bis(struct bt_bap *bap, uint8_t bis_index, * Specific Capabilities and if the BIS matches create a PAC with it */ match_data = bap_check_bis(bap->ldb, merge_data.result); - if (match_data.found == false) - goto cleanup; - - DBG(bap, "Matching BIS %i", bis_index); - - /* Create a QoS structure based on the received BIS information to - * specify the desired channel for this BIS/PAC - */ - type = BAP_CHANNEL_ALLOCATION_LTV_TYPE; - util_ltv_foreach(merge_data.result->iov_base, - merge_data.result->iov_len, &type, - bap_sink_get_allocation, &bis_qos.location); - - /* Create a remote PAC */ - pac_source_bis = bap_pac_new(bap->rdb, NULL, - BT_BAP_BCAST_SOURCE, codec, &bis_qos, - merge_data.result, meta); - - err = asprintf(&pac_source_bis->name, "%d", bis_index); - - if (err < 0) { - DBG(bap, "error in asprintf"); - goto cleanup; + if (match_data.found == true) { + *caps = merge_data.result; + *lpac = match_data.data; + DBG(bap, "Matching BIS %i", bis_index); + } else { + util_iov_free(merge_data.result, 1); + *caps = NULL; + *lpac = NULL; } - /* Add remote source endpoint */ - if (!bap->rdb->broadcast_sources) - bap->rdb->broadcast_sources = queue_new(); - queue_push_tail(bap->rdb->broadcast_sources, pac_source_bis); - - queue_foreach(bap->pac_cbs, notify_pac_added, pac_source_bis); - /* 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); - -cleanup: - util_iov_free(merge_data.result, 1); } diff --git a/src/shared/bap.h b/src/shared/bap.h index 62e2104850c7..35524df0b451 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -251,9 +251,9 @@ bool bt_bap_pac_bcast_is_local(struct bt_bap *bap, struct bt_bap_pac *pac); struct iovec *bt_bap_stream_get_base(struct bt_bap_stream *stream); -void bt_bap_add_bis(struct bt_bap *bap, uint8_t bis_index, +void bt_bap_verify_bis(struct bt_bap *bap, uint8_t bis_index, struct bt_bap_codec *codec, struct iovec *l2_caps, struct iovec *l3_caps, - struct iovec *meta); - + struct bt_bap_pac **lpac, + struct iovec **caps);