linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [alsa-devel][PATCH] add the nvidia HDMI codec driver for MCP77/79
@ 2008-09-03  7:58 peerchen
  2008-09-03  8:51 ` Takashi Iwai
  0 siblings, 1 reply; 17+ messages in thread
From: peerchen @ 2008-09-03  7:58 UTC (permalink / raw)
  To: alsa-devel, linux-kernel; +Cc: Takashi Iwai, akpm, pchen, wni

Add the nvidia HDMI codec driver for MCP77/79. 
The patch based on kernel 2.6.27-rc5.

Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Peer Chen <peerchen@gmail.com>
---
diff -uprN -X linux-2.6.26-Orig/Documentation/dontdiff linux-2.6.26-Orig/sound/pci/hda/hda_intel.c linux-2.6.26-New/sound/pci/hda/hda_intel.c
--- linux-2.6.26-Orig/sound/pci/hda/hda_intel.c	2008-08-28 13:47:20.000000000 +0800
+++ linux-2.6.26-New/sound/pci/hda/hda_intel.c	2008-08-28 15:33:51.000000000 +0800
@@ -223,8 +223,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO
 #define RIRB_INT_MASK		0x05
 
 /* STATESTS int mask: SD2,SD1,SD0 */
-#define AZX_MAX_CODECS		3
-#define STATESTS_INT_MASK	0x07
+#define AZX_MAX_CODECS		4
+#define STATESTS_INT_MASK	0x0f
 
 /* SD_CTL bits */
 #define SD_CTL_STREAM_RESET	0x01	/* stream reset bit */
diff -uprN -X linux-2.6.26-Orig/Documentation/dontdiff linux-2.6.26-Orig/sound/pci/hda/hda_patch.h linux-2.6.26-New/sound/pci/hda/hda_patch.h
--- linux-2.6.26-Orig/sound/pci/hda/hda_patch.h	2008-08-28 13:47:20.000000000 +0800
+++ linux-2.6.26-New/sound/pci/hda/hda_patch.h	2008-08-28 15:33:51.000000000 +0800
@@ -18,3 +18,5 @@ extern struct hda_codec_preset snd_hda_p
 extern struct hda_codec_preset snd_hda_preset_conexant[];
 /* VIA codecs */
 extern struct hda_codec_preset snd_hda_preset_via[];
+/* NVIDIA HDMI codecs */
+extern struct hda_codec_preset snd_hda_preset_nvhdmi[];
diff -uprN -X linux-2.6.26-Orig/Documentation/dontdiff linux-2.6.26-Orig/sound/pci/hda/Makefile linux-2.6.26-New/sound/pci/hda/Makefile
--- linux-2.6.26-Orig/sound/pci/hda/Makefile	2008-08-28 13:47:20.000000000 +0800
+++ linux-2.6.26-New/sound/pci/hda/Makefile	2008-08-28 15:33:51.000000000 +0800
@@ -14,5 +14,6 @@ snd-hda-intel-$(CONFIG_SND_HDA_CODEC_SI3
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_ATIHDMI) += patch_atihdmi.o
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_CONEXANT) += patch_conexant.o
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_VIA) += patch_via.o
+snd-hda-intel-$(CONFIG_SND_HDA_CODEC_NVHDMI) += patch_nvhdmi.o
 
 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
diff -uprN -X linux-2.6.26-Orig/Documentation/dontdiff linux-2.6.26-Orig/sound/pci/hda/patch_nvhdmi.c linux-2.6.26-New/sound/pci/hda/patch_nvhdmi.c
--- linux-2.6.26-Orig/sound/pci/hda/patch_nvhdmi.c	1970-01-01 08:00:00.000000000 +0800
+++ linux-2.6.26-New/sound/pci/hda/patch_nvhdmi.c	2008-08-28 15:37:33.000000000 +0800
@@ -0,0 +1,379 @@
+/*
+ * Universal Interface for Intel High Definition Audio Codec
+ *
+ * HD audio interface patch for Nvidia HDMI codecs
+ *
+ * Copyright (c) 2008 NVIDIA Corp. All rights reserved.
+ * Copyright (c) 2008 Wei Ni <wni@nvidia.com>
+ *
+ *
+ *  This driver is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This driver is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+#include <sound/asoundef.h>
+#include "hda_codec.h"
+#include "hda_local.h"
+#include "hda_patch.h"
+
+struct nvhdmi_spec {
+	struct hda_multi_out multiout;
+
+	struct hda_pcm pcm_rec;
+};
+
+static struct hda_verb nvhdmi_basic_init[] = {
+	/* enable digital output on pin widget */
+	{ 0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+	{} /* terminator */
+};
+
+static unsigned short convert_from_spdif_status_nv(unsigned int sbits)
+{
+        unsigned short val = 0;
+
+        if (sbits & IEC958_AES0_PROFESSIONAL)
+                val |= AC_DIG1_PROFESSIONAL;
+        if (sbits & IEC958_AES0_NONAUDIO)
+                val |= AC_DIG1_NONAUDIO;
+        if (sbits & IEC958_AES0_PROFESSIONAL) {
+                if ((sbits & IEC958_AES0_PRO_EMPHASIS) ==
+                    IEC958_AES0_PRO_EMPHASIS_5015)
+                        val |= AC_DIG1_EMPHASIS;
+        } else {
+                if ((sbits & IEC958_AES0_CON_EMPHASIS) ==
+                    IEC958_AES0_CON_EMPHASIS_5015)
+                        val |= AC_DIG1_EMPHASIS;
+                if (!(sbits & IEC958_AES0_CON_NOT_COPYRIGHT))
+                        val |= AC_DIG1_COPYRIGHT;
+                if (sbits & (IEC958_AES1_CON_ORIGINAL << 8))
+                        val |= AC_DIG1_LEVEL;
+                val |= sbits & (IEC958_AES1_CON_CATEGORY << 8);
+        }
+        return val;
+}
+
+static unsigned int convert_to_spdif_status_nv(unsigned short val)
+{
+        unsigned int sbits = 0;
+
+        if (val & AC_DIG1_NONAUDIO)
+                sbits |= IEC958_AES0_NONAUDIO;
+        if (val & AC_DIG1_PROFESSIONAL)
+                sbits |= IEC958_AES0_PROFESSIONAL;
+        if (sbits & IEC958_AES0_PROFESSIONAL) {
+                if (sbits & AC_DIG1_EMPHASIS)
+                        sbits |= IEC958_AES0_PRO_EMPHASIS_5015;
+        } else {
+                if (val & AC_DIG1_EMPHASIS)
+                        sbits |= IEC958_AES0_CON_EMPHASIS_5015;
+                if (!(val & AC_DIG1_COPYRIGHT))
+                        sbits |= IEC958_AES0_CON_NOT_COPYRIGHT;
+                if (val & AC_DIG1_LEVEL)
+                        sbits |= (IEC958_AES1_CON_ORIGINAL << 8);
+                sbits |= val & (0x7f << 8);
+        }
+        return sbits;
+}
+
+static int snd_hda_hdmi_cmask_get(struct snd_kcontrol *kcontrol,
+                                   struct snd_ctl_elem_value *ucontrol)
+{
+        ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
+                                           IEC958_AES0_NONAUDIO |
+                                           IEC958_AES0_CON_EMPHASIS_5015 |
+                                           IEC958_AES0_CON_NOT_COPYRIGHT;
+        ucontrol->value.iec958.status[1] = IEC958_AES1_CON_CATEGORY |
+                                           IEC958_AES1_CON_ORIGINAL;
+        return 0;
+}
+
+static int snd_hda_hdmi_pmask_get(struct snd_kcontrol *kcontrol,
+                                   struct snd_ctl_elem_value *ucontrol)
+{
+        ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
+                                           IEC958_AES0_NONAUDIO |
+                                           IEC958_AES0_PRO_EMPHASIS_5015;
+        return 0;
+}
+
+static int snd_hda_hdmi_mask_info(struct snd_kcontrol *kcontrol,
+                                   struct snd_ctl_elem_info *uinfo)
+{
+        uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
+        uinfo->count = 1;
+        return 0;
+}
+
+static int snd_hda_hdmi_default_get(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+
+        ucontrol->value.iec958.status[0] = codec->spdif_status & 0xff;
+        ucontrol->value.iec958.status[1] = (codec->spdif_status >> 8) & 0xff;
+        ucontrol->value.iec958.status[2] = (codec->spdif_status >> 16) & 0xff;
+        ucontrol->value.iec958.status[3] = (codec->spdif_status >> 24) & 0xff;
+
+        return 0;
+}
+
+static int snd_hda_hdmi_default_put(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+        hda_nid_t nid = kcontrol->private_value;
+        unsigned short val;
+        int change;
+
+        mutex_lock(&codec->spdif_mutex);
+        codec->spdif_status = ucontrol->value.iec958.status[0] |
+                ((unsigned int)ucontrol->value.iec958.status[1] << 8) |
+                ((unsigned int)ucontrol->value.iec958.status[2] << 16) |
+                ((unsigned int)ucontrol->value.iec958.status[3] << 24);
+        val = convert_from_spdif_status_nv(codec->spdif_status);
+        val |= codec->spdif_ctls & 1;
+        change = codec->spdif_ctls != val;
+        codec->spdif_ctls = val;
+
+        if (change) {
+                snd_hda_codec_write_cache(codec, nid, 0,
+                                          AC_VERB_SET_DIGI_CONVERT_1,
+                                          val & 0xff);
+                snd_hda_codec_write_cache(codec, nid, 0,
+                                          AC_VERB_SET_DIGI_CONVERT_2,
+                                          val >> 8);
+        }
+
+        mutex_unlock(&codec->spdif_mutex);
+        return change;
+}
+
+#define snd_hda_hdmi_out_switch_info   snd_ctl_boolean_mono_info
+
+static int snd_hda_hdmi_out_switch_get(struct snd_kcontrol *kcontrol,
+                                        struct snd_ctl_elem_value *ucontrol)
+{
+        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+
+        ucontrol->value.integer.value[0] = codec->spdif_ctls & AC_DIG1_ENABLE;
+        return 0;
+}
+
+static int snd_hda_hdmi_out_switch_put(struct snd_kcontrol *kcontrol,
+                                        struct snd_ctl_elem_value *ucontrol)
+{
+        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+        hda_nid_t nid = kcontrol->private_value;
+        unsigned short val;
+        int change;
+
+        mutex_lock(&codec->spdif_mutex);
+        val = codec->spdif_ctls & ~AC_DIG1_ENABLE;
+        if (ucontrol->value.integer.value[0])
+                val |= AC_DIG1_ENABLE;
+        change = codec->spdif_ctls != val;
+        if (change) {
+                codec->spdif_ctls = val;
+                snd_hda_codec_write_cache(codec, nid, 0,
+                                          AC_VERB_SET_DIGI_CONVERT_1,
+                                          val & 0xff);
+                /* unmute amp switch (if any) */
+                if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
+                    (val & AC_DIG1_ENABLE))
+                        snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
+                                                 HDA_AMP_MUTE, 0);
+        }
+        mutex_unlock(&codec->spdif_mutex);
+        return change;
+}
+
+struct snd_kcontrol_new hdmi_mixes[] = {
+    {
+        .access = SNDRV_CTL_ELEM_ACCESS_READ,
+        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+        .name = "IEC958 Playback Con Mask HDMI",
+        .info = snd_hda_hdmi_mask_info,
+        .get = snd_hda_hdmi_cmask_get,
+    },
+    {
+        .access = SNDRV_CTL_ELEM_ACCESS_READ,
+        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+        .name = "IEC958 Playback Pro Mask HDMI",
+        .info = snd_hda_hdmi_mask_info,
+        .get = snd_hda_hdmi_pmask_get,
+    },
+    {
+        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+        .name = "IEC958 Playback Default HDMI",
+        .info = snd_hda_hdmi_mask_info,
+        .get = snd_hda_hdmi_default_get,
+        .put = snd_hda_hdmi_default_put,
+    },
+    {
+        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+        .name = "IEC958 Playback Switch HDMI",
+        .info = snd_hda_hdmi_out_switch_info,
+        .get = snd_hda_hdmi_out_switch_get,
+        .put = snd_hda_hdmi_out_switch_put,
+    },
+    {}
+};
+
+int snd_hda_create_hdmi_out_ctls(struct hda_codec *codec, hda_nid_t nid)
+{
+        int err;
+        struct snd_kcontrol *kctl;
+        struct snd_kcontrol_new *dig_mix;
+
+        for (dig_mix = hdmi_mixes; dig_mix->name; dig_mix++) {
+                kctl = snd_ctl_new1(dig_mix, codec);
+                kctl->private_value = nid;
+                err = snd_ctl_add(codec->bus->card, kctl);
+                if (err < 0)
+                        return err;
+        }
+        codec->spdif_ctls =
+                snd_hda_codec_read(codec, nid, 0,
+                                   AC_VERB_GET_DIGI_CONVERT_1, 0);
+        codec->spdif_status = convert_to_spdif_status_nv(codec->spdif_ctls);
+        return 0;
+}
+
+/*
+ * Controls
+ */
+static int nvhdmi_build_controls(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	int err;
+
+	err = snd_hda_create_hdmi_out_ctls(codec, spec->multiout.dig_out_nid);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int nvhdmi_init(struct hda_codec *codec)
+{
+	snd_hda_sequence_write(codec, nvhdmi_basic_init);
+	return 0;
+}
+
+/*
+ * Digital out
+ */
+static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
+				     struct hda_codec *codec,
+				     struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_open(codec, &spec->multiout);
+}
+
+static int nvhdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
+				      struct hda_codec *codec,
+				      struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_close(codec, &spec->multiout);
+}
+
+static int nvhdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
+					    struct hda_codec *codec,
+					    unsigned int stream_tag,
+					    unsigned int format,
+					    struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
+					     format, substream);
+}
+
+static struct hda_pcm_stream nvhdmi_pcm_digital_playback = {
+	.substreams = 1,
+	.channels_min = 2,
+	.channels_max = 2,
+	.nid = 0x4, /* NID to query formats and rates and setup streams */
+        .rates = SNDRV_PCM_RATE_48000,
+        .maxbps = 16,
+        .formats = SNDRV_PCM_FMTBIT_S16_LE,
+	.ops = {
+		.open = nvhdmi_dig_playback_pcm_open,
+		.close = nvhdmi_dig_playback_pcm_close,
+		.prepare = nvhdmi_dig_playback_pcm_prepare
+	},
+};
+
+static int nvhdmi_build_pcms(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	struct hda_pcm *info = &spec->pcm_rec;
+
+	codec->num_pcms = 1;
+	codec->pcm_info = info;
+
+	info->name = "NVIDIA HDMI";
+        info->pcm_type = HDA_PCM_TYPE_HDMI
+	info->stream[SNDRV_PCM_STREAM_PLAYBACK] = nvhdmi_pcm_digital_playback;
+
+	return 0;
+}
+
+static void nvhdmi_free(struct hda_codec *codec)
+{
+	kfree(codec->spec);
+}
+
+static struct hda_codec_ops nvhdmi_patch_ops = {
+	.build_controls = nvhdmi_build_controls,
+	.build_pcms = nvhdmi_build_pcms,
+	.init = nvhdmi_init,
+	.free = nvhdmi_free,
+};
+
+static int patch_nvhdmi(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec;
+
+	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
+	if (spec == NULL)
+		return -ENOMEM;
+
+	codec->spec = spec;
+
+	spec->multiout.num_dacs = 0;	  /* no analog */
+	spec->multiout.max_channels = 2;
+	spec->multiout.dig_out_nid = 0x4; /* NID for copying analog to digital,
+					   * seems to be unused in pure-digital
+					   * case. */
+
+	codec->patch_ops = nvhdmi_patch_ops;
+
+	return 0;
+}
+
+/*
+ * patch entries
+ */
+struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
+	{ .id = 0x10de0002, .name = "Nvidia MCP78 HDMI", .patch = patch_nvhdmi },
+	{ .id = 0x10de0007, .name = "Nvidia MCP7A HDMI", .patch = patch_nvhdmi },
+	{} /* terminator */
+};
diff -uprN -X linux-2.6.26-Orig/Documentation/dontdiff linux-2.6.26-Orig/sound/pci/Kconfig linux-2.6.26-New/sound/pci/Kconfig
--- linux-2.6.26-Orig/sound/pci/Kconfig	2008-08-28 13:47:20.000000000 +0800
+++ linux-2.6.26-New/sound/pci/Kconfig	2008-08-28 15:33:51.000000000 +0800
@@ -557,6 +557,14 @@ config SND_HDA_CODEC_ATIHDMI
 	  Say Y here to include ATI HDMI HD-audio codec support in
 	  snd-hda-intel driver, such as ATI RS600 HDMI.
 
+config SND_HDA_CODEC_NVHDMI
+	bool "Build Nvidia HDMI HD-audio codec support"
+	depends on SND_HDA_INTEL
+	default y
+	help
+	  Say Y here to include Nvidia HDMI HD-audio codec support in
+	  snd-hda-intel driver, such as Nvidia MCP78 HDMI.
+
 config SND_HDA_CODEC_CONEXANT
 	bool "Build Conexant HD-audio codec support"
 	depends on SND_HDA_INTEL
-


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [alsa-devel][PATCH] add the nvidia HDMI codec driver for MCP77/79
  2008-09-03  7:58 [alsa-devel][PATCH] add the nvidia HDMI codec driver for MCP77/79 peerchen
@ 2008-09-03  8:51 ` Takashi Iwai
  2008-09-03 11:05   ` Wei Ni
  0 siblings, 1 reply; 17+ messages in thread
From: Takashi Iwai @ 2008-09-03  8:51 UTC (permalink / raw)
  To: peerchen; +Cc: alsa-devel, linux-kernel, akpm, pchen, wni

At Wed, 3 Sep 2008 15:58:17 +0800,
peerchen wrote:
> 
> Add the nvidia HDMI codec driver for MCP77/79. 
> The patch based on kernel 2.6.27-rc5.
> 
> Signed-off-by: Wei Ni <wni@nvidia.com>
> Signed-off-by: Peer Chen <peerchen@gmail.com>

Thanks for the patch.  Some comments below.


> diff -uprN -X linux-2.6.26-Orig/Documentation/dontdiff linux-2.6.26-Orig/sound/pci/hda/hda_intel.c linux-2.6.26-New/sound/pci/hda/hda_intel.c
> --- linux-2.6.26-Orig/sound/pci/hda/hda_intel.c	2008-08-28 13:47:20.000000000 +0800
> +++ linux-2.6.26-New/sound/pci/hda/hda_intel.c	2008-08-28 15:33:51.000000000 +0800
> @@ -223,8 +223,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO
>  #define RIRB_INT_MASK		0x05
>  
>  /* STATESTS int mask: SD2,SD1,SD0 */
> -#define AZX_MAX_CODECS		3
> -#define STATESTS_INT_MASK	0x07
> +#define AZX_MAX_CODECS		4
> +#define STATESTS_INT_MASK	0x0f

This may break other platforms.  Expanding STATESTS_INT_MASK is OK and
would be harmless, but AZX_MAX_CODECS is not.
AZX_MAX_CODECS is the default number of max codecs.  The chipset
specific max number of codecs is defined in azx_max_codecs[].
If Nvidia chipsets supports properly more than 3, change
azx_max_codecs[AZX_DRIVER_NVIDIA] to 4.


> +static unsigned short convert_from_spdif_status_nv(unsigned int sbits)
> +{
> +        unsigned short val = 0;
> +
> +        if (sbits & IEC958_AES0_PROFESSIONAL)
> +                val |= AC_DIG1_PROFESSIONAL;
> +        if (sbits & IEC958_AES0_NONAUDIO)
> +                val |= AC_DIG1_NONAUDIO;
> +        if (sbits & IEC958_AES0_PROFESSIONAL) {
> +                if ((sbits & IEC958_AES0_PRO_EMPHASIS) ==
> +                    IEC958_AES0_PRO_EMPHASIS_5015)
> +                        val |= AC_DIG1_EMPHASIS;
> +        } else {
> +                if ((sbits & IEC958_AES0_CON_EMPHASIS) ==
> +                    IEC958_AES0_CON_EMPHASIS_5015)
> +                        val |= AC_DIG1_EMPHASIS;
> +                if (!(sbits & IEC958_AES0_CON_NOT_COPYRIGHT))
> +                        val |= AC_DIG1_COPYRIGHT;
> +                if (sbits & (IEC958_AES1_CON_ORIGINAL << 8))
> +                        val |= AC_DIG1_LEVEL;
> +                val |= sbits & (IEC958_AES1_CON_CATEGORY << 8);
> +        }
> +        return val;
> +}
> +
> +static unsigned int convert_to_spdif_status_nv(unsigned short val)
> +{
> +        unsigned int sbits = 0;
> +
> +        if (val & AC_DIG1_NONAUDIO)
> +                sbits |= IEC958_AES0_NONAUDIO;
> +        if (val & AC_DIG1_PROFESSIONAL)
> +                sbits |= IEC958_AES0_PROFESSIONAL;
> +        if (sbits & IEC958_AES0_PROFESSIONAL) {
> +                if (sbits & AC_DIG1_EMPHASIS)
> +                        sbits |= IEC958_AES0_PRO_EMPHASIS_5015;
> +        } else {
> +                if (val & AC_DIG1_EMPHASIS)
> +                        sbits |= IEC958_AES0_CON_EMPHASIS_5015;
> +                if (!(val & AC_DIG1_COPYRIGHT))
> +                        sbits |= IEC958_AES0_CON_NOT_COPYRIGHT;
> +                if (val & AC_DIG1_LEVEL)
> +                        sbits |= (IEC958_AES1_CON_ORIGINAL << 8);
> +                sbits |= val & (0x7f << 8);
> +        }
> +        return sbits;
> +}
> +
> +static int snd_hda_hdmi_cmask_get(struct snd_kcontrol *kcontrol,
> +                                   struct snd_ctl_elem_value *ucontrol)
> +{
> +        ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
> +                                           IEC958_AES0_NONAUDIO |
> +                                           IEC958_AES0_CON_EMPHASIS_5015 |
> +                                           IEC958_AES0_CON_NOT_COPYRIGHT;
> +        ucontrol->value.iec958.status[1] = IEC958_AES1_CON_CATEGORY |
> +                                           IEC958_AES1_CON_ORIGINAL;
> +        return 0;
> +}
> +
> +static int snd_hda_hdmi_pmask_get(struct snd_kcontrol *kcontrol,
> +                                   struct snd_ctl_elem_value *ucontrol)
> +{
> +        ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
> +                                           IEC958_AES0_NONAUDIO |
> +                                           IEC958_AES0_PRO_EMPHASIS_5015;
> +        return 0;
> +}
> +
> +static int snd_hda_hdmi_mask_info(struct snd_kcontrol *kcontrol,
> +                                   struct snd_ctl_elem_info *uinfo)
> +{
> +        uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
> +        uinfo->count = 1;
> +        return 0;
> +}
> +
> +static int snd_hda_hdmi_default_get(struct snd_kcontrol *kcontrol,
> +                                     struct snd_ctl_elem_value *ucontrol)
> +{
> +        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
> +
> +        ucontrol->value.iec958.status[0] = codec->spdif_status & 0xff;
> +        ucontrol->value.iec958.status[1] = (codec->spdif_status >> 8) & 0xff;
> +        ucontrol->value.iec958.status[2] = (codec->spdif_status >> 16) & 0xff;
> +        ucontrol->value.iec958.status[3] = (codec->spdif_status >> 24) & 0xff;
> +
> +        return 0;
> +}
> +
> +static int snd_hda_hdmi_default_put(struct snd_kcontrol *kcontrol,
> +                                     struct snd_ctl_elem_value *ucontrol)
> +{
> +        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
> +        hda_nid_t nid = kcontrol->private_value;
> +        unsigned short val;
> +        int change;
> +
> +        mutex_lock(&codec->spdif_mutex);
> +        codec->spdif_status = ucontrol->value.iec958.status[0] |
> +                ((unsigned int)ucontrol->value.iec958.status[1] << 8) |
> +                ((unsigned int)ucontrol->value.iec958.status[2] << 16) |
> +                ((unsigned int)ucontrol->value.iec958.status[3] << 24);
> +        val = convert_from_spdif_status_nv(codec->spdif_status);
> +        val |= codec->spdif_ctls & 1;
> +        change = codec->spdif_ctls != val;
> +        codec->spdif_ctls = val;
> +
> +        if (change) {
> +                snd_hda_codec_write_cache(codec, nid, 0,
> +                                          AC_VERB_SET_DIGI_CONVERT_1,
> +                                          val & 0xff);
> +                snd_hda_codec_write_cache(codec, nid, 0,
> +                                          AC_VERB_SET_DIGI_CONVERT_2,
> +                                          val >> 8);
> +        }
> +
> +        mutex_unlock(&codec->spdif_mutex);
> +        return change;
> +}
> +
> +#define snd_hda_hdmi_out_switch_info   snd_ctl_boolean_mono_info
> +
> +static int snd_hda_hdmi_out_switch_get(struct snd_kcontrol *kcontrol,
> +                                        struct snd_ctl_elem_value *ucontrol)
> +{
> +        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
> +
> +        ucontrol->value.integer.value[0] = codec->spdif_ctls & AC_DIG1_ENABLE;
> +        return 0;
> +}
> +
> +static int snd_hda_hdmi_out_switch_put(struct snd_kcontrol *kcontrol,
> +                                        struct snd_ctl_elem_value *ucontrol)
> +{
> +        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
> +        hda_nid_t nid = kcontrol->private_value;
> +        unsigned short val;
> +        int change;
> +
> +        mutex_lock(&codec->spdif_mutex);
> +        val = codec->spdif_ctls & ~AC_DIG1_ENABLE;
> +        if (ucontrol->value.integer.value[0])
> +                val |= AC_DIG1_ENABLE;
> +        change = codec->spdif_ctls != val;
> +        if (change) {
> +                codec->spdif_ctls = val;
> +                snd_hda_codec_write_cache(codec, nid, 0,
> +                                          AC_VERB_SET_DIGI_CONVERT_1,
> +                                          val & 0xff);
> +                /* unmute amp switch (if any) */
> +                if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
> +                    (val & AC_DIG1_ENABLE))
> +                        snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
> +                                                 HDA_AMP_MUTE, 0);
> +        }
> +        mutex_unlock(&codec->spdif_mutex);
> +        return change;
> +}

These are almost identical with the functions in hda_codec.c.
Is your intention to allow a different set of IEC958 status bits
controls for HDMI *in addition* to SPDIF?  If so, we should change
the codes in hda_codec.c to allow other control names.


> +struct snd_kcontrol_new hdmi_mixes[] = {
> +    {
> +        .access = SNDRV_CTL_ELEM_ACCESS_READ,
> +        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> +        .name = "IEC958 Playback Con Mask HDMI",
> +        .info = snd_hda_hdmi_mask_info,
> +        .get = snd_hda_hdmi_cmask_get,
> +    },

These have also different names from the standard ones.
Any reason?

> +static struct hda_pcm_stream nvhdmi_pcm_digital_playback = {
> +	.substreams = 1,
> +	.channels_min = 2,
> +	.channels_max = 2,
> +	.nid = 0x4, /* NID to query formats and rates and setup streams */
> +        .rates = SNDRV_PCM_RATE_48000,
> +        .maxbps = 16,
> +        .formats = SNDRV_PCM_FMTBIT_S16_LE,

Use tabs please.

> +static int nvhdmi_build_pcms(struct hda_codec *codec)
> +{
> +	struct nvhdmi_spec *spec = codec->spec;
> +	struct hda_pcm *info = &spec->pcm_rec;
> +
> +	codec->num_pcms = 1;
> +	codec->pcm_info = info;
> +
> +	info->name = "NVIDIA HDMI";
> +        info->pcm_type = HDA_PCM_TYPE_HDMI

Ditto.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [alsa-devel][PATCH] add the nvidia HDMI codec driver for MCP77/79
  2008-09-03  8:51 ` Takashi Iwai
