Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp237164pxf; Tue, 6 Apr 2021 20:47:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf1mBdYT1aciiEIveIAbG6QmkgqiVEMoxVR85CQvgPibnwdqpLaMKLgFwjp179NqVCLh8C X-Received: by 2002:a17:906:c09:: with SMTP id s9mr1355060ejf.145.1617767259811; Tue, 06 Apr 2021 20:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617767259; cv=none; d=google.com; s=arc-20160816; b=efQN9TtPjPzkfkN8Xj2sSNGaWfnqAenkZbmDdOIV/8PTGWwPjV1PEDeutTMh75rGNd y39r+jLFUCA8xIAqdT3gTSRS7oGHit6fEJ28xB7lWKBTEcv+AHKDRHOv13OlZz02odfj QAgdVGOSOg/iJHIXITJAPxmEOwUnIziZDhFSA+SR8UTqdMtqp0GYPSJdHy4v4VMNc3ty m8AYH7mXK3ck9fId8BCLsEvdbFMKlr5q94RCXc6hBaZt+0yXkfR1AsGr2baDstdx9jK6 Sk+ZpGEEC3rDnfkXihkzvS48r6CZMz2FKWQ183427ko/IBhhs8ZHrsepi9PqurMtASB7 pO1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=lCFLtrKXF3h4soTvYh3SXY8b2OsZvdx3Tpsz6Q2fNr8=; b=JeqV03nM5tw7Tv8Ch6xT6N1o9sHbq3Wt2xzlJYPz0+TdWs7ftXgPXrrrxB4RUqnyQe /2+DqUNpWCU9dbcYn/AvTVCP1ZIJVYIpRLzMCZpnCOn30G60v0VrRN+1jVqR3V/IBtGc CkH/jHsQDZmYe3pRTiBrYb+o7C2zk01cbYES4MM0JXzicESte67qP5RVYlRRXS8rngYH bkH912DeTugx86zv43h3sdHNy/5IDm7Kjap0MrYrFDvWYFgNX9hWHxt32Ql3C9pckdWs ZvhQ8khB08DnoODxZ6ZX+2KgCDta5WXqdui/lxIleZB1D4FxLIZOKjKuiflOJYTCQgen wXRw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si17580107edw.468.2021.04.06.20.46.53; Tue, 06 Apr 2021 20:47:39 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243988AbhDFNgr (ORCPT + 99 others); Tue, 6 Apr 2021 09:36:47 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:47734 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344546AbhDFNgr (ORCPT ); Tue, 6 Apr 2021 09:36:47 -0400 Received: from localhost.localdomain (p4ff9f418.dip0.t-ipconnect.de [79.249.244.24]) by mail.holtmann.org (Postfix) with ESMTPSA id EE62FCED22 for ; Tue, 6 Apr 2021 15:44:20 +0200 (CEST) From: Marcel Holtmann To: linux-bluetooth@vger.kernel.org Subject: [PATCH] Bluetooth: Add support for reading AOSP vendor capabilities Date: Tue, 6 Apr 2021 15:36:32 +0200 Message-Id: <20210406133632.241599-1-marcel@holtmann.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When drivers indicate support for AOSP vendor extension, initialize them and read its capabilities. Signed-off-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 11 ++++++++++ net/bluetooth/Kconfig | 7 +++++++ net/bluetooth/Makefile | 1 + net/bluetooth/aosp.c | 35 ++++++++++++++++++++++++++++++++ net/bluetooth/aosp.h | 16 +++++++++++++++ net/bluetooth/hci_core.c | 3 +++ 6 files changed, 73 insertions(+) create mode 100644 net/bluetooth/aosp.c create mode 100644 net/bluetooth/aosp.h diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 1101589422d8..29f609b67f22 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -596,6 +596,10 @@ struct hci_dev { void *msft_data; #endif +#if IS_ENABLED(CONFIG_BT_AOSPEXT) + bool aosp_capable; +#endif + int (*open)(struct hci_dev *hdev); int (*close)(struct hci_dev *hdev); int (*flush)(struct hci_dev *hdev); @@ -1248,6 +1252,13 @@ static inline void hci_set_msft_opcode(struct hci_dev *hdev, __u16 opcode) #endif } +static inline void hci_set_aosp_capable(struct hci_dev *hdev) +{ +#if IS_ENABLED(CONFIG_BT_AOSPEXT) + hdev->aosp_capable = true; +#endif +} + int hci_dev_open(__u16 dev); int hci_dev_close(__u16 dev); int hci_dev_do_close(struct hci_dev *hdev); diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 400c5130dc0a..e0ab4cd7afc3 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -99,6 +99,13 @@ config BT_MSFTEXT This options enables support for the Microsoft defined HCI vendor extensions. +config BT_AOSPEXT + bool "Enable Android Open Source Project extensions" + depends on BT + help + This options enables support for the Android Open Source + Project defined HCI vendor extensions. + config BT_DEBUGFS bool "Export Bluetooth internals in debugfs" depends on BT && DEBUG_FS diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile index 1c645fba8c49..cc0995301f93 100644 --- a/net/bluetooth/Makefile +++ b/net/bluetooth/Makefile @@ -20,5 +20,6 @@ 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_AOSPEXT) += aosp.o bluetooth-$(CONFIG_BT_DEBUGFS) += hci_debugfs.o bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o diff --git a/net/bluetooth/aosp.c b/net/bluetooth/aosp.c new file mode 100644 index 000000000000..a1b7762335a5 --- /dev/null +++ b/net/bluetooth/aosp.c @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2021 Intel Corporation + */ + +#include +#include + +#include "aosp.h" + +void aosp_do_open(struct hci_dev *hdev) +{ + struct sk_buff *skb; + + if (!hdev->aosp_capable) + return; + + bt_dev_dbg(hdev, "Initialize AOSP extension"); + + /* LE Get Vendor Capabilities Command */ + skb = __hci_cmd_sync(hdev, hci_opcode_pack(0x3f, 0x153), 0, NULL, + HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) + return; + + kfree_skb(skb); +} + +void aosp_do_close(struct hci_dev *hdev) +{ + if (!hdev->aosp_capable) + return; + + bt_dev_dbg(hdev, "Cleanup of AOSP extension"); +} diff --git a/net/bluetooth/aosp.h b/net/bluetooth/aosp.h new file mode 100644 index 000000000000..d5603afeb718 --- /dev/null +++ b/net/bluetooth/aosp.h @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2021 Intel Corporation + */ + +#if IS_ENABLED(CONFIG_BT_AOSPEXT) + +void aosp_do_open(struct hci_dev *hdev); +void aosp_do_close(struct hci_dev *hdev); + +#else + +static inline void msft_do_open(struct hci_dev *hdev) {} +static inline void msft_do_close(struct hci_dev *hdev) {} + +#endif diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 520718d7679b..37a6c566aa62 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -44,6 +44,7 @@ #include "smp.h" #include "leds.h" #include "msft.h" +#include "aosp.h" static void hci_rx_work(struct work_struct *work); static void hci_cmd_work(struct work_struct *work); @@ -1586,6 +1587,7 @@ static int hci_dev_do_open(struct hci_dev *hdev) ret = hdev->set_diag(hdev, true); msft_do_open(hdev); + aosp_do_open(hdev); clear_bit(HCI_INIT, &hdev->flags); @@ -1782,6 +1784,7 @@ int hci_dev_do_close(struct hci_dev *hdev) hci_sock_dev_event(hdev, HCI_DEV_DOWN); + aosp_do_close(hdev); msft_do_close(hdev); if (hdev->flush) -- 2.30.2