aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/phase.c
diff options
context:
space:
mode:
authorVedran Miletic <rivanvx@gmail.com>2008-09-07 06:00:02 -0400
committerJaroslav Kysela <perex@perex.cz>2008-09-09 03:11:44 -0400
commitcc67b7f737103a2985e65e00edfdd1a5f89c3af5 (patch)
tree118a769ef9a5ec964a5d41bc8d69da11071b0961 /sound/pci/ice1712/phase.c
parent07f455f779acfb3eba4921fd1399761559b10fa9 (diff)
ALSA: ice1712/ice1724: Coding style fixes part 1 (more coming up)
Inspired by Alexander Beregalov's patches for wtm and aureon.c, I decided to run checkpatch on some more files. After some work checkpatch.pl-0.23 --no-tree --file --strict <file> reports 0 errors, 0 warnings, 0 checks, n lines checked for: phase.c phase.h juli.c (1 check about unused code, maybe we should comment it) juli.h (no changes necessary) In other files I have just fixed // comments and long lines along the way (but not all of them), more coming up. Signed-off-by: Vedran Miletic <rivanvx@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/ice1712/phase.c')
-rw-r--r--sound/pci/ice1712/phase.c244
1 files changed, 144 insertions, 100 deletions
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index 6a614729280f..de29be8c9657 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39/* PHASE 28 overview: 39/* PHASE 28 overview:
40 * Audio controller: VIA Envy24HT (full untrimmed version, 8in/8out) 40 * Audio controller: VIA Envy24HT (full untrimmed version, 4in/8out)
41 * Analog chip: WM8770 (8 channel 192k DAC, 2 channel 96k ADC) 41 * Analog chip: WM8770 (8 channel 192k DAC, 2 channel 96k ADC)
42 * Digital receiver: CS8414-CS (supported in this release) 42 * Digital receiver: CS8414-CS (supported in this release)
43 */ 43 */
@@ -86,18 +86,18 @@ struct phase28_spec {
86 * Computed as 20 * Log10(255 / x) 86 * Computed as 20 * Log10(255 / x)
87 */ 87 */
88static const unsigned char wm_vol[256] = { 88static const unsigned char wm_vol[256] = {
89 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,
90 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,
91 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,
92 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,
93 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,
94 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,
95 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,
96 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,
97 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,
98 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,
99 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,
100 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
101}; 101};
102 102
103#define WM_VOL_MAX (sizeof(wm_vol) - 1) 103#define WM_VOL_MAX (sizeof(wm_vol) - 1)
@@ -126,28 +126,31 @@ static int __devinit phase22_init(struct snd_ice1712 *ice)
126 struct snd_akm4xxx *ak; 126 struct snd_akm4xxx *ak;
127 int err; 127 int err;
128 128
129 // Configure DAC/ADC description for generic part of ice1724 129 /* Configure DAC/ADC description for generic part of ice1724 */
130 switch (ice->eeprom.subvendor) { 130 switch (ice->eeprom.subvendor) {
131 case VT1724_SUBDEVICE_PHASE22: 131 case VT1724_SUBDEVICE_PHASE22:
132 case VT1724_SUBDEVICE_TS22: 132 case VT1724_SUBDEVICE_TS22:
133 ice->num_total_dacs = 2; 133 ice->num_total_dacs = 2;
134 ice->num_total_adcs = 2; 134 ice->num_total_adcs = 2;
135 ice->vt1720 = 1; // Envy24HT-S have 16 bit wide GPIO 135 ice->vt1720 = 1; /* Envy24HT-S have 16 bit wide GPIO */
136 break; 136 break;
137 default: 137 default:
138 snd_BUG(); 138 snd_BUG();
139 return -EINVAL; 139 return -EINVAL;
140 } 140 }
141 141
142 // Initialize analog chips 142 /* Initialize analog chips */
143 ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); 143 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
144 if (! ak) 144 ak = ice->akm;
145 if (!ak)
145 return -ENOMEM; 146 return -ENOMEM;
146 ice->akm_codecs = 1; 147 ice->akm_codecs = 1;
147 switch (ice->eeprom.subvendor) { 148 switch (ice->eeprom.subvendor) {
148 case VT1724_SUBDEVICE_PHASE22: 149 case VT1724_SUBDEVICE_PHASE22:
149 case VT1724_SUBDEVICE_TS22: 150 case VT1724_SUBDEVICE_TS22:
150 if ((err = snd_ice1712_akm4xxx_init(ak, &akm_phase22, &akm_phase22_priv, ice)) < 0) 151 err = snd_ice1712_akm4xxx_init(ak, &akm_phase22,
152 &akm_phase22_priv, ice);
153 if (err < 0)
151 return err; 154 return err;
152 break; 155 break;
153 } 156 }
@@ -206,15 +209,16 @@ static unsigned char phase28_eeprom[] __devinitdata = {
206/* 209/*
207 * write data in the SPI mode 210 * write data in the SPI mode
208 */ 211 */
209static 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)
210{ 214{
211 unsigned int tmp; 215 unsigned int tmp;
212 int i; 216 int i;
213 217
214 tmp = snd_ice1712_gpio_read(ice); 218 tmp = snd_ice1712_gpio_read(ice);
215 219
216 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|
217 PHASE28_WM_CS)); 221 PHASE28_SPI_CLK|PHASE28_WM_CS));
218 tmp |= PHASE28_WM_RW; 222 tmp |= PHASE28_WM_RW;
219 tmp &= ~cs; 223 tmp &= ~cs;
220 snd_ice1712_gpio_write(ice, tmp); 224 snd_ice1712_gpio_write(ice, tmp);
@@ -273,14 +277,16 @@ static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val)
273 ice->akm[0].images[reg + 1] = val; 277 ice->akm[0].images[reg + 1] = val;
274} 278}
275 279
276static 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)
277{ 282{
278 unsigned char nvol; 283 unsigned char nvol;
279 284
280 if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE)) 285 if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE))
281 nvol = 0; 286 nvol = 0;
282 else 287 else
283 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];
284 290
285 wm_put(ice, index, nvol); 291 wm_put(ice, index, nvol);
286 wm_put_nocache(ice, index, 0x180 | nvol); 292 wm_put_nocache(ice, index, 0x180 | nvol);
@@ -291,17 +297,20 @@ static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned sho
291 */ 297 */
292#define wm_pcm_mute_info snd_ctl_boolean_mono_info 298#define wm_pcm_mute_info snd_ctl_boolean_mono_info
293 299
294static 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)
295{ 302{
296 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 303 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
297 304
298 mutex_lock(&ice->gpio_mutex); 305 mutex_lock(&ice->gpio_mutex);
299 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;
300 mutex_unlock(&ice->gpio_mutex); 308 mutex_unlock(&ice->gpio_mutex);
301 return 0; 309 return 0;
302} 310}
303 311
304static 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)
305{ 314{
306 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 315 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
307 unsigned short nval, oval; 316 unsigned short nval, oval;
@@ -310,7 +319,8 @@ static int wm_pcm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
310 snd_ice1712_save_gpio_status(ice); 319 snd_ice1712_save_gpio_status(ice);
311 oval = wm_get(ice, WM_MUTE); 320 oval = wm_get(ice, WM_MUTE);
312 nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10); 321 nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10);
313 if ((change = (nval != oval))) 322 change = (nval != oval);
323 if (change)
314 wm_put(ice, WM_MUTE, nval); 324 wm_put(ice, WM_MUTE, nval);
315 snd_ice1712_restore_gpio_status(ice); 325 snd_ice1712_restore_gpio_status(ice);
316 326
@@ -320,7 +330,8 @@ static int wm_pcm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
320/* 330/*
321 * Master volume attenuation mixer control 331 * Master volume attenuation mixer control
322 */ 332 */
323static 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)
324{ 335{
325 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 336 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
326 uinfo->count = 2; 337 uinfo->count = 2;
@@ -329,17 +340,20 @@ static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
329 return 0; 340 return 0;
330} 341}
331 342
332static 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)
333{ 345{
334 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 346 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
335 struct phase28_spec *spec = ice->spec; 347 struct phase28_spec *spec = ice->spec;
336 int i; 348 int i;
337 for (i=0; i<2; i++) 349 for (i = 0; i < 2; i++)
338 ucontrol->value.integer.value[i] = spec->master[i] & ~WM_VOL_MUTE; 350 ucontrol->value.integer.value[i] = spec->master[i] &
351 ~WM_VOL_MUTE;
339 return 0; 352 return 0;
340} 353}
341 354
342static 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)
343{ 357{
344 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 358 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
345 struct phase28_spec *spec = ice->spec; 359 struct phase28_spec *spec = ice->spec;
@@ -369,38 +383,38 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
369{ 383{
370 static const unsigned short wm_inits_phase28[] = { 384 static const unsigned short wm_inits_phase28[] = {
371 /* These come first to reduce init pop noise */ 385 /* These come first to reduce init pop noise */
372 0x1b, 0x044, /* ADC Mux (AC'97 source) */ 386 0x1b, 0x044, /* ADC Mux (AC'97 source) */
373 0x1c, 0x00B, /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */ 387 0x1c, 0x00B, /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */
374 0x1d, 0x009, /* Out Mux2 (VOUT2 = DAC, VOUT3 = DAC) */ 388 0x1d, 0x009, /* Out Mux2 (VOUT2 = DAC, VOUT3 = DAC) */
375 389
376 0x18, 0x000, /* All power-up */ 390 0x18, 0x000, /* All power-up */
377 391
378 0x16, 0x122, /* I2S, normal polarity, 24bit */ 392 0x16, 0x122, /* I2S, normal polarity, 24bit */
379 0x17, 0x022, /* 256fs, slave mode */ 393 0x17, 0x022, /* 256fs, slave mode */
380 0x00, 0, /* DAC1 analog mute */ 394 0x00, 0, /* DAC1 analog mute */
381 0x01, 0, /* DAC2 analog mute */ 395 0x01, 0, /* DAC2 analog mute */
382 0x02, 0, /* DAC3 analog mute */ 396 0x02, 0, /* DAC3 analog mute */
383 0x03, 0, /* DAC4 analog mute */ 397 0x03, 0, /* DAC4 analog mute */
384 0x04, 0, /* DAC5 analog mute */ 398 0x04, 0, /* DAC5 analog mute */
385 0x05, 0, /* DAC6 analog mute */ 399 0x05, 0, /* DAC6 analog mute */
386 0x06, 0, /* DAC7 analog mute */ 400 0x06, 0, /* DAC7 analog mute */
387 0x07, 0, /* DAC8 analog mute */ 401 0x07, 0, /* DAC8 analog mute */
388 0x08, 0x100, /* master analog mute */ 402 0x08, 0x100, /* master analog mute */
389 0x09, 0xff, /* DAC1 digital full */ 403 0x09, 0xff, /* DAC1 digital full */
390 0x0a, 0xff, /* DAC2 digital full */ 404 0x0a, 0xff, /* DAC2 digital full */
391 0x0b, 0xff, /* DAC3 digital full */ 405 0x0b, 0xff, /* DAC3 digital full */
392 0x0c, 0xff, /* DAC4 digital full */ 406 0x0c, 0xff, /* DAC4 digital full */
393 0x0d, 0xff, /* DAC5 digital full */ 407 0x0d, 0xff, /* DAC5 digital full */
394 0x0e, 0xff, /* DAC6 digital full */ 408 0x0e, 0xff, /* DAC6 digital full */
395 0x0f, 0xff, /* DAC7 digital full */ 409 0x0f, 0xff, /* DAC7 digital full */
396 0x10, 0xff, /* DAC8 digital full */ 410 0x10, 0xff, /* DAC8 digital full */
397 0x11, 0x1ff, /* master digital full */ 411 0x11, 0x1ff, /* master digital full */
398 0x12, 0x000, /* phase normal */ 412 0x12, 0x000, /* phase normal */
399 0x13, 0x090, /* unmute DAC L/R */ 413 0x13, 0x090, /* unmute DAC L/R */
400 0x14, 0x000, /* all unmute */ 414 0x14, 0x000, /* all unmute */
401 0x15, 0x000, /* no deemphasis, no ZFLG */ 415 0x15, 0x000, /* no deemphasis, no ZFLG */
402 0x19, 0x000, /* -12dB ADC/L */ 416 0x19, 0x000, /* -12dB ADC/L */
403 0x1a, 0x000, /* -12dB ADC/R */ 417 0x1a, 0x000, /* -12dB ADC/R */
404 (unsigned short)-1 418 (unsigned short)-1
405 }; 419 };
406 420
@@ -418,17 +432,19 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
418 return -ENOMEM; 432 return -ENOMEM;
419 ice->spec = spec; 433 ice->spec = spec;
420 434
421 // Initialize analog chips 435 /* Initialize analog chips */
422 ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); 436 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
437 ak = ice->akm;
423 if (!ak) 438 if (!ak)
424 return -ENOMEM; 439 return -ENOMEM;
425 ice->akm_codecs = 1; 440 ice->akm_codecs = 1;
426 441
427 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 */
428 443
429 /* reset the wm codec as the SPI mode */ 444 /* reset the wm codec as the SPI mode */
430 snd_ice1712_save_gpio_status(ice); 445 snd_ice1712_save_gpio_status(ice);
431 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));
432 448
433 tmp = snd_ice1712_gpio_read(ice); 449 tmp = snd_ice1712_gpio_read(ice);
434 tmp &= ~PHASE28_WM_RESET; 450 tmp &= ~PHASE28_WM_RESET;
@@ -460,7 +476,8 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
460/* 476/*
461 * DAC volume attenuation mixer control 477 * DAC volume attenuation mixer control
462 */ 478 */
463static 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)
464{ 481{
465 int voices = kcontrol->private_value >> 8; 482 int voices = kcontrol->private_value >> 8;
466 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 483 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -470,7 +487,8 @@ static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *
470 return 0; 487 return 0;
471} 488}
472 489
473static 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)
474{ 492{
475 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 493 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
476 struct phase28_spec *spec = ice->spec; 494 struct phase28_spec *spec = ice->spec;
@@ -484,7 +502,8 @@ static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *
484 return 0; 502 return 0;
485} 503}
486 504
487static 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)
488{ 507{
489 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 508 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
490 struct phase28_spec *spec = ice->spec; 509 struct phase28_spec *spec = ice->spec;
@@ -515,7 +534,8 @@ static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *
515/* 534/*
516 * WM8770 mute control 535 * WM8770 mute control
517 */ 536 */
518static 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) {
519 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 539 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
520 uinfo->count = kcontrol->private_value >> 8; 540 uinfo->count = kcontrol->private_value >> 8;
521 uinfo->value.integer.min = 0; 541 uinfo->value.integer.min = 0;
@@ -523,7 +543,8 @@ static int wm_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info
523 return 0; 543 return 0;
524} 544}
525 545
526static 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)
527{ 548{
528 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 549 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
529 struct phase28_spec *spec = ice->spec; 550 struct phase28_spec *spec = ice->spec;
@@ -538,7 +559,8 @@ static int wm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
538 return 0; 559 return 0;
539} 560}
540 561
541static 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)
542{ 564{
543 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 565 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
544 struct phase28_spec *spec = ice->spec; 566 struct phase28_spec *spec = ice->spec;
@@ -553,9 +575,10 @@ static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
553 if (ucontrol->value.integer.value[i] != val) { 575 if (ucontrol->value.integer.value[i] != val) {
554 spec->vol[ofs + i] &= ~WM_VOL_MUTE; 576 spec->vol[ofs + i] &= ~WM_VOL_MUTE;
555 spec->vol[ofs + i] |= 577 spec->vol[ofs + i] |=
556 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE; 578 ucontrol->value.integer.value[i] ? 0 :
579 WM_VOL_MUTE;
557 wm_set_vol(ice, ofs + i, spec->vol[ofs + i], 580 wm_set_vol(ice, ofs + i, spec->vol[ofs + i],
558 spec->master[i]); 581 spec->master[i]);
559 change = 1; 582 change = 1;
560 } 583 }
561 } 584 }
@@ -569,7 +592,8 @@ static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
569 */ 592 */
570#define wm_master_mute_info snd_ctl_boolean_stereo_info 593#define wm_master_mute_info snd_ctl_boolean_stereo_info
571 594
572static 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)
573{ 597{
574 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 598 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
575 struct phase28_spec *spec = ice->spec; 599 struct phase28_spec *spec = ice->spec;
@@ -581,7 +605,8 @@ static int wm_master_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
581 return 0; 605 return 0;
582} 606}
583 607
584static 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)
585{ 610{
586 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 611 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
587 struct phase28_spec *spec = ice->spec; 612 struct phase28_spec *spec = ice->spec;
@@ -594,11 +619,12 @@ static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
594 int dac; 619 int dac;
595 spec->master[i] &= ~WM_VOL_MUTE; 620 spec->master[i] &= ~WM_VOL_MUTE;
596 spec->master[i] |= 621 spec->master[i] |=
597 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE; 622 ucontrol->value.integer.value[i] ? 0 :
623 WM_VOL_MUTE;
598 for (dac = 0; dac < ice->num_total_dacs; dac += 2) 624 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
599 wm_set_vol(ice, WM_DAC_ATTEN + dac + i, 625 wm_set_vol(ice, WM_DAC_ATTEN + dac + i,
600 spec->vol[dac + i], 626 spec->vol[dac + i],
601 spec->master[i]); 627 spec->master[i]);
602 change = 1; 628 change = 1;
603 } 629 }
604 } 630 }
@@ -611,7 +637,8 @@ static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
611#define PCM_0dB 0xff 637#define PCM_0dB 0xff
612#define PCM_RES 128 /* -64dB */ 638#define PCM_RES 128 /* -64dB */
613#define PCM_MIN (PCM_0dB - PCM_RES) 639#define PCM_MIN (PCM_0dB - PCM_RES)
614static 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)
615{ 642{
616 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 643 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
617 uinfo->count = 1; 644 uinfo->count = 1;
@@ -620,7 +647,8 @@ static int wm_pcm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_in
620 return 0; 647 return 0;
621} 648}
622 649
623static 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)
624{ 652{
625 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 653 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
626 unsigned short val; 654 unsigned short val;
@@ -633,7 +661,8 @@ static int wm_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
633 return 0; 661 return 0;
634} 662}
635 663
636static 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)
637{ 666{
638 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 667 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
639 unsigned short ovol, nvol; 668 unsigned short ovol, nvol;
@@ -647,7 +676,8 @@ static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
647 ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff; 676 ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
648 if (ovol != nvol) { 677 if (ovol != nvol) {
649 wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */ 678 wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */
650 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);
651 change = 1; 681 change = 1;
652 } 682 }
653 snd_ice1712_restore_gpio_status(ice); 683 snd_ice1712_restore_gpio_status(ice);
@@ -659,18 +689,22 @@ static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
659 */ 689 */
660#define phase28_deemp_info snd_ctl_boolean_mono_info 690#define phase28_deemp_info snd_ctl_boolean_mono_info
661 691
662static 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)
663{ 694{
664 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 695 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
665 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;
666 return 0; 698 return 0;
667} 699}
668 700
669static 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)
670{ 703{
671 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 704 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
672 int temp, temp2; 705 int temp, temp2;
673 temp2 = temp = wm_get(ice, WM_DAC_CTRL2); 706 temp = wm_get(ice, WM_DAC_CTRL2);
707 temp2 = temp;
674 if (ucontrol->value.integer.value[0]) 708 if (ucontrol->value.integer.value[0])
675 temp |= 0xf; 709 temp |= 0xf;
676 else 710 else
@@ -685,7 +719,8 @@ static int phase28_deemp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
685/* 719/*
686 * ADC Oversampling 720 * ADC Oversampling
687 */ 721 */
688static 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)
689{ 724{
690 static char *texts[2] = { "128x", "64x" }; 725 static char *texts[2] = { "128x", "64x" };
691 726
@@ -694,25 +729,31 @@ static int phase28_oversampling_info(struct snd_kcontrol *k, struct snd_ctl_elem
694 uinfo->value.enumerated.items = 2; 729 uinfo->value.enumerated.items = 2;
695 730
696 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 731 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
697 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 732 uinfo->value.enumerated.item = uinfo->value.enumerated.items -
698 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 733 1;
734 strcpy(uinfo->value.enumerated.name,
735 texts[uinfo->value.enumerated.item]);
699 736
700 return 0; 737 return 0;
701} 738}
702 739
703static 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)
704{ 742{
705 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 743 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
706 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;
707 return 0; 746 return 0;
708} 747}
709 748
710static 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)
711{ 751{
712 int temp, temp2; 752 int temp, temp2;
713 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 753 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
714 754
715 temp2 = temp = wm_get(ice, WM_MASTER); 755 temp = wm_get(ice, WM_MASTER);
756 temp2 = temp;
716 757
717 if (ucontrol->value.enumerated.item[0]) 758 if (ucontrol->value.enumerated.item[0])
718 temp |= 0x8; 759 temp |= 0x8;
@@ -885,13 +926,16 @@ static int __devinit phase28_add_controls(struct snd_ice1712 *ice)
885 926
886 counts = ARRAY_SIZE(phase28_dac_controls); 927 counts = ARRAY_SIZE(phase28_dac_controls);
887 for (i = 0; i < counts; i++) { 928 for (i = 0; i < counts; i++) {
888 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));
889 if (err < 0) 932 if (err < 0)
890 return err; 933 return err;
891 } 934 }
892 935
893 for (i = 0; i < ARRAY_SIZE(wm_controls); i++) { 936 for (i = 0; i < ARRAY_SIZE(wm_controls); i++) {
894 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));
895 if (err < 0) 939 if (err < 0)
896 return err; 940 return err;
897 } 941 }