aboutsummaryrefslogtreecommitdiffstats
path: root/sound
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
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')
-rw-r--r--sound/pci/oxygen/oxygen_lib.c42
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c42
-rw-r--r--sound/pci/oxygen/oxygen_pcm.c18
-rw-r--r--sound/pci/oxygen/oxygen_regs.h12
4 files changed, 89 insertions, 25 deletions
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 3e61f94ec2e3..bd0050b12149 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -208,21 +208,45 @@ static void __devinit oxygen_init(struct oxygen *chip)
208 oxygen_set_bits8(chip, OXYGEN_FUNCTION, 208 oxygen_set_bits8(chip, OXYGEN_FUNCTION,
209 OXYGEN_FUNCTION_RESET_CODEC | 209 OXYGEN_FUNCTION_RESET_CODEC |
210 chip->model->function_flags); 210 chip->model->function_flags);
211 oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT, 0x010a); 211 oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT,
212 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, 0x010a); 212 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
213 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, 0x010a); 213 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
214 oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, 0x010a); 214 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
215 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
216 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
217 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
218 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
219 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
220 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
221 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
222 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
223 oxygen_write16(chip, OXYGEN_I2S_C_FORMAT,
224 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
225 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
226 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
215 oxygen_set_bits32(chip, OXYGEN_SPDIF_CONTROL, OXYGEN_SPDIF_RATE_MASK); 227 oxygen_set_bits32(chip, OXYGEN_SPDIF_CONTROL, OXYGEN_SPDIF_RATE_MASK);
216 oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits); 228 oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits);
217 oxygen_write16(chip, OXYGEN_PLAY_ROUTING, 0xe400); 229 oxygen_write16(chip, OXYGEN_PLAY_ROUTING,
218 oxygen_write8(chip, OXYGEN_REC_ROUTING, 0x10); 230 OXYGEN_PLAY_MULTICH_I2S_DAC | OXYGEN_PLAY_SPDIF_SPDIF |
219 oxygen_write8(chip, OXYGEN_ADC_MONITOR, 0x00); 231 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
220 oxygen_write8(chip, OXYGEN_A_MONITOR_ROUTING, 0xe4); 232 (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
233 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
234 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT));
235 oxygen_write8(chip, OXYGEN_REC_ROUTING,
236 OXYGEN_REC_A_ROUTE_I2S_ADC_1 |
237 OXYGEN_REC_B_ROUTE_AC97_1 |
238 OXYGEN_REC_C_ROUTE_SPDIF);
239 oxygen_write8(chip, OXYGEN_ADC_MONITOR, 0);
240 oxygen_write8(chip, OXYGEN_A_MONITOR_ROUTING,
241 (0 << OXYGEN_A_MONITOR_ROUTE_0_SHIFT) |
242 (1 << OXYGEN_A_MONITOR_ROUTE_1_SHIFT) |
243 (2 << OXYGEN_A_MONITOR_ROUTE_2_SHIFT) |
244 (3 << OXYGEN_A_MONITOR_ROUTE_3_SHIFT));
221 245
222 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); 246 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
223 oxygen_write16(chip, OXYGEN_DMA_STATUS, 0); 247 oxygen_write16(chip, OXYGEN_DMA_STATUS, 0);
224 248
225 oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0x00); 249 oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0);
226 if (chip->has_ac97_0) { 250 if (chip->has_ac97_0) {
227 oxygen_clear_bits16(chip, OXYGEN_AC97_OUT_CONFIG, 251 oxygen_clear_bits16(chip, OXYGEN_AC97_OUT_CONFIG,
228 OXYGEN_AC97_CODEC0_FRONTL | 252 OXYGEN_AC97_CODEC0_FRONTL |
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) |
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c
index 72481fdd11f3..f147f97bc696 100644
--- a/sound/pci/oxygen/oxygen_pcm.c
+++ b/sound/pci/oxygen/oxygen_pcm.c
@@ -396,7 +396,9 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream,
396 OXYGEN_I2S_FORMAT_MASK | 396 OXYGEN_I2S_FORMAT_MASK |
397 OXYGEN_I2S_MCLK_MASK | 397 OXYGEN_I2S_MCLK_MASK |
398 OXYGEN_I2S_BITS_MASK); 398 OXYGEN_I2S_BITS_MASK);
399 oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x08); 399 oxygen_write8_masked(chip, OXYGEN_REC_ROUTING,
400 OXYGEN_REC_A_ROUTE_I2S_ADC_1,
401 OXYGEN_REC_A_ROUTE_MASK);
400 spin_unlock_irq(&chip->reg_lock); 402 spin_unlock_irq(&chip->reg_lock);
401 403
402 mutex_lock(&chip->mutex); 404 mutex_lock(&chip->mutex);
@@ -428,7 +430,9 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream,
428 OXYGEN_I2S_FORMAT_MASK | 430 OXYGEN_I2S_FORMAT_MASK |
429 OXYGEN_I2S_MCLK_MASK | 431 OXYGEN_I2S_MCLK_MASK |
430 OXYGEN_I2S_BITS_MASK); 432 OXYGEN_I2S_BITS_MASK);
431 oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x10); 433 oxygen_write8_masked(chip, OXYGEN_REC_ROUTING,
434 OXYGEN_REC_B_ROUTE_I2S_ADC_2,
435 OXYGEN_REC_B_ROUTE_MASK);
432 spin_unlock_irq(&chip->reg_lock); 436 spin_unlock_irq(&chip->reg_lock);
433 437
434 mutex_lock(&chip->mutex); 438 mutex_lock(&chip->mutex);
@@ -451,7 +455,9 @@ static int oxygen_rec_c_hw_params(struct snd_pcm_substream *substream,
451 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, 455 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
452 oxygen_format(hw_params) << OXYGEN_REC_FORMAT_C_SHIFT, 456 oxygen_format(hw_params) << OXYGEN_REC_FORMAT_C_SHIFT,
453 OXYGEN_REC_FORMAT_C_MASK); 457 OXYGEN_REC_FORMAT_C_MASK);
454 oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x20); 458 oxygen_write8_masked(chip, OXYGEN_REC_ROUTING,
459 OXYGEN_REC_C_ROUTE_SPDIF,
460 OXYGEN_REC_C_ROUTE_MASK);
455 spin_unlock_irq(&chip->reg_lock); 461 spin_unlock_irq(&chip->reg_lock);
456 return 0; 462 return 0;
457} 463}
@@ -504,7 +510,11 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream,
504 OXYGEN_I2S_RATE_MASK | 510 OXYGEN_I2S_RATE_MASK |
505 OXYGEN_I2S_FORMAT_MASK | 511 OXYGEN_I2S_FORMAT_MASK |
506 OXYGEN_I2S_BITS_MASK); 512 OXYGEN_I2S_BITS_MASK);
507 oxygen_clear_bits16(chip, OXYGEN_PLAY_ROUTING, 0x001f); 513 oxygen_write16_masked(chip, OXYGEN_PLAY_ROUTING,
514 OXYGEN_PLAY_MULTICH_I2S_DAC,
515 OXYGEN_PLAY_MUTE01 | OXYGEN_PLAY_MUTE23 |
516 OXYGEN_PLAY_MUTE45 | OXYGEN_PLAY_MUTE67 |
517 OXYGEN_PLAY_MULTICH_MASK);
508 oxygen_update_dac_routing(chip); 518 oxygen_update_dac_routing(chip);
509 oxygen_update_spdif_source(chip); 519 oxygen_update_spdif_source(chip);
510 spin_unlock_irq(&chip->reg_lock); 520 spin_unlock_irq(&chip->reg_lock);
diff --git a/sound/pci/oxygen/oxygen_regs.h b/sound/pci/oxygen/oxygen_regs.h
index 530f1486f901..3e0cdaecb20c 100644
--- a/sound/pci/oxygen/oxygen_regs.h
+++ b/sound/pci/oxygen/oxygen_regs.h
@@ -360,10 +360,14 @@
360#define OXYGEN_ADC_MONITOR_C_HALF_VOL 0x20 360#define OXYGEN_ADC_MONITOR_C_HALF_VOL 0x20
361 361
362#define OXYGEN_A_MONITOR_ROUTING 0xc4 362#define OXYGEN_A_MONITOR_ROUTING 0xc4
363#define OXYGEN_A_MONITOR_ROUTE_01_MASK 0x03 363#define OXYGEN_A_MONITOR_ROUTE_0_MASK 0x03
364#define OXYGEN_A_MONITOR_ROUTE_23_MASK 0x0c 364#define OXYGEN_A_MONITOR_ROUTE_0_SHIFT 0
365#define OXYGEN_A_MONITOR_ROUTE_45_MASK 0x30 365#define OXYGEN_A_MONITOR_ROUTE_1_MASK 0x0c
366#define OXYGEN_A_MONITOR_ROUTE_67_MASK 0xc0 366#define OXYGEN_A_MONITOR_ROUTE_1_SHIFT 2
367#define OXYGEN_A_MONITOR_ROUTE_2_MASK 0x30
368#define OXYGEN_A_MONITOR_ROUTE_2_SHIFT 4
369#define OXYGEN_A_MONITOR_ROUTE_3_MASK 0xc0
370#define OXYGEN_A_MONITOR_ROUTE_3_SHIFT 6
367 371
368#define OXYGEN_AC97_CONTROL 0xd0 372#define OXYGEN_AC97_CONTROL 0xd0
369#define OXYGEN_AC97_COLD_RESET 0x0001 373#define OXYGEN_AC97_COLD_RESET 0x0001