linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set
@ 2021-11-19  9:42 Kiran K
  2021-11-19  9:42 ` [PATCH v2 2/9] shared/util: Decode MSFT offload codec UUID Kiran K
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Kiran K @ 2021-11-19  9:42 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: ravishankar.srivatsa, chethan.tumkur.narayan, luiz.von.dentz, Kiran K

This enables codec offload experimental feature if its UUIDs has been
enabled by main.conf:Experimental or -E has been passed in the command
line.
---
 src/adapter.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 src/main.c    |  1 +
 src/main.conf |  1 +
 3 files changed, 45 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 309956bbb5be..1627cc127057 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -142,6 +142,13 @@ static const struct mgmt_exp_uuid codec_offload_uuid = {
 	.str = "a6695ace-ee7f-4fb9-881a-5fac66c629af"
 };
 
+/* 0cc2131f-96f0-4cd1-b313-b97e7cbc8335 */
+static const struct mgmt_exp_uuid msft_a2dp_offload_codecs_uuid = {
+	.val = { 0x35, 0x83, 0xbc, 0x7c, 0x7e, 0xb9, 0x13, 0xb3,
+		0xd1, 0x4c, 0xf0, 0x96, 0x1f, 0x13, 0xc2, 0x0c},
+	.str = "0cc2131f-96f0-4cd1-b313-b97e7cbc8335"
+};
+
 static DBusConnection *dbus_conn = NULL;
 
 static uint32_t kernel_features = 0;
@@ -9789,6 +9796,41 @@ static void codec_offload_func(struct btd_adapter *adapter, uint8_t action)
 	btd_error(adapter->dev_id, "Failed to set Codec Offload");
 }
 
+static void msft_a2dp_offload_complete(uint8_t status, uint16_t len,
+				       const void *param, void *user_data)
+{
+	struct btd_adapter *adapter = user_data;
+	uint8_t action = btd_opts.experimental ? 0x01 : 0x00;
+
+	if (status != 0) {
+		error("Set MSFT a2dp offload codec failed with status 0x%02x (%s)",
+		       status, mgmt_errstr(status));
+		return;
+	}
+
+	DBG("MSFT a2dp offload codecs successfully set");
+
+	if (action)
+		queue_push_tail(adapter->exps,
+				(void *)msft_a2dp_offload_codecs_uuid.val);
+}
+
+static void msft_a2dp_offload_func(struct btd_adapter *adapter, uint8_t action)
+{
+	struct mgmt_cp_set_exp_feature cp;
+
+	memset(&cp, 0, sizeof(cp));
+	memcpy(cp.uuid, msft_a2dp_offload_codecs_uuid.val, 16);
+	cp.action = action;
+
+	if (mgmt_send(adapter->mgmt, MGMT_OP_SET_EXP_FEATURE,
+		      adapter->dev_id, sizeof(cp), &cp,
+		      msft_a2dp_offload_complete, adapter, NULL) > 0)
+		return;
+
+	btd_error(adapter->dev_id, "Failed to set RPA Resolution");
+}
+
 static const struct exp_feat {
 	const struct mgmt_exp_uuid *uuid;
 	void (*func)(struct btd_adapter *adapter, uint8_t action);
@@ -9799,6 +9841,7 @@ static const struct exp_feat {
 	EXP_FEAT(&quality_report_uuid, quality_report_func),
 	EXP_FEAT(&rpa_resolution_uuid, rpa_resolution_func),
 	EXP_FEAT(&codec_offload_uuid, codec_offload_func),
+	EXP_FEAT(&msft_a2dp_offload_codecs_uuid, msft_a2dp_offload_func),
 };
 
 static void read_exp_features_complete(uint8_t status, uint16_t length,
diff --git a/src/main.c b/src/main.c
index dd954e1abfe9..9776ff89a1d9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -571,6 +571,7 @@ static const char *valid_uuids[] = {
 	"15c0a148-c273-11ea-b3de-0242ac130004",
 	"330859bc-7506-492d-9370-9a6f0614037f",
 	"a6695ace-ee7f-4fb9-881a-5fac66c629af",
+	"0cc2131f-96f0-4cd1-b313-b97e7cbc8335",
 	"*"
 };
 
diff --git a/src/main.conf b/src/main.conf
index c82d7e6482c4..ab4a6128ad5c 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -116,6 +116,7 @@
 # 15c0a148-c273-11ea-b3de-0242ac130004 (BlueZ Experimental LL privacy)
 # 330859bc-7506-492d-9370-9a6f0614037f (BlueZ Experimental Bluetooth Quality Report)
 # a6695ace-ee7f-4fb9-881a-5fac66c629af (BlueZ Experimental Offload Codecs)
+# 0cc2131f-96f0-4cd1-b313-b97e7cbc8335 (BlueZ Experimental MSFT a2dp offload Codecs)
 # Defaults to false.
 #Experimental = false
 
-- 
2.17.1


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

* [PATCH v2 2/9] shared/util: Decode MSFT offload codec UUID
  2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
@ 2021-11-19  9:42 ` Kiran K
  2021-11-19  9:42 ` [PATCH v2 3/9] mgmt: Set MSFT offload codec feature Kiran K
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Kiran K @ 2021-11-19  9:42 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: ravishankar.srivatsa, chethan.tumkur.narayan, luiz.von.dentz, Kiran K

This adds MSFT offload codec UUID to uuid128_table so it is
decoded by the likes of btmon.
---
 src/shared/util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/shared/util.c b/src/shared/util.c
index 81b20d86f4ad..6754ca7bf17c 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1108,6 +1108,8 @@ static const struct {
 	{ "330859bc-7506-492d-9370-9a6f0614037f",
 		"BlueZ Experimental Bluetooth Quality Report" },
 	{ "a6695ace-ee7f-4fb9-881a-5fac66c629af", "BlueZ Offload Codecs"},
+	{ "0cc2131f-96f0-4cd1-b313-b97e7cbc8335",
+		"BlueZ Experimental MSFT offload codecs" },
 	{ }
 };
 
-- 
2.17.1


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

* [PATCH v2 3/9] mgmt: Set MSFT offload codec feature
  2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
  2021-11-19  9:42 ` [PATCH v2 2/9] shared/util: Decode MSFT offload codec UUID Kiran K
@ 2021-11-19  9:42 ` Kiran K
  2021-11-19  9:42 ` [PATCH v2 4/9] adapter: API to check if MSFT a2dp codec is enabled Kiran K
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Kiran K @ 2021-11-19  9:42 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: ravishankar.srivatsa, chethan.tumkur.narayan, luiz.von.dentz, Kiran K

Add support to toggle msft offload codec feature.
---
 tools/btmgmt.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 42ef9acefaea..3d76269b178a 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -2597,6 +2597,46 @@ static void cmd_exp_offload_codecs(int argc, char **argv)
 	}
 }
 
+static void exp_msft_offload_rsp(uint8_t status, uint16_t len,
+				 const void *param, void *user_data)
+{
+	if (status != 0)
+		error("Set MSFT offload codec failed with status 0x%02x (%s)",
+		      status, mgmt_errstr(status));
+	else
+		print("MSFT Offload codec feature successfully set");
+
+	bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
+static void cmd_exp_msft_offload_codecs(int argc, char **argv)
+{
+	/* 0cc2131f-96f0-4cd1-b313-b97e7cbc8335 */
+	static const uint8_t uuid[16] = {
+				0x35, 0x83, 0xbc, 0x7c, 0x7e, 0xb9, 0x13, 0xb3,
+				0xd1, 0x4c, 0xf0, 0x96, 0x1f, 0x13, 0xc2, 0x0c,
+	};
+	struct mgmt_cp_set_exp_feature cp;
+	uint8_t val;
+	uint16_t index;
+
+	if (parse_setting(argc, argv, &val) == false)
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+
+	index = mgmt_index;
+	if (index == MGMT_INDEX_NONE)
+		index = 0;
+
+	memset(&cp, 0, sizeof(cp));
+	memcpy(cp.uuid, uuid, 16);
+	cp.action = val;
+
+	if (mgmt_send(mgmt, MGMT_OP_SET_EXP_FEATURE, index, sizeof(cp), &cp,
+		      exp_msft_offload_rsp, NULL, NULL) == 0) {
+		error("Unable to send msft offload codecs feature cmd");
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
+}
 static void class_rsp(uint16_t op, uint16_t id, uint8_t status, uint16_t len,
 							const void *param)
 {
@@ -5640,6 +5680,8 @@ static const struct bt_shell_menu main_menu = {
 		"Set bluetooth quality report feature"			},
 	{ "exp-offload",		"<on/off>",
 		cmd_exp_offload_codecs,	"Toggle codec support"		},
+	{ "exp-msft-offload",		"<on/off>",
+		cmd_exp_msft_offload_codecs, "Toggle msft codec support"},
 	{ "read-sysconfig",	NULL,
 		cmd_read_sysconfig,	"Read System Configuration"	},
 	{ "set-sysconfig",	"<-v|-h> [options...]",
-- 
2.17.1


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

* [PATCH v2 4/9] adapter: API to check if MSFT a2dp codec is enabled
  2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
  2021-11-19  9:42 ` [PATCH v2 2/9] shared/util: Decode MSFT offload codec UUID Kiran K
  2021-11-19  9:42 ` [PATCH v2 3/9] mgmt: Set MSFT offload codec feature Kiran K
@ 2021-11-19  9:42 ` Kiran K
  2021-11-19  9:42 ` [PATCH v2 5/9] avdtp: Add a flag in struct avdtp to control MSFT a2dp offload Kiran K
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Kiran K @ 2021-11-19  9:42 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: ravishankar.srivatsa, chethan.tumkur.narayan, luiz.von.dentz, Kiran K

Add an utility API to check if MSFT a2dp codec feature is
enabled in Kernel.
---
 src/adapter.c | 6 ++++++
 src/adapter.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 1627cc127057..fd5ce614bec5 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -9796,6 +9796,12 @@ static void codec_offload_func(struct btd_adapter *adapter, uint8_t action)
 	btd_error(adapter->dev_id, "Failed to set Codec Offload");
 }
 
+bool is_msft_a2dp_offload_supported(struct btd_adapter *adapter)
+{
+	return queue_find(adapter->exps, is_exp_feature_uuid_the_same,
+			(void *)msft_a2dp_offload_codecs_uuid.val) != NULL;
+}
+
 static void msft_a2dp_offload_complete(uint8_t status, uint16_t len,
 				       const void *param, void *user_data)
 {
diff --git a/src/adapter.h b/src/adapter.h
index d191daf5dc12..3857126b4dff 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -261,3 +261,5 @@ bool btd_adapter_set_allowed_uuids(struct btd_adapter *adapter,
 							struct queue *uuids);
 bool btd_adapter_is_uuid_allowed(struct btd_adapter *adapter,
 							const char *uuid_str);
+
+bool is_msft_a2dp_offload_supported(struct btd_adapter *adapter);
-- 
2.17.1


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

* [PATCH v2 5/9] avdtp: Add a flag in struct avdtp to control MSFT a2dp offload
  2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
                   ` (2 preceding siblings ...)
  2021-11-19  9:42 ` [PATCH v2 4/9] adapter: API to check if MSFT a2dp codec is enabled Kiran K
@ 2021-11-19  9:42 ` Kiran K
  2021-11-19  9:42 ` [PATCH v2 6/9] avdtp: Add support for offload MSFT open command Kiran K
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Kiran K @ 2021-11-19  9:42 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: ravishankar.srivatsa, chethan.tumkur.narayan, luiz.von.dentz, Kiran K

Define a flag in struct avdtp to mark the support of MSFT
a2dp codecs. If the flag is set, for a2dp streaming offload
path will be selected.
---
 profiles/audio/avdtp.c | 7 +++++++
 src/adapter.c          | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index d3dfbf96dda3..58d419fb3148 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -409,6 +409,9 @@ struct avdtp {
 
 	/* Attempt stream setup instead of disconnecting */
 	gboolean stream_setup;
+
+	/* use offload for transport */
+	gboolean use_offload;
 };
 
 static GSList *state_callbacks = NULL;
@@ -2425,6 +2428,7 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,
 							struct queue *lseps)
 {
 	struct avdtp *session;
+	char *use_offload;
 
 	session = g_new0(struct avdtp, 1);
 
@@ -2436,6 +2440,9 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,
 
 	session->version = get_version(session);
 
+	if (is_msft_a2dp_offload_supported(avdtp_get_adapter(session)))
+		session->use_offload = TRUE;
+
 	if (!chan)
 		return session;
 
diff --git a/src/adapter.c b/src/adapter.c
index fd5ce614bec5..235748c52780 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -9796,6 +9796,15 @@ static void codec_offload_func(struct btd_adapter *adapter, uint8_t action)
 	btd_error(adapter->dev_id, "Failed to set Codec Offload");
 }
 
+static bool is_exp_feature_uuid_the_same(const void *data,
+					 const void *match_data)
+{
+	if (sizeof(data) != sizeof(match_data))
+		return false;
+
+	return memcmp(data, match_data, sizeof(data)) == 0;
+}
+
 bool is_msft_a2dp_offload_supported(struct btd_adapter *adapter)
 {
 	return queue_find(adapter->exps, is_exp_feature_uuid_the_same,
-- 
2.17.1


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

* [PATCH v2 6/9] avdtp: Add support for offload MSFT open command
  2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
                   ` (3 preceding siblings ...)
  2021-11-19  9:42 ` [PATCH v2 5/9] avdtp: Add a flag in struct avdtp to control MSFT a2dp offload Kiran K
@ 2021-11-19  9:42 ` Kiran K
  2021-11-19  9:42 ` [PATCH v2 7/9] avdtp: Add support for MSFT offload start command Kiran K
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Kiran K @ 2021-11-19  9:42 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: ravishankar.srivatsa, chethan.tumkur.narayan, luiz.von.dentz, Kiran K

In a2dp offload use case, controller needs to be sent
MSFT avdtp command after opening media transport channel
---
 lib/bluetooth.h        |  7 +++++++
 profiles/audio/avdtp.c | 46 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index 0fcf412c6c6b..b4bbe1373403 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -158,6 +158,13 @@ struct bt_codecs {
 	struct bt_codec codecs[];
 } __attribute__((packed));
 
+#define BT_MSFT		20
+struct bt_msft {
+	uint8_t sub_opcode;
+	uint8_t len;
+	uint8_t data[];
+} __attribute__((packed));
+
 /* Connection and socket states */
 enum {
 	BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 58d419fb3148..6a56bd4507c4 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2352,6 +2352,47 @@ static uint16_t get_version(struct avdtp *session)
 	return ver;
 }
 
+static gboolean msft_avdtp_open(struct avdtp_stream *stream)
+{
+	int sock;
+	struct avdtp_service_capability *caps = NULL;
+	struct bt_msft *cmd;
+	GSList *l;
+
+	if (!stream->io)
+		return FALSE;
+
+	sock = g_io_channel_unix_get_fd(stream->io);
+
+	for (l = stream->caps; l ; l = g_slist_next(l)) {
+		caps = l->data;
+
+		if (caps->category != AVDTP_MEDIA_CODEC) {
+			caps = NULL;
+			continue;
+		}
+		break;
+	}
+
+	if (!caps)
+		return FALSE;
+
+	cmd = g_malloc0(sizeof(*cmd) + sizeof(*caps) + caps->length);
+	cmd->sub_opcode = 0x08;
+	cmd->len = sizeof(*caps) + caps->length;
+	memcpy(cmd->data, caps, cmd->len);
+
+	if (setsockopt(sock, SOL_BLUETOOTH, BT_MSFT, cmd,
+		       sizeof(*cmd) + cmd->len)) {
+		g_free(cmd);
+		return FALSE;
+	}
+
+	g_free(cmd);
+
+	return TRUE;
+}
+
 static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 {
 	struct avdtp *session = user_data;
@@ -2385,6 +2426,11 @@ static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 			session->pending_open ? "transport" : "signaling",
 			address);
 
+	if (session->pending_open && session->use_offload) {
+		if (!msft_avdtp_open(session->pending_open))
+			goto failed;
+	}
+
 	if (session->state == AVDTP_SESSION_STATE_CONNECTING) {
 		DBG("AVDTP imtu=%u, omtu=%u", session->imtu, session->omtu);
 
-- 
2.17.1


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

* [PATCH v2 7/9] avdtp: Add support for MSFT offload start command
  2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
                   ` (4 preceding siblings ...)
  2021-11-19  9:42 ` [PATCH v2 6/9] avdtp: Add support for offload MSFT open command Kiran K
@ 2021-11-19  9:42 ` Kiran K
  2021-11-19  9:42 ` [PATCH v2 8/9] avdtp: Add support for MSFT offload suspend command Kiran K
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Kiran K @ 2021-11-19  9:42 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: ravishankar.srivatsa, chethan.tumkur.narayan, luiz.von.dentz, Kiran K

Send MSFT avdtp start command to trigger a2dp offload
streaming after sending remote AVDTP start command.
---
 profiles/audio/avdtp.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 6a56bd4507c4..72a5e9c5a82a 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2907,6 +2907,24 @@ static gboolean avdtp_open_resp(struct avdtp *session, struct avdtp_stream *stre
 	return TRUE;
 }
 
+static gboolean msft_avdtp_start(struct avdtp_stream *stream)
+{
+	int sock;
+	struct bt_msft cmd;
+
+	if (!stream->io)
+		return FALSE;
+
+	sock = g_io_channel_unix_get_fd(stream->io);
+
+	cmd.sub_opcode = 0x09;
+
+	if (setsockopt(sock, SOL_BLUETOOTH, BT_MSFT, &cmd, 1))
+		return FALSE;
+
+	return TRUE;
+}
+
 static gboolean avdtp_start_resp(struct avdtp *session,
 					struct avdtp_stream *stream,
 					struct seid_rej *resp, int size)
@@ -2921,6 +2939,9 @@ static gboolean avdtp_start_resp(struct avdtp *session,
 	if (sep->state != AVDTP_STATE_STREAMING)
 		avdtp_sep_set_state(session, sep, AVDTP_STATE_STREAMING);
 
+	if (session->use_offload)
+		msft_avdtp_start(stream);
+
 	return TRUE;
 }
 
-- 
2.17.1


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

* [PATCH v2 8/9] avdtp: Add support for MSFT offload suspend command
  2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
                   ` (5 preceding siblings ...)
  2021-11-19  9:42 ` [PATCH v2 7/9] avdtp: Add support for MSFT offload start command Kiran K
@ 2021-11-19  9:42 ` Kiran K
  2021-11-19  9:42 ` [PATCH v2 9/9] avdtp: Add support for MSFT offload close command Kiran K
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Kiran K @ 2021-11-19  9:42 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: ravishankar.srivatsa, chethan.tumkur.narayan, luiz.von.dentz, Kiran K

In a2dp offload use case, send MSFT avdtp suspend command
followed by remote AVDTP suspend command.
---
 profiles/audio/avdtp.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 72a5e9c5a82a..c0217f272b2c 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2958,6 +2958,24 @@ static gboolean avdtp_close_resp(struct avdtp *session,
 	return TRUE;
 }
 
+static gboolean msft_avdtp_suspend(struct avdtp_stream *stream)
+{
+	int sock;
+	struct bt_msft cmd;
+
+	if (!stream->io)
+		return FALSE;
+
+	sock = g_io_channel_unix_get_fd(stream->io);
+
+	cmd.sub_opcode = 0x0a;
+
+	if (setsockopt(sock, SOL_BLUETOOTH, BT_MSFT, &cmd, 1))
+		return FALSE;
+
+	return TRUE;
+}
+
 static gboolean avdtp_suspend_resp(struct avdtp *session,
 					struct avdtp_stream *stream,
 					void *data, int size)
@@ -2969,6 +2987,9 @@ static gboolean avdtp_suspend_resp(struct avdtp *session,
 	if (sep->cfm && sep->cfm->suspend)
 		sep->cfm->suspend(session, sep, stream, NULL, sep->user_data);
 
+	if (session->use_offload)
+		msft_avdtp_suspend(stream);
+
 	return TRUE;
 }
 
-- 
2.17.1


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

* [PATCH v2 9/9] avdtp: Add support for MSFT offload close command
  2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
                   ` (6 preceding siblings ...)
  2021-11-19  9:42 ` [PATCH v2 8/9] avdtp: Add support for MSFT offload suspend command Kiran K
@ 2021-11-19  9:42 ` Kiran K
  2021-11-19  9:55 ` [v2,1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set bluez.test.bot
  2021-11-19 10:06 ` [PATCH v2 1/9] " Marcel Holtmann
  9 siblings, 0 replies; 12+ messages in thread
From: Kiran K @ 2021-11-19  9:42 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: ravishankar.srivatsa, chethan.tumkur.narayan, luiz.von.dentz, Kiran K

In a2dp offload use case, send MSFT avdtp close
command followed by remote AVDTP close command.
---
 profiles/audio/avdtp.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index c0217f272b2c..7619c167e6cf 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2945,6 +2945,24 @@ static gboolean avdtp_start_resp(struct avdtp *session,
 	return TRUE;
 }
 
+static gboolean msft_avdtp_close(struct avdtp_stream *stream)
+{
+	int sock;
+	struct bt_msft cmd;
+
+	if (!stream->io)
+		return FALSE;
+
+	sock = g_io_channel_unix_get_fd(stream->io);
+
+	cmd.sub_opcode = 0x0b;
+
+	if (setsockopt(sock, SOL_BLUETOOTH, BT_MSFT, &cmd, 1))
+		return FALSE;
+
+	return TRUE;
+}
+
 static gboolean avdtp_close_resp(struct avdtp *session,
 					struct avdtp_stream *stream,
 					struct seid_rej *resp, int size)
@@ -2953,6 +2971,9 @@ static gboolean avdtp_close_resp(struct avdtp *session,
 
 	avdtp_sep_set_state(session, sep, AVDTP_STATE_CLOSING);
 
+	if (session->use_offload)
+		msft_avdtp_close(stream);
+
 	close_stream(stream);
 
 	return TRUE;
-- 
2.17.1


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

* RE: [v2,1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set
  2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
                   ` (7 preceding siblings ...)
  2021-11-19  9:42 ` [PATCH v2 9/9] avdtp: Add support for MSFT offload close command Kiran K
@ 2021-11-19  9:55 ` bluez.test.bot
  2021-11-19 10:06 ` [PATCH v2 1/9] " Marcel Holtmann
  9 siblings, 0 replies; 12+ messages in thread
From: bluez.test.bot @ 2021-11-19  9:55 UTC (permalink / raw)
  To: linux-bluetooth, kiran.k

[-- Attachment #1: Type: text/plain, Size: 4064 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=582945

---Test result---

Test Summary:
CheckPatch                    FAIL      13.45 seconds
GitLint                       PASS      8.97 seconds
Prep - Setup ELL              PASS      41.62 seconds
Build - Prep                  PASS      0.65 seconds
Build - Configure             PASS      7.91 seconds
Build - Make                  FAIL      138.93 seconds
Make Check                    FAIL      1.66 seconds
Make Distcheck                PASS      217.33 seconds
Build w/ext ELL - Configure   PASS      8.13 seconds
Build w/ext ELL - Make        FAIL      127.35 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
[v2,1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set
WARNING:LONG_LINE_STRING: line length of 83 exceeds 80 columns
#89: FILE: src/adapter.c:9806:
+		error("Set MSFT a2dp offload codec failed with status 0x%02x (%s)",

/github/workspace/src/12628551.patch total: 0 errors, 1 warnings, 75 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/12628551.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

[v2,6/9] avdtp: Add support for offload MSFT open command
WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed))
#72: FILE: lib/bluetooth.h:166:
+} __attribute__((packed));

/github/workspace/src/12628561.patch total: 0 errors, 1 warnings, 71 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/12628561.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: Build - Make - FAIL
Desc: Build the BlueZ source tree
Output:
profiles/audio/avdtp.c: In function ‘avdtp_new’:
profiles/audio/avdtp.c:2477:8: error: unused variable ‘use_offload’ [-Werror=unused-variable]
 2477 |  char *use_offload;
      |        ^~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8640: profiles/audio/bluetoothd-avdtp.o] Error 1
make: *** [Makefile:4175: all] Error 2


##############################
Test: Make Check - FAIL
Desc: Run 'make check'
Output:
profiles/audio/avdtp.c: In function ‘avdtp_new’:
profiles/audio/avdtp.c:2477:8: error: unused variable ‘use_offload’ [-Werror=unused-variable]
 2477 |  char *use_offload;
      |        ^~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8640: profiles/audio/bluetoothd-avdtp.o] Error 1
make: *** [Makefile:10501: check] Error 2


##############################
Test: Build w/ext ELL - Make - FAIL
Desc: Build BlueZ source with '--enable-external-ell' configuration
Output:
profiles/audio/avdtp.c: In function ‘avdtp_new’:
profiles/audio/avdtp.c:2477:8: error: unused variable ‘use_offload’ [-Werror=unused-variable]
 2477 |  char *use_offload;
      |        ^~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8640: profiles/audio/bluetoothd-avdtp.o] Error 1
make: *** [Makefile:4175: all] Error 2




---
Regards,
Linux Bluetooth


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

* Re: [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set
  2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
                   ` (8 preceding siblings ...)
  2021-11-19  9:55 ` [v2,1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set bluez.test.bot
@ 2021-11-19 10:06 ` Marcel Holtmann
  2021-11-19 10:10   ` K, Kiran
  9 siblings, 1 reply; 12+ messages in thread
From: Marcel Holtmann @ 2021-11-19 10:06 UTC (permalink / raw)
  To: Kiran K
  Cc: linux-bluetooth, ravishankar.srivatsa, chethan.tumkur.narayan,
	Luiz Augusto von Dentz

Hi Kiran,

> This enables codec offload experimental feature if its UUIDs has been
> enabled by main.conf:Experimental or -E has been passed in the command
> line.
> ---
> src/adapter.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> src/main.c    |  1 +
> src/main.conf |  1 +
> 3 files changed, 45 insertions(+)
> 
> diff --git a/src/adapter.c b/src/adapter.c
> index 309956bbb5be..1627cc127057 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -142,6 +142,13 @@ static const struct mgmt_exp_uuid codec_offload_uuid = {
> 	.str = "a6695ace-ee7f-4fb9-881a-5fac66c629af"
> };
> 
> +/* 0cc2131f-96f0-4cd1-b313-b97e7cbc8335 */
> +static const struct mgmt_exp_uuid msft_a2dp_offload_codecs_uuid = {
> +	.val = { 0x35, 0x83, 0xbc, 0x7c, 0x7e, 0xb9, 0x13, 0xb3,
> +		0xd1, 0x4c, 0xf0, 0x96, 0x1f, 0x13, 0xc2, 0x0c},
> +	.str = "0cc2131f-96f0-4cd1-b313-b97e7cbc8335"
> +};
> +
> static DBusConnection *dbus_conn = NULL;
> 
> static uint32_t kernel_features = 0;
> @@ -9789,6 +9796,41 @@ static void codec_offload_func(struct btd_adapter *adapter, uint8_t action)
> 	btd_error(adapter->dev_id, "Failed to set Codec Offload");
> }
> 
> +static void msft_a2dp_offload_complete(uint8_t status, uint16_t len,
> +				       const void *param, void *user_data)
> +{
> +	struct btd_adapter *adapter = user_data;
> +	uint8_t action = btd_opts.experimental ? 0x01 : 0x00;
> +
> +	if (status != 0) {
> +		error("Set MSFT a2dp offload codec failed with status 0x%02x (%s)",
> +		       status, mgmt_errstr(status));
> +		return;
> +	}
> +
> +	DBG("MSFT a2dp offload codecs successfully set");

we need to switch to using btd_debug or DBG_IDX to include the index number in the traces.

> +
> +	if (action)
> +		queue_push_tail(adapter->exps,
> +				(void *)msft_a2dp_offload_codecs_uuid.val);
> +}
> +
> +static void msft_a2dp_offload_func(struct btd_adapter *adapter, uint8_t action)
> +{
> +	struct mgmt_cp_set_exp_feature cp;
> +
> +	memset(&cp, 0, sizeof(cp));
> +	memcpy(cp.uuid, msft_a2dp_offload_codecs_uuid.val, 16);
> +	cp.action = action;
> +
> +	if (mgmt_send(adapter->mgmt, MGMT_OP_SET_EXP_FEATURE,
> +		      adapter->dev_id, sizeof(cp), &cp,
> +		      msft_a2dp_offload_complete, adapter, NULL) > 0)
> +		return;
> +
> +	btd_error(adapter->dev_id, "Failed to set RPA Resolution");
> +}

We are no longer dealing with the blunt copy-and-paste mistakes, please do a proper review before sending any patch.

Regards

Marcel


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

* RE: [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set
  2021-11-19 10:06 ` [PATCH v2 1/9] " Marcel Holtmann
@ 2021-11-19 10:10   ` K, Kiran
  0 siblings, 0 replies; 12+ messages in thread
From: K, Kiran @ 2021-11-19 10:10 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: linux-bluetooth, Srivatsa, Ravishankar, Tumkur Narayan, Chethan,
	Von Dentz, Luiz

Hi Marcel,

> -----Original Message-----
> From: Marcel Holtmann <marcel@holtmann.org>
> Sent: Friday, November 19, 2021 3:36 PM
> To: K, Kiran <kiran.k@intel.com>
> Cc: linux-bluetooth@vger.kernel.org; Srivatsa, Ravishankar
> <ravishankar.srivatsa@intel.com>; Tumkur Narayan, Chethan
> <chethan.tumkur.narayan@intel.com>; Von Dentz, Luiz
> <luiz.von.dentz@intel.com>
> Subject: Re: [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when
> Experimental is set
> 
> Hi Kiran,
> 
> > This enables codec offload experimental feature if its UUIDs has been
> > enabled by main.conf:Experimental or -E has been passed in the command
> > line.
> > ---
> > src/adapter.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> > src/main.c    |  1 +
> > src/main.conf |  1 +
> > 3 files changed, 45 insertions(+)
> >
> > diff --git a/src/adapter.c b/src/adapter.c index
> > 309956bbb5be..1627cc127057 100644
> > --- a/src/adapter.c
> > +++ b/src/adapter.c
> > @@ -142,6 +142,13 @@ static const struct mgmt_exp_uuid
> codec_offload_uuid = {
> > 	.str = "a6695ace-ee7f-4fb9-881a-5fac66c629af"
> > };
> >
> > +/* 0cc2131f-96f0-4cd1-b313-b97e7cbc8335 */ static const struct
> > +mgmt_exp_uuid msft_a2dp_offload_codecs_uuid = {
> > +	.val = { 0x35, 0x83, 0xbc, 0x7c, 0x7e, 0xb9, 0x13, 0xb3,
> > +		0xd1, 0x4c, 0xf0, 0x96, 0x1f, 0x13, 0xc2, 0x0c},
> > +	.str = "0cc2131f-96f0-4cd1-b313-b97e7cbc8335"
> > +};
> > +
> > static DBusConnection *dbus_conn = NULL;
> >
> > static uint32_t kernel_features = 0;
> > @@ -9789,6 +9796,41 @@ static void codec_offload_func(struct
> btd_adapter *adapter, uint8_t action)
> > 	btd_error(adapter->dev_id, "Failed to set Codec Offload"); }
> >
> > +static void msft_a2dp_offload_complete(uint8_t status, uint16_t len,
> > +				       const void *param, void *user_data) {
> > +	struct btd_adapter *adapter = user_data;
> > +	uint8_t action = btd_opts.experimental ? 0x01 : 0x00;
> > +
> > +	if (status != 0) {
> > +		error("Set MSFT a2dp offload codec failed with status 0x%02x
> (%s)",
> > +		       status, mgmt_errstr(status));
> > +		return;
> > +	}
> > +
> > +	DBG("MSFT a2dp offload codecs successfully set");
> 
> we need to switch to using btd_debug or DBG_IDX to include the index
> number in the traces.

Ok.
> 
> > +
> > +	if (action)
> > +		queue_push_tail(adapter->exps,
> > +				(void *)msft_a2dp_offload_codecs_uuid.val);
> > +}
> > +
> > +static void msft_a2dp_offload_func(struct btd_adapter *adapter,
> > +uint8_t action) {
> > +	struct mgmt_cp_set_exp_feature cp;
> > +
> > +	memset(&cp, 0, sizeof(cp));
> > +	memcpy(cp.uuid, msft_a2dp_offload_codecs_uuid.val, 16);
> > +	cp.action = action;
> > +
> > +	if (mgmt_send(adapter->mgmt, MGMT_OP_SET_EXP_FEATURE,
> > +		      adapter->dev_id, sizeof(cp), &cp,
> > +		      msft_a2dp_offload_complete, adapter, NULL) > 0)
> > +		return;
> > +
> > +	btd_error(adapter->dev_id, "Failed to set RPA Resolution"); }
> 
> We are no longer dealing with the blunt copy-and-paste mistakes, please do
> a proper review before sending any patch.

My bad. I will address in the next patchset.
> 
> Regards
> 
> Marcel

Thanks,
Kiran



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

end of thread, other threads:[~2021-11-19 10:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19  9:42 [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Kiran K
2021-11-19  9:42 ` [PATCH v2 2/9] shared/util: Decode MSFT offload codec UUID Kiran K
2021-11-19  9:42 ` [PATCH v2 3/9] mgmt: Set MSFT offload codec feature Kiran K
2021-11-19  9:42 ` [PATCH v2 4/9] adapter: API to check if MSFT a2dp codec is enabled Kiran K
2021-11-19  9:42 ` [PATCH v2 5/9] avdtp: Add a flag in struct avdtp to control MSFT a2dp offload Kiran K
2021-11-19  9:42 ` [PATCH v2 6/9] avdtp: Add support for offload MSFT open command Kiran K
2021-11-19  9:42 ` [PATCH v2 7/9] avdtp: Add support for MSFT offload start command Kiran K
2021-11-19  9:42 ` [PATCH v2 8/9] avdtp: Add support for MSFT offload suspend command Kiran K
2021-11-19  9:42 ` [PATCH v2 9/9] avdtp: Add support for MSFT offload close command Kiran K
2021-11-19  9:55 ` [v2,1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set bluez.test.bot
2021-11-19 10:06 ` [PATCH v2 1/9] " Marcel Holtmann
2021-11-19 10:10   ` K, Kiran

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).