]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[ALSA] oxygen: remove magic numbers
authorClemens Ladisch <clemens@ladisch.de>
Mon, 21 Jan 2008 07:44:24 +0000 (08:44 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 31 Jan 2008 16:30:05 +0000 (17:30 +0100)
Replace some magic numbers with register symbols.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
sound/pci/oxygen/oxygen_lib.c
sound/pci/oxygen/oxygen_mixer.c
sound/pci/oxygen/oxygen_pcm.c
sound/pci/oxygen/oxygen_regs.h

index 3e61f94ec2e336aeb425c95e2ed3bb194e1088e8..bd0050b1214906d64bf2a6217ea6de34036caa9a 100644 (file)
@@ -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 |
index 6fd2a594e89e23a0e71d4951b47a2ebadc7821a1..d23d18aed25c9a6d36a65441c09af609a74ee44e 100644 (file)
@@ -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) |
index 72481fdd11f318a78a7763578fbc19ed9d0aefde..f147f97bc696a69234d80e910096823aa4f9ff57 100644 (file)
@@ -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);
index 530f1486f90101fdcbe1081e5fe82212ef20e0e5..3e0cdaecb20cf72fbd884b0521d6d9f8d18d2b42 100644 (file)
 #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