diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-02-21 06:54:17 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-02-21 07:48:35 -0500 |
commit | 070cff4cfd267b9d266f4f8362ea99532234eb21 (patch) | |
tree | d4a119c94cd31ac911ed875cb0768de51e104de9 /sound/pci/hda/patch_realtek.c | |
parent | f568291ef571522202e8b9f893ab33694bb2fc31 (diff) |
ALSA: hda/realtek - Small code cleanups
A few clean-ups for post-static-quirk time:
- Call alc_auto_init_std() statically in alc_init() instead of setting
spec->init_hook in each caller. spec->init_hook field is left
unused for any future use.
- Move the call of set_capture_mixer() to to alc_parse_auto_config()
instead of each caller.
- Get rid of the ADC-filling and imux check in each parser function.
This is no longer needed since the auto-parser always check ADCs and
imux. It was only for the static quirks.
- Kill unused defines
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 140 |
1 files changed, 5 insertions, 135 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index e82911ab0f8c..e142f6f5c499 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -222,8 +222,6 @@ struct alc_spec { | |||
222 | struct snd_array bind_ctls; | 222 | struct snd_array bind_ctls; |
223 | }; | 223 | }; |
224 | 224 | ||
225 | #define ALC_MODEL_AUTO 0 /* common for all chips */ | ||
226 | |||
227 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, | 225 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
228 | int dir, unsigned int bits) | 226 | int dir, unsigned int bits) |
229 | { | 227 | { |
@@ -1074,45 +1072,6 @@ static bool alc_check_dyn_adc_switch(struct hda_codec *codec) | |||
1074 | return true; | 1072 | return true; |
1075 | } | 1073 | } |
1076 | 1074 | ||
1077 | /* rebuild imux for matching with the given auto-mic pins (if not yet) */ | ||
1078 | static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec) | ||
1079 | { | ||
1080 | struct alc_spec *spec = codec->spec; | ||
1081 | struct hda_input_mux *imux; | ||
1082 | static char * const texts[3] = { | ||
1083 | "Mic", "Internal Mic", "Dock Mic" | ||
1084 | }; | ||
1085 | int i; | ||
1086 | |||
1087 | if (!spec->auto_mic) | ||
1088 | return false; | ||
1089 | imux = &spec->private_imux[0]; | ||
1090 | if (spec->input_mux == imux) | ||
1091 | return true; | ||
1092 | spec->imux_pins[0] = spec->ext_mic_pin; | ||
1093 | spec->imux_pins[1] = spec->int_mic_pin; | ||
1094 | spec->imux_pins[2] = spec->dock_mic_pin; | ||
1095 | for (i = 0; i < 3; i++) { | ||
1096 | strcpy(imux->items[i].label, texts[i]); | ||
1097 | if (spec->imux_pins[i]) { | ||
1098 | hda_nid_t pin = spec->imux_pins[i]; | ||
1099 | int c; | ||
1100 | for (c = 0; c < spec->num_adc_nids; c++) { | ||
1101 | hda_nid_t cap = get_capsrc(spec, c); | ||
1102 | int idx = get_connection_index(codec, cap, pin); | ||
1103 | if (idx >= 0) { | ||
1104 | imux->items[i].index = idx; | ||
1105 | break; | ||
1106 | } | ||
1107 | } | ||
1108 | imux->num_items = i + 1; | ||
1109 | } | ||
1110 | } | ||
1111 | spec->num_mux_defs = 1; | ||
1112 | spec->input_mux = imux; | ||
1113 | return true; | ||
1114 | } | ||
1115 | |||
1116 | /* check whether all auto-mic pins are valid; setup indices if OK */ | 1075 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
1117 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) | 1076 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
1118 | { | 1077 | { |
@@ -2092,6 +2051,7 @@ static int alc_build_controls(struct hda_codec *codec) | |||
2092 | */ | 2051 | */ |
2093 | 2052 | ||
2094 | static void alc_init_special_input_src(struct hda_codec *codec); | 2053 | static void alc_init_special_input_src(struct hda_codec *codec); |
2054 | static void alc_auto_init_std(struct hda_codec *codec); | ||
2095 | 2055 | ||
2096 | static int alc_init(struct hda_codec *codec) | 2056 | static int alc_init(struct hda_codec *codec) |
2097 | { | 2057 | { |
@@ -2104,6 +2064,7 @@ static int alc_init(struct hda_codec *codec) | |||
2104 | for (i = 0; i < spec->num_init_verbs; i++) | 2064 | for (i = 0; i < spec->num_init_verbs; i++) |
2105 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | 2065 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
2106 | alc_init_special_input_src(codec); | 2066 | alc_init_special_input_src(codec); |
2067 | alc_auto_init_std(codec); | ||
2107 | 2068 | ||
2108 | if (spec->init_hook) | 2069 | if (spec->init_hook) |
2109 | spec->init_hook(codec); | 2070 | spec->init_hook(codec); |
@@ -4442,6 +4403,9 @@ static int alc_parse_auto_config(struct hda_codec *codec, | |||
4442 | if (spec->kctls.list) | 4403 | if (spec->kctls.list) |
4443 | add_mixer(spec, spec->kctls.list); | 4404 | add_mixer(spec, spec->kctls.list); |
4444 | 4405 | ||
4406 | if (!spec->no_analog && !spec->cap_mixer) | ||
4407 | set_capture_mixer(codec); | ||
4408 | |||
4445 | return 1; | 4409 | return 1; |
4446 | } | 4410 | } |
4447 | 4411 | ||
@@ -4844,15 +4808,6 @@ static int patch_alc880(struct hda_codec *codec) | |||
4844 | if (err < 0) | 4808 | if (err < 0) |
4845 | goto error; | 4809 | goto error; |
4846 | 4810 | ||
4847 | if (!spec->no_analog && !spec->adc_nids) { | ||
4848 | alc_auto_fill_adc_caps(codec); | ||
4849 | alc_rebuild_imux_for_auto_mic(codec); | ||
4850 | alc_remove_invalid_adc_nids(codec); | ||
4851 | } | ||
4852 | |||
4853 | if (!spec->no_analog && !spec->cap_mixer) | ||
4854 | set_capture_mixer(codec); | ||
4855 | |||
4856 | if (!spec->no_analog) { | 4811 | if (!spec->no_analog) { |
4857 | err = snd_hda_attach_beep_device(codec, 0x1); | 4812 | err = snd_hda_attach_beep_device(codec, 0x1); |
4858 | if (err < 0) | 4813 | if (err < 0) |
@@ -4861,7 +4816,6 @@ static int patch_alc880(struct hda_codec *codec) | |||
4861 | } | 4816 | } |
4862 | 4817 | ||
4863 | codec->patch_ops = alc_patch_ops; | 4818 | codec->patch_ops = alc_patch_ops; |
4864 | spec->init_hook = alc_auto_init_std; | ||
4865 | 4819 | ||
4866 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); | 4820 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
4867 | 4821 | ||
@@ -5009,15 +4963,6 @@ static int patch_alc260(struct hda_codec *codec) | |||
5009 | if (err < 0) | 4963 | if (err < 0) |
5010 | goto error; | 4964 | goto error; |
5011 | 4965 | ||
5012 | if (!spec->no_analog && !spec->adc_nids) { | ||
5013 | alc_auto_fill_adc_caps(codec); | ||
5014 | alc_rebuild_imux_for_auto_mic(codec); | ||
5015 | alc_remove_invalid_adc_nids(codec); | ||
5016 | } | ||
5017 | |||
5018 | if (!spec->no_analog && !spec->cap_mixer) | ||
5019 | set_capture_mixer(codec); | ||
5020 | |||
5021 | if (!spec->no_analog) { | 4966 | if (!spec->no_analog) { |
5022 | err = snd_hda_attach_beep_device(codec, 0x1); | 4967 | err = snd_hda_attach_beep_device(codec, 0x1); |
5023 | if (err < 0) | 4968 | if (err < 0) |
@@ -5026,7 +4971,6 @@ static int patch_alc260(struct hda_codec *codec) | |||
5026 | } | 4971 | } |
5027 | 4972 | ||
5028 | codec->patch_ops = alc_patch_ops; | 4973 | codec->patch_ops = alc_patch_ops; |
5029 | spec->init_hook = alc_auto_init_std; | ||
5030 | spec->shutup = alc_eapd_shutup; | 4974 | spec->shutup = alc_eapd_shutup; |
5031 | 4975 | ||
5032 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); | 4976 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
@@ -5477,15 +5421,6 @@ static int patch_alc882(struct hda_codec *codec) | |||
5477 | if (err < 0) | 5421 | if (err < 0) |
5478 | goto error; | 5422 | goto error; |
5479 | 5423 | ||
5480 | if (!spec->no_analog && !spec->adc_nids) { | ||
5481 | alc_auto_fill_adc_caps(codec); | ||
5482 | alc_rebuild_imux_for_auto_mic(codec); | ||
5483 | alc_remove_invalid_adc_nids(codec); | ||
5484 | } | ||
5485 | |||
5486 | if (!spec->no_analog && !spec->cap_mixer) | ||
5487 | set_capture_mixer(codec); | ||
5488 | |||
5489 | if (!spec->no_analog && has_cdefine_beep(codec)) { | 5424 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
5490 | err = snd_hda_attach_beep_device(codec, 0x1); | 5425 | err = snd_hda_attach_beep_device(codec, 0x1); |
5491 | if (err < 0) | 5426 | if (err < 0) |
@@ -5494,7 +5429,6 @@ static int patch_alc882(struct hda_codec *codec) | |||
5494 | } | 5429 | } |
5495 | 5430 | ||
5496 | codec->patch_ops = alc_patch_ops; | 5431 | codec->patch_ops = alc_patch_ops; |
5497 | spec->init_hook = alc_auto_init_std; | ||
5498 | 5432 | ||
5499 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); | 5433 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
5500 | 5434 | ||
@@ -5631,15 +5565,6 @@ static int patch_alc262(struct hda_codec *codec) | |||
5631 | if (err < 0) | 5565 | if (err < 0) |
5632 | goto error; | 5566 | goto error; |
5633 | 5567 | ||
5634 | if (!spec->no_analog && !spec->adc_nids) { | ||
5635 | alc_auto_fill_adc_caps(codec); | ||
5636 | alc_rebuild_imux_for_auto_mic(codec); | ||
5637 | alc_remove_invalid_adc_nids(codec); | ||
5638 | } | ||
5639 | |||
5640 | if (!spec->no_analog && !spec->cap_mixer) | ||
5641 | set_capture_mixer(codec); | ||
5642 | |||
5643 | if (!spec->no_analog && has_cdefine_beep(codec)) { | 5568 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
5644 | err = snd_hda_attach_beep_device(codec, 0x1); | 5569 | err = snd_hda_attach_beep_device(codec, 0x1); |
5645 | if (err < 0) | 5570 | if (err < 0) |
@@ -5648,7 +5573,6 @@ static int patch_alc262(struct hda_codec *codec) | |||
5648 | } | 5573 | } |
5649 | 5574 | ||
5650 | codec->patch_ops = alc_patch_ops; | 5575 | codec->patch_ops = alc_patch_ops; |
5651 | spec->init_hook = alc_auto_init_std; | ||
5652 | spec->shutup = alc_eapd_shutup; | 5576 | spec->shutup = alc_eapd_shutup; |
5653 | 5577 | ||
5654 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); | 5578 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
@@ -5745,17 +5669,7 @@ static int patch_alc268(struct hda_codec *codec) | |||
5745 | (0 << AC_AMPCAP_MUTE_SHIFT)); | 5669 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
5746 | } | 5670 | } |
5747 | 5671 | ||
5748 | if (!spec->no_analog && !spec->adc_nids) { | ||
5749 | alc_auto_fill_adc_caps(codec); | ||
5750 | alc_rebuild_imux_for_auto_mic(codec); | ||
5751 | alc_remove_invalid_adc_nids(codec); | ||
5752 | } | ||
5753 | |||
5754 | if (!spec->no_analog && !spec->cap_mixer) | ||
5755 | set_capture_mixer(codec); | ||
5756 | |||
5757 | codec->patch_ops = alc_patch_ops; | 5672 | codec->patch_ops = alc_patch_ops; |
5758 | spec->init_hook = alc_auto_init_std; | ||
5759 | spec->shutup = alc_eapd_shutup; | 5673 | spec->shutup = alc_eapd_shutup; |
5760 | 5674 | ||
5761 | return 0; | 5675 | return 0; |
@@ -6283,15 +6197,6 @@ static int patch_alc269(struct hda_codec *codec) | |||
6283 | if (err < 0) | 6197 | if (err < 0) |
6284 | goto error; | 6198 | goto error; |
6285 | 6199 | ||
6286 | if (!spec->no_analog && !spec->adc_nids) { | ||
6287 | alc_auto_fill_adc_caps(codec); | ||
6288 | alc_rebuild_imux_for_auto_mic(codec); | ||
6289 | alc_remove_invalid_adc_nids(codec); | ||
6290 | } | ||
6291 | |||
6292 | if (!spec->no_analog && !spec->cap_mixer) | ||
6293 | set_capture_mixer(codec); | ||
6294 | |||
6295 | if (!spec->no_analog && has_cdefine_beep(codec)) { | 6200 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
6296 | err = snd_hda_attach_beep_device(codec, 0x1); | 6201 | err = snd_hda_attach_beep_device(codec, 0x1); |
6297 | if (err < 0) | 6202 | if (err < 0) |
@@ -6303,7 +6208,6 @@ static int patch_alc269(struct hda_codec *codec) | |||
6303 | #ifdef CONFIG_PM | 6208 | #ifdef CONFIG_PM |
6304 | codec->patch_ops.resume = alc269_resume; | 6209 | codec->patch_ops.resume = alc269_resume; |
6305 | #endif | 6210 | #endif |
6306 | spec->init_hook = alc_auto_init_std; | ||
6307 | spec->shutup = alc269_shutup; | 6211 | spec->shutup = alc269_shutup; |
6308 | 6212 | ||
6309 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 6213 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -6424,15 +6328,6 @@ static int patch_alc861(struct hda_codec *codec) | |||
6424 | if (err < 0) | 6328 | if (err < 0) |
6425 | goto error; | 6329 | goto error; |
6426 | 6330 | ||
6427 | if (!spec->no_analog && !spec->adc_nids) { | ||
6428 | alc_auto_fill_adc_caps(codec); | ||
6429 | alc_rebuild_imux_for_auto_mic(codec); | ||
6430 | alc_remove_invalid_adc_nids(codec); | ||
6431 | } | ||
6432 | |||
6433 | if (!spec->no_analog && !spec->cap_mixer) | ||
6434 | set_capture_mixer(codec); | ||
6435 | |||
6436 | if (!spec->no_analog) { | 6331 | if (!spec->no_analog) { |
6437 | err = snd_hda_attach_beep_device(codec, 0x23); | 6332 | err = snd_hda_attach_beep_device(codec, 0x23); |
6438 | if (err < 0) | 6333 | if (err < 0) |
@@ -6441,7 +6336,6 @@ static int patch_alc861(struct hda_codec *codec) | |||
6441 | } | 6336 | } |
6442 | 6337 | ||
6443 | codec->patch_ops = alc_patch_ops; | 6338 | codec->patch_ops = alc_patch_ops; |
6444 | spec->init_hook = alc_auto_init_std; | ||
6445 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 6339 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6446 | spec->power_hook = alc_power_eapd; | 6340 | spec->power_hook = alc_power_eapd; |
6447 | #endif | 6341 | #endif |
@@ -6542,15 +6436,6 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
6542 | add_verb(spec, alc660vd_eapd_verbs); | 6436 | add_verb(spec, alc660vd_eapd_verbs); |
6543 | } | 6437 | } |
6544 | 6438 | ||
6545 | if (!spec->no_analog && !spec->adc_nids) { | ||
6546 | alc_auto_fill_adc_caps(codec); | ||
6547 | alc_rebuild_imux_for_auto_mic(codec); | ||
6548 | alc_remove_invalid_adc_nids(codec); | ||
6549 | } | ||
6550 | |||
6551 | if (!spec->no_analog && !spec->cap_mixer) | ||
6552 | set_capture_mixer(codec); | ||
6553 | |||
6554 | if (!spec->no_analog) { | 6439 | if (!spec->no_analog) { |
6555 | err = snd_hda_attach_beep_device(codec, 0x23); | 6440 | err = snd_hda_attach_beep_device(codec, 0x23); |
6556 | if (err < 0) | 6441 | if (err < 0) |
@@ -6560,7 +6445,6 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
6560 | 6445 | ||
6561 | codec->patch_ops = alc_patch_ops; | 6446 | codec->patch_ops = alc_patch_ops; |
6562 | 6447 | ||
6563 | spec->init_hook = alc_auto_init_std; | ||
6564 | spec->shutup = alc_eapd_shutup; | 6448 | spec->shutup = alc_eapd_shutup; |
6565 | 6449 | ||
6566 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); | 6450 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
@@ -6912,15 +6796,6 @@ static int patch_alc662(struct hda_codec *codec) | |||
6912 | if (err < 0) | 6796 | if (err < 0) |
6913 | goto error; | 6797 | goto error; |
6914 | 6798 | ||
6915 | if (!spec->no_analog && !spec->adc_nids) { | ||
6916 | alc_auto_fill_adc_caps(codec); | ||
6917 | alc_rebuild_imux_for_auto_mic(codec); | ||
6918 | alc_remove_invalid_adc_nids(codec); | ||
6919 | } | ||
6920 | |||
6921 | if (!spec->no_analog && !spec->cap_mixer) | ||
6922 | set_capture_mixer(codec); | ||
6923 | |||
6924 | if (!spec->no_analog && has_cdefine_beep(codec)) { | 6799 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
6925 | err = snd_hda_attach_beep_device(codec, 0x1); | 6800 | err = snd_hda_attach_beep_device(codec, 0x1); |
6926 | if (err < 0) | 6801 | if (err < 0) |
@@ -6941,7 +6816,6 @@ static int patch_alc662(struct hda_codec *codec) | |||
6941 | } | 6816 | } |
6942 | 6817 | ||
6943 | codec->patch_ops = alc_patch_ops; | 6818 | codec->patch_ops = alc_patch_ops; |
6944 | spec->init_hook = alc_auto_init_std; | ||
6945 | spec->shutup = alc_eapd_shutup; | 6819 | spec->shutup = alc_eapd_shutup; |
6946 | 6820 | ||
6947 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); | 6821 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
@@ -6984,11 +6858,7 @@ static int patch_alc680(struct hda_codec *codec) | |||
6984 | return err; | 6858 | return err; |
6985 | } | 6859 | } |
6986 | 6860 | ||
6987 | if (!spec->no_analog && !spec->cap_mixer) | ||
6988 | set_capture_mixer(codec); | ||
6989 | |||
6990 | codec->patch_ops = alc_patch_ops; | 6861 | codec->patch_ops = alc_patch_ops; |
6991 | spec->init_hook = alc_auto_init_std; | ||
6992 | 6862 | ||
6993 | return 0; | 6863 | return 0; |
6994 | } | 6864 | } |