Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1659975pxj; Wed, 19 May 2021 10:51:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVFany2QdzovWSuqBLUNXnKm1CsBKyC0/NL0rMrC6qOuloCG2r+QaWyo5LAPoYO9NW/Q6m X-Received: by 2002:a17:906:2504:: with SMTP id i4mr310279ejb.297.1621446670934; Wed, 19 May 2021 10:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621446670; cv=none; d=google.com; s=arc-20160816; b=hVSjwMRHCmMBC3RHZBNgIThaxDd0f0uO9tbE0qe8jahcCEtLWKmK6LdBI0YDOraj6q HWJAP3njNDnSL6rn1hIPhosHkdGB09QqmgEe1nXUe2KxjkI8Zf06WaCIhHtXO13fcCpy J+m4wHdDERUMDgz419coJCD2nCIGiQVE/ELys5cxZAadURvpz2p+xu7XcZ8xv11uTYbt j2Fd4AShx2L/61bfKwSpwvPBYdsMrDfmQd1oFdmqVso10JPrAl139/Pdu9GJFeKavpox peAbdEPIozFCNMuPz9ydWVPlBut3s3F/pCbVpZTFynGMuW50LwQoxbV0rvNhKSC+7qnC vGXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=XSbhO6nKA3WR4x+WRrjTw3cAX9GEQYhCL+AZTo/r+iE=; b=VJK+lBtTrMkwWmsFOMhdZcGWelT1SYEv1S7yHWmuzYsv8emBKYI7Q3csYFdjK6Hlay 6ypGZNuRzCpq1I/ZGbecJ5XYLGzMexKxxVwuxOvZK/EhmBAKwjI7EtSFE7dbW8HRH79H 2uR4A8Tgt+DItwRpEE2KAVnqenht8WaNL+FdK54KQ603zwM7t5j6uFaOHaN3ewUIZ+Pu BO7LHQ3jh1U20SDZfaj0EcTHO67pQGcSniGcnAVlU4Jx3R07J+DJrcndXNW+Sulo7HyD xBQd4X0XRZ60WTQqOMbVOVCrlAQMYrchvNKPlPxtlDE2TrB2OKSw7HjfPwoStTAzu5cD xifQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si290600ejc.644.2021.05.19.10.50.37; Wed, 19 May 2021 10:51:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242442AbhERKkS (ORCPT + 99 others); Tue, 18 May 2021 06:40:18 -0400 Received: from mga02.intel.com ([134.134.136.20]:23234 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348568AbhERKkO (ORCPT ); Tue, 18 May 2021 06:40:14 -0400 IronPort-SDR: VxchUP+h7gdFDjaPGG7zMDqUYWbs8mqa1VOA2Jy86HcG8ngX+6RSJ3PssMWJ3SeonQIeAlXVEL Xq0iX88Bnvig== X-IronPort-AV: E=McAfee;i="6200,9189,9987"; a="187804825" X-IronPort-AV: E=Sophos;i="5.82,309,1613462400"; d="scan'208";a="187804825" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 03:38:56 -0700 IronPort-SDR: PXZQPSDOGb56DXvIWxiuOU8yie54Iv4+2kED4+cTvB1/1dWs974d0fzknUJ6+Drnl47DxGdNCa UKBHI9wAYWkw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,309,1613462400"; d="scan'208";a="433017864" Received: from intel-lenovo-legion-y540-15irh-pg0.iind.intel.com ([10.224.186.95]) by orsmga007.jf.intel.com with ESMTP; 18 May 2021 03:38:54 -0700 From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com, Kiran K Subject: [PATCH v8 6/9] Bluetooth: btintel: Add a callback function to configure data path Date: Tue, 18 May 2021 16:12:29 +0530 Message-Id: <20210518104232.5431-6-kiran.k@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210518104232.5431-1-kiran.k@intel.com> References: <20210518104232.5431-1-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In HFP offload usecase, Intel controllers require offload use case id (NBS or WBS) to be set before opening SCO connection. Define a new callback which gets called on setsockopt SCO socket. User space audio module is expected to set codec via setsockopt(sk, BT_CODEC, ....) before opening SCO connection. Signed-off-by: Kiran K Reviewed-by: Chethan T N Reviewed-by: Srivatsa Ravishankar --- This callback gets called when audio module does setsockopt(sk, BT_CODEC,...) on SCO socket and data_path is 1 (non-HCI transport). For non-HCI transport, Intel controller expects presets to be set before opening SCO connection. Presets are pre-defined, 0 - NBS, 1 - WBS. Likewise additional presets will be defined for A2DP, LE Audio offload use cases. drivers/bluetooth/btintel.c | 50 ++++++++++++++++++++++++++++++++ drivers/bluetooth/btintel.h | 8 +++++ drivers/bluetooth/btusb.c | 1 + include/net/bluetooth/hci.h | 8 +++++ include/net/bluetooth/hci_core.h | 2 ++ 5 files changed, 69 insertions(+) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 8407e9736c62..8efb15504973 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -1308,6 +1308,56 @@ int btintel_get_data_path_id(struct hci_dev *hdev) } EXPORT_SYMBOL_GPL(btintel_get_data_path_id); +int btintel_configure_data_path(struct hci_dev *hdev, __u8 type, + struct bt_codec *codec) +{ + __u8 preset; + struct hci_op_configure_data_path *cmd; + __u8 buffer[255]; + struct sk_buff *skb; + + if (type != SCO_LINK && type != ESCO_LINK) + return -EINVAL; + + switch (codec->id) { + case 0x02: + preset = 0x00; + break; + case 0x05: + preset = 0x01; + break; + default: + return -EINVAL; + } + + cmd = (void *)buffer; + cmd->data_path_id = 0x01; + cmd->len = 1; + cmd->data[0] = preset; + + cmd->direction = 0x00; + skb = __hci_cmd_sync(hdev, HCI_CONFIGURE_DATA_PATH, sizeof(*cmd) + 1, + cmd, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "configure input data path failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + kfree_skb(skb); + + cmd->direction = 0x01; + skb = __hci_cmd_sync(hdev, HCI_CONFIGURE_DATA_PATH, sizeof(*cmd) + 1, + cmd, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "configure output data path failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + kfree_skb(skb); + return 0; +} +EXPORT_SYMBOL_GPL(btintel_configure_data_path); + MODULE_AUTHOR("Marcel Holtmann "); MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION); MODULE_VERSION(VERSION); diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 6d4edfd16d44..f4af22ecdc0d 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -177,6 +177,8 @@ int btintel_set_debug_features(struct hci_dev *hdev, const struct intel_debug_features *features); int btintel_read_offload_usecases(struct hci_dev *hdev); int btintel_get_data_path_id(struct hci_dev *hdev); +int btintel_configure_data_path(struct hci_dev *hdev, __u8 type, + struct bt_codec *codec); #else static inline int btintel_check_bdaddr(struct hci_dev *hdev) @@ -318,4 +320,10 @@ static int btintel_get_data_path_id(struct hci_dev *hdev) { return -EOPNOTSUPP; } + +static int btintel_configure_data_path(struct hci_dev *hdev, __u8 type, + struct bt_codec *codec) +{ + return -EOPNOTSUPP; +} #endif diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index f7b349db392a..220e7c85db10 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -4632,6 +4632,7 @@ static int btusb_probe(struct usb_interface *intf, hdev->set_bdaddr = btintel_set_bdaddr; hdev->cmd_timeout = btusb_intel_cmd_timeout; hdev->get_data_path_id = btintel_get_data_path_id; + hdev->configure_data_path = btintel_configure_data_path; set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 9658600ae5de..bd666b114aea 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1257,6 +1257,14 @@ struct hci_rp_read_local_oob_ext_data { __u8 rand256[16]; } __packed; +#define HCI_CONFIGURE_DATA_PATH 0x0c83 +struct hci_op_configure_data_path { + __u8 direction; + __u8 data_path_id; + __u8 len; + __u8 data[]; +} __packed; + #define HCI_OP_READ_LOCAL_VERSION 0x1001 struct hci_rp_read_local_version { __u8 status; diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 78d1ebab58f6..959585bafa8d 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -618,6 +618,8 @@ struct hci_dev { void (*cmd_timeout)(struct hci_dev *hdev); bool (*prevent_wake)(struct hci_dev *hdev); int (*get_data_path_id)(struct hci_dev *hdev); + int (*configure_data_path)(struct hci_dev *hdev, __u8 type, + struct bt_codec *codec); }; #define HCI_PHY_HANDLE(handle) (handle & 0xff) -- 2.17.1