Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1152458pxa; Thu, 13 Aug 2020 01:45:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfjYnrUD6ybefC3WDpFNqQ8cVuKCavy1KT+JB2J+ENG3NM8uj9t4hGxIjIi7+Th6EqD6HT X-Received: by 2002:a17:906:ca4d:: with SMTP id jx13mr3678103ejb.548.1597308333703; Thu, 13 Aug 2020 01:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597308333; cv=none; d=google.com; s=arc-20160816; b=WUGcMN7Q+pxWmXpuRBKD9ac6tRQRksfuaEObCRd5yhuC8noi3ekPEBuwbQYDoNlVpF H5sLFVO+lPdV8JUorsvkMahll/q0bh4+SEODuin1+Dbn4E3Y2l+c89R52FtfeNFQwf2m EUUNVgdf7PPnP4M7UkIhRHxfzenSsh4ClWYB1gIDS2jUUufaOHMK/1fxvfBmsGg5xH3o HCyKr0IlQv8Af1LibvxaDAtTxTr1f+Qoa7t8U2RVdS7xZdEZCHt853hMXWgXhAy2P7kW le5TQMSwqrdy9xQHiPF6kKKdSLKbJbHR1p7uqxc45NEV+CSxVf/vj4uDJ58e11rY2EOP kdKg== 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=kLumMv32BeXkjDSmCSCfzv64I6KOcubFlQAnOBbQLHk=; b=D+xDF6nYKW4fYot5G4vNwcor5MTbVZRq+Bm/Z8NGBPMR7YlidhvoxZKgvk0PSnu2jb acTrHMQPJW/R7Gg8kxtY+9n92cU9u6kr42sDjOnJmt4wqicZa5g9hlSKyM7+h/kH1VZI WayeaeWup5387Dxg6DI/rhj9txx9PBsxIug+PqCHPg1RaAW9tSqRnl01vgR7kFsVMez3 UqVU6QCLkBa6CUSgFwJmPrA+FobqKcv5+9Gx2xvEr5SsivQgRAYcOHRvlYU65NWma4F3 6MYXwsT/wEDRMK6jy+S7AFmJ5TKRGBMyIjvOkNURltXH6DRUEK2QPAQvH1/X7isL9b6W +Lrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="csVCNsb/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x8si2894093ejs.414.2020.08.13.01.45.09; Thu, 13 Aug 2020 01:45:33 -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; dkim=pass header.i=@chromium.org header.s=google header.b="csVCNsb/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbgHMImQ (ORCPT + 99 others); Thu, 13 Aug 2020 04:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726648AbgHMImQ (ORCPT ); Thu, 13 Aug 2020 04:42:16 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72086C061383 for ; Thu, 13 Aug 2020 01:42:16 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id ep8so2440821pjb.3 for ; Thu, 13 Aug 2020 01:42:16 -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=kLumMv32BeXkjDSmCSCfzv64I6KOcubFlQAnOBbQLHk=; b=csVCNsb/O6GNaQuqDG/6pQTHaBxFMmUH+HNd8tBVt3o1oYYoahhUoR+zPRfRsHeC53 W5RiwuVQcQYezemmi7mrz9Gt1ewdaWgPeZbVH1glbExQs7ev2LnIdr5rd6oGyJSUXTUH XE2KyPEseLoBPEgcdTPLzYLrOGBDqC5EPqOAs= 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=kLumMv32BeXkjDSmCSCfzv64I6KOcubFlQAnOBbQLHk=; b=QXXKHQRimnuoBekglt2Wt0E5vp3bVG2gTMpvT2D9YvdIe/Q2PYbbhBX9UOd9bZQgHE o52xJIX73C+iMJGxCZ44faxQlpMTuLu8WunIIUXjvTP1oYM+S5DktVC+NKrvuj2dBNqK t9y0Bvegwt7B7qH57V41D9kJorwW1kbO/mblyLmRcw4mRB/PmgMYJomFraQnNEXl8pLO 3MsYsWqCJuNRY7XnS7oEXdhe0usAAhwUzJ8G8rQGt+/efEBCMki6h5g08QS5lll0pffO wHIWNKRMVKw/wG70O0q9YlPvB+Dyw16kXJilSG5vL8tU9OWt+jq/mHygnACtkI+N7l4W iuHQ== X-Gm-Message-State: AOAM530hKbuysNe6R9Ije9AR/C0GHIvTZa4qHxRL0omUwEZloMg9EgXc IF18RuiWeLMlV1mmccNIOYV7lmypIbU= X-Received: by 2002:a17:90a:a65:: with SMTP id o92mr4072981pjo.104.1597308135142; Thu, 13 Aug 2020 01:42:15 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:de4a:3eff:fe7d:ff5f]) by smtp.gmail.com with ESMTPSA id y29sm5032035pfr.11.2020.08.13.01.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2020 01:42:14 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang , Alain Michaud , Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v1 1/2] Bluetooth: btusb: define HCI packet sizes of USB Alts Date: Thu, 13 Aug 2020 16:41:28 +0800 Message-Id: <20200813164059.v1.1.I56de28ec171134cb9f97062e2c304a72822ca38b@changeid> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog In-Reply-To: <20200813084129.332730-1-josephsih@chromium.org> References: <20200813084129.332730-1-josephsih@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 It is desirable to define the HCI packet payload sizes of USB alternate settings so that they can be exposed to user space. Reviewed-by: Alain Michaud Reviewed-by: Abhishek Pandit-Subedi Signed-off-by: Joseph Hwang --- drivers/bluetooth/btusb.c | 43 ++++++++++++++++++++++++-------- include/net/bluetooth/hci_core.h | 1 + 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 8d2608ddfd0875..df7cadf6385868 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -459,6 +459,22 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { #define BTUSB_WAKEUP_DISABLE 14 #define BTUSB_USE_ALT1_FOR_WBS 15 +/* Per core spec 5, vol 4, part B, table 2.1, + * list the hci packet payload sizes for various ALT settings. + * This is used to set the packet length for the wideband speech. + * If a controller does not probe its usb alt setting, the default + * value will be 0. Any clients at upper layers should interpret it + * as a default value and set a proper packet length accordingly. + * + * To calculate the HCI packet payload length: + * for alternate settings 1 - 5: + * hci_packet_size = suggested_max_packet_size * 3 (packets) - + * 3 (HCI header octets) + * for alternate setting 6: + * hci_packet_size = suggested_max_packet_size - 3 (HCI header octets) + */ +static const int hci_packet_size_usb_alt[] = { 0, 24, 48, 72, 96, 144, 60 }; + struct btusb_data { struct hci_dev *hdev; struct usb_device *udev; @@ -3958,6 +3974,15 @@ static int btusb_probe(struct usb_interface *intf, hdev->notify = btusb_notify; hdev->prevent_wake = btusb_prevent_wake; + if (id->driver_info & BTUSB_AMP) { + /* AMP controllers do not support SCO packets */ + data->isoc = NULL; + } else { + /* Interface orders are hardcoded in the specification */ + data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); + data->isoc_ifnum = ifnum_base + 1; + } + #ifdef CONFIG_PM err = btusb_config_oob_wake(hdev); if (err) @@ -4021,6 +4046,10 @@ static int btusb_probe(struct usb_interface *intf, hdev->set_diag = btintel_set_diag; hdev->set_bdaddr = btintel_set_bdaddr; hdev->cmd_timeout = btusb_intel_cmd_timeout; + + if (btusb_find_altsetting(data, 6)) + hdev->sco_pkt_len = hci_packet_size_usb_alt[6]; + 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); @@ -4062,15 +4091,6 @@ static int btusb_probe(struct usb_interface *intf, btusb_check_needs_reset_resume(intf); } - if (id->driver_info & BTUSB_AMP) { - /* AMP controllers do not support SCO packets */ - data->isoc = NULL; - } else { - /* Interface orders are hardcoded in the specification */ - data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); - data->isoc_ifnum = ifnum_base + 1; - } - if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) && (id->driver_info & BTUSB_REALTEK)) { hdev->setup = btrtl_setup_realtek; @@ -4082,9 +4102,10 @@ static int btusb_probe(struct usb_interface *intf, * (DEVICE_REMOTE_WAKEUP) */ set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); - if (btusb_find_altsetting(data, 1)) + if (btusb_find_altsetting(data, 1)) { set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags); - else + hdev->sco_pkt_len = hci_packet_size_usb_alt[1]; + } else bt_dev_err(hdev, "Device does not support ALT setting 1"); } diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 8caac20556b499..0624496328fc09 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -417,6 +417,7 @@ struct hci_dev { unsigned int acl_pkts; unsigned int sco_pkts; unsigned int le_pkts; + unsigned int sco_pkt_len; __u16 block_len; __u16 block_mtu; -- 2.28.0.236.gb10cc79966-goog