From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v6 6/6] client/player: Use ChannelAllocation given on SelectProperties
Date: Thu, 14 Dec 2023 15:55:56 -0500 [thread overview]
Message-ID: <20231214205556.1320286-6-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20231214205556.1320286-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes use of ChannelAllocation when present on SelectProperties
dictionary which is then passed on to bluetoothd and send over as part
of Codec Configuration:
< ACL Data TX: Handle 2048 flags 0x00 dlen 109
ATT: Write Command (0x52) len 104
Handle: 0x0098 Type: ASE Control Point (0x2bc6)
Data: 0104050202060000000010020103020201030428000503010000000
6020206000000001002010302020103042800050302000000010202060000
0000100201030202010304280005030100000002020206000000001002010
302020103042800050302000000
Opcode: Codec Configuration (0x01)
Number of ASE(s): 4
ASE: #0
ASE ID: 0x05
Target Latency: Balance Latency/Reliability (0x02)
PHY: 0x02
LE 2M PHY (0x02)
Codec: LC3 (0x06)
Codec Specific Configuration: #0: len 0x02 type 0x01
Sampling Frequency: 16 Khz (0x03)
Codec Specific Configuration: #1: len 0x02 type 0x02
Frame Duration: 10 ms (0x01)
Codec Specific Configuration: #2: len 0x03 type 0x04
Frame Length: 40 (0x0028)
Codec Specific Configuration: #3: len 0x05 type 0x03
Location: 0x00000001
Front Left (0x00000001)
ASE: #1
ASE ID: 0x06
Target Latency: Balance Latency/Reliability (0x02)
PHY: 0x02
LE 2M PHY (0x02)
Codec: LC3 (0x06)
Codec Specific Configuration: #0: len 0x02 type 0x01
Sampling Frequency: 16 Khz (0x03)
Codec Specific Configuration: #1: len 0x02 type 0x02
Frame Duration: 10 ms (0x01)
Codec Specific Configuration: #2: len 0x03 type 0x04
Frame Length: 40 (0x0028)
Codec Specific Configuration: #3: len 0x05 type 0x03
Location: 0x00000002
Front Right (0x00000002)
ASE: #2
ASE ID: 0x01
Target Latency: Balance Latency/Reliability (0x02)
PHY: 0x02
LE 2M PHY (0x02)
Codec: LC3 (0x06)
Codec Specific Configuration: #0: len 0x02 type 0x01
Sampling Frequency: 16 Khz (0x03)
Codec Specific Configuration: #1: len 0x02 type 0x02
Frame Duration: 10 ms (0x01)
Codec Specific Configuration: #2: len 0x03 type 0x04
Frame Length: 40 (0x0028)
Codec Specific Configuration: #3: len 0x05 type 0x03
Location: 0x00000001
Front Left (0x00000001)
ASE: #3
ASE ID: 0x02
Target Latency: Balance Latency/Reliability (0x02)
PHY: 0x02
LE 2M PHY (0x02)
Codec: LC3 (0x06)
Codec Specific Configuration: #0: len 0x02 type 0x01
Sampling Frequency: 16 Khz (0x03)
Codec Specific Configuration: #1: len 0x02 type 0x02
Frame Duration: 10 ms (0x01)
Codec Specific Configuration: #2: len 0x03 type 0x04
Frame Length: 40 (0x0028)
Codec Specific Configuration: #3: len 0x05 type 0x03
Location: 0x00000002
Front Right (0x00000002)
---
client/player.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/client/player.c b/client/player.c
index 4d49602c70d7..92fc91f920f3 100644
--- a/client/player.c
+++ b/client/player.c
@@ -64,7 +64,7 @@
#define SEC_USEC(_t) (_t * 1000000L)
#define TS_USEC(_ts) (SEC_USEC((_ts)->tv_sec) + NSEC_USEC((_ts)->tv_nsec))
-#define EP_SRC_LOCATIONS 0x00000001
+#define EP_SRC_LOCATIONS 0x00000003
#define EP_SNK_LOCATIONS 0x00000003
#define EP_SRC_CTXT 0x000f
@@ -2104,13 +2104,42 @@ static struct iovec *iov_append(struct iovec **iov, const void *data,
return *iov;
}
+static int parse_chan_alloc(DBusMessageIter *iter, uint32_t *location)
+{
+ while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_DICT_ENTRY) {
+ const char *key;
+ DBusMessageIter value, entry;
+ int var;
+
+ dbus_message_iter_recurse(iter, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &value);
+
+ var = dbus_message_iter_get_arg_type(&value);
+
+ if (!strcasecmp(key, "ChannelAllocation")) {
+ if (var != DBUS_TYPE_UINT32)
+ return -EINVAL;
+ dbus_message_iter_get_basic(&value, location);
+ return 0;
+ }
+
+ dbus_message_iter_next(iter);
+ }
+
+ return -EINVAL;
+}
+
static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep,
DBusMessage *msg,
struct codec_preset *preset)
{
DBusMessage *reply;
- DBusMessageIter iter;
+ DBusMessageIter iter, props;
struct endpoint_config *cfg;
+ uint32_t location = 0;
if (!preset)
return NULL;
@@ -2126,6 +2155,18 @@ static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep,
iov_append(&cfg->caps, preset->data.iov_base, preset->data.iov_len);
cfg->target_latency = preset->target_latency;
+ dbus_message_iter_init(msg, &iter);
+ dbus_message_iter_recurse(&iter, &props);
+
+ if (!parse_chan_alloc(&props, &location)) {
+ uint8_t chan_alloc_ltv[] = {
+ 0x05, LC3_CONFIG_CHAN_ALLOC, location & 0xff,
+ location >> 8, location >> 16, location >> 24
+ };
+
+ iov_append(&cfg->caps, &chan_alloc_ltv, sizeof(chan_alloc_ltv));
+ }
+
/* Copy metadata */
if (ep->meta)
iov_append(&cfg->meta, ep->meta->iov_base, ep->meta->iov_len);
--
2.43.0
next prev parent reply other threads:[~2023-12-14 20:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 20:55 [PATCH BlueZ v6 1/6] bap: Allow setup of multiple stream per endpoint Luiz Augusto von Dentz
2023-12-14 20:55 ` [PATCH BlueZ v6 2/6] shared/bap: Make bt_bap_select match the channel map Luiz Augusto von Dentz
2023-12-14 20:55 ` [PATCH BlueZ v6 3/6] org.bluez.MediaEndpoint: Add ChannelAllocation to SelectProperties Luiz Augusto von Dentz
2023-12-14 20:55 ` [PATCH BlueZ v6 4/6] shared/bap: Make bt_bap_select select a location Luiz Augusto von Dentz
2023-12-14 20:55 ` [PATCH BlueZ v6 5/6] shared/bap: Fix stream IO linking Luiz Augusto von Dentz
2023-12-14 20:55 ` Luiz Augusto von Dentz [this message]
2023-12-14 23:04 ` [BlueZ,v6,1/6] bap: Allow setup of multiple stream per endpoint bluez.test.bot
2023-12-15 20:50 ` [PATCH BlueZ v6 1/6] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231214205556.1320286-6-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).