Skip to contentSkip to conversation

Intel HDMI audio support

PATCH In review Wu Fengguang 3 participants 9 messages Nov 4, 2008 – Nov 5, 2008 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Intel HDMI audio support

Add support for Intel G45 integrated HDMI audio codecs.

This initial release supports:
- 2 channel stereo sound output
- report monitor's ELD information

---
 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_intelhdmi.c |  922 ++++++++++++++++++++++++++++++
 5 files changed, 936 insertions(+)
sound/pci/hda/hda_patch.h +2 -0
@@ -20,3 +20,5 @@ extern struct hda_codec_preset snd_hda_p
 extern struct hda_codec_preset snd_hda_preset_via[];
 /* NVIDIA HDMI codecs */
 extern struct hda_codec_preset snd_hda_preset_nvhdmi[];
+/* INTEL HDMI codecs */
+extern struct hda_codec_preset snd_hda_preset_intelhdmi[];
sound/pci/hda/Makefile +1 -0
@@ -16,5 +16,6 @@ snd-hda-intel-$(CONFIG_SND_HDA_CODEC_ATI
 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
+snd-hda-intel-$(CONFIG_SND_HDA_CODEC_INTELHDMI) += patch_intelhdmi.o
 
 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
sound/pci/Kconfig +8 -0
@@ -574,6 +574,14 @@ config SND_HDA_CODEC_NVHDMI
 	  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_INTELHDMI
+	bool "Build INTEL HDMI HD-audio codec support"
+	depends on SND_HDA_INTEL
+	default y
+	help
+	  Say Y here to include INTEL HDMI HD-audio codec support in
+	  snd-hda-intel driver, such as Eaglelake integrated HDMI.
+
 config SND_HDA_CODEC_CONEXANT
 	bool "Build Conexant HD-audio codec support"
 	depends on SND_HDA_INTEL
sound/pci/hda/hda_codec.c +3 -0
@@ -98,6 +98,9 @@ static const struct hda_codec_preset *hd
 #ifdef CONFIG_SND_HDA_CODEC_NVHDMI
 	snd_hda_preset_nvhdmi,
 #endif
+#ifdef CONFIG_SND_HDA_CODEC_INTELHDMI
+	snd_hda_preset_intelhdmi,
+#endif
 	NULL
 };
 
sound/pci/hda/patch_intelhdmi.c new file +922 -0

922 lines not on this page · raw message

#1 lore raw

At Tue, 4 Nov 2008 17:38:39 +0800,

Quoted 8 lines · Wu Fengguang

Add support for Intel G45 integrated HDMI audio codecs.

This initial release supports:
- 2 channel stereo sound output
- report monitor's ELD information

Thanks. The patch looks almost fine, but a few things to be fixed.

sound/pci/hda/patch_intelhdmi.c line 69

