Merge tag 'sound-fix-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Jun 2018 08:24:40 +0000 (17:24 +0900)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Jun 2018 08:24:40 +0000 (17:24 +0900)
Pull sound fixes from Takashi Iwai:
 "Here is a collection of small fixes on top of the previous update.

  All small and obvious fixes. Mostly for usual suspects, USB-audio and
  HD-audio, but a few trivial error handling fixes for misc drivers as
  well"

* tag 'sound-fix-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
  ALSA: usb-audio: Always create the interrupt pipe for the mixer
  ALSA: usb-audio: Add insertion control for UAC3 BADD
  ALSA: usb-audio: Change in connectors control creation interface
  ALSA: usb-audio: Add bi-directional terminal types
  ALSA: lx6464es: add error handling for pci_ioremap_bar
  ALSA: sonicvibes: add error handling for snd_ctl_add
  ALSA: usb-audio: Remove explicitly listed Mytek devices
  ALSA: usb-audio: Generic DSD detection for XMOS-based implementations
  ALSA: usb-audio: Add native DSD support for Mytek DACs
  ALSA: hda/realtek - Add shutup hint
  ALSA: usb-audio: Disable the quirk for Nura headset
  ALSA: hda: add dock and led support for HP ProBook 640 G4
  ALSA: hda: add dock and led support for HP EliteBook 830 G5
  ALSA: emu10k1: add error handling for snd_ctl_add
  ALSA: fm801: add error handling for snd_ctl_add

1  2 
sound/usb/format.c
sound/usb/mixer.c

diff --combined sound/usb/format.c
index 1f7a74a77ea34f6c7f86dc5259e716d5bd09e8f7,0a2a27f2854d169a09ea658930917435e0f97836..fd13ac11b13674e1c06500f7ab3eef151b1226e2
@@@ -64,8 -64,11 +64,11 @@@ static u64 parse_audio_format_i_type(st
                sample_width = fmt->bBitResolution;
                sample_bytes = fmt->bSubslotSize;
  
-               if (format & UAC2_FORMAT_TYPE_I_RAW_DATA)
+               if (format & UAC2_FORMAT_TYPE_I_RAW_DATA) {
                        pcm_formats |= SNDRV_PCM_FMTBIT_SPECIAL;
+                       /* flag potentially raw DSD capable altsettings */
+                       fp->dsd_raw = true;
+               }
  
                format <<= 1;
                break;
@@@ -188,8 -191,7 +191,8 @@@ static int parse_audio_format_rates_v1(
                 */
                int r, idx;
  
 -              fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
 +              fp->rate_table = kmalloc_array(nr_rates, sizeof(int),
 +                                             GFP_KERNEL);
                if (fp->rate_table == NULL)
                        return -ENOMEM;
  
@@@ -363,7 -365,7 +366,7 @@@ static int parse_audio_format_rates_v2v
                goto err_free;
        }
  
 -      fp->rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL);
 +      fp->rate_table = kmalloc_array(fp->nr_rates, sizeof(int), GFP_KERNEL);
        if (!fp->rate_table) {
                ret = -ENOMEM;
                goto err_free;
diff --combined sound/usb/mixer.c
index 8c3568d8d03bab132e5399fccd7cba184c81ed2a,b1dcf6dfc27e07469de6498836358eb8a6640bcb..ca963e94ec03ca261fe271577c0568b7832c84fb
@@@ -1653,11 -1653,11 +1653,11 @@@ static void build_feature_ctl_badd(stru
                        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);
  }
  
  /* 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;
        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.
         * 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;
        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);
@@@ -2042,7 -2042,7 +2042,7 @@@ static int parse_audio_input_terminal(s
  
        /* 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;
  }
@@@ -2515,7 -2515,7 +2515,7 @@@ static int parse_audio_selector_unit(st
                cval->control = (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) ?
                        UAC2_CX_CLOCK_SELECTOR : UAC2_SU_SELECTOR;
  
 -      namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL);
 +      namelist = kmalloc_array(desc->bNrInPins, sizeof(char *), GFP_KERNEL);
        if (!namelist) {
                kfree(cval);
                return -ENOMEM;
@@@ -2918,6 -2918,23 +2918,23 @@@ static int snd_usb_mixer_controls_badd(
                                       UAC3_BADD_FU_ID7, map->map);
        }
  
+       /* Insertion Control */
+       if (f->subclass == UAC3_FUNCTION_SUBCLASS_HEADSET_ADAPTER) {
+               struct usb_audio_term iterm, oterm;
+               /* Input Term - Insertion control */
+               memset(&iterm, 0, sizeof(iterm));
+               iterm.id = UAC3_BADD_IT_ID4;
+               iterm.type = UAC_BIDIR_TERMINAL_HEADSET;
+               build_connector_control(mixer, &iterm, true);
+               /* Output Term - Insertion control */
+               memset(&oterm, 0, sizeof(oterm));
+               oterm.id = UAC3_BADD_OT_ID3;
+               oterm.type = UAC_BIDIR_TERMINAL_HEADSET;
+               build_connector_control(mixer, &oterm, false);
+       }
        return 0;
  }
  
@@@ -2990,7 -3007,7 +3007,7 @@@ static int snd_usb_mixer_controls(struc
  
                        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 */
  
                        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);
                        }
                }
@@@ -3321,10 -3338,12 +3338,12 @@@ int snd_usb_create_mixer(struct snd_usb
                err = snd_usb_mixer_controls(mixer);
                if (err < 0)
                        goto _error;
-               err = snd_usb_mixer_status_create(mixer);
-               if (err < 0)
-                       goto _error;
        }
+       err = snd_usb_mixer_status_create(mixer);
+       if (err < 0)
+               goto _error;
        err = create_keep_iface_ctl(mixer);
        if (err < 0)
                goto _error;