All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hda: Added mono mux mixer for some STAC92HD7XXX family codecs
@ 2008-01-18 21:44 Matthew Ranostay
  2008-01-19  9:40 ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Matthew Ranostay @ 2008-01-18 21:44 UTC (permalink / raw)
  To: alsa-devel; +Cc: Takashi Iwai

Some 92HD7XXX family codecs have a mono mux, added support for selecting the input path to the mono out.

Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
---
diff -r a035d5e4801c pci/hda/patch_sigmatel.c
--- a/pci/hda/patch_sigmatel.c	Fri Jan 18 15:32:32 2008 +0100
+++ b/pci/hda/patch_sigmatel.c	Fri Jan 18 14:53:36 2008 -0500
@@ -131,6 +131,8 @@ struct sigmatel_spec {
 	hda_nid_t *pwr_nids;
 
 	/* playback */
+	struct hda_input_mux *mono_mux;
+	unsigned int cur_mmux;
 	struct hda_multi_out multiout;
 	hda_nid_t dac_nids[5];
 
@@ -144,6 +146,7 @@ struct sigmatel_spec {
 	hda_nid_t *dmux_nids;
 	unsigned int num_dmuxes;
 	hda_nid_t dig_in_nid;
+	hda_nid_t mono_nid;
 
 	/* pin widgets */
 	hda_nid_t *pin_nids;
@@ -399,6 +402,31 @@ static int stac92xx_mux_enum_put(struct 
 
 	return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
 				     spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
+}
+
+static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct sigmatel_spec *spec = codec->spec;
+	return snd_hda_input_mux_info(spec->mono_mux, uinfo);
+}
+
+static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct sigmatel_spec *spec = codec->spec;
+
+	ucontrol->value.enumerated.item[0] = spec->cur_mmux;
+	return 0;
+}
+
+static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct sigmatel_spec *spec = codec->spec;
+
+	return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
+				     spec->mono_nid, &spec->cur_mmux);
 }
 
 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
@@ -603,6 +631,16 @@ static struct hda_verb stac9205_core_ini
 	{}
 };
 
+#define STAC_MONO_MUX \
+	{ \
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+		.name = "Mono Mux", \
+		.count = 1, \
+		.info = stac92xx_mono_mux_enum_info, \
+		.get = stac92xx_mono_mux_enum_get, \
+		.put = stac92xx_mono_mux_enum_put, \
+	}
+
 #define STAC_INPUT_SOURCE(cnt) \
 	{ \
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -714,6 +752,7 @@ static struct snd_kcontrol_new stac92hd7
 
 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
 	STAC_INPUT_SOURCE(2),
+	STAC_MONO_MUX,
 
 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
@@ -733,6 +772,7 @@ static struct snd_kcontrol_new stac92hd7
 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
 	STAC_INPUT_SOURCE(2),
 	STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
+	STAC_MONO_MUX,
 
 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
@@ -1180,7 +1220,7 @@ static struct snd_pci_quirk stac92hd73xx
 
 static unsigned int ref92hd71bxx_pin_configs[10] = {
 	0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
-	0x0181302e, 0x01114010, 0x01a19020, 0x90a000f0,
+	0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
 	0x90a000f0, 0x01452050,
 };
 
@@ -3188,6 +3228,16 @@ again:
 	return 0;
 }
 
+static struct hda_input_mux stac92hd71bxx_mono_mux = {
+	/* count set later */
+	.items = {
+		{ "DAC0",  0x0 },
+		{ "DAC1",  0x1 },
+		/* not an option on all cards */
+		{ "Mixer", 0x2 },
+	 },
+};
+
 static int patch_stac92hd71bxx(struct hda_codec *codec)
 {
 	struct sigmatel_spec *spec;
@@ -3224,10 +3274,12 @@ again:
 	case 0x111d76b7:
 	case 0x111d76b4: /* 6 Port without Analog Mixer */
 	case 0x111d76b5:
+		stac92hd71bxx_mono_mux.num_items = 2,
 		spec->mixer = stac92hd71bxx_mixer;
 		spec->init = stac92hd71bxx_core_init;
 		break;
 	default:
+		stac92hd71bxx_mono_mux.num_items = 3,
 		spec->mixer = stac92hd71bxx_analog_mixer;
 		spec->init = stac92hd71bxx_analog_core_init;
 	}
@@ -3237,6 +3289,8 @@ again:
 
 	spec->gpio_mask = spec->gpio_data = 0x00000001; /* GPIO0 High = EAPD */
 
+	spec->mono_mux = &stac92hd71bxx_mono_mux;
+	spec->mono_nid = 0x15;
 	spec->mux_nids = stac92hd71bxx_mux_nids;
 	spec->adc_nids = stac92hd71bxx_adc_nids;
 	spec->dmic_nids = stac92hd71bxx_dmic_nids;

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

* Re: [PATCH] hda: Added mono mux mixer for some STAC92HD7XXX family codecs
  2008-01-18 21:44 [PATCH] hda: Added mono mux mixer for some STAC92HD7XXX family codecs Matthew Ranostay
@ 2008-01-19  9:40 ` Takashi Iwai
  2008-01-21 13:58   ` Matthew Ranostay
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2008-01-19  9:40 UTC (permalink / raw)
  To: Matthew Ranostay; +Cc: alsa-devel

At Fri, 18 Jan 2008 16:44:42 -0500,
Matthew Ranostay wrote:
> 
> Some 92HD7XXX family codecs have a mono mux, added support for selecting the input path to the mono out.
> 
> Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>

Could you fix the coding-style issues reported by checkpatch.pl?

> +static struct hda_input_mux stac92hd71bxx_mono_mux = {
> +	/* count set later */

This is a bit dangerous.  In theory, we may have several hd-audio
instances, e.g. an on-board and a graphic card.  The local common
variable may conflict between two instances.  Rather copy the whole
input_mux to spec, and modify locally.


thanks,

Takashi

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

* Re: [PATCH] hda: Added mono mux mixer for some STAC92HD7XXX family codecs
  2008-01-19  9:40 ` Takashi Iwai
@ 2008-01-21 13:58   ` Matthew Ranostay
  2008-01-21 14:11     ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Matthew Ranostay @ 2008-01-21 13:58 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Takashi Iwai wrote:
> At Fri, 18 Jan 2008 16:44:42 -0500,
> Matthew Ranostay wrote:
>> Some 92HD7XXX family codecs have a mono mux, added support for selecting the input path to the mono out.
>>
>> Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
> 
> Could you fix the coding-style issues reported by checkpatch.pl?
Ok, fixed the 80-character lines it complained about, although I left the 'declaration in if statement' since
the code block below it does the same style.
> 
>> +static struct hda_input_mux stac92hd71bxx_mono_mux = {
>> +	/* count set later */
> 
> This is a bit dangerous.  In theory, we may have several hd-audio
> instances, e.g. an on-board and a graphic card.  The local common
> variable may conflict between two instances.  Rather copy the whole
> input_mux to spec, and modify locally.
> 
Thanks Takashi for spotting this.
Ok I can't believe I didn't notice this.
> 
> thanks,
> 
> Takashi
> 


Some 92HD7XXX family codecs have a mono mux, added support for selecting the input path to the mono out.
Creates a dynamic mixer based on connection count of the mono-out nid.

Signed-off-by: Matthew Ranostay <mranostay@embededdalley.com>
---
diff -r a035d5e4801c pci/hda/patch_sigmatel.c
--- a/pci/hda/patch_sigmatel.c	Fri Jan 18 15:32:32 2008 +0100
+++ b/pci/hda/patch_sigmatel.c	Sun Jan 20 15:19:33 2008 -0500
@@ -131,6 +131,8 @@ struct sigmatel_spec {
 	hda_nid_t *pwr_nids;
 
 	/* playback */
+	struct hda_input_mux *mono_mux;
+	unsigned int cur_mmux;
 	struct hda_multi_out multiout;
 	hda_nid_t dac_nids[5];
 
@@ -144,6 +146,7 @@ struct sigmatel_spec {
 	hda_nid_t *dmux_nids;
 	unsigned int num_dmuxes;
 	hda_nid_t dig_in_nid;
+	hda_nid_t mono_nid;
 
 	/* pin widgets */
 	hda_nid_t *pin_nids;
@@ -174,6 +177,7 @@ struct sigmatel_spec {
 	struct snd_kcontrol_new *kctl_alloc;
 	struct hda_input_mux private_dimux;
 	struct hda_input_mux private_imux;
+	struct hda_input_mux private_mono_mux;
 
 	/* virtual master */
 	unsigned int vmaster_tlv[4];
@@ -399,6 +403,34 @@ static int stac92xx_mux_enum_put(struct 
 
 	return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
 				     spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
+}
+
+static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
+	struct snd_ctl_elem_info *uinfo)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct sigmatel_spec *spec = codec->spec;
+	return snd_hda_input_mux_info(spec->mono_mux, uinfo);
+}
+
+static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
+	struct snd_ctl_elem_value *ucontrol)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct sigmatel_spec *spec = codec->spec;
+
+	ucontrol->value.enumerated.item[0] = spec->cur_mmux;
+	return 0;
+}
+
+static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
+	struct snd_ctl_elem_value *ucontrol)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct sigmatel_spec *spec = codec->spec;
+
+	return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
+				     spec->mono_nid, &spec->cur_mmux);
 }
 
 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
