asoc: tegra: Enable ULP audio
Scott Peterson [Wed, 16 Oct 2013 22:16:57 +0000 (15:16 -0700)]
Enable the ULP audio using AVP for
K3.10 kernel.

Bug 1389595
Bug 1388523

Change-Id: I81a4732a00891db177e1e3aed8c5be7382f55b96
Signed-off-by: Scott Peterson <speterson@nvidia.com>
Reviewed-on: http://git-master/r/300176
Reviewed-by: Manoj Gangwal <mgangwal@nvidia.com>
Tested-by: Manoj Gangwal <mgangwal@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

include/sound/dmaengine_pcm.h
sound/soc/codecs/rt5639.c
sound/soc/soc-dmaengine-pcm.c
sound/soc/tegra/tegra_asoc_utils.c
sound/soc/tegra/tegra_pcm.c

index f11c35c..7bcbf5d 100644 (file)
@@ -33,6 +33,9 @@ snd_pcm_substream_to_dma_direction(const struct snd_pcm_substream *substream)
                return DMA_DEV_TO_MEM;
 }
 
+void snd_dmaengine_pcm_set_data(struct snd_pcm_substream *substream, void *data);
+void *snd_dmaengine_pcm_get_data(struct snd_pcm_substream *substream);
+
 int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream,
        const struct snd_pcm_hw_params *params, struct dma_slave_config *slave_config);
 int snd_dmaengine_pcm_trigger(struct snd_pcm_substream *substream, int cmd);
index 4b7b51f..eba74a5 100644 (file)
@@ -2318,7 +2318,7 @@ static int rt5639_probe(struct snd_soc_codec *codec)
        rt5639_reg_init(codec);
 #endif
 
-       codec->dapm.bias_level = SND_SOC_BIAS_STANDBY;
+       codec->dapm.bias_level = SND_SOC_BIAS_OFF;
 
        snd_soc_add_codec_controls(codec, rt5639_snd_controls,
                ARRAY_SIZE(rt5639_snd_controls));
index aa924d9..100ecf8 100644 (file)
@@ -33,6 +33,8 @@ struct dmaengine_pcm_runtime_data {
        dma_cookie_t cookie;
 
        unsigned int pos;
+
+       void *data;
 };
 
 static inline struct dmaengine_pcm_runtime_data *substream_to_prtd(
@@ -41,6 +43,33 @@ static inline struct dmaengine_pcm_runtime_data *substream_to_prtd(
        return substream->runtime->private_data;
 }
 
+/**
+ * snd_dmaengine_pcm_set_data - Set dmaengine substream private data
+ * @substream: PCM substream
+ * @data: Data to set
+ */
+void snd_dmaengine_pcm_set_data(struct snd_pcm_substream *substream, void *data)
+{
+       struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
+
+       prtd->data = data;
+}
+EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_set_data);
+
+/**
+ * snd_dmaengine_pcm_get_data - Get dmaeinge substream private data
+ * @substream: PCM substream
+ *
+ * Returns the data previously set with snd_dmaengine_pcm_set_data
+ */
+void *snd_dmaengine_pcm_get_data(struct snd_pcm_substream *substream)
+{
+       struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
+
+       return prtd->data;
+}
+EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_get_data);
+
 struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream)
 {
        struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
index fcbc065..f32613c 100644 (file)
@@ -169,7 +169,8 @@ static int tegra_set_avp_device(struct snd_kcontrol *kcontrol,
                substream =
                        rtd->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
                if (substream && substream->runtime) {
-                       prtd = substream->runtime->private_data;
+                       prtd = (struct tegra_runtime_data *)
+                               snd_dmaengine_pcm_get_data(substream);
                        if (!prtd)
                                return -EINVAL;
                        if (prtd->running)
@@ -183,7 +184,8 @@ static int tegra_set_avp_device(struct snd_kcontrol *kcontrol,
                substream =
                        rtd->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
                if (substream && substream->runtime) {
-                       prtd = substream->runtime->private_data;
+                       prtd = (struct tegra_runtime_data *)
+                               snd_dmaengine_pcm_get_data(substream);
                        if (!prtd)
                                return -EINVAL;
                        if (prtd->running)
@@ -216,14 +218,15 @@ static int tegra_get_dma_ch_id(struct snd_kcontrol *kcontrol,
        if (!substream || !substream->runtime)
                return 0;
 
-       prtd = substream->runtime->private_data;
+       prtd = (struct tegra_runtime_data *)
+               snd_dmaengine_pcm_get_data(substream);
 
        if (!prtd)
                return 0;
 
        chan = snd_dmaengine_pcm_get_chan(substream);
 
-       ucontrol->value.integer.value[0] = -1;
+       ucontrol->value.integer.value[0] = chan->chan_id;
 
        return 0;
 }
@@ -247,7 +250,9 @@ static int tegra_set_dma_addr(struct snd_kcontrol *kcontrol,
        if (!substream || !substream->runtime)
                return 0;
 
-       prtd = substream->runtime->private_data;
+       prtd = (struct tegra_runtime_data *)
+               snd_dmaengine_pcm_get_data(substream);
+
        if (!prtd)
                return 0;
 
@@ -274,7 +279,8 @@ static int tegra_get_dma_addr(struct snd_kcontrol *kcontrol,
        if (!substream || !substream->runtime)
                return 0;
 
-       prtd = substream->runtime->private_data;
+       prtd = (struct tegra_runtime_data *)
+               snd_dmaengine_pcm_get_data(substream);
 
        if (!prtd)
                return 0;
index ada00e1..3cb412e 100644 (file)
@@ -93,6 +93,8 @@ static int tegra_pcm_open(struct snd_pcm_substream *substream)
                return ret;
        }
 
+       snd_dmaengine_pcm_set_data(substream, prtd);
+
        return 0;
 }
 
@@ -152,9 +154,14 @@ int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct tegra_pcm_dma_params * dmap;
+       struct tegra_runtime_data *prtd;
 
        dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
 
+
+       prtd = (struct tegra_runtime_data *)
+       snd_dmaengine_pcm_get_data(substream);
+
        if (!dmap)
                return 0;
 
@@ -162,6 +169,13 @@ int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_RESUME:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+               prtd->running = 1;
+               if (prtd->disable_intr) {
+                       substream->runtime->dma_addr = prtd->avp_dma_addr;
+                       substream->runtime->no_period_wakeup = 1;
+               } else {
+                       substream->runtime->no_period_wakeup = 0;
+               }
 
                return snd_dmaengine_pcm_trigger(substream,
                                        SNDRV_PCM_TRIGGER_START);
@@ -169,6 +183,7 @@ int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_SUSPEND:
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+               prtd->running = 0;
 
                return snd_dmaengine_pcm_trigger(substream,
                                        SNDRV_PCM_TRIGGER_STOP);