aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Sanjuan <jorge.sanjuan@codethink.co.uk>2018-06-14 10:05:56 -0400
committerTakashi Iwai <tiwai@suse.de>2018-06-14 12:03:35 -0400
commit167e1fb1218d0526e65f2dd00b62ed08866dcfff (patch)
tree555111bb18070bedd83b699bb156e0f977d69072
parent2dd5aa15d9a2d4b87b32d93f3c5a66f175c0123d (diff)
ALSA: usb-audio: Change in connectors control creation interface
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 <jorge.sanjuan@codethink.co.uk> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/usb/mixer.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 898afd3001ea..34fef71e0330 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1653,11 +1653,11 @@ static void build_feature_ctl_badd(struct usb_mixer_interface *mixer,
1653 NULL, NULL, unitid, 0, 0); 1653 NULL, NULL, unitid, 0, 0);
1654} 1654}
1655 1655
1656static void get_connector_control_name(struct mixer_build *state, 1656static void get_connector_control_name(struct usb_mixer_interface *mixer,
1657 struct usb_audio_term *term, 1657 struct usb_audio_term *term,
1658 bool is_input, char *name, int name_size) 1658 bool is_input, char *name, int name_size)
1659{ 1659{
1660 int name_len = get_term_name(state->chip, term, name, name_size, 0); 1660 int name_len = get_term_name(mixer->chip, term, name, name_size, 0);
1661 1661
1662 if (name_len == 0) 1662 if (name_len == 0)
1663 strlcpy(name, "Unknown", name_size); 1663 strlcpy(name, "Unknown", name_size);
@@ -1674,7 +1674,7 @@ static void get_connector_control_name(struct mixer_build *state,
1674} 1674}
1675 1675
1676/* Build a mixer control for a UAC connector control (jack-detect) */ 1676/* Build a mixer control for a UAC connector control (jack-detect) */
1677static void build_connector_control(struct mixer_build *state, 1677static void build_connector_control(struct usb_mixer_interface *mixer,
1678 struct usb_audio_term *term, bool is_input) 1678 struct usb_audio_term *term, bool is_input)
1679{ 1679{
1680 struct snd_kcontrol *kctl; 1680 struct snd_kcontrol *kctl;
@@ -1683,7 +1683,7 @@ static void build_connector_control(struct mixer_build *state,
1683 cval = kzalloc(sizeof(*cval), GFP_KERNEL); 1683 cval = kzalloc(sizeof(*cval), GFP_KERNEL);
1684 if (!cval) 1684 if (!cval)
1685 return; 1685 return;
1686 snd_usb_mixer_elem_init_std(&cval->head, state->mixer, term->id); 1686 snd_usb_mixer_elem_init_std(&cval->head, mixer, term->id);
1687 /* 1687 /*
1688 * UAC2: The first byte from reading the UAC2_TE_CONNECTOR control returns the 1688 * UAC2: The first byte from reading the UAC2_TE_CONNECTOR control returns the
1689 * number of channels connected. 1689 * number of channels connected.
@@ -1694,7 +1694,7 @@ static void build_connector_control(struct mixer_build *state,
1694 * This boolean ctl will simply report if any channels are connected 1694 * This boolean ctl will simply report if any channels are connected
1695 * or not. 1695 * or not.
1696 */ 1696 */
1697 if (state->mixer->protocol == UAC_VERSION_2) 1697 if (mixer->protocol == UAC_VERSION_2)
1698 cval->control = UAC2_TE_CONNECTOR; 1698 cval->control = UAC2_TE_CONNECTOR;
1699 else /* UAC_VERSION_3 */ 1699 else /* UAC_VERSION_3 */
1700 cval->control = UAC3_TE_INSERTION; 1700 cval->control = UAC3_TE_INSERTION;
@@ -1705,11 +1705,11 @@ static void build_connector_control(struct mixer_build *state,
1705 cval->max = 1; 1705 cval->max = 1;
1706 kctl = snd_ctl_new1(&usb_connector_ctl_ro, cval); 1706 kctl = snd_ctl_new1(&usb_connector_ctl_ro, cval);
1707 if (!kctl) { 1707 if (!kctl) {
1708 usb_audio_err(state->chip, "cannot malloc kcontrol\n"); 1708 usb_audio_err(mixer->chip, "cannot malloc kcontrol\n");
1709 kfree(cval); 1709 kfree(cval);
1710 return; 1710 return;
1711 } 1711 }
1712 get_connector_control_name(state, term, is_input, kctl->id.name, 1712 get_connector_control_name(mixer, term, is_input, kctl->id.name,
1713 sizeof(kctl->id.name)); 1713 sizeof(kctl->id.name));
1714 kctl->private_free = snd_usb_mixer_elem_free; 1714 kctl->private_free = snd_usb_mixer_elem_free;
1715 snd_usb_mixer_add_control(&cval->head, kctl); 1715 snd_usb_mixer_add_control(&cval->head, kctl);
@@ -2042,7 +2042,7 @@ static int parse_audio_input_terminal(struct mixer_build *state, int unitid,
2042 2042
2043 /* Check for jack detection. */ 2043 /* Check for jack detection. */
2044 if (uac_v2v3_control_is_readable(bmctls, control)) 2044 if (uac_v2v3_control_is_readable(bmctls, control))
2045 build_connector_control(state, &iterm, true); 2045 build_connector_control(state->mixer, &iterm, true);
2046 2046
2047 return 0; 2047 return 0;
2048} 2048}
@@ -2990,7 +2990,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
2990 2990
2991 if (uac_v2v3_control_is_readable(le16_to_cpu(desc->bmControls), 2991 if (uac_v2v3_control_is_readable(le16_to_cpu(desc->bmControls),
2992 UAC2_TE_CONNECTOR)) { 2992 UAC2_TE_CONNECTOR)) {
2993 build_connector_control(&state, &state.oterm, 2993 build_connector_control(state.mixer, &state.oterm,
2994 false); 2994 false);
2995 } 2995 }
2996 } else { /* UAC_VERSION_3 */ 2996 } else { /* UAC_VERSION_3 */
@@ -3017,7 +3017,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
3017 3017
3018 if (uac_v2v3_control_is_readable(le32_to_cpu(desc->bmControls), 3018 if (uac_v2v3_control_is_readable(le32_to_cpu(desc->bmControls),
3019 UAC3_TE_INSERTION)) { 3019 UAC3_TE_INSERTION)) {
3020 build_connector_control(&state, &state.oterm, 3020 build_connector_control(state.mixer, &state.oterm,
3021 false); 3021 false);
3022 } 3022 }
3023 } 3023 }