提交 70e0d82d 编写于 作者: R Roman Volkov 提交者: Clemens Ladisch

ALSA: oxygen: Xonar DG(X): modify input select functions

First of all, we should not touch the GPIOs. They are not
for selecting the capture source, but they seems just enable
the whole audio input curcuit. The 'put' function calls the
'apply' functions to change register values. Change the order
of capture sources.
Signed-off-by: NRoman Volkov <v1ron@mail.ru>
Signed-off-by: NClemens Ladisch <clemens@ladisch.de>
上级 cf218b2e
...@@ -30,7 +30,8 @@ struct dg { ...@@ -30,7 +30,8 @@ struct dg {
unsigned char output_sel; unsigned char output_sel;
/* volumes for all capture sources */ /* volumes for all capture sources */
char input_vol[4][2]; char input_vol[4][2];
unsigned int input_sel; /* input select: mic/fp mic/line/aux */
unsigned char input_sel;
u8 hp_vol_att; u8 hp_vol_att;
}; };
......
...@@ -260,11 +260,27 @@ static int input_vol_put(struct snd_kcontrol *ctl, ...@@ -260,11 +260,27 @@ static int input_vol_put(struct snd_kcontrol *ctl,
return changed; return changed;
} }
/* Capture Source */
static int input_source_apply(struct oxygen *chip)
{
struct dg *data = chip->model_data;
data->cs4245_shadow[CS4245_ANALOG_IN] &= ~CS4245_SEL_MASK;
if (data->input_sel == CAPTURE_SRC_FP_MIC)
data->cs4245_shadow[CS4245_ANALOG_IN] |= CS4245_SEL_INPUT_2;
else if (data->input_sel == CAPTURE_SRC_LINE)
data->cs4245_shadow[CS4245_ANALOG_IN] |= CS4245_SEL_INPUT_4;
else if (data->input_sel != CAPTURE_SRC_MIC)
data->cs4245_shadow[CS4245_ANALOG_IN] |= CS4245_SEL_INPUT_1;
return cs4245_write_spi(chip, CS4245_ANALOG_IN);
}
static int input_sel_info(struct snd_kcontrol *ctl, static int input_sel_info(struct snd_kcontrol *ctl,
struct snd_ctl_elem_info *info) struct snd_ctl_elem_info *info)
{ {
static const char *const names[4] = { static const char *const names[4] = {
"Mic", "Aux", "Front Mic", "Line" "Mic", "Front Mic", "Line", "Aux"
}; };
return snd_ctl_enum_info(info, 1, 4, names); return snd_ctl_enum_info(info, 1, 4, names);
...@@ -285,15 +301,10 @@ static int input_sel_get(struct snd_kcontrol *ctl, ...@@ -285,15 +301,10 @@ static int input_sel_get(struct snd_kcontrol *ctl,
static int input_sel_put(struct snd_kcontrol *ctl, static int input_sel_put(struct snd_kcontrol *ctl,
struct snd_ctl_elem_value *value) struct snd_ctl_elem_value *value)
{ {
static const u8 sel_values[4] = {
CS4245_SEL_MIC,
CS4245_SEL_INPUT_1,
CS4245_SEL_INPUT_2,
CS4245_SEL_INPUT_4
};
struct oxygen *chip = ctl->private_data; struct oxygen *chip = ctl->private_data;
struct dg *data = chip->model_data; struct dg *data = chip->model_data;
int changed; int changed;
int ret;
if (value->value.enumerated.item[0] > 3) if (value->value.enumerated.item[0] > 3)
return -EINVAL; return -EINVAL;
...@@ -303,19 +314,12 @@ static int input_sel_put(struct snd_kcontrol *ctl, ...@@ -303,19 +314,12 @@ static int input_sel_put(struct snd_kcontrol *ctl,
if (changed) { if (changed) {
data->input_sel = value->value.enumerated.item[0]; data->input_sel = value->value.enumerated.item[0];
cs4245_write(chip, CS4245_ANALOG_IN, ret = input_source_apply(chip);
(data->cs4245_shadow[CS4245_ANALOG_IN] & if (ret >= 0)
~CS4245_SEL_MASK) | ret = input_volume_apply(chip,
sel_values[data->input_sel]); data->input_vol[data->input_sel][0],
data->input_vol[data->input_sel][1]);
cs4245_write_cached(chip, CS4245_PGA_A_CTRL, changed = ret >= 0 ? 1 : ret;
data->input_vol[data->input_sel][0]);
cs4245_write_cached(chip, CS4245_PGA_B_CTRL,
data->input_vol[data->input_sel][1]);
oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
data->input_sel ? 0 : GPIO_INPUT_ROUTE,
GPIO_INPUT_ROUTE);
} }
mutex_unlock(&chip->mutex); mutex_unlock(&chip->mutex);
return changed; return changed;
...@@ -395,10 +399,10 @@ static const struct snd_kcontrol_new dg_controls[] = { ...@@ -395,10 +399,10 @@ static const struct snd_kcontrol_new dg_controls[] = {
.get = hp_mute_get, .get = hp_mute_get,
.put = hp_mute_put, .put = hp_mute_put,
}, },
INPUT_VOLUME("Mic Capture Volume", 0), INPUT_VOLUME("Mic Capture Volume", CAPTURE_SRC_MIC),
INPUT_VOLUME("Aux Capture Volume", 1), INPUT_VOLUME("Front Mic Capture Volume", CAPTURE_SRC_FP_MIC),
INPUT_VOLUME("Front Mic Capture Volume", 2), INPUT_VOLUME("Line Capture Volume", CAPTURE_SRC_LINE),
INPUT_VOLUME("Line Capture Volume", 3), INPUT_VOLUME("Aux Capture Volume", CAPTURE_SRC_AUX),
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Capture Source", .name = "Capture Source",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册