alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: David Henningsson <david.henningsson@canonical.com>
To: tiwai@suse.de, alsa-devel@alsa-project.org
Cc: David Henningsson <david.henningsson@canonical.com>
Subject: [PATCH 3/3] ALSA: hda - Don't add unnecessary indices on HDMI and SPDIF
Date: Fri, 18 Jan 2013 15:43:03 +0100	[thread overview]
Message-ID: <1358520183-2908-4-git-send-email-david.henningsson@canonical.com> (raw)
In-Reply-To: <1358520183-2908-1-git-send-email-david.henningsson@canonical.com>

If there's one each of HDMI and SPDIF, we should not add an index
on the one that comes second.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
 sound/pci/hda/hda_auto_parser.c |   22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c
index a4810c7..dcb6575 100644
--- a/sound/pci/hda/hda_auto_parser.c
+++ b/sound/pci/hda/hda_auto_parser.c
@@ -603,6 +603,7 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
 	unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
 	const char *name = NULL;
 	int i;
+	bool hdmi;
 
 	if (indexp)
 		*indexp = 0;
@@ -621,16 +622,17 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
 					   label, maxlen, indexp);
 	case AC_JACK_SPDIF_OUT:
 	case AC_JACK_DIG_OTHER_OUT:
-		if (get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI)
-			name = "HDMI";
-		else
-			name = "SPDIF";
-		if (cfg && indexp) {
-			i = find_idx_in_nid_list(nid, cfg->dig_out_pins,
-						 cfg->dig_outs);
-			if (i >= 0)
-				*indexp = i;
-		}
+		hdmi = get_defcfg_location(def_conf) == AC_JACK_LOC_HDMI;
+		name = hdmi ? "HDMI" : "SPDIF";
+		if (cfg && indexp)
+			for (i = 0; i < cfg->dig_outs; i++) {
+				unsigned int c;
+				if (cfg->dig_out_pins[i] == nid)
+					break;
+				c = snd_hda_codec_get_pincfg(codec, cfg->dig_out_pins[i]);
+				if (hdmi == (get_defcfg_location(c) == AC_JACK_LOC_HDMI))
+					(*indexp)++;
+			}
 		break;
 	default:
 		if (cfg) {
-- 
1.7.9.5

  parent reply	other threads:[~2013-01-18 14:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-18 14:43 [PATCH 0/3] You guessed it, it's generic parser patches David Henningsson
2013-01-18 14:43 ` [PATCH 1/3] ALSA: hda - make sure there are enough input labels and paths David Henningsson
2013-01-18 14:43 ` [PATCH 2/3] ALSA: hda - don't compare with yourself in fill_input_pin_labels David Henningsson
2013-01-18 14:43 ` David Henningsson [this message]
2013-01-18 15:31 ` [PATCH 0/3] You guessed it, it's generic parser patches 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=1358520183-2908-4-git-send-email-david.henningsson@canonical.com \
    --to=david.henningsson@canonical.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;
as well as URLs for NNTP newsgroup(s).