From baa1d678d44a9dda7176866bfa050250b80d44fb Mon Sep 17 00:00:00 2001
From: Daniel Chen <crimsun@Box.ncat.edu>
Date: Thu, 31 May 2007 21:44:26 -0400
Subject: [PATCH] [PATCH] sound/pci/hda/: Fix detection of audio codec on some SB450-based devices (hda_intel.c)
Bug: 83015
Bug: 88570
Bug: 89889
Bug: 118169

Status: Merged in alsa-kernel hg

This changeset is the second of four necessary portions to fix the
above bugs.  The rationale from Takashi Iwai is that some SB450-based
devices have inverted audio and modem codec slots (where the former
appears after the latter ordinally), so the code needs to continue to
probe when no audio codec is present.

Signed-off-by: Daniel T Chen <crimsun@ubuntu.com>
---
 sound/pci/hda/hda_intel.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index d8c9e90..bae2536 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -979,7 +979,7 @@ static unsigned int azx_max_codecs[] __devinitdata = {
 static int __devinit azx_codec_create(struct azx *chip, const char *model)
 {
 	struct hda_bus_template bus_temp;
-	int c, codecs, err;
+	int c, codecs, audio_codecs, err;
 
 	memset(&bus_temp, 0, sizeof(bus_temp));
 	bus_temp.private_data = chip;
@@ -991,16 +991,19 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model)
 	if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0)
 		return err;
 
-	codecs = 0;
+	codecs = audio_codecs = 0;
 	for (c = 0; c < AZX_MAX_CODECS; c++) {
 		if ((chip->codec_mask & (1 << c)) & probe_mask) {
-			err = snd_hda_codec_new(chip->bus, c, NULL);
+			struct hda_codec *codec;
+			err = snd_hda_codec_new(chip->bus, c, &codec);
 			if (err < 0)
 				continue;
 			codecs++;
+			if (codec->afg)
+				audio_codecs++;
 		}
 	}
-	if (!codecs) {
+	if (!audio_codecs) {
 		/* probe additional slots if no codec is found */
 		for (; c < azx_max_codecs[chip->driver_type]; c++) {
 			if ((chip->codec_mask & (1 << c)) & probe_mask) {
-- 
1.5.2