@ 2008-09-03 11:05   ` Wei Ni
  2008-09-03 12:06     ` Takashi Iwai
  0 siblings, 1 reply; 17+ messages in thread
From: Wei Ni @ 2008-09-03 11:05 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, linux-kernel, akpm, Peer Chen


 Thanks for your comments. Some reply below:

-----Original Message-----
From: Takashi Iwai [mailto:tiwai@suse.de] 
Sent: Wednesday, September 03, 2008 4:52 PM
To: peerchen
Cc: alsa-devel; linux-kernel; akpm; Peer Chen; Wei Ni
Subject: Re: [alsa-devel][PATCH] add the nvidia HDMI codec driver for
MCP77/79

At Wed, 3 Sep 2008 15:58:17 +0800,
peerchen wrote:
> 
> Add the nvidia HDMI codec driver for MCP77/79. 
> The patch based on kernel 2.6.27-rc5.
> 
> Signed-off-by: Wei Ni <wni@nvidia.com>
> Signed-off-by: Peer Chen <peerchen@gmail.com>

Thanks for the patch.  Some comments below.


> diff -uprN -X linux-2.6.26-Orig/Documentation/dontdiff
linux-2.6.26-Orig/sound/pci/hda/hda_intel.c
linux-2.6.26-New/sound/pci/hda/hda_intel.c
> --- linux-2.6.26-Orig/sound/pci/hda/hda_intel.c	2008-08-28
13:47:20.000000000 +0800
> +++ linux-2.6.26-New/sound/pci/hda/hda_intel.c	2008-08-28
15:33:51.000000000 +0800
> @@ -223,8 +223,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO
>  #define RIRB_INT_MASK		0x05
>  
>  /* STATESTS int mask: SD2,SD1,SD0 */
> -#define AZX_MAX_CODECS		3
> -#define STATESTS_INT_MASK	0x07
> +#define AZX_MAX_CODECS		4
> +#define STATESTS_INT_MASK	0x0f