@@ -603,6 +635,16 @@ static struct hda_verb stac9205_core_ini
 	{}
 };
 
+#define STAC_MONO_MUX \
+	{ \
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+		.name = "Mono Mux", \
+		.count = 1, \
+		.info = stac92xx_mono_mux_enum_info, \
+		.get = stac92xx_mono_mux_enum_get, \
+		.put = stac92xx_mono_mux_enum_put, \
+	}
+
 #define STAC_INPUT_SOURCE(cnt) \
 	{ \
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -714,6 +756,7 @@ static struct snd_kcontrol_new stac92hd7
 
 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
 	STAC_INPUT_SOURCE(2),
+	STAC_MONO_MUX,
 
 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
@@ -733,6 +776,7 @@ static struct snd_kcontrol_new stac92hd7
 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
 	STAC_INPUT_SOURCE(2),
 	STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
+	STAC_MONO_MUX,
 
 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
@@ -1180,7 +1224,7 @@ static struct snd_pci_quirk stac92hd73xx
 
 static unsigned int ref92hd71bxx_pin_configs[10] = {
 	0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
-	0x0181302e, 0x01114010, 0x01a19020, 0x90a000f0,
+	0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
 	0x90a000f0, 0x01452050,
 };
 
@@ -2318,6 +2362,35 @@ static int stac92xx_auto_create_hp_ctls(
 	return 0;
 }
 
+/* labels for mono mux outputs */
+static const char *stac92xx_mono_labels[3] = {
+	"DAC0", "DAC1", "Mixer"
+};
+
+/* create mono mux for mono out on capable codecs */
+static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
+{
+	struct sigmatel_spec *spec = codec->spec;
+	struct hda_input_mux *mono_mux = &spec->private_mono_mux;
+	int i, num_cons;
+	hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
+
+	num_cons = snd_hda_get_connections(codec,
+				spec->mono_nid,
+				con_lst,
+				HDA_MAX_NUM_INPUTS);
+	if (!num_cons)
+		return -EINVAL;
+
+	for (i = 0; i < num_cons; i++) {
+		mono_mux->items[mono_mux->num_items].label =
+					stac92xx_mono_labels[i];
+		mono_mux->items[mono_mux->num_items].index = i;
+		mono_mux->num_items++;
+	}
+	return 0;
+}
+
 /* labels for dmic mux inputs */
 static const char *stac92xx_dmic_labels[5] = {
 	"Analog Inputs", "Digital Mic 1", "Digital Mic 2",
@@ -2532,6 +2605,10 @@ static int stac92xx_parse_auto_config(st
 	if (err < 0)
 		return err;
 
+	if (spec->mono_nid > 0)
+		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0)
+			return err;
+
 	if (spec->num_dmics > 0)
 		if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
 						&spec->autocfg)) < 0)
