Skip to contentSkip to conversation

Unifying sound/pci/hda/patch_*hdmi.c

PATCH Takashi Iwai 3 participants 8 messages Sep 15, 2010 – Sep 19, 2010 Sound

lore
Share & tools
lore
#0 lore raw

Hi,

the below is a patch for unifying three patch_*hdmi.c into a single file. I'd like to push this to 2.6.37, so please review, especially whether it can break Nvidia hardware (since I have no h/w available).

In future, we can reduce ATI- and Nvidia-specific codes gradually after confirming the generic parser works.

The patch is found in sound-unstable git tree, too. The corresponding alsa-driver-unstable tarball can be used for external builds.

thanks,

Takashi

Quoted 1 line

From fd74a0170e730d397b796dc34eb5212358e764ea Mon Sep 17 00:00:00 2001

From: Takashi Iwai <[email protected]>
Date: Tue, 7 Sep 2010 12:27:25 +0200
Subject: [PATCH] ALSA: hda - Merge all HDMI modules into the unified module

This patch merges all three patch_*hdmi variants to the single HDMI parser. There is only one snd-hda-codec-hdmi module now.

In this patch, the behavior of each parser isn't changed much. The old ATI parser still doesn't use the dynamic parser yet. In later patches, they'll be cleaned up.

Also, this patch gets rid of the individual snd-hda-eld module and builds into snd-hda-codec-hdmi, since this is referred only from the HDMI parser.

---
 sound/pci/hda/Kconfig           |   39 +--
 sound/pci/hda/Makefile          |   15 +-
 sound/pci/hda/hda_eld.c         |    7 -
 sound/pci/hda/patch_atihdmi.c   |  224 -------------
 sound/pci/hda/patch_hdmi.c      |  685 ++++++++++++++++++++++++++++++++++++++-
 sound/pci/hda/patch_intelhdmi.c |  220 -------------
 sound/pci/hda/patch_nvhdmi.c    |  608 ----------------------------------
 7 files changed, 691 insertions(+), 1107 deletions(-)
 delete mode 100644 sound/pci/hda/patch_atihdmi.c
 delete mode 100644 sound/pci/hda/patch_intelhdmi.c
 delete mode 100644 sound/pci/hda/patch_nvhdmi.c
sound/pci/hda/Kconfig +6 -33
index 9194c3c..329e116 100644
@@ -119,47 +119,20 @@ config SND_HDA_CODEC_VIA
 	  snd-hda-codec-via.
 	  This module is automatically loaded at probing.
 
-config SND_HDA_CODEC_ATIHDMI
-	bool "Build ATI HDMI HD-audio codec support"
-	default y
-	help
-	  Say Y here to include ATI HDMI HD-audio codec support in
-	  snd-hda-intel driver, such as ATI RS600 HDMI.
-
-	  When the HD-audio driver is built as a module, the codec
-	  support code is also built as another module,
-	  snd-hda-codec-atihdmi.
-	  This module is automatically loaded at probing.
-
-config SND_HDA_CODEC_NVHDMI
-	bool "Build NVIDIA HDMI HD-audio codec support"
-	default y
-	help
-	  Say Y here to include NVIDIA HDMI HD-audio codec support in
-	  snd-hda-intel driver, such as NVIDIA MCP78 HDMI.
-
-	  When the HD-audio driver is built as a module, the codec
-	  support code is also built as another module,
-	  snd-hda-codec-nvhdmi.
-	  This module is automatically loaded at probing.
-
-config SND_HDA_CODEC_INTELHDMI
-	bool "Build INTEL HDMI HD-audio codec support"
+config SND_HDA_CODEC_HDMI
+	bool "Build HDMI HD-audio codec support"
 	select SND_DYNAMIC_MINORS
 	default y
 	help
-	  Say Y here to include INTEL HDMI HD-audio codec support in
-	  snd-hda-intel driver, such as Eaglelake integrated HDMI.
+	  Say Y here to include HDMI HD-audio codec support in
+	  snd-hda-intel driver.  This includes all AMD/ATI, Intel and
+	  Nvidia HDMI codecs.
 
 	  When the HD-audio driver is built as a module, the codec
 	  support code is also built as another module,
-	  snd-hda-codec-intelhdmi.
+	  snd-hda-codec-hdmi.
 	  This module is automatically loaded at probing.
 
-config SND_HDA_ELD
-	def_bool y
-	depends on SND_HDA_CODEC_INTELHDMI || SND_HDA_CODEC_NVHDMI
-
 config SND_HDA_CODEC_CIRRUS
 	bool "Build Cirrus Logic codec support"
 	depends on SND_HDA_INTEL
sound/pci/hda/Makefile +3 -12
index 24bc195..17ef365 100644
@@ -3,7 +3,6 @@ snd-hda-intel-objs := hda_intel.o
 snd-hda-codec-y := hda_codec.o
 snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o
 snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
-snd-hda-codec-$(CONFIG_SND_HDA_ELD) += hda_eld.o
 snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
 snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
 
@@ -12,13 +11,11 @@ snd-hda-codec-cmedia-objs :=	patch_cmedia.o
 snd-hda-codec-analog-objs :=	patch_analog.o
 snd-hda-codec-idt-objs :=	patch_sigmatel.o
 snd-hda-codec-si3054-objs :=	patch_si3054.o
-snd-hda-codec-atihdmi-objs :=	patch_atihdmi.o
 snd-hda-codec-cirrus-objs :=	patch_cirrus.o
 snd-hda-codec-ca0110-objs :=	patch_ca0110.o
 snd-hda-codec-conexant-objs :=	patch_conexant.o
 snd-hda-codec-via-objs :=	patch_via.o
-snd-hda-codec-nvhdmi-objs :=	patch_nvhdmi.o
-snd-hda-codec-intelhdmi-objs :=	patch_intelhdmi.o
+snd-hda-codec-hdmi-objs :=	patch_hdmi.o hda_eld.o
 
 # common driver
 obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o
@@ -39,9 +36,6 @@ endif
 ifdef CONFIG_SND_HDA_CODEC_SI3054
 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-si3054.o
 endif
-ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
-obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-atihdmi.o
-endif
 ifdef CONFIG_SND_HDA_CODEC_CIRRUS
 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-cirrus.o
 endif
@@ -54,11 +48,8 @@ endif
 ifdef CONFIG_SND_HDA_CODEC_VIA
 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-via.o
 endif
-ifdef CONFIG_SND_HDA_CODEC_NVHDMI
-obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-nvhdmi.o
-endif
-ifdef CONFIG_SND_HDA_CODEC_INTELHDMI
-obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-intelhdmi.o
+ifdef CONFIG_SND_HDA_CODEC_HDMI
+obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-hdmi.o
 endif
 
 # this must be the last entry after codec drivers;
sound/pci/hda/hda_eld.c +0 -7
index 26c3ade..cb0c23a 100644
@@ -332,7 +332,6 @@ int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid)
 	return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE,
 						 AC_DIPSIZE_ELD_BUF);
 }
-EXPORT_SYMBOL_HDA(snd_hdmi_get_eld_size);
 
 int snd_hdmi_get_eld(struct hdmi_eld *eld,
 		     struct hda_codec *codec, hda_nid_t nid)
@@ -368,7 +367,6 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
 	kfree(buf);
 	return ret;
 }
-EXPORT_SYMBOL_HDA(snd_hdmi_get_eld);
 
 static void hdmi_show_short_audio_desc(struct cea_sad *a)
 {
@@ -407,7 +405,6 @@ void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen)
 	}
 	buf[j] = '\0';	/* necessary when j == 0 */
 }
-EXPORT_SYMBOL_HDA(snd_print_channel_allocation);
 
 void snd_hdmi_show_eld(struct hdmi_eld *e)
 {
@@ -426,7 +423,6 @@ void snd_hdmi_show_eld(struct hdmi_eld *e)
 	for (i = 0; i < e->sad_count; i++)
 		hdmi_show_short_audio_desc(e->sad + i);
 }
-EXPORT_SYMBOL_HDA(snd_hdmi_show_eld);
 
 #ifdef CONFIG_PROC_FS
 
@@ -585,7 +581,6 @@ int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld,
 
 	return 0;
 }
-EXPORT_SYMBOL_HDA(snd_hda_eld_proc_new);
 
 void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld)
 {
@@ -594,7 +589,6 @@ void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld)
 		eld->proc_entry = NULL;
 	}
 }
-EXPORT_SYMBOL_HDA(snd_hda_eld_proc_free);
 
 #endif /* CONFIG_PROC_FS */
 
@@ -645,4 +639,3 @@ void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm,
 	pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max);
 	pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps);
 }
-EXPORT_SYMBOL_HDA(hdmi_eld_update_pcm_info);
sound/pci/hda/patch_atihdmi.c deleted +0 -224

224 lines not on this page · raw message

sound/pci/hda/patch_hdmi.c +682 -3

714 lines not on this page · raw message

sound/pci/hda/patch_intelhdmi.c deleted +0 -220

220 lines not on this page · raw message

