summaryrefslogtreecommitdiffstats
path: root/sound/pci/ctxfi
diff options
context:
space:
mode:
authorHarry Butterworth <heb1001@gmail.com>2011-06-11 17:41:13 +0800
committerTakashi Iwai <tiwai@suse.de>2011-06-14 07:34:03 +0200
commitb028b81835d7503d68b230446cd5e39d14ff5b9f (patch)
tree62873fdf6c3c8002eed541b1e637554514d1a826 /sound/pci/ctxfi
parent55309216baeb9d7f951520cf8e8bf2337cd17bad (diff)
downloadop-kernel-dev-b028b81835d7503d68b230446cd5e39d14ff5b9f.zip
op-kernel-dev-b028b81835d7503d68b230446cd5e39d14ff5b9f.tar.gz
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>
Diffstat (limited to 'sound/pci/ctxfi')
-rw-r--r--sound/pci/ctxfi/ctatc.c31
-rw-r--r--sound/pci/ctxfi/ctatc.h6
-rw-r--r--sound/pci/ctxfi/cthardware.h12
-rw-r--r--sound/pci/ctxfi/cthw20k1.c29
-rw-r--r--sound/pci/ctxfi/cthw20k2.c27
-rw-r--r--sound/pci/ctxfi/ctmixer.c18
6 files changed, 39 insertions, 84 deletions
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index 952fd94..d8a4423 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -18,7 +18,6 @@
#include "ctatc.h"
#include "ctpcm.h"
#include "ctmixer.h"
-#include "cthardware.h"
#include "ctsrc.h"
#include "ctamixer.h"
#include "ctdaio.h"
@@ -972,25 +971,11 @@ static int atc_select_mic_in(struct ct_atc *atc)
return 0;
}
-static int atc_have_digit_io_switch(struct ct_atc *atc)
+static struct capabilities atc_capabilities(struct ct_atc *atc)
{
struct hw *hw = atc->hw;
- return hw->have_digit_io_switch(hw);
-}
-
-static int atc_have_dedicated_mic(struct ct_atc *atc)
-{
- struct hw *hw = atc->hw;
-
- return hw->have_dedicated_mic(hw);
-}
-
-static int atc_have_output_switch(struct ct_atc *atc)
-{
- struct hw *hw = atc->hw;
-
- return hw->have_output_switch(hw);
+ return hw->capabilities(hw);
}
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)
return hw->output_switch_put(hw, position);
}
-static int atc_have_mic_source_switch(struct ct_atc *atc)
-{
- struct hw *hw = atc->hw;
-
- return hw->have_mic_source_switch(hw);
-}
-
static int atc_mic_source_switch_get(struct ct_atc *atc)
{
struct hw *hw = atc->hw;
@@ -1664,12 +1642,9 @@ static struct ct_atc atc_preset __devinitdata = {
.spdif_out_get_status = atc_spdif_out_get_status,
.spdif_out_set_status = atc_spdif_out_set_status,
.spdif_out_passthru = atc_spdif_out_passthru,
- .have_digit_io_switch = atc_have_digit_io_switch,
- .have_dedicated_mic = atc_have_dedicated_mic,
- .have_output_switch = atc_have_output_switch,
+ .capabilities = atc_capabilities,
.output_switch_get = atc_output_switch_get,
.output_switch_put = atc_output_switch_put,
- .have_mic_source_switch = atc_have_mic_source_switch,
.mic_source_switch_get = atc_mic_source_switch_get,
.mic_source_switch_put = atc_mic_source_switch_put,
#ifdef CONFIG_PM
diff --git a/sound/pci/ctxfi/ctatc.h b/sound/pci/ctxfi/ctatc.h
index 6bad27e..3a0def6 100644
--- a/sound/pci/ctxfi/ctatc.h
+++ b/sound/pci/ctxfi/ctatc.h
@@ -25,6 +25,7 @@
#include <sound/core.h>
#include "ctvmem.h"
+#include "cthardware.h"
#include "ctresource.h"
enum CTALSADEVS { /* Types of alsa devices */
@@ -121,12 +122,9 @@ struct ct_atc {
int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status);
int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status);
int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state);
- int (*have_digit_io_switch)(struct ct_atc *atc);
- int (*have_dedicated_mic)(struct ct_atc *atc);
- int (*have_output_switch)(struct ct_atc *atc);
+ struct capabilities (*capabilities)(struct ct_atc *atc);
int (*output_switch_get)(struct ct_atc *atc);
int (*output_switch_put)(struct ct_atc *atc, int position);
- int (*have_mic_source_switch)(struct ct_atc *atc);
int (*mic_source_switch_get)(struct ct_atc *atc);
int (*mic_source_switch_put)(struct ct_atc *atc, int position);
diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h
index de59bbf..908315b 100644
--- a/sound/pci/ctxfi/cthardware.h
+++ b/sound/pci/ctxfi/cthardware.h
@@ -61,6 +61,13 @@ struct card_conf {
unsigned int msr; /* master sample rate in rsrs */
};
+struct capabilities {
+ unsigned int digit_io_switch:1;
+ unsigned int dedicated_mic:1;
+ unsigned int output_switch:1;
+ unsigned int mic_source_switch:1;
+};
+
struct hw {
int (*card_init)(struct hw *hw, struct card_conf *info);
int (*card_stop)(struct hw *hw);
@@ -71,12 +78,9 @@ struct hw {
#endif
int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source);
int (*select_adc_source)(struct hw *hw, enum ADCSRC source);
- int (*have_digit_io_switch)(struct hw *hw);
- int (*have_dedicated_mic)(struct hw *hw);
- int (*have_output_switch)(struct hw *hw);
+ struct capabilities (*capabilities)(struct hw *hw);
int (*output_switch_get)(struct hw *hw);
int (*output_switch_put)(struct hw *hw, int position);
- int (*have_mic_source_switch)(struct hw *hw);
int (*mic_source_switch_get)(struct hw *hw);
int (*mic_source_switch_put)(struct hw *hw, int position);
diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c
index 9a85a84..1ff692a 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)
return adc_init_SBx(hw, info->input, info->mic20db);
}
-static int hw_have_digit_io_switch(struct hw *hw)
+static struct capabilities hw_capabilities(struct hw *hw)
{
- /* SB073x and Vista compatible cards have no digit IO switch */
- return !(hw->model == CTSB073X || hw->model == CTUAA);
-}
-
-static int hw_have_dedicated_mic(struct hw *hw)
-{
- return 0;
-}
+ struct capabilities cap;
-static int hw_have_output_switch(struct hw *hw)
-{
- return 0;
-}
+ /* SB073x and Vista compatible cards have no digit IO switch */
+ cap.digit_io_switch = !(hw->model == CTSB073X || hw->model == CTUAA);
+ cap.dedicated_mic = 0;
+ cap.output_switch = 0;
+ cap.mic_source_switch = 0;
-static int hw_have_mic_source_switch(struct hw *hw)
-{
- return 0;
+ return cap;
}
#define CTLBITS(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
@@ -2187,10 +2179,7 @@ static struct hw ct20k1_preset __devinitdata = {
.pll_init = hw_pll_init,
.is_adc_source_selected = hw_is_adc_input_selected,
.select_adc_source = hw_adc_input_select,
- .have_digit_io_switch = hw_have_digit_io_switch,
- .have_dedicated_mic = hw_have_dedicated_mic,
- .have_output_switch = hw_have_output_switch,
- .have_mic_source_switch = hw_have_mic_source_switch,
+ .capabilities = hw_capabilities,
#ifdef CONFIG_PM
.suspend = hw_suspend,
.resume = hw_resume,
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c
index 8bc6e41..ea559a9 100644
--- a/sound/pci/ctxfi/cthw20k2.c
+++ b/sound/pci/ctxfi/cthw20k2.c
@@ -1915,19 +1915,16 @@ error:
return err;
}
-static int hw_have_digit_io_switch(struct hw *hw)
+static struct capabilities hw_capabilities(struct hw *hw)
{
- return 0;
-}
+ struct capabilities cap;
-static int hw_have_dedicated_mic(struct hw *hw)
-{
- return hw->model == CTSB1270;
-}
+ cap.digit_io_switch = 0;
+ cap.dedicated_mic = hw->model == CTSB1270;
+ cap.output_switch = hw->model == CTSB1270;
+ cap.mic_source_switch = hw->model == CTSB1270;
-static int hw_have_output_switch(struct hw *hw)
-{
- return hw->model == CTSB1270;
+ return cap;
}
static int hw_output_switch_get(struct hw *hw)
@@ -1978,11 +1975,6 @@ static int hw_output_switch_put(struct hw *hw, int position)
return 1;
}
-static int hw_have_mic_source_switch(struct hw *hw)
-{
- return hw->model == CTSB1270;
-}
-
static int hw_mic_source_switch_get(struct hw *hw)
{
struct hw20k2 *hw20k2 = (struct hw20k2 *)hw;
@@ -2256,12 +2248,9 @@ static struct hw ct20k2_preset __devinitdata = {
.pll_init = hw_pll_init,
.is_adc_source_selected = hw_is_adc_input_selected,
.select_adc_source = hw_adc_input_select,
- .have_digit_io_switch = hw_have_digit_io_switch,
- .have_dedicated_mic = hw_have_dedicated_mic,
- .have_output_switch = hw_have_output_switch,
+ .capabilities = hw_capabilities,
.output_switch_get = hw_output_switch_get,
.output_switch_put = hw_output_switch_put,
- .have_mic_source_switch = hw_have_mic_source_switch,
.mic_source_switch_get = hw_mic_source_switch_get,
.mic_source_switch_put = hw_mic_source_switch_put,
#ifdef CONFIG_PM
diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c
index 388235c..0cc13ee 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)
static void do_switch(struct ct_atc *atc, enum CTALSA_MIXER_CTL type, int state)
{
struct ct_mixer *mixer = atc->mixer;
- int have_dedicated_mic = atc->have_dedicated_mic(atc);
+ struct capabilities cap = atc->capabilities(atc);
/* Do changes in mixer. */
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)
}
}
/* Do changes out of mixer. */
- if (!have_dedicated_mic &&
+ if (!cap.dedicated_mic &&
(MIXER_LINEIN_C_S == type || MIXER_MIC_C_S == type)) {
if (state)
do_line_mic_switch(atc, type);
atc->line_in_unmute(atc, state);
- } else if (have_dedicated_mic && (MIXER_LINEIN_C_S == type))
+ } else if (cap.dedicated_mic && (MIXER_LINEIN_C_S == type))
atc->line_in_unmute(atc, state);
- else if (have_dedicated_mic && (MIXER_MIC_C_S == type))
+ else if (cap.dedicated_mic && (MIXER_MIC_C_S == type))
atc->mic_unmute(atc, state);
else if (MIXER_SPDIFI_C_S == type)
atc->spdif_in_unmute(atc, state);
@@ -739,6 +739,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer)
{
enum CTALSA_MIXER_CTL type;
struct ct_atc *atc = mixer->atc;
+ struct capabilities cap = atc->capabilities(atc);
int err;
/* Create snd kcontrol instances on demand */
@@ -752,8 +753,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer)
}
}
- ct_kcontrol_init_table[MIXER_DIGITAL_IO_S].ctl =
- atc->have_digit_io_switch(atc);
+ ct_kcontrol_init_table[MIXER_DIGITAL_IO_S].ctl = cap.digit_io_switch;
for (type = SWH_MIXER_START; type <= SWH_MIXER_END; type++) {
if (ct_kcontrol_init_table[type].ctl) {
@@ -777,13 +777,13 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer)
if (err)
return err;
- if (atc->have_output_switch(atc)) {
+ if (cap.output_switch) {
err = ct_mixer_kcontrol_new(mixer, &output_ctl);
if (err)
return err;
}
- if (atc->have_mic_source_switch(atc)) {
+ if (cap.mic_source_switch) {
err = ct_mixer_kcontrol_new(mixer, &mic_source_ctl);
if (err)
return err;
@@ -799,7 +799,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer)
atc->spdif_out_unmute(atc, 0);
set_switch_state(mixer, MIXER_SPDIFO_P_S, 0);
atc->line_in_unmute(atc, 0);
- if (atc->have_dedicated_mic(atc))
+ if (cap.dedicated_mic)
atc->mic_unmute(atc, 0);
atc->spdif_in_unmute(atc, 0);
set_switch_state(mixer, MIXER_PCM_C_S, 0);
OpenPOWER on IntegriCloud