This may break other platforms.  Expanding STATESTS_INT_MASK is OK and
would be harmless, but AZX_MAX_CODECS is not.
AZX_MAX_CODECS is the default number of max codecs.  The chipset
specific max number of codecs is defined in azx_max_codecs[].
If Nvidia chipsets supports properly more than 3, change
azx_max_codecs[AZX_DRIVER_NVIDIA] to 4.

==========Wei Ni's Answer: ==============
There are 2 codec connect to the nvidia AZA controller, one is realtek,
and the other is nvidia HDMI codec.
In azx_codec_create(), the chip->codec_mask indicate codec connection.
This chip->codec_mask=0x9, bit0 indicate realtek codec, and bit3
indicate hdmi codec.
In this routine, it use:
......
for (c = 0; c < AZX_MAX_CODECS; c++) {
		if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
			struct hda_codec *codec;
			err = snd_hda_codec_new(chip->bus, c, &codec);
			if (err < 0)
				continue;
			codecs++;
			if (codec->afg)
				audio_codecs++;
		}
	}
if (!audio_codecs) {
		/* probe additional slots if no codec is found */
		for (; c < azx_max_codecs[chip->driver_type]; c++) {
			if ((chip->codec_mask & (1 << c)) &
codec_probe_mask) {
				err = snd_hda_codec_new(chip->bus, c,
NULL);
				if (err < 0)
					continue;
				codecs++;
			}
		}
	}
......
According to these codes, It only can get the realtek codec and can not
get hdmi codec, if just change azx_max_codecs[AZX_DRIVER_NVIDIA] to 4
I think if remove "if (!audio_codecs)", it will be better, and I only
need to chang azx_max_codecs[AZX_DRIVER_NVIDIA] to 4
=====================================

> +static unsigned short convert_from_spdif_status_nv(unsigned int
sbits)
> +{
> +        unsigned short val = 0;
> +
> +        if (sbits & IEC958_AES0_PROFESSIONAL)
> +                val |= AC_DIG1_PROFESSIONAL;
> +        if (sbits & IEC958_AES0_NONAUDIO)
> +                val |= AC_DIG1_NONAUDIO;
> +        if (sbits & IEC958_AES0_PROFESSIONAL) {
> +                if ((sbits & IEC958_AES0_PRO_EMPHASIS) ==
> +                    IEC958_AES0_PRO_EMPHASIS_5015)
> +                        val |= AC_DIG1_EMPHASIS;
> +        } else {
> +                if ((sbits & IEC958_AES0_CON_EMPHASIS) ==
> +                    IEC958_AES0_CON_EMPHASIS_5015)
> +                        val |= AC_DIG1_EMPHASIS;
> +                if (!(sbits & IEC958_AES0_CON_NOT_COPYRIGHT))
> +                        val |= AC_DIG1_COPYRIGHT;
> +                if (sbits & (IEC958_AES1_CON_ORIGINAL << 8))
> +                        val |= AC_DIG1_LEVEL;
> +                val |= sbits & (IEC958_AES1_CON_CATEGORY << 8);
> +        }
> +        return val;
> +}
> +
> +static unsigned int convert_to_spdif_status_nv(unsigned short val)
> +{
> +        unsigned int sbits = 0;
> +
> +        if (val & AC_DIG1_NONAUDIO)
> +                sbits |= IEC958_AES0_NONAUDIO;
> +        if (val & AC_DIG1_PROFESSIONAL)
> +                sbits |= IEC958_AES0_PROFESSIONAL;
> +        if (sbits & IEC958_AES0_PROFESSIONAL) {
> +                if (sbits & AC_DIG1_EMPHASIS)
> +                        sbits |= IEC958_AES0_PRO_EMPHASIS_5015;
> +        } else {
> +                if (val & AC_DIG1_EMPHASIS)
> +                        sbits |= IEC958_AES0_CON_EMPHASIS_5015;
> +                if (!(val & AC_DIG1_COPYRIGHT))
> +                        sbits |= IEC958_AES0_CON_NOT_COPYRIGHT;
> +                if (val & AC_DIG1_LEVEL)
> +                        sbits |= (IEC958_AES1_CON_ORIGINAL << 8);
> +                sbits |= val & (0x7f << 8);
> +        }
> +        return sbits;
> +}
> +
> +static int snd_hda_hdmi_cmask_get(struct snd_kcontrol *kcontrol,
> +                                   struct snd_ctl_elem_value
*ucontrol)
> +{
> +        ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
> +                                           IEC958_AES0_NONAUDIO |
> +
IEC958_AES0_CON_EMPHASIS_5015 |
> +
IEC958_AES0_CON_NOT_COPYRIGHT;
> +        ucontrol->value.iec958.status[1] = IEC958_AES1_CON_CATEGORY |
> +                                           IEC958_AES1_CON_ORIGINAL;
> +        return 0;
> +}
> +
> +static int snd_hda_hdmi_pmask_get(struct snd_kcontrol *kcontrol,
> +                                   struct snd_ctl_elem_value
*ucontrol)
> +{
> +        ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
> +                                           IEC958_AES0_NONAUDIO |
> +
IEC958_AES0_PRO_EMPHASIS_5015;
> +        return 0;
> +}
> +
> +static int snd_hda_hdmi_mask_info(struct snd_kcontrol *kcontrol,
> +                                   struct snd_ctl_elem_info *uinfo)
> +{
> +        uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
> +        uinfo->count = 1;
> +        return 0;
> +}
> +
> +static int snd_hda_hdmi_default_get(struct snd_kcontrol *kcontrol,
> +                                     struct snd_ctl_elem_value
*ucontrol)
> +{
> +        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
> +
> +        ucontrol->value.iec958.status[0] = codec->spdif_status &
0xff;
> +        ucontrol->value.iec958.status[1] = (codec->spdif_status >> 8)
& 0xff;
> +        ucontrol->value.iec958.status[2] = (codec->spdif_status >>
16) & 0xff;
> +        ucontrol->value.iec958.status[3] = (codec->spdif_status >>
24) & 0xff;
> +
> +        return 0;
> +}
> +
> +static int snd_hda_hdmi_default_put(struct snd_kcontrol *kcontrol,
> +                                     struct snd_ctl_elem_value
*ucontrol)
> +{
> +        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
> +        hda_nid_t nid = kcontrol->private_value;
> +        unsigned short val;
> +        int change;
> +
> +        mutex_lock(&codec->spdif_mutex);
> +        codec->spdif_status = ucontrol->value.iec958.status[0] |
> +                ((unsigned int)ucontrol->value.iec958.status[1] << 8)
|
> +                ((unsigned int)ucontrol->value.iec958.status[2] <<
16) |
> +                ((unsigned int)ucontrol->value.iec958.status[3] <<
24);
> +        val = convert_from_spdif_status_nv(codec->spdif_status);
> +        val |= codec->spdif_ctls & 1;
> +        change = codec->spdif_ctls != val;
> +        codec->spdif_ctls = val;
> +
> +        if (change) {
> +                snd_hda_codec_write_cache(codec, nid, 0,
> +                                          AC_VERB_SET_DIGI_CONVERT_1,
> +                                          val & 0xff);
> +                snd_hda_codec_write_cache(codec, nid, 0,
> +                                          AC_VERB_SET_DIGI_CONVERT_2,
> +                                          val >> 8);
> +        }
> +
> +        mutex_unlock(&codec->spdif_mutex);
> +        return change;
> +}
> +
> +#define snd_hda_hdmi_out_switch_info   snd_ctl_boolean_mono_info
> +
> +static int snd_hda_hdmi_out_switch_get(struct snd_kcontrol *kcontrol,
> +                                        struct snd_ctl_elem_value
*ucontrol)
> +{
> +        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
> +
> +        ucontrol->value.integer.value[0] = codec->spdif_ctls &
AC_DIG1_ENABLE;
> +        return 0;
> +}
> +
> +static int snd_hda_hdmi_out_switch_put(struct snd_kcontrol *kcontrol,
> +                                        struct snd_ctl_elem_value
*ucontrol)
> +{
> +        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
> +        hda_nid_t nid = kcontrol->private_value;
> +        unsigned short val;
> +        int change;
> +
> +        mutex_lock(&codec->spdif_mutex);
> +        val = codec->spdif_ctls & ~AC_DIG1_ENABLE;
> +        if (ucontrol->value.integer.value[0])
> +                val |= AC_DIG1_ENABLE;
> +        change = codec->spdif_ctls != val;
> +        if (change) {
> +                codec->spdif_ctls = val;
> +                snd_hda_codec_write_cache(codec, nid, 0,
> +                                          AC_VERB_SET_DIGI_CONVERT_1,
> +                                          val & 0xff);
> +                /* unmute amp switch (if any) */
> +                if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
> +                    (val & AC_DIG1_ENABLE))
> +                        snd_hda_codec_amp_stereo(codec, nid,
HDA_OUTPUT, 0,
> +                                                 HDA_AMP_MUTE, 0);
> +        }
> +        mutex_unlock(&codec->spdif_mutex);
> +        return change;
> +}

These are almost identical with the functions in hda_codec.c.
Is your intention to allow a different set of IEC958 status bits
controls for HDMI *in addition* to SPDIF?  If so, we should change
the codes in hda_codec.c to allow other control names.

==========Wei Ni's Answer: ==============
There are 2 codec connect to the nvidia AZA controller, one is realtek,
the other is nvidia HDMI codec.
If I use the default SPDIF routine: snd_hda_create_spdif_out_ctls(), the
driver can not be insmod success.
I traced this issue, the realtek's SPDIF used this IEC958 first, and
then HDMI codec can't use IEC958 again.
( I traced it based on linux-2.6.25 )
So I write some routines for HDMI which are same as SPDIF routine, and
the driver can work.
=====================================