@@ -2552,6 +2629,7 @@ static int stac92xx_parse_auto_config(st
 	spec->input_mux = &spec->private_imux;
 	if (!spec->dinput_mux)
 		spec->dinput_mux = &spec->private_dimux;
+	spec->mono_mux = &spec->private_mono_mux;
 
 	return 1;
 }
@@ -3237,6 +3315,7 @@ again:
 
 	spec->gpio_mask = spec->gpio_data = 0x00000001; /* GPIO0 High = EAPD */
 
+	spec->mono_nid = 0x15;
 	spec->mux_nids = stac92hd71bxx_mux_nids;
 	spec->adc_nids = stac92hd71bxx_adc_nids;
 	spec->dmic_nids = stac92hd71bxx_dmic_nids;

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

* Re: [PATCH] hda: Added mono mux mixer for some STAC92HD7XXX family codecs
  2008-01-21 13:58   ` Matthew Ranostay
@ 2008-01-21 14:11     ` Takashi Iwai
  2008-01-21 14:14       ` Matthew Ranostay
  2008-01-21 14:45       ` Matthew Ranostay
  0 siblings, 2 replies; 8+ messages in thread
From: Takashi Iwai @ 2008-01-21 14:11 UTC (permalink / raw)
  To: Matthew Ranostay; +Cc: alsa-devel

At Mon, 21 Jan 2008 08:58:52 -0500,
Matthew Ranostay wrote:
> 
> Takashi Iwai wrote:
> > At Fri, 18 Jan 2008 16:44:42 -0500,
> > Matthew Ranostay wrote:
> >> Some 92HD7XXX family codecs have a mono mux, added support for selecting the input path to the mono out.
> >>
> >> Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
> > 
> > Could you fix the coding-style issues reported by checkpatch.pl?
> Ok, fixed the 80-character lines it complained about, although I left the 'declaration in if statement' since
> the code block below it does the same style.

Well, apprently you didn't run checkpatch.pl to the new patch? ;)

ERROR: do not use assignment in if condition (+		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0))
#224: FILE: pci/hda/patch_sigmatel.c:2609:
+		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0)

total: 1 errors, 0 warnings, 153 lines checked


Takashi

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

* Re: [PATCH] hda: Added mono mux mixer for some STAC92HD7XXX family codecs
  2008-01-21 14:11     ` Takashi Iwai
@ 2008-01-21 14:14       ` Matthew Ranostay
  2008-01-21 14:19         ` Takashi Iwai
  2008-01-21 14:45       ` Matthew Ranostay
  1 sibling, 1 reply; 8+ messages in thread
From: Matthew Ranostay @ 2008-01-21 14:14 UTC (permalink / raw)
  To: Takashi Iwai, alsa-devel

Takashi Iwai wrote:
> At Mon, 21 Jan 2008 08:58:52 -0500,
> Matthew Ranostay wrote:
>> Takashi Iwai wrote:
>>> At Fri, 18 Jan 2008 16:44:42 -0500,
>>> Matthew Ranostay wrote:
>>>> Some 92HD7XXX family codecs have a mono mux, added support for selecting the input path to the mono out.
>>>>
>>>> Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
>>> Could you fix the coding-style issues reported by checkpatch.pl?
>> Ok, fixed the 80-character lines it complained about, although I left the 'declaration in if statement' since
>> the code block below it does the same style.
> 
> Well, apprently you didn't run checkpatch.pl to the new patch? ;)
> 
> ERROR: do not use assignment in if condition (+		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0))
> #224: FILE: pci/hda/patch_sigmatel.c:2609:
> +		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0)
> 
I did but I didn't change it because the line below it does the same coding style.
But in that case I'll change both :)
> total: 1 errors, 0 warnings, 153 lines checked
> 
> 
> Takashi
> 

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

* Re: [PATCH] hda: Added mono mux mixer for some STAC92HD7XXX family codecs
  2008-01-21 14:14       ` Matthew Ranostay
@ 2008-01-21 14:19         ` Takashi Iwai
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2008-01-21 14:19 UTC (permalink / raw)
  To: Matthew Ranostay; +Cc: alsa-devel

