summaryrefslogtreecommitdiffstats
path: root/sound/pci/ca0106
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-07-25 18:40:39 +0200
committerJaroslav Kysela <perex@perex.cz>2007-10-16 15:57:59 +0200
commit18b5d32f201462ef7ed3c01773a88b4645128158 (patch)
tree3c6c631104fee79f581bb0d7b23332c76a0d56d1 /sound/pci/ca0106
parent485100706b4b397f8072c756839878f634e21f85 (diff)
downloadlinux-18b5d32f201462ef7ed3c01773a88b4645128158.tar.bz2
[ALSA] ca0106: Add more symbol SPI register names and use them
Add more symbol name for SPI register values. Change the SPI_XXX_BIT defines from the bit number to a mask. Saves having to write (1<<SPI_XXX_BIT) all the time to convert to mask. We never end up wanting the bit number. Use all the symbol names for the SPI DAC init sequence. The sequence is exactly the same as it was before. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/ca0106')
-rw-r--r--sound/pci/ca0106/ca0106.h79
-rw-r--r--sound/pci/ca0106/ca0106_main.c51
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c2
3 files changed, 92 insertions, 40 deletions
diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h
index 47d923821403..75da1746e758 100644
--- a/sound/pci/ca0106/ca0106.h
+++ b/sound/pci/ca0106/ca0106.h
@@ -559,38 +559,89 @@
#define SPI_REG_MASK 0x1ff /* 16-bit SPI writes have a 7-bit address */
#define SPI_REG_SHIFT 9 /* followed by 9 bits of data */
+#define SPI_LDA1_REG 0 /* digital attenuation */
+#define SPI_RDA1_REG 1
+#define SPI_LDA2_REG 4
+#define SPI_RDA2_REG 5
+#define SPI_LDA3_REG 6
+#define SPI_RDA3_REG 7
+#define SPI_LDA4_REG 13
+#define SPI_RDA4_REG 14
+#define SPI_MASTDA_REG 8
+
+#define SPI_DA_BIT_UPDATE (1<<8) /* update attenuation values */
+#define SPI_DA_BIT_0dB 0xff /* 0 dB */
+#define SPI_DA_BIT_infdB 0x00 /* inf dB attenuation (mute) */
+
+#define SPI_PL_REG 2
+#define SPI_PL_BIT_L_M (0<<5) /* left channel = mute */
+#define SPI_PL_BIT_L_L (1<<5) /* left channel = left */
+#define SPI_PL_BIT_L_R (2<<5) /* left channel = right */
+#define SPI_PL_BIT_L_C (3<<5) /* left channel = (L+R)/2 */
+#define SPI_PL_BIT_R_M (0<<7) /* right channel = mute */
+#define SPI_PL_BIT_R_L (1<<7) /* right channel = left */
+#define SPI_PL_BIT_R_R (2<<7) /* right channel = right */
+#define SPI_PL_BIT_R_C (3<<7) /* right channel = (L+R)/2 */
+#define SPI_IZD_REG 2
+#define SPI_IZD_BIT (1<<4) /* infinite zero detect */
+
+#define SPI_FMT_REG 3
+#define SPI_FMT_BIT_RJ (0<<0) /* right justified mode */
+#define SPI_FMT_BIT_LJ (1<<0) /* left justified mode */
+#define SPI_FMT_BIT_I2S (2<<0) /* I2S mode */
+#define SPI_FMT_BIT_DSP (3<<0) /* DSP Modes A or B */
+#define SPI_LRP_REG 3
+#define SPI_LRP_BIT (1<<2) /* invert LRCLK polarity */
+#define SPI_BCP_REG 3
+#define SPI_BCP_BIT (1<<3) /* invert BCLK polarity */
+#define SPI_IWL_REG 3
+#define SPI_IWL_BIT_16 (0<<4) /* 16-bit world length */
+#define SPI_IWL_BIT_20 (1<<4) /* 20-bit world length */
+#define SPI_IWL_BIT_24 (2<<4) /* 24-bit world length */
+#define SPI_IWL_BIT_32 (3<<4) /* 32-bit world length */
+
+#define SPI_MS_REG 10
+#define SPI_MS_BIT (1<<5) /* master mode */
+#define SPI_RATE_REG 10 /* only applies in master mode */
+#define SPI_RATE_BIT_128 (0<<6) /* MCLK = LRCLK * 128 */
+#define SPI_RATE_BIT_192 (1<<6)
+#define SPI_RATE_BIT_256 (2<<6)
+#define SPI_RATE_BIT_384 (3<<6)
+#define SPI_RATE_BIT_512 (4<<6)
+#define SPI_RATE_BIT_768 (5<<6)
+
/* They really do label the bit for the 4th channel "4" and not "3" */
#define SPI_DMUTE0_REG 9
#define SPI_DMUTE1_REG 9
#define SPI_DMUTE2_REG 9
#define SPI_DMUTE4_REG 15
-#define SPI_DMUTE0_BIT 3
-#define SPI_DMUTE1_BIT 4
-#define SPI_DMUTE2_BIT 5
-#define SPI_DMUTE4_BIT 2
+#define SPI_DMUTE0_BIT (1<<3)
+#define SPI_DMUTE1_BIT (1<<4)
+#define SPI_DMUTE2_BIT (1<<5)
+#define SPI_DMUTE4_BIT (1<<2)
#define SPI_PHASE0_REG 3
#define SPI_PHASE1_REG 3
#define SPI_PHASE2_REG 3
#define SPI_PHASE4_REG 15
-#define SPI_PHASE0_BIT 6
-#define SPI_PHASE1_BIT 7
-#define SPI_PHASE2_BIT 8
-#define SPI_PHASE4_BIT 3
+#define SPI_PHASE0_BIT (1<<6)
+#define SPI_PHASE1_BIT (1<<7)
+#define SPI_PHASE2_BIT (1<<8)
+#define SPI_PHASE4_BIT (1<<3)
#define SPI_PDWN_REG 2 /* power down all DACs */
-#define SPI_PDWN_BIT 2
+#define SPI_PDWN_BIT (1<<2)
#define SPI_DACD0_REG 10 /* power down individual DACs */
#define SPI_DACD1_REG 10
#define SPI_DACD2_REG 10
#define SPI_DACD4_REG 15
-#define SPI_DACD0_BIT 1
-#define SPI_DACD1_BIT 2
-#define SPI_DACD2_BIT 3
-#define SPI_DACD4_BIT 0 /* datasheet error says it's 1 */
+#define SPI_DACD0_BIT (1<<1)
+#define SPI_DACD1_BIT (1<<2)
+#define SPI_DACD2_BIT (1<<3)
+#define SPI_DACD4_BIT (1<<0) /* datasheet error says it's 1 */
#define SPI_PWRDNALL_REG 10 /* power down everything */
-#define SPI_PWRDNALL_BIT 4
+#define SPI_PWRDNALL_BIT (1<<4)
#include "ca_midi.h"
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 36b7cdda7c41..252710e4f5c8 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -467,10 +467,10 @@ static const int spi_dacd_reg[] = {
[PCM_UNKNOWN_CHANNEL] = SPI_DACD1_REG,
};
static const int spi_dacd_bit[] = {
- [PCM_FRONT_CHANNEL] = 1<<SPI_DACD4_BIT,
- [PCM_REAR_CHANNEL] = 1<<SPI_DACD0_BIT,
- [PCM_CENTER_LFE_CHANNEL]= 1<<SPI_DACD2_BIT,
- [PCM_UNKNOWN_CHANNEL] = 1<<SPI_DACD1_BIT,
+ [PCM_FRONT_CHANNEL] = SPI_DACD4_BIT,
+ [PCM_REAR_CHANNEL] = SPI_DACD0_BIT,
+ [PCM_CENTER_LFE_CHANNEL]= SPI_DACD2_BIT,
+ [PCM_UNKNOWN_CHANNEL] = SPI_DACD1_BIT,
};
/* open_playback callback */
@@ -1258,28 +1258,29 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct s
return 0;
}
+#define SPI_REG(reg, value) (((reg) << SPI_REG_SHIFT) | (value))
static unsigned int spi_dac_init[] = {
- 0x00ff,
- 0x02ff,
- 0x0400,
- 0x0520,
- 0x0620, /* Set 24 bit. Was 0x0600 */
- 0x08ff,
- 0x0aff,
- 0x0cff,
- 0x0eff,
- 0x10ff,
- 0x1200,
- 0x1400,
- 0x1480,
- 0x1800,
- 0x1aff,
- 0x1cff,
- 0x1e00,
- 0x0530,
- 0x0602,
- 0x0622,
- 0x140e,
+ SPI_REG(SPI_LDA1_REG, SPI_DA_BIT_0dB), /* 0dB dig. attenuation */
+ SPI_REG(SPI_RDA1_REG, SPI_DA_BIT_0dB),
+ SPI_REG(SPI_PL_REG, 0x00),
+ SPI_REG(SPI_PL_REG, SPI_PL_BIT_L_L | SPI_PL_BIT_R_R),
+ SPI_REG(SPI_FMT_REG, SPI_FMT_BIT_RJ | SPI_IWL_BIT_24),
+ SPI_REG(SPI_LDA2_REG, SPI_DA_BIT_0dB),
+ SPI_REG(SPI_RDA2_REG, SPI_DA_BIT_0dB),
+ SPI_REG(SPI_LDA3_REG, SPI_DA_BIT_0dB),
+ SPI_REG(SPI_RDA3_REG, SPI_DA_BIT_0dB),
+ SPI_REG(SPI_MASTDA_REG, SPI_DA_BIT_0dB),
+ SPI_REG(9, 0x00),
+ SPI_REG(SPI_MS_REG, 0x00),
+ SPI_REG(SPI_MS_REG, SPI_RATE_BIT_256),
+ SPI_REG(12, 0x00),
+ SPI_REG(SPI_LDA4_REG, SPI_DA_BIT_0dB),
+ SPI_REG(SPI_RDA4_REG, SPI_DA_BIT_0dB),
+ SPI_REG(15, 0x00),
+ SPI_REG(SPI_PL_REG, SPI_PL_BIT_L_L | SPI_PL_BIT_R_R | SPI_IZD_BIT),
+ SPI_REG(SPI_FMT_REG, SPI_FMT_BIT_I2S),
+ SPI_REG(SPI_FMT_REG, SPI_FMT_BIT_I2S | SPI_IWL_BIT_24),
+ SPI_REG(SPI_MS_REG, SPI_DACD0_BIT | SPI_DACD1_BIT | SPI_DACD2_BIT),
};
static unsigned int i2c_adc_init[][2] = {
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index 18a0525a6b5c..be519a17dfa5 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -599,7 +599,7 @@ static struct snd_kcontrol_new snd_ca0106_volume_i2c_adc_ctls[] __devinitdata =
.info = spi_mute_info, \
.get = spi_mute_get, \
.put = spi_mute_put, \
- .private_value = (reg<<SPI_REG_SHIFT) | (1<<bit) \
+ .private_value = (reg<<SPI_REG_SHIFT) | (bit) \
}
static struct snd_kcontrol_new snd_ca0106_volume_spi_dac_ctls[]