aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen/oxygen_mixer.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-01-21 02:44:24 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:30:05 -0500
commitc9946b2c807aa2e6829765accc267415a893f74a (patch)
treea0013598935d3da7b1f117eccb3c28f316167d34 /sound/pci/oxygen/oxygen_mixer.c
parent48a8a26dd8ea1f7aeacef6b48f2d4d45508f46ba (diff)
[ALSA] oxygen: remove magic numbers
Replace some magic numbers with register symbols. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/oxygen/oxygen_mixer.c')
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index 6fd2a594e89e..d23d18aed25c 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -120,10 +120,23 @@ static int upmix_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
120 120
121void oxygen_update_dac_routing(struct oxygen *chip) 121void oxygen_update_dac_routing(struct oxygen *chip)
122{ 122{
123 /* DAC 0: front, DAC 1: surround, DAC 2: center/LFE, DAC 3: back */
123 static const unsigned int reg_values[3] = { 124 static const unsigned int reg_values[3] = {
124 0xe400, /* front <- 0, surround <- 1, center <- 2, back <- 3 */ 125 /* stereo -> front */
125 0xe000, /* front <- 0, surround <- 0, center <- 2, back <- 3 */ 126 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
126 0x2000 /* front <- 0, surround <- 0, center <- 2, back <- 0 */ 127 (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
128 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
129 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
130 /* stereo -> front+surround */
131 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
132 (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
133 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
134 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
135 /* stereo -> front+surround+back */
136 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
137 (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
138 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
139 (0 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
127 }; 140 };
128 u8 channels; 141 u8 channels;
129 unsigned int reg_value; 142 unsigned int reg_value;
@@ -133,10 +146,21 @@ void oxygen_update_dac_routing(struct oxygen *chip)
133 if (channels == OXYGEN_PLAY_CHANNELS_2) 146 if (channels == OXYGEN_PLAY_CHANNELS_2)
134 reg_value = reg_values[chip->dac_routing]; 147 reg_value = reg_values[chip->dac_routing];
135 else if (channels == OXYGEN_PLAY_CHANNELS_8) 148 else if (channels == OXYGEN_PLAY_CHANNELS_8)
136 reg_value = 0x6c00; /* surround <- 3, back <- 1 */ 149 /* in 7.1 mode, "rear" channels go to the "back" jack */
150 reg_value = (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
151 (3 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
152 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
153 (1 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT);
137 else 154 else
138 reg_value = 0xe400; 155 reg_value = (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
139 oxygen_write16_masked(chip, OXYGEN_PLAY_ROUTING, reg_value, 0xff00); 156 (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
157 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
158 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT);
159 oxygen_write16_masked(chip, OXYGEN_PLAY_ROUTING, reg_value,
160 OXYGEN_PLAY_DAC0_SOURCE_MASK |
161 OXYGEN_PLAY_DAC1_SOURCE_MASK |
162 OXYGEN_PLAY_DAC2_SOURCE_MASK |
163 OXYGEN_PLAY_DAC3_SOURCE_MASK);
140} 164}
141 165
142static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) 166static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
@@ -199,13 +223,15 @@ void oxygen_update_spdif_source(struct oxygen *chip)
199 old_routing = oxygen_read16(chip, OXYGEN_PLAY_ROUTING); 223 old_routing = oxygen_read16(chip, OXYGEN_PLAY_ROUTING);
200 if (chip->pcm_active & (1 << PCM_SPDIF)) { 224 if (chip->pcm_active & (1 << PCM_SPDIF)) {
201 new_control = old_control | OXYGEN_SPDIF_OUT_ENABLE; 225 new_control = old_control | OXYGEN_SPDIF_OUT_ENABLE;
202 new_routing = (old_routing & ~0x00e0) | 0x0000; 226 new_routing = (old_routing & ~OXYGEN_PLAY_SPDIF_MASK)
227 | OXYGEN_PLAY_SPDIF_SPDIF;
203 oxygen_rate = (old_control >> OXYGEN_SPDIF_OUT_RATE_SHIFT) 228 oxygen_rate = (old_control >> OXYGEN_SPDIF_OUT_RATE_SHIFT)
204 & OXYGEN_I2S_RATE_MASK; 229 & OXYGEN_I2S_RATE_MASK;
205 /* S/PDIF rate was already set by the caller */ 230 /* S/PDIF rate was already set by the caller */
206 } else if ((chip->pcm_active & (1 << PCM_MULTICH)) && 231 } else if ((chip->pcm_active & (1 << PCM_MULTICH)) &&
207 chip->spdif_playback_enable) { 232 chip->spdif_playback_enable) {
208 new_routing = (old_routing & ~0x00e0) | 0x0020; 233 new_routing = (old_routing & ~OXYGEN_PLAY_SPDIF_MASK)
234 | OXYGEN_PLAY_SPDIF_MULTICH_01;
209 oxygen_rate = oxygen_read16(chip, OXYGEN_I2S_MULTICH_FORMAT) 235 oxygen_rate = oxygen_read16(chip, OXYGEN_I2S_MULTICH_FORMAT)
210 & OXYGEN_I2S_RATE_MASK; 236 & OXYGEN_I2S_RATE_MASK;
211 new_control = (old_control & ~OXYGEN_SPDIF_OUT_RATE_MASK) | 237 new_control = (old_control & ~OXYGEN_SPDIF_OUT_RATE_MASK) |