alsa:hda: enable inject null sample for stereo LPCM
Ashok Mudithanapalli [Thu, 28 Jan 2016 12:09:40 +0000 (17:09 +0530)]
add check for format along with channel count to
ensure that inject null sample enabled only for
stereo LPCM streams.

Also disable at the time of closing the device.

Bug 1718097

Change-Id: I1e46e49359cccc2b3a95d2706d9281789bbdcc44
Signed-off-by: Ashok Mudithanapalli <ashokm@nvidia.com>
Reviewed-on: http://git-master/r/999397
Reviewed-by: Sanjay Singh Chauhan <schauhan@nvidia.com>
Reviewed-by: Rahul Mittal <rmittal@nvidia.com>
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>

sound/pci/hda/patch_hdmi.c

index 2bc719b..3e865a4 100644 (file)
@@ -4,7 +4,7 @@
  *
  *  Copyright(c) 2008-2010 Intel Corporation. All rights reserved.
  *  Copyright (c) 2006 ATI Technologies Inc.
- *  Copyright (c) 2008-2015, NVIDIA CORPORATION.  All rights reserved.
+ *  Copyright (c) 2008-2016, NVIDIA CORPORATION.  All rights reserved.
  *  Copyright (c) 2008 Wei Ni <wni@nvidia.com>
  *
  *  Authors:
@@ -1567,6 +1567,9 @@ static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
  * HDMI callbacks
  */
 
+#define is_pcm_format(format) \
+       ((format & (1 << AC_FMT_TYPE_SHIFT)) == (AC_FMT_TYPE_PCM))
+
 static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
                                           struct hda_codec *codec,
                                           unsigned int stream_tag,
@@ -1593,7 +1596,8 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
                (codec->preset->id == 0x10de002a)) {
                int err = 0;
 
-               if (substream->runtime->channels == 2)
+               if ((substream->runtime->channels == 2) &&
+                       is_pcm_format(format))
                        tegra_hdmi_audio_null_sample_inject(true);
                else
                        tegra_hdmi_audio_null_sample_inject(false);
@@ -1644,6 +1648,15 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
        int pinctl;
 
        if (hinfo->nid) {
+#if defined(CONFIG_SND_HDA_PLATFORM_NVIDIA_TEGRA) && defined(CONFIG_TEGRA_DC)
+               if ((codec->preset->id == 0x10de0020) ||
+                       (codec->preset->id == 0x10de0022) ||
+                       (codec->preset->id == 0x10de0028) ||
+                       (codec->preset->id == 0x10de0029) ||
+                       (codec->preset->id == 0x10de002a)) {
+                       tegra_hdmi_audio_null_sample_inject(false);
+               }
+#endif
                cvt_idx = cvt_nid_to_cvt_index(spec, hinfo->nid);
                if (snd_BUG_ON(cvt_idx < 0))
                        return -EINVAL;