aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/mixer.c34
-rw-r--r--sound/usb/mixer.h8
-rw-r--r--sound/usb/mixer_quirks.c9
3 files changed, 26 insertions, 25 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index e4aaa21baed2..14e1455ca9de 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -412,7 +412,7 @@ static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval,
412 value); 412 value);
413} 413}
414 414
415static int get_cur_mix_value(struct usb_mixer_elem_info *cval, 415int snd_usb_get_cur_mix_value(struct usb_mixer_elem_info *cval,
416 int channel, int index, int *value) 416 int channel, int index, int *value)
417{ 417{
418 int err; 418 int err;
@@ -497,7 +497,7 @@ static int set_cur_ctl_value(struct usb_mixer_elem_info *cval,
497 return snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, validx, value); 497 return snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, validx, value);
498} 498}
499 499
500static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, 500int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
501 int index, int value) 501 int index, int value)
502{ 502{
503 int err; 503 int err;
@@ -815,7 +815,7 @@ static struct usb_feature_control_info audio_feature_info[] = {
815}; 815};
816 816
817/* private_free callback */ 817/* private_free callback */
818static void usb_mixer_elem_free(struct snd_kcontrol *kctl) 818void snd_usb_mixer_elem_free(struct snd_kcontrol *kctl)
819{ 819{
820 kfree(kctl->private_data); 820 kfree(kctl->private_data);
821 kctl->private_data = NULL; 821 kctl->private_data = NULL;
@@ -998,7 +998,7 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,
998 else 998 else
999 test -= cval->res; 999 test -= cval->res;
1000 if (test < cval->min || test > cval->max || 1000 if (test < cval->min || test > cval->max ||
1001 set_cur_mix_value(cval, minchn, 0, test) || 1001 snd_usb_set_cur_mix_value(cval, minchn, 0, test) ||
1002 get_cur_mix_raw(cval, minchn, &check)) { 1002 get_cur_mix_raw(cval, minchn, &check)) {
1003 cval->res = last_valid_res; 1003 cval->res = last_valid_res;
1004 break; 1004 break;
@@ -1007,7 +1007,7 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,
1007 break; 1007 break;
1008 cval->res *= 2; 1008 cval->res *= 2;
1009 } 1009 }
1010 set_cur_mix_value(cval, minchn, 0, saved); 1010 snd_usb_set_cur_mix_value(cval, minchn, 0, saved);
1011 } 1011 }
1012 1012
1013 cval->initialized = 1; 1013 cval->initialized = 1;
@@ -1086,7 +1086,7 @@ static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol,
1086 for (c = 0; c < MAX_CHANNELS; c++) { 1086 for (c = 0; c < MAX_CHANNELS; c++) {
1087 if (!(cval->cmask & (1 << c))) 1087 if (!(cval->cmask & (1 << c)))
1088 continue; 1088 continue;
1089 err = get_cur_mix_value(cval, c + 1, cnt, &val); 1089 err = snd_usb_get_cur_mix_value(cval, c + 1, cnt, &val);
1090 if (err < 0) 1090 if (err < 0)
1091 return cval->mixer->ignore_ctl_error ? 0 : err; 1091 return cval->mixer->ignore_ctl_error ? 0 : err;
1092 val = get_relative_value(cval, val); 1092 val = get_relative_value(cval, val);
@@ -1096,7 +1096,7 @@ static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol,
1096 return 0; 1096 return 0;
1097 } else { 1097 } else {
1098 /* master channel */ 1098 /* master channel */
1099 err = get_cur_mix_value(cval, 0, 0, &val); 1099 err = snd_usb_get_cur_mix_value(cval, 0, 0, &val);
1100 if (err < 0) 1100 if (err < 0)
1101 return cval->mixer->ignore_ctl_error ? 0 : err; 1101 return cval->mixer->ignore_ctl_error ? 0 : err;
1102 val = get_relative_value(cval, val); 1102 val = get_relative_value(cval, val);
@@ -1118,26 +1118,26 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol,
1118 for (c = 0; c < MAX_CHANNELS; c++) { 1118 for (c = 0; c < MAX_CHANNELS; c++) {
1119 if (!(cval->cmask & (1 << c))) 1119 if (!(cval->cmask & (1 << c)))
1120 continue; 1120 continue;
1121 err = get_cur_mix_value(cval, c + 1, cnt, &oval); 1121 err = snd_usb_get_cur_mix_value(cval, c + 1, cnt, &oval);
1122 if (err < 0) 1122 if (err < 0)
1123 return cval->mixer->ignore_ctl_error ? 0 : err; 1123 return cval->mixer->ignore_ctl_error ? 0 : err;
1124 val = ucontrol->value.integer.value[cnt]; 1124 val = ucontrol->value.integer.value[cnt];
1125 val = get_abs_value(cval, val); 1125 val = get_abs_value(cval, val);
1126 if (oval != val) { 1126 if (oval != val) {
1127 set_cur_mix_value(cval, c + 1, cnt, val); 1127 snd_usb_set_cur_mix_value(cval, c + 1, cnt, val);
1128 changed = 1; 1128 changed = 1;
1129 } 1129 }
1130 cnt++; 1130 cnt++;
1131 } 1131 }
1132 } else { 1132 } else {
1133 /* master channel */ 1133 /* master channel */
1134 err = get_cur_mix_value(cval, 0, 0, &oval); 1134 err = snd_usb_get_cur_mix_value(cval, 0, 0, &oval);
1135 if (err < 0) 1135 if (err < 0)
1136 return cval->mixer->ignore_ctl_error ? 0 : err; 1136 return cval->mixer->ignore_ctl_error ? 0 : err;
1137 val = ucontrol->value.integer.value[0]; 1137 val = ucontrol->value.integer.value[0];
1138 val = get_abs_value(cval, val); 1138 val = get_abs_value(cval, val);
1139 if (val != oval) { 1139 if (val != oval) {
1140 set_cur_mix_value(cval, 0, 0, val); 1140 snd_usb_set_cur_mix_value(cval, 0, 0, val);
1141 changed = 1; 1141 changed = 1;
1142 } 1142 }
1143 } 1143 }
@@ -1250,7 +1250,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1250 1250
1251 /* 1251 /*
1252 * If all channels in the mask are marked read-only, make the control 1252 * If all channels in the mask are marked read-only, make the control
1253 * read-only. set_cur_mix_value() will check the mask again and won't 1253 * read-only. snd_usb_set_cur_mix_value() will check the mask again and won't
1254 * issue write commands to read-only channels. 1254 * issue write commands to read-only channels.
1255 */ 1255 */
1256 if (cval->channels == readonly_mask) 1256 if (cval->channels == readonly_mask)
@@ -1263,7 +1263,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1263 kfree(cval); 1263 kfree(cval);
1264 return; 1264 return;
1265 } 1265 }
1266 kctl->private_free = usb_mixer_elem_free; 1266 kctl->private_free = snd_usb_mixer_elem_free;
1267 1267
1268 len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); 1268 len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
1269 mapped_name = len != 0; 1269 mapped_name = len != 0;
@@ -1546,7 +1546,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state,
1546 kfree(cval); 1546 kfree(cval);
1547 return; 1547 return;
1548 } 1548 }
1549 kctl->private_free = usb_mixer_elem_free; 1549 kctl->private_free = snd_usb_mixer_elem_free;
1550 1550
1551 len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); 1551 len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name));
1552 if (!len) 1552 if (!len)
@@ -1846,7 +1846,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
1846 kfree(cval); 1846 kfree(cval);
1847 return -ENOMEM; 1847 return -ENOMEM;
1848 } 1848 }
1849 kctl->private_free = usb_mixer_elem_free; 1849 kctl->private_free = snd_usb_mixer_elem_free;
1850 1850
1851 if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name))) { 1851 if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name))) {
1852 /* nothing */ ; 1852 /* nothing */ ;
@@ -2526,7 +2526,7 @@ static int restore_mixer_value(struct usb_mixer_elem_info *cval)
2526 if (!(cval->cmask & (1 << c))) 2526 if (!(cval->cmask & (1 << c)))
2527 continue; 2527 continue;
2528 if (cval->cached & (1 << c)) { 2528 if (cval->cached & (1 << c)) {
2529 err = set_cur_mix_value(cval, c + 1, idx, 2529 err = snd_usb_set_cur_mix_value(cval, c + 1, idx,
2530 cval->cache_val[idx]); 2530 cval->cache_val[idx]);
2531 if (err < 0) 2531 if (err < 0)
2532 return err; 2532 return err;
@@ -2536,7 +2536,7 @@ static int restore_mixer_value(struct usb_mixer_elem_info *cval)
2536 } else { 2536 } else {
2537 /* master */ 2537 /* master */
2538 if (cval->cached) { 2538 if (cval->cached) {
2539 err = set_cur_mix_value(cval, 0, 0, *cval->cache_val); 2539 err = snd_usb_set_cur_mix_value(cval, 0, 0, *cval->cache_val);
2540 if (err < 0) 2540 if (err < 0)
2541 return err; 2541 return err;
2542 } 2542 }
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index 7423f998cfb5..2478a844a322 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -76,4 +76,12 @@ int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer);
76int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume); 76int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume);
77#endif 77#endif
78 78
79int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
80 int index, int value);
81
82int snd_usb_get_cur_mix_value(struct usb_mixer_elem_info *cval,
83 int channel, int index, int *value);
84
85extern void snd_usb_mixer_elem_free(struct snd_kcontrol *kctl);
86
79#endif /* __USBMIXER_H */ 87#endif /* __USBMIXER_H */
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 45203168ac6d..b8b1f48c1f50 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -52,13 +52,6 @@ struct std_mono_table {
52 snd_kcontrol_tlv_rw_t *tlv_callback; 52 snd_kcontrol_tlv_rw_t *tlv_callback;
53}; 53};
54 54
55/* private_free callback */
56static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
57{
58 kfree(kctl->private_data);
59 kctl->private_data = NULL;
60}
61
62/* This function allows for the creation of standard UAC controls. 55/* This function allows for the creation of standard UAC controls.
63 * See the quirks for M-Audio FTUs or Ebox-44. 56 * See the quirks for M-Audio FTUs or Ebox-44.
64 * If you don't want to set a TLV callback pass NULL. 57 * If you don't want to set a TLV callback pass NULL.
@@ -108,7 +101,7 @@ static int snd_create_std_mono_ctl_offset(struct usb_mixer_interface *mixer,
108 101
109 /* Set name */ 102 /* Set name */
110 snprintf(kctl->id.name, sizeof(kctl->id.name), name); 103 snprintf(kctl->id.name, sizeof(kctl->id.name), name);
111 kctl->private_free = usb_mixer_elem_free; 104 kctl->private_free = snd_usb_mixer_elem_free;
112 105
113 /* set TLV */ 106 /* set TLV */
114 if (tlv_callback) { 107 if (tlv_callback) {