OSDN Git Service

ASoC: swr-wcd: Reduce latency for cold start on speaker
authorLaxminath Kasam <lkasam@codeaurora.org>
Mon, 13 Mar 2017 13:40:36 +0000 (19:10 +0530)
committerGerrit - the friendly Code Review server <code-review@localhost>
Wed, 22 Mar 2017 07:51:02 +0000 (00:51 -0700)
In SDM660 WSA speaker using MSM over soundwire version,
observe high cold start latency. As interrupt is disabled,
broadcast ack is not received which results in 200ms higher
latency. Reduce latency impact by blocking only for 10ms
for MSM over soundwire version.

Change-Id: Ic0e659d7c443c1462aba4da2f8bf9471031d02d2
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
drivers/soundwire/swr-wcd-ctrl.c
drivers/soundwire/swr-wcd-ctrl.h
drivers/soundwire/swrm_registers.h

index 63bc396..e72663b 100644 (file)
@@ -224,6 +224,12 @@ static struct dentry *debugfs_poke;
 static struct dentry *debugfs_reg_dump;
 static unsigned int read_data;
 
+
+static bool swrm_is_msm_variant(int val)
+{
+       return (val == SWRM_VERSION_1_3);
+}
+
 static int swrm_debug_open(struct inode *inode, struct file *file)
 {
        file->private_data = inode->i_private;
@@ -514,8 +520,17 @@ static int swrm_cmd_fifo_wr_cmd(struct swr_mstr_ctrl *swrm, u8 cmd_data,
                        __func__, val, ret);
                goto err;
        }
-       if (cmd_id == 0xF)
-               wait_for_completion_timeout(&swrm->broadcast, (2 * HZ/10));
+       if (cmd_id == 0xF) {
+               /*
+                * sleep for 10ms for MSM soundwire variant to allow broadcast
+                * command to complete.
+                */
+               if (swrm_is_msm_variant(swrm->version))
+                       usleep_range(10000, 10100);
+               else
+                       wait_for_completion_timeout(&swrm->broadcast,
+                                                   (2 * HZ/10));
+       }
 err:
        return ret;
 }
@@ -1472,6 +1487,7 @@ static int swrm_probe(struct platform_device *pdev)
                mutex_unlock(&swrm->mlock);
                goto err_mstr_fail;
        }
+       swrm->version = swrm->read(swrm->handle, SWRM_COMP_HW_VERSION);
 
        /* Enumerate slave devices */
        list_for_each_entry_safe(swr_dev, safe, &swrm->master.devices,
index 8992318..b7a3eda 100755 (executable)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
 
 #define SWR_MSTR_PORT_LEN      8 /* Number of master ports */
 
+#define SWRM_VERSION_1_0 0x01010000
+#define SWRM_VERSION_1_2 0x01030000
+#define SWRM_VERSION_1_3 0x01040000
+
 enum {
        SWR_MSTR_PAUSE,
        SWR_MSTR_RESUME,
@@ -88,6 +92,7 @@ struct swr_mstr_ctrl {
        int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
                        void *data), void *swr_handle, int type);
        int irq;
+       int version;
        int num_enum_slaves;
        int slave_status;
        struct swr_mstr_port *mstr_port;
index c6923f3..50c3ecf 100755 (executable)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -15,6 +15,7 @@
 
 #define SWRM_BASE_ADDRESS                              0x00
 
+#define SWRM_COMP_HW_VERSION                     SWRM_BASE_ADDRESS
 #define SWRM_COMP_CFG_ADDR                     (SWRM_BASE_ADDRESS+0x00000004)
 #define SWRM_COMP_CFG_RMSK                             0x3
 #define SWRM_COMP_CFG_IRQ_LEVEL_OR_PULSE_BMSK          0x2