From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C046FC433E1 for ; Sat, 22 Aug 2020 16:06:37 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2691B20738 for ; Sat, 22 Aug 2020 16:06:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Uv0oUJ3C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2691B20738 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8818784C; Sat, 22 Aug 2020 18:05:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8818784C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598112395; bh=xZlHkXSbwdAMEhdvlXRd18CW+x50ktcR6HkzvDrSbq8=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Uv0oUJ3CLjLZBjZIspL35dNyc6U/jAL2/NHThHVtOXqFxwcvJEinefy7JDsAE6pEc TkO9Dj0O6IBs8T1aS0eb1zpH0fMEXOI24Q+fw/EymhS4GdkbCo3/V0cYziKESYG3Du 3urGae6m6CYHQ+xPML3Zf/Dh/qFsYvvTkWeCLEvU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C7149F801ED; Sat, 22 Aug 2020 18:05:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9076CF801F9; Sat, 22 Aug 2020 18:05:42 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A7F56F800C0 for ; Sat, 22 Aug 2020 18:05:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A7F56F800C0 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8591BB71D; Sat, 22 Aug 2020 16:05:58 +0000 (UTC) Date: Sat, 22 Aug 2020 18:05:29 +0200 Message-ID: From: Takashi Iwai To: Alexander Tsoy Subject: Re: [PATCH 3/3] ALSA: usb-audio: Properly match with audio interface class In-Reply-To: <213664da6ebb6bf7f1382a93676f087236da412a.camel@tsoy.me> References: <20200817082140.20232-1-tiwai@suse.de> <20200817082140.20232-4-tiwai@suse.de> <213664da6ebb6bf7f1382a93676f087236da412a.camel@tsoy.me> 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=UTF-8 Content-Transfer-Encoding: 8bit Cc: alsa-devel@alsa-project.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Sat, 22 Aug 2020 17:27:35 +0200, Alexander Tsoy wrote: > > В Пн, 17/08/2020 в 10:21 +0200, Takashi Iwai пишет: > > There are a few entries in the quirk table that set the device ID > > with > > USB_DEVICE() macro while having an extra bInterfaceClass field. But > > bInterfaceClass field is never checked unless the proper match_flags > > is set, so those may match incorrectly with all interfaces. > > > > Introduce another macro to match with the vid/pid pair and the audio > > class interface, and apply it to such entries, so that they can match > > properly. > > > > Signed-off-by: Takashi Iwai > > --- > > sound/usb/quirks-table.h | 55 +++++++++++++++++--------------------- > > ---------- > > 1 file changed, 19 insertions(+), 36 deletions(-) > > > > diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h > > index 988bb9d00192..7a80ef31bbe4 100644 > > --- a/sound/usb/quirks-table.h > > +++ b/sound/usb/quirks-table.h > > @@ -35,6 +35,14 @@ > > .bInterfaceClass = USB_CLASS_AUDIO, \ > > .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL > > > > +/* Another standard entry matching with vid/pid and the audio class > > */ > > +#define USB_AUDIO_CLASS(vend, prod) \ > > + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ > > + USB_DEVICE_ID_MATCH_INT_CLASS, \ > > + .idVendor = vend, \ > > + .idProduct = prod, \ > > + .bInterfaceClass = USB_CLASS_AUDIO > > + > > /* FTDI devices */ > > { > > USB_DEVICE(0x0403, 0xb8d8), > > @@ -68,34 +76,14 @@ > > } > > }, > > > > -{ > > - /* E-Mu 0202 USB */ > > - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, > > - .idVendor = 0x041e, > > - .idProduct = 0x3f02, > > - .bInterfaceClass = USB_CLASS_AUDIO, > > -}, > > -{ > > - /* E-Mu 0404 USB */ > > - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, > > - .idVendor = 0x041e, > > - .idProduct = 0x3f04, > > - .bInterfaceClass = USB_CLASS_AUDIO, > > -}, > > -{ > > - /* E-Mu Tracker Pre */ > > - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, > > - .idVendor = 0x041e, > > - .idProduct = 0x3f0a, > > - .bInterfaceClass = USB_CLASS_AUDIO, > > -}, > > -{ > > - /* E-Mu 0204 USB */ > > - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, > > - .idVendor = 0x041e, > > - .idProduct = 0x3f19, > > - .bInterfaceClass = USB_CLASS_AUDIO, > > -}, > > +/* E-Mu 0202 USB */ > > +{ USB_AUDIO_CLASS(0x041e, 0x3f02) }, > > +/* E-Mu 0404 USB */ > > +{ USB_AUDIO_CLASS(0x041e, 0x3f04) }, > > +/* E-Mu Tracker Pre */ > > +{ USB_AUDIO_CLASS(0x041e, 0x3f0a) }, > > +/* E-Mu 0204 USB */ > > +{ USB_AUDIO_CLASS(0x041e, 0x3f19) }, > > > > /* > > * HP Wireless Audio > > @@ -2751,10 +2739,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), > > }, > > > > /* KeithMcMillen Stringport */ > > -{ > > - USB_DEVICE(0x1f38, 0x0001), > > - .bInterfaceClass = USB_CLASS_AUDIO, > > -}, > > +{ USB_AUDIO_CLASS(0x1f38, 0x0001) }, > > > > /* Miditech devices */ > > { > > @@ -2977,10 +2962,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", > > "HVR-950Q"), > > }, > > { > > /* Tascam US122 MKII - playback-only support */ > > - .match_flags = USB_DEVICE_ID_MATCH_DEVICE, > > - .idVendor = 0x0644, > > - .idProduct = 0x8021, > > - .bInterfaceClass = USB_CLASS_AUDIO, > > + USB_AUDIO_CLASS(0x0644, 0x8021), > > .driver_info = (unsigned long) &(const struct > > snd_usb_audio_quirk) { > > .vendor_name = "TASCAM", > > .product_name = "US122 MKII", > > @@ -3612,3 +3594,4 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", > > "HVR-950Q"), > > > > #undef USB_DEVICE_VENDOR_SPEC > > #undef USB_AUDIO_DEVICE > > +#undef USB_AUDIO_CLASS > > I don't know anything about KeithMcMillen Stringport, but all other > devices (US122 MKII and E-mu) seems to have Vendor-specific Class. OK, then it must be with USB_DEVICE_VENDOR_SPEC macro instead although they had .bInterfaceClass = USB_CLASS_AUDIO line wrongly. Could you submit the correction patch, or shall I fix in my side? > And > since the driver should already match all compliant devices, the only > potentional use for USB_AUDIO_CLASS macro is for devices > with bInterfaceClass = USB_CLASS_AUDIO and with some invalid > bInterfaceSubClass. The problem is that without the class match in addition to the device id match, it would match too eagerly, e.g. if a USB device defines multiple different classes with the same device id like HID and video. So we should restrict the matching as much as possible. thanks, Takashi