diff options
Diffstat (limited to 'sound/pci/ice1712/aureon.c')
-rw-r--r-- | sound/pci/ice1712/aureon.c | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c index 110d16e52733..9e66f6d306f8 100644 --- a/sound/pci/ice1712/aureon.c +++ b/sound/pci/ice1712/aureon.c | |||
@@ -689,42 +689,27 @@ static int aureon_ac97_mmute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
689 | return change; | 689 | return change; |
690 | } | 690 | } |
691 | 691 | ||
692 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1); | 692 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -10000, 100, 1); |
693 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1); | 693 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1); |
694 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_adc, -1200, 100, 0); | 694 | static const DECLARE_TLV_DB_SCALE(db_scale_wm_adc, -1200, 100, 0); |
695 | static const DECLARE_TLV_DB_SCALE(db_scale_ac97_master, -4650, 150, 0); | 695 | static const DECLARE_TLV_DB_SCALE(db_scale_ac97_master, -4650, 150, 0); |
696 | static const DECLARE_TLV_DB_SCALE(db_scale_ac97_gain, -3450, 150, 0); | 696 | static const DECLARE_TLV_DB_SCALE(db_scale_ac97_gain, -3450, 150, 0); |
697 | 697 | ||
698 | /* | 698 | #define WM_VOL_MAX 100 |
699 | * Logarithmic volume values for WM8770 | 699 | #define WM_VOL_CNT 101 /* 0dB .. -100dB */ |
700 | * Computed as 20 * Log10(255 / x) | ||
701 | */ | ||
702 | static const unsigned char wm_vol[256] = { | ||
703 | 127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23, | ||
704 | 23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, | ||
705 | 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, | ||
706 | 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, | ||
707 | 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, | ||
708 | 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, | ||
709 | 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, | ||
710 | 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, | ||
711 | 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, | ||
712 | 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, | ||
713 | 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, | ||
714 | 0, 0 | ||
715 | }; | ||
716 | |||
717 | #define WM_VOL_MAX (sizeof(wm_vol) - 1) | ||
718 | #define WM_VOL_MUTE 0x8000 | 700 | #define WM_VOL_MUTE 0x8000 |
719 | 701 | ||
720 | static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master) | 702 | static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master) |
721 | { | 703 | { |
722 | unsigned char nvol; | 704 | unsigned char nvol; |
723 | 705 | ||
724 | if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE)) | 706 | if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE)) { |
725 | nvol = 0; | 707 | nvol = 0; |
726 | else | 708 | } else { |
727 | nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) * (master & ~WM_VOL_MUTE)) / 127) & WM_VOL_MAX]; | 709 | nvol = ((vol % WM_VOL_CNT) * (master % WM_VOL_CNT)) / |
710 | WM_VOL_MAX; | ||
711 | nvol += 0x1b; | ||
712 | } | ||
728 | 713 | ||
729 | wm_put(ice, index, nvol); | 714 | wm_put(ice, index, nvol); |
730 | wm_put_nocache(ice, index, 0x180 | nvol); | 715 | wm_put_nocache(ice, index, 0x180 | nvol); |
@@ -795,7 +780,7 @@ static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_ | |||
795 | for (ch = 0; ch < 2; ch++) { | 780 | for (ch = 0; ch < 2; ch++) { |
796 | unsigned int vol = ucontrol->value.integer.value[ch]; | 781 | unsigned int vol = ucontrol->value.integer.value[ch]; |
797 | if (vol > WM_VOL_MAX) | 782 | if (vol > WM_VOL_MAX) |
798 | continue; | 783 | vol = WM_VOL_MAX; |
799 | vol |= spec->master[ch] & WM_VOL_MUTE; | 784 | vol |= spec->master[ch] & WM_VOL_MUTE; |
800 | if (vol != spec->master[ch]) { | 785 | if (vol != spec->master[ch]) { |
801 | int dac; | 786 | int dac; |
@@ -820,7 +805,7 @@ static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info * | |||
820 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 805 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
821 | uinfo->count = voices; | 806 | uinfo->count = voices; |
822 | uinfo->value.integer.min = 0; /* mute (-101dB) */ | 807 | uinfo->value.integer.min = 0; /* mute (-101dB) */ |
823 | uinfo->value.integer.max = 0x7F; /* 0dB */ | 808 | uinfo->value.integer.max = WM_VOL_MAX; /* 0dB */ |
824 | return 0; | 809 | return 0; |
825 | } | 810 | } |
826 | 811 | ||
@@ -850,9 +835,9 @@ static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value * | |||
850 | snd_ice1712_save_gpio_status(ice); | 835 | snd_ice1712_save_gpio_status(ice); |
851 | for (i = 0; i < voices; i++) { | 836 | for (i = 0; i < voices; i++) { |
852 | unsigned int vol = ucontrol->value.integer.value[i]; | 837 | unsigned int vol = ucontrol->value.integer.value[i]; |
853 | if (vol > 0x7f) | 838 | if (vol > WM_VOL_MAX) |
854 | continue; | 839 | vol = WM_VOL_MAX; |
855 | vol |= spec->vol[ofs+i]; | 840 | vol |= spec->vol[ofs+i] & WM_VOL_MUTE; |
856 | if (vol != spec->vol[ofs+i]) { | 841 | if (vol != spec->vol[ofs+i]) { |
857 | spec->vol[ofs+i] = vol; | 842 | spec->vol[ofs+i] = vol; |
858 | idx = WM_DAC_ATTEN + ofs + i; | 843 | idx = WM_DAC_ATTEN + ofs + i; |