At Mon, 21 Jan 2008 09:14:26 -0500,
Matthew Ranostay wrote:
> 
> Takashi Iwai wrote:
> > At Mon, 21 Jan 2008 08:58:52 -0500,
> > Matthew Ranostay wrote:
> >> Takashi Iwai wrote:
> >>> At Fri, 18 Jan 2008 16:44:42 -0500,
> >>> Matthew Ranostay wrote:
> >>>> Some 92HD7XXX family codecs have a mono mux, added support for selecting the input path to the mono out.
> >>>>
> >>>> Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
> >>> Could you fix the coding-style issues reported by checkpatch.pl?
> >> Ok, fixed the 80-character lines it complained about, although I left the 'declaration in if statement' since
> >> the code block below it does the same style.
> > 
> > Well, apprently you didn't run checkpatch.pl to the new patch? ;)
> > 
> > ERROR: do not use assignment in if condition (+		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0))
> > #224: FILE: pci/hda/patch_sigmatel.c:2609:
> > +		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0)
> > 
> I did but I didn't change it because the line below it does the same coding style.
> But in that case I'll change both :)

Do it only for your own part at first.  Then let's clean up the whole
file later so that we can separate changes, one for a bug fix, and one
for trivial coding style fixes.


thanks,

Takashi

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

* Re: [PATCH] hda: Added mono mux mixer for some STAC92HD7XXX family codecs
  2008-01-21 14:11     ` Takashi Iwai
  2008-01-21 14:14       ` Matthew Ranostay
@ 2008-01-21 14:45       ` Matthew Ranostay
  2008-01-21 14:59         ` Takashi Iwai
  1 sibling, 1 reply; 8+ messages in thread
From: Matthew Ranostay @ 2008-01-21 14:45 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Takashi Iwai wrote:
> At Mon, 21 Jan 2008 08:58:52 -0500,
> Matthew Ranostay wrote:
>> Takashi Iwai wrote:
>>> At Fri, 18 Jan 2008 16:44:42 -0500,
>>> Matthew Ranostay wrote:
>>>> Some 92HD7XXX family codecs have a mono mux, added support for selecting the input path to the mono out.
>>>>
>>>> Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
>>> Could you fix the coding-style issues reported by checkpatch.pl?
>> Ok, fixed the 80-character lines it complained about, although I left the 'declaration in if statement' since
>> the code block below it does the same style.
> 
> Well, apprently you didn't run checkpatch.pl to the new patch? ;)
> 
> ERROR: do not use assignment in if condition (+		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0))
> #224: FILE: pci/hda/patch_sigmatel.c:2609:
> +		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0)
> 
Ok fixed this line and the DMIC block below it. Hopefully this the last time I have to submit this :)

> total: 1 errors, 0 warnings, 153 lines checked
> 
> 
> Takashi
> 

Some 92HD7XXX family codecs have a mono mux, added support for selecting the input path to the mono out.
Creates a dynamic mixer based on connection count of the mono-out nid.

Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
---
diff -r a035d5e4801c pci/hda/patch_sigmatel.c
--- a/pci/hda/patch_sigmatel.c	Fri Jan 18 15:32:32 2008 +0100
+++ b/pci/hda/patch_sigmatel.c	Mon Jan 21 09:26:03 2008 -0500
@@ -131,6 +131,8 @@ struct sigmatel_spec {
 	hda_nid_t *pwr_nids;
 
 	/* playback */
+	struct hda_input_mux *mono_mux;
+	unsigned int cur_mmux;
 	struct hda_multi_out multiout;
 	hda_nid_t dac_nids[5];
 
@@ -144,6 +146,7 @@ struct sigmatel_spec {
 	hda_nid_t *dmux_nids;
 	unsigned int num_dmuxes;
 	hda_nid_t dig_in_nid;
+	hda_nid_t mono_nid;
 
 	/* pin widgets */
 	hda_nid_t *pin_nids;
@@ -174,6 +177,7 @@ struct sigmatel_spec {
 	struct snd_kcontrol_new *kctl_alloc;
 	struct hda_input_mux private_dimux;
 	struct hda_input_mux private_imux;
+	struct hda_input_mux private_mono_mux;
 
 	/* virtual master */
 	unsigned int vmaster_tlv[4];
@@ -399,6 +403,34 @@ static int stac92xx_mux_enum_put(struct 
 
 	return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
 				     spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
+}
+
+static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
+	struct snd_ctl_elem_info *uinfo)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct sigmatel_spec *spec = codec->spec;
+	return snd_hda_input_mux_info(spec->mono_mux, uinfo);
+}
+
+static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
+	struct snd_ctl_elem_value *ucontrol)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct sigmatel_spec *spec = codec->spec;
+
+	ucontrol->value.enumerated.item[0] = spec->cur_mmux;
+	return 0;
+}
+
+static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
+	struct snd_ctl_elem_value *ucontrol)
+{
+	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct sigmatel_spec *spec = codec->spec;
+
+	return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
+				     spec->mono_nid, &spec->cur_mmux);
 }
 
 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
