alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: HDA: Remove unconnected PCM devices for Intel HDMI
@ 2010-11-12 15:46 David Henningsson
  2010-11-23  7:12 ` Takashi Iwai
  2010-12-07 19:10 ` Takashi Iwai
  0 siblings, 2 replies; 15+ messages in thread
From: David Henningsson @ 2010-11-12 15:46 UTC (permalink / raw)
  To: ALSA Development Mailing List, Takashi Iwai; +Cc: wfg

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

Since I'm a little new in HDMI land and the patch is non-trivial, I 
wouldn't mind some comments on this one. Also thanks to Jaroslav who 
cleared a few things out about the logical and physical devices which 
helped me figure out what I should do about it :-)

Anyway, here's the patch.

Some newer chips have more than one HDMI output, but usually not
all of them are exposed as physical jacks. Removing the unused
PCM devices (as indicated by BIOS in the pin config default) will
reduce user confusion as they currently have to choose between
several HDMI devices, some of them not working anyway.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>

-- 
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic

[-- Attachment #2: 0001-ALSA-HDA-Remove-unconnected-PCM-devices-for-Intel-HD.patch --]
[-- Type: text/x-patch, Size: 3265 bytes --]

>From db7911afdd02648b1faf6e2e7c8024da20d88257 Mon Sep 17 00:00:00 2001
From: David Henningsson <david.henningsson@canonical.com>
Date: Thu, 11 Nov 2010 16:27:37 +0100
Subject: [PATCH] ALSA: HDA: Remove unconnected PCM devices for Intel HDMI

Some newer chips have more than one HDMI output, but usually not
all of them are exposed as physical jacks. Removing the unused
PCM devices (as indicated by BIOS in the pin config default) will
reduce user confusion as they currently have to choose between
several HDMI devices, some of them not working anyway.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
 hda/patch_hdmi.c |   37 ++++++++++++++++++++++++++++---------
 1 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/hda/patch_hdmi.c b/hda/patch_hdmi.c
index d3e49aa..6d964f4 100644
--- a/hda/patch_hdmi.c
+++ b/hda/patch_hdmi.c
@@ -905,22 +905,22 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
 	spec->pin[spec->num_pins] = pin_nid;
 	spec->num_pins++;
 
-	/*
-	 * It is assumed that converter nodes come first in the node list and
-	 * hence have been registered and usable now.
-	 */
 	return hdmi_read_pin_conn(codec, pin_nid);
 }
 
 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid)
 {
+	int i;
 	struct hdmi_spec *spec = codec->spec;
 
-	if (spec->num_cvts >= MAX_HDMI_CVTS) {
-		snd_printk(KERN_WARNING
-			   "HDMI: no space for converter %d\n", nid);
+	for (i = 0; spec->pin_cvt[i] != nid; i++) 
+		if (!spec->pin[i]) {
+			snd_printd("HDMI: Skipping node %d (no connection)\n", nid);
+			return -EINVAL;
+		}
+
+	if (snd_BUG_ON(spec->num_cvts >= MAX_HDMI_CVTS))
 		return -E2BIG;
-	}
 
 	spec->cvt[spec->num_cvts] = nid;
 	spec->num_cvts++;
@@ -932,6 +932,8 @@ static int hdmi_parse_codec(struct hda_codec *codec)
 {
 	hda_nid_t nid;
 	int i, nodes;
+	int num_tmp_cvts = 0;
+	hda_nid_t tmp_cvt[MAX_HDMI_CVTS];
 
 	nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
 	if (!nid || nodes < 0) {
@@ -942,6 +944,7 @@ static int hdmi_parse_codec(struct hda_codec *codec)
 	for (i = 0; i < nodes; i++, nid++) {
 		unsigned int caps;
 		unsigned int type;
+		unsigned int config;
 
 		caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);
 		type = get_wcaps_type(caps);
@@ -951,17 +954,33 @@ static int hdmi_parse_codec(struct hda_codec *codec)
 
 		switch (type) {
 		case AC_WID_AUD_OUT:
-			hdmi_add_cvt(codec, nid);
+			if (num_tmp_cvts >= MAX_HDMI_CVTS) {
+				snd_printk(KERN_WARNING
+					   "HDMI: no space for converter %d\n", nid);
+				continue;
+			}
+			tmp_cvt[num_tmp_cvts] = nid;
+			num_tmp_cvts++;
 			break;
 		case AC_WID_PIN:
 			caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
 			if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP)))
 				continue;
+
+			config = snd_hda_codec_read(codec, nid, 0, 
+					     AC_VERB_GET_CONFIG_DEFAULT, 0);
+			if (((config & AC_DEFCFG_PORT_CONN) >> 
+			    AC_DEFCFG_PORT_CONN_SHIFT) == AC_JACK_PORT_NONE)
+				continue;
+
 			hdmi_add_pin(codec, nid);
 			break;
 		}
 	}
 
+	for (i = 0; i < num_tmp_cvts; i++) 
+		hdmi_add_cvt(codec, tmp_cvt[i]);
+
 	/*
 	 * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event
 	 * can be lost and presence sense verb will become inaccurate if the
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

end of thread, other threads:[~2012-02-01 14:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-12 15:46 [PATCH] ALSA: HDA: Remove unconnected PCM devices for Intel HDMI David Henningsson
2010-11-23  7:12 ` Takashi Iwai
2010-11-23  9:29   ` David Henningsson
2010-11-23 11:06     ` Wu Fengguang
2010-11-23 13:51       ` Takashi Iwai
2010-11-23 14:19         ` David Henningsson
2010-11-23 14:58           ` Wu Fengguang
2010-11-24  9:39           ` Takashi Iwai
2010-11-23 15:15     ` Wu Fengguang
2010-11-23 15:40       ` David Henningsson
2010-11-23 15:54         ` Wu Fengguang
2010-11-24 13:50           ` David Henningsson
2010-11-23 16:16         ` Wu Fengguang
2010-12-07 19:10 ` Takashi Iwai
2012-02-01 12:38   ` RIDDICC

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).