ALSA: hda - hide HDMI/ELD printks unless snd.debug=2
[linux-2.6.git] / sound / pci / hda / patch_hdmi.c
index 3f42cc9..3e35734 100644 (file)
 #include <linux/module.h>
 #include <sound/core.h>
 #include <sound/jack.h>
+
+#ifdef CONFIG_SND_HDA_PLATFORM_NVIDIA_TEGRA
+#include <mach/hdmi-audio.h>
+#endif
+
 #include "hda_codec.h"
 #include "hda_local.h"
 #include "hda_jack.h"
@@ -757,8 +762,6 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
        struct hdmi_spec *spec = codec->spec;
        int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
        int pin_nid;
-       int pd = !!(res & AC_UNSOL_RES_PD);
-       int eldv = !!(res & AC_UNSOL_RES_ELDV);
        int pin_idx;
        struct hda_jack_tbl *jack;
 
@@ -768,9 +771,10 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
        pin_nid = jack->nid;
        jack->jack_dirty = 1;
 
-       printk(KERN_INFO
+       _snd_printd(SND_PR_VERBOSE,
                "HDMI hot plug event: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
-               codec->addr, pin_nid, pd, eldv);
+               codec->addr, pin_nid,
+               !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV));
 
        pin_idx = pin_nid_to_pin_index(spec, pin_nid);
        if (pin_idx < 0)
@@ -805,7 +809,6 @@ static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
 
 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res)
 {
-       struct hdmi_spec *spec = codec->spec;
        int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
        int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
 
@@ -887,6 +890,21 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
        per_pin = &spec->pins[pin_idx];
        eld = &per_pin->sink_eld;
 
+#ifdef CONFIG_SND_HDA_PLATFORM_NVIDIA_TEGRA
+       if ((codec->preset->id == 0x10de0020) &&
+           (!eld->monitor_present || !eld->lpcm_sad_ready)) {
+               if (!eld->monitor_present) {
+                       if (tegra_hdmi_setup_hda_presence() < 0) {
+                               snd_printk(KERN_WARNING
+                                          "HDMI: No HDMI device connected\n");
+                               return -ENODEV;
+                       }
+               }
+               if (!eld->lpcm_sad_ready)
+                       return -ENODEV;
+       }
+#endif
+
        /* Dynamically assign converter to stream */
        for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) {
                per_cvt = &spec->cvts[cvt_idx];
@@ -929,7 +947,7 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
        hinfo->maxbps = per_cvt->maxbps;
 
        /* Restrict capabilities by ELD if this isn't disabled */
-       if (!static_hdmi_pcm && eld->eld_valid) {
+       if (!static_hdmi_pcm && (eld->eld_valid || eld->lpcm_sad_ready)) {
                snd_hdmi_eld_update_pcm_info(eld, hinfo);
                if (hinfo->channels_min > hinfo->channels_max ||
                    !hinfo->rates || !hinfo->formats)
@@ -993,7 +1011,7 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
        if (eld->monitor_present)
                eld_valid       = !!(present & AC_PINSENSE_ELDV);
 
-       printk(KERN_INFO
+       _snd_printd(SND_PR_VERBOSE,
                "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
                codec->addr, pin_nid, eld->monitor_present, eld_valid);
 
@@ -1124,8 +1142,8 @@ static int hdmi_parse_codec(struct hda_codec *codec)
         * HDA link is powered off at hot plug or hw initialization time.
         */
 #ifdef CONFIG_SND_HDA_POWER_SAVE
-       if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) &
-             AC_PWRST_EPSS))
+       if ((!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) &
+             AC_PWRST_EPSS)) && (codec->preset->id != 0x10de0020))
                codec->bus->power_keep_link_on = 1;
 #endif
 
@@ -1156,6 +1174,21 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
        int pin_idx = hinfo_to_pin_index(spec, hinfo);
        hda_nid_t pin_nid = spec->pins[pin_idx].pin_nid;
 
