Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2178153pxb; Tue, 12 Oct 2021 00:37:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlLxS5BQ/Tfc8T9efPwPSq5DWoFBZXrSEqSpAveVFeRSdqiCPtNWfUEBXHK28sjjgbioMU X-Received: by 2002:a17:90a:3ec2:: with SMTP id k60mr4244697pjc.176.1634024253140; Tue, 12 Oct 2021 00:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634024253; cv=none; d=google.com; s=arc-20160816; b=hz0W+wHCTjysWypUOuk7sVOeFCJcqp5/PQCYvAbOcgBcmO7sDG9Y6Brpt0uqVWqQfe z2O68tI9eH/5FHWbXV/J7FiNIeFqvxbGBBxyHMw+hblI4iYL2m96V7DUXQu2CSff3Pjw qu9PjsV+uNZ2CqaUYUqwiztQkh7jIlGqnZg05OWbmRutUqGXzsS2KN4P465/DPv1f84J BAimqOV2/OyyAPe9p9q0GqIAxFwiYrwlZZ84kMTGGzAlxe9uWdDTBQxldqsxibrB/x5I TwFtCk4oN7TkHdOEM7MjQvP9F/SthhMF/TwmWyfOBGQCbz4B7BjV9QwlPGYnEf67cTRG sXIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=tFCztFG0NMzu9QUaokuXv6oskYuEM7OIjk8q5b1QKmM=; b=pBEiELyk5OERi5fOQ82+R51/g91uwks20TDbDeoWWTtUhYIwE7rrnlLVLnFe+w07N3 dea+LAhJHopCaC661xvrtmTW7WCG1x4A0wVYrkuE6+G5RdjN100QoLS+r4F2vUoCED9a RlWvtpKVy+sK56V2l0SSQAx1RAwkxzy5MA+7QYrIB0tnpqk8/13XTQxnCbQyKpoJhIdQ ZyIFtyDBtzEnzpfzEsDV1Ru/qAJwfgLbUECfwBs9MnQnKVGxrmadwsq8+YXZinKYBKEP kRSh98hu9EOftKZhUJiSHvcsglywloBjgmu5i3xPngDZIZjZ9wu5mzxe1ZP1IoK4WF1G Rc0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=deeaLoY1; dkim=neutral (no key) header.i=@suse.de header.b=pWxtcK1r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n5si15469542plh.278.2021.10.12.00.37.19; Tue, 12 Oct 2021 00:37:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=deeaLoY1; dkim=neutral (no key) header.i=@suse.de header.b=pWxtcK1r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234143AbhJLHhW (ORCPT + 99 others); Tue, 12 Oct 2021 03:37:22 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:40328 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232565AbhJLHhS (ORCPT ); Tue, 12 Oct 2021 03:37:18 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4340E1FF2A; Tue, 12 Oct 2021 07:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1634024116; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tFCztFG0NMzu9QUaokuXv6oskYuEM7OIjk8q5b1QKmM=; b=deeaLoY1E/z/wmhY6SlfmEIF79usbAz4JOh5UwnEucv0H4S8GxDZ0J+G8/mDfdBDBnH4nb B7VuSU3ockDrWm0Qjwl9socQVto0y7+n425ClOdEUvLQ+LaudFysMUkuKU+yPqR22vMLB2 KgnYO8EAKvksmVySp0tiKjm5EjhePOI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1634024116; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tFCztFG0NMzu9QUaokuXv6oskYuEM7OIjk8q5b1QKmM=; b=pWxtcK1rtSj4CMlAUVXexNrniQrKjYQIRCMWjUI4gUu+v0JSjHwjW0Njekh5TCIjDcV5Id 8+z6aZtjtwybCpAw== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 27E0EA3B85; Tue, 12 Oct 2021 07:35:16 +0000 (UTC) Date: Tue, 12 Oct 2021 09:35:16 +0200 Message-ID: From: Takashi Iwai To: Greg Kroah-Hartman Cc: Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: usb-audio: allow -EPIPE errors for some v2 messages In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Oct 2021 19:23:05 +0200, Greg Kroah-Hartman wrote: > > On Mon, Oct 11, 2021 at 06:07:01PM +0200, Takashi Iwai wrote: > > Could you also post the contents of /proc/asound/card*/usbmixer (only > > for the corresponding device), too? > > Sure, here it is: > > USB Mixer: usb_id=0x30be0101, ctrlif=0, ctlerr=0 > Card: Schiit Audio Schiit Hel at usb-0000:47:00.1-2.2, high speed > Unit: 5 > Control: name="Mic - Input Jack", index=0 > Info: id=5, control=2, cmask=0x0, channels=1, type="BOOLEAN" > Volume: min=0, max=1, dBmin=0, dBmax=0 > Unit: 7 > Control: name="Speaker - Output Jack", index=0 > Info: id=7, control=2, cmask=0x0, channels=1, type="BOOLEAN" > Volume: min=0, max=1, dBmin=0, dBmax=0 > Unit: 13 > Control: name="PCM Playback Switch", index=0 > Info: id=13, control=1, cmask=0x0, channels=1, type="INV_BOOLEAN" > Volume: min=0, max=1, dBmin=0, dBmax=0 > Unit: 17 > Control: name="Mic Capture Switch", index=0 > Info: id=17, control=1, cmask=0x0, channels=1, type="INV_BOOLEAN" > Volume: min=0, max=1, dBmin=0, dBmax=0 > Unit: 18 > Control: name="Clock Source 18 Validity", index=0 > Info: id=18, control=2, cmask=0x0, channels=1, type="BOOLEAN" > Volume: min=0, max=1, dBmin=0, dBmax=0 > Unit: 22 > Control: name="Clock Source 22 Validity", index=0 > Info: id=22, control=2, cmask=0x0, channels=1, type="BOOLEAN" > Volume: min=0, max=1, dBmin=0, dBmax=0 Hm, I expected more exotic control that failed, but it was Mic Capture Switch, which should be treated normally. Could you try the patch below? This will still show other warning messages, but it'll forcibly initialize the mixer elements at probe time, and the rest should work. Once after it's confirmed to work, we may shut up the device warnings with a quirk. thanks, Takashi --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -361,9 +361,8 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, memset(buf, 0, sizeof(buf)); - ret = snd_usb_lock_shutdown(chip) ? -EIO : 0; - if (ret) - goto error; + if (snd_usb_lock_shutdown(chip)) + return -EIO; idx = mixer_ctrl_intf(cval->head.mixer) | (cval->head.id << 8); ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest, @@ -372,8 +371,7 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, snd_usb_unlock_shutdown(chip); if (ret < 0) { -error: - usb_audio_err(chip, + usb_audio_dbg(chip, "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", request, validx, idx, cval->val_type); return ret; @@ -1201,12 +1199,32 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval, } } +/* forcibly initialize the current mixer value; if GET_CUR fails, set to + * the minimum as default + */ +static void init_cur_mix_raw(struct usb_mixer_elem_info *cval, int ch, int idx) +{ + int val, err; + + err = snd_usb_get_cur_mix_value(cval, ch, idx, &val); + if (!err) + return; + if (!cval->head.mixer->ignore_ctl_error) + usb_audio_warn(cval->head.mixer->chip, + "%d:%d: failed to get current value for ch %d (%d)\n", + cval->head.id, mixer_ctrl_intf(cval->head.mixer), + ch, err); + snd_usb_set_cur_mix_value(cval, ch, idx, cval->min); +} + /* * retrieve the minimum and maximum values for the specified control */ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval, int default_min, struct snd_kcontrol *kctl) { + int i, idx; + /* for failsafe */ cval->min = default_min; cval->max = cval->min + 1; @@ -1219,7 +1237,6 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval, } else { int minchn = 0; if (cval->cmask) { - int i; for (i = 0; i < MAX_CHANNELS; i++) if (cval->cmask & (1 << i)) { minchn = i + 1; @@ -1320,6 +1337,19 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval, } } + /* initialize all elements */ + if (!cval->cmask) { + init_cur_mix_raw(cval, 0, 0); + } else { + idx = 0; + for (i = 0; i < MAX_CHANNELS; i++) { + if (cval->cmask & (1 << i)) { + init_cur_mix_raw(cval, i + 1, idx); + idx++; + } + } + } + return 0; }