diff mbox series

[v1,4/5] avdtp: Add support for offload msft suspend command

Message ID 20211115094108.24331-4-kiran.k@intel.com
State New
Headers show
Series None | expand

Commit Message

K, Kiran Nov. 15, 2021, 9:41 a.m. UTC
In a2dp offload use case, send MSFT avdtp suspend command
followed by remote AVDTP suspend 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 32a3b5f0c2b9..2bd253aeeed4 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -160,6 +160,7 @@  struct bt_codecs {
 
 #define BT_MSFT_OPEN	20
 #define BT_MSFT_START	21
+#define BT_MSFT_SUSPEND 22
 #define BT_MSFT_CLOSE	23
 
 /* Connection and socket states */
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 1ae96e3e8a07..d5e8c7856be3 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2958,6 +2958,21 @@  static gboolean avdtp_close_resp(struct avdtp *session,
 	return TRUE;
 }
 
+static gboolean avdtp_offload_suspend(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_SUSPEND, 0, 0))
+		return FALSE;
+
+	return TRUE;
+}
+
 static gboolean avdtp_suspend_resp(struct avdtp *session,
 					struct avdtp_stream *stream,
 					void *data, int size)
@@ -2969,6 +2984,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)
+		avdtp_offload_suspend(stream);
+
 	return TRUE;
 }