diff options
author | Roman Volkov <v1ron@mail.ru> | 2014-01-24 07:18:18 -0500 |
---|---|---|
committer | Clemens Ladisch <clemens@ladisch.de> | 2014-01-29 14:45:51 -0500 |
commit | 70e0d82d5e5d65e96f56ced3de97221fdf62cf38 (patch) | |
tree | 93b2a02a266c7a6bbda0c3ab2412af44a8d5002c /sound/pci/oxygen/xonar_dg_mixer.c | |
parent | cf218b2ef345a26f4ae242907150035950f90cb8 (diff) |
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: Roman Volkov <v1ron@mail.ru>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/pci/oxygen/xonar_dg_mixer.c')
-rw-r--r-- | sound/pci/oxygen/xonar_dg_mixer.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/sound/pci/oxygen/xonar_dg_mixer.c b/sound/pci/oxygen/xonar_dg_mixer.c index 2417a1efd719..41ee39359bd6 100644 --- a/sound/pci/oxygen/xonar_dg_mixer.c +++ b/sound/pci/oxygen/xonar_dg_mixer.c | |||
@@ -260,11 +260,27 @@ static int input_vol_put(struct snd_kcontrol *ctl, | |||
260 | return changed; | 260 | return changed; |
261 | } | 261 | } |
262 | 262 | ||
263 | /* Capture Source */ | ||
264 | |||
265 | static int input_source_apply(struct oxygen *chip) | ||
266 | { | ||
267 | struct dg *data = chip->model_data; | ||
268 | |||
269 | data->cs4245_shadow[CS4245_ANALOG_IN] &= ~CS4245_SEL_MASK; | ||
270 | if (data->input_sel == CAPTURE_SRC_FP_MIC) | ||
271 | data->cs4245_shadow[CS4245_ANALOG_IN] |= CS4245_SEL_INPUT_2; | ||
272 | else if (data->input_sel == CAPTURE_SRC_LINE) | ||
273 | data->cs4245_shadow[CS4245_ANALOG_IN] |= CS4245_SEL_INPUT_4; | ||
274 | else if (data->input_sel != CAPTURE_SRC_MIC) | ||
275 | data->cs4245_shadow[CS4245_ANALOG_IN] |= CS4245_SEL_INPUT_1; | ||
276 | return cs4245_write_spi(chip, CS4245_ANALOG_IN); | ||
277 | } | ||
278 | |||
263 | static int input_sel_info(struct snd_kcontrol *ctl, | 279 | static int input_sel_info(struct snd_kcontrol *ctl, |
264 | struct snd_ctl_elem_info *info) | 280 | struct snd_ctl_elem_info *info) |
265 | { | 281 | { |
266 | static const char *const names[4] = { | 282 | static const char *const names[4] = { |
267 | "Mic", "Aux", "Front Mic", "Line" | 283 | "Mic", "Front Mic", "Line", "Aux" |
268 | }; | 284 | }; |
269 | 285 | ||
270 | return snd_ctl_enum_info(info, 1, 4, names); | 286 | return snd_ctl_enum_info(info, 1, 4, names); |
@@ -285,15 +301,10 @@ static int input_sel_get(struct snd_kcontrol *ctl, | |||
285 | static int input_sel_put(struct snd_kcontrol *ctl, | 301 | static int input_sel_put(struct snd_kcontrol *ctl, |
286 | struct snd_ctl_elem_value *value) | 302 | struct snd_ctl_elem_value *value) |
287 | { | 303 | { |
288 | static const u8 sel_values[4] = { | ||
289 | CS4245_SEL_MIC, | ||
290 | CS4245_SEL_INPUT_1, | ||
291 | CS4245_SEL_INPUT_2, | ||
292 | CS4245_SEL_INPUT_4 | ||
293 | }; | ||
294 | struct oxygen *chip = ctl->private_data; | 304 | struct oxygen *chip = ctl->private_data; |
295 | struct dg *data = chip->model_data; | 305 | struct dg *data = chip->model_data; |
296 | int changed; | 306 | int changed; |
307 | int ret; | ||
297 | 308 | ||
298 | if (value->value.enumerated.item[0] > 3) | 309 | if (value->value.enumerated.item[0] > 3) |
299 | return -EINVAL; | 310 | return -EINVAL; |
@@ -303,19 +314,12 @@ static int input_sel_put(struct snd_kcontrol *ctl, | |||
303 | if (changed) { | 314 | if (changed) { |
304 | data->input_sel = value->value.enumerated.item[0]; | 315 | data->input_sel = value->value.enumerated.item[0]; |
305 | 316 | ||
306 | cs4245_write(chip, CS4245_ANALOG_IN, | 317 | ret = input_source_apply(chip); |
307 | (data->cs4245_shadow[CS4245_ANALOG_IN] & | 318 | if (ret >= 0) |
308 | ~CS4245_SEL_MASK) | | 319 | ret = input_volume_apply(chip, |
309 | sel_values[data->input_sel]); | 320 | data->input_vol[data->input_sel][0], |
310 | 321 | data->input_vol[data->input_sel][1]); | |
311 | cs4245_write_cached(chip, CS4245_PGA_A_CTRL, | 322 | changed = ret >= 0 ? 1 : ret; |
312 | data->input_vol[data->input_sel][0]); | ||
313 | cs4245_write_cached(chip, CS4245_PGA_B_CTRL, | ||
314 | data->input_vol[data->input_sel][1]); | ||
315 | |||
316 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, | ||
317 | data->input_sel ? 0 : GPIO_INPUT_ROUTE, | ||
318 | GPIO_INPUT_ROUTE); | ||
319 | } | 323 | } |
320 | mutex_unlock(&chip->mutex); | 324 | mutex_unlock(&chip->mutex); |
321 | return changed; | 325 | return changed; |
@@ -395,10 +399,10 @@ static const struct snd_kcontrol_new dg_controls[] = { | |||
395 | .get = hp_mute_get, | 399 | .get = hp_mute_get, |
396 | .put = hp_mute_put, | 400 | .put = hp_mute_put, |
397 | }, | 401 | }, |
398 | INPUT_VOLUME("Mic Capture Volume", 0), | 402 | INPUT_VOLUME("Mic Capture Volume", CAPTURE_SRC_MIC), |
399 | INPUT_VOLUME("Aux Capture Volume", 1), | 403 | INPUT_VOLUME("Front Mic Capture Volume", CAPTURE_SRC_FP_MIC), |
400 | INPUT_VOLUME("Front Mic Capture Volume", 2), | 404 | INPUT_VOLUME("Line Capture Volume", CAPTURE_SRC_LINE), |
401 | INPUT_VOLUME("Line Capture Volume", 3), | 405 | INPUT_VOLUME("Aux Capture Volume", CAPTURE_SRC_AUX), |
402 | { | 406 | { |
403 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 407 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
404 | .name = "Capture Source", | 408 | .name = "Capture Source", |