Commit b028b818 authored by Harry Butterworth's avatar Harry Butterworth Committed by Takashi Iwai

ALSA: ctxfi: Implement a combined capabilities query method to replace...

ALSA: ctxfi: Implement a combined capabilities query method to replace multiple have_x query methods.
Signed-off-by: default avatarHarry Butterworth <heb1001@gmail.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 55309216
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "ctatc.h" #include "ctatc.h"
#include "ctpcm.h" #include "ctpcm.h"
#include "ctmixer.h" #include "ctmixer.h"
#include "cthardware.h"
#include "ctsrc.h" #include "ctsrc.h"
#include "ctamixer.h" #include "ctamixer.h"
#include "ctdaio.h" #include "ctdaio.h"
...@@ -972,25 +971,11 @@ static int atc_select_mic_in(struct ct_atc *atc) ...@@ -972,25 +971,11 @@ static int atc_select_mic_in(struct ct_atc *atc)
return 0; 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; struct hw *hw = atc->hw;
return hw->have_digit_io_switch(hw); return hw->capabilities(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);
} }
static int atc_output_switch_get(struct ct_atc *atc) 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,13 +992,6 @@ static int atc_output_switch_put(struct ct_atc *atc, int position)
return hw->output_switch_put(hw, 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) static int atc_mic_source_switch_get(struct ct_atc *atc)
{ {
struct hw *hw = atc->hw; struct hw *hw = atc->hw;
...@@ -1664,12 +1642,9 @@ static struct ct_atc atc_preset __devinitdata = { ...@@ -1664,12 +1642,9 @@ static struct ct_atc atc_preset __devinitdata = {
.spdif_out_get_status = atc_spdif_out_get_status, .spdif_out_get_status = atc_spdif_out_get_status,
.spdif_out_set_status = atc_spdif_out_set_status, .spdif_out_set_status = atc_spdif_out_set_status,
.spdif_out_passthru = atc_spdif_out_passthru, .spdif_out_passthru = atc_spdif_out_passthru,
.have_digit_io_switch = atc_have_digit_io_switch, .capabilities = atc_capabilities,
.have_dedicated_mic = atc_have_dedicated_mic,
.have_output_switch = atc_have_output_switch,
.output_switch_get = atc_output_switch_get, .output_switch_get = atc_output_switch_get,
.output_switch_put = atc_output_switch_put, .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_get = atc_mic_source_switch_get,
.mic_source_switch_put = atc_mic_source_switch_put, .mic_source_switch_put = atc_mic_source_switch_put,
#ifdef CONFIG_PM #ifdef CONFIG_PM
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <sound/core.h> #include <sound/core.h>
#include "ctvmem.h" #include "ctvmem.h"
#include "cthardware.h"
#include "ctresource.h" #include "ctresource.h"
enum CTALSADEVS { /* Types of alsa devices */ enum CTALSADEVS { /* Types of alsa devices */
...@@ -121,12 +122,9 @@ struct ct_atc { ...@@ -121,12 +122,9 @@ struct ct_atc {
int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status); 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_set_status)(struct ct_atc *atc, unsigned int status);
int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state); int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state);
int (*have_digit_io_switch)(struct ct_atc *atc); struct capabilities (*capabilities)(struct ct_atc *atc);
int (*have_dedicated_mic)(struct ct_atc *atc);
int (*have_output_switch)(struct ct_atc *atc);
int (*output_switch_get)(struct ct_atc *atc); int (*output_switch_get)(struct ct_atc *atc);
int (*output_switch_put)(struct ct_atc *atc, int position); 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_get)(struct ct_atc *atc);
int (*mic_source_switch_put)(struct ct_atc *atc, int position); int (*mic_source_switch_put)(struct ct_atc *atc, int position);
......
...@@ -61,6 +61,13 @@ struct card_conf { ...@@ -61,6 +61,13 @@ struct card_conf {
unsigned int msr; /* master sample rate in rsrs */ 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 { struct hw {
int (*card_init)(struct hw *hw, struct card_conf *info); int (*card_init)(struct hw *hw, struct card_conf *info);
int (*card_stop)(struct hw *hw); int (*card_stop)(struct hw *hw);
...@@ -71,12 +78,9 @@ struct hw { ...@@ -71,12 +78,9 @@ struct hw {
#endif #endif
int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source); int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source);
int (*select_adc_source)(struct hw *hw, enum ADCSRC source); int (*select_adc_source)(struct hw *hw, enum ADCSRC source);
int (*have_digit_io_switch)(struct hw *hw); struct capabilities (*capabilities)(struct hw *hw);
int (*have_dedicated_mic)(struct hw *hw);
int (*have_output_switch)(struct hw *hw);
int (*output_switch_get)(struct hw *hw); int (*output_switch_get)(struct hw *hw);
int (*output_switch_put)(struct hw *hw, int position); 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_get)(struct hw *hw);
int (*mic_source_switch_put)(struct hw *hw, int position); int (*mic_source_switch_put)(struct hw *hw, int position);
......
...@@ -1777,25 +1777,17 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info) ...@@ -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); 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 */ struct capabilities cap;
return !(hw->model == CTSB073X || hw->model == CTUAA);
}
static int hw_have_dedicated_mic(struct hw *hw)
{
return 0;
}
static int hw_have_output_switch(struct hw *hw) /* SB073x and Vista compatible cards have no digit IO switch */
{ cap.digit_io_switch = !(hw->model == CTSB073X || hw->model == CTUAA);
return 0; cap.dedicated_mic = 0;
} cap.output_switch = 0;
cap.mic_source_switch = 0;
static int hw_have_mic_source_switch(struct hw *hw) return cap;
{
return 0;
} }
#define CTLBITS(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) #define CTLBITS(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
...@@ -2187,10 +2179,7 @@ static struct hw ct20k1_preset __devinitdata = { ...@@ -2187,10 +2179,7 @@ static struct hw ct20k1_preset __devinitdata = {
.pll_init = hw_pll_init, .pll_init = hw_pll_init,
.is_adc_source_selected = hw_is_adc_input_selected, .is_adc_source_selected = hw_is_adc_input_selected,
.select_adc_source = hw_adc_input_select, .select_adc_source = hw_adc_input_select,
.have_digit_io_switch = hw_have_digit_io_switch, .capabilities = hw_capabilities,
.have_dedicated_mic = hw_have_dedicated_mic,
.have_output_switch = hw_have_output_switch,
.have_mic_source_switch = hw_have_mic_source_switch,
#ifdef CONFIG_PM #ifdef CONFIG_PM
.suspend = hw_suspend, .suspend = hw_suspend,
.resume = hw_resume, .resume = hw_resume,
......
...@@ -1915,19 +1915,16 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info) ...@@ -1915,19 +1915,16 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
return err; 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) cap.digit_io_switch = 0;
{ cap.dedicated_mic = hw->model == CTSB1270;
return 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 cap;
{
return hw->model == CTSB1270;
} }
static int hw_output_switch_get(struct hw *hw) 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,11 +1975,6 @@ static int hw_output_switch_put(struct hw *hw, int position)
return 1; 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) static int hw_mic_source_switch_get(struct hw *hw)
{ {
struct hw20k2 *hw20k2 = (struct hw20k2 *)hw; struct hw20k2 *hw20k2 = (struct hw20k2 *)hw;
...@@ -2256,12 +2248,9 @@ static struct hw ct20k2_preset __devinitdata = { ...@@ -2256,12 +2248,9 @@ static struct hw ct20k2_preset __devinitdata = {
.pll_init = hw_pll_init, .pll_init = hw_pll_init,
.is_adc_source_selected = hw_is_adc_input_selected, .is_adc_source_selected = hw_is_adc_input_selected,
.select_adc_source = hw_adc_input_select, .select_adc_source = hw_adc_input_select,
.have_digit_io_switch = hw_have_digit_io_switch, .capabilities = hw_capabilities,
.have_dedicated_mic = hw_have_dedicated_mic,
.have_output_switch = hw_have_output_switch,
.output_switch_get = hw_output_switch_get, .output_switch_get = hw_output_switch_get,
.output_switch_put = hw_output_switch_put, .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_get = hw_mic_source_switch_get,
.mic_source_switch_put = hw_mic_source_switch_put, .mic_source_switch_put = hw_mic_source_switch_put,
#ifdef CONFIG_PM #ifdef CONFIG_PM
......
...@@ -527,7 +527,7 @@ do_digit_io_switch(struct ct_atc *atc, int state) ...@@ -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) static void do_switch(struct ct_atc *atc, enum CTALSA_MIXER_CTL type, int state)
{ {
struct ct_mixer *mixer = atc->mixer; 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. */ /* Do changes in mixer. */
if ((SWH_CAPTURE_START <= type) && (SWH_CAPTURE_END >= type)) { 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,14 +540,14 @@ static void do_switch(struct ct_atc *atc, enum CTALSA_MIXER_CTL type, int state)
} }
} }
/* Do changes out of mixer. */ /* Do changes out of mixer. */
if (!have_dedicated_mic && if (!cap.dedicated_mic &&
(MIXER_LINEIN_C_S == type || MIXER_MIC_C_S == type)) { (MIXER_LINEIN_C_S == type || MIXER_MIC_C_S == type)) {
if (state) if (state)
do_line_mic_switch(atc, type); do_line_mic_switch(atc, type);
atc->line_in_unmute(atc, state); 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); 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); atc->mic_unmute(atc, state);
else if (MIXER_SPDIFI_C_S == type) else if (MIXER_SPDIFI_C_S == type)
atc->spdif_in_unmute(atc, state); atc->spdif_in_unmute(atc, state);
...@@ -739,6 +739,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer) ...@@ -739,6 +739,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer)
{ {
enum CTALSA_MIXER_CTL type; enum CTALSA_MIXER_CTL type;
struct ct_atc *atc = mixer->atc; struct ct_atc *atc = mixer->atc;
struct capabilities cap = atc->capabilities(atc);
int err; int err;
/* Create snd kcontrol instances on demand */ /* Create snd kcontrol instances on demand */
...@@ -752,8 +753,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer) ...@@ -752,8 +753,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer)
} }
} }
ct_kcontrol_init_table[MIXER_DIGITAL_IO_S].ctl = ct_kcontrol_init_table[MIXER_DIGITAL_IO_S].ctl = cap.digit_io_switch;
atc->have_digit_io_switch(atc);
for (type = SWH_MIXER_START; type <= SWH_MIXER_END; type++) { for (type = SWH_MIXER_START; type <= SWH_MIXER_END; type++) {
if (ct_kcontrol_init_table[type].ctl) { if (ct_kcontrol_init_table[type].ctl) {
...@@ -777,13 +777,13 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer) ...@@ -777,13 +777,13 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer)
if (err) if (err)
return err; return err;
if (atc->have_output_switch(atc)) { if (cap.output_switch) {
err = ct_mixer_kcontrol_new(mixer, &output_ctl); err = ct_mixer_kcontrol_new(mixer, &output_ctl);
if (err) if (err)
return err; return err;
} }
if (atc->have_mic_source_switch(atc)) { if (cap.mic_source_switch) {
err = ct_mixer_kcontrol_new(mixer, &mic_source_ctl); err = ct_mixer_kcontrol_new(mixer, &mic_source_ctl);
if (err) if (err)
return err; return err;
...@@ -799,7 +799,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer) ...@@ -799,7 +799,7 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *mixer)
atc->spdif_out_unmute(atc, 0); atc->spdif_out_unmute(atc, 0);
set_switch_state(mixer, MIXER_SPDIFO_P_S, 0); set_switch_state(mixer, MIXER_SPDIFO_P_S, 0);
atc->line_in_unmute(atc, 0); atc->line_in_unmute(atc, 0);
if (atc->have_dedicated_mic(atc)) if (cap.dedicated_mic)
atc->mic_unmute(atc, 0); atc->mic_unmute(atc, 0);
atc->spdif_in_unmute(atc, 0); atc->spdif_in_unmute(atc, 0);
set_switch_state(mixer, MIXER_PCM_C_S, 0); set_switch_state(mixer, MIXER_PCM_C_S, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment