diff mbox series

[v1,3/5] avdtp: Add support for offload msft start command

Message ID 20211115094108.24331-3-kiran.k@intel.com (mailing list archive)
State Changes Requested
Headers show
Series [v1,1/5] avdtp: Add a flag in struct avdtp to control a2dp offload | expand

Checks

Context Check Description
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS

Commit Message

K, Kiran Nov. 15, 2021, 9:41 a.m. UTC
Send MSFT avdtp start command to trigger a2dp offload
streaming after sending remote AVDTP start command.
---
 lib/bluetooth.h        |  1 +
 profiles/audio/avdtp.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index 59ef178a563a..32a3b5f0c2b9 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -159,6 +159,7 @@  struct bt_codecs {
 } __attribute__((packed));
 
 #define BT_MSFT_OPEN	20
+#define BT_MSFT_START	21
 #define BT_MSFT_CLOSE	23
 
 /* Connection and socket states */
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 1cd4b4472b08..1ae96e3e8a07 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2910,6 +2910,21 @@  static gboolean avdtp_open_resp(struct avdtp *session, struct avdtp_stream *stre
 	return TRUE;
 }
 
+static gboolean avdtp_offload_start(struct avdtp_stream *stream)
+{
+	int sock;
+
+	if (!stream->io)
+		return FALSE;
+
+	sock = g_io_channel_unix_get_fd(stream->io);
+
+	if (setsockopt(sock, SOL_BLUETOOTH, BT_MSFT_START, 0, 0))
+		return FALSE;
+
+	return TRUE;
+}
+
 static gboolean avdtp_start_resp(struct avdtp *session,
 					struct avdtp_stream *stream,
 					struct seid_rej *resp, int size)
@@ -2924,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)
+		avdtp_offload_start(stream);
+
 	return TRUE;
 }