aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/mixer.c109
1 files changed, 59 insertions, 50 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 60f65ace7474..c5444e00f0c6 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -765,10 +765,60 @@ 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 */
769static 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, 0x0991):
803 /* Most audio usb devices lie about volume resolution.
804 * Most Logitech webcams have res = 384.
805 * Proboly there is some logitech magic behind this number --fishor
806 */
807 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
808 snd_printk(KERN_INFO
809 "set resolution quirk: cval->res = 384\n");
810 cval->res = 384;
811 }
812 break;
813
814 }
815}
816
768/* 817/*
769 * retrieve the minimum and maximum values for the specified control 818 * retrieve the minimum and maximum values for the specified control
770 */ 819 */
771static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) 820static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,
821 int default_min, struct snd_kcontrol *kctl)
772{ 822{
773 /* for failsafe */ 823 /* for failsafe */
774 cval->min = default_min; 824 cval->min = default_min;
@@ -844,6 +894,9 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
844 cval->initialized = 1; 894 cval->initialized = 1;
845 } 895 }
846 896
897 if (kctl)
898 volume_control_quirks(cval, kctl);
899
847 /* USB descriptions contain the dB scale in 1/256 dB unit 900 /* USB descriptions contain the dB scale in 1/256 dB unit
848 * while ALSA TLV contains in 1/100 dB unit 901 * while ALSA TLV contains in 1/100 dB unit
849 */ 902 */
@@ -864,6 +917,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
864 return 0; 917 return 0;
865} 918}
866 919
920#define get_min_max(cval, def) get_min_max_with_quirks(cval, def, NULL)
867 921
868/* get a feature/mixer unit info */ 922/* get a feature/mixer unit info */
869static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 923static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
@@ -882,7 +936,7 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
882 uinfo->value.integer.max = 1; 936 uinfo->value.integer.max = 1;
883 } else { 937 } else {
884 if (!cval->initialized) { 938 if (!cval->initialized) {
885 get_min_max(cval, 0); 939 get_min_max_with_quirks(cval, 0, kcontrol);
886 if (cval->initialized && cval->dBmin >= cval->dBmax) { 940 if (cval->initialized && cval->dBmin >= cval->dBmax) {
887 kcontrol->vd[0].access &= 941 kcontrol->vd[0].access &=
888 ~(SNDRV_CTL_ELEM_ACCESS_TLV_READ | 942 ~(SNDRV_CTL_ELEM_ACCESS_TLV_READ |
@@ -1045,9 +1099,6 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1045 cval->ch_readonly = readonly_mask; 1099 cval->ch_readonly = readonly_mask;
1046 } 1100 }
1047 1101
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 1102 /* 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 1103 * read-only. set_cur_mix_value() will check the mask again and won't
1053 * issue write commands to read-only channels. */ 1104 * issue write commands to read-only channels. */
@@ -1069,6 +1120,9 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1069 len = snd_usb_copy_string_desc(state, nameid, 1120 len = snd_usb_copy_string_desc(state, nameid,
1070 kctl->id.name, sizeof(kctl->id.name)); 1121 kctl->id.name, sizeof(kctl->id.name));
1071 1122
1123 /* get min/max values */
1124 get_min_max_with_quirks(cval, 0, kctl);
1125
1072 switch (control) { 1126 switch (control) {
1073 case UAC_FU_MUTE: 1127 case UAC_FU_MUTE:
1074 case UAC_FU_VOLUME: 1128 case UAC_FU_VOLUME:
@@ -1118,51 +1172,6 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1118 break; 1172 break;
1119 } 1173 }
1120 1174
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; 1175 range = (cval->max - cval->min) / cval->res;
1167 /* Are there devices with volume range more than 255? I use a bit more 1176 /* 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 1177 * to be sure. 384 is a resolution magic number found on Logitech