asoc: codec: es755: Add delay between SPI commands
Srinivas Anne [Fri, 15 May 2015 19:32:55 +0000 (12:32 -0700)]
Summary:
1) Added 1ms delay between SPI commands that does not require response
from codec. Commands sent after the route is up and running.

2) 5ms delay for any commands that require a read response from codec.

This should minimize the frequency of SPI interrupts that starved
Audience FW and resulted in Audio corruption.

bug 1622994

Change-Id: I85d8f26245406326c350ebf4723eca31d297b53f
Signed-off-by: Srinivas Anne <sanne@nvidia.com>
Reviewed-on: http://git-master/r/743385
Reviewed-on: http://git-master/r/747494
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>

sound/soc/codecs/audience/es-d300.c
sound/soc/codecs/audience/es755.c
sound/soc/codecs/audience/escore-spi.c

index e557fd3..2dc1e8f 100644 (file)
@@ -259,7 +259,7 @@ static int escore_set_switch(int id)
         * Without delay, the switch settings are not coming into
         * effect.
         */
-       usleep_range(5000, 5005);
+       usleep_range(1000, 1005);
        cmd = switch_arr[id];
 
        mutex_lock(&escore->api_mutex);
index 3b0afd2..4e34340 100644 (file)
@@ -1643,6 +1643,9 @@ static int es755_codec_write(struct snd_soc_codec *codec, unsigned int reg,
                msleep(20);
        }
 
+       if (atomic_read(&escore->active_streams) > 0)
+               usleep_range(1000, 1005);
+
        ret = escore_write(codec, ES_CODEC_VALUE, reg<<8 | value);
        if (ret < 0) {
                dev_err(codec->dev, "codec reg %x write err %d\n",
index a1a2981..5500eff 100644 (file)
@@ -153,10 +153,9 @@ static int escore_spi_cmd(struct escore_priv *escore,
        do {
                --retry;
                if (escore->cmd_compl_mode != ES_CMD_COMP_INTR) {
-                       if (retry % ES_SPI_CONT_RETRY == 0) {
-                               usleep_range(ES_SPI_RETRY_DELAY,
-                                       ES_SPI_RETRY_DELAY + 200);
-                       }
+
+                               usleep_range(ES_SPI_1MS_DELAY,
+                                       ES_SPI_1MS_DELAY + 50);
                }
 
                err = escore_spi_read(escore, &resp16, sizeof(resp16));