[alsa-devel] [PATCH] snd-hda-intel: Jack Mode changes for Sigmatel boards
Nickolas Lloyd
ultrageek.lloyd at gmail.com
Wed May 27 16:14:08 CEST 2009
Takashi Iwai wrote:
> Well, a goto loop is old-fashioned as a code in 21st century :)
>
> Also, it might be better to use auto_pin_cfg_labels[] to each unique
> control name instead of index.
> It's often more intuitive.
>
>
> Takashi
>
>
Thanks for the suggestions. Indeed, using the labels array does make it
much more intuitive.
+static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
+ hda_nid_t nid, int idx)
+{
+ int def_conf = snd_hda_codec_get_pincfg(codec, nid);
+ int control = 0;
+ struct sigmatel_spec *spec = codec->spec;
+ char name[22];
+
+ if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
+ if (stac92xx_get_vref(codec, nid) == AC_PINCTL_VREF_GRD
+ && nid == spec->line_switch)
+ control = STAC_CTL_WIDGET_IO_SWITCH;
+ else if (snd_hda_query_pin_caps(codec, nid)
+ & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
+ control = STAC_CTL_WIDGET_DC_BIAS;
+ else if (nid == spec->mic_switch)
+ control = STAC_CTL_WIDGET_IO_SWITCH;
+ }
+
+ if (control) {
+ strcpy(name, auto_pin_cfg_labels[idx]);
+ return stac92xx_add_control(codec->spec, control,
+ strcat(name, " Jack Mode"), nid);
+ }
+
+ return 0;
+}
+
One question here is if it's possible for a Line In jack to act as a Mic
Jack via the use of a DC bias.
@@ -3269,20 +3336,13 @@ static int stac92xx_auto_create_multi_ou
return err;
}
- if (spec->line_switch) {
- err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
- "Line In as Output Switch",
- spec->line_switch << 8);
- if (err < 0)
- return err;
- }
-
- if (spec->mic_switch) {
- err = stac92xx_add_control(spec, STAC_CTL_WIDGET_DC_BIAS,
- "Mic Jack Mode",
- spec->mic_switch);
- if (err < 0)
- return err;
+ for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
+ nid = cfg->input_pins[idx];
+ if (nid) {
+ err = stac92xx_add_jack_mode_control(codec, nid, idx);
+ if (err < 0)
+ return err;
+ }
Do these sections look alright? And if so, should I re-up the whole
thing? Also, is there anything else you think I should change, or any
other suggestions you have?
Thanks,
Nick
More information about the Alsa-devel
mailing list