From: Wu Fengguang <fengguang.wu@intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, Wu Fengguang <fengguang.wu@intel.com>
Subject: [PATCH 10/11] hda - auto parse intelhdmi cvt/pin configurations
Date: Thu, 15 Oct 2009 15:03:58 +0800 [thread overview]
Message-ID: <20091015070919.069338242@intel.com> (raw)
In-Reply-To: 20091015070348.390451250@intel.com
[-- Attachment #1: hdmi-auto-parse.patch --]
[-- Type: text/plain, Size: 3661 bytes --]
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
sound/pci/hda/patch_intelhdmi.c | 120 +++++++++++++++++++++++++++++-
1 file changed, 119 insertions(+), 1 deletion(-)
--- sound-2.6.orig/sound/pci/hda/patch_intelhdmi.c 2009-10-15 12:38:57.000000000 +0800
+++ sound-2.6/sound/pci/hda/patch_intelhdmi.c 2009-10-15 12:41:02.000000000 +0800
@@ -213,6 +213,10 @@ static struct cea_channel_speaker_alloca
};
+/*
+ * HDA/HDMI auto parsing
+ */
+
static int hda_node_index(hda_nid_t *nids, hda_nid_t nid)
{
int i;
@@ -225,6 +229,113 @@ static int hda_node_index(hda_nid_t *nid
return -EINVAL;
}
+static int intel_hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid)
+{
+ struct intel_hdmi_spec *spec = codec->spec;
+ hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
+ int conn_len, curr;
+ int index;
+
+ if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) {
+ snd_printk(KERN_WARNING
+ "HDMI: pin %d wcaps %#x "
+ "does not support connection list\n",
+ pin_nid, get_wcaps(codec, pin_nid));
+ return -EINVAL;
+ }
+
+ conn_len = snd_hda_get_connections(codec, pin_nid, conn_list,
+ HDA_MAX_CONNECTIONS);
+ if (conn_len > 1)
+ curr = snd_hda_codec_read(codec, pin_nid, 0,
+ AC_VERB_GET_CONNECT_SEL, 0);
+ else
+ curr = 0;
+
+ index = hda_node_index(spec->pin, pin_nid);
+ if (index < 0)
+ return -EINVAL;
+
+ spec->pin_cvt[index] = conn_list[curr];
+
+ return 0;
+}
+
+static int intel_hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
+{
+ struct intel_hdmi_spec *spec = codec->spec;
+
+ if (spec->num_pins >= INTEL_HDMI_PINS) {
+ snd_printk(KERN_WARNING
+ "HDMI: no space for pin %d \n", pin_nid);
+ return -EINVAL;
+ }
+
+ 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 intel_hdmi_read_pin_conn(codec, pin_nid);
+}
+
+static int intel_hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid)
+{
+ struct intel_hdmi_spec *spec = codec->spec;
+
+ if (spec->num_cvts >= INTEL_HDMI_CVTS) {
+ snd_printk(KERN_WARNING
+ "HDMI: no space for converter %d \n", nid);
+ return -EINVAL;
+ }
+
+ spec->cvt[spec->num_cvts] = nid;
+ spec->num_cvts++;
+
+ return 0;
+}
+
+static int intel_hdmi_parse_codec(struct hda_codec *codec)
+{
+ hda_nid_t nid;
+ int i, nodes;
+
+ nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
+ if (!nid || nodes < 0) {
+ snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n");
+ return -EINVAL;
+ }
+
+ for (i = 0; i < nodes; i++, nid++) {
+ unsigned int caps;
+ unsigned int type;
+
+ caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);
+ type = get_wcaps_type(caps);
+
+ if (!(caps & AC_WCAP_DIGITAL))
+ continue;
+
+ switch (type) {
+ case AC_WID_AUD_OUT:
+ if (intel_hdmi_add_cvt(codec, nid) < 0)
+ return -EINVAL;
+ break;
+ case AC_WID_PIN:
+ caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
+ if (!(caps & AC_PINCAP_HDMI))
+ continue;
+ if (intel_hdmi_add_pin(codec, nid) < 0)
+ return -EINVAL;
+ break;
+ }
+ }
+
+ return 0;
+}
+
/*
* HDMI routines
*/
@@ -756,8 +867,15 @@ static int do_patch_intel_hdmi(struct hd
if (spec == NULL)
return -ENOMEM;
- *spec = static_specs[spec_id];
codec->spec = spec;
+ if (intel_hdmi_parse_codec(codec) < 0) {
+ codec->spec = NULL;
+ kfree(spec);
+ return -EINVAL;
+ }
+ if (memcmp(spec, static_specs + spec_id, sizeof(*spec)))
+ snd_printk(KERN_WARNING
+ "HDMI: auto parse disagree with known config\n");
codec->patch_ops = intel_hdmi_patch_ops;
for (i = 0; i < spec->num_pins; i++)
next prev parent reply other threads:[~2009-10-15 7:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-15 7:03 [PATCH 00/11] Intel IbexPeak HDMI codec support Wu Fengguang
2009-10-15 7:03 ` [PATCH 01/11] hda - select IbexPeak handler for Calpella Wu Fengguang
2009-10-15 7:03 ` [PATCH 02/11] hda - vectorize get_empty_pcm_device() Wu Fengguang
2009-10-15 7:03 ` [PATCH 03/11] hda - allow up to 4 HDMI devices Wu Fengguang
2009-10-15 7:03 ` [PATCH 04/11] hda - convert intelhdmi global references to local parameters Wu Fengguang
2009-10-15 7:03 ` [PATCH 05/11] hda - remove intelhdmi dependency on multiout Wu Fengguang
2009-10-15 7:03 ` [PATCH 06/11] hda - use pcm prepare/cleanup callbacks for intelhdmi Wu Fengguang
2009-10-15 7:03 ` [PATCH 07/11] hda - reorder intelhdmi prepare/cleanup callbacks Wu Fengguang
2009-10-15 7:03 ` [PATCH 08/11] hda - vectorize intelhdmi Wu Fengguang
2009-10-15 7:03 ` [PATCH 09/11] hda - get intelhdmi max channels from widget caps Wu Fengguang
2009-10-15 7:03 ` Wu Fengguang [this message]
2009-10-15 7:03 ` [PATCH 11/11] hda - remove static intelhdmi configurations Wu Fengguang
2009-10-30 10:47 ` [PATCH 00/11] Intel IbexPeak HDMI codec support Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091015070919.069338242@intel.com \
--to=fengguang.wu@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox