diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-05-17 03:15:55 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-05-17 03:15:55 -0400 |
commit | 47ad1f4e40c4374243a56c8df168f4fb551c7915 (patch) | |
tree | f2606118319fa7e2a4e1e945a6a1b74a7325d573 /sound | |
parent | e033ebfb399227e01686260ac271029011bc6b47 (diff) |
ALSA: hda - Code refactoring in patch_conexant.c
Use a struct instead of each array for managing input-source info
for auto-parser.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 2b12d72bf91e..390bc02dcf58 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -55,6 +55,13 @@ struct pin_dac_pair { | |||
55 | int type; | 55 | int type; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | struct imux_info { | ||
59 | hda_nid_t pin; /* input pin NID */ | ||
60 | hda_nid_t adc; /* connected ADC NID */ | ||
61 | hda_nid_t boost; /* optional boost volume NID */ | ||
62 | int index; /* corresponding to autocfg.input */ | ||
63 | }; | ||
64 | |||
58 | struct conexant_spec { | 65 | struct conexant_spec { |
59 | 66 | ||
60 | const struct snd_kcontrol_new *mixers[5]; | 67 | const struct snd_kcontrol_new *mixers[5]; |
@@ -108,10 +115,7 @@ struct conexant_spec { | |||
108 | /* dynamic controls, init_verbs and input_mux */ | 115 | /* dynamic controls, init_verbs and input_mux */ |
109 | struct auto_pin_cfg autocfg; | 116 | struct auto_pin_cfg autocfg; |
110 | struct hda_input_mux private_imux; | 117 | struct hda_input_mux private_imux; |
111 | int imux_cfg_idx[HDA_MAX_NUM_INPUTS]; /* corresponding autocfg.input */ | 118 | struct imux_info imux_info[HDA_MAX_NUM_INPUTS]; |
112 | hda_nid_t imux_boost_nid[HDA_MAX_NUM_INPUTS]; /* boost widget */ | ||
113 | hda_nid_t imux_adcs[HDA_MAX_NUM_INPUTS]; | ||
114 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; | ||
115 | hda_nid_t private_adc_nids[HDA_MAX_NUM_INPUTS]; | 119 | hda_nid_t private_adc_nids[HDA_MAX_NUM_INPUTS]; |
116 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; | 120 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
117 | struct pin_dac_pair dac_info[8]; | 121 | struct pin_dac_pair dac_info[8]; |
@@ -3254,7 +3258,7 @@ static int cx_auto_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
3254 | struct snd_pcm_substream *substream) | 3258 | struct snd_pcm_substream *substream) |
3255 | { | 3259 | { |
3256 | struct conexant_spec *spec = codec->spec; | 3260 | struct conexant_spec *spec = codec->spec; |
3257 | hda_nid_t adc = spec->imux_adcs[spec->cur_mux[0]]; | 3261 | hda_nid_t adc = spec->imux_info[spec->cur_mux[0]].adc; |
3258 | if (spec->adc_switching) { | 3262 | if (spec->adc_switching) { |
3259 | spec->cur_adc = adc; | 3263 | spec->cur_adc = adc; |
3260 | spec->cur_adc_stream_tag = stream_tag; | 3264 | spec->cur_adc_stream_tag = stream_tag; |
@@ -3541,9 +3545,9 @@ static int cx_auto_mux_enum_update(struct hda_codec *codec, | |||
3541 | idx = imux->num_items - 1; | 3545 | idx = imux->num_items - 1; |
3542 | if (spec->cur_mux[0] == idx) | 3546 | if (spec->cur_mux[0] == idx) |
3543 | return 0; | 3547 | return 0; |
3544 | adc = spec->imux_adcs[idx]; | 3548 | adc = spec->imux_info[idx].adc; |
3545 | select_input_connection(codec, spec->imux_adcs[idx], | 3549 | select_input_connection(codec, spec->imux_info[idx].adc, |
3546 | spec->imux_pins[idx]); | 3550 | spec->imux_info[idx].pin); |
3547 | if (spec->cur_adc && spec->cur_adc != adc) { | 3551 | if (spec->cur_adc && spec->cur_adc != adc) { |
3548 | /* stream is running, let's swap the current ADC */ | 3552 | /* stream is running, let's swap the current ADC */ |
3549 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); | 3553 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
@@ -3585,7 +3589,7 @@ static void cx_auto_automic(struct hda_codec *codec) | |||
3585 | 3589 | ||
3586 | if (!spec->auto_mic) | 3590 | if (!spec->auto_mic) |
3587 | return; | 3591 | return; |
3588 | if (snd_hda_jack_detect(codec, spec->imux_pins[ext_idx])) | 3592 | if (snd_hda_jack_detect(codec, spec->imux_info[ext_idx].pin)) |
3589 | cx_auto_mux_enum_update(codec, &spec->private_imux, ext_idx); | 3593 | cx_auto_mux_enum_update(codec, &spec->private_imux, ext_idx); |
3590 | else | 3594 | else |
3591 | cx_auto_mux_enum_update(codec, &spec->private_imux, !ext_idx); | 3595 | cx_auto_mux_enum_update(codec, &spec->private_imux, !ext_idx); |
@@ -3630,14 +3634,14 @@ static void cx_auto_check_auto_mic(struct hda_codec *codec) | |||
3630 | { | 3634 | { |
3631 | struct conexant_spec *spec = codec->spec; | 3635 | struct conexant_spec *spec = codec->spec; |
3632 | 3636 | ||
3633 | if (is_ext_mic(codec, spec->imux_pins[0]) && | 3637 | if (is_ext_mic(codec, spec->imux_info[0].pin) && |
3634 | is_int_mic(codec, spec->imux_pins[1])) { | 3638 | is_int_mic(codec, spec->imux_info[1].pin)) { |
3635 | spec->auto_mic = 1; | 3639 | spec->auto_mic = 1; |
3636 | spec->auto_mic_ext = 0; | 3640 | spec->auto_mic_ext = 0; |
3637 | return; | 3641 | return; |
3638 | } | 3642 | } |
3639 | if (is_int_mic(codec, spec->imux_pins[0]) && | 3643 | if (is_int_mic(codec, spec->imux_info[0].pin) && |
3640 | is_ext_mic(codec, spec->imux_pins[1])) { | 3644 | is_ext_mic(codec, spec->imux_info[1].pin)) { |
3641 | spec->auto_mic = 1; | 3645 | spec->auto_mic = 1; |
3642 | spec->auto_mic_ext = 1; | 3646 | spec->auto_mic_ext = 1; |
3643 | return; | 3647 | return; |
@@ -3660,10 +3664,10 @@ static void cx_auto_parse_input(struct hda_codec *codec) | |||
3660 | if (idx >= 0) { | 3664 | if (idx >= 0) { |
3661 | const char *label; | 3665 | const char *label; |
3662 | label = hda_get_autocfg_input_label(codec, cfg, i); | 3666 | label = hda_get_autocfg_input_label(codec, cfg, i); |
3663 | spec->imux_cfg_idx[imux->num_items] = i; | 3667 | spec->imux_info[imux->num_items].index = i; |
3664 | spec->imux_boost_nid[imux->num_items] = 0; | 3668 | spec->imux_info[imux->num_items].boost = 0; |
3665 | spec->imux_adcs[imux->num_items] = adc; | 3669 | spec->imux_info[imux->num_items].adc = adc; |
3666 | spec->imux_pins[imux->num_items] = | 3670 | spec->imux_info[imux->num_items].pin = |
3667 | cfg->inputs[i].pin; | 3671 | cfg->inputs[i].pin; |
3668 | snd_hda_add_imux_item(imux, label, idx, NULL); | 3672 | snd_hda_add_imux_item(imux, label, idx, NULL); |
3669 | break; | 3673 | break; |
@@ -3674,7 +3678,7 @@ static void cx_auto_parse_input(struct hda_codec *codec) | |||
3674 | cx_auto_check_auto_mic(codec); | 3678 | cx_auto_check_auto_mic(codec); |
3675 | if (imux->num_items > 1 && !spec->auto_mic) { | 3679 | if (imux->num_items > 1 && !spec->auto_mic) { |
3676 | for (i = 1; i < imux->num_items; i++) { | 3680 | for (i = 1; i < imux->num_items; i++) { |
3677 | if (spec->imux_adcs[i] != spec->imux_adcs[0]) { | 3681 | if (spec->imux_info[i].adc != spec->imux_info[0].adc) { |
3678 | spec->adc_switching = 1; | 3682 | spec->adc_switching = 1; |
3679 | break; | 3683 | break; |
3680 | } | 3684 | } |
@@ -3864,8 +3868,8 @@ static void cx_auto_init_input(struct hda_codec *codec) | |||
3864 | AC_USRSP_EN | CONEXANT_MIC_EVENT); | 3868 | AC_USRSP_EN | CONEXANT_MIC_EVENT); |
3865 | cx_auto_automic(codec); | 3869 | cx_auto_automic(codec); |
3866 | } else { | 3870 | } else { |
3867 | select_input_connection(codec, spec->imux_adcs[0], | 3871 | select_input_connection(codec, spec->imux_info[0].adc, |
3868 | spec->imux_pins[0]); | 3872 | spec->imux_info[0].pin); |
3869 | } | 3873 | } |
3870 | } | 3874 | } |
3871 | 3875 | ||
@@ -4010,21 +4014,21 @@ static int cx_auto_add_boost_volume(struct hda_codec *codec, int idx, | |||
4010 | hda_nid_t mux, nid; | 4014 | hda_nid_t mux, nid; |
4011 | int i, con; | 4015 | int i, con; |
4012 | 4016 | ||
4013 | nid = spec->imux_pins[idx]; | 4017 | nid = spec->imux_info[idx].pin; |
4014 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) | 4018 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) |
4015 | return cx_auto_add_volume(codec, label, " Boost", cidx, | 4019 | return cx_auto_add_volume(codec, label, " Boost", cidx, |
4016 | nid, HDA_INPUT); | 4020 | nid, HDA_INPUT); |
4017 | con = __select_input_connection(codec, spec->imux_adcs[idx], nid, &mux, | 4021 | con = __select_input_connection(codec, spec->imux_info[idx].adc, nid, |
4018 | false, 0); | 4022 | &mux, false, 0); |
4019 | if (con < 0) | 4023 | if (con < 0) |
4020 | return 0; | 4024 | return 0; |
4021 | for (i = 0; i < idx; i++) { | 4025 | for (i = 0; i < idx; i++) { |
4022 | if (spec->imux_boost_nid[i] == mux) | 4026 | if (spec->imux_info[i].boost == mux) |
4023 | return 0; /* already present */ | 4027 | return 0; /* already present */ |
4024 | } | 4028 | } |
4025 | 4029 | ||
4026 | if (get_wcaps(codec, mux) & AC_WCAP_OUT_AMP) { | 4030 | if (get_wcaps(codec, mux) & AC_WCAP_OUT_AMP) { |
4027 | spec->imux_boost_nid[idx] = mux; | 4031 | spec->imux_info[idx].boost = mux; |
4028 | return cx_auto_add_volume(codec, label, " Boost", 0, | 4032 | return cx_auto_add_volume(codec, label, " Boost", 0, |
4029 | mux, HDA_OUTPUT); | 4033 | mux, HDA_OUTPUT); |
4030 | } | 4034 | } |
@@ -4042,9 +4046,9 @@ static int cx_auto_build_input_controls(struct hda_codec *codec) | |||
4042 | 4046 | ||
4043 | multi_connection = 0; | 4047 | multi_connection = 0; |
4044 | for (i = 0; i < imux->num_items; i++) { | 4048 | for (i = 0; i < imux->num_items; i++) { |
4045 | cidx = get_input_connection(codec, spec->imux_adcs[i], | 4049 | cidx = get_input_connection(codec, spec->imux_info[i].adc, |
4046 | spec->imux_pins[i]); | 4050 | spec->imux_info[i].pin); |
4047 | input_conn[i] = (spec->imux_adcs[i] << 8) | cidx; | 4051 | input_conn[i] = (spec->imux_info[i].adc << 8) | cidx; |
4048 | if (i > 0 && input_conn[i] != input_conn[0]) | 4052 | if (i > 0 && input_conn[i] != input_conn[0]) |
4049 | multi_connection = 1; | 4053 | multi_connection = 1; |
4050 | } | 4054 | } |
@@ -4052,11 +4056,11 @@ static int cx_auto_build_input_controls(struct hda_codec *codec) | |||
4052 | prev_label = NULL; | 4056 | prev_label = NULL; |
4053 | cidx = 0; | 4057 | cidx = 0; |
4054 | for (i = 0; i < imux->num_items; i++) { | 4058 | for (i = 0; i < imux->num_items; i++) { |
4055 | hda_nid_t nid = spec->imux_pins[i]; | 4059 | hda_nid_t nid = spec->imux_info[i].pin; |
4056 | const char *label; | 4060 | const char *label; |
4057 | 4061 | ||
4058 | label = hda_get_autocfg_input_label(codec, &spec->autocfg, | 4062 | label = hda_get_autocfg_input_label(codec, &spec->autocfg, |
4059 | spec->imux_cfg_idx[i]); | 4063 | spec->imux_info[i].index); |
4060 | if (label == prev_label) | 4064 | if (label == prev_label) |
4061 | cidx++; | 4065 | cidx++; |
4062 | else | 4066 | else |