diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-11-30 02:31:30 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-11-30 05:49:02 -0500 |
commit | 475c3d21e8e1fe7cbec76b0f3e8d9f4dea66acd8 (patch) | |
tree | 5a83084d2c6da41edda11e73858e9e6980db58ee /sound/pci/hda | |
parent | 668d1e9673eddf7df3232e24a69dec8deba7331b (diff) |
ALSA: hda - Pass errors properly in alc_auto_check_switches()
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 6d57547aecac..0062c9f401c3 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -930,12 +930,12 @@ static int alc_add_automute_mode_enum(struct hda_codec *codec) | |||
930 | * Check the availability of HP/line-out auto-mute; | 930 | * Check the availability of HP/line-out auto-mute; |
931 | * Set up appropriately if really supported | 931 | * Set up appropriately if really supported |
932 | */ | 932 | */ |
933 | static void alc_init_automute(struct hda_codec *codec) | 933 | static int alc_init_automute(struct hda_codec *codec) |
934 | { | 934 | { |
935 | struct alc_spec *spec = codec->spec; | 935 | struct alc_spec *spec = codec->spec; |
936 | struct auto_pin_cfg *cfg = &spec->autocfg; | 936 | struct auto_pin_cfg *cfg = &spec->autocfg; |
937 | int present = 0; | 937 | int present = 0; |
938 | int i; | 938 | int i, err; |
939 | 939 | ||
940 | if (cfg->hp_pins[0]) | 940 | if (cfg->hp_pins[0]) |
941 | present++; | 941 | present++; |
@@ -944,7 +944,7 @@ static void alc_init_automute(struct hda_codec *codec) | |||
944 | if (cfg->speaker_pins[0]) | 944 | if (cfg->speaker_pins[0]) |
945 | present++; | 945 | present++; |
946 | if (present < 2) /* need two different output types */ | 946 | if (present < 2) /* need two different output types */ |
947 | return; | 947 | return 0; |
948 | 948 | ||
949 | if (!cfg->speaker_pins[0] && | 949 | if (!cfg->speaker_pins[0] && |
950 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { | 950 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
@@ -994,9 +994,13 @@ static void alc_init_automute(struct hda_codec *codec) | |||
994 | spec->automute_lo = spec->automute_lo_possible; | 994 | spec->automute_lo = spec->automute_lo_possible; |
995 | spec->automute_speaker = spec->automute_speaker_possible; | 995 | spec->automute_speaker = spec->automute_speaker_possible; |
996 | 996 | ||
997 | if (spec->automute_speaker_possible || spec->automute_lo_possible) | 997 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
998 | /* create a control for automute mode */ | 998 | /* create a control for automute mode */ |
999 | alc_add_automute_mode_enum(codec); | 999 | err = alc_add_automute_mode_enum(codec); |
1000 | if (err < 0) | ||
1001 | return err; | ||
1002 | } | ||
1003 | return 0; | ||
1000 | } | 1004 | } |
1001 | 1005 | ||
1002 | /* return the position of NID in the list, or -1 if not found */ | 1006 | /* 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) | |||
1096 | * Check the availability of auto-mic switch; | 1100 | * Check the availability of auto-mic switch; |
1097 | * Set up if really supported | 1101 | * Set up if really supported |
1098 | */ | 1102 | */ |
1099 | static void alc_init_auto_mic(struct hda_codec *codec) | 1103 | static int alc_init_auto_mic(struct hda_codec *codec) |
1100 | { | 1104 | { |
1101 | struct alc_spec *spec = codec->spec; | 1105 | struct alc_spec *spec = codec->spec; |
1102 | struct auto_pin_cfg *cfg = &spec->autocfg; | 1106 | struct auto_pin_cfg *cfg = &spec->autocfg; |
@@ -1104,7 +1108,7 @@ static void alc_init_auto_mic(struct hda_codec *codec) | |||
1104 | int i; | 1108 | int i; |
1105 | 1109 | ||
1106 | if (spec->shared_mic_hp) | 1110 | if (spec->shared_mic_hp) |
1107 | return; /* no auto-mic for the shared I/O */ | 1111 | return 0; /* no auto-mic for the shared I/O */ |
1108 | 1112 | ||
1109 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; | 1113 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
1110 | 1114 | ||
@@ -1116,25 +1120,25 @@ static void alc_init_auto_mic(struct hda_codec *codec) | |||
1116 | switch (snd_hda_get_input_pin_attr(defcfg)) { | 1120 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
1117 | case INPUT_PIN_ATTR_INT: | 1121 | case INPUT_PIN_ATTR_INT: |
1118 | if (fixed) | 1122 | if (fixed) |
1119 | return; /* already occupied */ | 1123 | return 0; /* already occupied */ |
1120 | if (cfg->inputs[i].type != AUTO_PIN_MIC) | 1124 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
1121 | return; /* invalid type */ | 1125 | return 0; /* invalid type */ |
1122 | fixed = nid; | 1126 | fixed = nid; |
1123 | break; | 1127 | break; |
1124 | case INPUT_PIN_ATTR_UNUSED: | 1128 | case INPUT_PIN_ATTR_UNUSED: |
1125 | return; /* invalid entry */ | 1129 | return 0; /* invalid entry */ |
1126 | case INPUT_PIN_ATTR_DOCK: | 1130 | case INPUT_PIN_ATTR_DOCK: |
1127 | if (dock) | 1131 | if (dock) |
1128 | return; /* already occupied */ | 1132 | return 0; /* already occupied */ |
1129 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) | 1133 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
1130 | return; /* invalid type */ | 1134 | return 0; /* invalid type */ |
1131 | dock = nid; | 1135 | dock = nid; |
1132 | break; | 1136 | break; |
1133 | default: | 1137 | default: |
1134 | if (ext) | 1138 | if (ext) |
1135 | return; /* already occupied */ | 1139 | return 0; /* already occupied */ |
1136 | if (cfg->inputs[i].type != AUTO_PIN_MIC) | 1140 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
1137 | return; /* invalid type */ | 1141 | return 0; /* invalid type */ |
1138 | ext = nid; | 1142 | ext = nid; |
1139 | break; | 1143 | break; |
1140 | } | 1144 | } |
@@ -1144,11 +1148,11 @@ static void alc_init_auto_mic(struct hda_codec *codec) | |||
1144 | dock = 0; | 1148 | dock = 0; |
1145 | } | 1149 | } |
1146 | if (!ext || !fixed) | 1150 | if (!ext || !fixed) |
1147 | return; | 1151 | return 0; |
1148 | if (!is_jack_detectable(codec, ext)) | 1152 | if (!is_jack_detectable(codec, ext)) |
1149 | return; /* no unsol support */ | 1153 | return 0; /* no unsol support */ |
1150 | if (dock && !is_jack_detectable(codec, dock)) | 1154 | if (dock && !is_jack_detectable(codec, dock)) |
1151 | return; /* no unsol support */ | 1155 | return 0; /* no unsol support */ |
1152 | 1156 | ||
1153 | /* check imux indices */ | 1157 | /* check imux indices */ |
1154 | spec->ext_mic_pin = ext; | 1158 | spec->ext_mic_pin = ext; |
@@ -1157,17 +1161,26 @@ static void alc_init_auto_mic(struct hda_codec *codec) | |||
1157 | 1161 | ||
1158 | spec->auto_mic = 1; | 1162 | spec->auto_mic = 1; |
1159 | if (!alc_auto_mic_check_imux(codec)) | 1163 | if (!alc_auto_mic_check_imux(codec)) |
1160 | return; | 1164 | return 0; |
1161 | 1165 | ||
1162 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", | 1166 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
1163 | ext, fixed, dock); | 1167 | ext, fixed, dock); |
1168 | |||
1169 | return 0; | ||
1164 | } | 1170 | } |
1165 | 1171 | ||
1166 | /* check the availabilities of auto-mute and auto-mic switches */ | 1172 | /* check the availabilities of auto-mute and auto-mic switches */ |
1167 | static void alc_auto_check_switches(struct hda_codec *codec) | 1173 | static int alc_auto_check_switches(struct hda_codec *codec) |
1168 | { | 1174 | { |
1169 | alc_init_automute(codec); | 1175 | int err; |
1170 | alc_init_auto_mic(codec); | 1176 | |
1177 | err = alc_init_automute(codec); | ||
1178 | if (err < 0) | ||
1179 | return err; | ||
1180 | err = alc_init_auto_mic(codec); | ||
1181 | if (err < 0) | ||
1182 | return err; | ||
1183 | return 0; | ||
1171 | } | 1184 | } |
1172 | 1185 | ||
1173 | /* | 1186 | /* |
@@ -4338,7 +4351,9 @@ static int alc_parse_auto_config(struct hda_codec *codec, | |||
4338 | alc_ssid_check(codec, ssid_nids); | 4351 | alc_ssid_check(codec, ssid_nids); |
4339 | 4352 | ||
4340 | if (!spec->no_analog) { | 4353 | if (!spec->no_analog) { |
4341 | alc_auto_check_switches(codec); | 4354 | err = alc_auto_check_switches(codec); |
4355 | if (err < 0) | ||
4356 | return err; | ||
4342 | err = alc_auto_add_mic_boost(codec); | 4357 | err = alc_auto_add_mic_boost(codec); |
4343 | if (err < 0) | 4358 | if (err < 0) |
4344 | return err; | 4359 | return err; |