asoc: tegra: Support Voice + Media
Scott Peterson [Thu, 17 Jan 2013 22:54:16 +0000 (14:54 -0800)]
Add support for concurent voice and media
streams without using the DAM when the audio
codec supports two I2S interfaces.

Bug 1213272

Change-Id: Ie39d048a27003bc69ab40ee4d3087d15894f168f
Signed-off-by: Scott Peterson <speterson@nvidia.com>
Reviewed-on: http://git-master/r/192202
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Rahul Mittal <rmittal@nvidia.com>

sound/soc/tegra/tegra30_i2s.c
sound/soc/tegra/tegra_cs42l73.c

index 9ad1bb6..e05b55a 100644 (file)
@@ -1215,9 +1215,10 @@ int tegra30_make_voice_call_connections(struct codec_config *codec_info,
                bb_info->rate, bb_info->bitsize, bb_info->bit_clk);
 
        if (uses_voice_codec) {
-               /* The following two lines are a hack */
-               tegra30_ahub_unset_rx_cif_source(TEGRA30_AHUB_RXCIF_APBIF_RX0);
-               tegra30_ahub_unset_rx_cif_source(TEGRA30_AHUB_RXCIF_I2S0_RX0+1);
+               tegra30_ahub_unset_rx_cif_source(TEGRA30_AHUB_RXCIF_APBIF_RX0 +
+                       codec_info->i2s_id);
+               tegra30_ahub_unset_rx_cif_source(TEGRA30_AHUB_RXCIF_APBIF_RX0 +
+                       bb_info->i2s_id);
 
                tegra30_ahub_set_rx_cif_source(TEGRA30_AHUB_RXCIF_I2S0_RX0 +
                            bb_info->i2s_id, TEGRA30_AHUB_TXCIF_I2S0_TX0 +
index 802303a..2b71cdd 100644 (file)
@@ -506,7 +506,8 @@ static int tegra_cs42l73_startup(struct snd_pcm_substream *substream)
                /*dam configuration*/
                if (!i2s->dam_ch_refcount)
                        i2s->dam_ifc = tegra30_dam_allocate_controller();
-
+               if (i2s->dam_ifc < 0)
+                       return i2s->dam_ifc;
                tegra30_dam_allocate_channel(i2s->dam_ifc, TEGRA30_DAM_CHIN1);
                i2s->dam_ch_refcount++;
                tegra30_dam_enable_clock(i2s->dam_ifc);
@@ -544,6 +545,10 @@ static int tegra_cs42l73_startup(struct snd_pcm_substream *substream)
                /* allocate a dam for voice call recording */
 
                i2s->call_record_dam_ifc = tegra30_dam_allocate_controller();
+
+               if (i2s->call_record_dam_ifc < 0)
+                       return i2s->call_record_dam_ifc;
+
                tegra30_dam_allocate_channel(i2s->call_record_dam_ifc,
                        TEGRA30_DAM_CHIN0_SRC);
                tegra30_dam_allocate_channel(i2s->call_record_dam_ifc,
@@ -751,7 +756,7 @@ static void tegra_voice_call_shutdown(struct snd_pcm_substream *substream)
        machine->codec_info[VOICE_CODEC].rate = 0;
        machine->codec_info[VOICE_CODEC].channels = 0;
 #endif
-
+       machine->is_device_bt = 0;
        return;
 }
 
@@ -818,7 +823,7 @@ static void tegra_bt_voice_call_shutdown(struct snd_pcm_substream *substream)
        machine->codec_info[BT_SCO].channels = 0;
 #endif
 
-       return;
+       machine->is_device_bt = 0;
 }
 
 static struct snd_soc_ops tegra_cs42l73_ops = {
@@ -1057,13 +1062,14 @@ static int tegra_cs42l73_init(struct snd_soc_pcm_runtime *rtd)
        int ret;
 
 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
-
-       if (machine->codec_info[BASEBAND].i2s_id != -1) {
-               if (i2s->id == machine->codec_info[BT_SCO].i2s_id)
+       if (machine->codec_info[BASEBAND].i2s_id != -1)
                        i2s->is_dam_used = true;
-       }
 #endif
 
+       if ((i2s->id == machine->codec_info[HIFI_CODEC].i2s_id) &&
+               (i2s->id != machine->codec_info[VOICE_CODEC].i2s_id))
+               i2s->is_dam_used = false;
+
        if (machine->init_done)
                return 0;