diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2008-01-21 10:44:24 +0300 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 19:30:05 +0300 |
commit | c9946b2c807aa2e6829765accc267415a893f74a (patch) | |
tree | a0013598935d3da7b1f117eccb3c28f316167d34 | |
parent | 48a8a26dd8ea1f7aeacef6b48f2d4d45508f46ba (diff) | |
download | linux-c9946b2c807aa2e6829765accc267415a893f74a.tar.xz |
[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>
-rw-r--r-- | sound/pci/oxygen/oxygen_lib.c | 42 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_mixer.c | 42 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_pcm.c | 18 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_regs.h | 12 |
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) oxygen_set_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC | chip->model->function_flags); - oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT, 0x010a); - oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, 0x010a); - oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, 0x010a); - oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, 0x010a); + oxygen_write16(chip, OXYGEN_I2S_MULTICH_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_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_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits); - oxygen_write16(chip, OXYGEN_PLAY_ROUTING, 0xe400); - oxygen_write8(chip, OXYGEN_REC_ROUTING, 0x10); - oxygen_write8(chip, OXYGEN_ADC_MONITOR, 0x00); - oxygen_write8(chip, OXYGEN_A_MONITOR_ROUTING, 0xe4); + oxygen_write16(chip, OXYGEN_PLAY_ROUTING, + OXYGEN_PLAY_MULTICH_I2S_DAC | OXYGEN_PLAY_SPDIF_SPDIF | + (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) | + (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_DMA_STATUS, 0); - oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0x00); + oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0); if (chip->has_ac97_0) { oxygen_clear_bits16(chip, OXYGEN_AC97_OUT_CONFIG, 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) 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] = { - 0xe400, /* front <- 0, surround <- 1, center <- 2, back <- 3 */ - 0xe000, /* front <- 0, surround <- 0, center <- 2, back <- 3 */ - 0x2000 /* front <- 0, surround <- 0, center <- 2, back <- 0 */ + /* stereo -> front */ + (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) | + (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; unsigned int reg_value; @@ -133,10 +146,21 @@ void oxygen_update_dac_routing(struct oxygen *chip) if (channels == OXYGEN_PLAY_CHANNELS_2) reg_value = reg_values[chip->dac_routing]; 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 - reg_value = 0xe400; - oxygen_write16_masked(chip, OXYGEN_PLAY_ROUTING, reg_value, 0xff00); + reg_value = (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) | + (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) @@ -199,13 +223,15 @@ void oxygen_update_spdif_source(struct oxygen *chip) old_routing = oxygen_read16(chip, OXYGEN_PLAY_ROUTING); if (chip->pcm_active & (1 << PCM_SPDIF)) { 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_I2S_RATE_MASK; /* S/PDIF rate was already set by the caller */ } else if ((chip->pcm_active & (1 << PCM_MULTICH)) && 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_I2S_RATE_MASK; 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, OXYGEN_I2S_FORMAT_MASK | OXYGEN_I2S_MCLK_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); mutex_lock(&chip->mutex); @@ -428,7 +430,9 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream, OXYGEN_I2S_FORMAT_MASK | OXYGEN_I2S_MCLK_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); mutex_lock(&chip->mutex); @@ -451,7 +455,9 @@ static int oxygen_rec_c_hw_params(struct snd_pcm_substream *substream, oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, oxygen_format(hw_params) << OXYGEN_REC_FORMAT_C_SHIFT, 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); return 0; } @@ -504,7 +510,11 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream, OXYGEN_I2S_RATE_MASK | OXYGEN_I2S_FORMAT_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_spdif_source(chip); 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 @@ #define OXYGEN_ADC_MONITOR_C_HALF_VOL 0x20 #define OXYGEN_A_MONITOR_ROUTING 0xc4 -#define OXYGEN_A_MONITOR_ROUTE_01_MASK 0x03 -#define OXYGEN_A_MONITOR_ROUTE_23_MASK 0x0c -#define OXYGEN_A_MONITOR_ROUTE_45_MASK 0x30 -#define OXYGEN_A_MONITOR_ROUTE_67_MASK 0xc0 +#define OXYGEN_A_MONITOR_ROUTE_0_MASK 0x03 +#define OXYGEN_A_MONITOR_ROUTE_0_SHIFT 0 +#define OXYGEN_A_MONITOR_ROUTE_1_MASK 0x0c +#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_COLD_RESET 0x0001 |