Skip to content

Commit 1f91ecc

Browse files
Roman Volkovcladisch
authored andcommitted
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>
1 parent fddc106 commit 1f91ecc

2 files changed

Lines changed: 22 additions & 24 deletions

File tree

‎sound/pci/oxygen/xonar_dg.c‎

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -262,33 +262,29 @@ static void set_cs4245_adc_params(struct oxygen *chip,
262262
cs4245_write_spi(chip, CS4245_MCLK_FREQ);
263263
}
264264

265-
static 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-
276265
static unsigned int adjust_dg_dac_routing(struct oxygen *chip,
277266
unsigned int play_routing)
278267
{
279-
return (play_routing & OXYGEN_PLAY_DAC0_SOURCE_MASK) |
280-
shift_bits(play_routing,
281-
OXYGEN_PLAY_DAC2_SOURCE_SHIFT,
282-
OXYGEN_PLAY_DAC1_SOURCE_SHIFT,
283-
OXYGEN_PLAY_DAC1_SOURCE_MASK) |
284-
shift_bits(play_routing,
285-
OXYGEN_PLAY_DAC1_SOURCE_SHIFT,
286-
OXYGEN_PLAY_DAC2_SOURCE_SHIFT,
287-
OXYGEN_PLAY_DAC2_SOURCE_MASK) |
288-
shift_bits(play_routing,
289-
OXYGEN_PLAY_DAC0_SOURCE_SHIFT,
290-
OXYGEN_PLAY_DAC3_SOURCE_SHIFT,
291-
OXYGEN_PLAY_DAC3_SOURCE_MASK);
268+
struct dg *data = chip->model_data;
269+
unsigned int routing = 0;
270+
271+
switch (data->pcm_output) {
272+
case PLAYBACK_DST_HP:
273+
case PLAYBACK_DST_HP_FP:
274+
oxygen_write8_masked(chip, OXYGEN_PLAY_ROUTING,
275+
OXYGEN_PLAY_MUTE23 | OXYGEN_PLAY_MUTE45 |
276+
OXYGEN_PLAY_MUTE67, OXYGEN_PLAY_MUTE_MASK);
277+
break;
278+
case PLAYBACK_DST_MULTICH:
279+
routing = (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
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;
292288
}
293289

294290
static int output_switch_info(struct snd_kcontrol *ctl,

‎sound/pci/oxygen/xonar_dg.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ enum cs4245_shadow_operation {
2626
struct dg {
2727
/* shadow copy of the CS4245 register space */
2828
unsigned char cs4245_shadow[17];
29+
/* output select: headphone/speakers */
30+
unsigned char pcm_output;
2931
unsigned int output_sel;
3032
s8 input_vol[4][2];
3133
unsigned int input_sel;

0 commit comments

Comments
 (0)