sound/pci/hda/patch_nvhdmi.c deleted +0 -608

608 lines not on this page · raw message

Signature · 1 line
1.7.2.1

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#1 lore raw

Thanks. I'll test it on Intel hardware tomorrow :)

Quoted 16 lines · Takashi Iwai

Hi,

the below is a patch for unifying three patch_*hdmi.c into a single file. I'd like to push this to 2.6.37, so please review, especially whether it can break Nvidia hardware (since I have no h/w available).

In future, we can reduce ATI- and Nvidia-specific codes gradually after confirming the generic parser works.

The patch is found in sound-unstable git tree, too. The corresponding alsa-driver-unstable tarball can be used for external builds.

thanks,

Takashi

#2 lore raw
In reply to Takashi Iwai

Takashi,

Since the driver will also be supporting DisplayPort audio, would you add "DisplayPort" too in the following chunk?

+config SND_HDA_CODEC_HDMI
==> + bool "Build HDMI HD-audio codec support"
select SND_DYNAMIC_MINORS
default y
help
- Say Y here to include INTEL HDMI HD-audio codec support in
- snd-hda-intel driver, such as Eaglelake integrated HDMI.

==>     +         Say Y here to include HDMI HD-audio codec support in
        +         snd-hda-intel driver.  This includes all AMD/ATI, Intel and
==>     +         Nvidia HDMI codecs.

Thanks,
Fengguang

#4 lore raw

At Wed, 15 Sep 2010 23:03:27 +0800,

Quoted 5 lines · Wu Fengguang

+ * Nvidia specific implmenetations

s/implmenetations/implementations/

Thanks, fixed both now.

Takashi

#5 lore raw
In reply to Takashi Iwai
Quoted 3 lines · Takashi Iwai

the below is a patch for unifying three patch_*hdmi.c into a single file. I'd like to push this to 2.6.37, so please review, especially whether it can break Nvidia hardware (since I have no h/w available).

First off, in general, I think working towards unifying all the HDMI code is a great goal.

However, this patch worries me a bit because it significantly changes the way some parts of the code work at the same time as performing the refactoring...

In particular, after a brief skim, I see the following issues:

+static int patch_nvhdmi_8ch_89(struct hda_codec *codec) +{
+ struct hdmi_spec *spec;
+ int err = patch_generic_hdmi(codec);
+
+ if (err < 0)
+ return err;
+ spec = codec->spec;
+ spec->old_pin_detect = 1;
+ spec->pcm_playback = &nvhdmi_pcm_playback_8ch_7x;

That last line is definitely wrong as far as I can tell. Just delete it?

+ return 0;
+}