@@ -603,6 +635,16 @@ static struct hda_verb stac9205_core_ini
 	{}
 };
 
+#define STAC_MONO_MUX \
+	{ \
+		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+		.name = "Mono Mux", \
+		.count = 1, \
+		.info = stac92xx_mono_mux_enum_info, \
+		.get = stac92xx_mono_mux_enum_get, \
+		.put = stac92xx_mono_mux_enum_put, \
+	}
+
 #define STAC_INPUT_SOURCE(cnt) \
 	{ \
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -714,6 +756,7 @@ static struct snd_kcontrol_new stac92hd7
 
 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
 	STAC_INPUT_SOURCE(2),
+	STAC_MONO_MUX,
 
 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
@@ -733,6 +776,7 @@ static struct snd_kcontrol_new stac92hd7
 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
 	STAC_INPUT_SOURCE(2),
 	STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
+	STAC_MONO_MUX,
 
 	HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
 	HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
@@ -1180,7 +1224,7 @@ static struct snd_pci_quirk stac92hd73xx
 
 static unsigned int ref92hd71bxx_pin_configs[10] = {
 	0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
-	0x0181302e, 0x01114010, 0x01a19020, 0x90a000f0,
+	0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
 	0x90a000f0, 0x01452050,
 };
 
@@ -2318,6 +2362,35 @@ static int stac92xx_auto_create_hp_ctls(
 	return 0;
 }
 
+/* labels for mono mux outputs */
+static const char *stac92xx_mono_labels[3] = {
+	"DAC0", "DAC1", "Mixer"
+};
+
+/* create mono mux for mono out on capable codecs */
+static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
+{
+	struct sigmatel_spec *spec = codec->spec;
+	struct hda_input_mux *mono_mux = &spec->private_mono_mux;
+	int i, num_cons;
+	hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
+
+	num_cons = snd_hda_get_connections(codec,
+				spec->mono_nid,
+				con_lst,
+				HDA_MAX_NUM_INPUTS);
+	if (!num_cons)
+		return -EINVAL;
+
+	for (i = 0; i < num_cons; i++) {
+		mono_mux->items[mono_mux->num_items].label =
+					stac92xx_mono_labels[i];
+		mono_mux->items[mono_mux->num_items].index = i;
+		mono_mux->num_items++;
+	}
+	return 0;
+}
+
 /* labels for dmic mux inputs */
 static const char *stac92xx_dmic_labels[5] = {
 	"Analog Inputs", "Digital Mic 1", "Digital Mic 2",
@@ -2532,10 +2605,18 @@ static int stac92xx_parse_auto_config(st
 	if (err < 0)
 		return err;
 
-	if (spec->num_dmics > 0)
-		if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
-						&spec->autocfg)) < 0)
+	if (spec->mono_nid > 0) {
+		err = stac92xx_auto_create_mono_output_ctls(codec);
+		if (err < 0)
 			return err;
+	}
+
+	if (spec->num_dmics > 0) {
+		err = stac92xx_auto_create_dmic_input_ctls(codec,
+						&spec->autocfg);
+		if (err < 0)
+			return err;
+	}
 
 	spec->multiout.max_channels = spec->multiout.num_dacs * 2;
 	if (spec->multiout.max_channels > 2)
