diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /sound/pci/ice1712/juli.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'sound/pci/ice1712/juli.c')
-rw-r--r-- | sound/pci/ice1712/juli.c | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c new file mode 100644 index 000000000000..3fb297b969cd --- /dev/null +++ b/sound/pci/ice1712/juli.c | |||
@@ -0,0 +1,230 @@ | |||
1 | /* | ||
2 | * ALSA driver for ICEnsemble VT1724 (Envy24HT) | ||
3 | * | ||
4 | * Lowlevel functions for ESI Juli@ cards | ||
5 | * | ||
6 | * Copyright (c) 2004 Jaroslav Kysela <perex@suse.cz> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include <sound/driver.h> | ||
25 | #include <asm/io.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/slab.h> | ||
30 | #include <sound/core.h> | ||
31 | |||
32 | #include "ice1712.h" | ||
33 | #include "envy24ht.h" | ||
34 | #include "juli.h" | ||
35 | |||
36 | /* | ||
37 | * chip addresses on I2C bus | ||
38 | */ | ||
39 | #define AK4114_ADDR 0x20 /* S/PDIF receiver */ | ||
40 | #define AK4358_ADDR 0x22 /* DAC */ | ||
41 | |||
42 | /* | ||
43 | * GPIO pins | ||
44 | */ | ||
45 | #define GPIO_FREQ_MASK (3<<0) | ||
46 | #define GPIO_FREQ_32KHZ (0<<0) | ||
47 | #define GPIO_FREQ_44KHZ (1<<0) | ||
48 | #define GPIO_FREQ_48KHZ (2<<0) | ||
49 | #define GPIO_MULTI_MASK (3<<2) | ||
50 | #define GPIO_MULTI_4X (0<<2) | ||
51 | #define GPIO_MULTI_2X (1<<2) | ||
52 | #define GPIO_MULTI_1X (2<<2) /* also external */ | ||
53 | #define GPIO_MULTI_HALF (3<<2) | ||
54 | #define GPIO_INTERNAL_CLOCK (1<<4) | ||
55 | #define GPIO_ANALOG_PRESENT (1<<5) /* RO only: 0 = present */ | ||
56 | #define GPIO_RXMCLK_SEL (1<<7) /* must be 0 */ | ||
57 | #define GPIO_AK5385A_CKS0 (1<<8) | ||
58 | #define GPIO_AK5385A_DFS0 (1<<9) /* swapped with DFS1 according doc? */ | ||
59 | #define GPIO_AK5385A_DFS1 (1<<10) | ||
60 | #define GPIO_DIGOUT_MONITOR (1<<11) /* 1 = active */ | ||
61 | #define GPIO_DIGIN_MONITOR (1<<12) /* 1 = active */ | ||
62 | #define GPIO_ANAIN_MONITOR (1<<13) /* 1 = active */ | ||
63 | #define GPIO_AK5385A_MCLK (1<<14) /* must be 0 */ | ||
64 | #define GPIO_MUTE_CONTROL (1<<15) /* 0 = off, 1 = on */ | ||
65 | |||
66 | static void juli_ak4114_write(void *private_data, unsigned char reg, unsigned char val) | ||
67 | { | ||
68 | snd_vt1724_write_i2c((ice1712_t *)private_data, AK4114_ADDR, reg, val); | ||
69 | } | ||
70 | |||
71 | static unsigned char juli_ak4114_read(void *private_data, unsigned char reg) | ||
72 | { | ||
73 | return snd_vt1724_read_i2c((ice1712_t *)private_data, AK4114_ADDR, reg); | ||
74 | } | ||
75 | |||
76 | /* | ||
77 | * AK4358 section | ||
78 | */ | ||
79 | |||
80 | static void juli_akm_lock(akm4xxx_t *ak, int chip) | ||
81 | { | ||
82 | } | ||
83 | |||
84 | static void juli_akm_unlock(akm4xxx_t *ak, int chip) | ||
85 | { | ||
86 | } | ||
87 | |||
88 | static void juli_akm_write(akm4xxx_t *ak, int chip, | ||
89 | unsigned char addr, unsigned char data) | ||
90 | { | ||
91 | ice1712_t *ice = ak->private_data[0]; | ||
92 | |||
93 | snd_assert(chip == 0, return); | ||
94 | snd_vt1724_write_i2c(ice, AK4358_ADDR, addr, data); | ||
95 | } | ||
96 | |||
97 | /* | ||
98 | * change the rate of envy24HT, AK4358 | ||
99 | */ | ||
100 | static void juli_akm_set_rate_val(akm4xxx_t *ak, unsigned int rate) | ||
101 | { | ||
102 | unsigned char old, tmp, dfs; | ||
103 | |||
104 | if (rate == 0) /* no hint - S/PDIF input is master, simply return */ | ||
105 | return; | ||
106 | |||
107 | /* adjust DFS on codecs */ | ||
108 | if (rate > 96000) | ||
109 | dfs = 2; | ||
110 | else if (rate > 48000) | ||
111 | dfs = 1; | ||
112 | else | ||
113 | dfs = 0; | ||
114 | |||
115 | tmp = snd_akm4xxx_get(ak, 0, 2); | ||
116 | old = (tmp >> 4) & 0x03; | ||
117 | if (old == dfs) | ||
118 | return; | ||
119 | /* reset DFS */ | ||
120 | snd_akm4xxx_reset(ak, 1); | ||
121 | tmp = snd_akm4xxx_get(ak, 0, 2); | ||
122 | tmp &= ~(0x03 << 4); | ||
123 | tmp |= dfs << 4; | ||
124 | snd_akm4xxx_set(ak, 0, 2, tmp); | ||
125 | snd_akm4xxx_reset(ak, 0); | ||
126 | } | ||
127 | |||
128 | static akm4xxx_t akm_juli_dac __devinitdata = { | ||
129 | .type = SND_AK4358, | ||
130 | .num_dacs = 2, | ||
131 | .ops = { | ||
132 | .lock = juli_akm_lock, | ||
133 | .unlock = juli_akm_unlock, | ||
134 | .write = juli_akm_write, | ||
135 | .set_rate_val = juli_akm_set_rate_val | ||
136 | } | ||
137 | }; | ||
138 | |||
139 | static int __devinit juli_add_controls(ice1712_t *ice) | ||
140 | { | ||
141 | return snd_ice1712_akm4xxx_build_controls(ice); | ||
142 | } | ||
143 | |||
144 | /* | ||
145 | * initialize the chip | ||
146 | */ | ||
147 | static int __devinit juli_init(ice1712_t *ice) | ||
148 | { | ||
149 | static unsigned char ak4114_init_vals[] = { | ||
150 | /* AK4117_REG_PWRDN */ AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1, | ||
151 | /* AK4114_REQ_FORMAT */ AK4114_DIF_I24I2S, | ||
152 | /* AK4114_REG_IO0 */ AK4114_TX1E, | ||
153 | /* AK4114_REG_IO1 */ AK4114_EFH_1024 | AK4114_DIT | AK4114_IPS(1), | ||
154 | /* AK4114_REG_INT0_MASK */ 0, | ||
155 | /* AK4114_REG_INT1_MASK */ 0 | ||
156 | }; | ||
157 | static unsigned char ak4114_init_txcsb[] = { | ||
158 | 0x41, 0x02, 0x2c, 0x00, 0x00 | ||
159 | }; | ||
160 | int err; | ||
161 | akm4xxx_t *ak; | ||
162 | |||
163 | #if 0 | ||
164 | for (err = 0; err < 0x20; err++) | ||
165 | juli_ak4114_read(ice, err); | ||
166 | juli_ak4114_write(ice, 0, 0x0f); | ||
167 | juli_ak4114_read(ice, 0); | ||
168 | juli_ak4114_read(ice, 1); | ||
169 | #endif | ||
170 | err = snd_ak4114_create(ice->card, | ||
171 | juli_ak4114_read, | ||
172 | juli_ak4114_write, | ||
173 | ak4114_init_vals, ak4114_init_txcsb, | ||
174 | ice, &ice->spec.juli.ak4114); | ||
175 | if (err < 0) | ||
176 | return err; | ||
177 | |||
178 | ice->spec.juli.analog = ice->gpio.get_data(ice) & GPIO_ANALOG_PRESENT; | ||
179 | |||
180 | if (ice->spec.juli.analog) { | ||
181 | printk(KERN_INFO "juli@: analog I/O detected\n"); | ||
182 | ice->num_total_dacs = 2; | ||
183 | ice->num_total_adcs = 2; | ||
184 | |||
185 | ak = ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); | ||
186 | if (! ak) | ||
187 | return -ENOMEM; | ||
188 | ice->akm_codecs = 1; | ||
189 | if ((err = snd_ice1712_akm4xxx_init(ak, &akm_juli_dac, NULL, ice)) < 0) | ||
190 | return err; | ||
191 | } | ||
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | |||
197 | /* | ||
198 | * Juli@ boards don't provide the EEPROM data except for the vendor IDs. | ||
199 | * hence the driver needs to sets up it properly. | ||
200 | */ | ||
201 | |||
202 | static unsigned char juli_eeprom[] __devinitdata = { | ||
203 | 0x20, /* SYSCONF: clock 512, mpu401, 1xADC, 1xDACs */ | ||
204 | 0x80, /* ACLINK: I2S */ | ||
205 | 0xf8, /* I2S: vol, 96k, 24bit, 192k */ | ||
206 | 0xc3, /* SPDIF: out-en, out-int, spdif-in */ | ||
207 | 0x9f, /* GPIO_DIR */ | ||
208 | 0xff, /* GPIO_DIR1 */ | ||
209 | 0x7f, /* GPIO_DIR2 */ | ||
210 | 0x9f, /* GPIO_MASK */ | ||
211 | 0xff, /* GPIO_MASK1 */ | ||
212 | 0x7f, /* GPIO_MASK2 */ | ||
213 | 0x16, /* GPIO_STATE: internal clock, multiple 1x, 48kHz */ | ||
214 | 0x80, /* GPIO_STATE1: mute */ | ||
215 | 0x00, /* GPIO_STATE2 */ | ||
216 | }; | ||
217 | |||
218 | /* entry point */ | ||
219 | struct snd_ice1712_card_info snd_vt1724_juli_cards[] __devinitdata = { | ||
220 | { | ||
221 | .subvendor = VT1724_SUBDEVICE_JULI, | ||
222 | .name = "ESI Juli@", | ||
223 | .model = "juli", | ||
224 | .chip_init = juli_init, | ||
225 | .build_controls = juli_add_controls, | ||
226 | .eeprom_size = sizeof(juli_eeprom), | ||
227 | .eeprom_data = juli_eeprom, | ||
228 | }, | ||
229 | { } /* terminator */ | ||
230 | }; | ||