aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/phase.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-10-11 15:39:35 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-11 15:39:35 -0400
commit56c5d900dbb8e042bfad035d18433476931d8f93 (patch)
tree00b793965beeef10db03e0ff021d2d965c410759 /sound/pci/ice1712/phase.c
parent4dd95b63ae25c5cad6986829b5e8788e9faa0330 (diff)
parentead9d23d803ea3a73766c3cb27bf7563ac8d7266 (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: sound/core/memalloc.c
Diffstat (limited to 'sound/pci/ice1712/phase.c')
-rw-r--r--sound/pci/ice1712/phase.c277
1 files changed, 172 insertions, 105 deletions
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index 5a158b73dcaa..de29be8c9657 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -22,15 +22,24 @@
22 */ 22 */
23 23
24/* PHASE 22 overview: 24/* PHASE 22 overview:
25 * Audio controller: VIA Envy24HT-S (slightly trimmed down version of Envy24HT) 25 * Audio controller: VIA Envy24HT-S (slightly trimmed down Envy24HT, 4in/4out)
26 * Analog chip: AK4524 (partially via Philip's 74HCT125) 26 * Analog chip: AK4524 (partially via Philip's 74HCT125)
27 * Digital receiver: CS8414-CS (not supported in this release) 27 * Digital receiver: CS8414-CS (supported in this release)
28 * PHASE 22 revision 2.0 and Terrasoniq/Musonik TS22PCI have CS8416
29 * (support status unknown, please test and report)
28 * 30 *
29 * Envy connects to AK4524 31 * Envy connects to AK4524
30 * - CS directly from GPIO 10 32 * - CS directly from GPIO 10
31 * - CCLK via 74HCT125's gate #4 from GPIO 4 33 * - CCLK via 74HCT125's gate #4 from GPIO 4
32 * - CDTI via 74HCT125's gate #2 from GPIO 5 34 * - CDTI via 74HCT125's gate #2 from GPIO 5
33 * CDTI may be completely blocked by 74HCT125's gate #1 controlled by GPIO 3 35 * CDTI may be completely blocked by 74HCT125's gate #1
36 * controlled by GPIO 3
37 */
38
39/* PHASE 28 overview:
40 * Audio controller: VIA Envy24HT (full untrimmed version, 4in/8out)
41 * Analog chip: WM8770 (8 channel 192k DAC, 2 channel 96k ADC)
42 * Digital receiver: CS8414-CS (supported in this release)
34 */ 43 */
35 44
36#include <asm/io.h> 45#include <asm/io.h>
@@ -77,18 +86,18 @@ struct phase28_spec {
77 * Computed as 20 * Log10(255 / x) 86 * Computed as 20 * Log10(255 / x)
78 */ 87 */
79static const unsigned char wm_vol[256] = { 88static const unsigned char wm_vol[256] = {
80 127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23, 89 127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24,
81 23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 90 24, 23, 23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18,
82 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, 91 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14,
83 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 92 14, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11,
84 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 93 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9,
85 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 94 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7,
86 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 95 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5,
87 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 96 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
88 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 97 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
89 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 98 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
90 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
91 0, 0 100 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
92}; 101};
93 102
94#define WM_VOL_MAX (sizeof(wm_vol) - 1) 103#define WM_VOL_MAX (sizeof(wm_vol) - 1)
@@ -117,26 +126,31 @@ static int __devinit phase22_init(struct snd_ice1712 *ice)
117 struct snd_akm4xxx *ak; 126 struct snd_akm4xxx *ak;
118 int err; 127 int err;
119 128
120 // Configure DAC/ADC description for generic part of ice1724 129 /* Configure DAC/ADC description for generic part of ice1724 */
121 switch (ice->eeprom.subvendor) { 130 switch (ice->eeprom.subvendor) {
122 case VT1724_SUBDEVICE_PHASE22: 131 case VT1724_SUBDEVICE_PHASE22:
132 case VT1724_SUBDEVICE_TS22:
123 ice->num_total_dacs = 2; 133 ice->num_total_dacs = 2;
124 ice->num_total_adcs = 2; 134 ice->num_total_adcs = 2;
125 ice->vt1720 = 1; // Envy24HT-S have 16 bit wide GPIO 135 ice->vt1720 = 1; /* Envy24HT-S have 16 bit wide GPIO */
126 break; 136 break;
127 default: 137 default:
128 snd_BUG(); 138 snd_BUG();
129 return -EINVAL; 139 return -EINVAL;
130 } 140 }
131 141
132 // Initialize analog chips 142 /* Initialize analog chips */
133 ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); 143 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
134 if (! ak) 144 ak = ice->akm;
145 if (!ak)
135 return -ENOMEM; 146 return -ENOMEM;
136 ice->akm_codecs = 1; 147 ice->akm_codecs = 1;
137 switch (ice->eeprom.subvendor) { 148 switch (ice->eeprom.subvendor) {
138 case VT1724_SUBDEVICE_PHASE22: 149 case VT1724_SUBDEVICE_PHASE22:
139 if ((err = snd_ice1712_akm4xxx_init(ak, &akm_phase22, &akm_phase22_priv, ice)) < 0) 150 case VT1724_SUBDEVICE_TS22:
151 err = snd_ice1712_akm4xxx_init(ak, &akm_phase22,
152 &akm_phase22_priv, ice);
153 if (err < 0)
140 return err; 154 return err;
141 break; 155 break;
142 } 156 }
@@ -150,6 +164,7 @@ static int __devinit phase22_add_controls(struct snd_ice1712 *ice)
150 164
151 switch (ice->eeprom.subvendor) { 165 switch (ice->eeprom.subvendor) {
152 case VT1724_SUBDEVICE_PHASE22: 166 case VT1724_SUBDEVICE_PHASE22:
167 case VT1724_SUBDEVICE_TS22:
153 err = snd_ice1712_akm4xxx_build_controls(ice); 168 err = snd_ice1712_akm4xxx_build_controls(ice);
154 if (err < 0) 169 if (err < 0)
155 return err; 170 return err;
@@ -158,9 +173,10 @@ static int __devinit phase22_add_controls(struct snd_ice1712 *ice)
158} 173}
159 174
160static unsigned char phase22_eeprom[] __devinitdata = { 175static unsigned char phase22_eeprom[] __devinitdata = {
161 [ICE_EEP2_SYSCONF] = 0x00, /* 1xADC, 1xDACs */ 176 [ICE_EEP2_SYSCONF] = 0x28, /* clock 512, mpu 401,
177 spdif-in/1xADC, 1xDACs */
162 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 178 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
163 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit */ 179 [ICE_EEP2_I2S] = 0xf0, /* vol, 96k, 24bit */
164 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */ 180 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
165 [ICE_EEP2_GPIO_DIR] = 0xff, 181 [ICE_EEP2_GPIO_DIR] = 0xff,
166 [ICE_EEP2_GPIO_DIR1] = 0xff, 182 [ICE_EEP2_GPIO_DIR1] = 0xff,
@@ -174,7 +190,8 @@ static unsigned char phase22_eeprom[] __devinitdata = {
174}; 190};
175 191
176static unsigned char phase28_eeprom[] __devinitdata = { 192static unsigned char phase28_eeprom[] __devinitdata = {
177 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */ 193 [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401,
194 spdif-in/1xADC, 4xDACs */
178 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 195 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
179 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 196 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
180 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */ 197 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
@@ -192,15 +209,16 @@ static unsigned char phase28_eeprom[] __devinitdata = {
192/* 209/*
193 * write data in the SPI mode 210 * write data in the SPI mode
194 */ 211 */
195static void phase28_spi_write(struct snd_ice1712 *ice, unsigned int cs, unsigned int data, int bits) 212static void phase28_spi_write(struct snd_ice1712 *ice, unsigned int cs,
213 unsigned int data, int bits)
196{ 214{
197 unsigned int tmp; 215 unsigned int tmp;
198 int i; 216 int i;
199 217
200 tmp = snd_ice1712_gpio_read(ice); 218 tmp = snd_ice1712_gpio_read(ice);
201 219
202 snd_ice1712_gpio_set_mask(ice, ~(PHASE28_WM_RW|PHASE28_SPI_MOSI|PHASE28_SPI_CLK| 220 snd_ice1712_gpio_set_mask(ice, ~(PHASE28_WM_RW|PHASE28_SPI_MOSI|
203 PHASE28_WM_CS)); 221 PHASE28_SPI_CLK|PHASE28_WM_CS));
204 tmp |= PHASE28_WM_RW; 222 tmp |= PHASE28_WM_RW;
205 tmp &= ~cs; 223 tmp &= ~cs;
206 snd_ice1712_gpio_write(ice, tmp); 224 snd_ice1712_gpio_write(ice, tmp);
@@ -259,14 +277,16 @@ static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val)
259 ice->akm[0].images[reg + 1] = val; 277 ice->akm[0].images[reg + 1] = val;
260} 278}
261 279
262static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master) 280static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index,
281 unsigned short vol, unsigned short master)
263{ 282{
264 unsigned char nvol; 283 unsigned char nvol;
265 284
266 if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE)) 285 if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE))
267 nvol = 0; 286 nvol = 0;
268 else 287 else
269 nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) * (master & ~WM_VOL_MUTE)) / 127) & WM_VOL_MAX]; 288 nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) *
289 (master & ~WM_VOL_MUTE)) / 127) & WM_VOL_MAX];
270 290
271 wm_put(ice, index, nvol); 291 wm_put(ice, index, nvol);
272 wm_put_nocache(ice, index, 0x180 | nvol); 292 wm_put_nocache(ice, index, 0x180 | nvol);
@@ -277,17 +297,20 @@ static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned sho
277 */ 297 */
278#define wm_pcm_mute_info snd_ctl_boolean_mono_info 298#define wm_pcm_mute_info snd_ctl_boolean_mono_info
279 299
280static int wm_pcm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 300static int wm_pcm_mute_get(struct snd_kcontrol *kcontrol,
301 struct snd_ctl_elem_value *ucontrol)
281{ 302{
282 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 303 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
283 304
284 mutex_lock(&ice->gpio_mutex); 305 mutex_lock(&ice->gpio_mutex);
285 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1; 306 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ?
307 0 : 1;
286 mutex_unlock(&ice->gpio_mutex); 308 mutex_unlock(&ice->gpio_mutex);
287 return 0; 309 return 0;
288} 310}
289 311
290static int wm_pcm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 312static int wm_pcm_mute_put(struct snd_kcontrol *kcontrol,
313 struct snd_ctl_elem_value *ucontrol)
291{ 314{
292 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 315 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
293 unsigned short nval, oval; 316 unsigned short nval, oval;
@@ -296,7 +319,8 @@ static int wm_pcm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
296 snd_ice1712_save_gpio_status(ice); 319 snd_ice1712_save_gpio_status(ice);
297 oval = wm_get(ice, WM_MUTE); 320 oval = wm_get(ice, WM_MUTE);
298 nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10); 321 nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10);
299 if ((change = (nval != oval))) 322 change = (nval != oval);
323 if (change)
300 wm_put(ice, WM_MUTE, nval); 324 wm_put(ice, WM_MUTE, nval);
301 snd_ice1712_restore_gpio_status(ice); 325 snd_ice1712_restore_gpio_status(ice);
302 326
@@ -306,7 +330,8 @@ static int wm_pcm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
306/* 330/*
307 * Master volume attenuation mixer control 331 * Master volume attenuation mixer control
308 */ 332 */
309static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 333static int wm_master_vol_info(struct snd_kcontrol *kcontrol,
334 struct snd_ctl_elem_info *uinfo)
310{ 335{
311 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 336 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
312 uinfo->count = 2; 337 uinfo->count = 2;
@@ -315,17 +340,20 @@ static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
315 return 0; 340 return 0;
316} 341}
317 342
318static int wm_master_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 343static int wm_master_vol_get(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_value *ucontrol)
319{ 345{
320 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 346 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
321 struct phase28_spec *spec = ice->spec; 347 struct phase28_spec *spec = ice->spec;
322 int i; 348 int i;
323 for (i=0; i<2; i++) 349 for (i = 0; i < 2; i++)
324 ucontrol->value.integer.value[i] = spec->master[i] & ~WM_VOL_MUTE; 350 ucontrol->value.integer.value[i] = spec->master[i] &
351 ~WM_VOL_MUTE;
325 return 0; 352 return 0;
326} 353}
327 354
328static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 355static int wm_master_vol_put(struct snd_kcontrol *kcontrol,
356 struct snd_ctl_elem_value *ucontrol)
329{ 357{
330 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 358 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
331 struct phase28_spec *spec = ice->spec; 359 struct phase28_spec *spec = ice->spec;
@@ -355,38 +383,38 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
355{ 383{
356 static const unsigned short wm_inits_phase28[] = { 384 static const unsigned short wm_inits_phase28[] = {
357 /* These come first to reduce init pop noise */ 385 /* These come first to reduce init pop noise */
358 0x1b, 0x044, /* ADC Mux (AC'97 source) */ 386 0x1b, 0x044, /* ADC Mux (AC'97 source) */
359 0x1c, 0x00B, /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */ 387 0x1c, 0x00B, /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */
360 0x1d, 0x009, /* Out Mux2 (VOUT2 = DAC, VOUT3 = DAC) */ 388 0x1d, 0x009, /* Out Mux2 (VOUT2 = DAC, VOUT3 = DAC) */
361 389
362 0x18, 0x000, /* All power-up */ 390 0x18, 0x000, /* All power-up */
363 391
364 0x16, 0x122, /* I2S, normal polarity, 24bit */ 392 0x16, 0x122, /* I2S, normal polarity, 24bit */
365 0x17, 0x022, /* 256fs, slave mode */ 393 0x17, 0x022, /* 256fs, slave mode */
366 0x00, 0, /* DAC1 analog mute */ 394 0x00, 0, /* DAC1 analog mute */
367 0x01, 0, /* DAC2 analog mute */ 395 0x01, 0, /* DAC2 analog mute */
368 0x02, 0, /* DAC3 analog mute */ 396 0x02, 0, /* DAC3 analog mute */
369 0x03, 0, /* DAC4 analog mute */ 397 0x03, 0, /* DAC4 analog mute */
370 0x04, 0, /* DAC5 analog mute */ 398 0x04, 0, /* DAC5 analog mute */
371 0x05, 0, /* DAC6 analog mute */ 399 0x05, 0, /* DAC6 analog mute */
372 0x06, 0, /* DAC7 analog mute */ 400 0x06, 0, /* DAC7 analog mute */
373 0x07, 0, /* DAC8 analog mute */ 401 0x07, 0, /* DAC8 analog mute */
374 0x08, 0x100, /* master analog mute */ 402 0x08, 0x100, /* master analog mute */
375 0x09, 0xff, /* DAC1 digital full */ 403 0x09, 0xff, /* DAC1 digital full */
376 0x0a, 0xff, /* DAC2 digital full */ 404 0x0a, 0xff, /* DAC2 digital full */
377 0x0b, 0xff, /* DAC3 digital full */ 405 0x0b, 0xff, /* DAC3 digital full */
378 0x0c, 0xff, /* DAC4 digital full */ 406 0x0c, 0xff, /* DAC4 digital full */
379 0x0d, 0xff, /* DAC5 digital full */ 407 0x0d, 0xff, /* DAC5 digital full */
380 0x0e, 0xff, /* DAC6 digital full */ 408 0x0e, 0xff, /* DAC6 digital full */
381 0x0f, 0xff, /* DAC7 digital full */ 409 0x0f, 0xff, /* DAC7 digital full */
382 0x10, 0xff, /* DAC8 digital full */ 410 0x10, 0xff, /* DAC8 digital full */
383 0x11, 0x1ff, /* master digital full */ 411 0x11, 0x1ff, /* master digital full */
384 0x12, 0x000, /* phase normal */ 412 0x12, 0x000, /* phase normal */
385 0x13, 0x090, /* unmute DAC L/R */ 413 0x13, 0x090, /* unmute DAC L/R */
386 0x14, 0x000, /* all unmute */ 414 0x14, 0x000, /* all unmute */
387 0x15, 0x000, /* no deemphasis, no ZFLG */ 415 0x15, 0x000, /* no deemphasis, no ZFLG */
388 0x19, 0x000, /* -12dB ADC/L */ 416 0x19, 0x000, /* -12dB ADC/L */
389 0x1a, 0x000, /* -12dB ADC/R */ 417 0x1a, 0x000, /* -12dB ADC/R */
390 (unsigned short)-1 418 (unsigned short)-1
391 }; 419 };
392 420
@@ -404,17 +432,19 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
404 return -ENOMEM; 432 return -ENOMEM;
405 ice->spec = spec; 433 ice->spec = spec;
406 434
407 // Initialize analog chips 435 /* Initialize analog chips */
408 ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); 436 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
437 ak = ice->akm;
409 if (!ak) 438 if (!ak)
410 return -ENOMEM; 439 return -ENOMEM;
411 ice->akm_codecs = 1; 440 ice->akm_codecs = 1;
412 441
413 snd_ice1712_gpio_set_dir(ice, 0x5fffff); /* fix this for the time being */ 442 snd_ice1712_gpio_set_dir(ice, 0x5fffff); /* fix this for time being */
414 443
415 /* reset the wm codec as the SPI mode */ 444 /* reset the wm codec as the SPI mode */
416 snd_ice1712_save_gpio_status(ice); 445 snd_ice1712_save_gpio_status(ice);
417 snd_ice1712_gpio_set_mask(ice, ~(PHASE28_WM_RESET|PHASE28_WM_CS|PHASE28_HP_SEL)); 446 snd_ice1712_gpio_set_mask(ice, ~(PHASE28_WM_RESET|PHASE28_WM_CS|
447 PHASE28_HP_SEL));
418 448
419 tmp = snd_ice1712_gpio_read(ice); 449 tmp = snd_ice1712_gpio_read(ice);
420 tmp &= ~PHASE28_WM_RESET; 450 tmp &= ~PHASE28_WM_RESET;
@@ -446,7 +476,8 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
446/* 476/*
447 * DAC volume attenuation mixer control 477 * DAC volume attenuation mixer control
448 */ 478 */
449static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 479static int wm_vol_info(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_info *uinfo)
450{ 481{
451 int voices = kcontrol->private_value >> 8; 482 int voices = kcontrol->private_value >> 8;
452 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 483 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -456,7 +487,8 @@ static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *
456 return 0; 487 return 0;
457} 488}
458 489
459static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 490static int wm_vol_get(struct snd_kcontrol *kcontrol,
491 struct snd_ctl_elem_value *ucontrol)
460{ 492{
461 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 493 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
462 struct phase28_spec *spec = ice->spec; 494 struct phase28_spec *spec = ice->spec;
@@ -470,7 +502,8 @@ static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *
470 return 0; 502 return 0;
471} 503}
472 504
473static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 505static int wm_vol_put(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_value *ucontrol)
474{ 507{
475 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 508 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
476 struct phase28_spec *spec = ice->spec; 509 struct phase28_spec *spec = ice->spec;
@@ -501,7 +534,8 @@ static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *
501/* 534/*
502 * WM8770 mute control 535 * WM8770 mute control
503 */ 536 */
504static int wm_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { 537static int wm_mute_info(struct snd_kcontrol *kcontrol,
538 struct snd_ctl_elem_info *uinfo) {
505 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 539 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
506 uinfo->count = kcontrol->private_value >> 8; 540 uinfo->count = kcontrol->private_value >> 8;
507 uinfo->value.integer.min = 0; 541 uinfo->value.integer.min = 0;
@@ -509,7 +543,8 @@ static int wm_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info
509 return 0; 543 return 0;
510} 544}
511 545
512static int wm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 546static int wm_mute_get(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_value *ucontrol)
513{ 548{
514 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 549 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
515 struct phase28_spec *spec = ice->spec; 550 struct phase28_spec *spec = ice->spec;
@@ -524,7 +559,8 @@ static int wm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
524 return 0; 559 return 0;
525} 560}
526 561
527static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 562static int wm_mute_put(struct snd_kcontrol *kcontrol,
563 struct snd_ctl_elem_value *ucontrol)
528{ 564{
529 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 565 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
530 struct phase28_spec *spec = ice->spec; 566 struct phase28_spec *spec = ice->spec;
@@ -539,9 +575,10 @@ static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
539 if (ucontrol->value.integer.value[i] != val) { 575 if (ucontrol->value.integer.value[i] != val) {
540 spec->vol[ofs + i] &= ~WM_VOL_MUTE; 576 spec->vol[ofs + i] &= ~WM_VOL_MUTE;
541 spec->vol[ofs + i] |= 577 spec->vol[ofs + i] |=
542 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE; 578 ucontrol->value.integer.value[i] ? 0 :
579 WM_VOL_MUTE;
543 wm_set_vol(ice, ofs + i, spec->vol[ofs + i], 580 wm_set_vol(ice, ofs + i, spec->vol[ofs + i],
544 spec->master[i]); 581 spec->master[i]);
545 change = 1; 582 change = 1;
546 } 583 }
547 } 584 }
@@ -555,7 +592,8 @@ static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
555 */ 592 */
556#define wm_master_mute_info snd_ctl_boolean_stereo_info 593#define wm_master_mute_info snd_ctl_boolean_stereo_info
557 594
558static int wm_master_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 595static int wm_master_mute_get(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
559{ 597{
560 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 598 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
561 struct phase28_spec *spec = ice->spec; 599 struct phase28_spec *spec = ice->spec;
@@ -567,7 +605,8 @@ static int wm_master_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
567 return 0; 605 return 0;
568} 606}
569 607
570static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 608static int wm_master_mute_put(struct snd_kcontrol *kcontrol,
609 struct snd_ctl_elem_value *ucontrol)
571{ 610{
572 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 611 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
573 struct phase28_spec *spec = ice->spec; 612 struct phase28_spec *spec = ice->spec;
@@ -580,11 +619,12 @@ static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
580 int dac; 619 int dac;
581 spec->master[i] &= ~WM_VOL_MUTE; 620 spec->master[i] &= ~WM_VOL_MUTE;
582 spec->master[i] |= 621 spec->master[i] |=
583 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE; 622 ucontrol->value.integer.value[i] ? 0 :
623 WM_VOL_MUTE;
584 for (dac = 0; dac < ice->num_total_dacs; dac += 2) 624 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
585 wm_set_vol(ice, WM_DAC_ATTEN + dac + i, 625 wm_set_vol(ice, WM_DAC_ATTEN + dac + i,
586 spec->vol[dac + i], 626 spec->vol[dac + i],
587 spec->master[i]); 627 spec->master[i]);
588 change = 1; 628 change = 1;
589 } 629 }
590 } 630 }
@@ -597,7 +637,8 @@ static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
597#define PCM_0dB 0xff 637#define PCM_0dB 0xff
598#define PCM_RES 128 /* -64dB */ 638#define PCM_RES 128 /* -64dB */
599#define PCM_MIN (PCM_0dB - PCM_RES) 639#define PCM_MIN (PCM_0dB - PCM_RES)
600static int wm_pcm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 640static int wm_pcm_vol_info(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_info *uinfo)
601{ 642{
602 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 643 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
603 uinfo->count = 1; 644 uinfo->count = 1;
@@ -606,7 +647,8 @@ static int wm_pcm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_in
606 return 0; 647 return 0;
607} 648}
608 649
609static int wm_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 650static int wm_pcm_vol_get(struct snd_kcontrol *kcontrol,
651 struct snd_ctl_elem_value *ucontrol)
610{ 652{
611 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 653 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
612 unsigned short val; 654 unsigned short val;
@@ -619,7 +661,8 @@ static int wm_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
619 return 0; 661 return 0;
620} 662}
621 663
622static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 664static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol,
665 struct snd_ctl_elem_value *ucontrol)
623{ 666{
624 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 667 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
625 unsigned short ovol, nvol; 668 unsigned short ovol, nvol;
@@ -633,7 +676,8 @@ static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
633 ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff; 676 ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
634 if (ovol != nvol) { 677 if (ovol != nvol) {
635 wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */ 678 wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */
636 wm_put_nocache(ice, WM_DAC_DIG_MASTER_ATTEN, nvol | 0x100); /* update */ 679 /* update */
680 wm_put_nocache(ice, WM_DAC_DIG_MASTER_ATTEN, nvol | 0x100);
637 change = 1; 681 change = 1;
638 } 682 }
639 snd_ice1712_restore_gpio_status(ice); 683 snd_ice1712_restore_gpio_status(ice);
@@ -645,18 +689,22 @@ static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
645 */ 689 */
646#define phase28_deemp_info snd_ctl_boolean_mono_info 690#define phase28_deemp_info snd_ctl_boolean_mono_info
647 691
648static int phase28_deemp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 692static int phase28_deemp_get(struct snd_kcontrol *kcontrol,
693 struct snd_ctl_elem_value *ucontrol)
649{ 694{
650 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 695 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
651 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf; 696 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) ==
697 0xf;
652 return 0; 698 return 0;
653} 699}
654 700
655static int phase28_deemp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 701static int phase28_deemp_put(struct snd_kcontrol *kcontrol,
702 struct snd_ctl_elem_value *ucontrol)
656{ 703{
657 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 704 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
658 int temp, temp2; 705 int temp, temp2;
659 temp2 = temp = wm_get(ice, WM_DAC_CTRL2); 706 temp = wm_get(ice, WM_DAC_CTRL2);
707 temp2 = temp;
660 if (ucontrol->value.integer.value[0]) 708 if (ucontrol->value.integer.value[0])
661 temp |= 0xf; 709 temp |= 0xf;
662 else 710 else
@@ -671,7 +719,8 @@ static int phase28_deemp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
671/* 719/*
672 * ADC Oversampling 720 * ADC Oversampling
673 */ 721 */
674static int phase28_oversampling_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo) 722static int phase28_oversampling_info(struct snd_kcontrol *k,
723 struct snd_ctl_elem_info *uinfo)
675{ 724{
676 static char *texts[2] = { "128x", "64x" }; 725 static char *texts[2] = { "128x", "64x" };
677 726
@@ -680,25 +729,31 @@ static int phase28_oversampling_info(struct snd_kcontrol *k, struct snd_ctl_elem
680 uinfo->value.enumerated.items = 2; 729 uinfo->value.enumerated.items = 2;
681 730
682 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 731 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
683 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 732 uinfo->value.enumerated.item = uinfo->value.enumerated.items -
684 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 733 1;
734 strcpy(uinfo->value.enumerated.name,
735 texts[uinfo->value.enumerated.item]);
685 736
686 return 0; 737 return 0;
687} 738}
688 739
689static int phase28_oversampling_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 740static int phase28_oversampling_get(struct snd_kcontrol *kcontrol,
741 struct snd_ctl_elem_value *ucontrol)
690{ 742{
691 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 743 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
692 ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8; 744 ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) ==
745 0x8;
693 return 0; 746 return 0;
694} 747}
695 748
696static int phase28_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 749static int phase28_oversampling_put(struct snd_kcontrol *kcontrol,
750 struct snd_ctl_elem_value *ucontrol)
697{ 751{
698 int temp, temp2; 752 int temp, temp2;
699 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 753 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
700 754
701 temp2 = temp = wm_get(ice, WM_MASTER); 755 temp = wm_get(ice, WM_MASTER);
756 temp2 = temp;
702 757
703 if (ucontrol->value.enumerated.item[0]) 758 if (ucontrol->value.enumerated.item[0])
704 temp |= 0x8; 759 temp |= 0x8;
@@ -871,13 +926,16 @@ static int __devinit phase28_add_controls(struct snd_ice1712 *ice)
871 926
872 counts = ARRAY_SIZE(phase28_dac_controls); 927 counts = ARRAY_SIZE(phase28_dac_controls);
873 for (i = 0; i < counts; i++) { 928 for (i = 0; i < counts; i++) {
874 err = snd_ctl_add(ice->card, snd_ctl_new1(&phase28_dac_controls[i], ice)); 929 err = snd_ctl_add(ice->card,
930 snd_ctl_new1(&phase28_dac_controls[i],
931 ice));
875 if (err < 0) 932 if (err < 0)
876 return err; 933 return err;
877 } 934 }
878 935
879 for (i = 0; i < ARRAY_SIZE(wm_controls); i++) { 936 for (i = 0; i < ARRAY_SIZE(wm_controls); i++) {
880 err = snd_ctl_add(ice->card, snd_ctl_new1(&wm_controls[i], ice)); 937 err = snd_ctl_add(ice->card,
938 snd_ctl_new1(&wm_controls[i], ice));
881 if (err < 0) 939 if (err < 0)
882 return err; 940 return err;
883 } 941 }
@@ -904,5 +962,14 @@ struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = {
904 .eeprom_size = sizeof(phase28_eeprom), 962 .eeprom_size = sizeof(phase28_eeprom),
905 .eeprom_data = phase28_eeprom, 963 .eeprom_data = phase28_eeprom,
906 }, 964 },
965 {
966 .subvendor = VT1724_SUBDEVICE_TS22,
967 .name = "Terrasoniq TS22 PCI",
968 .model = "TS22",
969 .chip_init = phase22_init,
970 .build_controls = phase22_add_controls,
971 .eeprom_size = sizeof(phase22_eeprom),
972 .eeprom_data = phase22_eeprom,
973 },
907 { } /* terminator */ 974 { } /* terminator */
908}; 975};