From patchwork Fri Nov 19 09:42:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 518227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A938EC433F5 for ; Fri, 19 Nov 2021 09:37:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8440061B1E for ; Fri, 19 Nov 2021 09:37:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232695AbhKSJkB (ORCPT ); Fri, 19 Nov 2021 04:40:01 -0500 Received: from mga07.intel.com ([134.134.136.100]:62588 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231796AbhKSJkA (ORCPT ); Fri, 19 Nov 2021 04:40:00 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="297804832" X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="297804832" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 01:36:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="594179321" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga002.fm.intel.com with ESMTP; 19 Nov 2021 01:36:57 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v2 1/9] adapter: Enable MSFT a2dp offload codec when Experimental is set Date: Fri, 19 Nov 2021 15:12:27 +0530 Message-Id: <20211119094235.2432-1-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 From patchwork Fri Nov 19 09:42:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 516977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD270C433FE for ; Fri, 19 Nov 2021 09:37:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A190D61B31 for ; Fri, 19 Nov 2021 09:37:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233643AbhKSJkE (ORCPT ); Fri, 19 Nov 2021 04:40:04 -0500 Received: from mga07.intel.com ([134.134.136.100]:62588 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233025AbhKSJkD (ORCPT ); Fri, 19 Nov 2021 04:40:03 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="297804834" X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="297804834" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 01:37:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="594179332" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga002.fm.intel.com with ESMTP; 19 Nov 2021 01:36:59 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v2 2/9] shared/util: Decode MSFT offload codec UUID Date: Fri, 19 Nov 2021 15:12:28 +0530 Message-Id: <20211119094235.2432-2-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119094235.2432-1-kiran.k@intel.com> References: <20211119094235.2432-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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" }, { } }; From patchwork Fri Nov 19 09:42:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 518226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82D55C433F5 for ; Fri, 19 Nov 2021 09:37:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68A9E61B04 for ; Fri, 19 Nov 2021 09:37:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233326AbhKSJkF (ORCPT ); Fri, 19 Nov 2021 04:40:05 -0500 Received: from mga07.intel.com ([134.134.136.100]:62588 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233025AbhKSJkF (ORCPT ); Fri, 19 Nov 2021 04:40:05 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="297804837" X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="297804837" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 01:37:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="594179346" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga002.fm.intel.com with ESMTP; 19 Nov 2021 01:37:02 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v2 3/9] mgmt: Set MSFT offload codec feature Date: Fri, 19 Nov 2021 15:12:29 +0530 Message-Id: <20211119094235.2432-3-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119094235.2432-1-kiran.k@intel.com> References: <20211119094235.2432-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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", "", cmd_exp_offload_codecs, "Toggle codec support" }, + { "exp-msft-offload", "", + cmd_exp_msft_offload_codecs, "Toggle msft codec support"}, { "read-sysconfig", NULL, cmd_read_sysconfig, "Read System Configuration" }, { "set-sysconfig", "<-v|-h> [options...]", From patchwork Fri Nov 19 09:42:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 516976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F228BC433F5 for ; Fri, 19 Nov 2021 09:37:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB56561B1E for ; Fri, 19 Nov 2021 09:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234174AbhKSJkH (ORCPT ); Fri, 19 Nov 2021 04:40:07 -0500 Received: from mga07.intel.com ([134.134.136.100]:62588 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232969AbhKSJkH (ORCPT ); Fri, 19 Nov 2021 04:40:07 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="297804840" X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="297804840" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 01:37:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="594179358" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga002.fm.intel.com with ESMTP; 19 Nov 2021 01:37:03 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v2 4/9] adapter: API to check if MSFT a2dp codec is enabled Date: Fri, 19 Nov 2021 15:12:30 +0530 Message-Id: <20211119094235.2432-4-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119094235.2432-1-kiran.k@intel.com> References: <20211119094235.2432-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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); From patchwork Fri Nov 19 09:42:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 518225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED53AC433F5 for ; Fri, 19 Nov 2021 09:37:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6D596139F for ; Fri, 19 Nov 2021 09:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234419AbhKSJkK (ORCPT ); Fri, 19 Nov 2021 04:40:10 -0500 Received: from mga07.intel.com ([134.134.136.100]:62588 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233761AbhKSJkJ (ORCPT ); Fri, 19 Nov 2021 04:40:09 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="297804844" X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="297804844" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 01:37:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="594179379" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga002.fm.intel.com with ESMTP; 19 Nov 2021 01:37:06 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v2 5/9] avdtp: Add a flag in struct avdtp to control MSFT a2dp offload Date: Fri, 19 Nov 2021 15:12:31 +0530 Message-Id: <20211119094235.2432-5-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119094235.2432-1-kiran.k@intel.com> References: <20211119094235.2432-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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, From patchwork Fri Nov 19 09:42:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 516975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 739F7C433EF for ; Fri, 19 Nov 2021 09:37:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D28C61B04 for ; Fri, 19 Nov 2021 09:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233761AbhKSJkM (ORCPT ); Fri, 19 Nov 2021 04:40:12 -0500 Received: from mga07.intel.com ([134.134.136.100]:62588 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234439AbhKSJkL (ORCPT ); Fri, 19 Nov 2021 04:40:11 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="297804849" X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="297804849" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 01:37:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="594179396" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga002.fm.intel.com with ESMTP; 19 Nov 2021 01:37:08 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v2 6/9] avdtp: Add support for offload MSFT open command Date: Fri, 19 Nov 2021 15:12:32 +0530 Message-Id: <20211119094235.2432-6-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119094235.2432-1-kiran.k@intel.com> References: <20211119094235.2432-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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); From patchwork Fri Nov 19 09:42:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 518224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 949DCC433F5 for ; Fri, 19 Nov 2021 09:37:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D3F361B04 for ; Fri, 19 Nov 2021 09:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234255AbhKSJkO (ORCPT ); Fri, 19 Nov 2021 04:40:14 -0500 Received: from mga07.intel.com ([134.134.136.100]:62588 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234197AbhKSJkN (ORCPT ); Fri, 19 Nov 2021 04:40:13 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="297804853" X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="297804853" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 01:37:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="594179409" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga002.fm.intel.com with ESMTP; 19 Nov 2021 01:37:10 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v2 7/9] avdtp: Add support for MSFT offload start command Date: Fri, 19 Nov 2021 15:12:33 +0530 Message-Id: <20211119094235.2432-7-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119094235.2432-1-kiran.k@intel.com> References: <20211119094235.2432-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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; } From patchwork Fri Nov 19 09:42:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 516974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9BC6C433EF for ; Fri, 19 Nov 2021 09:37:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C42D561B43 for ; Fri, 19 Nov 2021 09:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234197AbhKSJkP (ORCPT ); Fri, 19 Nov 2021 04:40:15 -0500 Received: from mga07.intel.com ([134.134.136.100]:62588 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234360AbhKSJkP (ORCPT ); Fri, 19 Nov 2021 04:40:15 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="297804862" X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="297804862" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 01:37:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="594179421" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga002.fm.intel.com with ESMTP; 19 Nov 2021 01:37:12 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v2 8/9] avdtp: Add support for MSFT offload suspend command Date: Fri, 19 Nov 2021 15:12:34 +0530 Message-Id: <20211119094235.2432-8-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119094235.2432-1-kiran.k@intel.com> References: <20211119094235.2432-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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; } From patchwork Fri Nov 19 09:42:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 518223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A426C433F5 for ; Fri, 19 Nov 2021 09:37:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5207761B1E for ; Fri, 19 Nov 2021 09:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234471AbhKSJkS (ORCPT ); Fri, 19 Nov 2021 04:40:18 -0500 Received: from mga07.intel.com ([134.134.136.100]:62588 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234325AbhKSJkR (ORCPT ); Fri, 19 Nov 2021 04:40:17 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="297804865" X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="297804865" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 01:37:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,246,1631602800"; d="scan'208";a="594179432" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga002.fm.intel.com with ESMTP; 19 Nov 2021 01:37:14 -0800 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, luiz.von.dentz@intel.com, Kiran K Subject: [PATCH v2 9/9] avdtp: Add support for MSFT offload close command Date: Fri, 19 Nov 2021 15:12:35 +0530 Message-Id: <20211119094235.2432-9-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119094235.2432-1-kiran.k@intel.com> References: <20211119094235.2432-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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;