aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/phase.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/phase.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/phase.c')
-rw-r--r--sound/pci/ice1712/phase.c82
1 files changed, 53 insertions, 29 deletions
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index 718e9359e1f2..9ab4a9f383cb 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -47,6 +47,12 @@
47#include "phase.h" 47#include "phase.h"
48#include <sound/tlv.h> 48#include <sound/tlv.h>
49 49
50/* AC97 register cache for Phase28 */
51struct phase28_spec {
52 unsigned short master[2];
53 unsigned short vol[8];
54} phase28;
55
50/* WM8770 registers */ 56/* WM8770 registers */
51#define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */ 57#define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */
52#define WM_DAC_MASTER_ATTEN 0x08 /* DAC master analog attenuation */ 58#define WM_DAC_MASTER_ATTEN 0x08 /* DAC master analog attenuation */
@@ -312,15 +318,17 @@ static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
312static int wm_master_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 318static int wm_master_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
313{ 319{
314 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 320 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
321 struct phase28_spec *spec = ice->spec;
315 int i; 322 int i;
316 for (i=0; i<2; i++) 323 for (i=0; i<2; i++)
317 ucontrol->value.integer.value[i] = ice->spec.phase28.master[i] & ~WM_VOL_MUTE; 324 ucontrol->value.integer.value[i] = spec->master[i] & ~WM_VOL_MUTE;
318 return 0; 325 return 0;
319} 326}
320 327
321static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 328static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
322{ 329{
323 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 330 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
331 struct phase28_spec *spec = ice->spec;
324 int ch, change = 0; 332 int ch, change = 0;
325 333
326 snd_ice1712_save_gpio_status(ice); 334 snd_ice1712_save_gpio_status(ice);
@@ -328,14 +336,14 @@ static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
328 unsigned int vol = ucontrol->value.integer.value[ch]; 336 unsigned int vol = ucontrol->value.integer.value[ch];
329 if (vol > WM_VOL_MAX) 337 if (vol > WM_VOL_MAX)
330 continue; 338 continue;
331 vol |= ice->spec.phase28.master[ch] & WM_VOL_MUTE; 339 vol |= spec->master[ch] & WM_VOL_MUTE;
332 if (vol != ice->spec.phase28.master[ch]) { 340 if (vol != spec->master[ch]) {
333 int dac; 341 int dac;
334 ice->spec.phase28.master[ch] = vol; 342 spec->master[ch] = vol;
335 for (dac = 0; dac < ice->num_total_dacs; dac += 2) 343 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
336 wm_set_vol(ice, WM_DAC_ATTEN + dac + ch, 344 wm_set_vol(ice, WM_DAC_ATTEN + dac + ch,
337 ice->spec.phase28.vol[dac + ch], 345 spec->vol[dac + ch],
338 ice->spec.phase28.master[ch]); 346 spec->master[ch]);
339 change = 1; 347 change = 1;
340 } 348 }
341 } 349 }
@@ -384,12 +392,18 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
384 392
385 unsigned int tmp; 393 unsigned int tmp;
386 struct snd_akm4xxx *ak; 394 struct snd_akm4xxx *ak;
395 struct phase28_spec *spec;
387 const unsigned short *p; 396 const unsigned short *p;
388 int i; 397 int i;
389 398
390 ice->num_total_dacs = 8; 399 ice->num_total_dacs = 8;
391 ice->num_total_adcs = 2; 400 ice->num_total_adcs = 2;
392 401
402 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
403 if (!spec)
404 return -ENOMEM;
405 ice->spec = spec;
406
393 // Initialize analog chips 407 // Initialize analog chips
394 ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); 408 ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
395 if (!ak) 409 if (!ak)
@@ -419,11 +433,11 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
419 433
420 snd_ice1712_restore_gpio_status(ice); 434 snd_ice1712_restore_gpio_status(ice);
421 435
422 ice->spec.phase28.master[0] = WM_VOL_MUTE; 436 spec->master[0] = WM_VOL_MUTE;
423 ice->spec.phase28.master[1] = WM_VOL_MUTE; 437 spec->master[1] = WM_VOL_MUTE;
424 for (i = 0; i < ice->num_total_dacs; i++) { 438 for (i = 0; i < ice->num_total_dacs; i++) {
425 ice->spec.phase28.vol[i] = WM_VOL_MUTE; 439 spec->vol[i] = WM_VOL_MUTE;
426 wm_set_vol(ice, i, ice->spec.phase28.vol[i], ice->spec.phase28.master[i % 2]); 440 wm_set_vol(ice, i, spec->vol[i], spec->master[i % 2]);
427 } 441 }
428 442
429 return 0; 443 return 0;
@@ -445,18 +459,21 @@ static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *
445static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 459static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
446{ 460{
447 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 461 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
462 struct phase28_spec *spec = ice->spec;
448 int i, ofs, voices; 463 int i, ofs, voices;
449 464
450 voices = kcontrol->private_value >> 8; 465 voices = kcontrol->private_value >> 8;
451 ofs = kcontrol->private_value & 0xff; 466 ofs = kcontrol->private_value & 0xff;
452 for (i = 0; i < voices; i++) 467 for (i = 0; i < voices; i++)
453 ucontrol->value.integer.value[i] = ice->spec.phase28.vol[ofs+i] & ~WM_VOL_MUTE; 468 ucontrol->value.integer.value[i] =
469 spec->vol[ofs+i] & ~WM_VOL_MUTE;
454 return 0; 470 return 0;
455} 471}
456 472
457static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 473static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
458{ 474{
459 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 475 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
476 struct phase28_spec *spec = ice->spec;
460 int i, idx, ofs, voices; 477 int i, idx, ofs, voices;
461 int change = 0; 478 int change = 0;
462 479
@@ -468,12 +485,12 @@ static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *
468 vol = ucontrol->value.integer.value[i]; 485 vol = ucontrol->value.integer.value[i];
469 if (vol > 0x7f) 486 if (vol > 0x7f)
470 continue; 487 continue;
471 vol |= ice->spec.phase28.vol[ofs+i] & WM_VOL_MUTE; 488 vol |= spec->vol[ofs+i] & WM_VOL_MUTE;
472 if (vol != ice->spec.phase28.vol[ofs+i]) { 489 if (vol != spec->vol[ofs+i]) {
473 ice->spec.phase28.vol[ofs+i] = vol; 490 spec->vol[ofs+i] = vol;
474 idx = WM_DAC_ATTEN + ofs + i; 491 idx = WM_DAC_ATTEN + ofs + i;
475 wm_set_vol(ice, idx, ice->spec.phase28.vol[ofs+i], 492 wm_set_vol(ice, idx, spec->vol[ofs+i],
476 ice->spec.phase28.master[i]); 493 spec->master[i]);
477 change = 1; 494 change = 1;
478 } 495 }
479 } 496 }
@@ -495,19 +512,22 @@ static int wm_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info
495static int wm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 512static int wm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
496{ 513{
497 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 514 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
515 struct phase28_spec *spec = ice->spec;
498 int voices, ofs, i; 516 int voices, ofs, i;
499 517
500 voices = kcontrol->private_value >> 8; 518 voices = kcontrol->private_value >> 8;
501 ofs = kcontrol->private_value & 0xFF; 519 ofs = kcontrol->private_value & 0xFF;
502 520
503 for (i = 0; i < voices; i++) 521 for (i = 0; i < voices; i++)
504 ucontrol->value.integer.value[i] = (ice->spec.phase28.vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1; 522 ucontrol->value.integer.value[i] =
523 (spec->vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1;
505 return 0; 524 return 0;
506} 525}
507 526
508static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 527static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
509{ 528{
510 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 529 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
530 struct phase28_spec *spec = ice->spec;
511 int change = 0, voices, ofs, i; 531 int change = 0, voices, ofs, i;
512 532
513 voices = kcontrol->private_value >> 8; 533 voices = kcontrol->private_value >> 8;
@@ -515,13 +535,13 @@ static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
515 535
516 snd_ice1712_save_gpio_status(ice); 536 snd_ice1712_save_gpio_status(ice);
517 for (i = 0; i < voices; i++) { 537 for (i = 0; i < voices; i++) {
518 int val = (ice->spec.phase28.vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1; 538 int val = (spec->vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
519 if (ucontrol->value.integer.value[i] != val) { 539 if (ucontrol->value.integer.value[i] != val) {
520 ice->spec.phase28.vol[ofs + i] &= ~WM_VOL_MUTE; 540 spec->vol[ofs + i] &= ~WM_VOL_MUTE;
521 ice->spec.phase28.vol[ofs + i] |= 541 spec->vol[ofs + i] |=
522 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE; 542 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
523 wm_set_vol(ice, ofs + i, ice->spec.phase28.vol[ofs + i], 543 wm_set_vol(ice, ofs + i, spec->vol[ofs + i],
524 ice->spec.phase28.master[i]); 544 spec->master[i]);
525 change = 1; 545 change = 1;
526 } 546 }
527 } 547 }
@@ -538,29 +558,33 @@ static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
538static int wm_master_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 558static int wm_master_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
539{ 559{
540 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 560 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
561 struct phase28_spec *spec = ice->spec;
541 562
542 ucontrol->value.integer.value[0] = (ice->spec.phase28.master[0] & WM_VOL_MUTE) ? 0 : 1; 563 ucontrol->value.integer.value[0] =
543 ucontrol->value.integer.value[1] = (ice->spec.phase28.master[1] & WM_VOL_MUTE) ? 0 : 1; 564 (spec->master[0] & WM_VOL_MUTE) ? 0 : 1;
565 ucontrol->value.integer.value[1] =
566 (spec->master[1] & WM_VOL_MUTE) ? 0 : 1;
544 return 0; 567 return 0;
545} 568}
546 569
547static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 570static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
548{ 571{
549 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 572 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
573 struct phase28_spec *spec = ice->spec;
550 int change = 0, i; 574 int change = 0, i;
551 575
552 snd_ice1712_save_gpio_status(ice); 576 snd_ice1712_save_gpio_status(ice);
553 for (i = 0; i < 2; i++) { 577 for (i = 0; i < 2; i++) {
554 int val = (ice->spec.phase28.master[i] & WM_VOL_MUTE) ? 0 : 1; 578 int val = (spec->master[i] & WM_VOL_MUTE) ? 0 : 1;
555 if (ucontrol->value.integer.value[i] != val) { 579 if (ucontrol->value.integer.value[i] != val) {
556 int dac; 580 int dac;
557 ice->spec.phase28.master[i] &= ~WM_VOL_MUTE; 581 spec->master[i] &= ~WM_VOL_MUTE;
558 ice->spec.phase28.master[i] |= 582 spec->master[i] |=
559 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE; 583 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
560 for (dac = 0; dac < ice->num_total_dacs; dac += 2) 584 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
561 wm_set_vol(ice, WM_DAC_ATTEN + dac + i, 585 wm_set_vol(ice, WM_DAC_ATTEN + dac + i,
562 ice->spec.phase28.vol[dac + i], 586 spec->vol[dac + i],
563 ice->spec.phase28.master[i]); 587 spec->master[i]);
564 change = 1; 588 change = 1;
565 } 589 }
566 } 590 }