diff options
author | Krzysztof Helt <krzysztof.h1@wp.pl> | 2009-11-18 11:29:36 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-11-19 05:52:47 -0500 |
commit | 4b28dca86066596721a6243c94611dab41970079 (patch) | |
tree | 96b1ae145d62d478edd28a2602f5bafe6cd22144 /sound | |
parent | bec145ae6f6978f0319e5600a742f45f76ecc4dd (diff) |
ALSA: cs4236: add dB scale for all volume controls
Use db scale for all volume controls according to Crystal's datasheets.
Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/isa/cs423x/cs4236_lib.c | 152 |
1 files changed, 108 insertions, 44 deletions
diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index 4c4024a73c6b..c5adca300632 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c | |||
@@ -88,6 +88,7 @@ | |||
88 | #include <sound/wss.h> | 88 | #include <sound/wss.h> |
89 | #include <sound/asoundef.h> | 89 | #include <sound/asoundef.h> |
90 | #include <sound/initval.h> | 90 | #include <sound/initval.h> |
91 | #include <sound/tlv.h> | ||
91 | 92 | ||
92 | /* | 93 | /* |
93 | * | 94 | * |
@@ -399,6 +400,14 @@ int snd_cs4236_pcm(struct snd_wss *chip, int device, struct snd_pcm **rpcm) | |||
399 | .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ | 400 | .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ |
400 | .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } | 401 | .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } |
401 | 402 | ||
403 | #define CS4236_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \ | ||
404 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | ||
405 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
406 | .info = snd_cs4236_info_single, \ | ||
407 | .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ | ||
408 | .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24), \ | ||
409 | .tlv = { .p = (xtlv) } } | ||
410 | |||
402 | static int snd_cs4236_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 411 | static int snd_cs4236_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
403 | { | 412 | { |
404 | int mask = (kcontrol->private_value >> 16) & 0xff; | 413 | int mask = (kcontrol->private_value >> 16) & 0xff; |
@@ -502,6 +511,16 @@ static int snd_cs4236_put_singlec(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
502 | .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ | 511 | .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ |
503 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } | 512 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } |
504 | 513 | ||
514 | #define CS4236_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, \ | ||
515 | shift_right, mask, invert, xtlv) \ | ||
516 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | ||
517 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
518 | .info = snd_cs4236_info_double, \ | ||
519 | .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ | ||
520 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | \ | ||
521 | (shift_right << 19) | (mask << 24) | (invert << 22), \ | ||
522 | .tlv = { .p = (xtlv) } } | ||
523 | |||
505 | static int snd_cs4236_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 524 | static int snd_cs4236_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
506 | { | 525 | { |
507 | int mask = (kcontrol->private_value >> 24) & 0xff; | 526 | int mask = (kcontrol->private_value >> 24) & 0xff; |
@@ -572,12 +591,23 @@ static int snd_cs4236_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
572 | return change; | 591 | return change; |
573 | } | 592 | } |
574 | 593 | ||
575 | #define CS4236_DOUBLE1(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ | 594 | #define CS4236_DOUBLE1(xname, xindex, left_reg, right_reg, shift_left, \ |
595 | shift_right, mask, invert) \ | ||
576 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 596 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
577 | .info = snd_cs4236_info_double, \ | 597 | .info = snd_cs4236_info_double, \ |
578 | .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ | 598 | .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ |
579 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } | 599 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } |
580 | 600 | ||
601 | #define CS4236_DOUBLE1_TLV(xname, xindex, left_reg, right_reg, shift_left, \ | ||
602 | shift_right, mask, invert, xtlv) \ | ||
603 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | ||
604 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
605 | .info = snd_cs4236_info_double, \ | ||
606 | .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ | ||
607 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | \ | ||
608 | (shift_right << 19) | (mask << 24) | (invert << 22), \ | ||
609 | .tlv = { .p = (xtlv) } } | ||
610 | |||
581 | static int snd_cs4236_get_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 611 | static int snd_cs4236_get_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
582 | { | 612 | { |
583 | struct snd_wss *chip = snd_kcontrol_chip(kcontrol); | 613 | struct snd_wss *chip = snd_kcontrol_chip(kcontrol); |
@@ -631,16 +661,18 @@ static int snd_cs4236_put_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
631 | return change; | 661 | return change; |
632 | } | 662 | } |
633 | 663 | ||
634 | #define CS4236_MASTER_DIGITAL(xname, xindex) \ | 664 | #define CS4236_MASTER_DIGITAL(xname, xindex, xtlv) \ |
635 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 665 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
666 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
636 | .info = snd_cs4236_info_double, \ | 667 | .info = snd_cs4236_info_double, \ |
637 | .get = snd_cs4236_get_master_digital, .put = snd_cs4236_put_master_digital, \ | 668 | .get = snd_cs4236_get_master_digital, .put = snd_cs4236_put_master_digital, \ |
638 | .private_value = 71 << 24 } | 669 | .private_value = 71 << 24, \ |
670 | .tlv = { .p = (xtlv) } } | ||
639 | 671 | ||
640 | static inline int snd_cs4236_mixer_master_digital_invert_volume(int vol) | 672 | static inline int snd_cs4236_mixer_master_digital_invert_volume(int vol) |
641 | { | 673 | { |
642 | return (vol < 64) ? 63 - vol : 64 + (71 - vol); | 674 | return (vol < 64) ? 63 - vol : 64 + (71 - vol); |
643 | } | 675 | } |
644 | 676 | ||
645 | static int snd_cs4236_get_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 677 | static int snd_cs4236_get_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
646 | { | 678 | { |
@@ -673,11 +705,13 @@ static int snd_cs4236_put_master_digital(struct snd_kcontrol *kcontrol, struct s | |||
673 | return change; | 705 | return change; |
674 | } | 706 | } |
675 | 707 | ||
676 | #define CS4235_OUTPUT_ACCU(xname, xindex) \ | 708 | #define CS4235_OUTPUT_ACCU(xname, xindex, xtlv) \ |
677 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 709 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
710 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
678 | .info = snd_cs4236_info_double, \ | 711 | .info = snd_cs4236_info_double, \ |
679 | .get = snd_cs4235_get_output_accu, .put = snd_cs4235_put_output_accu, \ | 712 | .get = snd_cs4235_get_output_accu, .put = snd_cs4235_put_output_accu, \ |
680 | .private_value = 3 << 24 } | 713 | .private_value = 3 << 24, \ |
714 | .tlv = { .p = (xtlv) } } | ||
681 | 715 | ||
682 | static inline int snd_cs4235_mixer_output_accu_get_volume(int vol) | 716 | static inline int snd_cs4235_mixer_output_accu_get_volume(int vol) |
683 | { | 717 | { |
@@ -732,41 +766,56 @@ static int snd_cs4235_put_output_accu(struct snd_kcontrol *kcontrol, struct snd_ | |||
732 | return change; | 766 | return change; |
733 | } | 767 | } |
734 | 768 | ||
769 | static const DECLARE_TLV_DB_SCALE(db_scale_7bit, -9450, 150, 0); | ||
770 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); | ||
771 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit_12db_max, -8250, 150, 0); | ||
772 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); | ||
773 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_22db_max, -2400, 150, 0); | ||
774 | static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0); | ||
775 | static const DECLARE_TLV_DB_SCALE(db_scale_2bit, -1800, 600, 0); | ||
776 | static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); | ||
777 | |||
735 | static struct snd_kcontrol_new snd_cs4236_controls[] = { | 778 | static struct snd_kcontrol_new snd_cs4236_controls[] = { |
736 | 779 | ||
737 | CS4236_DOUBLE("Master Digital Playback Switch", 0, | 780 | CS4236_DOUBLE("Master Digital Playback Switch", 0, |
738 | CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), | 781 | CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), |
739 | CS4236_DOUBLE("Master Digital Capture Switch", 0, | 782 | CS4236_DOUBLE("Master Digital Capture Switch", 0, |
740 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), | 783 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), |
741 | CS4236_MASTER_DIGITAL("Master Digital Volume", 0), | 784 | CS4236_MASTER_DIGITAL("Master Digital Volume", 0, db_scale_7bit), |
742 | 785 | ||
743 | CS4236_DOUBLE("Capture Boost Volume", 0, | 786 | CS4236_DOUBLE_TLV("Capture Boost Volume", 0, |
744 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1), | 787 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1, |
788 | db_scale_2bit), | ||
745 | 789 | ||
746 | WSS_DOUBLE("PCM Playback Switch", 0, | 790 | WSS_DOUBLE("PCM Playback Switch", 0, |
747 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | 791 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
748 | WSS_DOUBLE("PCM Playback Volume", 0, | 792 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, |
749 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), | 793 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, |
794 | db_scale_6bit), | ||
750 | 795 | ||
751 | CS4236_DOUBLE("DSP Playback Switch", 0, | 796 | CS4236_DOUBLE("DSP Playback Switch", 0, |
752 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), | 797 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), |
753 | CS4236_DOUBLE("DSP Playback Volume", 0, | 798 | CS4236_DOUBLE_TLV("DSP Playback Volume", 0, |
754 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 0, 0, 63, 1), | 799 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 0, 0, 63, 1, |
800 | db_scale_6bit), | ||
755 | 801 | ||
756 | CS4236_DOUBLE("FM Playback Switch", 0, | 802 | CS4236_DOUBLE("FM Playback Switch", 0, |
757 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 7, 7, 1, 1), | 803 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 7, 7, 1, 1), |
758 | CS4236_DOUBLE("FM Playback Volume", 0, | 804 | CS4236_DOUBLE_TLV("FM Playback Volume", 0, |
759 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 0, 0, 63, 1), | 805 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 0, 0, 63, 1, |
806 | db_scale_6bit), | ||
760 | 807 | ||
761 | CS4236_DOUBLE("Wavetable Playback Switch", 0, | 808 | CS4236_DOUBLE("Wavetable Playback Switch", 0, |
762 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 7, 7, 1, 1), | 809 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 7, 7, 1, 1), |
763 | CS4236_DOUBLE("Wavetable Playback Volume", 0, | 810 | CS4236_DOUBLE_TLV("Wavetable Playback Volume", 0, |
764 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 0, 0, 63, 1), | 811 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 0, 0, 63, 1, |
812 | db_scale_6bit_12db_max), | ||
765 | 813 | ||
766 | WSS_DOUBLE("Synth Playback Switch", 0, | 814 | WSS_DOUBLE("Synth Playback Switch", 0, |
767 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | 815 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), |
768 | WSS_DOUBLE("Synth Volume", 0, | 816 | WSS_DOUBLE_TLV("Synth Volume", 0, |
769 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), | 817 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1, |
818 | db_scale_5bit_12db_max), | ||
770 | WSS_DOUBLE("Synth Capture Switch", 0, | 819 | WSS_DOUBLE("Synth Capture Switch", 0, |
771 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), | 820 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), |
772 | WSS_DOUBLE("Synth Capture Bypass", 0, | 821 | WSS_DOUBLE("Synth Capture Bypass", 0, |
@@ -776,14 +825,16 @@ CS4236_DOUBLE("Mic Playback Switch", 0, | |||
776 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), | 825 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), |
777 | CS4236_DOUBLE("Mic Capture Switch", 0, | 826 | CS4236_DOUBLE("Mic Capture Switch", 0, |
778 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), | 827 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), |
779 | CS4236_DOUBLE("Mic Volume", 0, CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 0, 0, 31, 1), | 828 | CS4236_DOUBLE_TLV("Mic Volume", 0, CS4236_LEFT_MIC, CS4236_RIGHT_MIC, |
829 | 0, 0, 31, 1, db_scale_5bit_22db_max), | ||
780 | CS4236_DOUBLE("Mic Playback Boost (+20dB)", 0, | 830 | CS4236_DOUBLE("Mic Playback Boost (+20dB)", 0, |
781 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 5, 5, 1, 0), | 831 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 5, 5, 1, 0), |
782 | 832 | ||
783 | WSS_DOUBLE("Line Playback Switch", 0, | 833 | WSS_DOUBLE("Line Playback Switch", 0, |
784 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 834 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), |
785 | WSS_DOUBLE("Line Volume", 0, | 835 | WSS_DOUBLE_TLV("Line Volume", 0, |
786 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), | 836 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, |
837 | db_scale_5bit_12db_max), | ||
787 | WSS_DOUBLE("Line Capture Switch", 0, | 838 | WSS_DOUBLE("Line Capture Switch", 0, |
788 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), | 839 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), |
789 | WSS_DOUBLE("Line Capture Bypass", 0, | 840 | WSS_DOUBLE("Line Capture Bypass", 0, |
@@ -791,8 +842,9 @@ WSS_DOUBLE("Line Capture Bypass", 0, | |||
791 | 842 | ||
792 | WSS_DOUBLE("CD Playback Switch", 0, | 843 | WSS_DOUBLE("CD Playback Switch", 0, |
793 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 844 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
794 | WSS_DOUBLE("CD Volume", 0, | 845 | WSS_DOUBLE_TLV("CD Volume", 0, |
795 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), | 846 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, |
847 | db_scale_5bit_12db_max), | ||
796 | WSS_DOUBLE("CD Capture Switch", 0, | 848 | WSS_DOUBLE("CD Capture Switch", 0, |
797 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), | 849 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), |
798 | 850 | ||
@@ -800,44 +852,53 @@ CS4236_DOUBLE1("Mono Output Playback Switch", 0, | |||
800 | CS4231_MONO_CTRL, CS4236_RIGHT_MIX_CTRL, 6, 7, 1, 1), | 852 | CS4231_MONO_CTRL, CS4236_RIGHT_MIX_CTRL, 6, 7, 1, 1), |
801 | CS4236_DOUBLE1("Beep Playback Switch", 0, | 853 | CS4236_DOUBLE1("Beep Playback Switch", 0, |
802 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), | 854 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), |
803 | WSS_SINGLE("Beep Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1), | 855 | WSS_SINGLE_TLV("Beep Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1, |
856 | db_scale_4bit), | ||
804 | WSS_SINGLE("Beep Bypass Playback Switch", 0, CS4231_MONO_CTRL, 5, 1, 0), | 857 | WSS_SINGLE("Beep Bypass Playback Switch", 0, CS4231_MONO_CTRL, 5, 1, 0), |
805 | 858 | ||
806 | WSS_DOUBLE("Capture Volume", 0, | 859 | WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, |
807 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), | 860 | 0, 0, 15, 0, db_scale_rec_gain), |
808 | WSS_DOUBLE("Analog Loopback Capture Switch", 0, | 861 | WSS_DOUBLE("Analog Loopback Capture Switch", 0, |
809 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0), | 862 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0), |
810 | 863 | ||
811 | WSS_SINGLE("Digital Loopback Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0), | 864 | WSS_SINGLE("Loopback Digital Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0), |
812 | CS4236_DOUBLE1("Digital Loopback Playback Volume", 0, | 865 | CS4236_DOUBLE1_TLV("Loopback Digital Playback Volume", 0, |
813 | CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1) | 866 | CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1, |
867 | db_scale_6bit), | ||
814 | }; | 868 | }; |
815 | 869 | ||
870 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_6db_max, -5600, 200, 0); | ||
871 | static const DECLARE_TLV_DB_SCALE(db_scale_2bit_16db_max, -2400, 800, 0); | ||
872 | |||
816 | static struct snd_kcontrol_new snd_cs4235_controls[] = { | 873 | static struct snd_kcontrol_new snd_cs4235_controls[] = { |
817 | 874 | ||
818 | WSS_DOUBLE("Master Playback Switch", 0, | 875 | WSS_DOUBLE("Master Playback Switch", 0, |
819 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1), | 876 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1), |
820 | WSS_DOUBLE("Master Playback Volume", 0, | 877 | WSS_DOUBLE_TLV("Master Playback Volume", 0, |
821 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1), | 878 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1, |
879 | db_scale_5bit_6db_max), | ||
822 | 880 | ||
823 | CS4235_OUTPUT_ACCU("Playback Volume", 0), | 881 | CS4235_OUTPUT_ACCU("Playback Volume", 0, db_scale_2bit_16db_max), |
824 | 882 | ||
825 | WSS_DOUBLE("Synth Playback Switch", 1, | 883 | WSS_DOUBLE("Synth Playback Switch", 1, |
826 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | 884 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), |
827 | WSS_DOUBLE("Synth Capture Switch", 1, | 885 | WSS_DOUBLE("Synth Capture Switch", 1, |
828 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), | 886 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), |
829 | WSS_DOUBLE("Synth Volume", 1, | 887 | WSS_DOUBLE_TLV("Synth Volume", 1, |
830 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), | 888 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1, |
889 | db_scale_5bit_12db_max), | ||
831 | 890 | ||
832 | CS4236_DOUBLE("Capture Volume", 0, | 891 | CS4236_DOUBLE_TLV("Capture Volume", 0, |
833 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1), | 892 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1, |
893 | db_scale_2bit), | ||
834 | 894 | ||
835 | WSS_DOUBLE("PCM Playback Switch", 0, | 895 | WSS_DOUBLE("PCM Playback Switch", 0, |
836 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | 896 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
837 | WSS_DOUBLE("PCM Capture Switch", 0, | 897 | WSS_DOUBLE("PCM Capture Switch", 0, |
838 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), | 898 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), |
839 | WSS_DOUBLE("PCM Volume", 0, | 899 | WSS_DOUBLE_TLV("PCM Volume", 0, |
840 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), | 900 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, |
901 | db_scale_6bit), | ||
841 | 902 | ||
842 | CS4236_DOUBLE("DSP Switch", 0, CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), | 903 | CS4236_DOUBLE("DSP Switch", 0, CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), |
843 | 904 | ||
@@ -850,22 +911,25 @@ CS4236_DOUBLE("Mic Capture Switch", 0, | |||
850 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), | 911 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), |
851 | CS4236_DOUBLE("Mic Playback Switch", 0, | 912 | CS4236_DOUBLE("Mic Playback Switch", 0, |
852 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), | 913 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), |
853 | CS4236_SINGLE("Mic Volume", 0, CS4236_LEFT_MIC, 0, 31, 1), | 914 | CS4236_SINGLE_TLV("Mic Volume", 0, CS4236_LEFT_MIC, 0, 31, 1, |
915 | db_scale_5bit_22db_max), | ||
854 | CS4236_SINGLE("Mic Boost (+20dB)", 0, CS4236_LEFT_MIC, 5, 1, 0), | 916 | CS4236_SINGLE("Mic Boost (+20dB)", 0, CS4236_LEFT_MIC, 5, 1, 0), |
855 | 917 | ||
856 | WSS_DOUBLE("Line Playback Switch", 0, | 918 | WSS_DOUBLE("Line Playback Switch", 0, |
857 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 919 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), |
858 | WSS_DOUBLE("Line Capture Switch", 0, | 920 | WSS_DOUBLE("Line Capture Switch", 0, |
859 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), | 921 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), |
860 | WSS_DOUBLE("Line Volume", 0, | 922 | WSS_DOUBLE_TLV("Line Volume", 0, |
861 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), | 923 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, |
924 | db_scale_5bit_12db_max), | ||
862 | 925 | ||
863 | WSS_DOUBLE("CD Playback Switch", 1, | 926 | WSS_DOUBLE("CD Playback Switch", 1, |
864 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 927 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
865 | WSS_DOUBLE("CD Capture Switch", 1, | 928 | WSS_DOUBLE("CD Capture Switch", 1, |
866 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), | 929 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), |
867 | WSS_DOUBLE("CD Volume", 1, | 930 | WSS_DOUBLE_TLV("CD Volume", 1, |
868 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), | 931 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, |
932 | db_scale_5bit_12db_max), | ||
869 | 933 | ||
870 | CS4236_DOUBLE1("Beep Playback Switch", 0, | 934 | CS4236_DOUBLE1("Beep Playback Switch", 0, |
871 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), | 935 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), |