Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1306306imm; Tue, 5 Jun 2018 12:19:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJsm9TazbSDXNj6jSlE41sFpCbBuLzIwvjg4XUur2cGRrLzrk13mlbk+6Y0MMop6WUcVdHh X-Received: by 2002:a63:7247:: with SMTP id c7-v6mr22024527pgn.68.1528226392236; Tue, 05 Jun 2018 12:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528226392; cv=none; d=google.com; s=arc-20160816; b=hs3iap3ziuoubofuJukjmKntaEzCqJniveXcgU2Bfr/v+3d1P1Jrm8ipdp95wNp+3G JKLs4Hbl8ZOHUcFUfXuJe74mtzI9yPN4UoEovsAp+YIUDxj1w3CDOxy9z71m5rDyelEw 9TtNpv9ZFESdYpvU7tPx77Tf5bRnqA5lcEYJuByypvKYK/mead1RL3/KyQZd+CsE+2WS jmSdVfysUQorA+d8NFf9pcbE4wUdVfFBkItNKigf3h9R4dc8XFOnnT/Pimix+Spkf0cu IuKeO8/eZYqpOhp1ofSHLOKtF+pMv3i7G6MF/hDaXIvs1isxXQPPSsBQDcc5E6Jqy2zd Bhfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature :arc-authentication-results; bh=Fau4IpZ24W3Tqqm7tW8dW8nHTEFemHXp6AcvoCOlT8c=; b=h++zvPY71OZzh3UCeGlvnkSIqMMC+Vpiyh2/hZDz030DPxVtGSSXwcdPimJyyvfaDg HlEtj9LbCj5JbgAXH/H2+xqxMZwF5i4ZDKanNnCdvcClaoxv9WvaBQmxAuziqX3iI3xU +MNXz0l12X7jq4s/IaoNMMj5wSwwFfjmXEBIDEcvcuJFINiro7rFiBM9Z3XuU/LZzacD Prph7ScG6/BQMg4h2BOoNi9w+AHT0ZuGtzER4TWaAdahgEcWiPqVf0O1AUOyaPu/c+0N 3RlruPoqVZqVgcgQqQ8FvU8fafrKsOcpeJvnWLvapANCiaPbi+fhtuYnRAHAhjvSy4IQ mrYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Oe+GMJng; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n59-v6si48856267plb.198.2018.06.05.12.19.11; Tue, 05 Jun 2018 12:19:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Oe+GMJng; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752246AbeFETSf (ORCPT + 99 others); Tue, 5 Jun 2018 15:18:35 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38807 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805AbeFETSd (ORCPT ); Tue, 5 Jun 2018 15:18:33 -0400 Received: by mail-wm0-f68.google.com with SMTP id m129-v6so7202440wmb.3; Tue, 05 Jun 2018 12:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Fau4IpZ24W3Tqqm7tW8dW8nHTEFemHXp6AcvoCOlT8c=; b=Oe+GMJng3UbI3A6VHV+m1hKOA2Dda4na295ldD8vJgHAQM2FUWxuSVzLfmGDl21hKu +h5vNV7saJYylmOX7ft2cZVYWrfEIpPBGApx6mxypwccw9/ikp1yEeEil96bVNVFk1I/ bz2NbM1WKzG261YYcnieQCbLWhTPmdDL4a7897U458X9nRZnZzzwQmrIr8S7b5d0SK2m VbO6eedP+1tn8j9yEFhIDBbPyNfFogIHJ8dVWmhNxVgKoi47gb3cGmSpaqMyUVoyi0aZ INmOum3FmixQwMG4wBqNi5vwIuZ2KpJJWQjbYYe6Guypyg2YrqGYNl6zlDIpy2Ddjn5S 37fA== 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:mime-version :content-transfer-encoding; bh=Fau4IpZ24W3Tqqm7tW8dW8nHTEFemHXp6AcvoCOlT8c=; b=TmS7I8mkm0b8ERrhTr2kq8d0HWBirp8VeBEKsI7C5mWqD00JycMEY3qJTzIVS+F631 ALv79TpJOS50ZrYO2jaxOQhhO2dYp25hPU9N1Up/xUFDPq1ApU7J1RJ4e+KjnTpLmvOO XJiSw79kZcJ8tC1y7upjBg4rkPp1Cjx6UMCqUmmGvrHiqyXpVhKcyLOGzD4tzQjRfJqJ Buk3tM8h0+aTisSeXGHl18cy1xdueUAvmWrFW/eB8cQ8pJz/B1Tea6k1aR1k9KlYLK2U wAomZh7jmSit/dYlchHY4N3+jGyuInpRT5Onhb45S8avQT/6/Z24LFcZ/l22n+8jjRlB qQpw== X-Gm-Message-State: APt69E1KoMDfzBTEMTCetyQ6CJILslcX2wCyjzeAdPRjfrxIFHn24xLI lpCe5uqT6s0WuFICUr+fum/3xN19 X-Received: by 2002:a1c:bc3:: with SMTP id 186-v6mr310294wml.39.1528226311908; Tue, 05 Jun 2018 12:18:31 -0700 (PDT) Received: from localhost.localdomain ([188.24.92.194]) by smtp.googlemail.com with ESMTPSA id u70-v6sm3523792wmd.3.2018.06.05.12.18.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 12:18:30 -0700 (PDT) From: =?UTF-8?q?Attila=20T=C5=91k=C3=A9s?= Cc: =?UTF-8?q?Attila=20T=C5=91k=C3=A9s?= , Marcel Holtmann , Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: hci_bcm: Configure SCO routing automatically Date: Tue, 5 Jun 2018 22:17:43 +0300 Message-Id: <20180605191743.27748-1-attitokes@gmail.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Attila Tőkés --- drivers/bluetooth/hci_bcm.c | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c index ddbd8c6a..50c73eef 100644 --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -83,6 +83,16 @@ * @hu: pointer to HCI UART controller struct, * used to disable flow control during runtime suspend and system sleep * @is_suspended: whether flow control is currently disabled + * + * SCO routing parameters: + * used as the parameters for the bcm_set_pcm_int_params command + * @sco_routing: + * >= 255 (skip SCO routing configuration) + * 0-3 (PCM, Transport, Codec, I2S) + * @pcm_interface_rate: 0-4 (128 Kbps - 2048 Kbps) + * @pcm_frame_type: 0 (short), 1 (long) + * @pcm_sync_mode: 0 (slave), 1 (master) + * @pcm_clock_mode: 0 (slave), 1 (master) */ struct bcm_device { /* Must be the first member, hci_serdev.c expects this. */ @@ -114,6 +124,13 @@ struct bcm_device { struct hci_uart *hu; bool is_suspended; #endif + + /* SCO routing parameters */ + u32 sco_routing; + u32 pcm_interface_rate; + u32 pcm_frame_type; + u32 pcm_sync_mode; + u32 pcm_clock_mode; }; /* generic bcm uart resources */ @@ -189,6 +206,35 @@ static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed) return 0; } +static int bcm_configure_sco_routing(struct hci_uart *hu, struct bcm_device *bcm_dev) +{ + struct hci_dev *hdev = hu->hdev; + struct sk_buff *skb; + struct bcm_set_pcm_int_params params; + + bt_dev_dbg(hdev, "BCM: Configuring SCO routing (%d %d %d %d %d)", + bcm_dev->sco_routing, bcm_dev->pcm_interface_rate, bcm_dev->pcm_frame_type, + bcm_dev->pcm_sync_mode, bcm_dev->pcm_clock_mode); + + params.routing = bcm_dev->sco_routing; + params.rate = bcm_dev->pcm_interface_rate; + params.frame_sync = bcm_dev->pcm_frame_type; + params.sync_mode = bcm_dev->pcm_sync_mode; + params.clock_mode = bcm_dev->pcm_clock_mode; + + // send the SCO routing configuration command + skb = __hci_cmd_sync(hdev, 0xfc1c, sizeof(params), ¶ms, HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) { + int err = PTR_ERR(skb); + bt_dev_err(hdev, "BCM: failed to configure SCO routing (%d)", err); + return err; + } + + kfree_skb(skb); + + return 0; +} + /* bcm_device_exists should be protected by bcm_device_lock */ static bool bcm_device_exists(struct bcm_device *device) { @@ -534,6 +580,10 @@ static int bcm_setup(struct hci_uart *hu) host_set_baudrate(hu, speed); } + if (bcm->dev->sco_routing < 0xff) { + bcm_configure_sco_routing(hu, bcm->dev); + } + finalize: release_firmware(fw); @@ -1007,6 +1057,11 @@ static int bcm_acpi_probe(struct bcm_device *dev) static int bcm_of_probe(struct bcm_device *bdev) { device_property_read_u32(bdev->dev, "max-speed", &bdev->oper_speed); + device_property_read_u32(bdev->dev, "sco-routing", &bdev->sco_routing); + device_property_read_u32(bdev->dev, "pcm-interface-rate", &bdev->pcm_interface_rate); + device_property_read_u32(bdev->dev, "pcm-frame-type", &bdev->pcm_frame_type); + device_property_read_u32(bdev->dev, "pcm-sync-mode", &bdev->pcm_sync_mode); + device_property_read_u32(bdev->dev, "pcm-clock-mode", &bdev->pcm_clock_mode); return 0; } @@ -1022,6 +1077,9 @@ static int bcm_probe(struct platform_device *pdev) dev->dev = &pdev->dev; dev->irq = platform_get_irq(pdev, 0); + /* SCO routing configuration is disabled by default */ + dev->sco_routing = 0xff; + if (has_acpi_companion(&pdev->dev)) { ret = bcm_acpi_probe(dev); if (ret) @@ -1281,6 +1339,9 @@ static int bcm_serdev_probe(struct serdev_device *serdev) bcmdev->serdev_hu.serdev = serdev; serdev_device_set_drvdata(serdev, bcmdev); + /* SCO routing configuration is disabled by default */ + bcmdev->sco_routing = 0xff; + if (has_acpi_companion(&serdev->dev)) err = bcm_acpi_probe(bcmdev); else -- 2.17.0