aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen
diff options
context:
space:
mode:
authorRoman Volkov <v1ron@mail.ru>2014-01-24 07:18:11 -0500
committerClemens Ladisch <clemens@ladisch.de>2014-01-29 14:45:48 -0500
commit1f91ecc14deea9461aca93273d78871ec4d98fcd (patch)
tree9d3c09e4a4c710d375d8ea16d168d45e14bc56ca /sound/pci/oxygen
parentfddc106bc35ac2663f42c99bdf404c155a34b9a7 (diff)
ALSA: oxygen: modify adjust_dg_dac_routing function
When selecting the audio output destinations (headphones, FP headphones, multichannel output), the channel routing should be changed depending on what destination selected. Also unnecessary I2S channels are digitally muted. This function called when the user selects the destination in the ALSA mixer. Signed-off-by: Roman Volkov <v1ron@mail.ru> Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/pci/oxygen')
-rw-r--r--sound/pci/oxygen/xonar_dg.c44
-rw-r--r--sound/pci/oxygen/xonar_dg.h2
2 files changed, 22 insertions, 24 deletions
diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c
index 81c004c78766..329da5434556 100644
--- a/sound/pci/oxygen/xonar_dg.c
+++ b/sound/pci/oxygen/xonar_dg.c
@@ -262,33 +262,29 @@ static void set_cs4245_adc_params(struct oxygen *chip,
262 cs4245_write_spi(chip, CS4245_MCLK_FREQ); 262 cs4245_write_spi(chip, CS4245_MCLK_FREQ);
263} 263}
264 264
265static inline unsigned int shift_bits(unsigned int value,
266 unsigned int shift_from,
267 unsigned int shift_to,
268 unsigned int mask)
269{
270 if (shift_from < shift_to)
271 return (value << (shift_to - shift_from)) & mask;
272 else
273 return (value >> (shift_from - shift_to)) & mask;
274}
275
276static unsigned int adjust_dg_dac_routing(struct oxygen *chip, 265static unsigned int adjust_dg_dac_routing(struct oxygen *chip,
277 unsigned int play_routing) 266 unsigned int play_routing)
278{ 267{
279 return (play_routing & OXYGEN_PLAY_DAC0_SOURCE_MASK) | 268 struct dg *data = chip->model_data;
280 shift_bits(play_routing, 269 unsigned int routing = 0;
281 OXYGEN_PLAY_DAC2_SOURCE_SHIFT, 270
282 OXYGEN_PLAY_DAC1_SOURCE_SHIFT, 271 switch (data->pcm_output) {
283 OXYGEN_PLAY_DAC1_SOURCE_MASK) | 272 case PLAYBACK_DST_HP:
284 shift_bits(play_routing, 273 case PLAYBACK_DST_HP_FP:
285 OXYGEN_PLAY_DAC1_SOURCE_SHIFT, 274 oxygen_write8_masked(chip, OXYGEN_PLAY_ROUTING,
286 OXYGEN_PLAY_DAC2_SOURCE_SHIFT, 275 OXYGEN_PLAY_MUTE23 | OXYGEN_PLAY_MUTE45 |
287 OXYGEN_PLAY_DAC2_SOURCE_MASK) | 276 OXYGEN_PLAY_MUTE67, OXYGEN_PLAY_MUTE_MASK);
288 shift_bits(play_routing, 277 break;
289 OXYGEN_PLAY_DAC0_SOURCE_SHIFT, 278 case PLAYBACK_DST_MULTICH:
290 OXYGEN_PLAY_DAC3_SOURCE_SHIFT, 279 routing = (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
291 OXYGEN_PLAY_DAC3_SOURCE_MASK); 280 (2 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
281 (1 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
282 (0 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT);
283 oxygen_write8_masked(chip, OXYGEN_PLAY_ROUTING,
284 OXYGEN_PLAY_MUTE01, OXYGEN_PLAY_MUTE_MASK);
285 break;
286 }
287 return routing;
292} 288}
293 289
294static int output_switch_info(struct snd_kcontrol *ctl, 290static int output_switch_info(struct snd_kcontrol *ctl,
diff --git a/sound/pci/oxygen/xonar_dg.h b/sound/pci/oxygen/xonar_dg.h
index 944685edfce4..a9fba40bc013 100644
--- a/sound/pci/oxygen/xonar_dg.h
+++ b/sound/pci/oxygen/xonar_dg.h
@@ -26,6 +26,8 @@ enum cs4245_shadow_operation {
26struct dg { 26struct dg {
27 /* shadow copy of the CS4245 register space */ 27 /* shadow copy of the CS4245 register space */
28 unsigned char cs4245_shadow[17]; 28 unsigned char cs4245_shadow[17];
29 /* output select: headphone/speakers */
30 unsigned char pcm_output;
29 unsigned int output_sel; 31 unsigned int output_sel;
30 s8 input_vol[4][2]; 32 s8 input_vol[4][2];
31 unsigned int input_sel; 33 unsigned int input_sel;