> +struct snd_kcontrol_new hdmi_mixes[] = {
> +    {
> +        .access = SNDRV_CTL_ELEM_ACCESS_READ,
> +        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> +        .name = "IEC958 Playback Con Mask HDMI",
> +        .info = snd_hda_hdmi_mask_info,
> +        .get = snd_hda_hdmi_cmask_get,
> +    },

These have also different names from the standard ones.
Any reason?

==========Wei Ni's Answer: ==============
Ditto
=====================================

> +static struct hda_pcm_stream nvhdmi_pcm_digital_playback = {
> +	.substreams = 1,
> +	.channels_min = 2,
> +	.channels_max = 2,
> +	.nid = 0x4, /* NID to query formats and rates and setup streams
*/
> +        .rates = SNDRV_PCM_RATE_48000,
> +        .maxbps = 16,
> +        .formats = SNDRV_PCM_FMTBIT_S16_LE,

Use tabs please.

==========Wei Ni's Answer: ==============
Thanks, I will modify it.
=====================================

> +static int nvhdmi_build_pcms(struct hda_codec *codec)
> +{
> +	struct nvhdmi_spec *spec = codec->spec;
> +	struct hda_pcm *info = &spec->pcm_rec;
> +
> +	codec->num_pcms = 1;
> +	codec->pcm_info = info;
> +
> +	info->name = "NVIDIA HDMI";
> +        info->pcm_type = HDA_PCM_TYPE_HDMI

Ditto.

==========Wei Ni's Answer: ==============
Thanks, I will modify it.
=====================================


thanks,

Takashi
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [alsa-devel][PATCH] add the nvidia HDMI codec driver for MCP77/79
  2008-09-03 11:05   ` Wei Ni
@ 2008-09-03 12:06     ` Takashi Iwai
  2008-09-03 12:11       ` [alsa-devel] [PATCH] " Pavel Hofman
  0 siblings, 1 reply; 17+ messages in thread
From: Takashi Iwai @ 2008-09-03 12:06 UTC (permalink / raw)
  To: Wei Ni; +Cc: alsa-devel, linux-kernel, akpm, Peer Chen

At Wed, 3 Sep 2008 19:05:47 +0800,
Wei Ni wrote:
> 
> 
>  Thanks for your comments. Some reply below:
> 
> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de] 
> Sent: Wednesday, September 03, 2008 4:52 PM
> To: peerchen
> Cc: alsa-devel; linux-kernel; akpm; Peer Chen; Wei Ni
> Subject: Re: [alsa-devel][PATCH] add the nvidia HDMI codec driver for
> MCP77/79
> 
> At Wed, 3 Sep 2008 15:58:17 +0800,
> peerchen wrote:
> > 
> > Add the nvidia HDMI codec driver for MCP77/79. 
> > The patch based on kernel 2.6.27-rc5.
> > 
> > Signed-off-by: Wei Ni <wni@nvidia.com>
> > Signed-off-by: Peer Chen <peerchen@gmail.com>
> 
> Thanks for the patch.  Some comments below.
> 
> 
> > diff -uprN -X linux-2.6.26-Orig/Documentation/dontdiff
> linux-2.6.26-Orig/sound/pci/hda/hda_intel.c
> linux-2.6.26-New/sound/pci/hda/hda_intel.c
> > --- linux-2.6.26-Orig/sound/pci/hda/hda_intel.c	2008-08-28
> 13:47:20.000000000 +0800
> > +++ linux-2.6.26-New/sound/pci/hda/hda_intel.c	2008-08-28
> 15:33:51.000000000 +0800
> > @@ -223,8 +223,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO
> >  #define RIRB_INT_MASK		0x05
> >  
> >  /* STATESTS int mask: SD2,SD1,SD0 */
> > -#define AZX_MAX_CODECS		3
> > -#define STATESTS_INT_MASK	0x07
> > +#define AZX_MAX_CODECS		4
> > +#define STATESTS_INT_MASK	0x0f
> 
> This may break other platforms.  Expanding STATESTS_INT_MASK is OK and
> would be harmless, but AZX_MAX_CODECS is not.
> AZX_MAX_CODECS is the default number of max codecs.  The chipset
> specific max number of codecs is defined in azx_max_codecs[].
> If Nvidia chipsets supports properly more than 3, change
> azx_max_codecs[AZX_DRIVER_NVIDIA] to 4.
> 
> ==========Wei Ni's Answer: ==============
> There are 2 codec connect to the nvidia AZA controller, one is realtek,
> and the other is nvidia HDMI codec.
> In azx_codec_create(), the chip->codec_mask indicate codec connection.
> This chip->codec_mask=0x9, bit0 indicate realtek codec, and bit3
> indicate hdmi codec.
> In this routine, it use:
> ......
> for (c = 0; c < AZX_MAX_CODECS; c++) {
> 		if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
> 			struct hda_codec *codec;
> 			err = snd_hda_codec_new(chip->bus, c, &codec);
> 			if (err < 0)
> 				continue;
> 			codecs++;
> 			if (codec->afg)
> 				audio_codecs++;
> 		}
> 	}
> if (!audio_codecs) {
> 		/* probe additional slots if no codec is found */
> 		for (; c < azx_max_codecs[chip->driver_type]; c++) {
> 			if ((chip->codec_mask & (1 << c)) &
> codec_probe_mask) {
> 				err = snd_hda_codec_new(chip->bus, c,
> NULL);
> 				if (err < 0)
> 					continue;
> 				codecs++;
> 			}
> 		}
> 	}
> ......
> According to these codes, It only can get the realtek codec and can not
> get hdmi codec, if just change azx_max_codecs[AZX_DRIVER_NVIDIA] to 4
> I think if remove "if (!audio_codecs)", it will be better, and I only
> need to chang azx_max_codecs[AZX_DRIVER_NVIDIA] to 4

Well, the check is there for a good reason.

There are many machines with broken BIOS reporting the 4th slot
available although it isn't actually.  It's a workaround to skip such
a bogus information.  So, it cannot be changed so easily.

We need to sort out this in a better way...  Oh well.


> > +static unsigned short convert_from_spdif_status_nv(unsigned int
> sbits)
(snip)
> These are almost identical with the functions in hda_codec.c.
> Is your intention to allow a different set of IEC958 status bits
> controls for HDMI *in addition* to SPDIF?  If so, we should change
> the codes in hda_codec.c to allow other control names.
> 
> ==========Wei Ni's Answer: ==============
> There are 2 codec connect to the nvidia AZA controller, one is realtek,
> the other is nvidia HDMI codec.
> If I use the default SPDIF routine: snd_hda_create_spdif_out_ctls(), the
> driver can not be insmod success.
> I traced this issue, the realtek's SPDIF used this IEC958 first, and
> then HDMI codec can't use IEC958 again.
> ( I traced it based on linux-2.6.25 )

2.6.25 is too old as a reference.  The fix for multiple SPDIF devices
is already on the recent kernel.


Takashi

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driver for MCP77/79
  2008-09-03 12:06     ` Takashi Iwai
@ 2008-09-03 12:11       ` Pavel Hofman
  2008-09-04  7:04         ` Takashi Iwai
  0 siblings, 1 reply; 17+ messages in thread
From: Pavel Hofman @ 2008-09-03 12:11 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Wei Ni, Peer Chen, alsa-devel, linux-kernel, akpm


>> ......
>> According to these codes, It only can get the realtek codec and can not
>> get hdmi codec, if just change azx_max_codecs[AZX_DRIVER_NVIDIA] to 4
>> I think if remove "if (!audio_codecs)", it will be better, and I only
>> need to chang azx_max_codecs[AZX_DRIVER_NVIDIA] to 4
> 
> Well, the check is there for a good reason.
> 
> There are many machines with broken BIOS reporting the 4th slot
> available although it isn't actually.  It's a workaround to skip such
> a bogus information.  So, it cannot be changed so easily.
> 
> We need to sort out this in a better way...  Oh well.


Please, please, put the above information as a comment to the respective 
place. These "hacks" should be commented :)

Thanks a lot,

Pavel.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driver for MCP77/79
  2008-09-03 12:11       ` [alsa-devel] [PATCH] " Pavel Hofman
@ 2008-09-04  7:04         ` Takashi Iwai
  2008-09-05  8:28           ` Wei Ni
  0 siblings, 1 reply; 17+ messages in thread
From: Takashi Iwai @ 2008-09-04  7:04 UTC (permalink / raw)
  To: Pavel Hofman; +Cc: Wei Ni, Peer Chen, alsa-devel, linux-kernel, akpm

At Wed, 03 Sep 2008 14:11:16 +0200,
Pavel Hofman wrote:
> 
> 
> >> ......
> >> According to these codes, It only can get the realtek codec and can not
> >> get hdmi codec, if just change azx_max_codecs[AZX_DRIVER_NVIDIA] to 4
> >> I think if remove "if (!audio_codecs)", it will be better, and I only
> >> need to chang azx_max_codecs[AZX_DRIVER_NVIDIA] to 4
> > 
> > Well, the check is there for a good reason.
> > 
> > There are many machines with broken BIOS reporting the 4th slot
> > available although it isn't actually.  It's a workaround to skip such
> > a bogus information.  So, it cannot be changed so easily.
> > 
> > We need to sort out this in a better way...  Oh well.
> 
> 
> Please, please, put the above information as a comment to the respective 
> place. These "hacks" should be commented :)

I changed that code yesterday with a little bit more comment.

Wei, Peer, could you regenerate the patch based on the latest sound
git tree?

    git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git

or use the snapshot tarball from

    ftp://ftp.kernel.org/pub/linux/tiwai/snapshot/

This already contains the fix for the 4th slot probe on Nvidia
chipset.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [alsa-devel] [PATCH] add the nvidia HDMI codec driver for MCP77/79
  2008-09-04  7:04         ` Takashi Iwai
@ 2008-09-05  8:28           ` Wei Ni
  2008-09-17  9:00             ` Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79 peerchen
  0 siblings, 1 reply; 17+ messages in thread
From: Wei Ni @ 2008-09-05  8:28 UTC (permalink / raw)
  To: Takashi Iwai, Pavel Hofman; +Cc: Peer Chen, alsa-devel, linux-kernel, akpm

Thanks for your reply, I will generate the pach based on the latest
sound git tree.

Wei

-----Original Message-----
From: Takashi Iwai [mailto:tiwai@suse.de] 
Sent: Thursday, September 04, 2008 3:04 PM
To: Pavel Hofman
Cc: Wei Ni; Peer Chen; alsa-devel; linux-kernel; akpm
Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driver for
MCP77/79

At Wed, 03 Sep 2008 14:11:16 +0200,
Pavel Hofman wrote:
> 
> 
> >> ......
> >> According to these codes, It only can get the realtek codec and can
not
> >> get hdmi codec, if just change azx_max_codecs[AZX_DRIVER_NVIDIA] to
4
> >> I think if remove "if (!audio_codecs)", it will be better, and I
only
> >> need to chang azx_max_codecs[AZX_DRIVER_NVIDIA] to 4
> > 
> > Well, the check is there for a good reason.
> > 
> > There are many machines with broken BIOS reporting the 4th slot
> > available although it isn't actually.  It's a workaround to skip
such
> > a bogus information.  So, it cannot be changed so easily.
> > 
> > We need to sort out this in a better way...  Oh well.
> 
> 
> Please, please, put the above information as a comment to the
respective 
> place. These "hacks" should be commented :)

I changed that code yesterday with a little bit more comment.

Wei, Peer, could you regenerate the patch based on the latest sound
git tree?

    git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git

or use the snapshot tarball from

    ftp://ftp.kernel.org/pub/linux/tiwai/snapshot/

This already contains the fix for the 4th slot probe on Nvidia
chipset.


thanks,

Takashi
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79
  2008-09-05  8:28           ` Wei Ni
@ 2008-09-17  9:00             ` peerchen
  2008-09-17 14:04               ` Takashi Iwai
  0 siblings, 1 reply; 17+ messages in thread
From: peerchen @ 2008-09-17  9:00 UTC (permalink / raw)
  To: Wei Ni, Takashi Iwai, Pavel Hofman
  Cc: Peer Chen, alsa-devel, linux-kernel, akpm

new patch base on git tree.

Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Peer Chen <peerchen@gmail.com>
---
diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff linux-2.6-tiwai-sound/sound/pci/hda/hda_codec.c linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_codec.c
--- linux-2.6-tiwai-sound/sound/pci/hda/hda_codec.c	2008-09-10 17:40:52.000000000 +0800
+++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_codec.c	2008-09-10 17:51:36.000000000 +0800
@@ -94,6 +94,9 @@ static const struct hda_codec_preset *hd
 #ifdef CONFIG_SND_HDA_CODEC_VIA
 	snd_hda_preset_via,
 #endif
+#ifdef CONFIG_SND_HDA_CODEC_NVHDMI
+	snd_hda_preset_nvhdmi,
+#endif
 	NULL
 };
 
diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
--- linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c	2008-09-10 17:40:52.000000000 +0800
+++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c	2008-09-10 17:49:31.000000000 +0800
@@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(st
 	if (err < 0)
 		return err;
 
+	if (chip->driver_type == AZX_DRIVER_NVIDIA)
+		chip->bus->needs_damn_long_delay = 1;
+
 	codecs = audio_codecs = 0;
 	max_slots = azx_max_codecs[chip->driver_type];
 	if (!max_slots)
diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff linux-2.6-tiwai-sound/sound/pci/hda/hda_patch.h linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_patch.h
--- linux-2.6-tiwai-sound/sound/pci/hda/hda_patch.h	2008-09-10 17:40:52.000000000 +0800
+++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_patch.h	2008-09-10 17:50:41.000000000 +0800
@@ -18,3 +18,5 @@ extern struct hda_codec_preset snd_hda_p
 extern struct hda_codec_preset snd_hda_preset_conexant[];
 /* VIA codecs */
 extern struct hda_codec_preset snd_hda_preset_via[];
+/* NVIDIA HDMI codecs */
+extern struct hda_codec_preset snd_hda_preset_nvhdmi[];
diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff linux-2.6-tiwai-sound/sound/pci/hda/Makefile linux-2.6-tiwai-sound-niwei/sound/pci/hda/Makefile
--- linux-2.6-tiwai-sound/sound/pci/hda/Makefile	2008-09-10 17:40:52.000000000 +0800
+++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/Makefile	2008-09-10 17:52:06.000000000 +0800
@@ -15,5 +15,6 @@ snd-hda-intel-$(CONFIG_SND_HDA_CODEC_SI3
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_ATIHDMI) += patch_atihdmi.o
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_CONEXANT) += patch_conexant.o
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_VIA) += patch_via.o
+snd-hda-intel-$(CONFIG_SND_HDA_CODEC_NVHDMI) += patch_nvhdmi.o
 
 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff linux-2.6-tiwai-sound/sound/pci/hda/patch_nvhdmi.c linux-2.6-tiwai-sound-niwei/sound/pci/hda/patch_nvhdmi.c
--- linux-2.6-tiwai-sound/sound/pci/hda/patch_nvhdmi.c	1970-01-01 08:00:00.000000000 +0800
+++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/patch_nvhdmi.c	2008-09-10 18:03:15.000000000 +0800
@@ -0,0 +1,164 @@
+/*
+ * Universal Interface for Intel High Definition Audio Codec
+ *
+ * HD audio interface patch for Nvidia HDMI codecs
+ *
+ * Copyright (c) 2008 Nvidia Corp.  All rights reserved.
+ * Copyright 2008 Wei Ni <wni@nvidia.com>
+ *
+ *
+ *  This driver is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This driver is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+#include "hda_codec.h"
+#include "hda_local.h"
+
+struct nvhdmi_spec {
+	struct hda_multi_out multiout;
+
+	struct hda_pcm pcm_rec;
+};
+
+static struct hda_verb nvhdmi_basic_init[] = {
+	/* enable digital output on pin widget */
+	{ 0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+	{} /* terminator */
+};
+
+/*
+ * Controls
+ */
+static int nvhdmi_build_controls(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	int err;
+
+	err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int nvhdmi_init(struct hda_codec *codec)
+{
+	snd_hda_sequence_write(codec, nvhdmi_basic_init);
+	return 0;
+}
+
+/*
+ * Digital out
+ */
+static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
+				     struct hda_codec *codec,
+				     struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_open(codec, &spec->multiout);
+}
+
+static int nvhdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
+				      struct hda_codec *codec,
+				      struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_close(codec, &spec->multiout);
+}
+
+static int nvhdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
+					    struct hda_codec *codec,
+					    unsigned int stream_tag,
+					    unsigned int format,
+					    struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
+					     format, substream);
+}
+
+static struct hda_pcm_stream nvhdmi_pcm_digital_playback = {
+	.substreams = 1,
+	.channels_min = 2,
+	.channels_max = 2,
+	.nid = 0x4, /* NID to query formats and rates and setup streams */
+        .rates = SNDRV_PCM_RATE_48000,
+        .maxbps = 16,
+        .formats = SNDRV_PCM_FMTBIT_S16_LE,
+	.ops = {
+		.open = nvhdmi_dig_playback_pcm_open,
+		.close = nvhdmi_dig_playback_pcm_close,
+		.prepare = nvhdmi_dig_playback_pcm_prepare
+	},
+};
+
+static int nvhdmi_build_pcms(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	struct hda_pcm *info = &spec->pcm_rec;
+
+	codec->num_pcms = 1;
+	codec->pcm_info = info;
+
+	info->name = "NVIDIA HDMI";
+	info->stream[SNDRV_PCM_STREAM_PLAYBACK] = nvhdmi_pcm_digital_playback;
+
+	return 0;
+}
+
+static void nvhdmi_free(struct hda_codec *codec)
+{
+	kfree(codec->spec);
+}
+
+static struct hda_codec_ops nvhdmi_patch_ops = {
+	.build_controls = nvhdmi_build_controls,
+	.build_pcms = nvhdmi_build_pcms,
+	.init = nvhdmi_init,
+	.free = nvhdmi_free,
+};
+
+static int patch_nvhdmi(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec;
+
+	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
+	if (spec == NULL)
+		return -ENOMEM;
+
+	codec->spec = spec;
+
+	spec->multiout.num_dacs = 0;	  /* no analog */
+	spec->multiout.max_channels = 2;
+	spec->multiout.dig_out_nid = 0x4; /* NID for copying analog to digital,
+					   * seems to be unused in pure-digital
+					   * case. */
+
+	codec->patch_ops = nvhdmi_patch_ops;
+
+	return 0;
+}
+
+/*
+ * patch entries
+ */
+struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
+	{ .id = 0x10de0002, .name = "Nvidia MCP77/78 HDMI", .patch = patch_nvhdmi },
+	{ .id = 0x10de0007, .name = "Nvidia MCP79/7A HDMI", .patch = patch_nvhdmi },
+	{} /* terminator */
+};
diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff linux-2.6-tiwai-sound/sound/pci/Kconfig linux-2.6-tiwai-sound-niwei/sound/pci/Kconfig
--- linux-2.6-tiwai-sound/sound/pci/Kconfig	2008-09-10 17:40:51.000000000 +0800
+++ linux-2.6-tiwai-sound-niwei/sound/pci/Kconfig	2008-09-10 17:53:38.000000000 +0800
@@ -565,6 +565,14 @@ config SND_HDA_CODEC_ATIHDMI
 	  Say Y here to include ATI HDMI HD-audio codec support in
 	  snd-hda-intel driver, such as ATI RS600 HDMI.
 
+config SND_HDA_CODEC_NVHDMI
+	bool "Build NVIDIA HDMI HD-audio codec support"
+	depends on SND_HDA_INTEL
+	default y
+	help
+	  Say Y here to include NVIDIA HDMI HD-audio codec support in
+	  snd-hda-intel driver, such as NVIDIA MCP77/78 HDMI.
+
 config SND_HDA_CODEC_CONEXANT
 	bool "Build Conexant HD-audio codec support"
 	depends on SND_HDA_INTEL
-


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79
  2008-09-17  9:00             ` Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79 peerchen
@ 2008-09-17 14:04               ` Takashi Iwai
  2008-09-19  4:42                 ` Wei Ni
  2008-09-22  6:33                 ` Wei Ni
  0 siblings, 2 replies; 17+ messages in thread
From: Takashi Iwai @ 2008-09-17 14:04 UTC (permalink / raw)
  To: peerchen; +Cc: Wei Ni, Pavel Hofman, Peer Chen, alsa-devel, linux-kernel, akpm

At Wed, 17 Sep 2008 17:00:04 +0800,
peerchen wrote:
> 
> new patch base on git tree.
> 
> Signed-off-by: Wei Ni <wni@nvidia.com>
> Signed-off-by: Peer Chen <peerchen@gmail.com>

Thanks!

But, the patch looks like no "rebase".  You secretly added a new
function call that wasn't in your previous patch, namely...

> diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> --- linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c	2008-09-10 17:40:52.000000000 +0800
> +++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c	2008-09-10 17:49:31.000000000 +0800
> @@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(st
>  	if (err < 0)
>  		return err;
>  
> +	if (chip->driver_type == AZX_DRIVER_NVIDIA)
> +		chip->bus->needs_damn_long_delay = 1;
> +

Do we really need this inevitably?  I don't think so -- otherwise I
would have far more bug reports.

This flag is the last resort and should be avoided as much as
possible.  This results in a significant slow down of suspend/resume
speed, for example.

If it's really needed with some devices and there is no other way to
fix it, add this flag rather in the codec-initialization part.

Also, if you resend a patch, please add the original patch description 
again.  This helps my patch work a lot indeed.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79
  2008-09-17 14:04               ` Takashi Iwai
@ 2008-09-19  4:42                 ` Wei Ni
  2008-09-22  6:33                 ` Wei Ni
  1 sibling, 0 replies; 17+ messages in thread
From: Wei Ni @ 2008-09-19  4:42 UTC (permalink / raw)
  To: Takashi Iwai, peerchen
  Cc: Pavel Hofman, Peer Chen, alsa-devel, linux-kernel, akpm

Thanks for your reply.

About the "long delay", we had some problems on reading RIRB buffer when
testing this driver, so we add this "delay"
We will try to find a best way to fix this issue.

And we didn't familiar with git, we will research it more such as
"rebase" and then submit the patch file again.

Thanks

-----Original Message-----
From: Takashi Iwai [mailto:tiwai@suse.de] 
Sent: Wednesday, September 17, 2008 10:05 PM
To: peerchen
Cc: Wei Ni; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
MCP77/79

At Wed, 17 Sep 2008 17:00:04 +0800,
peerchen wrote:
> 
> new patch base on git tree.
> 
> Signed-off-by: Wei Ni <wni@nvidia.com>
> Signed-off-by: Peer Chen <peerchen@gmail.com>

Thanks!

But, the patch looks like no "rebase".  You secretly added a new
function call that wasn't in your previous patch, namely...

> diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff
linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c
linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> --- linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c	2008-09-10
17:40:52.000000000 +0800
> +++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
2008-09-10 17:49:31.000000000 +0800
> @@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(st
>  	if (err < 0)
>  		return err;
>  
> +	if (chip->driver_type == AZX_DRIVER_NVIDIA)
> +		chip->bus->needs_damn_long_delay = 1;
> +

Do we really need this inevitably?  I don't think so -- otherwise I
would have far more bug reports.

This flag is the last resort and should be avoided as much as
possible.  This results in a significant slow down of suspend/resume
speed, for example.

If it's really needed with some devices and there is no other way to
fix it, add this flag rather in the codec-initialization part.

Also, if you resend a patch, please add the original patch description 
again.  This helps my patch work a lot indeed.


thanks,

Takashi
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79
  2008-09-17 14:04               ` Takashi Iwai
  2008-09-19  4:42                 ` Wei Ni
@ 2008-09-22  6:33                 ` Wei Ni
  2008-09-22  9:58                   ` Takashi Iwai
  1 sibling, 1 reply; 17+ messages in thread
From: Wei Ni @ 2008-09-22  6:33 UTC (permalink / raw)
  To: Takashi Iwai, peerchen
  Cc: Pavel Hofman, Peer Chen, alsa-devel, linux-kernel, akpm

Hi, Takashi

About the "long delay", it seemed that we need to add this "delay" to
fix some issue on our aza controller.
Because it related with the controller, not just codec, so I think this
flag should not be added in codec-initialization part.
I think it's better to add the flag in that place which I submitted.

Thanks

-----Original Message-----
From: Wei Ni 
Sent: Friday, September 19, 2008 12:43 PM
To: 'Takashi Iwai'; peerchen
Cc: Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
Subject: RE: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
MCP77/79

Thanks for your reply.

About the "long delay", we had some problems on reading RIRB buffer when
testing this driver, so we add this "delay"
We will try to find a best way to fix this issue.

And we didn't familiar with git, we will research it more such as
"rebase" and then submit the patch file again.

Thanks

-----Original Message-----
From: Takashi Iwai [mailto:tiwai@suse.de] 
Sent: Wednesday, September 17, 2008 10:05 PM
To: peerchen
Cc: Wei Ni; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
MCP77/79

At Wed, 17 Sep 2008 17:00:04 +0800,
peerchen wrote:
> 
> new patch base on git tree.
> 
> Signed-off-by: Wei Ni <wni@nvidia.com>
> Signed-off-by: Peer Chen <peerchen@gmail.com>

Thanks!

But, the patch looks like no "rebase".  You secretly added a new
function call that wasn't in your previous patch, namely...

> diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff
linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c
linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> --- linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c	2008-09-10
17:40:52.000000000 +0800
> +++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
2008-09-10 17:49:31.000000000 +0800
> @@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(st
>  	if (err < 0)
>  		return err;
>  
> +	if (chip->driver_type == AZX_DRIVER_NVIDIA)
> +		chip->bus->needs_damn_long_delay = 1;
> +

Do we really need this inevitably?  I don't think so -- otherwise I
would have far more bug reports.

This flag is the last resort and should be avoided as much as
possible.  This results in a significant slow down of suspend/resume
speed, for example.

If it's really needed with some devices and there is no other way to
fix it, add this flag rather in the codec-initialization part.

Also, if you resend a patch, please add the original patch description 
again.  This helps my patch work a lot indeed.


thanks,

Takashi
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79
  2008-09-22  6:33                 ` Wei Ni
@ 2008-09-22  9:58                   ` Takashi Iwai
  2008-09-25  7:14                     ` Wei Ni
  0 siblings, 1 reply; 17+ messages in thread
From: Takashi Iwai @ 2008-09-22  9:58 UTC (permalink / raw)
  To: Wei Ni; +Cc: peerchen, Pavel Hofman, Peer Chen, alsa-devel, linux-kernel, akpm

At Mon, 22 Sep 2008 14:33:58 +0800,
Wei Ni wrote:
> 
> Hi, Takashi
> 
> About the "long delay", it seemed that we need to add this "delay" to
> fix some issue on our aza controller.
> Because it related with the controller, not just codec, so I think this
> flag should not be added in codec-initialization part.
> I think it's better to add the flag in that place which I submitted.

OK, then could you split the patch to separate ones, i.e. one for the
fix for this problem regarding Nvidia controller chip, and one for the
addition of HDMI?

Don't forget to add a proper description for each patch, please ;)

As mentioned, that flag is a last resort, and I think it can be fixed
in a saner way.  But, the flag is surely safe, and we can track down
the problem later on.


thanks,

Takashi


> 
> Thanks
> 
> -----Original Message-----
> From: Wei Ni 
> Sent: Friday, September 19, 2008 12:43 PM
> To: 'Takashi Iwai'; peerchen
> Cc: Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> Subject: RE: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
> MCP77/79
> 
> Thanks for your reply.
> 
> About the "long delay", we had some problems on reading RIRB buffer when
> testing this driver, so we add this "delay"
> We will try to find a best way to fix this issue.
> 
> And we didn't familiar with git, we will research it more such as
> "rebase" and then submit the patch file again.
> 
> Thanks
> 
> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de] 
> Sent: Wednesday, September 17, 2008 10:05 PM
> To: peerchen
> Cc: Wei Ni; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
> MCP77/79
> 
> At Wed, 17 Sep 2008 17:00:04 +0800,
> peerchen wrote:
> > 
> > new patch base on git tree.
> > 
> > Signed-off-by: Wei Ni <wni@nvidia.com>
> > Signed-off-by: Peer Chen <peerchen@gmail.com>
> 
> Thanks!
> 
> But, the patch looks like no "rebase".  You secretly added a new
> function call that wasn't in your previous patch, namely...
> 
> > diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff
> linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c
> linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> > --- linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c	2008-09-10
> 17:40:52.000000000 +0800
> > +++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> 2008-09-10 17:49:31.000000000 +0800
> > @@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(st
> >  	if (err < 0)
> >  		return err;
> >  
> > +	if (chip->driver_type == AZX_DRIVER_NVIDIA)
> > +		chip->bus->needs_damn_long_delay = 1;
> > +
> 
> Do we really need this inevitably?  I don't think so -- otherwise I
> would have far more bug reports.
> 
> This flag is the last resort and should be avoided as much as
> possible.  This results in a significant slow down of suspend/resume
> speed, for example.
> 
> If it's really needed with some devices and there is no other way to
> fix it, add this flag rather in the codec-initialization part.
> 
> Also, if you resend a patch, please add the original patch description 
> again.  This helps my patch work a lot indeed.
> 
> 
> thanks,
> 
> Takashi
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s) and may contain
> confidential information.  Any unauthorized review, use, disclosure or distribution
> is prohibited.  If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79
  2008-09-22  9:58                   ` Takashi Iwai
@ 2008-09-25  7:14                     ` Wei Ni
  2008-09-25  9:55                       ` Takashi Iwai
  0 siblings, 1 reply; 17+ messages in thread
From: Wei Ni @ 2008-09-25  7:14 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: peerchen, Pavel Hofman, Peer Chen, alsa-devel, linux-kernel, akpm

[-- Attachment #1: Type: text/plain, Size: 4334 bytes --]

Hi, Takashi
I use git to generate patches. (I run git-fetch origin, git-fetch-rebase
origin, and git-format-patch origin)

There are two patch, one for the addition of HDMI, and one for the fix
for our aza controller.

Please check it.

Thanks

-----Original Message-----
From: Takashi Iwai [mailto:tiwai@suse.de] 
Sent: Monday, September 22, 2008 5:58 PM
To: Wei Ni
Cc: peerchen; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
MCP77/79

At Mon, 22 Sep 2008 14:33:58 +0800,
Wei Ni wrote:
> 
> Hi, Takashi
> 
> About the "long delay", it seemed that we need to add this "delay" to
> fix some issue on our aza controller.
> Because it related with the controller, not just codec, so I think
this
> flag should not be added in codec-initialization part.
> I think it's better to add the flag in that place which I submitted.

OK, then could you split the patch to separate ones, i.e. one for the
fix for this problem regarding Nvidia controller chip, and one for the
addition of HDMI?

Don't forget to add a proper description for each patch, please ;)

As mentioned, that flag is a last resort, and I think it can be fixed
in a saner way.  But, the flag is surely safe, and we can track down
the problem later on.


thanks,

Takashi


> 
> Thanks
> 
> -----Original Message-----
> From: Wei Ni 
> Sent: Friday, September 19, 2008 12:43 PM
> To: 'Takashi Iwai'; peerchen
> Cc: Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> Subject: RE: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
> MCP77/79
> 
> Thanks for your reply.
> 
> About the "long delay", we had some problems on reading RIRB buffer
when
> testing this driver, so we add this "delay"
> We will try to find a best way to fix this issue.
> 
> And we didn't familiar with git, we will research it more such as
> "rebase" and then submit the patch file again.
> 
> Thanks
> 
> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de] 
> Sent: Wednesday, September 17, 2008 10:05 PM
> To: peerchen
> Cc: Wei Ni; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
> MCP77/79
> 
> At Wed, 17 Sep 2008 17:00:04 +0800,
> peerchen wrote:
> > 
> > new patch base on git tree.
> > 
> > Signed-off-by: Wei Ni <wni@nvidia.com>
> > Signed-off-by: Peer Chen <peerchen@gmail.com>
> 
> Thanks!
> 
> But, the patch looks like no "rebase".  You secretly added a new
> function call that wasn't in your previous patch, namely...
> 
> > diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff
> linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c
> linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> > --- linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c	2008-09-10
> 17:40:52.000000000 +0800
> > +++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> 2008-09-10 17:49:31.000000000 +0800
> > @@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(st
> >  	if (err < 0)
> >  		return err;
> >  
> > +	if (chip->driver_type == AZX_DRIVER_NVIDIA)
> > +		chip->bus->needs_damn_long_delay = 1;
> > +
> 
> Do we really need this inevitably?  I don't think so -- otherwise I
> would have far more bug reports.
> 
> This flag is the last resort and should be avoided as much as
> possible.  This results in a significant slow down of suspend/resume
> speed, for example.
> 
> If it's really needed with some devices and there is no other way to
> fix it, add this flag rather in the codec-initialization part.
> 
> Also, if you resend a patch, please add the original patch description

> again.  This helps my patch work a lot indeed.
> 
> 
> thanks,
> 
> Takashi
>
------------------------------------------------------------------------
-----------
> This email message is for the sole use of the intended recipient(s)
and may contain
> confidential information.  Any unauthorized review, use, disclosure or
distribution
> is prohibited.  If you are not the intended recipient, please contact
the sender by
> reply email and destroy all copies of the original message.
>
------------------------------------------------------------------------
-----------
> 

[-- Attachment #2: 0001-Support-NVIDIA-MCP78-HDMI-audio.patch --]
[-- Type: application/octet-stream, Size: 7215 bytes --]

From df8aab53c51f4b285dfc22f6ee1f982f6e81a377 Mon Sep 17 00:00:00 2001
From: root <root@niwei.linux1>
Date: Thu, 25 Sep 2008 14:49:54 +0800
Subject: [PATCH] Support NVIDIA MCP78 HDMI audio

---
 sound/pci/Kconfig            |    8 ++
 sound/pci/hda/Makefile       |    1 +
 sound/pci/hda/hda_codec.c    |    3 +
 sound/pci/hda/hda_patch.h    |    2 +
 sound/pci/hda/patch_nvhdmi.c |  164 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 178 insertions(+), 0 deletions(-)
 create mode 100644 sound/pci/hda/patch_nvhdmi.c

diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 1f8b796..7003711 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -565,6 +565,14 @@ config SND_HDA_CODEC_ATIHDMI
 	  Say Y here to include ATI HDMI HD-audio codec support in
 	  snd-hda-intel driver, such as ATI RS600 HDMI.
 
+config SND_HDA_CODEC_NVHDMI
+	bool "Build NVIDIA HDMI HD-audio codec support"
+	depends on SND_HDA_INTEL
+	default y
+	help
+	  Say Y here to include NVIDIA HDMI HD-audio codec support in
+	  snd-hda-intel driver, such as NVIDIA MCP78 HDMI.
+
 config SND_HDA_CODEC_CONEXANT
 	bool "Build Conexant HD-audio codec support"
 	depends on SND_HDA_INTEL
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 6db92fd..1980c6d 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -15,5 +15,6 @@ snd-hda-intel-$(CONFIG_SND_HDA_CODEC_SI3054) += patch_si3054.o
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_ATIHDMI) += patch_atihdmi.o
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_CONEXANT) += patch_conexant.o
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_VIA) += patch_via.o
+snd-hda-intel-$(CONFIG_SND_HDA_CODEC_NVHDMI) += patch_nvhdmi.o
 
 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index c742e10..0da3a64 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -94,6 +94,9 @@ static const struct hda_codec_preset *hda_preset_tables[] = {
 #ifdef CONFIG_SND_HDA_CODEC_VIA
 	snd_hda_preset_via,
 #endif
+#ifdef CONFIG_SND_HDA_CODEC_NVHDMI
+	snd_hda_preset_nvhdmi,
+#endif
 	NULL
 };
 
diff --git a/sound/pci/hda/hda_patch.h b/sound/pci/hda/hda_patch.h
index 2fdf235..dfbcfa8 100644
--- a/sound/pci/hda/hda_patch.h
+++ b/sound/pci/hda/hda_patch.h
@@ -18,3 +18,5 @@ extern struct hda_codec_preset snd_hda_preset_atihdmi[];
 extern struct hda_codec_preset snd_hda_preset_conexant[];
 /* VIA codecs */
 extern struct hda_codec_preset snd_hda_preset_via[];
+/* NVIDIA HDMI codecs */
+extern struct hda_codec_preset snd_hda_preset_nvhdmi[];
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c
new file mode 100644
index 0000000..d0fdd5d
--- /dev/null
+++ b/sound/pci/hda/patch_nvhdmi.c
@@ -0,0 +1,164 @@
+/*
+ * Universal Interface for Intel High Definition Audio Codec
+ *
+ * HD audio interface patch for NVIDIA HDMI codecs
+ *
+ * Copyright (c) 2008 NVIDIA Corp.  All rights reserved.
+ * Copyright (c) 2008 Wei Ni <wni@nvidia.com>
+ *
+ *
+ *  This driver is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This driver is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+#include "hda_codec.h"
+#include "hda_local.h"
+
+struct nvhdmi_spec {
+	struct hda_multi_out multiout;
+
+	struct hda_pcm pcm_rec;
+};
+
+static struct hda_verb nvhdmi_basic_init[] = {
+	/* enable digital output on pin widget */
+	{ 0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+	{} /* terminator */
+};
+
+/*
+ * Controls
+ */
+static int nvhdmi_build_controls(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	int err;
+
+	err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int nvhdmi_init(struct hda_codec *codec)
+{
+	snd_hda_sequence_write(codec, nvhdmi_basic_init);
+	return 0;
+}
+
+/*
+ * Digital out
+ */
+static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
+				     struct hda_codec *codec,
+				     struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_open(codec, &spec->multiout);
+}
+
+static int nvhdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
+				      struct hda_codec *codec,
+				      struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_close(codec, &spec->multiout);
+}
+
+static int nvhdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
+					    struct hda_codec *codec,
+					    unsigned int stream_tag,
+					    unsigned int format,
+					    struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
+					     format, substream);
+}
+
+static struct hda_pcm_stream nvhdmi_pcm_digital_playback = {
+	.substreams = 1,
+	.channels_min = 2,
+	.channels_max = 2,
+	.nid = 0x4, /* NID to query formats and rates and setup streams */
+        .rates = SNDRV_PCM_RATE_48000,
+        .maxbps = 16,
+        .formats = SNDRV_PCM_FMTBIT_S16_LE,
+	.ops = {
+		.open = nvhdmi_dig_playback_pcm_open,
+		.close = nvhdmi_dig_playback_pcm_close,
+		.prepare = nvhdmi_dig_playback_pcm_prepare
+	},
+};
+
+static int nvhdmi_build_pcms(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	struct hda_pcm *info = &spec->pcm_rec;
+
+	codec->num_pcms = 1;
+	codec->pcm_info = info;
+
+	info->name = "NVIDIA HDMI";
+	info->stream[SNDRV_PCM_STREAM_PLAYBACK] = nvhdmi_pcm_digital_playback;
+
+	return 0;
+}
+
+static void nvhdmi_free(struct hda_codec *codec)
+{
+	kfree(codec->spec);
+}
+
+static struct hda_codec_ops nvhdmi_patch_ops = {
+	.build_controls = nvhdmi_build_controls,
+	.build_pcms = nvhdmi_build_pcms,
+	.init = nvhdmi_init,
+	.free = nvhdmi_free,
+};
+
+static int patch_nvhdmi(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec;
+
+	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
+	if (spec == NULL)
+		return -ENOMEM;
+
+	codec->spec = spec;
+
+	spec->multiout.num_dacs = 0;	  /* no analog */
+	spec->multiout.max_channels = 2;
+	spec->multiout.dig_out_nid = 0x4; /* NID for copying analog to digital,
+					   * seems to be unused in pure-digital
+					   * case. */
+
+	codec->patch_ops = nvhdmi_patch_ops;
+
+	return 0;
+}
+
+/*
+ * patch entries
+ */
+struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
+	{ .id = 0x10de0002, .name = "NVIDIA MCP78 HDMI", .patch = patch_nvhdmi },
+	{ .id = 0x10de0007, .name = "NVIDIA MCP7A HDMI", .patch = patch_nvhdmi },
+	{} /* terminator */
+};
-- 
1.5.6


[-- Attachment #3: 0002-Fix-for-reading-RIRB-buffer-on-NVIDIA-aza-controller.patch --]
[-- Type: application/octet-stream, Size: 790 bytes --]

From 2b9a1e62b9ce599703d7dd73a0df5d82e9482a31 Mon Sep 17 00:00:00 2001
From: root <root@niwei.linux1>
Date: Thu, 25 Sep 2008 14:56:28 +0800
Subject: [PATCH] Fix for reading RIRB buffer on NVIDIA aza controller

---
 sound/pci/hda/hda_intel.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 60cc44a..9f316c1 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
 	if (err < 0)
 		return err;
 
+	if (chip->driver_type == AZX_DRIVER_NVIDIA)
+		chip->bus->needs_damn_long_delay = 1;
+
 	codecs = audio_codecs = 0;
 	max_slots = azx_max_codecs[chip->driver_type];
 	if (!max_slots)
-- 
1.5.6


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79
  2008-09-25  7:14                     ` Wei Ni
@ 2008-09-25  9:55                       ` Takashi Iwai
  2008-09-25 11:29                         ` Wei Ni
  2008-09-26  6:19                         ` Wei Ni
  0 siblings, 2 replies; 17+ messages in thread
From: Takashi Iwai @ 2008-09-25  9:55 UTC (permalink / raw)
  To: Wei Ni; +Cc: peerchen, Pavel Hofman, Peer Chen, alsa-devel, linux-kernel, akpm

At Thu, 25 Sep 2008 15:14:50 +0800,
Wei Ni wrote:
> 
> Hi, Takashi
> I use git to generate patches. (I run git-fetch origin, git-fetch-rebase
> origin, and git-format-patch origin)
> 
> There are two patch, one for the addition of HDMI, and one for the fix
> for our aza controller.
> 
> Please check it.

Thanks for patches.  It's good that you are using git now.
The code changes look good, but there are small issues in the patches:

- The author line is bogus.  Edit your ~/.gitconfig and add like the
  following:
	[user]
	  name = Wei Ni
	  email = wni@nvidia.com
  Then reset and commit patches again.

- Missing sign-off.  Add --sign option when you do git-commit.

- No proper change log.  Only a subject line isn't enough for many
  (most) cases, especially for a patch like workaround for nvidia
  controller.
  Please describe why this change is needed more precisely.

Could you fix and repost again?


Thanks!

Takashi


> 
> Thanks
> 
> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de] 
> Sent: Monday, September 22, 2008 5:58 PM
> To: Wei Ni
> Cc: peerchen; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
> MCP77/79
> 
> At Mon, 22 Sep 2008 14:33:58 +0800,
> Wei Ni wrote:
> > 
> > Hi, Takashi
> > 
> > About the "long delay", it seemed that we need to add this "delay" to
> > fix some issue on our aza controller.
> > Because it related with the controller, not just codec, so I think
> this
> > flag should not be added in codec-initialization part.
> > I think it's better to add the flag in that place which I submitted.
> 
> OK, then could you split the patch to separate ones, i.e. one for the
> fix for this problem regarding Nvidia controller chip, and one for the
> addition of HDMI?
> 
> Don't forget to add a proper description for each patch, please ;)
> 
> As mentioned, that flag is a last resort, and I think it can be fixed
> in a saner way.  But, the flag is surely safe, and we can track down
> the problem later on.
> 
> 
> thanks,
> 
> Takashi
> 
> 
> > 
> > Thanks
> > 
> > -----Original Message-----
> > From: Wei Ni 
> > Sent: Friday, September 19, 2008 12:43 PM
> > To: 'Takashi Iwai'; peerchen
> > Cc: Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> > Subject: RE: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
> > MCP77/79
> > 
> > Thanks for your reply.
> > 
> > About the "long delay", we had some problems on reading RIRB buffer
> when
> > testing this driver, so we add this "delay"
> > We will try to find a best way to fix this issue.
> > 
> > And we didn't familiar with git, we will research it more such as
> > "rebase" and then submit the patch file again.
> > 
> > Thanks
> > 
> > -----Original Message-----
> > From: Takashi Iwai [mailto:tiwai@suse.de] 
> > Sent: Wednesday, September 17, 2008 10:05 PM
> > To: peerchen
> > Cc: Wei Ni; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> > Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
> > MCP77/79
> > 
> > At Wed, 17 Sep 2008 17:00:04 +0800,
> > peerchen wrote:
> > > 
> > > new patch base on git tree.
> > > 
> > > Signed-off-by: Wei Ni <wni@nvidia.com>
> > > Signed-off-by: Peer Chen <peerchen@gmail.com>
> > 
> > Thanks!
> > 
> > But, the patch looks like no "rebase".  You secretly added a new
> > function call that wasn't in your previous patch, namely...
> > 
> > > diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff
> > linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c
> > linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> > > --- linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c	2008-09-10
> > 17:40:52.000000000 +0800
> > > +++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> > 2008-09-10 17:49:31.000000000 +0800
> > > @@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(st
> > >  	if (err < 0)
> > >  		return err;
> > >  
> > > +	if (chip->driver_type == AZX_DRIVER_NVIDIA)
> > > +		chip->bus->needs_damn_long_delay = 1;
> > > +
> > 
> > Do we really need this inevitably?  I don't think so -- otherwise I
> > would have far more bug reports.
> > 
> > This flag is the last resort and should be avoided as much as
> > possible.  This results in a significant slow down of suspend/resume
> > speed, for example.
> > 
> > If it's really needed with some devices and there is no other way to
> > fix it, add this flag rather in the codec-initialization part.
> > 
> > Also, if you resend a patch, please add the original patch description
> 
> > again.  This helps my patch work a lot indeed.
> > 
> > 
> > thanks,
> > 
> > Takashi
> >
> ------------------------------------------------------------------------
> -----------
> > This email message is for the sole use of the intended recipient(s)
> and may contain
> > confidential information.  Any unauthorized review, use, disclosure or
> distribution
> > is prohibited.  If you are not the intended recipient, please contact
> the sender by
> > reply email and destroy all copies of the original message.
> >
> ------------------------------------------------------------------------
> -----------
> > 
> [2 0001-Support-NVIDIA-MCP78-HDMI-audio.patch <application/octet-stream (base64)>]
> 
> [3 0002-Fix-for-reading-RIRB-buffer-on-NVIDIA-aza-controller.patch <application/octet-stream (base64)>]
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79
  2008-09-25  9:55                       ` Takashi Iwai
@ 2008-09-25 11:29                         ` Wei Ni
  2008-09-26  6:19                         ` Wei Ni
  1 sibling, 0 replies; 17+ messages in thread
From: Wei Ni @ 2008-09-25 11:29 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: peerchen, Pavel Hofman, Peer Chen, alsa-devel, linux-kernel, akpm


 Thanks for your comments, I will fix and repost again.

-----Original Message-----
From: Takashi Iwai [mailto:tiwai@suse.de] 
Sent: Thursday, September 25, 2008 5:55 PM
To: Wei Ni
Cc: peerchen; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
MCP77/79

At Thu, 25 Sep 2008 15:14:50 +0800,
Wei Ni wrote:
> 
> Hi, Takashi
> I use git to generate patches. (I run git-fetch origin,
git-fetch-rebase
> origin, and git-format-patch origin)
> 
> There are two patch, one for the addition of HDMI, and one for the fix
> for our aza controller.
> 
> Please check it.

Thanks for patches.  It's good that you are using git now.
The code changes look good, but there are small issues in the patches:

- The author line is bogus.  Edit your ~/.gitconfig and add like the
  following:
	[user]
	  name = Wei Ni
	  email = wni@nvidia.com
  Then reset and commit patches again.

- Missing sign-off.  Add --sign option when you do git-commit.

- No proper change log.  Only a subject line isn't enough for many
  (most) cases, especially for a patch like workaround for nvidia
  controller.
  Please describe why this change is needed more precisely.

Could you fix and repost again?


Thanks!

Takashi


> 
> Thanks
> 
> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de] 
> Sent: Monday, September 22, 2008 5:58 PM
> To: Wei Ni
> Cc: peerchen; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
> MCP77/79
> 
> At Mon, 22 Sep 2008 14:33:58 +0800,
> Wei Ni wrote:
> > 
> > Hi, Takashi
> > 
> > About the "long delay", it seemed that we need to add this "delay"
to
> > fix some issue on our aza controller.
> > Because it related with the controller, not just codec, so I think
> this
> > flag should not be added in codec-initialization part.
> > I think it's better to add the flag in that place which I submitted.
> 
> OK, then could you split the patch to separate ones, i.e. one for the
> fix for this problem regarding Nvidia controller chip, and one for the
> addition of HDMI?
> 
> Don't forget to add a proper description for each patch, please ;)
> 
> As mentioned, that flag is a last resort, and I think it can be fixed
> in a saner way.  But, the flag is surely safe, and we can track down
> the problem later on.
> 
> 
> thanks,
> 
> Takashi
> 
> 
> > 
> > Thanks
> > 
> > -----Original Message-----
> > From: Wei Ni 
> > Sent: Friday, September 19, 2008 12:43 PM
> > To: 'Takashi Iwai'; peerchen
> > Cc: Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> > Subject: RE: [alsa-devel] [PATCH] add the nvidia HDMI codec
driverfor
> > MCP77/79
> > 
> > Thanks for your reply.
> > 
> > About the "long delay", we had some problems on reading RIRB buffer
> when
> > testing this driver, so we add this "delay"
> > We will try to find a best way to fix this issue.
> > 
> > And we didn't familiar with git, we will research it more such as
> > "rebase" and then submit the patch file again.
> > 
> > Thanks
> > 
> > -----Original Message-----
> > From: Takashi Iwai [mailto:tiwai@suse.de] 
> > Sent: Wednesday, September 17, 2008 10:05 PM
> > To: peerchen
> > Cc: Wei Ni; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> > Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec
driverfor
> > MCP77/79
> > 
> > At Wed, 17 Sep 2008 17:00:04 +0800,
> > peerchen wrote:
> > > 
> > > new patch base on git tree.
> > > 
> > > Signed-off-by: Wei Ni <wni@nvidia.com>
> > > Signed-off-by: Peer Chen <peerchen@gmail.com>
> > 
> > Thanks!
> > 
> > But, the patch looks like no "rebase".  You secretly added a new
> > function call that wasn't in your previous patch, namely...
> > 
> > > diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff
> > linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c
> > linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> > > --- linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c
2008-09-10
> > 17:40:52.000000000 +0800
> > > +++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> > 2008-09-10 17:49:31.000000000 +0800
> > > @@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(st
> > >  	if (err < 0)
> > >  		return err;
> > >  
> > > +	if (chip->driver_type == AZX_DRIVER_NVIDIA)
> > > +		chip->bus->needs_damn_long_delay = 1;
> > > +
> > 
> > Do we really need this inevitably?  I don't think so -- otherwise I
> > would have far more bug reports.
> > 
> > This flag is the last resort and should be avoided as much as
> > possible.  This results in a significant slow down of suspend/resume
> > speed, for example.
> > 
> > If it's really needed with some devices and there is no other way to
> > fix it, add this flag rather in the codec-initialization part.
> > 
> > Also, if you resend a patch, please add the original patch
description
> 
> > again.  This helps my patch work a lot indeed.
> > 
> > 
> > thanks,
> > 
> > Takashi
> >
>
------------------------------------------------------------------------
> -----------
> > This email message is for the sole use of the intended recipient(s)
> and may contain
> > confidential information.  Any unauthorized review, use, disclosure
or
> distribution
> > is prohibited.  If you are not the intended recipient, please
contact
> the sender by
> > reply email and destroy all copies of the original message.
> >
>
------------------------------------------------------------------------
> -----------
> > 
> [2 0001-Support-NVIDIA-MCP78-HDMI-audio.patch
<application/octet-stream (base64)>]
> 
> [3 0002-Fix-for-reading-RIRB-buffer-on-NVIDIA-aza-controller.patch
<application/octet-stream (base64)>]
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79
  2008-09-25  9:55                       ` Takashi Iwai
  2008-09-25 11:29                         ` Wei Ni
@ 2008-09-26  6:19                         ` Wei Ni
  2008-09-26  8:40                           ` Takashi Iwai
  1 sibling, 1 reply; 17+ messages in thread
From: Wei Ni @ 2008-09-26  6:19 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: peerchen, Pavel Hofman, Peer Chen, alsa-devel, linux-kernel, akpm

[-- Attachment #1: Type: text/plain, Size: 5915 bytes --]

Hi, Takashi
I fixed something based on your comments, please check the patch files.

Thanks

-----Original Message-----
From: Takashi Iwai [mailto:tiwai@suse.de] 
Sent: Thursday, September 25, 2008 5:55 PM
To: Wei Ni
Cc: peerchen; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
MCP77/79

At Thu, 25 Sep 2008 15:14:50 +0800,
Wei Ni wrote:
> 
> Hi, Takashi
> I use git to generate patches. (I run git-fetch origin,
git-fetch-rebase
> origin, and git-format-patch origin)
> 
> There are two patch, one for the addition of HDMI, and one for the fix
> for our aza controller.
> 
> Please check it.

Thanks for patches.  It's good that you are using git now.
The code changes look good, but there are small issues in the patches:

- The author line is bogus.  Edit your ~/.gitconfig and add like the
  following:
	[user]
	  name = Wei Ni
	  email = wni@nvidia.com
  Then reset and commit patches again.

- Missing sign-off.  Add --sign option when you do git-commit.

- No proper change log.  Only a subject line isn't enough for many
  (most) cases, especially for a patch like workaround for nvidia
  controller.
  Please describe why this change is needed more precisely.

Could you fix and repost again?


Thanks!

Takashi


> 
> Thanks
> 
> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de] 
> Sent: Monday, September 22, 2008 5:58 PM
> To: Wei Ni
> Cc: peerchen; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor
> MCP77/79
> 
> At Mon, 22 Sep 2008 14:33:58 +0800,
> Wei Ni wrote:
> > 
> > Hi, Takashi
> > 
> > About the "long delay", it seemed that we need to add this "delay"
to
> > fix some issue on our aza controller.
> > Because it related with the controller, not just codec, so I think
> this
> > flag should not be added in codec-initialization part.
> > I think it's better to add the flag in that place which I submitted.
> 
> OK, then could you split the patch to separate ones, i.e. one for the
> fix for this problem regarding Nvidia controller chip, and one for the
> addition of HDMI?
> 
> Don't forget to add a proper description for each patch, please ;)
> 
> As mentioned, that flag is a last resort, and I think it can be fixed
> in a saner way.  But, the flag is surely safe, and we can track down
> the problem later on.
> 
> 
> thanks,
> 
> Takashi
> 
> 
> > 
> > Thanks
> > 
> > -----Original Message-----
> > From: Wei Ni 
> > Sent: Friday, September 19, 2008 12:43 PM
> > To: 'Takashi Iwai'; peerchen
> > Cc: Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> > Subject: RE: [alsa-devel] [PATCH] add the nvidia HDMI codec
driverfor
> > MCP77/79
> > 
> > Thanks for your reply.
> > 
> > About the "long delay", we had some problems on reading RIRB buffer
> when
> > testing this driver, so we add this "delay"
> > We will try to find a best way to fix this issue.
> > 
> > And we didn't familiar with git, we will research it more such as
> > "rebase" and then submit the patch file again.
> > 
> > Thanks
> > 
> > -----Original Message-----
> > From: Takashi Iwai [mailto:tiwai@suse.de] 
> > Sent: Wednesday, September 17, 2008 10:05 PM
> > To: peerchen
> > Cc: Wei Ni; Pavel Hofman; Peer Chen; alsa-devel; linux-kernel; akpm
> > Subject: Re: [alsa-devel] [PATCH] add the nvidia HDMI codec
driverfor
> > MCP77/79
> > 
> > At Wed, 17 Sep 2008 17:00:04 +0800,
> > peerchen wrote:
> > > 
> > > new patch base on git tree.
> > > 
> > > Signed-off-by: Wei Ni <wni@nvidia.com>
> > > Signed-off-by: Peer Chen <peerchen@gmail.com>
> > 
> > Thanks!
> > 
> > But, the patch looks like no "rebase".  You secretly added a new
> > function call that wasn't in your previous patch, namely...
> > 
> > > diff -uprN -X linux-2.6-tiwai-sound/Documentation/dontdiff
> > linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c
> > linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> > > --- linux-2.6-tiwai-sound/sound/pci/hda/hda_intel.c
2008-09-10
> > 17:40:52.000000000 +0800
> > > +++ linux-2.6-tiwai-sound-niwei/sound/pci/hda/hda_intel.c
> > 2008-09-10 17:49:31.000000000 +0800
> > > @@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(st
> > >  	if (err < 0)
> > >  		return err;
> > >  
> > > +	if (chip->driver_type == AZX_DRIVER_NVIDIA)
> > > +		chip->bus->needs_damn_long_delay = 1;
> > > +
> > 
> > Do we really need this inevitably?  I don't think so -- otherwise I
> > would have far more bug reports.
> > 
> > This flag is the last resort and should be avoided as much as
> > possible.  This results in a significant slow down of suspend/resume
> > speed, for example.
> > 
> > If it's really needed with some devices and there is no other way to
> > fix it, add this flag rather in the codec-initialization part.
> > 
> > Also, if you resend a patch, please add the original patch
description
> 
> > again.  This helps my patch work a lot indeed.
> > 
> > 
> > thanks,
> > 
> > Takashi
> >
>
------------------------------------------------------------------------
> -----------
> > This email message is for the sole use of the intended recipient(s)
> and may contain
> > confidential information.  Any unauthorized review, use, disclosure
or
> distribution
> > is prohibited.  If you are not the intended recipient, please
contact
> the sender by
> > reply email and destroy all copies of the original message.
> >
>
------------------------------------------------------------------------
> -----------
> > 
> [2 0001-Support-NVIDIA-MCP78-HDMI-audio.patch
<application/octet-stream (base64)>]
> 
> [3 0002-Fix-for-reading-RIRB-buffer-on-NVIDIA-aza-controller.patch
<application/octet-stream (base64)>]
> 

[-- Attachment #2: 0001-Support-NVIDIA-MCP78-7A-HDMI-audio.patch --]
[-- Type: application/octet-stream, Size: 7330 bytes --]

From 982290df7077cef44dc6f7dca679ae6c6f85b9bd Mon Sep 17 00:00:00 2001
From: Wei Ni <wni@nvidia.com>
Date: Fri, 26 Sep 2008 13:45:46 +0800
Subject: [PATCH] Support NVIDIA MCP78/7A HDMI audio

Signed-off-by: Wei Ni <wni@nvidia.com>

Add NVIDIA HDMI HD-audio codec support in snd-hda-intel driver, include NVIDIA MCP78/7A HDMI.
---
 sound/pci/Kconfig            |    8 ++
 sound/pci/hda/Makefile       |    1 +
 sound/pci/hda/hda_codec.c    |    3 +
 sound/pci/hda/hda_patch.h    |    2 +
 sound/pci/hda/patch_nvhdmi.c |  164 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 178 insertions(+), 0 deletions(-)
 create mode 100644 sound/pci/hda/patch_nvhdmi.c

diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 1f8b796..7003711 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -565,6 +565,14 @@ config SND_HDA_CODEC_ATIHDMI
 	  Say Y here to include ATI HDMI HD-audio codec support in
 	  snd-hda-intel driver, such as ATI RS600 HDMI.
 
+config SND_HDA_CODEC_NVHDMI
+	bool "Build NVIDIA HDMI HD-audio codec support"
+	depends on SND_HDA_INTEL
+	default y
+	help
+	  Say Y here to include NVIDIA HDMI HD-audio codec support in
+	  snd-hda-intel driver, such as NVIDIA MCP78 HDMI.
+
 config SND_HDA_CODEC_CONEXANT
 	bool "Build Conexant HD-audio codec support"
 	depends on SND_HDA_INTEL
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 6db92fd..1980c6d 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -15,5 +15,6 @@ snd-hda-intel-$(CONFIG_SND_HDA_CODEC_SI3054) += patch_si3054.o
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_ATIHDMI) += patch_atihdmi.o
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_CONEXANT) += patch_conexant.o
 snd-hda-intel-$(CONFIG_SND_HDA_CODEC_VIA) += patch_via.o
+snd-hda-intel-$(CONFIG_SND_HDA_CODEC_NVHDMI) += patch_nvhdmi.o
 
 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 94ea654..fdb6d55 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -94,6 +94,9 @@ static const struct hda_codec_preset *hda_preset_tables[] = {
 #ifdef CONFIG_SND_HDA_CODEC_VIA
 	snd_hda_preset_via,
 #endif
+#ifdef CONFIG_SND_HDA_CODEC_NVHDMI
+	snd_hda_preset_nvhdmi,
+#endif
 	NULL
 };
 
diff --git a/sound/pci/hda/hda_patch.h b/sound/pci/hda/hda_patch.h
index 2fdf235..dfbcfa8 100644
--- a/sound/pci/hda/hda_patch.h
+++ b/sound/pci/hda/hda_patch.h
@@ -18,3 +18,5 @@ extern struct hda_codec_preset snd_hda_preset_atihdmi[];
 extern struct hda_codec_preset snd_hda_preset_conexant[];
 /* VIA codecs */
 extern struct hda_codec_preset snd_hda_preset_via[];
+/* NVIDIA HDMI codecs */
+extern struct hda_codec_preset snd_hda_preset_nvhdmi[];
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c
new file mode 100644
index 0000000..1a65775
--- /dev/null
+++ b/sound/pci/hda/patch_nvhdmi.c
@@ -0,0 +1,164 @@
+/*
+ * Universal Interface for Intel High Definition Audio Codec
+ *
+ * HD audio interface patch for NVIDIA HDMI codecs
+ *
+ * Copyright (c) 2008 NVIDIA Corp.  All rights reserved.
+ * Copyright (c) 2008 Wei Ni <wni@nvidia.com>
+ *
+ *
+ *  This driver is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This driver is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+#include "hda_codec.h"
+#include "hda_local.h"
+
+struct nvhdmi_spec {
+	struct hda_multi_out multiout;
+
+	struct hda_pcm pcm_rec;
+};
+
+static struct hda_verb nvhdmi_basic_init[] = {
+	/* enable digital output on pin widget */
+	{ 0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+	{} /* terminator */
+};
+
+/*
+ * Controls
+ */
+static int nvhdmi_build_controls(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	int err;
+
+	err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int nvhdmi_init(struct hda_codec *codec)
+{
+	snd_hda_sequence_write(codec, nvhdmi_basic_init);
+	return 0;
+}
+
+/*
+ * Digital out
+ */
+static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
+				     struct hda_codec *codec,
+				     struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_open(codec, &spec->multiout);
+}
+
+static int nvhdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
+				      struct hda_codec *codec,
+				      struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_close(codec, &spec->multiout);
+}
+
+static int nvhdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
+					    struct hda_codec *codec,
+					    unsigned int stream_tag,
+					    unsigned int format,
+					    struct snd_pcm_substream *substream)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
+					     format, substream);
+}
+
+static struct hda_pcm_stream nvhdmi_pcm_digital_playback = {
+	.substreams = 1,
+	.channels_min = 2,
+	.channels_max = 2,
+	.nid = 0x4, /* NID to query formats and rates and setup streams */
+	.rates = SNDRV_PCM_RATE_48000,
+	.maxbps = 16,
+	.formats = SNDRV_PCM_FMTBIT_S16_LE,
+	.ops = {
+		.open = nvhdmi_dig_playback_pcm_open,
+		.close = nvhdmi_dig_playback_pcm_close,
+		.prepare = nvhdmi_dig_playback_pcm_prepare
+	},
+};
+
+static int nvhdmi_build_pcms(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec = codec->spec;
+	struct hda_pcm *info = &spec->pcm_rec;
+
+	codec->num_pcms = 1;
+	codec->pcm_info = info;
+
+	info->name = "NVIDIA HDMI";
+	info->stream[SNDRV_PCM_STREAM_PLAYBACK] = nvhdmi_pcm_digital_playback;
+
+	return 0;
+}
+
+static void nvhdmi_free(struct hda_codec *codec)
+{
+	kfree(codec->spec);
+}
+
+static struct hda_codec_ops nvhdmi_patch_ops = {
+	.build_controls = nvhdmi_build_controls,
+	.build_pcms = nvhdmi_build_pcms,
+	.init = nvhdmi_init,
+	.free = nvhdmi_free,
+};
+
+static int patch_nvhdmi(struct hda_codec *codec)
+{
+	struct nvhdmi_spec *spec;
+
+	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
+	if (spec == NULL)
+		return -ENOMEM;
+
+	codec->spec = spec;
+
+	spec->multiout.num_dacs = 0;	  /* no analog */
+	spec->multiout.max_channels = 2;
+	spec->multiout.dig_out_nid = 0x4; /* NID for copying analog to digital,
+					   * seems to be unused in pure-digital
+					   * case. */
+
+	codec->patch_ops = nvhdmi_patch_ops;
+
+	return 0;
+}
+
+/*
+ * patch entries
+ */
+struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
+	{ .id = 0x10de0002, .name = "NVIDIA MCP78 HDMI", .patch = patch_nvhdmi },
+	{ .id = 0x10de0007, .name = "NVIDIA MCP7A HDMI", .patch = patch_nvhdmi },
+	{} /* terminator */
+};
-- 
1.5.6


[-- Attachment #3: 0002-Fix-for-reading-RIRB-buffer-on-NVIDIA-aza-controller.patch --]
[-- Type: application/octet-stream, Size: 1101 bytes --]

From 2e77787cae6652a76f48f499c61218acb70baee8 Mon Sep 17 00:00:00 2001
From: Wei Ni <wni@nvidia.com>
Date: Fri, 26 Sep 2008 13:55:56 +0800
Subject: [PATCH] Fix for reading RIRB buffer on NVIDIA aza controller with AMD Phenom cpu

Signed-off-by: Wei Ni <wni@nvidia.com>

When read RIRB buffer immediately after RIRB interrupt received, sometimes the data will be "0x0". If we wait for some time, the data in buffer will be correct. This issue only occurred with AMD Phenom cpu. So we set this "needs_damn_long_delay" flag.
---
 sound/pci/hda/hda_intel.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 60cc44a..9f316c1 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1220,6 +1220,9 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
 	if (err < 0)
 		return err;
 
+	if (chip->driver_type == AZX_DRIVER_NVIDIA)
+		chip->bus->needs_damn_long_delay = 1;
+
 	codecs = audio_codecs = 0;
 	max_slots = azx_max_codecs[chip->driver_type];
 	if (!max_slots)
-- 
1.5.6


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79
  2008-09-26  6:19                         ` Wei Ni
@ 2008-09-26  8:40                           ` Takashi Iwai
  0 siblings, 0 replies; 17+ messages in thread
From: Takashi Iwai @ 2008-09-26  8:40 UTC (permalink / raw)
  To: Wei Ni; +Cc: peerchen, Pavel Hofman, Peer Chen, alsa-devel, linux-kernel, akpm

At Fri, 26 Sep 2008 14:19:46 +0800,
Wei Ni wrote:
> 
> Hi, Takashi
> I fixed something based on your comments, please check the patch files.

Thanks! I applied both patches now after formatting comments.
These will be included in 2.6.28.

(At the next time, please put your sign-off at the end of commit log,
 and add line breaks appropriately to keep commit log in 80 or less
 column letters.)


Takashi

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2008-09-26  8:40 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-03  7:58 [alsa-devel][PATCH] add the nvidia HDMI codec driver for MCP77/79 peerchen
2008-09-03  8:51 ` Takashi Iwai
2008-09-03 11:05   ` Wei Ni
2008-09-03 12:06     ` Takashi Iwai
2008-09-03 12:11       ` [alsa-devel] [PATCH] " Pavel Hofman
2008-09-04  7:04         ` Takashi Iwai
2008-09-05  8:28           ` Wei Ni
2008-09-17  9:00             ` Re: [alsa-devel] [PATCH] add the nvidia HDMI codec driverfor MCP77/79 peerchen
2008-09-17 14:04               ` Takashi Iwai
2008-09-19  4:42                 ` Wei Ni
2008-09-22  6:33                 ` Wei Ni
2008-09-22  9:58                   ` Takashi Iwai
2008-09-25  7:14                     ` Wei Ni
2008-09-25  9:55                       ` Takashi Iwai
2008-09-25 11:29                         ` Wei Ni
2008-09-26  6:19                         ` Wei Ni
2008-09-26  8:40                           ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).