Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6123767rdb; Thu, 14 Dec 2023 08:55:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEz4KG68PHXr+cB0zq29fGCg0Oi/syuzaGPIi5EThYoQEwxd9FxSpYRoJS102IwO1Ts223i X-Received: by 2002:a17:906:7488:b0:a22:e2d7:9e5c with SMTP id e8-20020a170906748800b00a22e2d79e5cmr2148006ejl.17.1702572937618; Thu, 14 Dec 2023 08:55:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702572937; cv=pass; d=google.com; s=arc-20160816; b=XTacl8ddvLhMASvEQCxiAfPpf9ra9HzkemHjhx0DZA8mJZwHC8CpuFymPq8Xt08DUB CoWdwe+SFVV+OpQg1mPDvVLTi/89NXhd4lrY7f4Qt7J/X8IGIPm344i0dS3/szYHxTRw gTEOYot6DF/nDBgGKbTw8FhXo5XhwcP2nmnnp+7w7W57JMrOh/y0PpzQ/tmQjx2p7Eie LHtrmcqzyTDaEC5O+OZ8gnZzsu42ZYVRG84+VH7yTcvn9raTCh2J/2USvcR6dY49oI/E em4nj+P3BL6HJCPenh3GiEZzl7U/LZjLdl9HumDuE/6QXGxkseE6uQtrl6wa4YOMEdj3 wlTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:autocrypt:references :in-reply-to:date:to:from:subject:message-id:dkim-signature; bh=/qLcC+OjSMj1sv51SLAUZNNnRFrqCu+n3okXya4P46Y=; fh=HK6t0SFPvSh88TNcprQy3ad2PhCK0eaoptA9zvoG5Hg=; b=SJJNJesjtT9K69oJlfNNHuo/C4M2NCBhiKeexTSsCVT16/OJqRy2zpPaFmsCiS9IsG TTph4Z0SovQ4khnFtxiltTSGXnMgi0p+60lmXJLca9UT9Wd5zIShqKJ31IivS7dWo45T z6TyArhASS9ojO165JivNrbu8Lf9/UXaVJgTZ/ISzRTP+uKzwY3DaxT7DT25e8r8qphh dQW67bNYbLS1a0ldX/KbnJK3jD5zugMkJpec/0fcdWyTLcq3Ze80OPrCBsiT0dx3e5Yb 47l0n0fJ63FmY48beXg7+wyMy2I4by74u0Z7tyC6rWEGs4d2uVRVGq+F8WVLoUhqxCL2 xLCA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b=uFG8+Tom; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth+bounces-594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-594-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dk24-20020a170906f0d800b00a1db8d8e75csi6826181ejb.31.2023.12.14.08.55.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 08:55:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b=uFG8+Tom; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth+bounces-594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-594-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 399101F2181F for ; Thu, 14 Dec 2023 16:55:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2583961FD9; Thu, 14 Dec 2023 16:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b="uFG8+Tom" X-Original-To: linux-bluetooth@vger.kernel.org Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28CFA8E for ; Thu, 14 Dec 2023 08:55:24 -0800 (PST) Received: from [192.168.1.195] (unknown [IPv6:2a0c:f040:0:2790::a01d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav@iki.fi) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4Srdkw6bvCz49Q3t; Thu, 14 Dec 2023 18:55:20 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1702572921; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=/qLcC+OjSMj1sv51SLAUZNNnRFrqCu+n3okXya4P46Y=; b=uFG8+Tome4Ugvnrda2GShGrfect97Fi/rXN8mkKd9DE9z1DQWUyGpX4o96C6gj28ILA74S aGWnbMsLESA5Nl3hjfum1y55g7TfLnKrT9F8+fraZLQMhkKjkPDfmhaW4edrZISAO2meXy u4fMUMpV5YhKzWhpMiYgkWTHIoKTlMBjgQHpONZCJDQdKdHJiNihdkBrhJOXA3o6Up2KG+ 36ubACx0RXap2o0rw4dmeFwWh1zg6qUcsi3jL3ZANnQywZMdY6V3IupxFKPX4e3zg+AkHg SBNam6qVdjdoNEyvMZX2D4ifU2yEngw/X8tN000x/Wgq471DQ5n0K3S65AhwWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1702572921; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=/qLcC+OjSMj1sv51SLAUZNNnRFrqCu+n3okXya4P46Y=; b=vWdjvG+yENO8MG7Nh/lOF+t6YAb62YGteM0XOXlUtbeHgHOWm6h6qo/YhHnIUIINy8OPJd v4ECNqFRqAIN86GnppsDPD06rcRJHqjSZK/fgunDwQYoAErgUuxvks8hkGh1FaWGWoXXbE 0110nlohswRtHHe9ysoZp5Kcq0WjrX3v5nye40gXDmJrll6R942divqwMuzCTY5ANDI9kp yaCZebPTibbw+VynYCSl+Yv+CkXtHfO3XC8u7FsfZbMjGyfT+zZ06OXMOKQi5iJvKQ6hzf 1HRIVYoLaYVjK3LbDPRoQFbnsPDtIOeAcVVqDSwfeausGs19tbAzDP1outQgaA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav@iki.fi smtp.mailfrom=pav@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1702572921; a=rsa-sha256; cv=none; b=CV+neXU5/fBmxBNk8mEK+4APevtIRzfr22k7RTZi8Wk5Pr8nZVxOfMxwKLJHCItzNkNN8d X9QI5PchIjjL29IlSLL52sOHQy5drrjqd6g/M05sfuVTaCF5aOc51chnz3mtvrQ6ykfukL NnDdGq9GUXlUpicJ6X2ZMXL+7oDpSXxXpFFzde4I03qH6qziXBkzHAdiJndITl3wFsaYOu zapDEUIfpSTOnDk1B/lXlaK4nWTyNh25e2bf5pQAxpoXBzgyAx4j7Ej32wIKozsgcsSI1q 4DBGYtJnLprMhEP6B0EG5Rg1vYNCGx5L1XvlhYbbHZEHtSqrOnL29ixQrzYm+Q== Message-ID: Subject: Re: [PATCH BlueZ v4 4/6] shared/bap: Make bt_bap_select select a location From: Pauli Virtanen To: Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org Date: Thu, 14 Dec 2023 18:55:17 +0200 In-Reply-To: <20231211212516.577426-4-luiz.dentz@gmail.com> References: <20231211212516.577426-1-luiz.dentz@gmail.com> <20231211212516.577426-4-luiz.dentz@gmail.com> Autocrypt: addr=pav@iki.fi; prefer-encrypt=mutual; keydata=mQGiBDuWdUoRBAD5TV1PNJbFxQRmG3moFyJT74l8/6ailvCjgIzwl6Umi4oaDsrogD+myums6lgYe+J2kmbe1Sk2MiOdWzRgY+HbrW5tr8UV+hmNg88gMz9gl2ygWHgG/CSa53Zn+R6TmXXL23KafCYOWH2NKaXxU31c/0Da+yEI+AgkrW8nCOMeFwCgzuJK2qqKtjLqh7Iukt1Urxdp1IUEAMFVHx9TPoFEk4OsuWJRunn7cylFsI/FQlXqXa4GHwhA5zKTMJHo6aX8ITQlnZfdZuxBWF2bmdK2/CRzp0dirJw+f4Qa163kaH2gTq5b+xZXF56xgYMO3wgANtDG1ZKBmYpnV7lFPYpbuNuR0JpksBL5G1Ml3WGblpb4EWtVNrWfA/91HylTGtZnNIxI8iJUjDN0uPHgPVM90C/bU2Ll3i3UpyuXwSFIJq00+bxGQh/wWa50G6GvrBStzhAXdQ1xQRusQBppFByjCpVpzkCyV6POe74pa4m88PRhXKlj2MKWbWjxZeU88sAWhFx5u79Cs6imTSckOCyg0eiO4ca1TLZOGbQbUGF1bGkgVmlydGFuZW4gPHBhdkBpa2kuZmk+iIEEExEKAEECGyMCHgECF4ACGQEFCwkIBwMFFQoJCAsFFgIDAQAWIQSfjAgX4lc0PoQd+D3oFDFvs7SlYAUCWZ8gRwUJHgn8fQAKCRDoFDFvs7SlYELXAJ47uNwB5yXTPDmAhIebcrlE0Ub0kgCdGAfxvoNmbwJwk1sAikf9H5FBBBC0I1BhdWxpIFZpcnRhbmVuIDxwdHZpcnRhbkBjYy5odXQuZmk+iEkEMBECAAkFAlIFBAACHSAACgkQ6BQxb7O0pWDfnACgrnO9z6UBQDTtzYqJzN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/s2WV/mgwQEJZqhdwBT+L/0mxqhuFMWuDnvkUzzBxLTM5a66SB4/JZtyQt14VSnRCuxBUaw/IUftK0ru3zIZjWFfLgHwSUwJCSy6oYwm7x2MAiKQUtAzpSfFJnwyQG2wK1uy6EpSjBX7YphlpKKv6UGiL0QuwWtXALrbI4EVbnozes89CaZHeE6zx/aDQgKa4ajInkIIvtOBmRqbvTPkJjcH84o7b84rP10DSO2Q2ooP8WYQ85y9RkF00yndR01VwNnURt7XmjVuoy8el0WUMv0q7evGTWSmXDPtUMq8e5DKt1uHWdkjV3uhHXjUTlI2gdMrxzbzxPYIWVWg4eE9jEdQvvGaYhDfFpmqF/ZSQT9jUCuWXMMpscy8NrmHnJtTvHBEfmaSgOQPnI7D7AA62q6mAVWEjcfKpgEs0Z2SK75P5yHmD2yEdZy+wSD8zheY1YDqvL50rx+l3mqoONmBwiW7R5dkMInqgQ156Uf8yMc8vv5exARr8WhJV61R2mSeHfxTFMMXaFG//NTHNX7ZpP0tECyePbu+IB32oa7P45EoNRZnLDG2KDOFsoUuy+CzQYPku5Gz8aqcgP7k8wb4J3QPPfiaAYrRJ9XOoiLUDodnWnPW9zLA1yWMnarzilEFPVmBztx6JKxlbFxnOfO6u5ry+uXZC4w= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.2 (3.50.2-1.fc39) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi, ma, 2023-12-11 kello 16:25 -0500, Luiz Augusto von Dentz kirjoitti: > > From: Luiz Augusto von Dentz > >=20 > > This makes bt_bap_select select a location based on the PAC channel > > count and PACS locations, this is then passed to the Endpoint as a > > recommended ChannelAllocation. > > --- > > profiles/audio/media.c | 6 ++- > > src/shared/bap.c | 88 +++++++++++++++++++++++++++--------------- > > src/shared/bap.h | 2 +- > > 3 files changed, 63 insertions(+), 33 deletions(-) > >=20 > > diff --git a/profiles/audio/media.c b/profiles/audio/media.c > > index 62f53defa7af..b17c555b63e4 100644 > > --- a/profiles/audio/media.c > > +++ b/profiles/audio/media.c > > @@ -921,7 +921,7 @@ done: > > } > > =20 > > static int pac_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac= , > > - struct bt_bap_pac_qos *qos, > > + uint32_t chan_alloc, struct bt_bap_pac_qos *qos, > > bt_bap_pac_select_t cb, void *cb_data, void *user_data) > > { > > struct media_endpoint *endpoint =3D user_data; > > @@ -969,6 +969,10 @@ static int pac_select(struct bt_bap_pac *lpac, str= uct bt_bap_pac *rpac, > > g_dbus_dict_append_entry(&dict, "Locations", DBUS_TYPE_UINT32, > > &loc); > > =20 > > + if (chan_alloc) > > + g_dbus_dict_append_entry(&dict, "ChannelAllocation", > > + DBUS_TYPE_UINT32, &chan_alloc); > > + > > if (metadata) { > > key =3D "Metadata"; > > g_dbus_dict_append_basic_array(&dict, DBUS_TYPE_STRING, &key, > > diff --git a/src/shared/bap.c b/src/shared/bap.c > > index cb505d1564d6..e1dad95aca99 100644 > > --- a/src/shared/bap.c > > +++ b/src/shared/bap.c > > @@ -177,6 +177,11 @@ struct bt_bap { > > void *user_data; > > }; > > =20 > > +struct bt_bap_chan { > > + uint8_t count; > > + uint32_t location; > > +}; > > + > > struct bt_bap_pac { > > struct bt_bap_db *bdb; > > char *name; > > @@ -185,7 +190,7 @@ struct bt_bap_pac { > > struct bt_bap_pac_qos qos; > > struct iovec *data; > > struct iovec *metadata; > > - struct queue *chan_map; > > + struct queue *channels; > > struct bt_bap_pac_ops *ops; > > void *user_data; > > }; > > @@ -2422,19 +2427,22 @@ static void bap_pac_foreach_channel(size_t i, u= int8_t l, uint8_t t, uint8_t *v, > > void *user_data) > > { > > struct bt_bap_pac *pac =3D user_data; > > + struct bt_bap_chan *chan; > > =20 > > if (!v) > > return; > > =20 > > - if (!pac->chan_map) > > - pac->chan_map =3D queue_new(); > > + if (!pac->channels) > > + pac->channels =3D queue_new(); > > =20 > > - printf("PAC %p chan_map 0x%02x\n", pac, *v); > > + chan =3D new0(struct bt_bap_chan, 1); > > + chan->count =3D *v; > > + chan->location =3D bt_bap_pac_get_locations(pac) ? : pac->qos.locatio= n; > > =20 > > - queue_push_tail(pac->chan_map, UINT_TO_PTR(*v)); > > + queue_push_tail(pac->channels, chan); > > } > > =20 > > -static void bap_pac_update_chan_map(struct bt_bap_pac *pac, struct iov= ec *data) > > +static void bap_pac_update_channels(struct bt_bap_pac *pac, struct iov= ec *data) > > { > > uint8_t type =3D 0x03; > > =20 > > @@ -2454,8 +2462,8 @@ static void bap_pac_merge(struct bt_bap_pac *pac,= struct iovec *data, > > else > > pac->data =3D util_iov_dup(data, 1); > > =20 > > - /* Update channel map */ > > - bap_pac_update_chan_map(pac, data); > > + /* Update channels */ > > + bap_pac_update_channels(pac, data); > > =20 > > /* Merge metadata into existing record */ > > if (pac->metadata) > > @@ -2495,7 +2503,7 @@ static void bap_pac_free(void *data) > > free(pac->name); > > util_iov_free(pac->metadata, 1); > > util_iov_free(pac->data, 1); > > - queue_destroy(pac->chan_map, NULL); > > + queue_destroy(pac->channels, free); > > free(pac); > > } > > =20 > > @@ -4677,34 +4685,52 @@ int bt_bap_select(struct bt_bap_pac *lpac, stru= ct bt_bap_pac *rpac, > > if (!lpac->ops || !lpac->ops->select) > > return -EOPNOTSUPP; > > =20 > > - for (lchan =3D queue_get_entries(lpac->chan_map); lchan; > > + for (lchan =3D queue_get_entries(lpac->channels); lchan; > > lchan =3D lchan->next) { > > - uint8_t lmap =3D PTR_TO_UINT(lchan->data); > > + struct bt_bap_chan *lc =3D lchan->data; > > + uint8_t lmap =3D lc->count; > > + int i; > > =20 > > - for (rchan =3D queue_get_entries(rpac->chan_map); rchan; > > - rchan =3D rchan->next) { > > - uint8_t rmap =3D PTR_TO_UINT(rchan->data); > > + printf("lmap 0x%02x\n", lmap); > > =20 > > - printf("lmap 0x%02x rmap 0x%02x\n", lmap, rmap); > > + for (i =3D 0, rchan =3D queue_get_entries(rpac->channels); rchan; > > + rchan =3D rchan->next, i++) { > > + struct bt_bap_chan *rc =3D rchan->data; > > =20 > > - /* Try matching the channel mapping */ > > - if (lmap & rmap) { > > - lpac->ops->select(lpac, rpac, &rpac->qos, > > - func, user_data, > > - lpac->user_data); > > - if (count) > > - (*count)++; > > + printf("rc->count 0x%02x\n", rc->count); > > =20 > > - /* Check if there are any channels left */ > > - lmap &=3D ~(lmap & rmap); > > - if (!lmap) > > - break; > > - > > - /* Check if device require AC*(i) settings */ > > - if (rmap =3D=3D 0x01) > > - lmap =3D lmap >> 1; > > - } else > > + /* Try matching the channel count */ > > + if (!(lmap & rc->count)) > > break; > > + > > + /* Check if location was set otherwise attempt to > > + * assign one based on the number of channels it > > + * supports. > > + */ > > + if (!rc->location) { > > + rc->location =3D bt_bap_pac_get_locations(rpac); > > + /* If channel count is 1 use a single > > + * location > > + */ > > + if (rc->count =3D=3D 0x01) > > + rc->location &=3D BIT(i); > > + } > > + > > + lpac->ops->select(lpac, rpac, lc->location & > > + rc->location, &rpac->qos, > > + func, user_data, > > + lpac->user_data); > > + if (count) > > + (*count)++; If sound server PAC supports both 1 and 2 channels, and remote PAC only support 1 channel, and two streams are set up: then it looks like sound server would be called two times with same ChannelAllocation so it'd likely set up two left channels. This code perhaps should first decide the bitmask of locations that will be set up, and then in each call to select() pass only the so far unallocated location bits. I'll try to find some time to set things up to test this in Pipewire, where we need some changes to enable multiple streams per device but it should be straightforward. > > + > > + /* Check if there are any channels left to select */ > > + lmap &=3D ~(lmap & rc->count); > > + if (!lmap) > > + break; > > + > > + /* Check if device require AC*(i) settings */ > > + if (rc->count =3D=3D 0x01) > > + lmap =3D lmap >> 1; > > } > > } > > =20 > > diff --git a/src/shared/bap.h b/src/shared/bap.h > > index 470313e66fc0..9be198cec72c 100644 > > --- a/src/shared/bap.h > > +++ b/src/shared/bap.h > > @@ -151,7 +151,7 @@ struct bt_bap_pac *bt_bap_add_pac(struct gatt_db *d= b, const char *name, > > =20 > > struct bt_bap_pac_ops { > > int (*select)(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, > > - struct bt_bap_pac_qos *qos, > > + uint32_t chan_alloc, struct bt_bap_pac_qos *qos, > > bt_bap_pac_select_t cb, void *cb_data, void *user_data); > > int (*config)(struct bt_bap_stream *stream, struct iovec *cfg, > > struct bt_bap_qos *qos, bt_bap_pac_config_t cb, --=20 Pauli Virtanen