Skip to contentSkip to conversation

hda: STAC92xx Line In/Mic as output check

PATCH In review Matthew Ranostay 2 participants 3 messages Jan 25, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hda: STAC92xx Line In/Mic as output check

This patch checks to see the Line In/Mic port have the ability to do output before creating the the control switches. The 92hd71bxx series of codecs has this issue with the port 0xe, which only allows input.

---

pci/hda/patch_sigmatel.c +26 -8
diff -r 303f894ac2a8 pci/hda/patch_sigmatel.c
@@ -2226,7 +2226,7 @@ static int stac92xx_auto_create_multi_ou
 	int i, err;
 
 	struct sigmatel_spec *spec = codec->spec;
-	unsigned int wid_caps;
+	unsigned int wid_caps, pincap;
 
 
 	for (i = 0; i < cfg->line_outs; i++) {
@@ -2262,13 +2262,31 @@ static int stac92xx_auto_create_multi_ou
 		}
 	}
 
-	if (spec->line_switch)
-		if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
-			return err;
-
-	if (spec->mic_switch)
-		if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
-			return err;
+	if (spec->line_switch) {
+		nid = cfg->input_pins[AUTO_PIN_LINE];
+		pincap = snd_hda_param_read(codec, nid,
+						AC_PAR_PIN_CAP);
+		if (pincap & AC_PINCAP_OUT) {
+			err = stac92xx_add_control(spec,
+				STAC_CTL_WIDGET_IO_SWITCH,
+				"Line In as Output Switch", nid << 8);
+			if (err < 0)
+				return err;
+		}
+	}
+
+	if (spec->mic_switch) {
+		nid = cfg->input_pins[AUTO_PIN_MIC];
+		pincap = snd_hda_param_read(codec, nid,
+						AC_PAR_PIN_CAP);
+		if (pincap & AC_PINCAP_OUT) {
+		`	err = stac92xx_add_control(spec,
+				STAC_CTL_WIDGET_IO_SWITCH,
+				"Mic as Output Switch", (nid << 8) | 1);
+			if (err < 0)
+				return err;
+		}
+	}
 
 	return 0;
 }
#1 lore raw

At Fri, 25 Jan 2008 08:43:55 -0500,

Quoted 5 lines · Matthew Ranostay

This patch checks to see the Line In/Mic port have the ability to do output before creating the the control switches. The 92hd71bxx series of codecs has this issue with the port 0xe, which only allows input.

Looks good (but it has a garbage (`) in the patch)

Anyway, applied to HG tree now. Thanks.

Takashi

Quoted 53 lines

---
diff -r 303f894ac2a8 pci/hda/patch_sigmatel.c

pci/hda/patch_sigmatel.c +26 -8
@@ -2226,7 +2226,7 @@ static int stac92xx_auto_create_multi_ou
 	int i, err;
 
 	struct sigmatel_spec *spec = codec->spec;
-	unsigned int wid_caps;
+	unsigned int wid_caps, pincap;
 
 
 	for (i = 0; i < cfg->line_outs; i++) {
@@ -2262,13 +2262,31 @@ static int stac92xx_auto_create_multi_ou
 		}
 	}
 
-	if (spec->line_switch)
-		if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
-			return err;
-
-	if (spec->mic_switch)
-		if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
-			return err;
+	if (spec->line_switch) {
+		nid = cfg->input_pins[AUTO_PIN_LINE];
+		pincap = snd_hda_param_read(codec, nid,
+						AC_PAR_PIN_CAP);
+		if (pincap & AC_PINCAP_OUT) {
+			err = stac92xx_add_control(spec,
+				STAC_CTL_WIDGET_IO_SWITCH,
+				"Line In as Output Switch", nid << 8);
+			if (err < 0)
+				return err;
+		}
+	}
+
+	if (spec->mic_switch) {
+		nid = cfg->input_pins[AUTO_PIN_MIC];
+		pincap = snd_hda_param_read(codec, nid,
+						AC_PAR_PIN_CAP);
+		if (pincap & AC_PINCAP_OUT) {
+		`	err = stac92xx_add_control(spec,
+				STAC_CTL_WIDGET_IO_SWITCH,
+				"Mic as Output Switch", (nid << 8) | 1);
+			if (err < 0)
+				return err;
+		}
+	}
 
 	return 0;
 }
#2 lore raw
Quoted 9 lines · Takashi Iwai

At Fri, 25 Jan 2008 08:43:55 -0500,

Quoted 4 lines · Matthew Ranostay

This patch checks to see the Line In/Mic port have the ability to do output before creating the the control switches. The 92hd71bxx series of codecs has this issue with the port 0xe, which only allows input.

Looks good (but it has a garbage (`) in the patch)

You certainly have a eagle-eye there :)

Quoted 60 lines

Anyway, applied to HG tree now. Thanks.

Takashi

Quoted 53 lines

---
diff -r 303f894ac2a8 pci/hda/patch_sigmatel.c

pci/hda/patch_sigmatel.c +26 -8
@@ -2226,7 +2226,7 @@ static int stac92xx_auto_create_multi_ou
 	int i, err;
 
 	struct sigmatel_spec *spec = codec->spec;
-	unsigned int wid_caps;
+	unsigned int wid_caps, pincap;
 
 
 	for (i = 0; i < cfg->line_outs; i++) {
@@ -2262,13 +2262,31 @@ static int stac92xx_auto_create_multi_ou
 		}
 	}
 
-	if (spec->line_switch)
-		if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
-			return err;
-
-	if (spec->mic_switch)
-		if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
-			return err;
+	if (spec->line_switch) {
+		nid = cfg->input_pins[AUTO_PIN_LINE];
+		pincap = snd_hda_param_read(codec, nid,
+						AC_PAR_PIN_CAP);
+		if (pincap & AC_PINCAP_OUT) {
+			err = stac92xx_add_control(spec,
+				STAC_CTL_WIDGET_IO_SWITCH,
+				"Line In as Output Switch", nid << 8);
+			if (err < 0)
+				return err;
+		}
+	}
+
+	if (spec->mic_switch) {
+		nid = cfg->input_pins[AUTO_PIN_MIC];
+		pincap = snd_hda_param_read(codec, nid,
+						AC_PAR_PIN_CAP);
+		if (pincap & AC_PINCAP_OUT) {
+		`	err = stac92xx_add_control(spec,
+				STAC_CTL_WIDGET_IO_SWITCH,
+				"Mic as Output Switch", (nid << 8) | 1);
+			if (err < 0)
+				return err;
+		}
+	}
 
 	return 0;
 }