+#if defined(CONFIG_SND_HDA_PLATFORM_NVIDIA_TEGRA) && defined(CONFIG_TEGRA_DC)
+       if (codec->preset->id == 0x10de0020) {
+               int err = 0;
+               /* Set hdmi:audio freq and source selection*/
+               err = tegra_hdmi_setup_audio_freq_source(
+                                       substream->runtime->rate, HDA);
+               if ( err < 0 ) {
+                       snd_printk(KERN_ERR
+                               "Unable to set hdmi audio freq to %d \n",
+                                               substream->runtime->rate);
+                       return err;
+               }
+       }
+#endif
+
        hdmi_set_channel_count(codec, cvt_nid, substream->runtime->channels);
 
        hdmi_setup_audio_infoframe(codec, pin_idx, substream);
@@ -1242,7 +1275,6 @@ static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
        if (pcmdev > 0)
                sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
 
-       hdmi_present_sense(per_pin, 0);
        return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str, 0);
 }
 
@@ -1274,7 +1306,7 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
                if (err < 0)
                        return err;
 
-               hdmi_present_sense(per_pin, false);
+               hdmi_present_sense(per_pin, 0);
        }
 
        return 0;
@@ -1285,6 +1317,14 @@ static int generic_hdmi_init(struct hda_codec *codec)
        struct hdmi_spec *spec = codec->spec;
        int pin_idx;
 
+       switch (codec->preset->id) {
+       case 0x10de0020:
+               snd_hda_codec_write(codec, 4, 0,
+                                   AC_VERB_SET_DIGI_CONVERT_1, 0x11);
+       default:
+               break;
+       }
+
        for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
                struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx];
                hda_nid_t pin_nid = per_pin->pin_nid;
@@ -1900,6 +1940,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
 { .id = 0x10de001a, .name = "GPU 1a HDMI/DP",  .patch = patch_generic_hdmi },
 { .id = 0x10de001b, .name = "GPU 1b HDMI/DP",  .patch = patch_generic_hdmi },
 { .id = 0x10de001c, .name = "GPU 1c HDMI/DP",  .patch = patch_generic_hdmi },
+{ .id = 0x10de0020, .name = "Tegra30 HDMI",    .patch = patch_generic_hdmi },
 { .id = 0x10de0040, .name = "GPU 40 HDMI/DP",  .patch = patch_generic_hdmi },
 { .id = 0x10de0041, .name = "GPU 41 HDMI/DP",  .patch = patch_generic_hdmi },
 { .id = 0x10de0042, .name = "GPU 42 HDMI/DP",  .patch = patch_generic_hdmi },
@@ -1914,6 +1955,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
 { .id = 0x80862804, .name = "IbexPeak HDMI",   .patch = patch_generic_hdmi },
 { .id = 0x80862805, .name = "CougarPoint HDMI",        .patch = patch_generic_hdmi },
 { .id = 0x80862806, .name = "PantherPoint HDMI", .patch = patch_generic_hdmi },
+{ .id = 0x80862880, .name = "CedarTrail HDMI", .patch = patch_generic_hdmi },
 { .id = 0x808629fb, .name = "Crestline HDMI",  .patch = patch_generic_hdmi },
 {} /* terminator */
 };
@@ -1945,6 +1987,7 @@ MODULE_ALIAS("snd-hda-codec-id:10de0019");
 MODULE_ALIAS("snd-hda-codec-id:10de001a");
 MODULE_ALIAS("snd-hda-codec-id:10de001b");
 MODULE_ALIAS("snd-hda-codec-id:10de001c");
+MODULE_ALIAS("snd-hda-codec-id:10de0020");
 MODULE_ALIAS("snd-hda-codec-id:10de0040");
 MODULE_ALIAS("snd-hda-codec-id:10de0041");
 MODULE_ALIAS("snd-hda-codec-id:10de0042");
@@ -1960,6 +2003,7 @@ MODULE_ALIAS("snd-hda-codec-id:80862803");
 MODULE_ALIAS("snd-hda-codec-id:80862804");
 MODULE_ALIAS("snd-hda-codec-id:80862805");
 MODULE_ALIAS("snd-hda-codec-id:80862806");
+MODULE_ALIAS("snd-hda-codec-id:80862880");
 MODULE_ALIAS("snd-hda-codec-id:808629fb");
 
 MODULE_LICENSE("GPL");