Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp410289ybf; Fri, 28 Feb 2020 00:07:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwjqP9PEWeFFwTEBnopz+h2d1lOHfAItYdnib9d4dPvWOobzo/f5f4yD7GeB7nUS/rkh1do X-Received: by 2002:a9d:7356:: with SMTP id l22mr2239619otk.335.1582877226203; Fri, 28 Feb 2020 00:07:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582877226; cv=none; d=google.com; s=arc-20160816; b=FgGb0PdqhPbWyKeeAqk7nvE3T4CCt54r45IE5u/upgUOBntGoVyjjm+JzN3gxSLQ2r Z25I8eXRFydcHy54kkLeuHZUhJ53rXecSAwOYRuiEM2Z8t8fCnAAyoKjrLG/Pa+jS4Sy aJei9BRJfrT2dzGz9gdDM1YoOjSh0Uj5G4vP+kcL7UcVot71VbtiIbRlAf/dUZCOOU9/ rI6otrlkvTvtgdP9CvGkhPec78N0ml0WCfyyjRZdfAVA34NUXjohuZkJba19Jwz8DeC3 97NrelQx2BcLy+19HUdu+h3Q0MDz2Ekdl9CSML1qW0x459AAzvE6+vIrBZL4WxZDdgDE dsUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=WjNYi/nrmjQ36ABSU5F71B0BeGRJgoBvWwx3dr7CjH0=; b=OKqdQIvREQQlsk74FLIr6u/pmm698i3FLD0RTeFSqaqhNkaL1CLMO1yxiYve+mB8sL jgTIE4d+l9xqMa/W1wIA619W1zmZVt2fm53Ua2xj0z4LK9ovdou5Pd0WR7cK5/xu6lcq KNs161qIHCf6W25nox2vC2OjgMWm6iolNs+DN2bn3kl5JF/Wob8kiwwefkD3qs6wlsWN Q+sPUDzYuoA+iuxz7PHWFAdwtvVpHP21Sfxu6WZq3DxKhszHbJtJQpMcda2pWvyZL+LX uL+dO0/4Msn8apKoixjO1qdUM65sptd6tNXLFR7mmy81V9/S6aII9+/3J4gKGFG7crwa A0Lg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13si1170023otg.56.2020.02.28.00.06.48; Fri, 28 Feb 2020 00:07:06 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbgB1IGS convert rfc822-to-8bit (ORCPT + 99 others); Fri, 28 Feb 2020 03:06:18 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:46785 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbgB1IGS (ORCPT ); Fri, 28 Feb 2020 03:06:18 -0500 Received: from marcel-macbook.fritz.box (p4FEFC5A7.dip0.t-ipconnect.de [79.239.197.167]) by mail.holtmann.org (Postfix) with ESMTPSA id 5D6C5CECF5; Fri, 28 Feb 2020 09:15:43 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) Subject: Re: [PATCH v1 3/3] bluetooth: Enable erroneous data reporting if wbs is supported From: Marcel Holtmann In-Reply-To: <20200227182938.110670-4-alainm@chromium.org> Date: Fri, 28 Feb 2020 09:06:16 +0100 Cc: Bluez mailing list Content-Transfer-Encoding: 8BIT Message-Id: References: <20200227182938.110670-1-alainm@chromium.org> <20200227182938.110670-4-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.60.0.2.5) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Alain, > 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 > --- > > 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; > + So I realized that in monitor/bt.h I also used the full name, but inside the kernel code it feels way too long and creates harder to read code. My proposal is HCI_OP_READ_DEF_ERR_DATA_REPORTING and HCI_OP_WRITE_DEF_ERR_DATA_REPORTING. You might realize that I included the read command here as well. So first, we need to read the current value of the controller if supported and then also start tracking changes to it. You will find examples in hci_event.c and how that is done. Store the current value in hci_dev. I also realized that we should only advertise Wideband speech support if this command is actually supported. So that you might need to fix as well. > #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) && Don’t do this in hci_dev_do_open. You want to read the current value in the init procedure and change it if needed. This is similar to Secure Connections and other values that we only allow to change while the controller is down. Regards Marcel