Commit c9946b2c authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Jaroslav Kysela

[ALSA] oxygen: remove magic numbers

Replace some magic numbers with register symbols.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 48a8a26d
...@@ -208,21 +208,45 @@ static void __devinit oxygen_init(struct oxygen *chip) ...@@ -208,21 +208,45 @@ static void __devinit oxygen_init(struct oxygen *chip)
oxygen_set_bits8(chip, OXYGEN_FUNCTION, oxygen_set_bits8(chip, OXYGEN_FUNCTION,
OXYGEN_FUNCTION_RESET_CODEC | OXYGEN_FUNCTION_RESET_CODEC |
chip->model->function_flags); chip->model->function_flags);
oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT, 0x010a); oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT,
oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, 0x010a); OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, 0x010a); OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, 0x010a); OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
oxygen_write16(chip, OXYGEN_I2S_C_FORMAT,
OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
oxygen_set_bits32(chip, OXYGEN_SPDIF_CONTROL, OXYGEN_SPDIF_RATE_MASK); oxygen_set_bits32(chip, OXYGEN_SPDIF_CONTROL, OXYGEN_SPDIF_RATE_MASK);
oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits); oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits);
oxygen_write16(chip, OXYGEN_PLAY_ROUTING, 0xe400); oxygen_write16(chip, OXYGEN_PLAY_ROUTING,
oxygen_write8(chip, OXYGEN_REC_ROUTING, 0x10); OXYGEN_PLAY_MULTICH_I2S_DAC | OXYGEN_PLAY_SPDIF_SPDIF |
oxygen_write8(chip, OXYGEN_ADC_MONITOR, 0x00); (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
oxygen_write8(chip, OXYGEN_A_MONITOR_ROUTING, 0xe4); (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
(2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
(3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT));
oxygen_write8(chip, OXYGEN_REC_ROUTING,
OXYGEN_REC_A_ROUTE_I2S_ADC_1 |
OXYGEN_REC_B_ROUTE_AC97_1 |
OXYGEN_REC_C_ROUTE_SPDIF);
oxygen_write8(chip, OXYGEN_ADC_MONITOR, 0);
oxygen_write8(chip, OXYGEN_A_MONITOR_ROUTING,
(0 << OXYGEN_A_MONITOR_ROUTE_0_SHIFT) |
(1 << OXYGEN_A_MONITOR_ROUTE_1_SHIFT) |
(2 << OXYGEN_A_MONITOR_ROUTE_2_SHIFT) |
(3 << OXYGEN_A_MONITOR_ROUTE_3_SHIFT));
oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
oxygen_write16(chip, OXYGEN_DMA_STATUS, 0); oxygen_write16(chip, OXYGEN_DMA_STATUS, 0);
oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0x00); oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0);
if (chip->has_ac97_0) { if (chip->has_ac97_0) {
oxygen_clear_bits16(chip, OXYGEN_AC97_OUT_CONFIG, oxygen_clear_bits16(chip, OXYGEN_AC97_OUT_CONFIG,
OXYGEN_AC97_CODEC0_FRONTL | OXYGEN_AC97_CODEC0_FRONTL |
......
...@@ -120,10 +120,23 @@ static int upmix_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) ...@@ -120,10 +120,23 @@ static int upmix_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
void oxygen_update_dac_routing(struct oxygen *chip) void oxygen_update_dac_routing(struct oxygen *chip)
{ {
/* DAC 0: front, DAC 1: surround, DAC 2: center/LFE, DAC 3: back */
static const unsigned int reg_values[3] = { static const unsigned int reg_values[3] = {
0xe400, /* front <- 0, surround <- 1, center <- 2, back <- 3 */ /* stereo -> front */
0xe000, /* front <- 0, surround <- 0, center <- 2, back <- 3 */ (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
0x2000 /* front <- 0, surround <- 0, center <- 2, back <- 0 */ (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
(2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
(3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
/* stereo -> front+surround */
(0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
(0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
(2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
(3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
/* stereo -> front+surround+back */
(0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
(0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
(2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
(0 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
}; };
u8 channels; u8 channels;
unsigned int reg_value; unsigned int reg_value;
...@@ -133,10 +146,21 @@ void oxygen_update_dac_routing(struct oxygen *chip) ...@@ -133,10 +146,21 @@ void oxygen_update_dac_routing(struct oxygen *chip)
if (channels == OXYGEN_PLAY_CHANNELS_2) if (channels == OXYGEN_PLAY_CHANNELS_2)
reg_value = reg_values[chip->dac_routing]; reg_value = reg_values[chip->dac_routing];
else if (channels == OXYGEN_PLAY_CHANNELS_8) else if (channels == OXYGEN_PLAY_CHANNELS_8)
reg_value = 0x6c00; /* surround <- 3, back <- 1 */ /* in 7.1 mode, "rear" channels go to the "back" jack */
reg_value = (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
(3 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
(2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
(1 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT);
else else
reg_value = 0xe400; reg_value = (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
oxygen_write16_masked(chip, OXYGEN_PLAY_ROUTING, reg_value, 0xff00); (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
(2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
(3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT);
oxygen_write16_masked(chip, OXYGEN_PLAY_ROUTING, reg_value,
OXYGEN_PLAY_DAC0_SOURCE_MASK |
OXYGEN_PLAY_DAC1_SOURCE_MASK |
OXYGEN_PLAY_DAC2_SOURCE_MASK |
OXYGEN_PLAY_DAC3_SOURCE_MASK);
} }
static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) static 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,13 +223,15 @@ void oxygen_update_spdif_source(struct oxygen *chip)
old_routing = oxygen_read16(chip, OXYGEN_PLAY_ROUTING); old_routing = oxygen_read16(chip, OXYGEN_PLAY_ROUTING);
if (chip->pcm_active & (1 << PCM_SPDIF)) { if (chip->pcm_active & (1 << PCM_SPDIF)) {
new_control = old_control | OXYGEN_SPDIF_OUT_ENABLE; new_control = old_control | OXYGEN_SPDIF_OUT_ENABLE;
new_routing = (old_routing & ~0x00e0) | 0x0000; new_routing = (old_routing & ~OXYGEN_PLAY_SPDIF_MASK)
| OXYGEN_PLAY_SPDIF_SPDIF;
oxygen_rate = (old_control >> OXYGEN_SPDIF_OUT_RATE_SHIFT) oxygen_rate = (old_control >> OXYGEN_SPDIF_OUT_RATE_SHIFT)
& OXYGEN_I2S_RATE_MASK; & OXYGEN_I2S_RATE_MASK;
/* S/PDIF rate was already set by the caller */ /* S/PDIF rate was already set by the caller */
} else if ((chip->pcm_active & (1 << PCM_MULTICH)) && } else if ((chip->pcm_active & (1 << PCM_MULTICH)) &&
chip->spdif_playback_enable) { chip->spdif_playback_enable) {
new_routing = (old_routing & ~0x00e0) | 0x0020; new_routing = (old_routing & ~OXYGEN_PLAY_SPDIF_MASK)
| OXYGEN_PLAY_SPDIF_MULTICH_01;
oxygen_rate = oxygen_read16(chip, OXYGEN_I2S_MULTICH_FORMAT) oxygen_rate = oxygen_read16(chip, OXYGEN_I2S_MULTICH_FORMAT)
& OXYGEN_I2S_RATE_MASK; & OXYGEN_I2S_RATE_MASK;
new_control = (old_control & ~OXYGEN_SPDIF_OUT_RATE_MASK) | new_control = (old_control & ~OXYGEN_SPDIF_OUT_RATE_MASK) |
......
...@@ -396,7 +396,9 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream, ...@@ -396,7 +396,9 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream,
OXYGEN_I2S_FORMAT_MASK | OXYGEN_I2S_FORMAT_MASK |
OXYGEN_I2S_MCLK_MASK | OXYGEN_I2S_MCLK_MASK |
OXYGEN_I2S_BITS_MASK); OXYGEN_I2S_BITS_MASK);
oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x08); oxygen_write8_masked(chip, OXYGEN_REC_ROUTING,
OXYGEN_REC_A_ROUTE_I2S_ADC_1,
OXYGEN_REC_A_ROUTE_MASK);
spin_unlock_irq(&chip->reg_lock); spin_unlock_irq(&chip->reg_lock);
mutex_lock(&chip->mutex); mutex_lock(&chip->mutex);
...@@ -428,7 +430,9 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream, ...@@ -428,7 +430,9 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream,
OXYGEN_I2S_FORMAT_MASK | OXYGEN_I2S_FORMAT_MASK |
OXYGEN_I2S_MCLK_MASK | OXYGEN_I2S_MCLK_MASK |
OXYGEN_I2S_BITS_MASK); OXYGEN_I2S_BITS_MASK);
oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x10); oxygen_write8_masked(chip, OXYGEN_REC_ROUTING,
OXYGEN_REC_B_ROUTE_I2S_ADC_2,
OXYGEN_REC_B_ROUTE_MASK);
spin_unlock_irq(&chip->reg_lock); spin_unlock_irq(&chip->reg_lock);
mutex_lock(&chip->mutex); mutex_lock(&chip->mutex);
...@@ -451,7 +455,9 @@ static int oxygen_rec_c_hw_params(struct snd_pcm_substream *substream, ...@@ -451,7 +455,9 @@ static int oxygen_rec_c_hw_params(struct snd_pcm_substream *substream,
oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
oxygen_format(hw_params) << OXYGEN_REC_FORMAT_C_SHIFT, oxygen_format(hw_params) << OXYGEN_REC_FORMAT_C_SHIFT,
OXYGEN_REC_FORMAT_C_MASK); OXYGEN_REC_FORMAT_C_MASK);
oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x20); oxygen_write8_masked(chip, OXYGEN_REC_ROUTING,
OXYGEN_REC_C_ROUTE_SPDIF,
OXYGEN_REC_C_ROUTE_MASK);
spin_unlock_irq(&chip->reg_lock); spin_unlock_irq(&chip->reg_lock);
return 0; return 0;
} }
...@@ -504,7 +510,11 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream, ...@@ -504,7 +510,11 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream,
OXYGEN_I2S_RATE_MASK | OXYGEN_I2S_RATE_MASK |
OXYGEN_I2S_FORMAT_MASK | OXYGEN_I2S_FORMAT_MASK |
OXYGEN_I2S_BITS_MASK); OXYGEN_I2S_BITS_MASK);
oxygen_clear_bits16(chip, OXYGEN_PLAY_ROUTING, 0x001f); oxygen_write16_masked(chip, OXYGEN_PLAY_ROUTING,
OXYGEN_PLAY_MULTICH_I2S_DAC,
OXYGEN_PLAY_MUTE01 | OXYGEN_PLAY_MUTE23 |
OXYGEN_PLAY_MUTE45 | OXYGEN_PLAY_MUTE67 |
OXYGEN_PLAY_MULTICH_MASK);
oxygen_update_dac_routing(chip); oxygen_update_dac_routing(chip);
oxygen_update_spdif_source(chip); oxygen_update_spdif_source(chip);
spin_unlock_irq(&chip->reg_lock); spin_unlock_irq(&chip->reg_lock);
......
...@@ -360,10 +360,14 @@ ...@@ -360,10 +360,14 @@
#define OXYGEN_ADC_MONITOR_C_HALF_VOL 0x20 #define OXYGEN_ADC_MONITOR_C_HALF_VOL 0x20
#define OXYGEN_A_MONITOR_ROUTING 0xc4 #define OXYGEN_A_MONITOR_ROUTING 0xc4
#define OXYGEN_A_MONITOR_ROUTE_01_MASK 0x03 #define OXYGEN_A_MONITOR_ROUTE_0_MASK 0x03
#define OXYGEN_A_MONITOR_ROUTE_23_MASK 0x0c #define OXYGEN_A_MONITOR_ROUTE_0_SHIFT 0
#define OXYGEN_A_MONITOR_ROUTE_45_MASK 0x30 #define OXYGEN_A_MONITOR_ROUTE_1_MASK 0x0c
#define OXYGEN_A_MONITOR_ROUTE_67_MASK 0xc0 #define OXYGEN_A_MONITOR_ROUTE_1_SHIFT 2
#define OXYGEN_A_MONITOR_ROUTE_2_MASK 0x30
#define OXYGEN_A_MONITOR_ROUTE_2_SHIFT 4
#define OXYGEN_A_MONITOR_ROUTE_3_MASK 0xc0
#define OXYGEN_A_MONITOR_ROUTE_3_SHIFT 6
#define OXYGEN_AC97_CONTROL 0xd0 #define OXYGEN_AC97_CONTROL 0xd0
#define OXYGEN_AC97_COLD_RESET 0x0001 #define OXYGEN_AC97_COLD_RESET 0x0001
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment