From patchwork Sun Jan 12 10:05:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Tsoy X-Patchwork-Id: 193893 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=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT 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 9AEC3C32771 for ; Sun, 12 Jan 2020 10:06:39 +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 D78F2222D9 for ; Sun, 12 Jan 2020 10: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="qNgZFirv"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=tsoy.me header.i=@tsoy.me header.b="Tjv6Y002" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D78F2222D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=tsoy.me 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 8860D166E; Sun, 12 Jan 2020 11:05:45 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8860D166E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1578823595; bh=XjX44ETR78pMdnW9NR1iJKLXuMWEeplS6cfr47eszjY=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=qNgZFirvFxxC7XsOvtLeU/e2DEGiJgB0BDDZyD7/pzkxsuggIMsEvWDEBVrJO/5dc NZNVl+8qRYefO1lLb0DjVnT9CZmj3KGzQZuTjf+vElUiX7+IrsAZO9vu0C2WRWdrK/ 9YMjsosgKebGEhPuI9BMXduc+wea2zUH7J9KhHlo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E3E62F8014D; Sun, 12 Jan 2020 11:05:44 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9E9B5F8014E; Sun, 12 Jan 2020 11:05:42 +0100 (CET) Received: from puleglot.ru (puleglot.ru [IPv6:2a01:4f8:1c0c:58e8::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D54C9F80103 for ; Sun, 12 Jan 2020 11:05:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D54C9F80103 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=tsoy.me header.i=@tsoy.me header.b="Tjv6Y002" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tsoy.me; s=mymail; h=Sender:Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=XRuQ1Ec43AOpcYkWIHpHMpSLiTLtzY5fULqhDCxhpxw=; b=Tjv6Y00277n60xxfahqpsf3Vq0 xwdisgMW6WszCojDnD3/mBm03gF6MIzdC/to43KYiNJ+onriSa69O4kBCSwam5YT9K5lFQF6TDy/2 c+vlXBUt9psalbFDqY+7imUMRlSJgDDcvWJ1kbfajWE9LIDpCrJIx7m74iFGUvpR5QP0=; Received: from [2a00:1370:8125:8203:1dce:4cab:baac:10ca] (helo=home.puleglot.ru) by puleglot.ru with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1iqa7m-000uTW-Fz; Sun, 12 Jan 2020 13:05:38 +0300 From: Alexander Tsoy To: alsa-devel@alsa-project.org Date: Sun, 12 Jan 2020 13:05:36 +0300 Message-Id: <20200112100536.17326-1-alexander@tsoy.me> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Cc: Takashi Iwai Subject: [alsa-devel] [PATCH v2] ALSA: usb-audio: Add boot quirk for MOTU M Series 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" Add delay to make sure that audio urbs are not sent too early. Otherwise the device hangs. Windows driver makes ~2s delay, so use about the same time delay value. snd_usb_apply_boot_quirk() is called 3 times for my MOTU M4, which is an overkill. Thus a quirk that is called only once is implemented. Also send two vendor-specific control messages before and after the delay. This behaviour is blindly copied from the Windows driver. Signed-off-by: Alexander Tsoy --- v2 changes: indentation fixes sound/usb/card.c | 4 ++++ sound/usb/quirks.c | 38 ++++++++++++++++++++++++++++++++++++++ sound/usb/quirks.h | 5 +++++ 3 files changed, 47 insertions(+) diff --git a/sound/usb/card.c b/sound/usb/card.c index 9f743ebae615..2f582ac7cf78 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -600,6 +600,10 @@ static int usb_audio_probe(struct usb_interface *intf, } } if (! chip) { + err = snd_usb_apply_boot_quirk_once(dev, intf, quirk, id); + if (err < 0) + return err; + /* it's a fresh one. * now look for an empty slot and create a new card instance */ diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 82184036437b..0464df785f2e 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1113,6 +1113,31 @@ static int snd_usb_motu_microbookii_boot_quirk(struct usb_device *dev) return err; } +static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) +{ + int ret; + + if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + return -EINVAL; + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0x0, 0, NULL, 0, 1000); + + if (ret < 0) + return ret; + + msleep(2000); + + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0x20, 0, NULL, 0, 1000); + + if (ret < 0) + return ret; + + return 0; +} + /* * Setup quirks */ @@ -1297,6 +1322,19 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev, return 0; } +int snd_usb_apply_boot_quirk_once(struct usb_device *dev, + struct usb_interface *intf, + const struct snd_usb_audio_quirk *quirk, + unsigned int id) +{ + switch (id) { + case USB_ID(0x07fd, 0x0008): /* MOTU M Series */ + return snd_usb_motu_m_series_boot_quirk(dev); + } + + return 0; +} + /* * check if the device uses big-endian samples */ diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h index a80e0ddd0736..b46b108769e8 100644 --- a/sound/usb/quirks.h +++ b/sound/usb/quirks.h @@ -20,6 +20,11 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev, const struct snd_usb_audio_quirk *quirk, unsigned int usb_id); +int snd_usb_apply_boot_quirk_once(struct usb_device *dev, + struct usb_interface *intf, + const struct snd_usb_audio_quirk *quirk, + unsigned int usb_id); + void snd_usb_set_format_quirk(struct snd_usb_substream *subs, struct audioformat *fmt);