aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2011-05-25 03:09:00 -0400
committerTakashi Iwai <tiwai@suse.de>2011-05-25 03:34:34 -0400
commitef9d59708949b2012b1b723a1eaec82981c40013 (patch)
tree49827ad76ad2cf84933d295ef1df9520dfdb911b
parent5875c2cb7633ca280c2ece43389d6a6f3c00e951 (diff)
ALSA: usb-audio: rework add_control_to_empty()
This patch renames add_control_to_empty() to snd_usb_mixer_add_control() and exports it, so the quirks functions can make use of it. Also, as "struct mixer_build" is private to mixer.c, rewrite the function to take an argument of type "struct usb_mixer_interface" instead. Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/usb/mixer.c19
-rw-r--r--sound/usb/mixer.h3
2 files changed, 13 insertions, 9 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index eab06edcc9b7..ba19bfdfdc9e 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -535,20 +535,21 @@ static int check_matrix_bitmap(unsigned char *bmap, int ich, int och, int num_ou
535 * if failed, give up and free the control instance. 535 * if failed, give up and free the control instance.
536 */ 536 */
537 537
538static int add_control_to_empty(struct mixer_build *state, struct snd_kcontrol *kctl) 538int snd_usb_mixer_add_control(struct usb_mixer_interface *mixer,
539 struct snd_kcontrol *kctl)
539{ 540{
540 struct usb_mixer_elem_info *cval = kctl->private_data; 541 struct usb_mixer_elem_info *cval = kctl->private_data;
541 int err; 542 int err;
542 543
543 while (snd_ctl_find_id(state->chip->card, &kctl->id)) 544 while (snd_ctl_find_id(mixer->chip->card, &kctl->id))
544 kctl->id.index++; 545 kctl->id.index++;
545 if ((err = snd_ctl_add(state->chip->card, kctl)) < 0) { 546 if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) {
546 snd_printd(KERN_ERR "cannot add control (err = %d)\n", err); 547 snd_printd(KERN_ERR "cannot add control (err = %d)\n", err);
547 return err; 548 return err;
548 } 549 }
549 cval->elem_id = &kctl->id; 550 cval->elem_id = &kctl->id;
550 cval->next_id_elem = state->mixer->id_elems[cval->id]; 551 cval->next_id_elem = mixer->id_elems[cval->id];
551 state->mixer->id_elems[cval->id] = cval; 552 mixer->id_elems[cval->id] = cval;
552 return 0; 553 return 0;
553} 554}
554 555
@@ -1176,7 +1177,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1176 1177
1177 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", 1178 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
1178 cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res); 1179 cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res);
1179 add_control_to_empty(state, kctl); 1180 snd_usb_mixer_add_control(state->mixer, kctl);
1180} 1181}
1181 1182
1182 1183
@@ -1340,7 +1341,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state,
1340 1341
1341 snd_printdd(KERN_INFO "[%d] MU [%s] ch = %d, val = %d/%d\n", 1342 snd_printdd(KERN_INFO "[%d] MU [%s] ch = %d, val = %d/%d\n",
1342 cval->id, kctl->id.name, cval->channels, cval->min, cval->max); 1343 cval->id, kctl->id.name, cval->channels, cval->min, cval->max);
1343 add_control_to_empty(state, kctl); 1344 snd_usb_mixer_add_control(state->mixer, kctl);
1344} 1345}
1345 1346
1346 1347
@@ -1641,7 +1642,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw
1641 1642
1642 snd_printdd(KERN_INFO "[%d] PU [%s] ch = %d, val = %d/%d\n", 1643 snd_printdd(KERN_INFO "[%d] PU [%s] ch = %d, val = %d/%d\n",
1643 cval->id, kctl->id.name, cval->channels, cval->min, cval->max); 1644 cval->id, kctl->id.name, cval->channels, cval->min, cval->max);
1644 if ((err = add_control_to_empty(state, kctl)) < 0) 1645 if ((err = snd_usb_mixer_add_control(state->mixer, kctl)) < 0)
1645 return err; 1646 return err;
1646 } 1647 }
1647 return 0; 1648 return 0;
@@ -1858,7 +1859,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void
1858 1859
1859 snd_printdd(KERN_INFO "[%d] SU [%s] items = %d\n", 1860 snd_printdd(KERN_INFO "[%d] SU [%s] items = %d\n",
1860 cval->id, kctl->id.name, desc->bNrInPins); 1861 cval->id, kctl->id.name, desc->bNrInPins);
1861 if ((err = add_control_to_empty(state, kctl)) < 0) 1862 if ((err = snd_usb_mixer_add_control(state->mixer, kctl)) < 0)
1862 return err; 1863 return err;
1863 1864
1864 return 0; 1865 return 0;
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index b4a2c8165e4b..459551ac53ae 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -55,4 +55,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
55void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer); 55void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer);
56int snd_usb_mixer_activate(struct usb_mixer_interface *mixer); 56int snd_usb_mixer_activate(struct usb_mixer_interface *mixer);
57 57
58int snd_usb_mixer_add_control(struct usb_mixer_interface *mixer,
59 struct snd_kcontrol *kctl);
60
58#endif /* __USBMIXER_H */ 61#endif /* __USBMIXER_H */