Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp399765lqt; Mon, 18 Mar 2024 10:58:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/PJiXm8WM/KsbHTE6sFymwr77yx21PN5EO/KT4h7KpPGbK1tpMTBBXYETyJ0YRPWhypy/n40cRFt+gjeAYruTY1QjOztBfjMTa6Kngw== X-Google-Smtp-Source: AGHT+IEwgFnDKYV0sIuNaVrOgu3On0lIlVJMgs5ek0JrVDd9nlHpV+6CyqqRwgvcN03AZXV1Ss3p X-Received: by 2002:a05:6a00:2da3:b0:6e6:9dfb:7e71 with SMTP id fb35-20020a056a002da300b006e69dfb7e71mr450334pfb.2.1710784696674; Mon, 18 Mar 2024 10:58:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710784696; cv=pass; d=google.com; s=arc-20160816; b=FTu88pX4ZoKZHopJ3YfylDbvgMMkoJyZALLM3qqw9V7qRTx7RDii1faHM4+kTEbn8M bIFVutiYxg0okTY+ldbmi7FR/5pSST3+sy7J4byXmn7/iH6TjjXHrvbPETwyl87SYBuf Ojx6lpJTrR3g3yeqI6HAgDjzBivIdkFbYk7QRVYeQe0ENmxljsjeo3bcEE8m5L09LfRj KLN/CensP/h4aRCwiL8sSkI3lOpRWbiMXF6yy34Ara5s/GyH9RZyueBHDhTCRhgpdEal KaeKApOwSnykh990HM94D5NcJREhmJxgolES0b2XNmZ8Mks0IIzORnNZ3d/JVkglkRUh ad/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=vyYrP1E5Ts83b8z/e+7ECzvdaYjijY63GIoKx09GJ4s=; fh=4cfHHvMRvxrr4lXvRqQ13xW+EMunW4MjA7lyDAf7cC4=; b=CluH+x2SZ8HMwA92hzbkp0lRWM8AMc6PlEa95DPKBL/7HXtnu3Gd+bkM6cg+oa7uch IJirSI0dWlAkxhIC67wvh/mKXPCG4j+P7uDwWphaOBpzIZkgMnTdEiDzx0ZwdIRXWPsK Ajd0Q6u2G8siEC/U24DqYVdNAlyzeeb1Dv12t9X+WgdSwORfXPvRPiZsVeUzp4erWH+G 5lIYL3SWoyza5nCQvbkSY353sfwT6+cWVk18Z+rfwzTs2oxyW+ot3pUz7rJ+Akv2VEOB MIbYhRYrQ/MT/qG6yojyUBzJDj8rQ0SqzbVPaUfpPW9+avnt6aNaKDAcLjxivyiu54pL B38A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lm+2+681; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2602-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a3-20020a63cd43000000b005d29ed61d61si8355207pgj.78.2024.03.18.10.58.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 10:58:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-2602-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lm+2+681; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2602-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B1BCC284C18 for ; Mon, 18 Mar 2024 17:38:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 221DB55780; Mon, 18 Mar 2024 17:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lm+2+681" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADAFF55E42 for ; Mon, 18 Mar 2024 17:38:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710783508; cv=none; b=AE0jSagIQcRLLHptqkhukO2uNcdn9GxnhnL5zcS8wFqsd8kzZpY4axV1P/9n5K2TNryDRArZ7TQ5kDwaHU8ZSoKVMByFNS0pJNAlegoIfmd0q68bB28zVhx66bTkvp4gcBCvxYwPwtcDdBjzLEDLV3SwaR8cFT2D8/qXDnzBaiY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710783508; c=relaxed/simple; bh=GVlE9G6+hWkhA2ey+er7iMYquoRltEz+dobpXAIZUGY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FXIoutkrKwzxi+L02ywX98wjNuOWbKUQ2xW2AfLZxYHOcCZxL1hS+eDDcYvHtsmusoLy5+o/EP1+7uvucfrY/f8hjM39HdAkwBHQUpm30CiOL8hRmCTWuavamfBfRi4NjZAMuhbOCYW04XarhDAnszfRn+q4Lr2oQqUgs/wSDEo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lm+2+681; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d28051376eso75589351fa.0 for ; Mon, 18 Mar 2024 10:38:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710783505; x=1711388305; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vyYrP1E5Ts83b8z/e+7ECzvdaYjijY63GIoKx09GJ4s=; b=lm+2+681yP3xXRvbZjquH3oRCuTtKd8jENTRMiZVHNdeDVp7PfnQPWnTNwBifp8JaK HqAOUn1tS6kTIxPD8jlcrTzJAVbGQo6S7WgiUalA4OaBOiMpeOLz4w4rL6RhNprGEsi/ k6/TqpAeHTFnCiNdsHddQc3i1nL7iP6kyObtrCVBCTnj3ElCYNePnEdn3Aiosk0FSlaC c4exw/zxyyKQyTZQXuiyv3ZJ37aQcemX3sywSlSm5FD8rXOKRxkwN1k8FbaAv1taTNId fkL53KVHElVyhPORxOGxGTjy5VgQF8ljRQeBO5p/LRyR/Am/wxYDnl+TerrWlJPbmT36 5QvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710783505; x=1711388305; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vyYrP1E5Ts83b8z/e+7ECzvdaYjijY63GIoKx09GJ4s=; b=XZkUCpqkKwGoePzZJQmH3M1DLNShldjNve8K5y2STp/EUbAI+hxBr5WjnU5q1RzQqA VAgP3fBYBTVf1mBwSeDzJmpBc7weHtMsMWjbTRgdH1wITave5FIuQcINVGtTXi6s3gs7 A9xw2Ff+rw98s60u5FYcjToQl1TECEgYhPg674xCZgP9enRYsc7tkWropDtwU+R4mXIj x68PtL3N4OwbTbLUQtWcPYubkP1vr3n3Dt4Fxn+xOLMziUkrwAiq63JIsOBRE+8sjUfH 645ftUcdj+enscK82Iw79+YxDzOeNCnBm5DT/zLozRihkmEraB3chTtRGrcUDBrZvVMT 9XbA== X-Gm-Message-State: AOJu0Yx3QHaUzRPqCjIahDdGUWUG2NsRvFl1kXx+VSahaYXOpqzWBclG wED1cOgC1hrJLjrpc5B8xlTjoxRCJ7vgdtGhJUKY1rA2qfJ3Nj2OQTuXAbIUvP8BTouaN+I/qzh RTaO5co93ZfevD9jhcYQ6sPI8cnw= X-Received: by 2002:a2e:8747:0:b0:2d4:8bfe:69b7 with SMTP id q7-20020a2e8747000000b002d48bfe69b7mr5302584ljj.46.1710783504328; Mon, 18 Mar 2024 10:38:24 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240318163853.68598-1-silviu.barbulescu@nxp.com> <20240318163853.68598-4-silviu.barbulescu@nxp.com> In-Reply-To: <20240318163853.68598-4-silviu.barbulescu@nxp.com> From: Luiz Augusto von Dentz Date: Mon, 18 Mar 2024 17:38:10 +0000 Message-ID: Subject: Re: [PATCH BlueZ v4 3/5] bap: Broadcast source reconfiguration support added To: Silviu Florian Barbulescu Cc: linux-bluetooth@vger.kernel.org, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, iulia.tanasescu@nxp.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Silviu, On Mon, Mar 18, 2024 at 4:39=E2=80=AFPM Silviu Florian Barbulescu wrote: > > If a BIS is reconfigured, the metadata and codec capabilities are updated= . > Also, the BASE is updated to reflect the update. > > --- > profiles/audio/bap.c | 76 ++++++++++++++++++++++++++++++++++++++ > profiles/audio/transport.c | 6 ++- > src/shared/bap.c | 11 +++++- > 3 files changed, 91 insertions(+), 2 deletions(-) > > diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c > index 964ba9c21..e508e03ba 100644 > --- a/profiles/audio/bap.c > +++ b/profiles/audio/bap.c > @@ -580,6 +580,11 @@ static int setup_parse_bcast_qos(struct bap_setup *s= etup, const char *key, > return -EINVAL; > > dbus_message_iter_get_basic(iter, &qos->bcast.big); > + } else if (!strcasecmp(key, "BIS")) { > + if (var !=3D DBUS_TYPE_BYTE) > + return -EINVAL; > + > + dbus_message_iter_get_basic(iter, &qos->bcast.bis); > } else if (!strcasecmp(key, "Options")) { > if (var !=3D DBUS_TYPE_BYTE) > return -EINVAL; > @@ -884,6 +889,53 @@ static void setup_free(void *data) > free(setup); > } > > +static void iterate_setups(struct bap_setup *setup) > +{ > + const struct queue_entry *entry; > + struct bap_setup *ent_setup; > + uint8_t bis_cnt =3D 1; > + > + for (entry =3D queue_get_entries(setup->ep->setups); > + entry; entry =3D entry->next) { > + ent_setup =3D entry->data; > + > + if (setup->qos.bcast.big !=3D ent_setup->qos.bcast.big) > + continue; > + > + util_iov_free(ent_setup->base, 1); > + ent_setup->base =3D NULL; I do wonder why we need to store the base as part of the setup? Can't we just generate it later when it is actually about to be configured into the socket like I did? > + if (setup->qos.bcast.bis =3D=3D bis_cnt) { > + bt_bap_stream_config(ent_setup->stream, &setup->q= os, > + setup->caps, NULL, NULL); > + bt_bap_stream_metadata(ent_setup->stream, > + setup->metadata, NULL, NULL); > + } > + > + bis_cnt++; > + } > +} > + > +static bool verify_state(struct bap_setup *setup) > +{ > + const struct queue_entry *entry; > + struct bap_setup *ent_setup; > + > + for (entry =3D queue_get_entries(setup->ep->setups); > + entry; entry =3D entry->next) { > + ent_setup =3D entry->data; > + > + if (setup->qos.bcast.big !=3D ent_setup->qos.bcast.big) > + continue; > + > + if (bt_bap_stream_get_state(ent_setup->stream) =3D=3D > + BT_BAP_STREAM_STATE_STREAMING) > + return false; > + } > + > + return true; > +} > + > static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage = *msg, > void *dat= a) > { > @@ -925,6 +977,30 @@ static DBusMessage *set_configuration(DBusConnection= *conn, DBusMessage *msg, > util_iov_free(setup->metadata, 1); > setup->metadata =3D util_iov_dup( > bt_bap_pac_get_metadata(ep->rpac), 1); > + } else if (bt_bap_pac_get_type(ep->lpac) =3D=3D BT_BAP_BCAST_SOUR= CE) { > + if (setup->qos.bcast.bis !=3D BT_ISO_QOS_BIS_UNSET) { > + if ((setup->qos.bcast.bis > queue_length(ep->setu= ps)) || > + (setup->qos.bcast.bis =3D=3D 0)) = { > + setup_free(setup); > + return btd_error_invalid_args(msg); > + } > + > + /* Verify that no BIS in the BIG is in streaming = state > + */ > + if (!verify_state(setup)) { > + setup_free(setup); > + return btd_error_not_permitted(msg, > + "Broadcast Audio Stream s= tate is invalid"); > + } I was thinking we could delay the BASE setup until later when the code actually needs it then the code for stream_get_base can actually detect what are the streams with the same BIG and generate the BASE just once. > + /* Find and update the BIS specified in > + * set_configuration command > + */ > + iterate_setups(setup); > + > + setup_free(setup); > + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID= ); > + } > } > > setup->stream =3D bt_bap_stream_new(ep->data->bap, ep->lpac, ep->= rpac, > diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c > index 122c3339e..a060f8c61 100644 > --- a/profiles/audio/transport.c > +++ b/profiles/audio/transport.c > @@ -1643,8 +1643,12 @@ static void bap_state_changed(struct bt_bap_stream= *stream, uint8_t old_state, > bap_update_links(transport); > if (!media_endpoint_is_broadcast(transport->endpoint)) > bap_update_qos(transport); > - else if (bt_bap_stream_io_dir(stream) !=3D BT_BAP_BCAST_S= OURCE) > + else if (bt_bap_stream_io_dir(stream) !=3D BT_BAP_BCAST_S= OURCE) { > bap_update_bcast_qos(transport); > + if (old_state =3D=3D BT_BAP_STREAM_STATE_QOS) > + bap_update_bcast_config(transport); > + } > + > transport_update_playing(transport, FALSE); > return; > case BT_BAP_STREAM_STATE_DISABLING: > diff --git a/src/shared/bap.c b/src/shared/bap.c > index fd99cbbca..603d6d646 100644 > --- a/src/shared/bap.c > +++ b/src/shared/bap.c > @@ -1701,7 +1701,16 @@ static unsigned int bap_bcast_config(struct bt_bap= _stream *stream, > struct bt_bap_qos *qos, struct iovec= *data, > bt_bap_stream_func_t func, void *use= r_data) > { > - stream->qos =3D *qos; > + if (qos) { > + stream->qos =3D *qos; > + stream->qos.bcast.bcode =3D util_iov_dup(qos->bcast.bcode= , 1); > + } > + > + if (data) { > + util_iov_free(stream->cc, 1); > + stream->cc =3D util_iov_dup(data, 1); > + } > + > stream->lpac->ops->config(stream, stream->cc, &stream->qos, > ep_config_cb, stream->lpac->user_data); > > -- > 2.39.2 These changes to shared/bap shall be submitted in a separate patch with a proper description. --=20 Luiz Augusto von Dentz