From patchwork Thu May 20 04:01:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 443336 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 56481C433B4 for ; Thu, 20 May 2021 04:03:12 +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 8C46460FE6 for ; Thu, 20 May 2021 04:03:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C46460FE6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp 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 48897166E; Thu, 20 May 2021 06:02:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 48897166E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621483388; bh=kVTLKKPhEpPQ2jVMHSULc0bF0gLHZr+UtSvVLwA0rFc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BVAGE1b5NuRp4Or9AUVsZiesVzXdSAr/edX2Uv9DAWoaSzFYdmeeSEOVV9nCr6Dt5 ShDh7W/PM450bNo+ljjIlzK5xFhOMHLyr9d2Ozmls9k0ItApYPjyBb38QgGVkZUVq9 eAnlICPzKL8YwleGFvgnvi+q4KmVDwJ8GnWk7uUY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7211EF802E2; Thu, 20 May 2021 06:02:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E0E7BF80424; Thu, 20 May 2021 06:02:10 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9DBCEF800C8 for ; Thu, 20 May 2021 06:02:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9DBCEF800C8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="LbF4huTH"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FNv4/Bg7" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 6310E5C00FF; Thu, 20 May 2021 00:02:00 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 20 May 2021 00:02:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=S6Ff3OHA3awAv rJn4vaAKtDrHHN7gtM7gFcL1aiZiDs=; b=LbF4huTHM251OFX9zGXrQuH5AfKc4 iMg3zRzPgE7Vjq/3iE74eOx6vnjIVyOgvAAdBFlwuFzVMqOX/SDU5vylwc6FKUgf LdM1FUeO1cWBrmOIgD7H/PtIcdXaZut2AVzrjDxci503lEPZgtSo4ML/kn7rd9zq xISTNfvlRTmNGoSypMhecuAjObQDTfutqp3uwr6krIrOw5kLq24hs5l6HrVZuPVC 0VgIHtNTXHl0/eW+73YQFElPe0A4M9Uju8pU4xoUqwIuRdsqHCvtgyiR7465fX+z 8mTPV6IMaReiqAMsCfUKs8ED0/8a8rz3w/WKA+jsTD6WX2UidE9aWx+Rg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=S6Ff3OHA3awAvrJn4vaAKtDrHHN7gtM7gFcL1aiZiDs=; b=FNv4/Bg7 zeXxB0pXVJ7qp9kb4vH1hBWycGkd8DXPOXNLgi9sA5f0PuWKA8F6u2EQXn62lL2p oI8kZAN5GwZVflkrgp1qxWoTLyVt2qW7Rh2HC8KlUdb1lmM/r5p7N954gWl3hxPO UupY48TcU0mchjn/vOixp5Q6R6OkfNU9F1gPZ+n9n4Vbtym7H+AosQ/YGNsB41mO p/KZWW7LYazQaU6GKaWYYmAkB1QEGV9vTguLbuZjMkMKUNcweyq+/2+iqdU0SmHM Mye+4jjpJiWiq/RCjhvmpPwr2C5ZtgjKxzZ/DqAsg6m9e1MJHY9xmRNg6GaxAZGL PVF5oTR5w2/mlQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejtddgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 May 2021 00:01:59 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 1/8] ALSA: firewire-lib: code refactoring for size of CIP header Date: Thu, 20 May 2021 13:01:47 +0900 Message-Id: <20210520040154.80450-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210520040154.80450-1-o-takashi@sakamocchi.jp> References: <20210520040154.80450-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, clemens@ladisch.de 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" Some macros are added to refactor codes related to CIP header. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index af5c3629f1ac..f178cb5f2df3 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -33,7 +33,8 @@ #define TAG_NO_CIP_HEADER 0 #define TAG_CIP 1 -/* common isochronous packet header parameters */ +// Common Isochronous Packet (CIP) header parameters. Use two quadlets CIP header when supported. +#define CIP_HEADER_QUADLETS 2 #define CIP_EOH_SHIFT 31 #define CIP_EOH (1u << CIP_EOH_SHIFT) #define CIP_EOH_MASK 0x80000000 @@ -51,17 +52,21 @@ #define CIP_SYT_MASK 0x0000ffff #define CIP_SYT_NO_INFO 0xffff +#define CIP_HEADER_SIZE (sizeof(__be32) * CIP_HEADER_QUADLETS) + /* Audio and Music transfer protocol specific parameters */ #define CIP_FMT_AM 0x10 #define AMDTP_FDF_NO_DATA 0xff -// For iso header, tstamp and 2 CIP header. -#define IR_CTX_HEADER_SIZE_CIP 16 // For iso header and tstamp. -#define IR_CTX_HEADER_SIZE_NO_CIP 8 +#define IR_CTX_HEADER_DEFAULT_QUADLETS 2 +// Add nothing. +#define IR_CTX_HEADER_SIZE_NO_CIP (sizeof(__be32) * IR_CTX_HEADER_DEFAULT_QUADLETS) +// Add two quadlets CIP header. +#define IR_CTX_HEADER_SIZE_CIP (IR_CTX_HEADER_SIZE_NO_CIP + CIP_HEADER_SIZE) #define HEADER_TSTAMP_MASK 0x0000ffff -#define IT_PKT_HEADER_SIZE_CIP 8 // For 2 CIP header. +#define IT_PKT_HEADER_SIZE_CIP CIP_HEADER_SIZE #define IT_PKT_HEADER_SIZE_NO_CIP 0 // Nothing. // The initial firmware of OXFW970 can postpone transmission of packet during finishing @@ -323,7 +328,7 @@ unsigned int amdtp_stream_get_max_payload(struct amdtp_stream *s) if (s->flags & CIP_JUMBO_PAYLOAD) multiplier = IR_JUMBO_PAYLOAD_MAX_SKIP_CYCLES; if (!(s->flags & CIP_NO_HEADER)) - cip_header_size = sizeof(__be32) * 2; + cip_header_size = CIP_HEADER_SIZE; return cip_header_size + s->syt_interval * s->data_block_quadlets * sizeof(__be32) * multiplier; @@ -642,7 +647,7 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, payload_length = be32_to_cpu(ctx_header[0]) >> ISO_DATA_LENGTH_SHIFT; if (!(s->flags & CIP_NO_HEADER)) - cip_header_size = 8; + cip_header_size = CIP_HEADER_SIZE; else cip_header_size = 0; @@ -655,7 +660,7 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, if (cip_header_size > 0) { if (payload_length >= cip_header_size) { - cip_header = ctx_header + 2; + cip_header = ctx_header + IR_CTX_HEADER_DEFAULT_QUADLETS; err = check_cip_header(s, cip_header, payload_length - cip_header_size, data_blocks, data_block_counter, syt); if (err < 0) @@ -907,7 +912,7 @@ static void out_stream_callback(struct fw_iso_context *context, u32 tstamp, unsigned int syt; struct { struct fw_iso_packet params; - __be32 header[IT_PKT_HEADER_SIZE_CIP / sizeof(__be32)]; + __be32 header[CIP_HEADER_QUADLETS]; } template = { {0}, {0} }; bool sched_irq = false; @@ -1140,7 +1145,7 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, dir = DMA_FROM_DEVICE; type = FW_ISO_CONTEXT_RECEIVE; if (!(s->flags & CIP_NO_HEADER)) { - max_ctx_payload_size -= 8; + max_ctx_payload_size -= CIP_HEADER_SIZE; ctx_header_size = IR_CTX_HEADER_SIZE_CIP; } else { ctx_header_size = IR_CTX_HEADER_SIZE_NO_CIP; From patchwork Thu May 20 04:01:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 443335 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 9AB00C433B4 for ; Thu, 20 May 2021 04:04:06 +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 CA1E260FE6 for ; Thu, 20 May 2021 04:04:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA1E260FE6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp 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 5E4691690; Thu, 20 May 2021 06:03:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5E4691690 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621483444; bh=HocBdUxJy2GCDD6P/4lUERgXb7gZS1yASIduDCi1NBU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=IkPzv7Jzz3H4W9YlT2KhZfVeQZeXGIXzgjx30nbye/zz5MxKJPVtY0ELGEbB9MH0i 0yl81ayE8akx4ZkEav6+kYR/bz7QhTSy58L7ya/0Lr5DqXTFCjsNiZ4ex/hFJGCaJB LjpzP8mFzvIYRjige+k0XPX+SZZ79+9/LUo0TZV8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BDF35F8027D; Thu, 20 May 2021 06:02:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6E8D7F80475; Thu, 20 May 2021 06:02:21 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A5302F80217 for ; Thu, 20 May 2021 06:02:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A5302F80217 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="sle6foJA"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XJ0T/ljA" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id A5DCA5C0103; Thu, 20 May 2021 00:02:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 20 May 2021 00:02:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=zmwM190SEAe4M b8bvrU0gl7jNG1ypEhRd46vPJqq2fM=; b=sle6foJAxW68NgSpQZL7tdbxkLHRf cJUo6lnda0ca1PCDV3q3WBcZxSByViz7CQY0Zk4AlU11PnBaZXQA/2n975e/NY1D e+pwXLA9Iy2iCN1YBYhJOfDHtkCJxU3yFG/kDgRRviuzS0+6vbQlmc/THeLMzJfY TEaQln8IcpSAdqxtmJ/IGpKaUNFp+p5U02HTFl5u4rEYTpmOuSYpRRarCF6ufJmC KrDo4S0uIV78qoQ16MMpAqi15qBXfqEjAmUDLDEpc88xKnHZKNxSyq1nIfwaM4Bh zWfAWtS8q8W/gJgHHCHqTIISjOwnokwI6NrvlkGdVHEFQBgOAE5aCmtNA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=zmwM190SEAe4Mb8bvrU0gl7jNG1ypEhRd46vPJqq2fM=; b=XJ0T/ljA ExirfIEo6643a26forj27hqLDuT50uVTMp9zZE7lug1yYBb6QvDcFxNiuSlYulHK UWBxWQqyoA0g9PifcIEepkxwK6cOEYOv2U/H74F3kspV8SqhOU2vAr9yuGjFEXBj 3zpSP2xKZBUgcx/DndzsTkAVOu9qt7bhyXBS1pKKXRibixyTt2Y0lIv35oWxIeqb 8+iap/u28tt7ip6CV73SZ4llkpcS9tHO8P5+IOu4UrZODhciBVxJRm5Q1RKOrrHr I76lyWPCyfR95dq7D49qoMcO3Tp0ShK1+4CGPOT8iHHwP0rt+uk8KhwjN9c61uYo ngbvRmKUeGEONg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejtddgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 May 2021 00:02:00 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 2/8] ALSA: firewire-lib: code refactoring for calculation of context payload Date: Thu, 20 May 2021 13:01:48 +0900 Message-Id: <20210520040154.80450-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210520040154.80450-1-o-takashi@sakamocchi.jp> References: <20210520040154.80450-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, clemens@ladisch.de 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" It's convenient to calculate the size of context payload apart from the size of isochronous packet payload. This commit adds a helper function for it. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 37 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index f178cb5f2df3..36135296c144 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -313,6 +313,19 @@ int amdtp_stream_set_parameters(struct amdtp_stream *s, unsigned int rate, } EXPORT_SYMBOL(amdtp_stream_set_parameters); +// The CIP header is processed in context header apart from context payload. +static int amdtp_stream_get_max_ctx_payload_size(struct amdtp_stream *s) +{ + unsigned int multiplier; + + if (s->flags & CIP_JUMBO_PAYLOAD) + multiplier = IR_JUMBO_PAYLOAD_MAX_SKIP_CYCLES; + else + multiplier = 1; + + return s->syt_interval * s->data_block_quadlets * sizeof(__be32) * multiplier; +} + /** * amdtp_stream_get_max_payload - get the stream's packet size * @s: the AMDTP stream @@ -322,16 +335,14 @@ EXPORT_SYMBOL(amdtp_stream_set_parameters); */ unsigned int amdtp_stream_get_max_payload(struct amdtp_stream *s) { - unsigned int multiplier = 1; - unsigned int cip_header_size = 0; + unsigned int cip_header_size; - if (s->flags & CIP_JUMBO_PAYLOAD) - multiplier = IR_JUMBO_PAYLOAD_MAX_SKIP_CYCLES; if (!(s->flags & CIP_NO_HEADER)) cip_header_size = CIP_HEADER_SIZE; + else + cip_header_size = 0; - return cip_header_size + - s->syt_interval * s->data_block_quadlets * sizeof(__be32) * multiplier; + return cip_header_size + amdtp_stream_get_max_ctx_payload_size(s); } EXPORT_SYMBOL(amdtp_stream_get_max_payload); @@ -1140,27 +1151,21 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, } // initialize packet buffer. - max_ctx_payload_size = amdtp_stream_get_max_payload(s); if (s->direction == AMDTP_IN_STREAM) { dir = DMA_FROM_DEVICE; type = FW_ISO_CONTEXT_RECEIVE; - if (!(s->flags & CIP_NO_HEADER)) { - max_ctx_payload_size -= CIP_HEADER_SIZE; + if (!(s->flags & CIP_NO_HEADER)) ctx_header_size = IR_CTX_HEADER_SIZE_CIP; - } else { + else ctx_header_size = IR_CTX_HEADER_SIZE_NO_CIP; - } } else { dir = DMA_TO_DEVICE; type = FW_ISO_CONTEXT_TRANSMIT; ctx_header_size = 0; // No effect for IT context. - - if (!(s->flags & CIP_NO_HEADER)) - max_ctx_payload_size -= IT_PKT_HEADER_SIZE_CIP; } + max_ctx_payload_size = amdtp_stream_get_max_ctx_payload_size(s); - err = iso_packets_buffer_init(&s->buffer, s->unit, queue_size, - max_ctx_payload_size, dir); + err = iso_packets_buffer_init(&s->buffer, s->unit, queue_size, max_ctx_payload_size, dir); if (err < 0) goto err_unlock; s->queue_size = queue_size; From patchwork Thu May 20 04:01:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 443334 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 2CE52C433B4 for ; Thu, 20 May 2021 04:05:01 +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 50A5C61073 for ; Thu, 20 May 2021 04:05:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50A5C61073 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp 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 D812D169C; Thu, 20 May 2021 06:04:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D812D169C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621483498; bh=4tv2SfHeWbL34rA8bT2dizIqxHwLhnbPmHBGKYbgtZQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Tbo3V3pheBd5Jk4+Ppyy+MlAbT7+uetXxnTI6unNdV8YYNXcRGGD8fkJtBNMHQAXa /zmq+1QOkpSm4C5ntRoVRY1R7WpeLIbdfT1GrkySfkiSI6mVCgHV8RlySTbdoGNiN5 4UNAwc6QWkMeqdH7OFAOnZEWy2W7iYB5mfUtdTR8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E5D46F804AE; Thu, 20 May 2021 06:02:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6C15AF804AE; Thu, 20 May 2021 06:02:28 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A8D7CF80229 for ; Thu, 20 May 2021 06:02:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A8D7CF80229 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="mZzCe565"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JTl6pO9t" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 00DC75C00E7; Thu, 20 May 2021 00:02:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 20 May 2021 00:02:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=0nuJr2tzyvSn+ /z3rmTx+oAAdmgp2PD0SCmA+y0mj1s=; b=mZzCe565TPjc99yGrwCkzJQ4MBo5m dC/3sO1hXE9tQnXUDzIx3MkOlNjif+mwxYNZCXLlFuWVrALyyjPQVOLSixTxwpFr JoG6zEnWJJk30O7R2+CRmcnXNb3K74SBGN1YBrs6PCV3zuVuUlmab64OejEwJZbp l6XA0fxuPSI28q1zJ6hvqO66JvzsjpnMbv4+Q4VMHokhcndDpUwSUp9BEIE9gOVp 6DL+hpdVu9fV4V3HPTTXUlvEfBMLzkdkbBpo1S2Z+Rq2Wrg4Y0hcvx4ZK4/CBrCa PDRvLR/y+4QPVRIgwjjV/gw7Oedt3Gi4YNjREtda7dP+l56CHJqMDQePg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=0nuJr2tzyvSn+/z3rmTx+oAAdmgp2PD0SCmA+y0mj1s=; b=JTl6pO9t ZxP/WUDRQ+IkD+AJ0jmUwegONF4h04aU0nGrVz3YylpZBFZshmx0YzwgjBRlHD5v JjXQtnXG8dImVYwhWudlcPWkZ0MvfPHXoISI1L7yIi3PtfQ36/jD/PeJWAv6EaZ4 u2+BiKHtEUh7LSyoNrp7nQoDugH/F4XO48sWrESFl4Dc8WEOsuHpW7ddXCw9kXwA NCMmasUMJAanJrGiBqA2tCpBRVb5hnsEh20KuyNnp3ISoA42SalmQt4vFkK7KSVO 2Nmxv25+Ij4ESU8XcQ1eYXr12wR4Rsujkg2habt135eYN2tRl9mSMMcXC0IERWZm j5HB4GUkH7G7Gw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejtddgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 May 2021 00:02:01 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 3/8] ALSA: firewire-lib: code refactoring for selection of IT context header length Date: Thu, 20 May 2021 13:01:49 +0900 Message-Id: <20210520040154.80450-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210520040154.80450-1-o-takashi@sakamocchi.jp> References: <20210520040154.80450-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, clemens@ladisch.de 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" This commit refactors regarding to the size of CIP header. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 36135296c144..87644cb0d8ab 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -526,7 +526,7 @@ static void generate_cip_header(struct amdtp_stream *s, __be32 cip_header[2], } static void build_it_pkt_header(struct amdtp_stream *s, unsigned int cycle, - struct fw_iso_packet *params, + struct fw_iso_packet *params, unsigned int header_length, unsigned int data_blocks, unsigned int data_block_counter, unsigned int syt, unsigned int index) @@ -537,16 +537,15 @@ static void build_it_pkt_header(struct amdtp_stream *s, unsigned int cycle, payload_length = data_blocks * sizeof(__be32) * s->data_block_quadlets; params->payload_length = payload_length; - if (!(s->flags & CIP_NO_HEADER)) { + if (header_length > 0) { cip_header = (__be32 *)params->header; generate_cip_header(s, cip_header, data_block_counter, syt); - params->header_length = 2 * sizeof(__be32); - payload_length += params->header_length; + params->header_length = header_length; } else { cip_header = NULL; } - trace_amdtp_packet(s, cycle, cip_header, payload_length, data_blocks, + trace_amdtp_packet(s, cycle, cip_header, payload_length + header_length, data_blocks, data_block_counter, s->packet_index, index); } @@ -904,6 +903,7 @@ static void out_stream_callback(struct fw_iso_context *context, u32 tstamp, const __be32 *ctx_header = header; unsigned int events_per_period = d->events_per_period; unsigned int event_count = s->ctx_data.rx.event_count; + unsigned int pkt_header_length; unsigned int packets; int i; @@ -918,6 +918,11 @@ static void out_stream_callback(struct fw_iso_context *context, u32 tstamp, process_ctx_payloads(s, s->pkt_descs, packets); + if (!(s->flags & CIP_NO_HEADER)) + pkt_header_length = IT_PKT_HEADER_SIZE_CIP; + else + pkt_header_length = 0; + for (i = 0; i < packets; ++i) { const struct pkt_desc *desc = s->pkt_descs + i; unsigned int syt; @@ -932,7 +937,7 @@ static void out_stream_callback(struct fw_iso_context *context, u32 tstamp, else syt = s->ctx_data.rx.syt_override; - build_it_pkt_header(s, desc->cycle, &template.params, + build_it_pkt_header(s, desc->cycle, &template.params, pkt_header_length, desc->data_blocks, desc->data_block_counter, syt, i); From patchwork Thu May 20 04:01:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 443333 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 38D93C433B4 for ; Thu, 20 May 2021 04:05:44 +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 ABC7D61073 for ; Thu, 20 May 2021 04:05:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABC7D61073 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp 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 49ECC1696; Thu, 20 May 2021 06:04:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 49ECC1696 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621483542; bh=NmTPowujpDRcmat7b9Rr2SJYGPOGggPZ7163Yh6JubQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=D/DFp7ZP7OZazhnJTJhYK4xlHRpdIssqNHYFDslCCq6eIVsqkjkVUkVWNvl2bqdSb N8VeQq2ZD5lAYi0c2NZAaImk14xhbw637dYPABatm8iRi1kuReLYs+9pKqNljOUdlV YZtBPcVErJ2iNqAjboNNlzKSmBqUR6H5sYQ6oYSU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6F05BF804CF; Thu, 20 May 2021 06:02:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C01C2F804AE; Thu, 20 May 2021 06:02:29 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7837AF80272 for ; Thu, 20 May 2021 06:02:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7837AF80272 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="poUm0rs2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="AgVajk4R" Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id D858B5C00F8; Thu, 20 May 2021 00:02:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 20 May 2021 00:02:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=sLryzudFZO8jL D2w0dSy6J6g21/XpNI0qiJ7oD3pNwI=; b=poUm0rs2Qoyr2HWV2AgrWD3MLeDm9 uxjJlzQRaYAWm3G9omRbCqnriPBG49PFYQXUCEq+iOG7FF0IIWp3oLmec7iCCP3a pUGo0qW/hWg/1s5KRmImxF5VrCwpllmZJ3kC6W+6hP4/aCHfzzussZYhzt1OMLym 0VNSs+vO15XtQnh25OqEVkm5vKXRhrb9AiSUum6/a45VgCLLint5G0Dob1nmsoPO NHUDq1OTxB15p6zTM8XC15FkhtWm3OAUWZZthk/aDaasYtgcDgozQxoHKuJ0U5vm /Ipj10pFFm+lr5MEKivr6ThUMIkIMWUkCgvDLZfhsDJBHD7TQRWNB32NA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=sLryzudFZO8jLD2w0dSy6J6g21/XpNI0qiJ7oD3pNwI=; b=AgVajk4R C7X9OMJUsOrjn2yjdWs+MDrqMg5uKj+HezYskSBhmbibzPz1iNKaytSFEU+TDXqu oI1TFT2ZSuFavzhxY4WVrGPgGeUy0TjWIMk4ZEKalFO6f/nvKFUmCfRGrbPjbqqH 6JJ5cyXVQtdBRo8vCdrJ7oBX81sc95RVYFKsrPJ3v6bAoHg4lsdgF6+whnMm07i7 E3EwqLkKFtBtCsvO4YCilwUFp6+rb+q1u+eRiJ3IcQb03Pe5HYCGKJ1y8ZHV3s4l tVE12F9DnJQ89AXO2QB//m2YIgqiC3qMjqrmR5rv3PVTzet3rJntNQRozCNpz5L7 u8vwUA3g9VYdCA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejtddgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 May 2021 00:02:04 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 5/8] ALSA: firewire-lib: skip initial packets instead of scheduling IR context Date: Thu, 20 May 2021 13:01:51 +0900 Message-Id: <20210520040154.80450-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210520040154.80450-1-o-takashi@sakamocchi.jp> References: <20210520040154.80450-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, clemens@ladisch.de 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" Current implementation of ALSA IEC 61883-1/6 packet streaming engine allows drivers to decide isochronous cycle to start IR context. This option is mainly used to avoid processing the sequence of packet with some quirks; e.g. discontinuity of counter. However, it's inconvenient to fail to continue packet processing when the target device doesn't start transmission of packet till the decided cycle. This commit changes the behaviour. As an alternative to the start cycle for IR context, the cycle count to drop content of packet in the beginning of IR context. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 80 +++++------------------------ sound/firewire/amdtp-stream.h | 3 +- sound/firewire/bebob/bebob_stream.c | 21 +++----- 3 files changed, 23 insertions(+), 81 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 35925c9666fc..48ed9612407f 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -1199,12 +1199,16 @@ static void amdtp_stream_first_callback(struct fw_iso_context *context, } if (stream_count == callbacked_count) { + unsigned int next_cycle; + list_for_each_entry(s, &d->streams, list) { if (s->direction != AMDTP_IN_STREAM) continue; - if (compare_ohci_cycle_count(s->next_cycle, cycle) > 0) - cycle = s->next_cycle; + next_cycle = increment_ohci_cycle_count(s->next_cycle, + d->processing_cycle.tx_init_skip); + if (compare_ohci_cycle_count(next_cycle, cycle) > 0) + cycle = next_cycle; s->context->callback.sc = process_tx_packets_intermediately; } @@ -1533,36 +1537,13 @@ int amdtp_domain_add_stream(struct amdtp_domain *d, struct amdtp_stream *s, } EXPORT_SYMBOL_GPL(amdtp_domain_add_stream); -static int get_current_cycle_time(struct fw_card *fw_card, int *cur_cycle) -{ - int generation; - int rcode; - __be32 reg; - u32 data; - - // This is a request to local 1394 OHCI controller and expected to - // complete without any event waiting. - generation = fw_card->generation; - smp_rmb(); // node_id vs. generation. - rcode = fw_run_transaction(fw_card, TCODE_READ_QUADLET_REQUEST, - fw_card->node_id, generation, SCODE_100, - CSR_REGISTER_BASE + CSR_CYCLE_TIME, - ®, sizeof(reg)); - if (rcode != RCODE_COMPLETE) - return -EIO; - - data = be32_to_cpu(reg); - *cur_cycle = data >> 12; - - return 0; -} - /** * amdtp_domain_start - start sending packets for isoc context in the domain. * @d: the AMDTP domain. - * @ir_delay_cycle: the cycle delay to start all IR contexts. + * @tx_init_skip_cycles: the number of cycles to skip processing packets at initial stage of IR + * contexts. */ -int amdtp_domain_start(struct amdtp_domain *d, unsigned int ir_delay_cycle) +int amdtp_domain_start(struct amdtp_domain *d, unsigned int tx_init_skip_cycles) { static const struct { unsigned int data_block; @@ -1581,7 +1562,6 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int ir_delay_cycle) unsigned int idle_irq_interval; unsigned int queue_size; struct amdtp_stream *s; - int cycle; int err; // Select an IT context as IRQ target. @@ -1593,6 +1573,8 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int ir_delay_cycle) return -ENXIO; d->irq_target = s; + d->processing_cycle.tx_init_skip = tx_init_skip_cycles; + // This is a case that AMDTP streams in domain run just for MIDI // substream. Use the number of events equivalent to 10 msec as // interval of hardware IRQ. @@ -1615,48 +1597,12 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int ir_delay_cycle) d->syt_offset_state = entry->syt_offset; d->last_syt_offset = TICKS_PER_CYCLE; - if (ir_delay_cycle > 0) { - struct fw_card *fw_card = fw_parent_device(s->unit)->card; - - err = get_current_cycle_time(fw_card, &cycle); - if (err < 0) - goto error; - - // No need to care overflow in cycle field because of enough - // width. - cycle += ir_delay_cycle; - - // Round up to sec field. - if ((cycle & 0x00001fff) >= CYCLES_PER_SECOND) { - unsigned int sec; - - // The sec field can overflow. - sec = (cycle & 0xffffe000) >> 13; - cycle = (++sec << 13) | - ((cycle & 0x00001fff) / CYCLES_PER_SECOND); - } - - // In OHCI 1394 specification, lower 2 bits are available for - // sec field. - cycle &= 0x00007fff; - } else { - cycle = -1; - } - list_for_each_entry(s, &d->streams, list) { - int cycle_match; - - if (s->direction == AMDTP_IN_STREAM) { - cycle_match = cycle; - } else { - // IT context starts immediately. - cycle_match = -1; + if (s->direction == AMDTP_OUT_STREAM) s->ctx_data.rx.seq_index = 0; - } if (s != d->irq_target) { - err = amdtp_stream_start(s, s->channel, s->speed, - cycle_match, queue_size, 0); + err = amdtp_stream_start(s, s->channel, s->speed, -1, queue_size, 0); if (err < 0) goto error; } diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index 6fad113188fe..ebd040560791 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h @@ -289,6 +289,7 @@ struct amdtp_domain { struct amdtp_stream *irq_target; struct { + unsigned int tx_init_skip; unsigned int tx_start; } processing_cycle; @@ -309,7 +310,7 @@ void amdtp_domain_destroy(struct amdtp_domain *d); int amdtp_domain_add_stream(struct amdtp_domain *d, struct amdtp_stream *s, int channel, int speed); -int amdtp_domain_start(struct amdtp_domain *d, unsigned int ir_delay_cycle); +int amdtp_domain_start(struct amdtp_domain *d, unsigned int tx_init_skip_cycles); void amdtp_domain_stop(struct amdtp_domain *d); static inline int amdtp_domain_set_events_per_period(struct amdtp_domain *d, diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index b612ee3e33b6..8053d02b68f0 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c @@ -626,7 +626,7 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob) enum snd_bebob_clock_type src; struct amdtp_stream *master, *slave; unsigned int curr_rate; - unsigned int ir_delay_cycle; + unsigned int tx_init_skip_cycles; if (bebob->maudio_special_quirk) { err = bebob->spec->rate->get(bebob, &curr_rate); @@ -654,20 +654,13 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob) if (err < 0) goto error; - // The device postpones start of transmission mostly for 1 sec - // after receives packets firstly. For safe, IR context starts - // 0.4 sec (=3200 cycles) later to version 1 or 2 firmware, - // 2.0 sec (=16000 cycles) for version 3 firmware. This is - // within 2.5 sec (=CALLBACK_TIMEOUT). - // Furthermore, some devices transfer isoc packets with - // discontinuous counter in the beginning of packet streaming. - // The delay has an effect to avoid detection of this - // discontinuity. + // Some devices transfer isoc packets with discontinuous counter in the beginning + // of packet streaming. if (bebob->version < 2) - ir_delay_cycle = 3200; + tx_init_skip_cycles = 3200; else - ir_delay_cycle = 16000; - err = amdtp_domain_start(&bebob->domain, ir_delay_cycle); + tx_init_skip_cycles = 16000; + err = amdtp_domain_start(&bebob->domain, tx_init_skip_cycles); if (err < 0) goto error; @@ -684,6 +677,8 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob) } } + // Some devices postpone start of transmission mostly for 1 sec after receives + // packets firstly. if (!amdtp_stream_wait_callback(&bebob->rx_stream, CALLBACK_TIMEOUT) || !amdtp_stream_wait_callback(&bebob->tx_stream, From patchwork Thu May 20 04:01:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 443332 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 BF17BC433ED for ; Thu, 20 May 2021 04:06:24 +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 3E35B61073 for ; Thu, 20 May 2021 04:06:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E35B61073 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp 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 CC17F16A8; Thu, 20 May 2021 06:05:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CC17F16A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621483582; bh=kfheQhWWKBaJa+GjHdg4oQxwHM0Sv+j9CE3czu2oPSs=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qtza86ClSgJc3sHheAGDs6vf54+sY+KtoE461gMODJ/InwXpYNLbcp0ymAw5AEECs SLze7yoO4no7E9wweNL1oB7wuhJ6Rj2ORYJUObsIS2ktkudTdsvvBtOgnoZTUvQ80b gB8WcLEQjdGdrEUe6IIKRL9lRvuWW2pNoTNRivBw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 24977F804E2; Thu, 20 May 2021 06:02:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 81C34F80272; Thu, 20 May 2021 06:02:31 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 93057F802C8 for ; Thu, 20 May 2021 06:02:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 93057F802C8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="MoqICWdh"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="RlR707DD" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id BF1D85C00A2; Thu, 20 May 2021 00:02:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 20 May 2021 00:02:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=C4rSSz6ZpvGPI s0MmRj27i3xggR0vVj5hmEV2Swbfc4=; b=MoqICWdhll+9H19LqKij7B0IbSwg8 JTEDkeFcVgJT2It90KcrIa0FNfapKHIkwUEvSZtD3L7MCLX13DZxeonXCqGJ6yM4 r2aiNA8JdCdEHad8m3VcBG91jnRhB5rTUECf8vqd2hLT8QsiwUXxKC9w160qvslU yEYzKZEeQhO4LhkHKyGfiA3pBclhHICYI8ezqKACywPBBr9ISWmpQ2sy2kCocYBO JROd0o0CeOKgHmjEVmKXoQjc6Dsb7nydySU+nL6PC1LS6rhkBavnfOotZW/8abcv aqpBIXvS+Qqx0ONldffd4MD8ZChCOtIfy8or9a6eaxAzByS17XVieUJ5A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=C4rSSz6ZpvGPIs0MmRj27i3xggR0vVj5hmEV2Swbfc4=; b=RlR707DD 2lXNFovcBw5iEOSVOWyx0XkxqjRfn2f5s2kEhz+lBTHG+Q+WhqSkA9QrB3mwsJoG 3D2p/MCM8YTGi5pYnYqvXkooN/IlbrXTwZHPtxsJP0uBHmUfPmhGHUnmHT1qi/oB oo4bMMhf1JmAWUesOcYbu81fhrGoCBmZEviBBtApbkp756IoRyJyKUF8NZY7JsQL UpvgvsxXxwW4GoKGTvyQ1BKuuPwZHHQRQHP3s0pcpVFqt92IK6YzALzvDSz2Xikc YtSjQqAX0SLWYXw7vfm3VbSoCtvuhoMKqQj906i2azdy9vC9yhaw9vDJcvdYK/TH Z9t/CtNhwfd8Rg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejtddgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 May 2021 00:02:08 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 8/8] ALSA: firewire-lib: change waking up timing to process packets Date: Thu, 20 May 2021 13:01:54 +0900 Message-Id: <20210520040154.80450-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210520040154.80450-1-o-takashi@sakamocchi.jp> References: <20210520040154.80450-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, clemens@ladisch.de 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" When starting AMDTP domain, tasks in process context yields running CPU till all of isochronous context get callback, with an assumption that it's OK to process content of packet. However several isochronous cycles are skipped to transfer rx packets, or the content of rx packets are dropped, to manage the timing to start processing the packets. This commit changes the timing for tasks in process context to wake up when processing content of packet is actually ready. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 16 +++++--- sound/firewire/amdtp-stream.h | 44 ++++++++++++--------- sound/firewire/bebob/bebob_stream.c | 8 +--- sound/firewire/dice/dice-stream.c | 15 ++----- sound/firewire/digi00x/digi00x-stream.c | 7 +--- sound/firewire/fireface/ff-stream.c | 7 +--- sound/firewire/fireworks/fireworks_stream.c | 8 +--- sound/firewire/motu/motu-stream.c | 7 +--- sound/firewire/oxfw/oxfw-stream.c | 14 +------ sound/firewire/tascam/tascam-stream.c | 7 +--- 10 files changed, 54 insertions(+), 79 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index e9bdb609f2eb..a6a7a72a2452 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -107,7 +107,7 @@ int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit, INIT_WORK(&s->period_work, pcm_period_work); s->packet_index = 0; - init_waitqueue_head(&s->callback_wait); + init_waitqueue_head(&s->ready_wait); s->callbacked = false; s->fmt = fmt; @@ -1029,6 +1029,9 @@ static void process_rx_packets_intermediately(struct fw_iso_context *context, u3 } if (offset < packets) { + s->ready_processing = true; + wake_up(&s->ready_wait); + process_rx_packets(context, tstamp, header_length, ctx_header, private_data); if (amdtp_streaming_error(s)) return; @@ -1145,6 +1148,9 @@ static void process_tx_packets_intermediately(struct fw_iso_context *context, u3 } if (offset < packets) { + s->ready_processing = true; + wake_up(&s->ready_wait); + process_tx_packets(context, tstamp, header_length, ctx_header, s); if (amdtp_streaming_error(s)) return; @@ -1286,12 +1292,9 @@ static void amdtp_stream_first_callback(struct fw_iso_context *context, const __be32 *ctx_header = header; u32 cycle; - /* - * For in-stream, first packet has come. - * For out-stream, prepared to transmit first packet - */ + // For in-stream, first packet has come. + // For out-stream, prepared to transmit first packet s->callbacked = true; - wake_up(&s->callback_wait); if (s->direction == AMDTP_IN_STREAM) { cycle = compute_ohci_cycle_count(ctx_header[1]); @@ -1464,6 +1467,7 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, tag |= FW_ISO_CONTEXT_MATCH_TAG0; s->callbacked = false; + s->ready_processing = false; err = fw_iso_context_start(s->context, -1, 0, tag); if (err < 0) goto err_pkt_descs; diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index 7725d9793458..b362a6499265 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h @@ -167,9 +167,11 @@ struct amdtp_stream { snd_pcm_uframes_t pcm_buffer_pointer; unsigned int pcm_period_pointer; - /* To wait for first packet. */ - bool callbacked; - wait_queue_head_t callback_wait; + // To start processing content of packets at the same cycle in several contexts for + // each direction. + bool callbacked:1; + bool ready_processing:1; + wait_queue_head_t ready_wait; unsigned int next_cycle; /* For backends to process data blocks. */ @@ -259,21 +261,6 @@ static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc) return sfc & 1; } -/** - * amdtp_stream_wait_callback - sleep till callbacked or timeout - * @s: the AMDTP stream - * @timeout: msec till timeout - * - * If this function return false, the AMDTP stream should be stopped. - */ -static inline bool amdtp_stream_wait_callback(struct amdtp_stream *s, - unsigned int timeout) -{ - return wait_event_timeout(s->callback_wait, - s->callbacked, - msecs_to_jiffies(timeout)) > 0; -} - struct seq_desc { unsigned int syt_offset; unsigned int data_blocks; @@ -327,4 +314,25 @@ unsigned long amdtp_domain_stream_pcm_pointer(struct amdtp_domain *d, struct amdtp_stream *s); int amdtp_domain_stream_pcm_ack(struct amdtp_domain *d, struct amdtp_stream *s); +/** + * amdtp_domain_wait_ready - sleep till being ready to process packets or timeout + * @d: the AMDTP domain + * @timeout_ms: msec till timeout + * + * If this function return false, the AMDTP domain should be stopped. + */ +static inline bool amdtp_domain_wait_ready(struct amdtp_domain *d, unsigned int timeout_ms) +{ + struct amdtp_stream *s; + + list_for_each_entry(s, &d->streams, list) { + unsigned int j = msecs_to_jiffies(timeout_ms); + + if (wait_event_interruptible_timeout(s->ready_wait, s->ready_processing, j) <= 0) + return false; + } + + return true; +} + #endif diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index 8053d02b68f0..df764171f84b 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c @@ -7,8 +7,7 @@ #include "./bebob.h" -#define CALLBACK_TIMEOUT 2500 -#define FW_ISO_RESOURCE_DELAY 1000 +#define READY_TIMEOUT_MS 2500 /* * NOTE; @@ -679,10 +678,7 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob) // Some devices postpone start of transmission mostly for 1 sec after receives // packets firstly. - if (!amdtp_stream_wait_callback(&bebob->rx_stream, - CALLBACK_TIMEOUT) || - !amdtp_stream_wait_callback(&bebob->tx_stream, - CALLBACK_TIMEOUT)) { + if (!amdtp_domain_wait_ready(&bebob->domain, READY_TIMEOUT_MS)) { err = -ETIMEDOUT; goto error; } diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c index c4dfe76500c2..a9a0fe9635dd 100644 --- a/sound/firewire/dice/dice-stream.c +++ b/sound/firewire/dice/dice-stream.c @@ -8,7 +8,7 @@ #include "dice.h" -#define CALLBACK_TIMEOUT 200 +#define READY_TIMEOUT_MS 200 #define NOTIFICATION_TIMEOUT_MS (2 * MSEC_PER_SEC) struct reg_params { @@ -463,16 +463,9 @@ int snd_dice_stream_start_duplex(struct snd_dice *dice) if (err < 0) goto error; - for (i = 0; i < MAX_STREAMS; i++) { - if ((i < tx_params.count && - !amdtp_stream_wait_callback(&dice->tx_stream[i], - CALLBACK_TIMEOUT)) || - (i < rx_params.count && - !amdtp_stream_wait_callback(&dice->rx_stream[i], - CALLBACK_TIMEOUT))) { - err = -ETIMEDOUT; - goto error; - } + if (!amdtp_domain_wait_ready(&dice->domain, READY_TIMEOUT_MS)) { + err = -ETIMEDOUT; + goto error; } } diff --git a/sound/firewire/digi00x/digi00x-stream.c b/sound/firewire/digi00x/digi00x-stream.c index 405d6903bfbc..f11aaff2e248 100644 --- a/sound/firewire/digi00x/digi00x-stream.c +++ b/sound/firewire/digi00x/digi00x-stream.c @@ -7,7 +7,7 @@ #include "digi00x.h" -#define CALLBACK_TIMEOUT 500 +#define READY_TIMEOUT_MS 500 const unsigned int snd_dg00x_stream_rates[SND_DG00X_RATE_COUNT] = { [SND_DG00X_RATE_44100] = 44100, @@ -379,10 +379,7 @@ int snd_dg00x_stream_start_duplex(struct snd_dg00x *dg00x) if (err < 0) goto error; - if (!amdtp_stream_wait_callback(&dg00x->rx_stream, - CALLBACK_TIMEOUT) || - !amdtp_stream_wait_callback(&dg00x->tx_stream, - CALLBACK_TIMEOUT)) { + if (!amdtp_domain_wait_ready(&dg00x->domain, READY_TIMEOUT_MS)) { err = -ETIMEDOUT; goto error; } diff --git a/sound/firewire/fireface/ff-stream.c b/sound/firewire/fireface/ff-stream.c index 5452115c0ef9..53a21fb95add 100644 --- a/sound/firewire/fireface/ff-stream.c +++ b/sound/firewire/fireface/ff-stream.c @@ -7,7 +7,7 @@ #include "ff.h" -#define CALLBACK_TIMEOUT_MS 200 +#define READY_TIMEOUT_MS 200 int snd_ff_stream_get_multiplier_mode(enum cip_sfc sfc, enum snd_ff_stream_mode *mode) @@ -203,10 +203,7 @@ int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate) if (err < 0) goto error; - if (!amdtp_stream_wait_callback(&ff->rx_stream, - CALLBACK_TIMEOUT_MS) || - !amdtp_stream_wait_callback(&ff->tx_stream, - CALLBACK_TIMEOUT_MS)) { + if (!amdtp_domain_wait_ready(&ff->domain, READY_TIMEOUT_MS)) { err = -ETIMEDOUT; goto error; } diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index 2206af0fef42..858cd6085c1f 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c @@ -6,7 +6,7 @@ */ #include "./fireworks.h" -#define CALLBACK_TIMEOUT 100 +#define READY_TIMEOUT_MS 100 static int init_stream(struct snd_efw *efw, struct amdtp_stream *stream) { @@ -276,11 +276,7 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw) if (err < 0) goto error; - // Wait first callback. - if (!amdtp_stream_wait_callback(&efw->rx_stream, - CALLBACK_TIMEOUT) || - !amdtp_stream_wait_callback(&efw->tx_stream, - CALLBACK_TIMEOUT)) { + if (!amdtp_domain_wait_ready(&efw->domain, READY_TIMEOUT_MS)) { err = -ETIMEDOUT; goto error; } diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index 2028c5419f6f..925241ae2551 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -7,7 +7,7 @@ #include "motu.h" -#define CALLBACK_TIMEOUT 200 +#define READY_TIMEOUT_MS 200 #define ISOC_COMM_CONTROL_OFFSET 0x0b00 #define ISOC_COMM_CONTROL_MASK 0xffff0000 @@ -264,10 +264,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu) if (err < 0) goto stop_streams; - if (!amdtp_stream_wait_callback(&motu->tx_stream, - CALLBACK_TIMEOUT) || - !amdtp_stream_wait_callback(&motu->rx_stream, - CALLBACK_TIMEOUT)) { + if (!amdtp_domain_wait_ready(&motu->domain, READY_TIMEOUT_MS)) { err = -ETIMEDOUT; goto stop_streams; } diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index e9b6a9f171bf..4121d95e161f 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -9,7 +9,7 @@ #include #define AVC_GENERIC_FRAME_MAXIMUM_BYTES 512 -#define CALLBACK_TIMEOUT 200 +#define READY_TIMEOUT_MS 200 /* * According to datasheet of Oxford Semiconductor: @@ -358,20 +358,10 @@ int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw) if (err < 0) goto error; - // Wait first packet. - if (!amdtp_stream_wait_callback(&oxfw->rx_stream, - CALLBACK_TIMEOUT)) { + if (!amdtp_domain_wait_ready(&oxfw->domain, READY_TIMEOUT_MS)) { err = -ETIMEDOUT; goto error; } - - if (oxfw->has_output) { - if (!amdtp_stream_wait_callback(&oxfw->tx_stream, - CALLBACK_TIMEOUT)) { - err = -ETIMEDOUT; - goto error; - } - } } return 0; diff --git a/sound/firewire/tascam/tascam-stream.c b/sound/firewire/tascam/tascam-stream.c index eb07e1decf9b..296ecf5f6ddc 100644 --- a/sound/firewire/tascam/tascam-stream.c +++ b/sound/firewire/tascam/tascam-stream.c @@ -11,7 +11,7 @@ #define CLOCK_STATUS_MASK 0xffff0000 #define CLOCK_CONFIG_MASK 0x0000ffff -#define CALLBACK_TIMEOUT 500 +#define READY_TIMEOUT_MS 500 static int get_clock(struct snd_tscm *tscm, u32 *data) { @@ -477,10 +477,7 @@ int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate) if (err < 0) return err; - if (!amdtp_stream_wait_callback(&tscm->rx_stream, - CALLBACK_TIMEOUT) || - !amdtp_stream_wait_callback(&tscm->tx_stream, - CALLBACK_TIMEOUT)) { + if (!amdtp_domain_wait_ready(&tscm->domain, READY_TIMEOUT_MS)) { err = -ETIMEDOUT; goto error; }