Commit ef9d5970 authored by Daniel Mack's avatar Daniel Mack Committed by Takashi Iwai

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: default avatarDaniel Mack <zonque@gmail.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 5875c2cb
...@@ -535,20 +535,21 @@ static int check_matrix_bitmap(unsigned char *bmap, int ich, int och, int num_ou ...@@ -535,20 +535,21 @@ static int check_matrix_bitmap(unsigned char *bmap, int ich, int och, int num_ou
* if failed, give up and free the control instance. * if failed, give up and free the control instance.
*/ */
static int add_control_to_empty(struct mixer_build *state, struct snd_kcontrol *kctl) int snd_usb_mixer_add_control(struct usb_mixer_interface *mixer,
struct snd_kcontrol *kctl)
{ {
struct usb_mixer_elem_info *cval = kctl->private_data; struct usb_mixer_elem_info *cval = kctl->private_data;
int err; int err;
while (snd_ctl_find_id(state->chip->card, &kctl->id)) while (snd_ctl_find_id(mixer->chip->card, &kctl->id))
kctl->id.index++; kctl->id.index++;
if ((err = snd_ctl_add(state->chip->card, kctl)) < 0) { if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) {
snd_printd(KERN_ERR "cannot add control (err = %d)\n", err); snd_printd(KERN_ERR "cannot add control (err = %d)\n", err);
return err; return err;
} }
cval->elem_id = &kctl->id; cval->elem_id = &kctl->id;
cval->next_id_elem = state->mixer->id_elems[cval->id]; cval->next_id_elem = mixer->id_elems[cval->id];
state->mixer->id_elems[cval->id] = cval; mixer->id_elems[cval->id] = cval;
return 0; return 0;
} }
...@@ -1176,7 +1177,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, ...@@ -1176,7 +1177,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res); cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res);
add_control_to_empty(state, kctl); snd_usb_mixer_add_control(state->mixer, kctl);
} }
...@@ -1340,7 +1341,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state, ...@@ -1340,7 +1341,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state,
snd_printdd(KERN_INFO "[%d] MU [%s] ch = %d, val = %d/%d\n", snd_printdd(KERN_INFO "[%d] MU [%s] ch = %d, val = %d/%d\n",
cval->id, kctl->id.name, cval->channels, cval->min, cval->max); cval->id, kctl->id.name, cval->channels, cval->min, cval->max);
add_control_to_empty(state, kctl); snd_usb_mixer_add_control(state->mixer, kctl);
} }
...@@ -1641,7 +1642,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw ...@@ -1641,7 +1642,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw
snd_printdd(KERN_INFO "[%d] PU [%s] ch = %d, val = %d/%d\n", snd_printdd(KERN_INFO "[%d] PU [%s] ch = %d, val = %d/%d\n",
cval->id, kctl->id.name, cval->channels, cval->min, cval->max); cval->id, kctl->id.name, cval->channels, cval->min, cval->max);
if ((err = add_control_to_empty(state, kctl)) < 0) if ((err = snd_usb_mixer_add_control(state->mixer, kctl)) < 0)
return err; return err;
} }
return 0; return 0;
...@@ -1858,7 +1859,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void ...@@ -1858,7 +1859,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void
snd_printdd(KERN_INFO "[%d] SU [%s] items = %d\n", snd_printdd(KERN_INFO "[%d] SU [%s] items = %d\n",
cval->id, kctl->id.name, desc->bNrInPins); cval->id, kctl->id.name, desc->bNrInPins);
if ((err = add_control_to_empty(state, kctl)) < 0) if ((err = snd_usb_mixer_add_control(state->mixer, kctl)) < 0)
return err; return err;
return 0; return 0;
......
...@@ -55,4 +55,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, ...@@ -55,4 +55,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer); void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer);
int snd_usb_mixer_activate(struct usb_mixer_interface *mixer); int snd_usb_mixer_activate(struct usb_mixer_interface *mixer);
int snd_usb_mixer_add_control(struct usb_mixer_interface *mixer,
struct snd_kcontrol *kctl);
#endif /* __USBMIXER_H */ #endif /* __USBMIXER_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment