diff options
Diffstat (limited to 'sound/usb/mixer.c')
-rw-r--r-- | sound/usb/mixer.c | 110 |
1 files changed, 60 insertions, 50 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 60f65ace7474..ab23869c01bb 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c | |||
@@ -765,10 +765,61 @@ static void usb_mixer_elem_free(struct snd_kcontrol *kctl) | |||
765 | * interface to ALSA control for feature/mixer units | 765 | * interface to ALSA control for feature/mixer units |
766 | */ | 766 | */ |
767 | 767 | ||
768 | /* volume control quirks */ | ||
769 | static void volume_control_quirks(struct usb_mixer_elem_info *cval, | ||
770 | struct snd_kcontrol *kctl) | ||
771 | { | ||
772 | switch (cval->mixer->chip->usb_id) { | ||
773 | case USB_ID(0x0471, 0x0101): | ||
774 | case USB_ID(0x0471, 0x0104): | ||
775 | case USB_ID(0x0471, 0x0105): | ||
776 | case USB_ID(0x0672, 0x1041): | ||
777 | /* quirk for UDA1321/N101. | ||
778 | * note that detection between firmware 2.1.1.7 (N101) | ||
779 | * and later 2.1.1.21 is not very clear from datasheets. | ||
780 | * I hope that the min value is -15360 for newer firmware --jk | ||
781 | */ | ||
782 | if (!strcmp(kctl->id.name, "PCM Playback Volume") && | ||
783 | cval->min == -15616) { | ||
784 | snd_printk(KERN_INFO | ||
785 | "set volume quirk for UDA1321/N101 chip\n"); | ||
786 | cval->max = -256; | ||
787 | } | ||
788 | break; | ||
789 | |||
790 | case USB_ID(0x046d, 0x09a4): | ||
791 | if (!strcmp(kctl->id.name, "Mic Capture Volume")) { | ||
792 | snd_printk(KERN_INFO | ||
793 | "set volume quirk for QuickCam E3500\n"); | ||
794 | cval->min = 6080; | ||
795 | cval->max = 8768; | ||
796 | cval->res = 192; | ||
797 | } | ||
798 | break; | ||
799 | |||
800 | case USB_ID(0x046d, 0x0808): | ||
801 | case USB_ID(0x046d, 0x0809): | ||
802 | case USB_ID(0x046d, 0x081d): /* HD Webcam c510 */ | ||
803 | case USB_ID(0x046d, 0x0991): | ||
804 | /* Most audio usb devices lie about volume resolution. | ||
805 | * Most Logitech webcams have res = 384. | ||
806 | * Proboly there is some logitech magic behind this number --fishor | ||
807 | */ | ||
808 | if (!strcmp(kctl->id.name, "Mic Capture Volume")) { | ||
809 | snd_printk(KERN_INFO | ||
810 | "set resolution quirk: cval->res = 384\n"); | ||
811 | cval->res = 384; | ||
812 | } | ||
813 | break; | ||
814 | |||
815 | } | ||
816 | } | ||
817 | |||
768 | /* | 818 | /* |
769 | * retrieve the minimum and maximum values for the specified control | 819 | * retrieve the minimum and maximum values for the specified control |
770 | */ | 820 | */ |
771 | static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | 821 | static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval, |
822 | int default_min, struct snd_kcontrol *kctl) | ||
772 | { | 823 | { |
773 | /* for failsafe */ | 824 | /* for failsafe */ |
774 | cval->min = default_min; | 825 | cval->min = default_min; |
@@ -844,6 +895,9 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | |||
844 | cval->initialized = 1; | 895 | cval->initialized = 1; |
845 | } | 896 | } |
846 | 897 | ||
898 | if (kctl) | ||
899 | volume_control_quirks(cval, kctl); | ||
900 | |||
847 | /* USB descriptions contain the dB scale in 1/256 dB unit | 901 | /* USB descriptions contain the dB scale in 1/256 dB unit |
848 | * while ALSA TLV contains in 1/100 dB unit | 902 | * while ALSA TLV contains in 1/100 dB unit |
849 | */ | 903 | */ |
@@ -864,6 +918,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | |||
864 | return 0; | 918 | return 0; |
865 | } | 919 | } |
866 | 920 | ||
921 | #define get_min_max(cval, def) get_min_max_with_quirks(cval, def, NULL) | ||
867 | 922 | ||
868 | /* get a feature/mixer unit info */ | 923 | /* get a feature/mixer unit info */ |
869 | static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 924 | static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
@@ -882,7 +937,7 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
882 | uinfo->value.integer.max = 1; | 937 | uinfo->value.integer.max = 1; |
883 | } else { | 938 | } else { |
884 | if (!cval->initialized) { | 939 | if (!cval->initialized) { |
885 | get_min_max(cval, 0); | 940 | get_min_max_with_quirks(cval, 0, kcontrol); |
886 | if (cval->initialized && cval->dBmin >= cval->dBmax) { | 941 | if (cval->initialized && cval->dBmin >= cval->dBmax) { |
887 | kcontrol->vd[0].access &= | 942 | kcontrol->vd[0].access &= |
888 | ~(SNDRV_CTL_ELEM_ACCESS_TLV_READ | | 943 | ~(SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
@@ -1045,9 +1100,6 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, | |||
1045 | cval->ch_readonly = readonly_mask; | 1100 | cval->ch_readonly = readonly_mask; |
1046 | } | 1101 | } |
1047 | 1102 | ||
1048 | /* get min/max values */ | ||
1049 | get_min_max(cval, 0); | ||
1050 | |||
1051 | /* if all channels in the mask are marked read-only, make the control | 1103 | /* if all channels in the mask are marked read-only, make the control |
1052 | * read-only. set_cur_mix_value() will check the mask again and won't | 1104 | * read-only. set_cur_mix_value() will check the mask again and won't |
1053 | * issue write commands to read-only channels. */ | 1105 | * issue write commands to read-only channels. */ |
@@ -1069,6 +1121,9 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, | |||
1069 | len = snd_usb_copy_string_desc(state, nameid, | 1121 | len = snd_usb_copy_string_desc(state, nameid, |
1070 | kctl->id.name, sizeof(kctl->id.name)); | 1122 | kctl->id.name, sizeof(kctl->id.name)); |
1071 | 1123 | ||
1124 | /* get min/max values */ | ||
1125 | get_min_max_with_quirks(cval, 0, kctl); | ||
1126 | |||
1072 | switch (control) { | 1127 | switch (control) { |
1073 | case UAC_FU_MUTE: | 1128 | case UAC_FU_MUTE: |
1074 | case UAC_FU_VOLUME: | 1129 | case UAC_FU_VOLUME: |
@@ -1118,51 +1173,6 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, | |||
1118 | break; | 1173 | break; |
1119 | } | 1174 | } |
1120 | 1175 | ||
1121 | /* volume control quirks */ | ||
1122 | switch (state->chip->usb_id) { | ||
1123 | case USB_ID(0x0471, 0x0101): | ||
1124 | case USB_ID(0x0471, 0x0104): | ||
1125 | case USB_ID(0x0471, 0x0105): | ||
1126 | case USB_ID(0x0672, 0x1041): | ||
1127 | /* quirk for UDA1321/N101. | ||
1128 | * note that detection between firmware 2.1.1.7 (N101) | ||
1129 | * and later 2.1.1.21 is not very clear from datasheets. | ||
1130 | * I hope that the min value is -15360 for newer firmware --jk | ||
1131 | */ | ||
1132 | if (!strcmp(kctl->id.name, "PCM Playback Volume") && | ||
1133 | cval->min == -15616) { | ||
1134 | snd_printk(KERN_INFO | ||
1135 | "set volume quirk for UDA1321/N101 chip\n"); | ||
1136 | cval->max = -256; | ||
1137 | } | ||
1138 | break; | ||
1139 | |||
1140 | case USB_ID(0x046d, 0x09a4): | ||
1141 | if (!strcmp(kctl->id.name, "Mic Capture Volume")) { | ||
1142 | snd_printk(KERN_INFO | ||
1143 | "set volume quirk for QuickCam E3500\n"); | ||
1144 | cval->min = 6080; | ||
1145 | cval->max = 8768; | ||
1146 | cval->res = 192; | ||
1147 | } | ||
1148 | break; | ||
1149 | |||
1150 | case USB_ID(0x046d, 0x0808): | ||
1151 | case USB_ID(0x046d, 0x0809): | ||
1152 | case USB_ID(0x046d, 0x0991): | ||
1153 | /* Most audio usb devices lie about volume resolution. | ||
1154 | * Most Logitech webcams have res = 384. | ||
1155 | * Proboly there is some logitech magic behind this number --fishor | ||
1156 | */ | ||
1157 | if (!strcmp(kctl->id.name, "Mic Capture Volume")) { | ||
1158 | snd_printk(KERN_INFO | ||
1159 | "set resolution quirk: cval->res = 384\n"); | ||
1160 | cval->res = 384; | ||
1161 | } | ||
1162 | break; | ||
1163 | |||
1164 | } | ||
1165 | |||
1166 | range = (cval->max - cval->min) / cval->res; | 1176 | range = (cval->max - cval->min) / cval->res; |
1167 | /* Are there devices with volume range more than 255? I use a bit more | 1177 | /* Are there devices with volume range more than 255? I use a bit more |
1168 | * to be sure. 384 is a resolution magic number found on Logitech | 1178 | * to be sure. 384 is a resolution magic number found on Logitech |