Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7863196rdb; Thu, 4 Jan 2024 09:55:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiOzfKVE0BJmF0r2Y91CGV4mP8v1A3omrJGQmwbhZWecHZMfRxsDxXqBJiC/qVJMBhWyiC X-Received: by 2002:a05:6870:c0e:b0:204:2951:2f95 with SMTP id le14-20020a0568700c0e00b0020429512f95mr1162191oab.67.1704390943806; Thu, 04 Jan 2024 09:55:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704390943; cv=none; d=google.com; s=arc-20160816; b=cXFtXJFOm3bvTXW9eTp8Xzu7LR2RQ+RjTpy9noKN4kmaaV5dK0z3LKBp4msZmPvIPx QsGdLqCwNaMKc4Ctq1zErQKmVUngOc76JCZy65hIbTQTUPEytLjUk/6naj8KHPYDW5TN T9NXYryWirSCAvBll25Fx6JH2SgfZFWYDozjNl+6yEnSrQLikIRdKDDu1juulsVB4yfv U0nc4XnGCNpq0q1dii9HcO/9oAucnILqT2Yo35GHzp50A5DswouJb+72qR5pT7rNlGE6 m6ZRiWAdyWk6eXHk8qaHeCCH+zBGM3/kpLZJTNy5nuonvlB1io19pCgr7y3X1Ddup4J5 DQnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature; bh=6kVcIBmBp9fKGH9/SteJ33s3BaeBj1aenXaldVnphgQ=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=hiqy10xQh8qQzQHLlXfKCETD6HywUg9nd/DbZYjQPGNxZOvoS0zwelQmM/M2lnCGf1 D8hPgvh4xPKGfOTtJUhNADp/rXMmuK6w7GxuswaVgkpGIfPE4bSPA9ys1gYfO4JFEjku 2ct3hygrUOWoGEef3dqw+G3kmw5BRkguTia/NpKAzMf9rhqRCkQ9UOfgM/1LxeR/1JjE 5uJKvBAWrkjEracqPHBBFQQCb65B7A73yk+oZXIGyDP4KdxR3UMpiyfhNYPzYNNP7T2i Z64FXb8LMgcY3K/r7vhx52LP/VvZC1zEAe9pzMOav25d08gB05/pDrOzgCL4DZ5P3goH 1vpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="MbXUi9/D"; spf=pass (google.com: domain of linux-bluetooth+bounces-894-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-894-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 s7-20020a656907000000b005ce4b19c30csi13709685pgq.519.2024.01.04.09.55.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 09:55:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-894-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="MbXUi9/D"; spf=pass (google.com: domain of linux-bluetooth+bounces-894-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-894-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 67E59286BE9 for ; Thu, 4 Jan 2024 17:55:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98FDA28DB0; Thu, 4 Jan 2024 17:55:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MbXUi9/D" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 A7F5728DA0 for ; Thu, 4 Jan 2024 17:55:34 +0000 (UTC) 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-yw1-f179.google.com with SMTP id 00721157ae682-5e7c1012a42so7799177b3.3 for ; Thu, 04 Jan 2024 09:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704390932; x=1704995732; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=6kVcIBmBp9fKGH9/SteJ33s3BaeBj1aenXaldVnphgQ=; b=MbXUi9/D9Ayzo7vmb6cDXQSrXYy5USaJAKdjMT4RhbyeYnPEEDB0ssWZUMFJqRCZT8 +nVcD9gFNENgeKk40yPEiQfO85kuQh2vQG8cqqWtiuz8jPLr1eLwmGsobZxYrWF63leh mjAisK+HOuK2NrTqPb0islx6FmBL8C+N/1lZgToqr2vWObwWeCQJJzyrXOa6+bO4EH1J 7Hgh1tnK1eShhUOjjeNlJVMRhLKjkQQhtQyDZkV/uKn23XikB0cZGEFUzDeRKRmbNrUM b0YQ0RYBv0kNf5vAMrKy9sfckSjc9FMhQDjEDIwbXtDS8SobAgaXv0/q8CCVZGeCEFJn po+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704390932; x=1704995732; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6kVcIBmBp9fKGH9/SteJ33s3BaeBj1aenXaldVnphgQ=; b=T1jDkLgdBFVEluk0YNfX62N6srtSAgzbpmgWAv6IYjuUpLq9hM/m4laFE8BNTr3K98 ax62XAF/b2deArwLJ+P3tLhN6f2W97L7oiBcuko069MlpcS52qamAYfb3WsAqoYt9jzy 42fanWWyVk8SYPGNs1ZhCcwQlysFiflM5fr3KrDz9/1mExntJWjnS5ca05LWyzFoyOFq uOrhblMP1yUitc1Wgx5ZSdDnBxFE5qfPYbqoGQ1H914GcbGfkuYlFj510c6UbCm79Ict v9kfr6r7SMHe0yE8Evtmzx6HDMPw3DN/QcOTBmT3QrHZUmvZKO/0R8yq0xoEj+GiYhJR EJfg== X-Gm-Message-State: AOJu0Yza59px/nKUhsVOq1WQblgjV1mp2M4lkgRNer/5GxeKmjTYIk1C ixXrWnqC2JCPDefu1NUrW3MqTT50/WY= X-Received: by 2002:a81:6d54:0:b0:5f3:dd8d:4646 with SMTP id i81-20020a816d54000000b005f3dd8d4646mr948765ywc.81.1704390932277; Thu, 04 Jan 2024 09:55:32 -0800 (PST) Received: from lvondent-mobl4.. (071-047-239-151.res.spectrum.com. [71.47.239.151]) by smtp.gmail.com with ESMTPSA id bz9-20020a05690c084900b005ecd8995666sm9631765ywb.59.2024.01.04.09.55.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 09:55:31 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1] client/player: Adjust the SDU size based on the number of locations Date: Thu, 4 Jan 2024 12:55:30 -0500 Message-ID: <20240104175530.4011031-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz If there are multiple locations, aka. multiplexing, being selected then that should be accounted properly on the SDU size since the presets only account for just 1 channel. Fixes: https://github.com/bluez/bluez/issues/662 --- client/player.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/client/player.c b/client/player.c index 92fc91f920f3..dad243786a39 100644 --- a/client/player.c +++ b/client/player.c @@ -1860,7 +1860,7 @@ struct endpoint_config { struct iovec *caps; struct iovec *meta; uint8_t target_latency; - const struct codec_qos *qos; + struct codec_qos qos; }; #define BCODE {0x01, 0x02, 0x68, 0x05, 0x53, 0xf1, 0x41, 0x5a, \ @@ -1886,7 +1886,7 @@ static struct bt_iso_qos bcast_qos = { static void append_io_qos(DBusMessageIter *iter, struct endpoint_config *cfg) { - struct codec_qos *qos = (void *)cfg->qos; + struct codec_qos *qos = &cfg->qos; bt_shell_printf("Interval %u\n", qos->interval); @@ -1897,7 +1897,7 @@ static void append_io_qos(DBusMessageIter *iter, struct endpoint_config *cfg) g_dbus_dict_append_entry(iter, "PHY", DBUS_TYPE_BYTE, &qos->phy); - bt_shell_printf("SDU %u\n", cfg->qos->sdu); + bt_shell_printf("SDU %u\n", qos->sdu); g_dbus_dict_append_entry(iter, "SDU", DBUS_TYPE_UINT16, &qos->sdu); @@ -1914,7 +1914,7 @@ static void append_io_qos(DBusMessageIter *iter, struct endpoint_config *cfg) static void append_ucast_qos(DBusMessageIter *iter, struct endpoint_config *cfg) { - struct codec_qos *qos = (void *)cfg->qos; + struct codec_qos *qos = &cfg->qos; if (cfg->ep->iso_group != BT_ISO_QOS_GROUP_UNSET) { bt_shell_printf("CIG 0x%2.2x\n", cfg->ep->iso_group); @@ -2020,7 +2020,7 @@ static void append_bcast_qos(DBusMessageIter *iter, struct endpoint_config *cfg) static void append_qos(DBusMessageIter *iter, struct endpoint_config *cfg) { DBusMessageIter entry, var, dict; - struct codec_qos *qos = (void *)cfg->qos; + struct codec_qos *qos = &cfg->qos; const char *key = "QoS"; if (!qos) @@ -2104,7 +2104,8 @@ static struct iovec *iov_append(struct iovec **iov, const void *data, return *iov; } -static int parse_chan_alloc(DBusMessageIter *iter, uint32_t *location) +static int parse_chan_alloc(DBusMessageIter *iter, uint32_t *location, + uint8_t *channels) { while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_DICT_ENTRY) { const char *key; @@ -2123,6 +2124,8 @@ static int parse_chan_alloc(DBusMessageIter *iter, uint32_t *location) if (var != DBUS_TYPE_UINT32) return -EINVAL; dbus_message_iter_get_basic(&value, location); + if (*channels) + *channels = __builtin_popcount(*location); return 0; } @@ -2140,6 +2143,7 @@ static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep, DBusMessageIter iter, props; struct endpoint_config *cfg; uint32_t location = 0; + uint8_t channels = 1; if (!preset) return NULL; @@ -2158,7 +2162,7 @@ static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep, dbus_message_iter_init(msg, &iter); dbus_message_iter_recurse(&iter, &props); - if (!parse_chan_alloc(&props, &location)) { + if (!parse_chan_alloc(&props, &location, &channels)) { uint8_t chan_alloc_ltv[] = { 0x05, LC3_CONFIG_CHAN_ALLOC, location & 0xff, location >> 8, location >> 16, location >> 24 @@ -2171,9 +2175,15 @@ static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep, if (ep->meta) iov_append(&cfg->meta, ep->meta->iov_base, ep->meta->iov_len); - if (preset->qos.phy) + if (preset->qos.phy) { /* Set QoS parameters */ - cfg->qos = &preset->qos; + cfg->qos = preset->qos; + /* Adjust the SDU size based on the number of + * locations/channels that is being requested. + */ + if (channels > 1) + cfg->qos.sdu *= channels; + } dbus_message_iter_init_append(reply, &iter); @@ -3177,7 +3187,7 @@ static void cmd_config_endpoint(int argc, char *argv[]) } /* Set QoS parameters */ - cfg->qos = &preset->qos; + cfg->qos = preset->qos; endpoint_set_config(cfg); return; -- 2.43.0