diff options
author | Harry Butterworth <heb1001@gmail.com> | 2011-06-11 05:41:13 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-06-14 01:34:03 -0400 |
commit | b028b81835d7503d68b230446cd5e39d14ff5b9f (patch) | |
tree | 62873fdf6c3c8002eed541b1e637554514d1a826 | |
parent | 55309216baeb9d7f951520cf8e8bf2337cd17bad (diff) |
ALSA: ctxfi: Implement a combined capabilities query method to replace multiple have_x query methods.
Signed-off-by: Harry Butterworth <heb1001@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pci/ctxfi/ctatc.c | 31 | ||||
-rw-r--r-- | sound/pci/ctxfi/ctatc.h | 6 | ||||
-rw-r--r-- | sound/pci/ctxfi/cthardware.h | 12 | ||||
-rw-r--r-- | sound/pci/ctxfi/cthw20k1.c | 29 | ||||
-rw-r--r-- | sound/pci/ctxfi/cthw20k2.c | 27 | ||||
-rw-r--r-- | sound/pci/ctxfi/ctmixer.c | 18 |
6 files changed, 39 insertions, 84 deletions
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 952fd94c2666..d8a4423539ce 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include "ctatc.h" | 18 | #include "ctatc.h" |
19 | #include "ctpcm.h" | 19 | #include "ctpcm.h" |
20 | #include "ctmixer.h" | 20 | #include "ctmixer.h" |
21 | #include "cthardware.h" | ||
22 | #include "ctsrc.h" | 21 | #include "ctsrc.h" |
23 | #include "ctamixer.h" | 22 | #include "ctamixer.h" |
24 | #include "ctdaio.h" | 23 | #include "ctdaio.h" |
@@ -972,25 +971,11 @@ static int atc_select_mic_in(struct ct_atc *atc) | |||
972 | return 0; | 971 | return 0; |
973 | } | 972 | } |
974 | 973 | ||
975 | static int atc_have_digit_io_switch(struct ct_atc *atc) | 974 | static struct capabilities atc_capabilities(struct ct_atc *atc) |
976 | { | 975 | { |
977 | struct hw *hw = atc->hw; | 976 | struct hw *hw = atc->hw; |
978 | 977 | ||
979 | return hw->have_digit_io_switch(hw); | 978 | return hw->capabilities(hw); |
980 | } | ||
981 | |||
982 | static int atc_have_dedicated_mic(struct ct_atc *atc) | ||
983 | { | ||
984 | struct hw *hw = atc->hw; | ||
985 | |||
986 | return hw->have_dedicated_mic(hw); | ||
987 | } | ||
988 | |||
989 | static int atc_have_output_switch(struct ct_atc *atc) | ||
990 | { | ||
991 | struct hw *hw = atc->hw; | ||
992 | |||
993 | return hw->have_output_switch(hw); | ||
994 | } | 979 | } |
995 | 980 | ||
996 | static int atc_output_switch_get(struct ct_atc *atc) | 981 | static int atc_output_switch_get(struct ct_atc *atc) |
@@ -1007,13 +992,6 @@ static int atc_output_switch_put(struct ct_atc *atc, int position) | |||
1007 | return hw->output_switch_put(hw, position); | 992 | return hw->output_switch_put(hw, position); |
1008 | } | 993 | } |
1009 | 994 | ||
1010 | static int atc_have_mic_source_switch(struct ct_atc *atc) | ||
1011 | { | ||
1012 | struct hw *hw = atc->hw; | ||
1013 | |||
1014 | return hw->have_mic_source_switch(hw); | ||
1015 | } | ||
1016 | |||
1017 | static int atc_mic_source_switch_get(struct ct_atc *atc) | 995 | static int atc_mic_source_switch_get(struct ct_atc *atc) |
1018 | { | 996 | { |
1019 | struct hw *hw = atc->hw; | 997 | struct hw *hw = atc->hw; |
@@ -1664,12 +1642,9 @@ static struct ct_atc atc_preset __devinitdata = { | |||
1664 | .spdif_out_get_status = atc_spdif_out_get_status, | 1642 | .spdif_out_get_status = atc_spdif_out_get_status, |
1665 | .spdif_out_set_status = atc_spdif_out_set_status, | 1643 | .spdif_out_set_status = atc_spdif_out_set_status, |
1666 | .spdif_out_passthru = atc_spdif_out_passthru, | 1644 | .spdif_out_passthru = atc_spdif_out_passthru, |
1667 | .have_digit_io_switch = atc_have_digit_io_switch, | 1645 | .capabilities = atc_capabilities, |
1668 | .have_dedicated_mic = atc_have_dedicated_mic, | ||
1669 | .have_output_switch = atc_have_output_switch, | ||
1670 | .output_switch_get = atc_output_switch_get, | 1646 | .output_switch_get = atc_output_switch_get, |
1671 | .output_switch_put = atc_output_switch_put, | 1647 | .output_switch_put = atc_output_switch_put, |
1672 | .have_mic_source_switch = atc_have_mic_source_switch, | ||
1673 | .mic_source_switch_get = atc_mic_source_switch_get, | 1648 | .mic_source_switch_get = atc_mic_source_switch_get, |
1674 | .mic_source_switch_put = atc_mic_source_switch_put, | 1649 | .mic_source_switch_put = atc_mic_source_switch_put, |
1675 | #ifdef CONFIG_PM | 1650 | #ifdef CONFIG_PM |
diff --git a/sound/pci/ctxfi/ctatc.h b/sound/pci/ctxfi/ctatc.h index 6bad27e06f4d..3a0def656af0 100644 --- a/sound/pci/ctxfi/ctatc.h +++ b/sound/pci/ctxfi/ctatc.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <sound/core.h> | 25 | #include <sound/core.h> |
26 | 26 | ||
27 | #include "ctvmem.h" | 27 | #include "ctvmem.h" |
28 | #include "cthardware.h" | ||
28 | #include "ctresource.h" | 29 | #include "ctresource.h" |
29 | 30 | ||
30 | enum CTALSADEVS { /* Types of alsa devices */ | 31 | enum CTALSADEVS { /* Types of alsa devices */ |
@@ -121,12 +122,9 @@ struct ct_atc { | |||
121 | int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status); | 122 | int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status); |
122 | int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status); | 123 | int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status); |
123 | int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state); | 124 | int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state); |
124 | int (*have_digit_io_switch)(struct ct_atc *atc); | 125 | struct capabilities (*capabilities)(struct ct_atc *atc); |
125 | int (*have_dedicated_mic)(struct ct_atc *atc); | ||
126 | int (*have_output_switch)(struct ct_atc *atc); | ||
127 | int (*output_switch_get)(struct ct_atc *atc); | 126 | int (*output_switch_get)(struct ct_atc *atc); |
128 | int (*output_switch_put)(struct ct_atc *atc, int position); | 127 | int (*output_switch_put)(struct ct_atc *atc, int position); |
129 | int (*have_mic_source_switch)(struct ct_atc *atc); | ||
130 | int (*mic_source_switch_get)(struct ct_atc *atc); | 128 | int (*mic_source_switch_get)(struct ct_atc *atc); |
131 | int (*mic_source_switch_put)(struct ct_atc *atc, int position); | 129 | int (*mic_source_switch_put)(struct ct_atc *atc, int position); |
132 | 130 | ||
diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h index de59bbf2702f..908315bec3b4 100644 --- a/sound/pci/ctxfi/cthardware.h +++ b/sound/pci/ctxfi/cthardware.h | |||
@@ -61,6 +61,13 @@ struct card_conf { | |||
61 | unsigned int msr; /* master sample rate in rsrs */ | 61 | unsigned int msr; /* master sample rate in rsrs */ |
62 | }; | 62 | }; |
63 | 63 | ||
64 | struct capabilities { | ||
65 | unsigned int digit_io_switch:1; | ||
66 | unsigned int dedicated_mic:1; | ||
67 | unsigned int output_switch:1; | ||
68 | unsigned int mic_source_switch:1; | ||
69 | }; | ||
70 | |||
64 | struct hw { | 71 | struct hw { |
65 | int (*card_init)(struct hw *hw, struct card_conf *info); | 72 | int (*card_init)(struct hw *hw, struct card_conf *info); |
66 | int (*card_stop)(struct hw *hw); | 73 | int (*card_stop)(struct hw *hw); |
@@ -71,12 +78,9 @@ struct hw { | |||
71 | #endif | 78 | #endif |
72 | int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source); | 79 | int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source); |
73 | int (*select_adc_source)(struct hw *hw, enum ADCSRC source); | 80 | int (*select_adc_source)(struct hw *hw, enum ADCSRC source); |
74 | int (*have_digit_io_switch)(struct hw *hw); | 81 | struct capabilities (*capabilities)(struct hw *hw); |
75 | int (*have_dedicated_mic)(struct hw *hw); | ||
76 | int (*have_output_switch)(struct hw *hw); | ||
77 | int (*output_switch_get)(struct hw *hw); | 82 | int (*output_switch_get)(struct hw *hw); |
78 | int (*output_switch_put)(struct hw *hw, int position); | 83 | int (*output_switch_put)(struct hw *hw, int position); |
79 | int (*have_mic_source_switch)(struct hw *hw); | ||
80 | int (*mic_source_switch_get)(struct hw *hw); | 84 | int (*mic_source_switch_get)(struct hw *hw); |
81 | int (*mic_source_switch_put)(struct hw *hw, int position); | 85 | int (*mic_source_switch_put)(struct hw *hw, int position); |
82 | 86 | ||
diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index 9a85a84b23ab..1ff692a9d016 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c | |||
@@ -1777,25 +1777,17 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info) | |||
1777 | return adc_init_SBx(hw, info->input, info->mic20db); | 1777 | return adc_init_SBx(hw, info->input, info->mic20db); |
1778 | } | 1778 | } |
1779 | 1779 | ||
1780 | static int hw_have_digit_io_switch(struct hw *hw) | 1780 | static struct capabilities hw_capabilities(struct hw *hw) |
1781 | { | 1781 | { |
1782 | /* SB073x and Vista compatible cards have no digit IO switch */ | 1782 | struct capabilities cap; |
1783 | return !(hw->model == CTSB073X || hw->model == CTUAA); | ||
1784 | } | ||
1785 | |||
1786 | static int hw_have_dedicated_mic(struct hw *hw) | ||
1787 | { | ||
1788 | return 0; | ||
1789 | } | ||
1790 | 1783 | ||
1791 | static int hw_have_output_switch(struct hw *hw) | 1784 | /* SB073x and Vista compatible cards have no digit IO switch */ |
1792 | { | 1785 | cap.digit_io_switch = !(hw->model == CTSB073X || hw->model == CTUAA); |
1793 | return 0; | 1786 | cap.dedicated_mic = 0; |
1794 | } | 1787 | cap.output_switch = 0; |
1788 | cap.mic_source_switch = 0; | ||
1795 | 1789 | ||
1796 | static int hw_have_mic_source_switch(struct hw *hw) | 1790 | return cap; |
1797 | { | ||
1798 | return 0; | ||
1799 | } | 1791 | } |
1800 | 1792 | ||
1801 | #define CTLBITS(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) | 1793 | #define CTLBITS(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) |
@@ -2187,10 +2179,7 @@ static struct hw ct20k1_preset __devinitdata = { | |||
2187 | .pll_init = hw_pll_init, | 2179 | .pll_init = hw_pll_init, |
2188 | .is_adc_source_selected = hw_is_adc_input_selected, | 2180 | .is_adc_source_selected = hw_is_adc_input_selected, |
2189 | .select_adc_source = hw_adc_input_select, | 2181 | .select_adc_source = hw_adc_input_select, |
2190 | .have_digit_io_switch = hw_have_digit_io_switch, | 2182 | .capabilities = hw_capabilities, |
2191 | .have_dedicated_mic = hw_have_dedicated_mic, | ||
2192 | .have_output_switch = hw_have_output_switch, | ||
2193 | .have_mic_source_switch = hw_have_mic_source_switch, | ||
2194 | #ifdef CONFIG_PM | 2183 | #ifdef CONFIG_PM |
2195 | .suspend = hw_suspend, | 2184 | .suspend = hw_suspend, |
2196 | .resume = hw_resume, | 2185 | .resume = hw_resume, |
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 8bc6e41ce64b..ea559a9e2934 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c | |||
@@ -1915,19 +1915,16 @@ error: | |||
1915 | return err; | 1915 | return err; |
1916 | } | 1916 | } |
1917 | 1917 | ||
1918 | static int hw_have_digit_io_switch(struct hw *hw) | 1918 | static struct capabilities hw_capabilities(struct hw *hw) |
1919 | { | 1919 | { |
1920 | return 0; | 1920 | struct capabilities cap; |
1921 | } | ||
1922 | 1921 | ||
1923 | static int hw_have_dedicated_mic(struct hw *hw) | 1922 | cap.digit_io_switch = 0; |
1924 | { | 1923 | cap.dedicated_mic = hw->model == CTSB1270; |
1925 | return hw->model == CTSB1270; | 1924 | cap.output_switch = hw->model == CTSB1270; |
1926 | } | 1925 | cap.mic_source_switch = hw->model == CTSB1270; |
1927 | 1926 | ||
1928 | static int hw_have_output_switch(struct hw *hw) | 1927 | return cap; |
1929 | { | ||
1930 | return hw->model == CTSB1270; | ||
1931 | } | 1928 | } |
1932 | 1929 | ||
1933 | static int hw_output_switch_get(struct hw *hw) | 1930 | static int hw_output_switch_get(struct hw *hw) |
@@ -1978,11 +1975,6 @@ static int hw_output_switch_put(struct hw *hw, int position) | |||
1978 | return 1; | 1975 | return 1; |
1979 | } | 1976 | } |
1980 | 1977 | ||
1981 | static int hw_have_mic_source_switch(struct hw *hw) | ||
1982 | { | ||
1983 | return hw->model == CTSB1270; | ||
1984 | } | ||
1985 | |||
1986 | static int hw_mic_source_switch_get(struct hw *hw) | 1978 | static int hw_mic_source_switch_get(struct hw *hw) |
1987 | { | 1979 | { |
1988 | struct hw20k2 *hw20k2 = (struct hw20k2 *)hw; | 1980 | struct hw20k2 *hw20k2 = (struct hw20k2 *)hw; |
@@ -2256,12 +2248,9 @@ static struct hw ct20k2_preset __devinitdata = { | |||
2256 | .pll_init = hw_pll_init, | 2248 | .pll_init = hw_pll_init, |
2257 | .is_adc_source_selected = hw_is_adc_input_selected, | 2249 | .is_adc_source_selected = hw_is_adc_input_selected, |
2258 | .select_adc_source = hw_adc_input_select, | 2250 | .select_adc_source = hw_adc_input_select, |
2259 | .have_digit_io_switch = hw_have_digit_io_switch, | 2251 | .capabilities = hw_capabilities, |
2260 | .have_dedicated_mic = hw_have_dedicated_mic, | ||
2261 | .have_output_switch = hw_have_output_switch, | ||
2262 | .output_switch_get = hw_output_switch_get, | 2252 | .output_switch_get = hw_output_switch_get, |
2263 | .output_switch_put = hw_output_switch_put, | 2253 | .output_switch_put = hw_output_switch_put, |
2264 | .have_mic_source_switch = hw_have_mic_source_switch, | ||
2265 | .mic_source_switch_get = hw_mic_source_switch_get, | 2254 | .mic_source_switch_get = hw_mic_source_switch_get, |
2266 | .mic_source_switch_put = hw_mic_source_switch_put, | 2255 | .mic_source_switch_put = hw_mic_source_switch_put, |
2267 | #ifdef CONFIG_PM | 2256 | #ifdef CONFIG_PM |
diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c index 388235c43789..0cc13eeef8da 100644 --- a/sound/pci/ctxfi/ctmixer.c +++ b/sound/pci/ctxfi/ctmixer.c | |||
@@ -527,7 +527,7 @@ do_digit_io_switch(struct ct_atc *atc, int state) | |||
527 | static void do_switch(struct ct_atc *atc, enum CTALSA_MIXER_CTL type, int state) | 527 | static void do_switch(struct ct_atc *atc, enum CTALSA_MIXER_CTL type, int state) |
528 | { | 528 | { |
529 | struct ct_mixer *mixer = atc->mixer; | 529 | struct ct_mixer *mixer = atc->mixer; |
530 | int have_dedicated_mic = atc->have_dedicated_mic(atc); | 530 | struct capabilities cap = atc->capabilities(atc); |
531 | 531 | ||
532 | /* Do changes in mixer. */ | 532 | /* Do changes in mixer. */ |
533 | if ((SWH_CAPTURE_START <= type) && (SWH_CAPTURE_END >= type)) { | 533 | if ((SWH_CAPTURE_START <= type) && (SWH_CAPTURE_END >= type)) { |
@@ -540,14 +540,14 @@ static void do_switch(struct ct_atc *atc, enum CTALSA_MIXER_CTL type, int state) | |||
540 | } | 540 | } |
541 | } | 541 | } |
542 | /* Do changes out of mixer. */ | 542 | /* Do changes out of mixer. */ |
543 | if (!have_dedicated_mic && | 543 | if (!cap.dedicated_mic && |
544 | (MIXER_LINEIN_C_S == type || MIXER_MIC_C_S == type)) { | 544 | (MIXER_LINEIN_C_S == type || MIXER_MIC_C_S == type)) { |
545 | if (state) | 545 | if (state) |
546 | do_line_mic_switch(atc, type); | 546 | do_line_mic_switch(atc, type); |
547 | atc->line_in_unmute(atc, state); | 547 | atc->line_in_unmute(atc, state); |
548 | } else if (have_dedicated_mic && (MIXER_LINEIN_C_S == type)) | 548 | } else if (cap.dedicated_mic && (MIXER_LINEIN_C_S == type)) |
549 | atc->line_in_unmute(atc, state); | 549 | atc->line_in_unmute(atc, state); |
550 | else if (have_dedicated_mic && (MIXER_MIC_C_S == type)) | 550 | else if (cap.dedicated_mic && (MIXER_MIC_C_S == type)) |
551 | atc->mic_unmute(atc, state); | 551 | atc->mic_unmute(atc, state); |
552 | else if (MIXER_SPDIFI_C_S == type) | 552 | else if (MIXER_SPDIFI_C_S == type) |
553 | atc->spdif_in_unmute(atc, state); | 553 | atc->spdif_in_unmute(atc, state); |
@@ -739,6 +739,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer) | |||
739 | { | 739 | { |
740 | enum CTALSA_MIXER_CTL type; | 740 | enum CTALSA_MIXER_CTL type; |
741 | struct ct_atc *atc = mixer->atc; | 741 | struct ct_atc *atc = mixer->atc; |
742 | struct capabilities cap = atc->capabilities(atc); | ||
742 | int err; | 743 | int err; |
743 | 744 | ||
744 | /* Create snd kcontrol instances on demand */ | 745 | /* Create snd kcontrol instances on demand */ |
@@ -752,8 +753,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer) | |||
752 | } | 753 | } |
753 | } | 754 | } |
754 | 755 | ||
755 | ct_kcontrol_init_table[MIXER_DIGITAL_IO_S].ctl = | 756 | ct_kcontrol_init_table[MIXER_DIGITAL_IO_S].ctl = cap.digit_io_switch; |
756 | atc->have_digit_io_switch(atc); | ||
757 | 757 | ||
758 | for (type = SWH_MIXER_START; type <= SWH_MIXER_END; type++) { | 758 | for (type = SWH_MIXER_START; type <= SWH_MIXER_END; type++) { |
759 | if (ct_kcontrol_init_table[type].ctl) { | 759 | if (ct_kcontrol_init_table[type].ctl) { |
@@ -777,13 +777,13 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer) | |||
777 | if (err) | 777 | if (err) |
778 | return err; | 778 | return err; |
779 | 779 | ||
780 | if (atc->have_output_switch(atc)) { | 780 | if (cap.output_switch) { |
781 | err = ct_mixer_kcontrol_new(mixer, &output_ctl); | 781 | err = ct_mixer_kcontrol_new(mixer, &output_ctl); |
782 | if (err) | 782 | if (err) |
783 | return err; | 783 | return err; |
784 | } | 784 | } |
785 | 785 | ||
786 | if (atc->have_mic_source_switch(atc)) { | 786 | if (cap.mic_source_switch) { |
787 | err = ct_mixer_kcontrol_new(mixer, &mic_source_ctl); | 787 | err = ct_mixer_kcontrol_new(mixer, &mic_source_ctl); |
788 | if (err) | 788 | if (err) |
789 | return err; | 789 | return err; |
@@ -799,7 +799,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer) | |||
799 | atc->spdif_out_unmute(atc, 0); | 799 | atc->spdif_out_unmute(atc, 0); |
800 | set_switch_state(mixer, MIXER_SPDIFO_P_S, 0); | 800 | set_switch_state(mixer, MIXER_SPDIFO_P_S, 0); |
801 | atc->line_in_unmute(atc, 0); | 801 | atc->line_in_unmute(atc, 0); |
802 | if (atc->have_dedicated_mic(atc)) | 802 | if (cap.dedicated_mic) |
803 | atc->mic_unmute(atc, 0); | 803 | atc->mic_unmute(atc, 0); |
804 | atc->spdif_in_unmute(atc, 0); | 804 | atc->spdif_in_unmute(atc, 0); |
805 | set_switch_state(mixer, MIXER_PCM_C_S, 0); | 805 | set_switch_state(mixer, MIXER_PCM_C_S, 0); |