aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/prodigy_hifi.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-01-18 07:36:07 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:30:05 -0500
commit7cda8ba9f4e471dfba914ecf67fd14ebffb17c16 (patch)
tree5786b450d9099809b974929ea356b444c9f2bc07 /sound/pci/ice1712/prodigy_hifi.c
parent797760ab14db4e82a50c06a9916dd5c6147b415b (diff)
[ALSA] ice1712, ice1724 - Code clean up
Clean up ice1712/ice1724 codes. The board-specific data is allocated locally in each code instead of having an ungly union in struct ice1712. Also, fix coding issues in prodigy_hifi.c. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/ice1712/prodigy_hifi.c')
-rw-r--r--sound/pci/ice1712/prodigy_hifi.c301
1 files changed, 158 insertions, 143 deletions
diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c
index 6ec1aa44c18..043a93879bd 100644
--- a/sound/pci/ice1712/prodigy_hifi.c
+++ b/sound/pci/ice1712/prodigy_hifi.c
@@ -40,6 +40,11 @@
40#include "envy24ht.h" 40#include "envy24ht.h"
41#include "prodigy_hifi.h" 41#include "prodigy_hifi.h"
42 42
43struct prodigy_hifi_spec {
44 unsigned short master[2];
45 unsigned short vol[8];
46};
47
43/* I2C addresses */ 48/* I2C addresses */
44#define WM_DEV 0x34 49#define WM_DEV 0x34
45 50
@@ -177,7 +182,8 @@ static void wm8766_spi_send_word(struct snd_ice1712 *ice, unsigned int data)
177 } 182 }
178} 183}
179 184
180static void wm8766_spi_write(struct snd_ice1712 *ice, unsigned int reg, unsigned int data) 185static void wm8766_spi_write(struct snd_ice1712 *ice, unsigned int reg,
186 unsigned int data)
181{ 187{
182 unsigned int block; 188 unsigned int block;
183 189
@@ -216,7 +222,8 @@ static void ak4396_send_word(struct snd_ice1712 *ice, unsigned int data)
216 } 222 }
217} 223}
218 224
219static void ak4396_write(struct snd_ice1712 *ice, unsigned int reg, unsigned int data) 225static void ak4396_write(struct snd_ice1712 *ice, unsigned int reg,
226 unsigned int data)
220{ 227{
221 unsigned int block; 228 unsigned int block;
222 229
@@ -246,7 +253,8 @@ static void ak4396_write(struct snd_ice1712 *ice, unsigned int reg, unsigned int
246 * DAC volume attenuation mixer control (-64dB to 0dB) 253 * DAC volume attenuation mixer control (-64dB to 0dB)
247 */ 254 */
248 255
249static int ak4396_dac_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 256static int ak4396_dac_vol_info(struct snd_kcontrol *kcontrol,
257 struct snd_ctl_elem_info *uinfo)
250{ 258{
251 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 259 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
252 uinfo->count = 2; 260 uinfo->count = 2;
@@ -255,31 +263,32 @@ static int ak4396_dac_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
255 return 0; 263 return 0;
256} 264}
257 265
258static int ak4396_dac_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 266static int ak4396_dac_vol_get(struct snd_kcontrol *kcontrol,
267 struct snd_ctl_elem_value *ucontrol)
259{ 268{
260 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 269 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
270 struct prodigy_hifi_spec *spec = ice->spec;
261 int i; 271 int i;
262 272
263 for (i = 0; i < 2; i++) { 273 for (i = 0; i < 2; i++)
264 ucontrol->value.integer.value[i] =ice->spec.prodigy_hd2.vol[i]; 274 ucontrol->value.integer.value[i] = spec->vol[i];
265 } 275
266 return 0; 276 return 0;
267} 277}
268 278
269static int ak4396_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 279static int ak4396_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
270{ 280{
271 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 281 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
282 struct prodigy_hifi_spec *spec = ice->spec;
272 int i; 283 int i;
273 int change = 0; 284 int change = 0;
274 285
275 mutex_lock(&ice->gpio_mutex); 286 mutex_lock(&ice->gpio_mutex);
276 for (i = 0; i < 2; i++) { 287 for (i = 0; i < 2; i++) {
277 if (ucontrol->value.integer.value[i] != 288 if (ucontrol->value.integer.value[i] != spec->vol[i]) {
278 ice->spec.prodigy_hd2.vol[i]) { 289 spec->vol[i] = ucontrol->value.integer.value[i];
279 ice->spec.prodigy_hd2.vol[i] = 290 ak4396_write(ice, AK4396_LCH_ATT + i,
280 ucontrol->value.integer.value[i]; 291 spec->vol[i] & 0xff);
281 ak4396_write(ice, AK4396_LCH_ATT+i,
282 (ice->spec.prodigy_hd2.vol[i] & 0xff));
283 change = 1; 292 change = 1;
284 } 293 }
285 } 294 }
@@ -333,7 +342,8 @@ static const unsigned char wm_vol[256] = {
333#define DAC_MIN (DAC_0dB - DAC_RES) 342#define DAC_MIN (DAC_0dB - DAC_RES)
334 343
335 344
336static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master) 345static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index,
346 unsigned short vol, unsigned short master)
337{ 347{
338 unsigned char nvol; 348 unsigned char nvol;
339 349
@@ -349,7 +359,8 @@ static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned sho
349 wm_put_nocache(ice, index, 0x100 | nvol); 359 wm_put_nocache(ice, index, 0x100 | nvol);
350} 360}
351 361
352static void wm8766_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master) 362static void wm8766_set_vol(struct snd_ice1712 *ice, unsigned int index,
363 unsigned short vol, unsigned short master)
353{ 364{
354 unsigned char nvol; 365 unsigned char nvol;
355 366
@@ -360,7 +371,6 @@ static void wm8766_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned
360 & WM_VOL_MAX; 371 & WM_VOL_MAX;
361 nvol = (nvol ? (nvol + DAC_MIN) : 0) & 0xff; 372 nvol = (nvol ? (nvol + DAC_MIN) : 0) & 0xff;
362 } 373 }
363
364 374
365 wm8766_spi_write(ice, index, (0x0100 | nvol)); 375 wm8766_spi_write(ice, index, (0x0100 | nvol));
366} 376}
@@ -370,7 +380,8 @@ static void wm8766_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned
370 * DAC volume attenuation mixer control (-64dB to 0dB) 380 * DAC volume attenuation mixer control (-64dB to 0dB)
371 */ 381 */
372 382
373static int wm_dac_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 383static int wm_dac_vol_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo)
374{ 385{
375 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 386 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
376 uinfo->count = 2; 387 uinfo->count = 2;
@@ -379,33 +390,32 @@ static int wm_dac_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_in
379 return 0; 390 return 0;
380} 391}
381 392
382static int wm_dac_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 393static int wm_dac_vol_get(struct snd_kcontrol *kcontrol,
394 struct snd_ctl_elem_value *ucontrol)
383{ 395{
384 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 396 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
397 struct prodigy_hifi_spec *spec = ice->spec;
385 int i; 398 int i;
386 399
387 for (i = 0; i < 2; i++) { 400 for (i = 0; i < 2; i++)
388 ucontrol->value.integer.value[i] = 401 ucontrol->value.integer.value[i] =
389 ice->spec.prodigy_hifi.vol[2+i] & ~WM_VOL_MUTE; 402 spec->vol[2 + i] & ~WM_VOL_MUTE;
390 }
391 return 0; 403 return 0;
392} 404}
393 405
394static int wm_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 406static int wm_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
395{ 407{
396 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 408 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
409 struct prodigy_hifi_spec *spec = ice->spec;
397 int i, idx, change = 0; 410 int i, idx, change = 0;
398 411
399 mutex_lock(&ice->gpio_mutex); 412 mutex_lock(&ice->gpio_mutex);
400 for (i = 0; i < 2; i++) { 413 for (i = 0; i < 2; i++) {
401 if (ucontrol->value.integer.value[i] != 414 if (ucontrol->value.integer.value[i] != spec->vol[2 + i]) {
402 ice->spec.prodigy_hifi.vol[2+i]) {
403 idx = WM_DAC_ATTEN_L + i; 415 idx = WM_DAC_ATTEN_L + i;
404 ice->spec.prodigy_hifi.vol[2+i] &= WM_VOL_MUTE; 416 spec->vol[2 + i] &= WM_VOL_MUTE;
405 ice->spec.prodigy_hifi.vol[2+i] |= 417 spec->vol[2 + i] |= ucontrol->value.integer.value[i];
406 ucontrol->value.integer.value[i]; 418 wm_set_vol(ice, idx, spec->vol[2 + i], spec->master[i]);
407 wm_set_vol(ice, idx, ice->spec.prodigy_hifi.vol[2+i],
408 ice->spec.prodigy_hifi.master[i]);
409 change = 1; 419 change = 1;
410 } 420 }
411 } 421 }
@@ -417,7 +427,8 @@ static int wm_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
417/* 427/*
418 * WM8766 DAC volume attenuation mixer control 428 * WM8766 DAC volume attenuation mixer control
419 */ 429 */
420static int wm8766_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 430static int wm8766_vol_info(struct snd_kcontrol *kcontrol,
431 struct snd_ctl_elem_info *uinfo)
421{ 432{
422 int voices = kcontrol->private_value >> 8; 433 int voices = kcontrol->private_value >> 8;
423 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 434 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -427,22 +438,24 @@ static int wm8766_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_in
427 return 0; 438 return 0;
428} 439}
429 440
430static int wm8766_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 441static int wm8766_vol_get(struct snd_kcontrol *kcontrol,
442 struct snd_ctl_elem_value *ucontrol)
431{ 443{
432 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 444 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
445 struct prodigy_hifi_spec *spec = ice->spec;
433 int i, ofs, voices; 446 int i, ofs, voices;
434 447
435 voices = kcontrol->private_value >> 8; 448 voices = kcontrol->private_value >> 8;
436 ofs = kcontrol->private_value & 0xff; 449 ofs = kcontrol->private_value & 0xff;
437 for (i = 0; i < voices; i++) 450 for (i = 0; i < voices; i++)
438 ucontrol->value.integer.value[i] = 451 ucontrol->value.integer.value[i] = spec->vol[ofs + i];
439 ice->spec.prodigy_hifi.vol[ofs+i];
440 return 0; 452 return 0;
441} 453}
442 454
443static int wm8766_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 455static int wm8766_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
444{ 456{
445 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 457 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
458 struct prodigy_hifi_spec *spec = ice->spec;
446 int i, idx, ofs, voices; 459 int i, idx, ofs, voices;
447 int change = 0; 460 int change = 0;
448 461
@@ -450,15 +463,12 @@ static int wm8766_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
450 ofs = kcontrol->private_value & 0xff; 463 ofs = kcontrol->private_value & 0xff;
451 mutex_lock(&ice->gpio_mutex); 464 mutex_lock(&ice->gpio_mutex);
452 for (i = 0; i < voices; i++) { 465 for (i = 0; i < voices; i++) {
453 if (ucontrol->value.integer.value[i] != 466 if (ucontrol->value.integer.value[i] != spec->vol[ofs + i]) {
454 ice->spec.prodigy_hifi.vol[ofs+i]) {
455 idx = WM8766_LDA1 + ofs + i; 467 idx = WM8766_LDA1 + ofs + i;
456 ice->spec.prodigy_hifi.vol[ofs+i] &= WM_VOL_MUTE; 468 spec->vol[ofs + i] &= WM_VOL_MUTE;
457 ice->spec.prodigy_hifi.vol[ofs+i] |= 469 spec->vol[ofs + i] |= ucontrol->value.integer.value[i];
458 ucontrol->value.integer.value[i];
459 wm8766_set_vol(ice, idx, 470 wm8766_set_vol(ice, idx,
460 ice->spec.prodigy_hifi.vol[ofs+i], 471 spec->vol[ofs + i], spec->master[i]);
461 ice->spec.prodigy_hifi.master[i]);
462 change = 1; 472 change = 1;
463 } 473 }
464 } 474 }
@@ -469,7 +479,8 @@ static int wm8766_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
469/* 479/*
470 * Master volume attenuation mixer control / applied to WM8776+WM8766 480 * Master volume attenuation mixer control / applied to WM8776+WM8766
471 */ 481 */
472static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 482static int wm_master_vol_info(struct snd_kcontrol *kcontrol,
483 struct snd_ctl_elem_info *uinfo)
473{ 484{
474 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 485 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
475 uinfo->count = 2; 486 uinfo->count = 2;
@@ -478,45 +489,41 @@ static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
478 return 0; 489 return 0;
479} 490}
480 491
481static int wm_master_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 492static int wm_master_vol_get(struct snd_kcontrol *kcontrol,
493 struct snd_ctl_elem_value *ucontrol)
482{ 494{
483 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 495 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
496 struct prodigy_hifi_spec *spec = ice->spec;
484 int i; 497 int i;
485 for (i=0; i<2; i++) 498 for (i = 0; i < 2; i++)
486 ucontrol->value.integer.value[i] = 499 ucontrol->value.integer.value[i] = spec->master[i];
487 ice->spec.prodigy_hifi.master[i];
488 return 0; 500 return 0;
489} 501}
490 502
491static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 503static int wm_master_vol_put(struct snd_kcontrol *kcontrol,
504 struct snd_ctl_elem_value *ucontrol)
492{ 505{
493 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 506 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
507 struct prodigy_hifi_spec *spec = ice->spec;
494 int ch, change = 0; 508 int ch, change = 0;
495 509
496 mutex_lock(&ice->gpio_mutex); 510 mutex_lock(&ice->gpio_mutex);
497 for (ch = 0; ch < 2; ch++) { 511 for (ch = 0; ch < 2; ch++) {
498 if (ucontrol->value.integer.value[ch] != 512 if (ucontrol->value.integer.value[ch] != spec->master[ch]) {
499 ice->spec.prodigy_hifi.master[ch]) { 513 spec->master[ch] = ucontrol->value.integer.value[ch];
500 ice->spec.prodigy_hifi.master[ch] &= 0x00;
501 ice->spec.prodigy_hifi.master[ch] |=
502 ucontrol->value.integer.value[ch];
503 514
504 /* Apply to front DAC */ 515 /* Apply to front DAC */
505 wm_set_vol(ice, WM_DAC_ATTEN_L + ch, 516 wm_set_vol(ice, WM_DAC_ATTEN_L + ch,
506 ice->spec.prodigy_hifi.vol[2 + ch], 517 spec->vol[2 + ch], spec->master[ch]);
507 ice->spec.prodigy_hifi.master[ch]);
508 518
509 wm8766_set_vol(ice, WM8766_LDA1 + ch, 519 wm8766_set_vol(ice, WM8766_LDA1 + ch,
510 ice->spec.prodigy_hifi.vol[0 + ch], 520 spec->vol[0 + ch], spec->master[ch]);
511 ice->spec.prodigy_hifi.master[ch]);
512 521
513 wm8766_set_vol(ice, WM8766_LDA2 + ch, 522 wm8766_set_vol(ice, WM8766_LDA2 + ch,
514 ice->spec.prodigy_hifi.vol[4 + ch], 523 spec->vol[4 + ch], spec->master[ch]);
515 ice->spec.prodigy_hifi.master[ch]);
516 524
517 wm8766_set_vol(ice, WM8766_LDA3 + ch, 525 wm8766_set_vol(ice, WM8766_LDA3 + ch,
518 ice->spec.prodigy_hifi.vol[6 + ch], 526 spec->vol[6 + ch], spec->master[ch]);
519 ice->spec.prodigy_hifi.master[ch]);
520 change = 1; 527 change = 1;
521 } 528 }
522 } 529 }
@@ -525,64 +532,71 @@ static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
525} 532}
526 533
527 534
528
529/* KONSTI */ 535/* KONSTI */
530 536
531static int wm_adc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 537static int wm_adc_mux_enum_info(struct snd_kcontrol *kcontrol,
538 struct snd_ctl_elem_info *uinfo)
532{ 539{
533 static char* texts[32] = {"NULL", WM_AIN1, WM_AIN2, WM_AIN1 "+" WM_AIN2, 540 static char* texts[32] = {
534 WM_AIN3, WM_AIN1 "+" WM_AIN3, WM_AIN2 "+" WM_AIN3, 541 "NULL", WM_AIN1, WM_AIN2, WM_AIN1 "+" WM_AIN2,
535 WM_AIN1 "+" WM_AIN2 "+" WM_AIN3, 542 WM_AIN3, WM_AIN1 "+" WM_AIN3, WM_AIN2 "+" WM_AIN3,
536 WM_AIN4, WM_AIN1 "+" WM_AIN4, WM_AIN2 "+" WM_AIN4, 543 WM_AIN1 "+" WM_AIN2 "+" WM_AIN3,
537 WM_AIN1 "+" WM_AIN2 "+" WM_AIN4, 544 WM_AIN4, WM_AIN1 "+" WM_AIN4, WM_AIN2 "+" WM_AIN4,
538 WM_AIN3 "+" WM_AIN4, WM_AIN1 "+" WM_AIN3 "+" WM_AIN4, 545 WM_AIN1 "+" WM_AIN2 "+" WM_AIN4,
539 WM_AIN2 "+" WM_AIN3 "+" WM_AIN4, 546 WM_AIN3 "+" WM_AIN4, WM_AIN1 "+" WM_AIN3 "+" WM_AIN4,
540 WM_AIN1 "+" WM_AIN2 "+" WM_AIN3 "+" WM_AIN4, 547 WM_AIN2 "+" WM_AIN3 "+" WM_AIN4,
541 WM_AIN5, WM_AIN1 "+" WM_AIN5, WM_AIN2 "+" WM_AIN5, 548 WM_AIN1 "+" WM_AIN2 "+" WM_AIN3 "+" WM_AIN4,
542 WM_AIN1 "+" WM_AIN2 "+" WM_AIN5, 549 WM_AIN5, WM_AIN1 "+" WM_AIN5, WM_AIN2 "+" WM_AIN5,
543 WM_AIN3 "+" WM_AIN5, WM_AIN1 "+" WM_AIN3 "+" WM_AIN5, 550 WM_AIN1 "+" WM_AIN2 "+" WM_AIN5,
544 WM_AIN2 "+" WM_AIN3 "+" WM_AIN5, 551 WM_AIN3 "+" WM_AIN5, WM_AIN1 "+" WM_AIN3 "+" WM_AIN5,
545 WM_AIN1 "+" WM_AIN2 "+" WM_AIN3 "+" WM_AIN5, 552 WM_AIN2 "+" WM_AIN3 "+" WM_AIN5,
546 WM_AIN4 "+" WM_AIN5, WM_AIN1 "+" WM_AIN4 "+" WM_AIN5, 553 WM_AIN1 "+" WM_AIN2 "+" WM_AIN3 "+" WM_AIN5,
547 WM_AIN2 "+" WM_AIN4 "+" WM_AIN5, 554 WM_AIN4 "+" WM_AIN5, WM_AIN1 "+" WM_AIN4 "+" WM_AIN5,
548 WM_AIN1 "+" WM_AIN2 "+" WM_AIN4 "+" WM_AIN5, 555 WM_AIN2 "+" WM_AIN4 "+" WM_AIN5,
549 WM_AIN3 "+" WM_AIN4 "+" WM_AIN5, 556 WM_AIN1 "+" WM_AIN2 "+" WM_AIN4 "+" WM_AIN5,
550 WM_AIN1 "+" WM_AIN3 "+" WM_AIN4 "+" WM_AIN5, 557 WM_AIN3 "+" WM_AIN4 "+" WM_AIN5,
551 WM_AIN2 "+" WM_AIN3 "+" WM_AIN4 "+" WM_AIN5, 558 WM_AIN1 "+" WM_AIN3 "+" WM_AIN4 "+" WM_AIN5,
552 WM_AIN1 "+" WM_AIN2 "+" WM_AIN3 "+" WM_AIN4 "+" WM_AIN5}; 559 WM_AIN2 "+" WM_AIN3 "+" WM_AIN4 "+" WM_AIN5,
560 WM_AIN1 "+" WM_AIN2 "+" WM_AIN3 "+" WM_AIN4 "+" WM_AIN5
561 };
553 562
554 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 563 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
555 uinfo->count = 1; 564 uinfo->count = 1;
556 uinfo->value.enumerated.items = 32; 565 uinfo->value.enumerated.items = 32;
557 if (uinfo->value.enumerated.item > 31) 566 if (uinfo->value.enumerated.item > 31)
558 uinfo->value.enumerated.item = 31; 567 uinfo->value.enumerated.item = 31;
559 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 568 strcpy(uinfo->value.enumerated.name,
569 texts[uinfo->value.enumerated.item]);
560 return 0; 570 return 0;
561} 571}
562 572
563static int wm_adc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 573static int wm_adc_mux_enum_get(struct snd_kcontrol *kcontrol,
574 struct snd_ctl_elem_value *ucontrol)
564{ 575{
565 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 576 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
566 577
567 mutex_lock(&ice->gpio_mutex); 578 mutex_lock(&ice->gpio_mutex);
568 ucontrol->value.integer.value[0]=wm_get(ice, WM_ADC_MUX) & 0x1f; 579 ucontrol->value.integer.value[0] = wm_get(ice, WM_ADC_MUX) & 0x1f;
569 mutex_unlock(&ice->gpio_mutex); 580 mutex_unlock(&ice->gpio_mutex);
570 return 0; 581 return 0;
571} 582}
572 583
573static int wm_adc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 584static int wm_adc_mux_enum_put(struct snd_kcontrol *kcontrol,
585 struct snd_ctl_elem_value *ucontrol)
574{ 586{
575 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 587 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
576 unsigned short oval, nval; 588 unsigned short oval, nval;
589 int change = 0;
577 590
578 mutex_lock(&ice->gpio_mutex); 591 mutex_lock(&ice->gpio_mutex);
579 oval = wm_get(ice, WM_ADC_MUX); 592 oval = wm_get(ice, WM_ADC_MUX);
580 nval = ( oval & 0xe0 ) | ucontrol->value.integer.value[0] ; 593 nval = (oval & 0xe0) | ucontrol->value.integer.value[0];
581 if ( nval != oval ) { 594 if (nval != oval) {
582 wm_put(ice, WM_ADC_MUX, nval); 595 wm_put(ice, WM_ADC_MUX, nval);
596 change = 1;
583 } 597 }
584 mutex_unlock(&ice->gpio_mutex); 598 mutex_unlock(&ice->gpio_mutex);
585 return 0; 599 return change;
586} 600}
587 601
588/* KONSTI */ 602/* KONSTI */
@@ -595,7 +609,8 @@ static int wm_adc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
595#define ADC_RES 128 609#define ADC_RES 128
596#define ADC_MIN (ADC_0dB - ADC_RES) 610#define ADC_MIN (ADC_0dB - ADC_RES)
597 611
598static int wm_adc_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 612static int wm_adc_vol_info(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_info *uinfo)
599{ 614{
600 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 615 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
601 uinfo->count = 2; 616 uinfo->count = 2;
@@ -604,7 +619,8 @@ static int wm_adc_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_in
604 return 0; 619 return 0;
605} 620}
606 621
607static int wm_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 622static int wm_adc_vol_get(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_value *ucontrol)
608{ 624{
609 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 625 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
610 unsigned short val; 626 unsigned short val;
@@ -620,7 +636,8 @@ static int wm_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
620 return 0; 636 return 0;
621} 637}
622 638
623static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 639static int wm_adc_vol_put(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
624{ 641{
625 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 642 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
626 unsigned short ovol, nvol; 643 unsigned short ovol, nvol;
@@ -644,27 +661,23 @@ static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
644/* 661/*
645 * ADC input mux mixer control 662 * ADC input mux mixer control
646 */ 663 */
647static int wm_adc_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 664#define wm_adc_mux_info snd_ctl_boolean_mono_info
648{
649 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
650 uinfo->count = 1;
651 uinfo->value.integer.min = 0;
652 uinfo->value.integer.max = 1;
653 return 0;
654}
655 665
656static int wm_adc_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 666static int wm_adc_mux_get(struct snd_kcontrol *kcontrol,
667 struct snd_ctl_elem_value *ucontrol)
657{ 668{
658 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 669 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
659 int bit = kcontrol->private_value; 670 int bit = kcontrol->private_value;
660 671
661 mutex_lock(&ice->gpio_mutex); 672 mutex_lock(&ice->gpio_mutex);
662 ucontrol->value.integer.value[0] = (wm_get(ice, WM_ADC_MUX) & (1 << bit)) ? 1 : 0; 673 ucontrol->value.integer.value[0] =
674 (wm_get(ice, WM_ADC_MUX) & (1 << bit)) ? 1 : 0;
663 mutex_unlock(&ice->gpio_mutex); 675 mutex_unlock(&ice->gpio_mutex);
664 return 0; 676 return 0;
665} 677}
666 678
667static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 679static int wm_adc_mux_put(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
668{ 681{
669 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 682 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
670 int bit = kcontrol->private_value; 683 int bit = kcontrol->private_value;
@@ -688,26 +701,22 @@ static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
688/* 701/*
689 * Analog bypass (In -> Out) 702 * Analog bypass (In -> Out)
690 */ 703 */
691static int wm_bypass_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 704#define wm_bypass_info snd_ctl_boolean_mono_info
692{
693 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
694 uinfo->count = 1;
695 uinfo->value.integer.min = 0;
696 uinfo->value.integer.max = 1;
697 return 0;
698}
699 705
700static int wm_bypass_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 706static int wm_bypass_get(struct snd_kcontrol *kcontrol,
707 struct snd_ctl_elem_value *ucontrol)
701{ 708{
702 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 709 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
703 710
704 mutex_lock(&ice->gpio_mutex); 711 mutex_lock(&ice->gpio_mutex);
705 ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX) & 0x04) ? 1 : 0; 712 ucontrol->value.integer.value[0] =
713 (wm_get(ice, WM_OUT_MUX) & 0x04) ? 1 : 0;
706 mutex_unlock(&ice->gpio_mutex); 714 mutex_unlock(&ice->gpio_mutex);
707 return 0; 715 return 0;
708} 716}
709 717
710static int wm_bypass_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 718static int wm_bypass_put(struct snd_kcontrol *kcontrol,
719 struct snd_ctl_elem_value *ucontrol)
711{ 720{
712 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 721 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
713 unsigned short val, oval; 722 unsigned short val, oval;
@@ -730,16 +739,10 @@ static int wm_bypass_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
730/* 739/*
731 * Left/Right swap 740 * Left/Right swap
732 */ 741 */
733static int wm_chswap_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 742#define wm_chswap_info snd_ctl_boolean_mono_info
734{
735 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
736 uinfo->count = 1;
737 uinfo->value.integer.min = 0;
738 uinfo->value.integer.max = 1;
739 return 0;
740}
741 743
742static int wm_chswap_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 744static int wm_chswap_get(struct snd_kcontrol *kcontrol,
745 struct snd_ctl_elem_value *ucontrol)
743{ 746{
744 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 747 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
745 748
@@ -750,7 +753,8 @@ static int wm_chswap_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
750 return 0; 753 return 0;
751} 754}
752 755
753static int wm_chswap_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 756static int wm_chswap_put(struct snd_kcontrol *kcontrol,
757 struct snd_ctl_elem_value *ucontrol)
754{ 758{
755 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 759 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
756 unsigned short val, oval; 760 unsigned short val, oval;
@@ -894,9 +898,10 @@ static struct snd_kcontrol_new prodigy_hifi_controls[] __devinitdata = {
894/* 898/*
895 * WM codec registers 899 * WM codec registers
896 */ 900 */
897static void wm_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 901static void wm_proc_regs_write(struct snd_info_entry *entry,
902 struct snd_info_buffer *buffer)
898{ 903{
899 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; 904 struct snd_ice1712 *ice = entry->private_data;
900 char line[64]; 905 char line[64];
901 unsigned int reg, val; 906 unsigned int reg, val;
902 mutex_lock(&ice->gpio_mutex); 907 mutex_lock(&ice->gpio_mutex);
@@ -909,9 +914,10 @@ static void wm_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buf
909 mutex_unlock(&ice->gpio_mutex); 914 mutex_unlock(&ice->gpio_mutex);
910} 915}
911 916
912static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 917static void wm_proc_regs_read(struct snd_info_entry *entry,
918 struct snd_info_buffer *buffer)
913{ 919{
914 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; 920 struct snd_ice1712 *ice = entry->private_data;
915 int reg, val; 921 int reg, val;
916 922
917 mutex_lock(&ice->gpio_mutex); 923 mutex_lock(&ice->gpio_mutex);
@@ -925,7 +931,7 @@ static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buff
925static void wm_proc_init(struct snd_ice1712 *ice) 931static void wm_proc_init(struct snd_ice1712 *ice)
926{ 932{
927 struct snd_info_entry *entry; 933 struct snd_info_entry *entry;
928 if (! snd_card_proc_new(ice->card, "wm_codec", &entry)) { 934 if (!snd_card_proc_new(ice->card, "wm_codec", &entry)) {
929 snd_info_set_text_ops(entry, ice, wm_proc_regs_read); 935 snd_info_set_text_ops(entry, ice, wm_proc_regs_read);
930 entry->mode |= S_IWUSR; 936 entry->mode |= S_IWUSR;
931 entry->c.text.write = wm_proc_regs_write; 937 entry->c.text.write = wm_proc_regs_write;
@@ -938,7 +944,8 @@ static int __devinit prodigy_hifi_add_controls(struct snd_ice1712 *ice)
938 int err; 944 int err;
939 945
940 for (i = 0; i < ARRAY_SIZE(prodigy_hifi_controls); i++) { 946 for (i = 0; i < ARRAY_SIZE(prodigy_hifi_controls); i++) {
941 err = snd_ctl_add(ice->card, snd_ctl_new1(&prodigy_hifi_controls[i], ice)); 947 err = snd_ctl_add(ice->card,
948 snd_ctl_new1(&prodigy_hifi_controls[i], ice));
942 if (err < 0) 949 if (err < 0)
943 return err; 950 return err;
944 } 951 }
@@ -950,18 +957,19 @@ static int __devinit prodigy_hifi_add_controls(struct snd_ice1712 *ice)
950 957
951static int __devinit prodigy_hd2_add_controls(struct snd_ice1712 *ice) 958static int __devinit prodigy_hd2_add_controls(struct snd_ice1712 *ice)
952{ 959{
953 unsigned int i; 960 unsigned int i;
954 int err; 961 int err;
955 962
956 for (i = 0; i < ARRAY_SIZE(prodigy_hd2_controls); i++) { 963 for (i = 0; i < ARRAY_SIZE(prodigy_hd2_controls); i++) {
957 err = snd_ctl_add(ice->card, snd_ctl_new1(&prodigy_hd2_controls[i], ice)); 964 err = snd_ctl_add(ice->card,
958 if (err < 0) 965 snd_ctl_new1(&prodigy_hd2_controls[i], ice));
959 return err; 966 if (err < 0)
960 } 967 return err;
968 }
961 969
962 wm_proc_init(ice); 970 wm_proc_init(ice);
963 971
964 return 0; 972 return 0;
965} 973}
966 974
967 975
@@ -1025,7 +1033,7 @@ static int __devinit prodigy_hifi_init(struct snd_ice1712 *ice)
1025 WM8766_MUTE2, 0x0000, 1033 WM8766_MUTE2, 0x0000,
1026 }; 1034 };
1027 1035
1028 1036 struct prodigy_hifi_spec *spec;
1029 unsigned int i; 1037 unsigned int i;
1030 1038
1031 ice->vt1720 = 0; 1039 ice->vt1720 = 0;
@@ -1033,7 +1041,6 @@ static int __devinit prodigy_hifi_init(struct snd_ice1712 *ice)
1033 1041
1034 ice->num_total_dacs = 8; 1042 ice->num_total_dacs = 8;
1035 ice->num_total_adcs = 1; 1043 ice->num_total_adcs = 1;
1036 ice->akm_codecs = 2;
1037 1044
1038 /* HACK - use this as the SPDIF source. 1045 /* HACK - use this as the SPDIF source.
1039 * don't call snd_ice1712_gpio_get/put(), otherwise it's overwritten 1046 * don't call snd_ice1712_gpio_get/put(), otherwise it's overwritten
@@ -1044,7 +1051,12 @@ static int __devinit prodigy_hifi_init(struct snd_ice1712 *ice)
1044 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); 1051 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
1045 if (! ice->akm) 1052 if (! ice->akm)
1046 return -ENOMEM; 1053 return -ENOMEM;
1047 ice->akm_codecs = 1; 1054 ice->akm_codecs = 1;
1055
1056 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1057 if (!spec)
1058 return -ENOMEM;
1059 ice->spec = spec;
1048 1060
1049 /* initialize WM8776 codec */ 1061 /* initialize WM8776 codec */
1050 for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2) 1062 for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2)
@@ -1054,7 +1066,6 @@ static int __devinit prodigy_hifi_init(struct snd_ice1712 *ice)
1054 wm_put(ice, wm_inits2[i], wm_inits2[i+1]); 1066 wm_put(ice, wm_inits2[i], wm_inits2[i+1]);
1055 1067
1056 /* initialize WM8766 codec */ 1068 /* initialize WM8766 codec */
1057
1058 for (i = 0; i < ARRAY_SIZE(wm8766_inits); i += 2) 1069 for (i = 0; i < ARRAY_SIZE(wm8766_inits); i += 2)
1059 wm8766_spi_write(ice, wm8766_inits[i], wm8766_inits[i+1]); 1070 wm8766_spi_write(ice, wm8766_inits[i], wm8766_inits[i+1]);
1060 1071
@@ -1076,7 +1087,7 @@ static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice)
1076 AK4396_RCH_ATT, 0x00, 1087 AK4396_RCH_ATT, 0x00,
1077 }; 1088 };
1078 1089
1079 1090 struct prodigy_hifi_spec *spec;
1080 unsigned int i; 1091 unsigned int i;
1081 1092
1082 ice->vt1720 = 0; 1093 ice->vt1720 = 0;
@@ -1084,7 +1095,6 @@ static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice)
1084 1095
1085 ice->num_total_dacs = 1; 1096 ice->num_total_dacs = 1;
1086 ice->num_total_adcs = 1; 1097 ice->num_total_adcs = 1;
1087 ice->akm_codecs = 1;
1088 1098
1089 /* HACK - use this as the SPDIF source. 1099 /* HACK - use this as the SPDIF source.
1090 * don't call snd_ice1712_gpio_get/put(), otherwise it's overwritten 1100 * don't call snd_ice1712_gpio_get/put(), otherwise it's overwritten
@@ -1097,6 +1107,11 @@ static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice)
1097 return -ENOMEM; 1107 return -ENOMEM;
1098 ice->akm_codecs = 1; 1108 ice->akm_codecs = 1;
1099 1109
1110 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1111 if (!spec)
1112 return -ENOMEM;
1113 ice->spec = spec;
1114
1100 /* initialize ak4396 codec */ 1115 /* initialize ak4396 codec */
1101 /* reset codec */ 1116 /* reset codec */
1102 ak4396_write(ice, AK4396_CTRL1, 0x86); 1117 ak4396_write(ice, AK4396_CTRL1, 0x86);