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>

authored by Roman Volkov and committed by Clemens Ladisch 70e0d82d cf218b2e

+30 -25
+2 -1
sound/pci/oxygen/xonar_dg.h
··· 30 30 unsigned char output_sel; 31 31 /* volumes for all capture sources */ 32 32 char input_vol[4][2]; 33 - unsigned int input_sel; 33 + /* input select: mic/fp mic/line/aux */ 34 + unsigned char input_sel; 34 35 u8 hp_vol_att; 35 36 }; 36 37
+28 -24
sound/pci/oxygen/xonar_dg_mixer.c
··· 260 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 279 static int input_sel_info(struct snd_kcontrol *ctl, 264 280 struct snd_ctl_elem_info *info) 265 281 { 266 282 static const char *const names[4] = { 267 - "Mic", "Aux", "Front Mic", "Line" 283 + "Mic", "Front Mic", "Line", "Aux" 268 284 }; 269 285 270 286 return snd_ctl_enum_info(info, 1, 4, names); ··· 301 285 static int input_sel_put(struct snd_kcontrol *ctl, 302 286 struct snd_ctl_elem_value *value) 303 287 { 304 - static const u8 sel_values[4] = { 305 - CS4245_SEL_MIC, 306 - CS4245_SEL_INPUT_1, 307 - CS4245_SEL_INPUT_2, 308 - CS4245_SEL_INPUT_4 309 - }; 310 288 struct oxygen *chip = ctl->private_data; 311 289 struct dg *data = chip->model_data; 312 290 int changed; 291 + int ret; 313 292 314 293 if (value->value.enumerated.item[0] > 3) 315 294 return -EINVAL; ··· 314 303 if (changed) { 315 304 data->input_sel = value->value.enumerated.item[0]; 316 305 317 - cs4245_write(chip, CS4245_ANALOG_IN, 318 - (data->cs4245_shadow[CS4245_ANALOG_IN] & 319 - ~CS4245_SEL_MASK) | 320 - sel_values[data->input_sel]); 321 - 322 - cs4245_write_cached(chip, CS4245_PGA_A_CTRL, 323 - data->input_vol[data->input_sel][0]); 324 - cs4245_write_cached(chip, CS4245_PGA_B_CTRL, 325 - data->input_vol[data->input_sel][1]); 326 - 327 - oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, 328 - data->input_sel ? 0 : GPIO_INPUT_ROUTE, 329 - GPIO_INPUT_ROUTE); 306 + ret = input_source_apply(chip); 307 + if (ret >= 0) 308 + ret = input_volume_apply(chip, 309 + data->input_vol[data->input_sel][0], 310 + data->input_vol[data->input_sel][1]); 311 + changed = ret >= 0 ? 1 : ret; 330 312 } 331 313 mutex_unlock(&chip->mutex); 332 314 return changed; ··· 399 395 .get = hp_mute_get, 400 396 .put = hp_mute_put, 401 397 }, 402 - INPUT_VOLUME("Mic Capture Volume", 0), 403 - INPUT_VOLUME("Aux Capture Volume", 1), 404 - INPUT_VOLUME("Front Mic Capture Volume", 2), 405 - INPUT_VOLUME("Line Capture Volume", 3), 398 + INPUT_VOLUME("Mic Capture Volume", CAPTURE_SRC_MIC), 399 + INPUT_VOLUME("Front Mic Capture Volume", CAPTURE_SRC_FP_MIC), 400 + INPUT_VOLUME("Line Capture Volume", CAPTURE_SRC_LINE), 401 + INPUT_VOLUME("Aux Capture Volume", CAPTURE_SRC_AUX), 406 402 { 407 403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 408 404 .name = "Capture Source",