ALSA: hda - Pass errors properly in alc_auto_check_switches()

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2012-11-30 08:31:30 +01:00
parent 668d1e9673
commit 475c3d21e8
1 changed files with 37 additions and 22 deletions

View File

@ -930,12 +930,12 @@ static int alc_add_automute_mode_enum(struct hda_codec *codec)
* Check the availability of HP/line-out auto-mute; * Check the availability of HP/line-out auto-mute;
* Set up appropriately if really supported * Set up appropriately if really supported
*/ */
static void alc_init_automute(struct hda_codec *codec) static int alc_init_automute(struct hda_codec *codec)
{ {
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
struct auto_pin_cfg *cfg = &spec->autocfg; struct auto_pin_cfg *cfg = &spec->autocfg;
int present = 0; int present = 0;
int i; int i, err;
if (cfg->hp_pins[0]) if (cfg->hp_pins[0])
present++; present++;
@ -944,7 +944,7 @@ static void alc_init_automute(struct hda_codec *codec)
if (cfg->speaker_pins[0]) if (cfg->speaker_pins[0])
present++; present++;
if (present < 2) /* need two different output types */ if (present < 2) /* need two different output types */
return; return 0;
if (!cfg->speaker_pins[0] && if (!cfg->speaker_pins[0] &&
cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
@ -994,9 +994,13 @@ static void alc_init_automute(struct hda_codec *codec)
spec->automute_lo = spec->automute_lo_possible; spec->automute_lo = spec->automute_lo_possible;
spec->automute_speaker = spec->automute_speaker_possible; spec->automute_speaker = spec->automute_speaker_possible;
if (spec->automute_speaker_possible || spec->automute_lo_possible) if (spec->automute_speaker_possible || spec->automute_lo_possible) {
/* create a control for automute mode */ /* create a control for automute mode */
alc_add_automute_mode_enum(codec); err = alc_add_automute_mode_enum(codec);
if (err < 0)
return err;
}
return 0;
} }
/* return the position of NID in the list, or -1 if not found */ /* return the position of NID in the list, or -1 if not found */
@ -1096,7 +1100,7 @@ static bool alc_auto_mic_check_imux(struct hda_codec *codec)
* Check the availability of auto-mic switch; * Check the availability of auto-mic switch;
* Set up if really supported * Set up if really supported
*/ */
static void alc_init_auto_mic(struct hda_codec *codec) static int alc_init_auto_mic(struct hda_codec *codec)
{ {
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
struct auto_pin_cfg *cfg = &spec->autocfg; struct auto_pin_cfg *cfg = &spec->autocfg;
@ -1104,7 +1108,7 @@ static void alc_init_auto_mic(struct hda_codec *codec)
int i; int i;
if (spec->shared_mic_hp) if (spec->shared_mic_hp)
return; /* no auto-mic for the shared I/O */ return 0; /* no auto-mic for the shared I/O */
spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1;
@ -1116,25 +1120,25 @@ static void alc_init_auto_mic(struct hda_codec *codec)
switch (snd_hda_get_input_pin_attr(defcfg)) { switch (snd_hda_get_input_pin_attr(defcfg)) {
case INPUT_PIN_ATTR_INT: case INPUT_PIN_ATTR_INT:
if (fixed) if (fixed)
return; /* already occupied */ return 0; /* already occupied */
if (cfg->inputs[i].type != AUTO_PIN_MIC) if (cfg->inputs[i].type != AUTO_PIN_MIC)
return; /* invalid type */ return 0; /* invalid type */
fixed = nid; fixed = nid;
break; break;
case INPUT_PIN_ATTR_UNUSED: case INPUT_PIN_ATTR_UNUSED:
return; /* invalid entry */ return 0; /* invalid entry */
case INPUT_PIN_ATTR_DOCK: case INPUT_PIN_ATTR_DOCK:
if (dock) if (dock)
return; /* already occupied */ return 0; /* already occupied */
if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) if (cfg->inputs[i].type > AUTO_PIN_LINE_IN)
return; /* invalid type */ return 0; /* invalid type */
dock = nid; dock = nid;
break; break;
default: default:
if (ext) if (ext)
return; /* already occupied */ return 0; /* already occupied */
if (cfg->inputs[i].type != AUTO_PIN_MIC) if (cfg->inputs[i].type != AUTO_PIN_MIC)
return; /* invalid type */ return 0; /* invalid type */
ext = nid; ext = nid;
break; break;
} }
@ -1144,11 +1148,11 @@ static void alc_init_auto_mic(struct hda_codec *codec)
dock = 0; dock = 0;
} }
if (!ext || !fixed) if (!ext || !fixed)
return; return 0;
if (!is_jack_detectable(codec, ext)) if (!is_jack_detectable(codec, ext))
return; /* no unsol support */ return 0; /* no unsol support */
if (dock && !is_jack_detectable(codec, dock)) if (dock && !is_jack_detectable(codec, dock))
return; /* no unsol support */ return 0; /* no unsol support */
/* check imux indices */ /* check imux indices */
spec->ext_mic_pin = ext; spec->ext_mic_pin = ext;
@ -1157,17 +1161,26 @@ static void alc_init_auto_mic(struct hda_codec *codec)
spec->auto_mic = 1; spec->auto_mic = 1;
if (!alc_auto_mic_check_imux(codec)) if (!alc_auto_mic_check_imux(codec))
return; return 0;
snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
ext, fixed, dock); ext, fixed, dock);
return 0;
} }
/* check the availabilities of auto-mute and auto-mic switches */ /* check the availabilities of auto-mute and auto-mic switches */
static void alc_auto_check_switches(struct hda_codec *codec) static int alc_auto_check_switches(struct hda_codec *codec)
{ {
alc_init_automute(codec); int err;
alc_init_auto_mic(codec);
err = alc_init_automute(codec);
if (err < 0)
return err;
err = alc_init_auto_mic(codec);
if (err < 0)
return err;
return 0;
} }
/* /*
@ -4338,7 +4351,9 @@ static int alc_parse_auto_config(struct hda_codec *codec,
alc_ssid_check(codec, ssid_nids); alc_ssid_check(codec, ssid_nids);
if (!spec->no_analog) { if (!spec->no_analog) {
alc_auto_check_switches(codec); err = alc_auto_check_switches(codec);
if (err < 0)
return err;
err = alc_auto_add_mic_boost(codec); err = alc_auto_add_mic_boost(codec);
if (err < 0) if (err < 0)
return err; return err;