Quoted 12 lines
sound/pci/hda/patch_intelhdmi.c new file +12 -0
+/*
+ * ELD: EDID Like Data
+ */
+struct sink_eld {
+	int	eld_size;
+	int	baseline_len;
+	int	eld_ver;	/* (eld_ver == 0) indicates invalid ELD */
+	int	cea_edid_ver;
+	char	monitor_name[ELD_MAX_MNL + 1];
+	int	manufacture_id;
+	int	product_id;
+	long	port_id;

If you need a 64bit value, use u64 explicitly.

Quoted 6 lines
sound/pci/hda/patch_intelhdmi.c new file +6 -0
+struct hdmi_audio_infoframe {
+	u8 type; /* 0x84 */
+	u8 ver;  /* 0x01 */
+	u8 len;  /* 0x0a */
+
+	u8 checksum;	/* PB0 */

sound/pci/hda/patch_intelhdmi.c

Quoted 10 lines
sound/pci/hda/patch_intelhdmi.c new file +9 -0
+	u8 CC02_CT47;	/* CC in bits 0:2, CT in 4:7 */
+	u8 SS01_SF24;
+	u8 CXT04;
+	u8 CA;
+	u8 LFEPBL01_LSV36_DM_INH7;
+	u8 reserved[5];	/* PB6  - PB10 */
+};
 
+#define GRAB_BITS(buf, byte, lowbit, bits, val) \
+	(val) = ((buf)[(byte)] >> (lowbit)) & ((1 << (bits)) - 1)

This should be rather a form

#define GRAB_BITS(buf, byte, lowbit, bits) \
	((buf)[(byte)] >> (lowbit)) & ((1 << (bits)) - 1)

and

foo = GRAB_BITS(buf, byte, low, bits);

sound/pci/hda/patch_intelhdmi.c line 427

Quoted 7 lines
sound/pci/hda/patch_intelhdmi.c new file +7 -0
+static void hdmi_update_short_audio_desc(struct cea_sad *a,
+					 const unsigned char *buf)
+{
+	int i;
+	int val;
+
+	GRAB_BITS(buf, 1, 0, 7, val);

The numbers is GRAB_BITS() could be better defined.

Quoted 2 lines
sound/pci/hda/patch_intelhdmi.c new file +2 -0
+static int hdmi_update_sink_eld(struct hda_codec *codec,
+				const unsigned char *buf, int size)

(snip)

sound/pci/hda/patch_intelhdmi.c line 525

Quoted 1 line
sound/pci/hda/patch_intelhdmi.c new file +1 -0
+	e->port_id	  = le64_to_cpu(*(u64 *)(buf + 8));

Use get_unaligned_*() for this, just to be more portable. (And include <asm/unaligned.h> beforehand.)

sound/pci/hda/patch_intelhdmi.c line 529

Quoted 3 lines
sound/pci/hda/patch_intelhdmi.c new file +3 -0
+	/* the spec's tendency is little endian */
+	e->manufacture_id = le16_to_cpu(*(u16 *)(buf + 16));
+	e->product_id	  = le16_to_cpu(*(u16 *)(buf + 18));

Ditto.

sound/pci/hda/patch_intelhdmi.c line 539

Quoted 10 lines
sound/pci/hda/patch_intelhdmi.c new file +10 -0
+
+	if (mnl > ELD_MAX_MNL) {
+		snd_printd(KERN_INFO "MNL is reserved value %d\n", mnl);
+		goto out_fail;
+	} else if (ELD_FIXED_BYTES + mnl > size) {
+		snd_printd(KERN_INFO "out of range MNL %d\n", mnl);
+		goto out_fail;
+	} else {
+		strncpy(e->monitor_name, buf + ELD_FIXED_BYTES, mnl);
+		e->monitor_name[mnl] = '\0';

Use strlcpy().

Quoted 7 lines
sound/pci/hda/patch_intelhdmi.c new file +7 -0
+static void hdmi_show_eld(struct hda_codec *codec)
+{
+	int i;
+	int j;
+	struct intel_hdmi_spec *spec = codec->spec;
+	struct sink_eld *e = &spec->sink;
+	char buf[80];

(snip)

sound/pci/hda/patch_intelhdmi.c line 641

Quoted 4 lines
sound/pci/hda/patch_intelhdmi.c new file +4 -0
+	for (i = 0; i < ARRAY_SIZE(cea_speaker_allocation_names); i++) {
+		if (e->spk_alloc & (1 << i))
+			j += sprintf(buf + j, " %s",
+					cea_speaker_allocation_names[i]);

Use snprintf() instead to avoid overflow.

sound/pci/hda/patch_intelhdmi.c line 648

Quoted 7 lines
sound/pci/hda/patch_intelhdmi.c new file +7 -0
+	}
+	buf[j] = '\0';
+	printk(KERN_INFO "speaker allocations: (0x%x)%s\n", e->spk_alloc, buf);
+
+	for (i = 0; i < e->sad_count; i++) {
+		hdmi_show_short_audio_desc(e->sad + i);
+	}

checkpatch.pl warns about these braces.
In general, it's worth to run once before submission.

Could you fix these and repost?

thanks,

Takashi

#2 lore raw

On Tue, Nov 04, 2008 at 07:51:35PM +0800, Takashi Iwai wrote:

[...]

Quoted 1 line

Could you fix these and repost?

Takashi, your comments are all pertinent ones,
thank you very much for your review!

I'll repost.

Thank you,
Fengguang

#3 lore raw

PATCH 1/1 Intel HDMI audio support

In reply to Takashi Iwai

Add support for Intel G45 integrated HDMI audio codecs.

This initial release supports:
- 2 channel stereo sound output
- report monitor's ELD information

---
 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_intelhdmi.c |  926 ++++++++++++++++++++++++++++++
 5 files changed, 940 insertions(+)
sound/pci/hda/hda_patch.h +2 -0
@@ -20,3 +20,5 @@ extern struct hda_codec_preset snd_hda_p
 extern struct hda_codec_preset snd_hda_preset_via[];
 /* NVIDIA HDMI codecs */
 extern struct hda_codec_preset snd_hda_preset_nvhdmi[];
+/* INTEL HDMI codecs */
+extern struct hda_codec_preset snd_hda_preset_intelhdmi[];
sound/pci/hda/Makefile +1 -0
@@ -16,5 +16,6 @@ snd-hda-intel-$(CONFIG_SND_HDA_CODEC_ATI
 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
+snd-hda-intel-$(CONFIG_SND_HDA_CODEC_INTELHDMI) += patch_intelhdmi.o
 
 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
sound/pci/Kconfig +8 -0
@@ -574,6 +574,14 @@ config SND_HDA_CODEC_NVHDMI
 	  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_INTELHDMI
+	bool "Build INTEL HDMI HD-audio codec support"
+	depends on SND_HDA_INTEL
+	default y
+	help
+	  Say Y here to include INTEL HDMI HD-audio codec support in
+	  snd-hda-intel driver, such as Eaglelake integrated HDMI.
+
 config SND_HDA_CODEC_CONEXANT
 	bool "Build Conexant HD-audio codec support"
 	depends on SND_HDA_INTEL
sound/pci/hda/hda_codec.c +3 -0
@@ -98,6 +98,9 @@ static const struct hda_codec_preset *hd
 #ifdef CONFIG_SND_HDA_CODEC_NVHDMI
 	snd_hda_preset_nvhdmi,
 #endif
+#ifdef CONFIG_SND_HDA_CODEC_INTELHDMI
+	snd_hda_preset_intelhdmi,
+#endif
 	NULL
 };
 
sound/pci/hda/patch_intelhdmi.c new file +926 -0

926 lines not on this page · raw message

#4 lore raw

At Wed, 5 Nov 2008 11:16:56 +0800,

Quoted 8 lines · Fengguang

Add support for Intel G45 integrated HDMI audio codecs.

This initial release supports:
- 2 channel stereo sound output
- report monitor's ELD information

Applied now. Thanks for your quick fixes!

Takashi

#5 lore raw
Quoted 5 lines · Takashi Iwai

At Wed, 5 Nov 2008 11:16:56 +0800,

Quoted 3 lines · Fengguang

Add support for Intel G45 integrated HDMI audio codecs.

Quoted 7 lines
Quoted 5 lines

This initial release supports:
- 2 channel stereo sound output
- report monitor's ELD information

Applied now. Thanks for your quick fixes!

Thank you :-)

Fengguang

#6 lore raw

This has broken compilation of sound-unstable-2.6. It complains about Makefile of intelhdmi, not sure exactly what is the problem.

2008/11/5 Wu, Fengguang <[email protected]>:

Quoted 23 lines · Takashi Iwai
Quoted 5 lines

At Wed, 5 Nov 2008 11:16:56 +0800,

Quoted 3 lines · Fengguang

Add support for Intel G45 integrated HDMI audio codecs.

Quoted 7 lines
Quoted 5 lines

This initial release supports:
- 2 channel stereo sound output
- report monitor's ELD information

Applied now. Thanks for your quick fixes!

Thank you :-)

Fengguang

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

Signature · 5 lines
Vedran Miletić
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#7 lore raw

OK, that was an easy one. Adding patch_intelhdmi.c to pci/hda/ with content:
#define __NO_VERSION__
#include "adriver.h"
#include "../../alsa-kernel/pci/hda/patch_intelhdmi.c"
fixed it.

2008/11/5 Vedran Miletić <[email protected]>:

Quoted 33 lines

This has broken compilation of sound-unstable-2.6. It complains about Makefile of intelhdmi, not sure exactly what is the problem.

2008/11/5 Wu, Fengguang <[email protected]>:

Quoted 14 lines · Takashi Iwai
Quoted 5 lines

At Wed, 5 Nov 2008 11:16:56 +0800,

Quoted 3 lines · Fengguang

Add support for Intel G45 integrated HDMI audio codecs.

Quoted 7 lines
Quoted 5 lines

This initial release supports:
- 2 channel stereo sound output
- report monitor's ELD information

Applied now. Thanks for your quick fixes!

Quoted 9 lines

Thank you :-)

Fengguang

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

--
Vedran Miletić

Signature · 5 lines
Vedran Miletić
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#8 lore raw

At Wed, 5 Nov 2008 16:42:20 +0100,

Quoted 6 lines · =?UTF-8?Q?Vedran_Mileti=C4=87?= wrote:

OK, that was an easy one. Adding patch_intelhdmi.c to pci/hda/ with content:
#define __NO_VERSION__
#include "adriver.h"
#include "../../alsa-kernel/pci/hda/patch_intelhdmi.c"
fixed it.

Yep, I'll fix it that soon.

thanks,

Takashi

Quoted 31 lines

2008/11/5 Vedran Miletić <[email protected]>:

Quoted 30 lines

This has broken compilation of sound-unstable-2.6. It complains about Makefile of intelhdmi, not sure exactly what is the problem.

2008/11/5 Wu, Fengguang <[email protected]>:

Quoted 23 lines · Takashi Iwai
Quoted 5 lines

At Wed, 5 Nov 2008 11:16:56 +0800,

Quoted 3 lines · Fengguang

Add support for Intel G45 integrated HDMI audio codecs.

Quoted 7 lines
Quoted 5 lines

This initial release supports:
- 2 channel stereo sound output
- report monitor's ELD information

Applied now. Thanks for your quick fixes!

Thank you :-)

Fengguang

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

Quoted 8 lines
Quoted 3 lines

--
Vedran Miletić

Signature · 1 line
Vedran Miletić

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