From: "Attila Tőkés" <attitokes@gmail.com>
Cc: "Attila Tőkés" <attitokes@gmail.com>,
"Marcel Holtmann" <marcel@holtmann.org>,
"Johan Hedberg" <johan.hedberg@gmail.com>,
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 [thread overview]
Message-ID: <20180605191743.27748-1-attitokes@gmail.com> (raw)
Signed-off-by: Attila Tőkés <attitokes@gmail.com>
---
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
next reply other threads:[~2018-06-05 19:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 19:17 Attila Tőkés [this message]
2018-06-07 13:43 ` [PATCH] Bluetooth: hci_bcm: Configure SCO routing automatically Marcel Holtmann
2018-06-08 16:20 ` attitokes
2018-06-08 16:33 ` Attila Tőkés
2018-06-08 17:25 ` Rob Herring
2018-06-09 6:26 ` Attila Tőkés
2018-06-11 15:34 ` Rob Herring
2018-06-11 15:47 ` Marcel Holtmann
2018-06-11 17:54 ` Rob Herring
2018-06-11 18:19 ` Marcel Holtmann
2018-06-11 19:05 ` Rob Herring
2018-06-12 17:28 ` Attila Tőkés
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=20180605191743.27748-1-attitokes@gmail.com \
--to=attitokes@gmail.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).