All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1 1/2] client/player: Set number of channels based on locations
@ 2024-07-22 20:51 Luiz Augusto von Dentz
  2024-07-22 20:51 ` [PATCH BlueZ v1 2/2] client/player: Add support to enter alternative preset Luiz Augusto von Dentz
  2024-07-22 23:07 ` [BlueZ,v1,1/2] client/player: Set number of channels based on locations bluez.test.bot
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2024-07-22 20:51 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This sets the number of channels based on the locations set rather than
always hardcoding it to 3 which in certain case is incorrect and can
lead for the same location to be configured multiple times.
---
 client/player.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/client/player.c b/client/player.c
index 5b0b918fb8d7..486629a9add2 100644
--- a/client/player.c
+++ b/client/player.c
@@ -1140,10 +1140,9 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn,
 		.meta = _meta, \
 	}
 
-#define LC3_DATA(_freq, _duration, _chan_count, _len_min, _len_max) \
+#define LC3_DATA(_freq, _duration, _len_min, _len_max) \
 	UTIL_IOV_INIT(0x03, LC3_FREQ, _freq, _freq >> 8, \
 			0x02, LC3_DURATION, _duration, \
-			0x02, LC3_CHAN_COUNT, _chan_count, \
 			0x05, LC3_FRAME_LEN, _len_min, _len_min >> 8, \
 			_len_max, _len_max >> 8)
 
@@ -1182,11 +1181,10 @@ static const struct capabilities {
 	 *
 	 * Frequencies: 8Khz 11Khz 16Khz 22Khz 24Khz 32Khz 44.1Khz 48Khz
 	 * Duration: 7.5 ms 10 ms
-	 * Channel count: 3
 	 * Frame length: 26-240
 	 */
 	CODEC_CAPABILITIES("pac_snk/lc3", PAC_SINK_UUID, LC3_ID,
-				LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, 3u, 26,
+				LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, 26,
 					240),
 				UTIL_IOV_INIT()),
 
@@ -1198,7 +1196,7 @@ static const struct capabilities {
 	 * Frame length: 26-240
 	 */
 	CODEC_CAPABILITIES("pac_src/lc3", PAC_SOURCE_UUID, LC3_ID,
-				LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, 3u, 26,
+				LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, 26,
 					240),
 				UTIL_IOV_INIT()),
 
@@ -1210,7 +1208,7 @@ static const struct capabilities {
 	 * Frame length: 26-240
 	 */
 	CODEC_CAPABILITIES("bcaa/lc3", BCAA_SERVICE_UUID, LC3_ID,
-				LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, 3u, 26,
+				LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, 26,
 					240),
 				UTIL_IOV_INIT()),
 
@@ -1222,7 +1220,7 @@ static const struct capabilities {
 	 * Frame length: 26-240
 	 */
 	CODEC_CAPABILITIES("baa/lc3", BAA_SERVICE_UUID, LC3_ID,
-				LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, 3u, 26,
+				LC3_DATA(LC3_FREQ_ANY, LC3_DURATION_ANY, 26,
 					240),
 				UTIL_IOV_INIT()),
 };
@@ -3220,6 +3218,7 @@ static void endpoint_locations(const char *input, void *user_data)
 	struct endpoint *ep = user_data;
 	char *endptr = NULL;
 	int value;
+	uint8_t channels;
 
 	value = strtol(input, &endptr, 0);
 
@@ -3230,6 +3229,10 @@ static void endpoint_locations(const char *input, void *user_data)
 
 	ep->locations = value;
 
+	/* Update LC3_CHAN_COUNT based on the locations */
+	channels = __builtin_popcount(value);
+	util_ltv_push(ep->caps, sizeof(channels), LC3_CHAN_COUNT, &channels);
+
 	bt_shell_prompt_input(ep->path, "Supported Context (value):",
 				endpoint_supported_context, ep);
 }
@@ -4186,6 +4189,8 @@ static const struct bt_shell_menu endpoint_menu = {
 
 static void endpoint_init_bcast(struct endpoint *ep)
 {
+	uint8_t channels;
+
 	if (!strcmp(ep->uuid, BAA_SERVICE_UUID)) {
 		ep->locations = EP_SNK_LOCATIONS;
 		ep->supported_context = EP_SUPPORTED_SNK_CTXT;
@@ -4193,6 +4198,10 @@ static void endpoint_init_bcast(struct endpoint *ep)
 		ep->locations = EP_SRC_LOCATIONS;
 		ep->supported_context = EP_SUPPORTED_SRC_CTXT;
 	}
+
+	/* Update LC3_CHAN_COUNT based on the locations */
+	channels = __builtin_popcount(ep->locations);
+	util_ltv_push(ep->caps, sizeof(channels), LC3_CHAN_COUNT, &channels);
 }
 
 static void endpoint_init_ucast(struct endpoint *ep)
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-22 23:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-22 20:51 [PATCH BlueZ v1 1/2] client/player: Set number of channels based on locations Luiz Augusto von Dentz
2024-07-22 20:51 ` [PATCH BlueZ v1 2/2] client/player: Add support to enter alternative preset Luiz Augusto von Dentz
2024-07-22 23:07 ` [BlueZ,v1,1/2] client/player: Set number of channels based on locations bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.