All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alain Michaud <alainm@chromium.org>
To: linux-bluetooth@vger.kernel.org
Cc: Alain Michaud <alainm@chromium.org>
Subject: [PATCH v1 3/3] bluetooth: Enable erroneous data reporting if wbs is supported
Date: Thu, 27 Feb 2020 18:29:41 +0000	[thread overview]
Message-ID: <20200227182938.110670-4-alainm@chromium.org> (raw)
In-Reply-To: <20200227182938.110670-1-alainm@chromium.org>

This change will enable erroneous data reporting if wide band speech is
supported by the controller as indicated by the
HCI_QUIRK_WIDE_BAND_SPEECH_SUPPORTED quirk.

Signed-off-by: Alain Michaud <alainm@chromium.org>
---

 include/net/bluetooth/hci.h |  7 +++++++
 net/bluetooth/hci_core.c    | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index b214c4358d1c..807fd40bb358 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1095,6 +1095,13 @@ struct hci_rp_read_inq_rsp_tx_power {
 	__s8     tx_power;
 } __packed;
 
+#define HCI_OP_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING	0x0c5b
+	#define ERRONEOUS_DATA_REPORTING_DISABLED	0x00
+	#define ERRONEOUS_DATA_REPORTING_ENABLED	0x01
+struct hci_cp_write_default_erroneous_data_reporting {
+	__u8     erroneous_data_reporting;
+} __packed;
+
 #define HCI_OP_SET_EVENT_MASK_PAGE_2	0x0c63
 
 #define HCI_OP_READ_LOCATION_DATA	0x0c64
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 1ca7508b6ca7..19afb85ad399 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1382,6 +1382,29 @@ static void hci_dev_get_bd_addr_from_property(struct hci_dev *hdev)
 	bacpy(&hdev->public_addr, &ba);
 }
 
+static int hci_write_default_erroneous_data_req(struct hci_request *req,
+						unsigned long opt)
+{
+	struct hci_cp_write_default_erroneous_data_reporting cp = {};
+
+	cp.erroneous_data_reporting = (__u8)opt;
+	hci_req_add(req, HCI_OP_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING,
+		    sizeof(cp), &cp);
+	return 0;
+}
+
+static void hci_write_default_erroneous_data(struct hci_dev *hdev,
+					     __u8 erroneous_data_reporting)
+{
+	int err = __hci_req_sync(hdev,
+				 hci_write_default_erroneous_data_req,
+				 erroneous_data_reporting, HCI_CMD_TIMEOUT,
+				 NULL);
+	if (err) {
+		BT_ERR("HCI_OP_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING failed");
+	}
+}
+
 static int hci_dev_do_open(struct hci_dev *hdev)
 {
 	int ret = 0;
@@ -1547,6 +1570,16 @@ static int hci_dev_do_open(struct hci_dev *hdev)
 		set_bit(HCI_UP, &hdev->flags);
 		hci_sock_dev_event(hdev, HCI_DEV_UP);
 		hci_leds_update_powered(hdev, true);
+
+		/* If the controller supports wide_band_speech, enable erroneous
+		 * data reporting.
+		 */
+		if (test_bit(HCI_QUIRK_WIDE_BAND_SPEECH_SUPPORTED,
+			     &hdev->quirks)) {
+			hci_write_default_erroneous_data(hdev,
+					      ERRONEOUS_DATA_REPORTING_ENABLED);
+		}
+
 		if (!hci_dev_test_flag(hdev, HCI_SETUP) &&
 		    !hci_dev_test_flag(hdev, HCI_CONFIG) &&
 		    !hci_dev_test_flag(hdev, HCI_UNCONFIGURED) &&
-- 
2.25.1.481.gfbce0eb801-goog


  parent reply	other threads:[~2020-02-27 18:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-27 18:29 [PATCH v1 0/3] This series allows a higher level HFP implementation to enable wbs Alain Michaud
2020-02-27 18:29 ` [PATCH v1 1/3] bluetooth: Add flag to define wideband speech capability Alain Michaud
2020-02-28  7:56   ` Marcel Holtmann
2020-02-27 18:29 ` [PATCH v1 2/3] bluetooth: Support querying for WBS support through MGMT Alain Michaud
2020-02-28  7:56   ` Marcel Holtmann
2020-02-27 18:29 ` Alain Michaud [this message]
2020-02-28  8:06   ` [PATCH v1 3/3] bluetooth: Enable erroneous data reporting if wbs is supported Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200227182938.110670-4-alainm@chromium.org \
    --to=alainm@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.