Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp369011ybb; Sat, 28 Mar 2020 00:47:22 -0700 (PDT) X-Google-Smtp-Source: ADFU+vubl96VCa5OUWkC6jznNtnaCA/kZ6PrGoQnaViLtihVRpNdmkcyfNmY9vAgvj/5/RPg7Pig X-Received: by 2002:a9d:630f:: with SMTP id q15mr1755853otk.146.1585381641993; Sat, 28 Mar 2020 00:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585381641; cv=none; d=google.com; s=arc-20160816; b=L+3oF5GRgx7nT8LBOJ/GZBMY0QL5kA50Qz5sS1DJ4gSsPujmeB9FVD0cM7edCd/66y y+iC6rf2PIaHK1GTAldRnDuHb3yPkyZFSDp1Kv8935+4kXi9UR0l1PoZyzepD6pX9z/l LkNeFUNWbmQR9PnYY9C+w4pmSLk9wz8+/LPjPsorA9QfbqVCbFoDYJha8HSlQTKMyVSf 2my6AwEUZKfmXlW6Mf/h1JIXU0UNsilCCeHf4idi6eGSv1cH92MPSFkleyibCwwD4vWS NByDMItrRbByreduDxyztCd/k35jrQbJfBx+KX81km3G0CgBBkieEwZdw90kQRohbmlM B10A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=udOjHUuVrYhmjpcD3RfPEn/4AJ+kCTCeCAwVdy3cmzE=; b=RD+GqOyGN/Uvt+dFXd2KhK/aEWfweUST4q+Pi+36A4Fn29bQPonbgcU8GRaw5vtsXy gU2U2TcVaBCa5OGc2aR7b1dsfWktwkpGW0SOvIFYBB8YVe9/tBbN87AvzNwZadY22no3 iPpy3t7HgajOybmUs8jjuBrdTRXsjSi9zJw8zlhLk7IqK8JEQIFLbrCTxU5xcZyqlcmG W+yNsr540/rgu+zn1miRzc6IQVEFnZtLZ8wbt85W/kOGUTLbNAr/rgNVwVACXGvp4FxO V13XsRBSp6woiIJ/vOo806A6X/9U7P4zauZn0HHbJVHrZMHG30GC4ugQdG198az6ZjAY On6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XOTwvg1q; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n9si3274956ota.103.2020.03.28.00.46.55; Sat, 28 Mar 2020 00:47:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XOTwvg1q; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726295AbgC1Hqq (ORCPT + 99 others); Sat, 28 Mar 2020 03:46:46 -0400 Received: from mail-pg1-f170.google.com ([209.85.215.170]:36734 "EHLO mail-pg1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725800AbgC1Hqq (ORCPT ); Sat, 28 Mar 2020 03:46:46 -0400 Received: by mail-pg1-f170.google.com with SMTP id j29so5832971pgl.3 for ; Sat, 28 Mar 2020 00:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=udOjHUuVrYhmjpcD3RfPEn/4AJ+kCTCeCAwVdy3cmzE=; b=XOTwvg1q2GtN1U/qnPXTCULtOxjsFTkJ+RaYVY3ArtrTo0vWDo+m6lxr2PDmhtJrvI n3C+CEOWHRgiHJd6wuP+jDzZvXbSaKaJ9K2cP0nL+3YoMA6kSema8qVVccM3LxGjshvv AHTkZZE1Y0+ZtVGSTV+KZRDRY6+n1u3t19Vro= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=udOjHUuVrYhmjpcD3RfPEn/4AJ+kCTCeCAwVdy3cmzE=; b=KcW9tPmxcZRcvbWIgfquCDrVyd39Jmc9kLh/jSCpCHZDx1Ggo5+N13HlZx8D/1LqLH 6FwaSuFJuTTsRw51jyshxEKhvnZBLO2oXcbNEkc2yovkwuJEWzv3FuLTSp2UynjDau00 Ia1B8r2RAH0Dl31Fs3WU2KjqgWz8IbVIqrMIyYVJA7rYFRnUQzK/YSknDwf41qLsrXuF mfWyKiqrUiUZ1rvgbnyFT1Rarl16y9C6MDDI1M2XGAHk+Y25fuuXFWwb5++p1NuhrMPa 8B3T9d3rjbsDqq/ojUtNB4XXBZqyBJz8BvRv56oZ9OViF4PLZBiE8sZECIygvK91h7Jt LcHg== X-Gm-Message-State: ANhLgQ1HACvVRgruCYMUE1KVmw/OFq8zMC/UDdaLmVAWxmL2O+/63h3V wXQumtBxDR+eZTQcw9eHtLTrKFgrvMI= X-Received: by 2002:a63:d709:: with SMTP id d9mr3168715pgg.82.1585381604560; Sat, 28 Mar 2020 00:46:44 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:b46:ac84:1014:9555]) by smtp.gmail.com with ESMTPSA id r59sm5273063pjb.45.2020.03.28.00.46.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Mar 2020 00:46:43 -0700 (PDT) From: Miao-chen Chou To: Bluetooth Kernel Mailing List Cc: Alain Michaud , Marcel Holtmann , Luiz Augusto von Dentz , Miao-chen Chou , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 1/2] Bluetooth: btusb: Indicate Microsoft vendor extension for Intel 9460/9560 and 9160/9260 Date: Sat, 28 Mar 2020 00:46:31 -0700 Message-Id: <20200328004507.v4.1.I0e975833a6789e8acc74be7756cd54afde6ba98c@changeid> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200328074632.21907-1-mcchou@chromium.org> References: <20200328074632.21907-1-mcchou@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds a bit mask of driver_info for Microsoft vendor extension and indicates the support for Intel 9460/9560 and 9160/9260. See https://docs.microsoft.com/en-us/windows-hardware/drivers/bluetooth/ microsoft-defined-bluetooth-hci-commands-and-events for more information about the extension. This also add a kernel config, BT_MSFTEXT, and a source file to facilitate Microsoft vendor extension functions. This was verified with Intel ThunderPeak BT controller where msft_vnd_ext_opcode is 0xFC1E. Signed-off-by: Marcel Holtmann Signed-off-by: Miao-chen Chou --- Changes in v4: - Introduce CONFIG_BT_MSFTEXT as a starting point of providing a framework to use Microsoft extension - Create include/net/bluetooth/msft.h and net/bluetooth/msft.c to facilitate functions of Microsoft extension. Changes in v3: - Create net/bluetooth/msft.c with struct msft_vnd_ext defined internally and change the hdev->msft_ext field to void*. - Define and expose msft_vnd_ext_set_opcode() for btusb use. - Init hdev->msft_ext in hci_alloc_dev() and deinit it in hci_free_dev(). Changes in v2: - Define struct msft_vnd_ext and add a field of this type to struct hci_dev to facilitate the support of Microsoft vendor extension. drivers/bluetooth/btusb.c | 11 +++++++++-- include/net/bluetooth/hci_core.h | 4 ++++ net/bluetooth/Kconfig | 9 ++++++++- net/bluetooth/Makefile | 1 + net/bluetooth/msft.c | 16 ++++++++++++++++ net/bluetooth/msft.h | 19 +++++++++++++++++++ 6 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 net/bluetooth/msft.c create mode 100644 net/bluetooth/msft.h diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 3bdec42c9612..0fe47708d3c8 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -21,6 +21,7 @@ #include #include +#include "../../net/bluetooth/msft.h" #include "btintel.h" #include "btbcm.h" #include "btrtl.h" @@ -58,6 +59,7 @@ static struct usb_driver btusb_driver; #define BTUSB_CW6622 0x100000 #define BTUSB_MEDIATEK 0x200000 #define BTUSB_WIDEBAND_SPEECH 0x400000 +#define BTUSB_MSFT_VND_EXT 0x800000 static const struct usb_device_id btusb_table[] = { /* Generic Bluetooth USB device */ @@ -335,7 +337,8 @@ static const struct usb_device_id blacklist_table[] = { /* Intel Bluetooth devices */ { USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_NEW | - BTUSB_WIDEBAND_SPEECH }, + BTUSB_WIDEBAND_SPEECH | + BTUSB_MSFT_VND_EXT }, { USB_DEVICE(0x8087, 0x0026), .driver_info = BTUSB_INTEL_NEW | BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x8087, 0x0029), .driver_info = BTUSB_INTEL_NEW | @@ -348,7 +351,8 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x8087, 0x0aa7), .driver_info = BTUSB_INTEL | BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x8087, 0x0aaa), .driver_info = BTUSB_INTEL_NEW | - BTUSB_WIDEBAND_SPEECH }, + BTUSB_WIDEBAND_SPEECH | + BTUSB_MSFT_VND_EXT }, /* Other Intel Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01), @@ -3800,6 +3804,9 @@ static int btusb_probe(struct usb_interface *intf, 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); + + if (id->driver_info & BTUSB_MSFT_VND_EXT) + msft_set_opcode(hdev, 0xFC1E); } if (id->driver_info & BTUSB_MARVELL) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index d4e28773d378..239cae2d9998 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -484,6 +484,10 @@ struct hci_dev { struct led_trigger *power_led; #endif +#if IS_ENABLED(CONFIG_BT_MSFTEXT) + __u16 msft_opcode; +#endif + int (*open)(struct hci_dev *hdev); int (*close)(struct hci_dev *hdev); int (*flush)(struct hci_dev *hdev); diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 165148c7c4ce..5929ccb02b39 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -30,7 +30,7 @@ menuconfig BT L2CAP (Logical Link Control and Adaptation Protocol) SMP (Security Manager Protocol) on LE (Low Energy) links HCI Device drivers (Interface to the hardware) - RFCOMM Module (RFCOMM Protocol) + RFCOMM Module (RFCOMM Protocol) BNEP Module (Bluetooth Network Encapsulation Protocol) CMTP Module (CAPI Message Transport Protocol) HIDP Module (Human Interface Device Protocol) @@ -93,6 +93,13 @@ config BT_LEDS This option selects a few LED triggers for different Bluetooth events. +config BT_MSFTEXT + bool "Enable Microsoft extensions" + depends on BT + help + This options enables support for the Microsoft defined HCI + vendor extensions. + config BT_SELFTEST bool "Bluetooth self testing support" depends on BT && DEBUG_KERNEL diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile index fda41c0b4781..41dd541a44a5 100644 --- a/net/bluetooth/Makefile +++ b/net/bluetooth/Makefile @@ -19,5 +19,6 @@ bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ bluetooth-$(CONFIG_BT_BREDR) += sco.o bluetooth-$(CONFIG_BT_HS) += a2mp.o amp.o bluetooth-$(CONFIG_BT_LEDS) += leds.o +bluetooth-$(CONFIG_BT_MSFTEXT) += msft.o bluetooth-$(CONFIG_BT_DEBUGFS) += hci_debugfs.o bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c new file mode 100644 index 000000000000..7609932c48ca --- /dev/null +++ b/net/bluetooth/msft.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* Copyright (C) 2020 Google Corporation */ + +#include +#include + +#include "msft.h" + +void msft_set_opcode(struct hci_dev *hdev, __u16 opcode) +{ + hdev->msft_opcode = opcode; + + bt_dev_info(hdev, "Enabling MSFT extensions with opcode 0x%2.2x", + hdev->msft_opcode); +} +EXPORT_SYMBOL(msft_set_opcode); diff --git a/net/bluetooth/msft.h b/net/bluetooth/msft.h new file mode 100644 index 000000000000..7218ea759dde --- /dev/null +++ b/net/bluetooth/msft.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (C) 2020 Google Corporation */ + +#ifndef __MSFT_H +#define __MSFT_H + +#include + +#if IS_ENABLED(CONFIG_BT_MSFTEXT) + +void msft_set_opcode(struct hci_dev *hdev, __u16 opcode); + +#else + +static inline void msft_set_opcode(struct hci_dev *hdev, __u16 opcode) {} + +#endif + +#endif /* __MSFT_H*/ -- 2.24.1