All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hda: dynamically create capture mux contols
@ 2008-08-14 16:03 Matthew Ranostay
  2008-08-14 16:46 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Ranostay @ 2008-08-14 16:03 UTC (permalink / raw)
  To: alsa-devel; +Cc: Takashi Iwai

Dynamically create capture mux volume controls when a output amp is detected.

---
Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>

diff --git a/pci/hda/patch_sigmatel.c b/pci/hda/patch_sigmatel.c
index ff56432..621cc48 100644
--- a/pci/hda/patch_sigmatel.c
+++ b/pci/hda/patch_sigmatel.c
@@ -794,7 +794,9 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
 	STAC_INPUT_SOURCE(1),
 	HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
 	HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
+	/*
 	HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
+	*/
 	{ } /* end */
 };

@@ -908,14 +910,15 @@ static struct snd_kcontrol_new
stac92hd71bxx_analog_mixer[] = {

 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
+	/*
 	HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
+	*/

 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
-	HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
-
 	/* analog pc-beep replaced with digital beep support */
 	/*
+	HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
 	HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
 	HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
 	*/
@@ -931,11 +934,15 @@ static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {

 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
+	/*
 	HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
+	*/

 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
+	/*
 	HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
+	*/
 	{ } /* end */
 };

@@ -943,7 +950,9 @@ static struct snd_kcontrol_new stac925x_mixer[] = {
 	STAC_INPUT_SOURCE(1),
 	HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
 	HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
+	/*
 	HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
+	*/
 	{ } /* end */
 };

@@ -957,8 +966,9 @@ static struct snd_kcontrol_new stac9205_mixer[] = {

 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
+	/*
 	HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
-
+	*/
 	{ } /* end */
 };

@@ -971,7 +981,9 @@ static struct snd_kcontrol_new stac922x_mixer[] = {

 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
+	/*
 	HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
+	*/
 	{ } /* end */
 };

@@ -990,7 +1002,9 @@ static struct snd_kcontrol_new stac927x_mixer[] = {

 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
+	/*
 	HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
+	*/
 	{ } /* end */
 };

@@ -2780,6 +2794,35 @@ static int stac92xx_auto_create_beep_ctls(struct
hda_codec *codec,
 	return 0;
 }

+/* labels for mux inputs */
+static const char *stac92xx_mux_labels[4] = {
+	"Capture Mux 1", "Capture Mux 2", "Capture Mux 3",
+	"Capture Mux 4"
+};
+
+static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
+{
+	struct sigmatel_spec *spec = codec->spec;
+	int wcaps, nid, i, err = 0;
+	char name[32];
+
+	for (i = 0; i < spec->num_muxes; i++) {
+		nid = spec->mux_nids[i];
+		wcaps = get_wcaps(codec, nid);
+
+		if (wcaps & AC_WCAP_OUT_AMP) {
+			sprintf(name, "%s Capture Volume",
+				stac92xx_mux_labels[i]);
+			err = stac92xx_add_control(spec,
+				STAC_CTL_WIDGET_VOL, name,
+				HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
+			if (err < 0)
+				return err;
+		}
+	}
+	return 0;
+};
+
 /* labels for dmic mux inputs */
 static const char *stac92xx_dmic_labels[5] = {
 	"Analog Inputs", "Digital Mic 1", "Digital Mic 2",
@@ -3078,6 +3121,11 @@ static int stac92xx_parse_auto_config(struct hda_codec
*codec, hda_nid_t dig_out
 		if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
 						&spec->autocfg)) < 0)
 			return err;
+	if (spec->num_muxes > 0) {
+		err = stac92xx_auto_create_mux_input_ctls(codec);
+		if (err < 0)
+			return err;
+	}

 	spec->multiout.max_channels = spec->multiout.num_dacs * 2;
 	if (spec->multiout.max_channels > 2)

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

* Re: [PATCH] hda: dynamically create capture mux contols
  2008-08-14 16:03 [PATCH] hda: dynamically create capture mux contols Matthew Ranostay
@ 2008-08-14 16:46 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2008-08-14 16:46 UTC (permalink / raw)
  To: Matthew Ranostay; +Cc: alsa-devel

At Thu, 14 Aug 2008 12:03:32 -0400,
Matthew Ranostay wrote:
> 
> Dynamically create capture mux volume controls when a output amp is detected.
> 
> ---
> Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
> 
> diff --git a/pci/hda/patch_sigmatel.c b/pci/hda/patch_sigmatel.c
> index ff56432..621cc48 100644
> --- a/pci/hda/patch_sigmatel.c
> +++ b/pci/hda/patch_sigmatel.c
> @@ -794,7 +794,9 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
>  	STAC_INPUT_SOURCE(1),
>  	HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
>  	HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
> +	/*
>  	HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
> +	*/

Let's remove these instead of comment out.  The comment-out is good if
it could be re-added, but in this case, it shouldn't happen.

>  	{ } /* end */
>  };
> 
> @@ -908,14 +910,15 @@ static struct snd_kcontrol_new
> stac92hd71bxx_analog_mixer[] = {
> 
>  	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
>  	HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
> +	/*
>  	HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
> +	*/
> 
>  	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
>  	HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
> -	HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
> -
>  	/* analog pc-beep replaced with digital beep support */
>  	/*
> +	HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
>  	HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
>  	HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
>  	*/
> @@ -931,11 +934,15 @@ static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
> 
>  	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
>  	HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
> +	/*
>  	HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
> +	*/
> 
>  	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
>  	HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
> +	/*
>  	HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
> +	*/
>  	{ } /* end */
>  };
> 
> @@ -943,7 +950,9 @@ static struct snd_kcontrol_new stac925x_mixer[] = {
>  	STAC_INPUT_SOURCE(1),
>  	HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
>  	HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
> +	/*
>  	HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
> +	*/
>  	{ } /* end */
>  };
> 
> @@ -957,8 +966,9 @@ static struct snd_kcontrol_new stac9205_mixer[] = {
> 
>  	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
>  	HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
> +	/*
>  	HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
> -
> +	*/
>  	{ } /* end */
>  };
> 
> @@ -971,7 +981,9 @@ static struct snd_kcontrol_new stac922x_mixer[] = {
> 
>  	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
>  	HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
> +	/*
>  	HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
> +	*/
>  	{ } /* end */
>  };
> 
> @@ -990,7 +1002,9 @@ static struct snd_kcontrol_new stac927x_mixer[] = {
> 
>  	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
>  	HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
> +	/*
>  	HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
> +	*/
>  	{ } /* end */
>  };
> 
> @@ -2780,6 +2794,35 @@ static int stac92xx_auto_create_beep_ctls(struct
> hda_codec *codec,
>  	return 0;
>  }
> 
> +/* labels for mux inputs */
> +static const char *stac92xx_mux_labels[4] = {
> +	"Capture Mux 1", "Capture Mux 2", "Capture Mux 3",
> +	"Capture Mux 4"
> +};

These names are not good.  In your code, the resultant string will be
something like "Capture Mux 1 Capture Volume".  This should be
"Mux Capture Volume" to keep the compatibility (actually "Capture Mux
Volume" was wrong).

The secondary and later items should use index=1 and so.
stac92xx_add_control() should be changed as well to take the index
(or better to keep stac92xx_add_control() as is now, and make it
 calling another one, because stac92xx_add_control() is called already
 from many places.)


thanks,

Takashi

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

end of thread, other threads:[~2008-08-14 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-14 16:03 [PATCH] hda: dynamically create capture mux contols Matthew Ranostay
2008-08-14 16:46 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.