Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2184136imm; Thu, 7 Jun 2018 06:47:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJZ6HAA2BA6vER8sK5qFUtnXzqvwxKC/bHyirAYuBAlBqNjSb6D6ckhPmajWq3+StGs9++n X-Received: by 2002:a65:44c8:: with SMTP id g8-v6mr1672988pgs.356.1528379221294; Thu, 07 Jun 2018 06:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528379221; cv=none; d=google.com; s=arc-20160816; b=MNWjJvhPtlYPtdBm14zX3sAJRR4JVCTETfsBZ+jm9CLT1zpYfp54Ra+VQMJPF4ev+F bPDLcX7zZtnaf81N0Q1Ul+yASq34PjsH1ZYpR6GvWVWX797EixAb1dBNfbmLjJYUmkOq pumU6lOte0aJbmRWnGyLWV6p/PSt4vng88qr3Pc+kmmWVw/aDuwDKwDaraShcaEYOSjG cCawCPOshrwtLOkZ7AI+f8pwp84Yf2OeX4e4X/KE8j5uek6nKdV0YRClQQZWj4syWhW/ CluJh51hsG0LoVsIBzthmUiU4ZKPRqAi94lISlU1u4Tj/LbYpossTrVC6XqpJFyRPGOs 3zsA== 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:arc-authentication-results; bh=XxwiPzjxtPR+un7JSQ5y2NbV55DsSaVowk2hthIQY4g=; b=kDmHCmXdWAkzbsZ46W8df9pQ3DUjQbJHOt+Dsk4amboBPpEWmiO+T6yjgsLSoXzdxX LWkQMOEM/mEBXvzjGsZVW8FTu3zNUzCc1UGH3rg4eO60S20K5gEd4zKTbPBr7icQ/zKE 0LggDDsgh+/+s1g7MHv4mv1mit3SC7CyOWDUC3sYGApnQr0CRoOWs0KA50yk4nSHomVq d559ABAdxrU4CPWtbQI8fHVVmy0tdO+X/n4U2kyyU76cCcWu9W5YNVnirSRw6HEOQCDl wMG46bBFzeNUIrnUUaEBRJ0zS226S9969wN3xiFTIPt6hJtpqKeUvrHbq7YqrVNHgJ7h T7eQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5-v6si43951669pgc.537.2018.06.07.06.46.46; Thu, 07 Jun 2018 06:47:01 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753696AbeFGNnp convert rfc822-to-8bit (ORCPT + 99 others); Thu, 7 Jun 2018 09:43:45 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:51902 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753665AbeFGNnn (ORCPT ); Thu, 7 Jun 2018 09:43:43 -0400 Received: from marcel-macpro.fritz.box (p5B3D24B5.dip0.t-ipconnect.de [91.61.36.181]) by mail.holtmann.org (Postfix) with ESMTPSA id 2AF14CF356; Thu, 7 Jun 2018 15:50:22 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.4 \(3445.8.2\)) Subject: Re: [PATCH] Bluetooth: hci_bcm: Configure SCO routing automatically From: Marcel Holtmann In-Reply-To: <20180605191743.27748-1-attitokes@gmail.com> Date: Thu, 7 Jun 2018 15:43:40 +0200 Cc: Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <280FCB2C-6DF1-4790-A89F-AF5BE3513AE5@holtmann.org> References: <20180605191743.27748-1-attitokes@gmail.com> To: =?utf-8?B?QXR0aWxhIFTFkWvDqXM=?= X-Mailer: Apple Mail (2.3445.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Attila, please include a commit message explains the changes. > 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; > }; These should be all u8 since that is what they are in bcm_set_pcm_int_params. > /* 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 Please follow networking comment style here. > + 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); > + } > + Move that check into bcm_configure_sco_routing to exit that function early. I would also recommend to read the current settings first and deal with missing parameters in the DT. For example if you just change the routing part that should be fine as well. > 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; > } You need a patch documenting these DT settings. > > @@ -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 Regards Marcel