From: Kiran K <kiran.k@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com,
luiz.von.dentz@intel.com, Kiran K <kiran.k@intel.com>
Subject: [PATCH v2 6/9] avdtp: Add support for offload MSFT open command
Date: Fri, 19 Nov 2021 15:12:32 +0530 [thread overview]
Message-ID: <20211119094235.2432-6-kiran.k@intel.com> (raw)
In-Reply-To: <20211119094235.2432-1-kiran.k@intel.com>
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
next prev parent reply other threads:[~2021-11-19 9:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Kiran K [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211119094235.2432-6-kiran.k@intel.com \
--to=kiran.k@intel.com \
--cc=chethan.tumkur.narayan@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.von.dentz@intel.com \
--cc=ravishankar.srivatsa@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).