@@ -2552,6 +2633,7 @@ static int stac92xx_parse_auto_config(st
 	spec->input_mux = &spec->private_imux;
 	if (!spec->dinput_mux)
 		spec->dinput_mux = &spec->private_dimux;
+	spec->mono_mux = &spec->private_mono_mux;
 
 	return 1;
 }
@@ -3237,6 +3319,7 @@ again:
 
 	spec->gpio_mask = spec->gpio_data = 0x00000001; /* GPIO0 High = EAPD */
 
+	spec->mono_nid = 0x15;
 	spec->mux_nids = stac92hd71bxx_mux_nids;
 	spec->adc_nids = stac92hd71bxx_adc_nids;
 	spec->dmic_nids = stac92hd71bxx_dmic_nids;

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

* Re: [PATCH] hda: Added mono mux mixer for some STAC92HD7XXX family codecs
  2008-01-21 14:45       ` Matthew Ranostay
@ 2008-01-21 14:59         ` Takashi Iwai
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2008-01-21 14:59 UTC (permalink / raw)
  To: Matthew Ranostay; +Cc: alsa-devel

At Mon, 21 Jan 2008 09:45:02 -0500,
Matthew Ranostay wrote:
> 
> Takashi Iwai wrote:
> > At Mon, 21 Jan 2008 08:58:52 -0500,
> > Matthew Ranostay wrote:
> >> Takashi Iwai wrote:
> >>> At Fri, 18 Jan 2008 16:44:42 -0500,
> >>> Matthew Ranostay wrote:
> >>>> Some 92HD7XXX family codecs have a mono mux, added support for selecting the input path to the mono out.
> >>>>
> >>>> Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
> >>> Could you fix the coding-style issues reported by checkpatch.pl?
> >> Ok, fixed the 80-character lines it complained about, although I left the 'declaration in if statement' since
> >> the code block below it does the same style.
> > 
> > Well, apprently you didn't run checkpatch.pl to the new patch? ;)
> > 
> > ERROR: do not use assignment in if condition (+		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0))
> > #224: FILE: pci/hda/patch_sigmatel.c:2609:
> > +		if ((err = stac92xx_auto_create_mono_output_ctls(codec)) < 0)
> > 
> Ok fixed this line and the DMIC block below it. Hopefully this the last time I have to submit this :)

Thanks, but right now I found another thing...

> @@ -2318,6 +2362,35 @@ static int stac92xx_auto_create_hp_ctls(
>  	return 0;
>  }
>  
> +/* labels for mono mux outputs */
> +static const char *stac92xx_mono_labels[3] = {
> +	"DAC0", "DAC1", "Mixer"
> +};
> +
> +/* create mono mux for mono out on capable codecs */
> +static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
> +{
> +	struct sigmatel_spec *spec = codec->spec;
> +	struct hda_input_mux *mono_mux = &spec->private_mono_mux;
> +	int i, num_cons;
> +	hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
> +
> +	num_cons = snd_hda_get_connections(codec,
> +				spec->mono_nid,
> +				con_lst,
> +				HDA_MAX_NUM_INPUTS);
> +	if (!num_cons)
> +		return -EINVAL;
> +
> +	for (i = 0; i < num_cons; i++) {
> +		mono_mux->items[mono_mux->num_items].label =
> +					stac92xx_mono_labels[i];

num_cons could be over 3.  Better to add a check here.


Takashi

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

end of thread, other threads:[~2008-01-21 14:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-18 21:44 [PATCH] hda: Added mono mux mixer for some STAC92HD7XXX family codecs Matthew Ranostay
2008-01-19  9:40 ` Takashi Iwai
2008-01-21 13:58   ` Matthew Ranostay
2008-01-21 14:11     ` Takashi Iwai
2008-01-21 14:14       ` Matthew Ranostay
2008-01-21 14:19         ` Takashi Iwai
2008-01-21 14:45       ` Matthew Ranostay
2008-01-21 14:59         ` 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.