From patchwork Fri Oct 8 13:58:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12545457 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 99D3FC433F5 for ; Fri, 8 Oct 2021 13:53:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73B466101E for ; Fri, 8 Oct 2021 13:53:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233133AbhJHNzT (ORCPT ); Fri, 8 Oct 2021 09:55:19 -0400 Received: from mga18.intel.com ([134.134.136.126]:60420 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232599AbhJHNzT (ORCPT ); Fri, 8 Oct 2021 09:55:19 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10130"; a="213457756" X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="213457756" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 06:53:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="624744938" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga001.fm.intel.com with ESMTP; 08 Oct 2021 06:53:21 -0700 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 v1 1/7] Bluetooth: Refactor code to read supported codecs in getsockopt Date: Fri, 8 Oct 2021 19:28:47 +0530 Message-Id: <20211008135853.8604-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 patch moves reading of supported codecs from cache to a new function to reuse over L2CAP sockets to be used in a2dp offload use case. Signed-off-by: Kiran K Change-Id: I080ed7ca8abd824d3af10859afd808bad28ee86d --- net/bluetooth/hci_codec.c | 88 +++++++++++++++++++++++++++++++++++ net/bluetooth/hci_codec.h | 2 + net/bluetooth/sco.c | 98 +++------------------------------------ 3 files changed, 96 insertions(+), 92 deletions(-) diff --git a/net/bluetooth/hci_codec.c b/net/bluetooth/hci_codec.c index 38201532f58e..f4d8d3a253d8 100644 --- a/net/bluetooth/hci_codec.c +++ b/net/bluetooth/hci_codec.c @@ -250,3 +250,91 @@ void hci_read_supported_codecs_v2(struct hci_dev *hdev) error: kfree_skb(skb); } + +int hci_get_supported_codecs(struct hci_dev *hdev, u8 type, char __user *optval, + int __user *optlen, int len) +{ + int n = 0, buf_len = 0, err = 0; + struct hci_codec_caps *caps; + struct bt_codec codec; + u8 num_codecs = 0, i, __user *ptr; + struct codec_list *c; + + if (!hci_dev_test_flag(hdev, HCI_OFFLOAD_CODECS_ENABLED)) { + err = -EOPNOTSUPP; + goto error; + } + + if (!hdev->get_data_path_id) { + err = -EOPNOTSUPP; + goto error; + } + + /* find total buffer size required to copy codec + capabilities */ + hci_dev_lock(hdev); + list_for_each_entry(c, &hdev->local_codecs, list) { + if (c->transport != type) + continue; + num_codecs++; + for (i = 0, caps = c->caps; i < c->num_caps; i++) { + buf_len += 1 + caps->len; + caps = (void *)&caps->data[caps->len]; + } + buf_len += sizeof(struct bt_codec); + } + hci_dev_unlock(hdev); + + buf_len += sizeof(struct bt_codecs); + if (buf_len > len) { + err = -ENOBUFS; + goto error; + } + ptr = optval; + + if (put_user(num_codecs, ptr)) { + err = -EFAULT; + goto error; + } + ptr += sizeof(num_codecs); + + /* Iterate over all the codecs on required transport */ + hci_dev_lock(hdev); + list_for_each_entry(c, &hdev->local_codecs, list) { + if (c->transport != type) + continue; + + codec.id = c->id; + codec.cid = c->cid; + codec.vid = c->vid; + err = hdev->get_data_path_id(hdev, &codec.data_path); + if (err < 0) + break; + codec.num_caps = c->num_caps; + if (copy_to_user(ptr, &codec, sizeof(codec))) { + err = -EFAULT; + break; + } + ptr += sizeof(codec); + + /* find codec capabilities data length */ + n = 0; + for (i = 0, caps = c->caps; i < c->num_caps; i++) { + n += 1 + caps->len; + caps = (void *)&caps->data[caps->len]; + } + + /* copy codec capabilities data */ + if (n && copy_to_user(ptr, c->caps, n)) { + err = -EFAULT; + break; + } + ptr += n; + } + hci_dev_unlock(hdev); + + if (!err && put_user(buf_len, optlen)) + err = -EFAULT; + +error: + return err; +} diff --git a/net/bluetooth/hci_codec.h b/net/bluetooth/hci_codec.h index a2751930f123..6e849c7d75b9 100644 --- a/net/bluetooth/hci_codec.h +++ b/net/bluetooth/hci_codec.h @@ -5,3 +5,5 @@ void hci_read_supported_codecs(struct hci_dev *hdev); void hci_read_supported_codecs_v2(struct hci_dev *hdev); void hci_codec_list_clear(struct list_head *codec_list); +int hci_get_supported_codecs(struct hci_dev *hdev, u8 type, char __user *optval, + int __user *optlen, int len); diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 8eabf41b2993..0af814c13b5f 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -33,6 +33,8 @@ #include #include +#include "hci_codec.h" + static bool disable_esco; static const struct proto_ops sco_sock_ops; @@ -1032,12 +1034,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, struct bt_voice voice; u32 phys; int pkt_status; - int buf_len; - struct codec_list *c; - u8 num_codecs, i, __user *ptr; struct hci_dev *hdev; - struct hci_codec_caps *caps; - struct bt_codec codec; BT_DBG("sk %p", sk); @@ -1103,98 +1100,15 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, break; case BT_CODEC: - num_codecs = 0; - buf_len = 0; - - hdev = hci_get_route(&sco_pi(sk)->dst, &sco_pi(sk)->src, BDADDR_BREDR); + hdev = hci_get_route(&sco_pi(sk)->dst, &sco_pi(sk)->src, + BDADDR_BREDR); if (!hdev) { err = -EBADFD; break; } - - if (!hci_dev_test_flag(hdev, HCI_OFFLOAD_CODECS_ENABLED)) { - hci_dev_put(hdev); - err = -EOPNOTSUPP; - break; - } - - if (!hdev->get_data_path_id) { - hci_dev_put(hdev); - err = -EOPNOTSUPP; - break; - } - - /* find total buffer size required to copy codec + caps */ - hci_dev_lock(hdev); - list_for_each_entry(c, &hdev->local_codecs, list) { - if (c->transport != HCI_TRANSPORT_SCO_ESCO) - continue; - num_codecs++; - for (i = 0, caps = c->caps; i < c->num_caps; i++) { - buf_len += 1 + caps->len; - caps = (void *)&caps->data[caps->len]; - } - buf_len += sizeof(struct bt_codec); - } - hci_dev_unlock(hdev); - - buf_len += sizeof(struct bt_codecs); - if (buf_len > len) { - hci_dev_put(hdev); - err = -ENOBUFS; - break; - } - ptr = optval; - - if (put_user(num_codecs, ptr)) { - hci_dev_put(hdev); - err = -EFAULT; - break; - } - ptr += sizeof(num_codecs); - - /* Iterate all the codecs supported over SCO and populate - * codec data - */ - hci_dev_lock(hdev); - list_for_each_entry(c, &hdev->local_codecs, list) { - if (c->transport != HCI_TRANSPORT_SCO_ESCO) - continue; - - codec.id = c->id; - codec.cid = c->cid; - codec.vid = c->vid; - err = hdev->get_data_path_id(hdev, &codec.data_path); - if (err < 0) - break; - codec.num_caps = c->num_caps; - if (copy_to_user(ptr, &codec, sizeof(codec))) { - err = -EFAULT; - break; - } - ptr += sizeof(codec); - - /* find codec capabilities data length */ - len = 0; - for (i = 0, caps = c->caps; i < c->num_caps; i++) { - len += 1 + caps->len; - caps = (void *)&caps->data[caps->len]; - } - - /* copy codec capabilities data */ - if (len && copy_to_user(ptr, c->caps, len)) { - err = -EFAULT; - break; - } - ptr += len; - } - - if (!err && put_user(buf_len, optlen)) - err = -EFAULT; - - hci_dev_unlock(hdev); + err = hci_get_supported_codecs(hdev, HCI_TRANSPORT_SCO_ESCO, + optval, optlen, len); hci_dev_put(hdev); - break; default: From patchwork Fri Oct 8 13:58:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12545459 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 28473C433F5 for ; Fri, 8 Oct 2021 13:53:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10E2360FD8 for ; Fri, 8 Oct 2021 13:53:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234200AbhJHNzV (ORCPT ); Fri, 8 Oct 2021 09:55:21 -0400 Received: from mga18.intel.com ([134.134.136.126]:60420 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233283AbhJHNzU (ORCPT ); Fri, 8 Oct 2021 09:55:20 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10130"; a="213457760" X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="213457760" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 06:53:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="624744956" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga001.fm.intel.com with ESMTP; 08 Oct 2021 06:53:23 -0700 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 v1 2/7] Bluetooth: Support reading of codecs supported over l2cap socket Date: Fri, 8 Oct 2021 19:28:48 +0530 Message-Id: <20211008135853.8604-2-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211008135853.8604-1-kiran.k@intel.com> References: <20211008135853.8604-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Codecs supported for A2DP offload use case are returned over l2cap socket. Add BT_CODEC option to getsockopt to return the codecs. Signed-off-by: Kiran K Change-Id: I1592f3bb1167771bfb2cb9114438e473ea372c90 --- include/net/bluetooth/hci.h | 1 + net/bluetooth/l2cap_sock.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 63065bc01b76..451d491f7f68 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -2666,6 +2666,7 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) #define hci_iso_data_flags(h) ((h) >> 14) /* codec transport types */ +#define HCI_TRANSPORT_ACL 0x00 #define HCI_TRANSPORT_SCO_ESCO 0x01 /* le24 support */ diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 160c016a5dfb..06f8ea681972 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -36,6 +36,7 @@ #include #include "smp.h" +#include "hci_codec.h" static struct bt_sock_list l2cap_sk_list = { .lock = __RW_LOCK_UNLOCKED(l2cap_sk_list.lock) @@ -549,6 +550,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, struct bt_power pwr; u32 phys; int len, mode, err = 0; + struct hci_dev *hdev; BT_DBG("sk %p", sk); @@ -685,6 +687,18 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, err = -EFAULT; break; + case BT_CODEC: + hdev = hci_get_route(BDADDR_ANY, &chan->src, BDADDR_BREDR); + if (!hdev) { + err = -EBADFD; + break; + } + + err = hci_get_supported_codecs(hdev, HCI_TRANSPORT_ACL, optval, + optlen, len); + hci_dev_put(hdev); + break; + default: err = -ENOPROTOOPT; break; From patchwork Fri Oct 8 13:58:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12545461 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 1C640C433FE for ; Fri, 8 Oct 2021 13:53:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03B836101E for ; Fri, 8 Oct 2021 13:53:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235647AbhJHNzY (ORCPT ); Fri, 8 Oct 2021 09:55:24 -0400 Received: from mga18.intel.com ([134.134.136.126]:60420 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234337AbhJHNzW (ORCPT ); Fri, 8 Oct 2021 09:55:22 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10130"; a="213457764" X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="213457764" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 06:53:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="624744966" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga001.fm.intel.com with ESMTP; 08 Oct 2021 06:53:25 -0700 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 v1 3/7] Bluetooth: btintel: cache offload use case data Date: Fri, 8 Oct 2021 19:28:49 +0530 Message-Id: <20211008135853.8604-3-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211008135853.8604-1-kiran.k@intel.com> References: <20211008135853.8604-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Keep a copy of use cases preset information in driver data. Use cases preset data can be re-used later instead of reading from controller every time. Signed-off-by: Kiran K Change-Id: I4057eb3ce1412baf0f0ba1bb83bbe71aaefaf9fc --- drivers/bluetooth/btintel.c | 6 ++++++ drivers/bluetooth/btintel.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 9359bff47296..f1431143eff5 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -2219,6 +2219,7 @@ static int btintel_configure_offload(struct hci_dev *hdev) struct sk_buff *skb; int err = 0; struct intel_offload_use_cases *use_cases; + struct btintel_data *intel_data; skb = __hci_cmd_sync(hdev, 0xfc86, 0, NULL, HCI_INIT_TIMEOUT); if (IS_ERR(skb)) { @@ -2239,10 +2240,15 @@ static int btintel_configure_offload(struct hci_dev *hdev) goto error; } + intel_data = hci_get_priv((hdev)); + + intel_data->use_cases = *use_cases; + if (use_cases->preset[0] & 0x03) { hdev->get_data_path_id = btintel_get_data_path_id; hdev->get_codec_config_data = btintel_get_codec_config_data; } + error: kfree_skb(skb); return err; diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index e500c0d7a729..091528d75256 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -158,6 +158,7 @@ enum { struct btintel_data { DECLARE_BITMAP(flags, __INTEL_NUM_FLAGS); + struct intel_offload_use_cases use_cases; }; #define btintel_set_flag(hdev, nr) \ From patchwork Fri Oct 8 13:58:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12545463 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 15E0DC433F5 for ; Fri, 8 Oct 2021 13:53:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F066D61039 for ; Fri, 8 Oct 2021 13:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234388AbhJHNz1 (ORCPT ); Fri, 8 Oct 2021 09:55:27 -0400 Received: from mga18.intel.com ([134.134.136.126]:60420 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236030AbhJHNzZ (ORCPT ); Fri, 8 Oct 2021 09:55:25 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10130"; a="213457770" X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="213457770" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 06:53:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="624744977" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga001.fm.intel.com with ESMTP; 08 Oct 2021 06:53:27 -0700 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 v1 4/7] Bluetooth: Pass transport type in get_data_path_id Date: Fri, 8 Oct 2021 19:28:50 +0530 Message-Id: <20211008135853.8604-4-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211008135853.8604-1-kiran.k@intel.com> References: <20211008135853.8604-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org To support fetching of data path id for other transport types like a2dp, le audio, pass an additional parameter to get_data_path_id callback function. Signed-off-by: Kiran K Change-Id: Ie3f0c50cb07b6cf8e8ae001361940e8b1411b461 --- drivers/bluetooth/btintel.c | 19 +++++++++++++++---- drivers/bluetooth/hci_vhci.c | 6 +++++- include/net/bluetooth/hci_core.h | 3 ++- net/bluetooth/hci_codec.c | 9 ++++++--- net/bluetooth/hci_conn.c | 3 ++- net/bluetooth/hci_request.c | 5 +++-- net/bluetooth/hci_request.h | 3 ++- 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index f1431143eff5..de4667179efb 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -2207,11 +2207,22 @@ static int btintel_get_codec_config_data(struct hci_dev *hdev, return err; } -static int btintel_get_data_path_id(struct hci_dev *hdev, __u8 *data_path_id) +static int btintel_get_data_path_id(struct hci_dev *hdev, __u8 transport, + __u8 *data_path_id) { - /* Intel uses 1 as data path id for all the usecases */ - *data_path_id = 1; - return 0; + struct btintel_data *intel_data; + + if (transport != HCI_TRANSPORT_SCO_ESCO) + return -EINVAL; + + intel_data = hci_get_priv((hdev)); + + if (intel_data->use_cases.preset[0] & 0x03) { + /* Intel uses 1 as data path id for all the usecases */ + *data_path_id = 1; + return 0; + } + return -EOPNOTSUPP; } static int btintel_configure_offload(struct hci_dev *hdev) diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 56c6b22be10b..a011d5b5694a 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -78,8 +78,12 @@ static int vhci_send_frame(struct hci_dev *hdev, struct sk_buff *skb) return 0; } -static int vhci_get_data_path_id(struct hci_dev *hdev, u8 *data_path_id) +static int vhci_get_data_path_id(struct hci_dev *hdev, u8 transport, + u8 *data_path_id) { + if (transport != HCI_TRANSPORT_SCO_ESCO) + return -EINVAL; + *data_path_id = 0; return 0; } diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index dd8840e70e25..8b8b45f6d5bd 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -619,7 +619,8 @@ struct hci_dev { void (*cmd_timeout)(struct hci_dev *hdev); bool (*wakeup)(struct hci_dev *hdev); int (*set_quality_report)(struct hci_dev *hdev, bool enable); - int (*get_data_path_id)(struct hci_dev *hdev, __u8 *data_path); + int (*get_data_path_id)(struct hci_dev *hdev, __u8 transport, + __u8 *data_path); int (*get_codec_config_data)(struct hci_dev *hdev, __u8 type, struct bt_codec *codec, __u8 *vnd_len, __u8 **vnd_data); diff --git a/net/bluetooth/hci_codec.c b/net/bluetooth/hci_codec.c index f4d8d3a253d8..6d4e5353f05c 100644 --- a/net/bluetooth/hci_codec.c +++ b/net/bluetooth/hci_codec.c @@ -259,6 +259,7 @@ int hci_get_supported_codecs(struct hci_dev *hdev, u8 type, char __user *optval, struct bt_codec codec; u8 num_codecs = 0, i, __user *ptr; struct codec_list *c; + u8 data_path; if (!hci_dev_test_flag(hdev, HCI_OFFLOAD_CODECS_ENABLED)) { err = -EOPNOTSUPP; @@ -270,6 +271,10 @@ int hci_get_supported_codecs(struct hci_dev *hdev, u8 type, char __user *optval, goto error; } + err = hdev->get_data_path_id(hdev, type, &data_path); + if (err < 0) + goto error; + /* find total buffer size required to copy codec + capabilities */ hci_dev_lock(hdev); list_for_each_entry(c, &hdev->local_codecs, list) { @@ -306,9 +311,7 @@ int hci_get_supported_codecs(struct hci_dev *hdev, u8 type, char __user *optval, codec.id = c->id; codec.cid = c->cid; codec.vid = c->vid; - err = hdev->get_data_path_id(hdev, &codec.data_path); - if (err < 0) - break; + codec.data_path = data_path; codec.num_caps = c->num_caps; if (copy_to_user(ptr, &codec, sizeof(codec))) { err = -EFAULT; diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index bd669c95b9a7..62192f463e5c 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -317,7 +317,8 @@ static bool hci_enhanced_setup_sync_conn(struct hci_conn *conn, __u16 handle) /* for offload use case, codec needs to configured before opening SCO */ if (conn->codec.data_path) - hci_req_configure_datapath(hdev, &conn->codec); + hci_req_configure_datapath(hdev, HCI_TRANSPORT_SCO_ESCO, + &conn->codec); conn->state = BT_CONNECT; conn->out = true; diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 92611bfc0b9e..34a104a2ca32 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2950,7 +2950,8 @@ static void config_data_path_complete(struct hci_dev *hdev, u8 status, bt_dev_dbg(hdev, "status %u", status); } -int hci_req_configure_datapath(struct hci_dev *hdev, struct bt_codec *codec) +int hci_req_configure_datapath(struct hci_dev *hdev, u8 transport, + struct bt_codec *codec) { struct hci_request req; int err; @@ -2970,7 +2971,7 @@ int hci_req_configure_datapath(struct hci_dev *hdev, struct bt_codec *codec) goto error; } - err = hdev->get_data_path_id(hdev, &cmd->data_path_id); + err = hdev->get_data_path_id(hdev, transport, &cmd->data_path_id); if (err < 0) goto error; diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index f31420f58525..d80a4e277a20 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -101,7 +101,8 @@ void __hci_req_update_class(struct hci_request *req); /* Returns true if HCI commands were queued */ bool hci_req_stop_discovery(struct hci_request *req); -int hci_req_configure_datapath(struct hci_dev *hdev, struct bt_codec *codec); +int hci_req_configure_datapath(struct hci_dev *hdev, u8 transport, + struct bt_codec *codec); static inline void hci_req_update_scan(struct hci_dev *hdev) { From patchwork Fri Oct 8 13:58:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12545465 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 36523C433FE for ; Fri, 8 Oct 2021 13:53:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D67261042 for ; Fri, 8 Oct 2021 13:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234491AbhJHNz2 (ORCPT ); Fri, 8 Oct 2021 09:55:28 -0400 Received: from mga18.intel.com ([134.134.136.126]:60430 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240647AbhJHNz1 (ORCPT ); Fri, 8 Oct 2021 09:55:27 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10130"; a="213457772" X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="213457772" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 06:53:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="624744994" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga001.fm.intel.com with ESMTP; 08 Oct 2021 06:53:30 -0700 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 v1 5/7] Bluetooth: btintel: Add support to fetch data path id for a2dp offload Date: Fri, 8 Oct 2021 19:28:51 +0530 Message-Id: <20211008135853.8604-5-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211008135853.8604-1-kiran.k@intel.com> References: <20211008135853.8604-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org During *setup*, when configuring offload, set get_data_path_id callback function and support fetching of data path id for a2dp offload use case. Signed-off-by: Kiran K Change-Id: Id05bff65e5e88ac4e6379d4184a5775fb6330c6d --- drivers/bluetooth/btintel.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index de4667179efb..8dcb0e3c7386 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -2212,16 +2212,30 @@ static int btintel_get_data_path_id(struct hci_dev *hdev, __u8 transport, { struct btintel_data *intel_data; - if (transport != HCI_TRANSPORT_SCO_ESCO) + if (transport != HCI_TRANSPORT_SCO_ESCO && + transport != HCI_TRANSPORT_ACL) { + bt_dev_err(hdev, "Invalid transport type %u", transport); return -EINVAL; + } intel_data = hci_get_priv((hdev)); - if (intel_data->use_cases.preset[0] & 0x03) { - /* Intel uses 1 as data path id for all the usecases */ - *data_path_id = 1; - return 0; + switch (transport) { + case HCI_TRANSPORT_SCO_ESCO: + if (intel_data->use_cases.preset[0] & 0x03) { + *data_path_id = 1; + return 0; + } + break; + case HCI_TRANSPORT_ACL: + if (intel_data->use_cases.preset[0] & 0x08) { + *data_path_id = 1; + return 0; + } + break; } + bt_dev_err(hdev, "Required preset is not supported 0x%02x", + intel_data->use_cases.preset[0]); return -EOPNOTSUPP; } @@ -2260,6 +2274,10 @@ static int btintel_configure_offload(struct hci_dev *hdev) hdev->get_codec_config_data = btintel_get_codec_config_data; } + /* supports SBC codec for a2dp offload */ + if (use_cases->preset[0] & 0x08) + hdev->get_data_path_id = btintel_get_data_path_id; + error: kfree_skb(skb); return err; From patchwork Fri Oct 8 13:58:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12545467 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 46D5FC433EF for ; Fri, 8 Oct 2021 13:53:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 303E46101E for ; Fri, 8 Oct 2021 13:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233918AbhJHNzc (ORCPT ); Fri, 8 Oct 2021 09:55:32 -0400 Received: from mga18.intel.com ([134.134.136.126]:60434 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234337AbhJHNz3 (ORCPT ); Fri, 8 Oct 2021 09:55:29 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10130"; a="213457779" X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="213457779" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 06:53:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="624745011" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga001.fm.intel.com with ESMTP; 08 Oct 2021 06:53:31 -0700 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 v1 6/7] Bluetooth: Remove unused member in struct hci_vnd_codec_v2 Date: Fri, 8 Oct 2021 19:28:52 +0530 Message-Id: <20211008135853.8604-6-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211008135853.8604-1-kiran.k@intel.com> References: <20211008135853.8604-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Remove unused "u8 id" member in struct hci_vnd_codec_v2. Vendor codec is identifiable by Company Id and Vendor Id fields. Change-Id: I466f0ecac850115d15dfe72a943fbf3f31baf18d --- include/net/bluetooth/hci.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 451d491f7f68..7ea1bfce204f 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1393,7 +1393,6 @@ struct hci_std_codecs_v2 { } __packed; struct hci_vnd_codec_v2 { - __u8 id; __le16 cid; __le16 vid; __u8 transport; From patchwork Fri Oct 8 13:58:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K, Kiran" X-Patchwork-Id: 12545469 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 659DAC433F5 for ; Fri, 8 Oct 2021 13:53:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50E4A60FD8 for ; Fri, 8 Oct 2021 13:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235027AbhJHNze (ORCPT ); Fri, 8 Oct 2021 09:55:34 -0400 Received: from mga18.intel.com ([134.134.136.126]:60434 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239126AbhJHNzb (ORCPT ); Fri, 8 Oct 2021 09:55:31 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10130"; a="213457783" X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="213457783" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2021 06:53:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,357,1624345200"; d="scan'208";a="624745019" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by fmsmga001.fm.intel.com with ESMTP; 08 Oct 2021 06:53:33 -0700 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 v1 7/7] Bluetooth: Read Output codec capabilities Date: Fri, 8 Oct 2021 19:28:53 +0530 Message-Id: <20211008135853.8604-7-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211008135853.8604-1-kiran.k@intel.com> References: <20211008135853.8604-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When reading codec capabilities, read output (controller to host) capabilities also along with input (host to controller) capabilities. Change-Id: I68c9aaca0fb0f57be3cceb33251b39acfae58aaa --- net/bluetooth/hci_codec.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/bluetooth/hci_codec.c b/net/bluetooth/hci_codec.c index 6d4e5353f05c..c6bd934dcf36 100644 --- a/net/bluetooth/hci_codec.c +++ b/net/bluetooth/hci_codec.c @@ -159,6 +159,9 @@ void hci_read_supported_codecs(struct hci_dev *hdev) caps.id = std_codecs->codec[i]; caps.direction = 0x00; hci_read_codec_capabilities(hdev, LOCAL_CODEC_ACL_MASK, &caps); + + caps.direction = 0x01; + hci_read_codec_capabilities(hdev, LOCAL_CODEC_ACL_MASK, &caps); } skb_pull(skb, flex_array_size(std_codecs, codec, std_codecs->num) @@ -179,6 +182,9 @@ void hci_read_supported_codecs(struct hci_dev *hdev) caps.vid = vnd_codecs->codec[i].vid; caps.direction = 0x00; hci_read_codec_capabilities(hdev, LOCAL_CODEC_ACL_MASK, &caps); + + caps.direction = 0x01; + hci_read_codec_capabilities(hdev, LOCAL_CODEC_ACL_MASK, &caps); } error: @@ -224,6 +230,10 @@ void hci_read_supported_codecs_v2(struct hci_dev *hdev) for (i = 0; i < std_codecs->num; i++) { caps.id = std_codecs->codec[i].id; + caps.direction = 0x00; + hci_read_codec_capabilities(hdev, std_codecs->codec[i].transport, + &caps); + caps.direction = 0x01; hci_read_codec_capabilities(hdev, std_codecs->codec[i].transport, &caps); } @@ -243,6 +253,10 @@ void hci_read_supported_codecs_v2(struct hci_dev *hdev) caps.id = 0xFF; caps.cid = vnd_codecs->codec[i].cid; caps.vid = vnd_codecs->codec[i].vid; + caps.direction = 0x00; + hci_read_codec_capabilities(hdev, vnd_codecs->codec[i].transport, + &caps); + caps.direction = 0x01; hci_read_codec_capabilities(hdev, vnd_codecs->codec[i].transport, &caps); }