summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Volkov <v1ron@mail.ru>2014-01-24 16:18:11 +0400
committerClemens Ladisch <clemens@ladisch.de>2014-01-29 20:45:48 +0100
commit1f91ecc14deea9461aca93273d78871ec4d98fcd (patch)
tree9d3c09e4a4c710d375d8ea16d168d45e14bc56ca
parentfddc106bc35ac2663f42c99bdf404c155a34b9a7 (diff)
downloadlinux-1f91ecc14deea9461aca93273d78871ec4d98fcd.tar.gz
linux-1f91ecc14deea9461aca93273d78871ec4d98fcd.tar.bz2
linux-1f91ecc14deea9461aca93273d78871ec4d98fcd.zip
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>
-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,
cs4245_write_spi(chip, CS4245_MCLK_FREQ);
}
-static inline unsigned int shift_bits(unsigned int value,
- unsigned int shift_from,
- unsigned int shift_to,
- unsigned int mask)
-{
- if (shift_from < shift_to)
- return (value << (shift_to - shift_from)) & mask;
- else
- return (value >> (shift_from - shift_to)) & mask;
-}
-
static unsigned int adjust_dg_dac_routing(struct oxygen *chip,
unsigned int play_routing)
{
- return (play_routing & OXYGEN_PLAY_DAC0_SOURCE_MASK) |
- shift_bits(play_routing,
- OXYGEN_PLAY_DAC2_SOURCE_SHIFT,
- OXYGEN_PLAY_DAC1_SOURCE_SHIFT,
- OXYGEN_PLAY_DAC1_SOURCE_MASK) |
- shift_bits(play_routing,
- OXYGEN_PLAY_DAC1_SOURCE_SHIFT,
- OXYGEN_PLAY_DAC2_SOURCE_SHIFT,
- OXYGEN_PLAY_DAC2_SOURCE_MASK) |
- shift_bits(play_routing,
- OXYGEN_PLAY_DAC0_SOURCE_SHIFT,
- OXYGEN_PLAY_DAC3_SOURCE_SHIFT,
- OXYGEN_PLAY_DAC3_SOURCE_MASK);
+ struct dg *data = chip->model_data;
+ unsigned int routing = 0;
+
+ switch (data->pcm_output) {
+ case PLAYBACK_DST_HP:
+ case PLAYBACK_DST_HP_FP:
+ oxygen_write8_masked(chip, OXYGEN_PLAY_ROUTING,
+ OXYGEN_PLAY_MUTE23 | OXYGEN_PLAY_MUTE45 |
+ OXYGEN_PLAY_MUTE67, OXYGEN_PLAY_MUTE_MASK);
+ break;
+ case PLAYBACK_DST_MULTICH:
+ routing = (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
+ (2 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
+ (1 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
+ (0 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT);
+ oxygen_write8_masked(chip, OXYGEN_PLAY_ROUTING,
+ OXYGEN_PLAY_MUTE01, OXYGEN_PLAY_MUTE_MASK);
+ break;
+ }
+ return routing;
}
static 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 {
struct dg {
/* shadow copy of the CS4245 register space */
unsigned char cs4245_shadow[17];
+ /* output select: headphone/speakers */
+ unsigned char pcm_output;
unsigned int output_sel;
s8 input_vol[4][2];
unsigned int input_sel;