hdmi: Set INJECT_NULL_SAMPLE only for stereo streams
Sayak Ghosh Choudhury [Tue, 24 Apr 2012 14:39:09 +0000 (19:39 +0530)]
Bug 953210

Change-Id: Id40b3fe90174a2a8c9a6faf3f35f61d9f7eeb642
Signed-off-by: Sayak Ghosh Choudhury <sayakc@nvidia.com>
Reviewed-on: http://git-master/r/98477
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

arch/arm/mach-tegra/include/mach/hdmi-audio.h
drivers/video/tegra/dc/hdmi.c
sound/pci/hda/patch_hdmi.c

index 7d76069..3555550 100644 (file)
@@ -42,5 +42,6 @@ enum {
 
 int tegra_hdmi_setup_audio_freq_source(unsigned audio_freq, unsigned audio_source);
 int tegra_hdmi_setup_hda_presence(void);
+int tegra_hdmi_audio_null_sample_inject(bool on);
 
 #endif /* __MACH_TEGRA_HDMI_AUDIO_H */
index 9c96bad..112c1aa 100644 (file)
@@ -94,6 +94,7 @@ struct tegra_dc_hdmi_data {
        bool                            clk_enabled;
        unsigned                        audio_freq;
        unsigned                        audio_source;
+       bool                            audio_inject_null;
 
        bool                            dvi;
 };
@@ -1820,7 +1821,10 @@ static int tegra_dc_hdmi_setup_audio(struct tegra_dc *dc, unsigned audio_freq,
                a_source = AUDIO_CNTRL0_SOURCE_SELECT_SPDIF;
 
 #if !defined(CONFIG_ARCH_TEGRA_2x_SOC)
-       tegra_hdmi_writel(hdmi,a_source | AUDIO_CNTRL0_INJECT_NULLSMPL,
+       if (hdmi->audio_inject_null)
+               a_source |= AUDIO_CNTRL0_INJECT_NULLSMPL;
+
+       tegra_hdmi_writel(hdmi,a_source,
                          HDMI_NV_PDISP_SOR_AUDIO_CNTRL0_0);
        tegra_hdmi_writel(hdmi,
                          AUDIO_CNTRL0_ERROR_TOLERANCE(6) |
@@ -1923,6 +1927,31 @@ int tegra_hdmi_setup_audio_freq_source(unsigned audio_freq, unsigned audio_sourc
 EXPORT_SYMBOL(tegra_hdmi_setup_audio_freq_source);
 
 #if !defined(CONFIG_ARCH_TEGRA_2x_SOC)
+int tegra_hdmi_audio_null_sample_inject(bool on)
+{
+       struct tegra_dc_hdmi_data *hdmi = dc_hdmi;
+       unsigned int val = 0;
+
+       if (!hdmi)
+               return -EAGAIN;
+
+       if (hdmi->audio_inject_null != on) {
+               hdmi->audio_inject_null = on;
+               if (hdmi->clk_enabled) {
+                       val = tegra_hdmi_readl(hdmi,
+                               HDMI_NV_PDISP_SOR_AUDIO_CNTRL0_0);
+                       val &= ~AUDIO_CNTRL0_INJECT_NULLSMPL;
+                       if (on)
+                               val |= AUDIO_CNTRL0_INJECT_NULLSMPL;
+                       tegra_hdmi_writel(hdmi,val,
+                               HDMI_NV_PDISP_SOR_AUDIO_CNTRL0_0);
+               }
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL(tegra_hdmi_audio_null_sample_inject);
+
 int tegra_hdmi_setup_hda_presence()
 {
        struct tegra_dc_hdmi_data *hdmi = dc_hdmi;
index fcc32f5..5942395 100644 (file)
@@ -1112,6 +1112,12 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
 #if defined(CONFIG_SND_HDA_PLATFORM_NVIDIA_TEGRA) && defined(CONFIG_TEGRA_DC)
        if (codec->preset->id == 0x10de0020) {
                int err = 0;
+
+               if (substream->runtime->channels == 2)
+                       tegra_hdmi_audio_null_sample_inject(true);
+               else
+                       tegra_hdmi_audio_null_sample_inject(false);
+
                /* Set hdmi:audio freq and source selection*/
                err = tegra_hdmi_setup_audio_freq_source(
                                        substream->runtime->rate, HDA);