diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2008-01-21 02:50:19 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:30:07 -0500 |
commit | 878ac3ee76a5abb4952396570207f6ebe0597e52 (patch) | |
tree | 9c5dea50a61302f3b4533314091b8cb9c02f4170 /sound/pci/oxygen/virtuoso.c | |
parent | 44fb7aae82b37f5bb66cb1423e2babb11d90969e (diff) |
[ALSA] oxygen: add more symbols
Add symbol definitions for the various codecs and GPIO pins.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/oxygen/virtuoso.c')
-rw-r--r-- | sound/pci/oxygen/virtuoso.c | 123 |
1 files changed, 94 insertions, 29 deletions
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index 73975711c074..7b240c778759 100644 --- a/sound/pci/oxygen/virtuoso.c +++ b/sound/pci/oxygen/virtuoso.c | |||
@@ -18,6 +18,8 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * CMI8788: | ||
22 | * | ||
21 | * SPI 0 -> 1st PCM1796 (front) | 23 | * SPI 0 -> 1st PCM1796 (front) |
22 | * SPI 1 -> 2nd PCM1796 (surround) | 24 | * SPI 1 -> 2nd PCM1796 (surround) |
23 | * SPI 2 -> 3rd PCM1796 (center/LFE) | 25 | * SPI 2 -> 3rd PCM1796 (center/LFE) |
@@ -25,9 +27,13 @@ | |||
25 | * | 27 | * |
26 | * GPIO 2 -> M0 of CS5381 | 28 | * GPIO 2 -> M0 of CS5381 |
27 | * GPIO 3 -> M1 of CS5381 | 29 | * GPIO 3 -> M1 of CS5381 |
28 | * GPIO 5 <- ? (D2X only) | 30 | * GPIO 5 <- external power present (D2X only) |
29 | * GPIO 7 -> ALT | 31 | * GPIO 7 -> ALT |
30 | * GPIO 8 -> ? (amps enable?) | 32 | * GPIO 8 -> enable output to speakers |
33 | * | ||
34 | * CM9780: | ||
35 | * | ||
36 | * GPIO 0 -> enable AC'97 bypass (line in -> ADC) | ||
31 | */ | 37 | */ |
32 | 38 | ||
33 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
@@ -40,6 +46,7 @@ | |||
40 | #include <sound/pcm.h> | 46 | #include <sound/pcm.h> |
41 | #include <sound/tlv.h> | 47 | #include <sound/tlv.h> |
42 | #include "oxygen.h" | 48 | #include "oxygen.h" |
49 | #include "cm9780.h" | ||
43 | 50 | ||
44 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); | 51 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); |
45 | MODULE_DESCRIPTION("Asus AV200 driver"); | 52 | MODULE_DESCRIPTION("Asus AV200 driver"); |
@@ -64,14 +71,68 @@ static struct pci_device_id xonar_ids[] __devinitdata = { | |||
64 | }; | 71 | }; |
65 | MODULE_DEVICE_TABLE(pci, xonar_ids); | 72 | MODULE_DEVICE_TABLE(pci, xonar_ids); |
66 | 73 | ||
67 | /* register 0x12 */ | 74 | |
75 | #define GPIO_CS5381_M_MASK 0x000c | ||
76 | #define GPIO_CS5381_M_SINGLE 0x0000 | ||
77 | #define GPIO_CS5381_M_DOUBLE 0x0004 | ||
78 | #define GPIO_CS5381_M_QUAD 0x0008 | ||
79 | #define GPIO_EXT_POWER 0x0020 | ||
80 | #define GPIO_ALT 0x0080 | ||
81 | #define GPIO_OUTPUT_ENABLE 0x0100 | ||
82 | |||
83 | /* register 16 */ | ||
84 | #define PCM1796_ATL_MASK 0xff | ||
85 | /* register 17 */ | ||
86 | #define PCM1796_ATR_MASK 0xff | ||
87 | /* register 18 */ | ||
68 | #define PCM1796_MUTE 0x01 | 88 | #define PCM1796_MUTE 0x01 |
69 | #define PCM1796_FMT_24_MSB 0x30 | 89 | #define PCM1796_DME 0x02 |
90 | #define PCM1796_DMF_MASK 0x0c | ||
91 | #define PCM1796_DMF_DISABLED 0x00 | ||
92 | #define PCM1796_DMF_48 0x04 | ||
93 | #define PCM1796_DMF_441 0x08 | ||
94 | #define PCM1796_DMF_32 0x0c | ||
95 | #define PCM1796_FMT_MASK 0x70 | ||
96 | #define PCM1796_FMT_16_RJUST 0x00 | ||
97 | #define PCM1796_FMT_20_RJUST 0x10 | ||
98 | #define PCM1796_FMT_24_RJUST 0x20 | ||
99 | #define PCM1796_FMT_24_LJUST 0x30 | ||
100 | #define PCM1796_FMT_16_I2S 0x40 | ||
101 | #define PCM1796_FMT_24_I2S 0x50 | ||
70 | #define PCM1796_ATLD 0x80 | 102 | #define PCM1796_ATLD 0x80 |
71 | /* register 0x14 */ | 103 | /* register 19 */ |
104 | #define PCM1796_INZD 0x01 | ||
105 | #define PCM1796_FLT_MASK 0x02 | ||
106 | #define PCM1796_FLT_SHARP 0x00 | ||
107 | #define PCM1796_FLT_SLOW 0x02 | ||
108 | #define PCM1796_DFMS 0x04 | ||
109 | #define PCM1796_OPE 0x10 | ||
110 | #define PCM1796_ATS_MASK 0x60 | ||
111 | #define PCM1796_ATS_1 0x00 | ||
112 | #define PCM1796_ATS_2 0x20 | ||
113 | #define PCM1796_ATS_4 0x40 | ||
114 | #define PCM1796_ATS_8 0x60 | ||
115 | #define PCM1796_REV 0x80 | ||
116 | /* register 20 */ | ||
117 | #define PCM1796_OS_MASK 0x03 | ||
72 | #define PCM1796_OS_64 0x00 | 118 | #define PCM1796_OS_64 0x00 |
73 | #define PCM1796_OS_32 0x01 | 119 | #define PCM1796_OS_32 0x01 |
74 | #define PCM1796_OS_128 0x02 | 120 | #define PCM1796_OS_128 0x02 |
121 | #define PCM1796_CHSL_MASK 0x04 | ||
122 | #define PCM1796_CHSL_LEFT 0x00 | ||
123 | #define PCM1796_CHSL_RIGHT 0x04 | ||
124 | #define PCM1796_MONO 0x08 | ||
125 | #define PCM1796_DFTH 0x10 | ||
126 | #define PCM1796_DSD 0x20 | ||
127 | #define PCM1796_SRST 0x40 | ||
128 | /* register 21 */ | ||
129 | #define PCM1796_PCMZ 0x01 | ||
130 | #define PCM1796_DZ_MASK 0x06 | ||
131 | /* register 22 */ | ||
132 | #define PCM1796_ZFGL 0x01 | ||
133 | #define PCM1796_ZFGR 0x02 | ||
134 | /* register 23 */ | ||
135 | #define PCM1796_ID_MASK 0x1f | ||
75 | 136 | ||
76 | static void pcm1796_write(struct oxygen *chip, unsigned int codec, | 137 | static void pcm1796_write(struct oxygen *chip, unsigned int codec, |
77 | u8 reg, u8 value) | 138 | u8 reg, u8 value) |
@@ -93,20 +154,23 @@ static void xonar_init(struct oxygen *chip) | |||
93 | unsigned int i; | 154 | unsigned int i; |
94 | 155 | ||
95 | for (i = 0; i < 4; ++i) { | 156 | for (i = 0; i < 4; ++i) { |
96 | pcm1796_write(chip, i, 0x12, PCM1796_FMT_24_MSB | PCM1796_ATLD); | 157 | pcm1796_write(chip, i, 18, PCM1796_FMT_24_LJUST | PCM1796_ATLD); |
97 | pcm1796_write(chip, i, 0x13, 0); | 158 | pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); |
98 | pcm1796_write(chip, i, 0x14, PCM1796_OS_64); | 159 | pcm1796_write(chip, i, 20, PCM1796_OS_64); |
99 | pcm1796_write(chip, i, 0x15, 0); | 160 | pcm1796_write(chip, i, 21, 0); |
100 | pcm1796_write(chip, i, 0x10, 0xff); | 161 | pcm1796_write(chip, i, 16, 0xff); /* set ATL/ATR after ATLD */ |
101 | pcm1796_write(chip, i, 0x11, 0xff); | 162 | pcm1796_write(chip, i, 17, 0xff); |
102 | } | 163 | } |
103 | 164 | ||
104 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 0x8c); | 165 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, |
105 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, 0x00, 0x8c); | 166 | GPIO_CS5381_M_MASK | GPIO_ALT); |
106 | oxygen_ac97_set_bits(chip, 0, 0x62, 0x0080); | 167 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, |
168 | GPIO_CS5381_M_SINGLE, | ||
169 | GPIO_CS5381_M_MASK | GPIO_ALT); | ||
170 | oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC); | ||
107 | msleep(300); | 171 | msleep(300); |
108 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 0x100); | 172 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_OUTPUT_ENABLE); |
109 | oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, 0x100); | 173 | oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE); |
110 | 174 | ||
111 | snd_component_add(chip->card, "PCM1796"); | 175 | snd_component_add(chip->card, "PCM1796"); |
112 | snd_component_add(chip->card, "CS5381"); | 176 | snd_component_add(chip->card, "CS5381"); |
@@ -114,7 +178,7 @@ static void xonar_init(struct oxygen *chip) | |||
114 | 178 | ||
115 | static void xonar_cleanup(struct oxygen *chip) | 179 | static void xonar_cleanup(struct oxygen *chip) |
116 | { | 180 | { |
117 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, 0x100); | 181 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE); |
118 | } | 182 | } |
119 | 183 | ||
120 | static void set_pcm1796_params(struct oxygen *chip, | 184 | static void set_pcm1796_params(struct oxygen *chip, |
@@ -126,7 +190,7 @@ static void set_pcm1796_params(struct oxygen *chip, | |||
126 | 190 | ||
127 | value = params_rate(params) >= 96000 ? PCM1796_OS_32 : PCM1796_OS_64; | 191 | value = params_rate(params) >= 96000 ? PCM1796_OS_32 : PCM1796_OS_64; |
128 | for (i = 0; i < 4; ++i) | 192 | for (i = 0; i < 4; ++i) |
129 | pcm1796_write(chip, i, 0x14, value); | 193 | pcm1796_write(chip, i, 20, value); |
130 | #endif | 194 | #endif |
131 | } | 195 | } |
132 | 196 | ||
@@ -135,8 +199,8 @@ static void update_pcm1796_volume(struct oxygen *chip) | |||
135 | unsigned int i; | 199 | unsigned int i; |
136 | 200 | ||
137 | for (i = 0; i < 4; ++i) { | 201 | for (i = 0; i < 4; ++i) { |
138 | pcm1796_write(chip, i, 0x10, chip->dac_volume[i * 2]); | 202 | pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]); |
139 | pcm1796_write(chip, i, 0x11, chip->dac_volume[i * 2 + 1]); | 203 | pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]); |
140 | } | 204 | } |
141 | } | 205 | } |
142 | 206 | ||
@@ -145,11 +209,11 @@ static void update_pcm1796_mute(struct oxygen *chip) | |||
145 | unsigned int i; | 209 | unsigned int i; |
146 | u8 value; | 210 | u8 value; |
147 | 211 | ||
148 | value = PCM1796_FMT_24_MSB | PCM1796_ATLD; | 212 | value = PCM1796_FMT_24_LJUST | PCM1796_ATLD; |
149 | if (chip->dac_mute) | 213 | if (chip->dac_mute) |
150 | value |= PCM1796_MUTE; | 214 | value |= PCM1796_MUTE; |
151 | for (i = 0; i < 4; ++i) | 215 | for (i = 0; i < 4; ++i) |
152 | pcm1796_write(chip, i, 0x12, value); | 216 | pcm1796_write(chip, i, 18, value); |
153 | } | 217 | } |
154 | 218 | ||
155 | static void set_cs5381_params(struct oxygen *chip, | 219 | static void set_cs5381_params(struct oxygen *chip, |
@@ -158,12 +222,13 @@ static void set_cs5381_params(struct oxygen *chip, | |||
158 | unsigned int value; | 222 | unsigned int value; |
159 | 223 | ||
160 | if (params_rate(params) <= 54000) | 224 | if (params_rate(params) <= 54000) |
161 | value = 0; | 225 | value = GPIO_CS5381_M_SINGLE; |
162 | else if (params_rate(params) <= 108000) | 226 | else if (params_rate(params) <= 108000) |
163 | value = 4; | 227 | value = GPIO_CS5381_M_DOUBLE; |
164 | else | 228 | else |
165 | value = 8; | 229 | value = GPIO_CS5381_M_QUAD; |
166 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, value, 0x000c); | 230 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, |
231 | value, GPIO_CS5381_M_MASK); | ||
167 | } | 232 | } |
168 | 233 | ||
169 | static int pcm1796_volume_info(struct snd_kcontrol *ctl, | 234 | static int pcm1796_volume_info(struct snd_kcontrol *ctl, |
@@ -182,7 +247,7 @@ static int alt_switch_get(struct snd_kcontrol *ctl, | |||
182 | struct oxygen *chip = ctl->private_data; | 247 | struct oxygen *chip = ctl->private_data; |
183 | 248 | ||
184 | value->value.integer.value[0] = | 249 | value->value.integer.value[0] = |
185 | !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & 0x80); | 250 | !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_ALT); |
186 | return 0; | 251 | return 0; |
187 | } | 252 | } |
188 | 253 | ||
@@ -196,9 +261,9 @@ static int alt_switch_put(struct snd_kcontrol *ctl, | |||
196 | spin_lock_irq(&chip->reg_lock); | 261 | spin_lock_irq(&chip->reg_lock); |
197 | old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); | 262 | old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); |
198 | if (value->value.integer.value[0]) | 263 | if (value->value.integer.value[0]) |
199 | new_bits = old_bits | 0x80; | 264 | new_bits = old_bits | GPIO_ALT; |
200 | else | 265 | else |
201 | new_bits = old_bits & ~0x80; | 266 | new_bits = old_bits & ~GPIO_ALT; |
202 | changed = new_bits != old_bits; | 267 | changed = new_bits != old_bits; |
203 | if (changed) | 268 | if (changed) |
204 | oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits); | 269 | oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits); |