+static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) +{
+ struct hdmi_spec *spec;
+ int err = patch_generic_hdmi(codec);

The old nvhdmi_8ch_7x code was custom like nvhdmi_2ch. Unfortunately, I'm not familiar with the old HW nor why it used custom code instead of the generic parser. This seems like a risky change without testing.

One behavioral change I see is that patch_generic_hdmi will call snd_hda_eld_proc_new, which wasn't previously called for this codec type. Yet, nvhdmi_patch_ops_8ch_7x doesn't point unsol_event at hdmi_unsol_event, so the ELD stuff won't work. I don't know if the unsolicited event logic in the HW works on this chip or not, given the Linux driver hasn't used it before. I suppose it has to work, but who knows...

Related,

+static struct hda_codec_ops nvhdmi_patch_ops_2ch = {
+ .build_controls = generic_hdmi_build_controls,
+ .build_pcms = generic_hdmi_build_pcms,
+ .init = nvhdmi_7x_init,
+ .free = generic_hdmi_free,
+};

Generic_hdmi_free calls snd_hda_eld_proc_free. Since nvhdmi_7x_init doesn't call generic_hdmi_init, will that attempt to free ELD structures that aren't allocated?

Once the above issues are thought through, I can try to find time to test this on HW. Unfortunately, I definitely don't have any of the "2ch" HW available to test at all. I do have a small subset of the "8ch_7x" and "8ch_89" HW (although my only HDMI sink at work only supports 2-channel audio). Also, my allotted time to work on the audio driver is very small right now, plus I'll be away from the office next week and hence won't have HW access to test anything anyway. Sorry I suck at being a tester!

Quoted 10 lines

In future, we can reduce ATI- and Nvidia-specific codes gradually after confirming the generic parser works.

The patch is found in sound-unstable git tree, too. The corresponding alsa-driver-unstable tarball can be used for external builds.

thanks,

Takashi

Signature · 1 line
nvpublic
#6 lore raw

At Thu, 16 Sep 2010 11:10:13 -0700,

Quoted 26 lines · Stephen Warren
Quoted 3 lines · Takashi Iwai

the below is a patch for unifying three patch_*hdmi.c into a single file. I'd like to push this to 2.6.37, so please review, especially whether it can break Nvidia hardware (since I have no h/w available).

First off, in general, I think working towards unifying all the HDMI code is a great goal.

However, this patch worries me a bit because it significantly changes the way some parts of the code work at the same time as performing the refactoring...

In particular, after a brief skim, I see the following issues:

(quoted diff) +10 -0
+static int patch_nvhdmi_8ch_89(struct hda_codec *codec)
+{
+	struct hdmi_spec *spec;
+	int err = patch_generic_hdmi(codec);
+
+	if (err < 0)
+		return err;
+	spec = codec->spec;
+	spec->old_pin_detect = 1;
+	spec->pcm_playback = &nvhdmi_pcm_playback_8ch_7x;
Quoted 2 lines

That last line is definitely wrong as far as I can tell. Just delete it?

Ah, crap, this has to be removed.

Quoted 11 lines
(quoted diff) +6 -0
+	return 0;
+}
 
+static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
+{
+	struct hdmi_spec *spec;
+	int err = patch_generic_hdmi(codec);

The old nvhdmi_8ch_7x code was custom like nvhdmi_2ch. Unfortunately, I'm not familiar with the old HW nor why it used custom code instead of the generic parser. This seems like a risky change without testing.

Looks like I did wrong copy&paste here and there. It was intended to call patch_nvhdmi_2ch() instead. The additional fix patch is below.

Quoted 16 lines

One behavioral change I see is that patch_generic_hdmi will call snd_hda_eld_proc_new, which wasn't previously called for this codec type. Yet, nvhdmi_patch_ops_8ch_7x doesn't point unsol_event at hdmi_unsol_event, so the ELD stuff won't work. I don't know if the unsolicited event logic in the HW works on this chip or not, given the Linux driver hasn't used it before. I suppose it has to work, but who knows...

Related,

(quoted diff) +6 -0
+static struct hda_codec_ops nvhdmi_patch_ops_2ch = {
+	.build_controls = generic_hdmi_build_controls,
+	.build_pcms = generic_hdmi_build_pcms,
+	.init = nvhdmi_7x_init,
+	.free = generic_hdmi_free,
+};
Quoted 3 lines

Generic_hdmi_free calls snd_hda_eld_proc_free. Since nvhdmi_7x_init doesn't call generic_hdmi_init, will that attempt to free ELD structures that aren't allocated?

The call of snd_hda_eld_proc_free() is harmless, so I chose one function to reduce rather than having two.

Quoted 7 lines

Once the above issues are thought through, I can try to find time to test this on HW. Unfortunately, I definitely don't have any of the "2ch" HW available to test at all. I do have a small subset of the "8ch_7x" and "8ch_89" HW (although my only HDMI sink at work only supports 2-channel audio). Also, my allotted time to work on the audio driver is very small right now, plus I'll be away from the office next week and hence won't have HW access to test anything anyway. Sorry I suck at being a tester!

OK, no problem.
Thanks for review, anyway.

Takashi

---

sound/pci/hda/patch_hdmi.c +2 -2
index c6d183e..7d4ed7f 100644
@@ -1352,7 +1352,6 @@ static int patch_nvhdmi_8ch_89(struct hda_codec *codec)
 		return err;
 	spec = codec->spec;
 	spec->old_pin_detect = 1;
-	spec->pcm_playback = &nvhdmi_pcm_playback_8ch_7x;
 	return 0;
 }
 
@@ -1382,12 +1381,13 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec)
 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
 {
 	struct hdmi_spec *spec;
-	int err = patch_generic_hdmi(codec);
+	int err = patch_nvhdmi_2ch(codec);
 
 	if (err < 0)
 		return err;
 	spec = codec->spec;
 	spec->multiout.max_channels = 8;
+	spec->pcm_playback = &nvhdmi_pcm_playback_8ch_7x;
 	codec->patch_ops = nvhdmi_patch_ops_8ch_7x;
 	return 0;
 }
#7 lore raw
In reply to Takashi Iwai
Quoted 5 lines · Takashi Iwai

Hi,

the below is a patch for unifying three patch_*hdmi.c into a single file. I'd like to push this to 2.6.37, so please review, especially whether it can break Nvidia hardware (since I have no h/w available).

It works on Eaglelake (G45) and CougarPoint. I cannot find a IbexPeak box for test for now, however its codec file is almost the same as CougarPoint, so there should be no big problem.

Thanks,
Fengguang