Skip to content

Commit

Permalink
ALSA: usb-audio: Change in connectors control creation interface
Browse files Browse the repository at this point in the history
Change build_connector_control() and get_connector_control_name()
so they take `struct usb_mixer_interface` as input argument instead
of `struct mixer_build`.

This is preliminary work to add support for connectors control
for UAC3 BADD devices. No functional change.

Signed-off-by: Jorge Sanjuan <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
Jorge Sanjuan authored and tiwai committed Jun 14, 2018
1 parent 2dd5aa1 commit 167e1fb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sound/usb/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1653,11 +1653,11 @@ static void build_feature_ctl_badd(struct usb_mixer_interface *mixer,
NULL, NULL, unitid, 0, 0);
}

static void get_connector_control_name(struct mixer_build *state,
static void get_connector_control_name(struct usb_mixer_interface *mixer,
struct usb_audio_term *term,
bool is_input, char *name, int name_size)
{
int name_len = get_term_name(state->chip, term, name, name_size, 0);
int name_len = get_term_name(mixer->chip, term, name, name_size, 0);

if (name_len == 0)
strlcpy(name, "Unknown", name_size);
Expand All @@ -1674,7 +1674,7 @@ static void get_connector_control_name(struct mixer_build *state,
}

/* Build a mixer control for a UAC connector control (jack-detect) */
static void build_connector_control(struct mixer_build *state,
static void build_connector_control(struct usb_mixer_interface *mixer,
struct usb_audio_term *term, bool is_input)
{
struct snd_kcontrol *kctl;
Expand All @@ -1683,7 +1683,7 @@ static void build_connector_control(struct mixer_build *state,
cval = kzalloc(sizeof(*cval), GFP_KERNEL);
if (!cval)
return;
snd_usb_mixer_elem_init_std(&cval->head, state->mixer, term->id);
snd_usb_mixer_elem_init_std(&cval->head, mixer, term->id);
/*
* UAC2: The first byte from reading the UAC2_TE_CONNECTOR control returns the
* number of channels connected.
Expand All @@ -1694,7 +1694,7 @@ static void build_connector_control(struct mixer_build *state,
* This boolean ctl will simply report if any channels are connected
* or not.
*/
if (state->mixer->protocol == UAC_VERSION_2)
if (mixer->protocol == UAC_VERSION_2)
cval->control = UAC2_TE_CONNECTOR;
else /* UAC_VERSION_3 */
cval->control = UAC3_TE_INSERTION;
Expand All @@ -1705,11 +1705,11 @@ static void build_connector_control(struct mixer_build *state,
cval->max = 1;
kctl = snd_ctl_new1(&usb_connector_ctl_ro, cval);
if (!kctl) {
usb_audio_err(state->chip, "cannot malloc kcontrol\n");
usb_audio_err(mixer->chip, "cannot malloc kcontrol\n");
kfree(cval);
return;
}
get_connector_control_name(state, term, is_input, kctl->id.name,
get_connector_control_name(mixer, term, is_input, kctl->id.name,
sizeof(kctl->id.name));
kctl->private_free = snd_usb_mixer_elem_free;
snd_usb_mixer_add_control(&cval->head, kctl);
Expand Down Expand Up @@ -2042,7 +2042,7 @@ static int parse_audio_input_terminal(struct mixer_build *state, int unitid,

/* Check for jack detection. */
if (uac_v2v3_control_is_readable(bmctls, control))
build_connector_control(state, &iterm, true);
build_connector_control(state->mixer, &iterm, true);

return 0;
}
Expand Down Expand Up @@ -2990,7 +2990,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)

if (uac_v2v3_control_is_readable(le16_to_cpu(desc->bmControls),
UAC2_TE_CONNECTOR)) {
build_connector_control(&state, &state.oterm,
build_connector_control(state.mixer, &state.oterm,
false);
}
} else { /* UAC_VERSION_3 */
Expand All @@ -3017,7 +3017,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)

if (uac_v2v3_control_is_readable(le32_to_cpu(desc->bmControls),
UAC3_TE_INSERTION)) {
build_connector_control(&state, &state.oterm,
build_connector_control(state.mixer, &state.oterm,
false);
}
}
Expand Down

0 comments on commit 167e1fb

Please sign in to comment.