From patchwork Sat May 22 01:32:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 12274271 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 1ED76C04FF3 for ; Sat, 22 May 2021 01:35: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 3C087613F4 for ; Sat, 22 May 2021 01:35:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C087613F4 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 C2E2416B5; Sat, 22 May 2021 03:34:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C2E2416B5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621647309; bh=4QBBXAmeC0bHj3fgbbJWs92VxVhWTvSPEeXZRlpZOf8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=jTc6EHtEzOZlwzWNEhdZnCLETQYaUl0ijpi0de7d91bmGrlXvs/5ymZNdpG4Wc4OR wvTCEb0euuHssojcthNwlEptYidkBuA0mk8HnN7mdrx0eKzGvPSFMpgT9A9ibjCWpf zMQqBMAlHxuc7HPEtKo2nvrWdIIsoZtxogtJxREQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 63495F80229; Sat, 22 May 2021 03:33:30 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 474C9F80424; Sat, 22 May 2021 03:33:23 +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 651C4F80153 for ; Sat, 22 May 2021 03:33:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 651C4F80153 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="pwFU46lo"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mK5/9s6g" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 829C15C0136; Fri, 21 May 2021 21:33:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 21 May 2021 21:33: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=vMqWzAqCcYD5Q RFqsriVfFGNLSMQC1q4C8Fur9LTWxE=; b=pwFU46lonX5n6fAuyy/iQ78AVttaB oam8QxqMcTPUvyeFRahG0fHW+JhmUtEfavBocn7rdQfNXOpLJAA8MylNTbShZdxO jH8nnGOiVoqczUYtRJ7D3c3mRUweDct36DyEzqJzSmtThE79XSPM4805FSTEhg5h o+2jXDz0m1r01CMUlETAmpPh9wDBvnvUYOioObqJDpl0eFSI67LcVGptMY1ZqbMA ckLT6wWA9YouFc6zHNvYD+mtiSWN2aZtfsPqEd411vOajSmicEVWkYW1wdlL3/Q5 CiOgm6TQhmB1ou4HseDwOdvuAEbY5UPKCHOy88Rs+r3t4CRqRDH4L1Ecg== 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=vMqWzAqCcYD5QRFqsriVfFGNLSMQC1q4C8Fur9LTWxE=; b=mK5/9s6g yQ2W3MP3+mpfnVbHjUyh1nCIg74/0vLa+NUVvUG9c5A3R7/97WPP0kkoUtjJUJnW 5dfiznPjpYdfRtvwLAR9nxcuedxQPBAHe6h9yCcl/3/i+ozaGb13dOTXl8yC+/2O h5CSke+eujBsniGe7Z8kY/2wO/Nry0WIaOrW79BarTcHvi11mjIGVUXHyVn+wvKy MsBHzQAT1SY4RVMDdJBuj+m8gRQA9ywoXFLe3SQ1UpJr9lriIpo1QQlrTeTYzB4y B4TlfyQTN2zcQbaKoeWzW0G5Giil0HbAGTb49gY+Pfc8i4a0dx0mC3R7qSJdTAtC q/uAVUfBs4phzQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejgedggeekucetufdoteggodetrfdotf 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; Fri, 21 May 2021 21:33:08 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 1/6] ALSA: firewire-lib: add flag to unaware of syt in CIP header Date: Sat, 22 May 2021 10:32:58 +0900 Message-Id: <20210522013303.49596-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210522013303.49596-1-o-takashi@sakamocchi.jp> References: <20210522013303.49596-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" Many devices are unaware of syt field in rx CIP for playback timing. This commit adds a flag to cancel processing syt field. Actually, syt calculation is required to decide the number of events per rx packet. The flag put 0xffff to CIP header of rx packet. On the other hand, The value of syt field in CIP header of tx packet is unavailable. The sequence of packet descriptor for tx packet includes 0 for the offset of syt field to avoid computation. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 27 ++++++++++----------------- sound/firewire/amdtp-stream.h | 4 +++- sound/firewire/motu/amdtp-motu.c | 4 +--- sound/firewire/tascam/amdtp-tascam.c | 6 ++---- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 3713188aac25..7e763f46e5a4 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -113,9 +113,6 @@ int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit, s->fmt = fmt; s->process_ctx_payloads = process_ctx_payloads; - if (dir == AMDTP_OUT_STREAM) - s->ctx_data.rx.syt_override = -1; - return 0; } EXPORT_SYMBOL(amdtp_stream_init); @@ -638,7 +635,8 @@ static int check_cip_header(struct amdtp_stream *s, const __be32 *buf, *data_block_counter = dbc; - *syt = cip_header[1] & CIP_SYT_MASK; + if (!(s->flags & CIP_UNAWARE_SYT)) + *syt = cip_header[1] & CIP_SYT_MASK; return 0; } @@ -836,22 +834,23 @@ static void generate_pkt_descs(struct amdtp_stream *s, struct pkt_desc *descs, { unsigned int dbc = s->data_block_counter; unsigned int seq_index = s->ctx_data.rx.seq_index; + bool aware_syt = !(s->flags & CIP_UNAWARE_SYT); int i; for (i = 0; i < packets; ++i) { struct pkt_desc *desc = descs + i; unsigned int index = (s->packet_index + i) % s->queue_size; const struct seq_desc *seq = seq_descs + seq_index; - unsigned int syt; desc->cycle = compute_ohci_it_cycle(*ctx_header, s->queue_size); - syt = seq->syt_offset; - if (syt != CIP_SYT_NO_INFO) { - syt = compute_syt(syt, desc->cycle, - s->ctx_data.rx.transfer_delay); + if (aware_syt && seq->syt_offset != CIP_SYT_NO_INFO) { + desc->syt = compute_syt(seq->syt_offset, desc->cycle, + s->ctx_data.rx.transfer_delay); + } else { + desc->syt = CIP_SYT_NO_INFO; } - desc->syt = syt; + desc->data_blocks = seq->data_blocks; if (s->flags & CIP_DBC_IS_END_EVENT) @@ -924,21 +923,15 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ for (i = 0; i < packets; ++i) { const struct pkt_desc *desc = s->pkt_descs + i; - unsigned int syt; struct { struct fw_iso_packet params; __be32 header[CIP_HEADER_QUADLETS]; } template = { {0}, {0} }; bool sched_irq = false; - if (s->ctx_data.rx.syt_override < 0) - syt = desc->syt; - else - syt = s->ctx_data.rx.syt_override; - build_it_pkt_header(s, desc->cycle, &template.params, pkt_header_length, desc->data_blocks, desc->data_block_counter, - syt, i); + desc->syt, i); if (s == s->domain->irq_target) { event_count += desc->data_blocks; diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index b362a6499265..6c4d277dc0dd 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h @@ -35,6 +35,8 @@ * @CIP_NO_HEADERS: a lack of headers in packets * @CIP_UNALIGHED_DBC: Only for in-stream. The value of dbc is not alighed to * the value of current SYT_INTERVAL; e.g. initial value is not zero. + * @CIP_UNAWARE_SYT: For outgoing packet, the value in SYT field of CIP is 0xffff. + * For incoming packet, the value in SYT field of CIP is not handled. */ enum cip_flags { CIP_NONBLOCKING = 0x00, @@ -48,6 +50,7 @@ enum cip_flags { CIP_HEADER_WITHOUT_EOH = 0x80, CIP_NO_HEADER = 0x100, CIP_UNALIGHED_DBC = 0x200, + CIP_UNAWARE_SYT = 0x400, }; /** @@ -143,7 +146,6 @@ struct amdtp_stream { // To generate CIP header. unsigned int fdf; - int syt_override; // To generate constant hardware IRQ. unsigned int event_count; diff --git a/sound/firewire/motu/amdtp-motu.c b/sound/firewire/motu/amdtp-motu.c index 9ccde07d6295..18bf433f43b6 100644 --- a/sound/firewire/motu/amdtp-motu.c +++ b/sound/firewire/motu/amdtp-motu.c @@ -441,7 +441,7 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit, { amdtp_stream_process_ctx_payloads_t process_ctx_payloads; int fmt = CIP_FMT_MOTU; - int flags = CIP_BLOCKING; + unsigned int flags = CIP_BLOCKING | CIP_UNAWARE_SYT; int err; if (dir == AMDTP_IN_STREAM) { @@ -479,8 +479,6 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit, if (dir == AMDTP_OUT_STREAM) { // Use fixed value for FDF field. s->ctx_data.rx.fdf = MOTU_FDF_AM824; - // Not used. - s->ctx_data.rx.syt_override = 0xffff; } return 0; diff --git a/sound/firewire/tascam/amdtp-tascam.c b/sound/firewire/tascam/amdtp-tascam.c index f823a2ab3544..64d66a802545 100644 --- a/sound/firewire/tascam/amdtp-tascam.c +++ b/sound/firewire/tascam/amdtp-tascam.c @@ -228,6 +228,7 @@ int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit, enum amdtp_stream_direction dir, unsigned int pcm_channels) { amdtp_stream_process_ctx_payloads_t process_ctx_payloads; + unsigned int flags = CIP_NONBLOCKING | CIP_SKIP_DBC_ZERO_CHECK | CIP_UNAWARE_SYT; struct amdtp_tscm *p; unsigned int fmt; int err; @@ -240,8 +241,7 @@ int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit, process_ctx_payloads = process_it_ctx_payloads; } - err = amdtp_stream_init(s, unit, dir, - CIP_NONBLOCKING | CIP_SKIP_DBC_ZERO_CHECK, fmt, + err = amdtp_stream_init(s, unit, dir, flags, fmt, process_ctx_payloads, sizeof(struct amdtp_tscm)); if (err < 0) return 0; @@ -249,8 +249,6 @@ int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit, if (dir == AMDTP_OUT_STREAM) { // Use fixed value for FDF field. s->ctx_data.rx.fdf = 0x00; - // Not used. - s->ctx_data.rx.syt_override = 0x0000; } /* This protocol uses fixed number of data channels for PCM samples. */ From patchwork Sat May 22 01:32:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 12274269 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=-13.9 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,UNWANTED_LANGUAGE_BODY, 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 C3474C04FF3 for ; Sat, 22 May 2021 01:34:22 +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 1ADB1613F5 for ; Sat, 22 May 2021 01:34:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1ADB1613F5 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 AF3D01616; Sat, 22 May 2021 03:33:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AF3D01616 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621647258; bh=Fnj7Qf+JIbqGyTJWf9Z1340dYKWJUxsSCjcnPS8tQTY=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ocLM9ta/21OQAb8AdebQU9bpdA21yEnOvZruIq674jpRsivMarDvCPmISK+J5aAv9 4GFLbEZiEDTI4B6MaivXFRo4WTQg8S/vn47cljem7Wf21eFwn8ffIrnlbi3LQuFRX2 tXc1Et7WKFQGuNlIxyMSy+3kBj7GepqaeieX9tBQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5AB74F80153; Sat, 22 May 2021 03:33:27 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E6C0AF80217; Sat, 22 May 2021 03:33:23 +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 6CB87F80217 for ; Sat, 22 May 2021 03:33:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6CB87F80217 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="hqFwxRwG"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="g07jMXaz" Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id C519F5C024A; Fri, 21 May 2021 21:33:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 21 May 2021 21:33:10 -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=1PnkI9x3FpNx3 pObvJwkKgeAegiijK8QkociNPtQ0RI=; b=hqFwxRwGJxbpMX92ADh7Gkiw+ik+t 4HleQV0LeBvSLBlSMDsR3GlsXgeggGCG4MDhSNkyJvu6XwHFUb5fZiZgwwIO+rPw Hm9C8K4sqzX9W5FCRRLugRC8Jc60LBaXNaZzudajWGnkLwGZhWS5SLRSXUZVJwnq AL7z8bmXrMYNMcMtlCYnuRnKWy/XUTCfbxATMgpB3gn1Dl+0F1tT9aXXx7xruCLE GM/EG3TNuyBOdWk3eh9yj7sgoT/aOLBlZZXKE15cSCMs4sKWHJmESYb2wQ/a7ehR oCoqtmd1qQl0ILdXPnHwC2UD2Vou3p/ymR6Q3Nyr9uqf+QVf9bW/gFCjA== 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=1PnkI9x3FpNx3pObvJwkKgeAegiijK8QkociNPtQ0RI=; b=g07jMXaz hq+Hwp1X3en1fdp/0Qo9/48FcWJc8S0w8pqHVbmbbczgE7C4RDOlCfIuY4Z/HBn4 0sQxihMa/AtqxzK7xOQhQkxNuV+b5QY8FW/p5TNnGQWPWFNJYiYZndPS05CgR9Mb nf6X3xHuB3YnEN2zi99PzlXCxcoRylffX/TVHM5x7g+ujQDs4/sHGa8Y3QkIT2Jy GiSD3uwib3oi+EZWOktvLu1UY83Knxg72VsV+vh7xY/WTnRtsuQPNithU3Nw27/S M6XhyYICWczwzyZ+qNGhsMBEbrtZ4wwOqw2E2o7IPqVd+Pu2INie7kKT6OZYewqO hr2ArzZa9ZbvCA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejgedggeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepieetueeuvd elfedvteejteeiheeugeelvedvkeeffeffuedutdeifeeukeeutefgnecuffhomhgrihhn pehrgidruggrthgrnecukfhppedugedrfedrieehrddujeehnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgr mhhotggthhhirdhjph 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; Fri, 21 May 2021 21:33:09 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 2/6] ALSA: firewire-lib: pool sequence of packet in IT context independently Date: Sat, 22 May 2021 10:32:59 +0900 Message-Id: <20210522013303.49596-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210522013303.49596-1-o-takashi@sakamocchi.jp> References: <20210522013303.49596-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 pools the sequence in AMDTP domain. This is convenient regarding to memory usage and computation time, however inconvenient for the devices such that several rx streams are expected to transfer timing information independently. This commit refactors to pool the sequence per rx packet stream. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 150 ++++++++++++++-------------------- sound/firewire/amdtp-stream.h | 22 ++--- 2 files changed, 72 insertions(+), 100 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 7e763f46e5a4..cf4fbbd18756 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -441,6 +441,30 @@ static unsigned int calculate_syt_offset(unsigned int *last_syt_offset, return syt_offset; } +static void pool_ideal_seq_descs(struct amdtp_stream *s, unsigned int count) +{ + unsigned int seq_tail = s->ctx_data.rx.seq.tail; + const unsigned int seq_size = s->ctx_data.rx.seq.size; + const unsigned int syt_interval = s->syt_interval; + const enum cip_sfc sfc = s->sfc; + const bool is_blocking = !!(s->flags & CIP_BLOCKING); + int i; + + for (i = 0; i < count; ++i) { + struct seq_desc *desc = s->ctx_data.rx.seq.descs + seq_tail; + + desc->syt_offset = calculate_syt_offset(&s->ctx_data.rx.last_syt_offset, + &s->ctx_data.rx.syt_offset_state, sfc); + desc->data_blocks = calculate_data_blocks(&s->ctx_data.rx.data_block_state, + is_blocking, desc->syt_offset == CIP_SYT_NO_INFO, + syt_interval, sfc); + + seq_tail = (seq_tail + 1) % seq_size; + } + + s->ctx_data.rx.seq.tail = seq_tail; +} + static void update_pcm_pointers(struct amdtp_stream *s, struct snd_pcm_substream *pcm, unsigned int frames) @@ -833,14 +857,14 @@ static void generate_pkt_descs(struct amdtp_stream *s, struct pkt_desc *descs, unsigned int seq_size) { unsigned int dbc = s->data_block_counter; - unsigned int seq_index = s->ctx_data.rx.seq_index; + unsigned int seq_head = s->ctx_data.rx.seq.head; bool aware_syt = !(s->flags & CIP_UNAWARE_SYT); int i; for (i = 0; i < packets; ++i) { struct pkt_desc *desc = descs + i; unsigned int index = (s->packet_index + i) % s->queue_size; - const struct seq_desc *seq = seq_descs + seq_index; + const struct seq_desc *seq = seq_descs + seq_head; desc->cycle = compute_ohci_it_cycle(*ctx_header, s->queue_size); @@ -863,13 +887,13 @@ static void generate_pkt_descs(struct amdtp_stream *s, struct pkt_desc *descs, desc->ctx_payload = s->buffer.packets[index].buffer; - seq_index = (seq_index + 1) % seq_size; + seq_head = (seq_head + 1) % seq_size; ++ctx_header; } s->data_block_counter = dbc; - s->ctx_data.rx.seq_index = seq_index; + s->ctx_data.rx.seq.head = seq_head; } static inline void cancel_stream(struct amdtp_stream *s) @@ -911,8 +935,10 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ // Calculate the number of packets in buffer and check XRUN. packets = header_length / sizeof(*ctx_header); - generate_pkt_descs(s, s->pkt_descs, ctx_header, packets, d->seq.descs, - d->seq.size); + pool_ideal_seq_descs(s, packets); + + generate_pkt_descs(s, s->pkt_descs, ctx_header, packets, s->ctx_data.rx.seq.descs, + s->ctx_data.rx.seq.size); process_ctx_payloads(s, s->pkt_descs, packets); @@ -1152,51 +1178,6 @@ static void process_tx_packets_intermediately(struct fw_iso_context *context, u3 } } -static void pool_ideal_seq_descs(struct amdtp_domain *d, unsigned int packets) -{ - struct amdtp_stream *irq_target = d->irq_target; - unsigned int seq_tail = d->seq.tail; - unsigned int seq_size = d->seq.size; - unsigned int min_avail; - struct amdtp_stream *s; - - min_avail = d->seq.size; - list_for_each_entry(s, &d->streams, list) { - unsigned int seq_index; - unsigned int avail; - - if (s->direction == AMDTP_IN_STREAM) - continue; - - seq_index = s->ctx_data.rx.seq_index; - avail = d->seq.tail; - if (seq_index > avail) - avail += d->seq.size; - avail -= seq_index; - - if (avail < min_avail) - min_avail = avail; - } - - while (min_avail < packets) { - struct seq_desc *desc = d->seq.descs + seq_tail; - - desc->syt_offset = calculate_syt_offset(&d->last_syt_offset, - &d->syt_offset_state, irq_target->sfc); - desc->data_blocks = calculate_data_blocks(&d->data_block_state, - !!(irq_target->flags & CIP_BLOCKING), - desc->syt_offset == CIP_SYT_NO_INFO, - irq_target->syt_interval, irq_target->sfc); - - ++seq_tail; - seq_tail %= seq_size; - - ++min_avail; - } - - d->seq.tail = seq_tail; -} - static void process_ctxs_in_domain(struct amdtp_domain *d) { struct amdtp_stream *s; @@ -1225,9 +1206,6 @@ static void irq_target_callback(struct fw_iso_context *context, u32 tstamp, size { struct amdtp_stream *s = private_data; struct amdtp_domain *d = s->domain; - unsigned int packets = header_length / sizeof(__be32); - - pool_ideal_seq_descs(d, packets); process_rx_packets(context, tstamp, header_length, header, private_data); process_ctxs_in_domain(d); @@ -1238,9 +1216,6 @@ static void irq_target_callback_intermediately(struct fw_iso_context *context, u { struct amdtp_stream *s = private_data; struct amdtp_domain *d = s->domain; - unsigned int packets = header_length / sizeof(__be32); - - pool_ideal_seq_descs(d, packets); process_rx_packets_intermediately(context, tstamp, header_length, header, private_data); process_ctxs_in_domain(d); @@ -1415,7 +1390,31 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, s->ctx_data.tx.max_ctx_payload_length = max_ctx_payload_size; s->ctx_data.tx.ctx_header_size = ctx_header_size; } else { - s->ctx_data.rx.seq_index = 0; + static const struct { + unsigned int data_block; + unsigned int syt_offset; + } *entry, initial_state[] = { + [CIP_SFC_32000] = { 4, 3072 }, + [CIP_SFC_48000] = { 6, 1024 }, + [CIP_SFC_96000] = { 12, 1024 }, + [CIP_SFC_192000] = { 24, 1024 }, + [CIP_SFC_44100] = { 0, 67 }, + [CIP_SFC_88200] = { 0, 67 }, + [CIP_SFC_176400] = { 0, 67 }, + }; + + s->ctx_data.rx.seq.descs = kcalloc(queue_size, sizeof(*s->ctx_data.rx.seq.descs), GFP_KERNEL); + if (!s->ctx_data.rx.seq.descs) + goto err_context; + s->ctx_data.rx.seq.size = queue_size; + s->ctx_data.rx.seq.tail = 0; + s->ctx_data.rx.seq.head = 0; + + entry = &initial_state[s->sfc]; + s->ctx_data.rx.data_block_state = entry->data_block; + s->ctx_data.rx.syt_offset_state = entry->syt_offset; + s->ctx_data.rx.last_syt_offset = TICKS_PER_CYCLE; + s->ctx_data.rx.event_count = 0; } @@ -1471,6 +1470,8 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, err_pkt_descs: kfree(s->pkt_descs); err_context: + if (s->direction == AMDTP_OUT_STREAM) + kfree(s->ctx_data.rx.seq.descs); fw_iso_context_destroy(s->context); s->context = ERR_PTR(-1); err_buffer: @@ -1581,7 +1582,8 @@ static void amdtp_stream_stop(struct amdtp_stream *s) iso_packets_buffer_destroy(&s->buffer, s->unit); kfree(s->pkt_descs); - s->callbacked = false; + if (s->direction == AMDTP_OUT_STREAM) + kfree(s->ctx_data.rx.seq.descs); mutex_unlock(&s->mutex); } @@ -1613,8 +1615,6 @@ int amdtp_domain_init(struct amdtp_domain *d) d->events_per_period = 0; - d->seq.descs = NULL; - return 0; } EXPORT_SYMBOL_GPL(amdtp_domain_init); @@ -1665,18 +1665,6 @@ EXPORT_SYMBOL_GPL(amdtp_domain_add_stream); */ int amdtp_domain_start(struct amdtp_domain *d, unsigned int tx_init_skip_cycles) { - static const struct { - unsigned int data_block; - unsigned int syt_offset; - } *entry, initial_state[] = { - [CIP_SFC_32000] = { 4, 3072 }, - [CIP_SFC_48000] = { 6, 1024 }, - [CIP_SFC_96000] = { 12, 1024 }, - [CIP_SFC_192000] = { 24, 1024 }, - [CIP_SFC_44100] = { 0, 67 }, - [CIP_SFC_88200] = { 0, 67 }, - [CIP_SFC_176400] = { 0, 67 }, - }; unsigned int events_per_buffer = d->events_per_buffer; unsigned int events_per_period = d->events_per_period; unsigned int queue_size; @@ -1705,17 +1693,6 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int tx_init_skip_cycles) queue_size = DIV_ROUND_UP(CYCLES_PER_SECOND * events_per_buffer, amdtp_rate_table[d->irq_target->sfc]); - d->seq.descs = kcalloc(queue_size, sizeof(*d->seq.descs), GFP_KERNEL); - if (!d->seq.descs) - return -ENOMEM; - d->seq.size = queue_size; - d->seq.tail = 0; - - entry = &initial_state[s->sfc]; - d->data_block_state = entry->data_block; - d->syt_offset_state = entry->syt_offset; - d->last_syt_offset = TICKS_PER_CYCLE; - list_for_each_entry(s, &d->streams, list) { unsigned int idle_irq_interval = 0; @@ -1734,8 +1711,6 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int tx_init_skip_cycles) error: list_for_each_entry(s, &d->streams, list) amdtp_stream_stop(s); - kfree(d->seq.descs); - d->seq.descs = NULL; return err; } EXPORT_SYMBOL_GPL(amdtp_domain_start); @@ -1760,8 +1735,5 @@ void amdtp_domain_stop(struct amdtp_domain *d) d->events_per_period = 0; d->irq_target = NULL; - - kfree(d->seq.descs); - d->seq.descs = NULL; } EXPORT_SYMBOL_GPL(amdtp_domain_stop); diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index 6c4d277dc0dd..fc653fe95405 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h @@ -142,13 +142,23 @@ struct amdtp_stream { struct { // To calculate CIP data blocks and tstamp. unsigned int transfer_delay; - unsigned int seq_index; // To generate CIP header. unsigned int fdf; // To generate constant hardware IRQ. unsigned int event_count; + + struct { + struct seq_desc *descs; + unsigned int size; + unsigned int tail; + unsigned int head; + } seq; + + unsigned int data_block_state; + unsigned int syt_offset_state; + unsigned int last_syt_offset; } rx; } ctx_data; @@ -281,16 +291,6 @@ struct amdtp_domain { unsigned int tx_start; unsigned int rx_start; } processing_cycle; - - struct { - struct seq_desc *descs; - unsigned int size; - unsigned int tail; - } seq; - - unsigned int data_block_state; - unsigned int syt_offset_state; - unsigned int last_syt_offset; }; int amdtp_domain_init(struct amdtp_domain *d); From patchwork Sat May 22 01:33:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 12274275 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 BAE05C04FF3 for ; Sat, 22 May 2021 01:35:59 +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 38444613F5 for ; Sat, 22 May 2021 01:35:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38444613F5 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 C8FD116A3; Sat, 22 May 2021 03:35:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C8FD116A3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621647357; bh=f/nE8+ySeyABv7RyneOLz8z6N7LOrjK02BcXtEA9YcM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=byv1oiH4dSXYA/V6L2uRIwHuO3rG7FPUgrsdNuaTU3UvSiKXs8xOslksc8ClR2cFn EdgHOhDAYPbwfUN2xESnyXNz3fsGHo7GZ+NPeF0MYk8G7iojSSsnI+AZKGUwK5q9Em oN5D02d8KqzMpyk+e7tLC/pJ2R26I5pn1T59T+9U= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4B10CF804AA; Sat, 22 May 2021 03:33:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 09AA1F802C8; Sat, 22 May 2021 03:33:27 +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 5BE60F80229 for ; Sat, 22 May 2021 03:33:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5BE60F80229 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="Iz5b7FAX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FhRn32CL" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 824465C025B; Fri, 21 May 2021 21:33:12 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 21 May 2021 21:33:12 -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=X3Cu6lEuCZJ2y ULLlkDaRE3zidiH8ERLDI8koG0w7PA=; b=Iz5b7FAXTqlntRoysfXxhAI2eYKpE PXDmu0M2ZSFg7Hfd4Y1y1bMWspTdLQ1uAR+Tw1hh60uAFfYWODtufOT1w7UU6Eq3 0wu/mrvd9qtYkwhBHs3Rw7u5u5x0hTrDKDP1W35/TprJvxbIuw9F8mWOEJy5eraK 0QBy6lVJZOoCImFNnf0Tq5uMgtcAbnglYht/UWuyVLfsub1pBk3jSebVuAaomub8 sxmuif4YyipelOxIfsmWPOZdvQo8jTKJ3OwWDenjY/bM/kV/xW3qK9a5FHgX1jjM DXzjIme8Xren7geU7Xwb2sHcMy+wvrDUl1b/uZ4Q+qFVieI5MOYuQaRFA== 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=X3Cu6lEuCZJ2yULLlkDaRE3zidiH8ERLDI8koG0w7PA=; b=FhRn32CL tbN2jCchtjlEPP70vgZSRc4ncp++eH6i9w77cBxwqKfA3Wksej8iDfPqjWTzgwuC ZMpdl0N2JF2NXN8DMKB4WHV7r6OxhOTovfJVAH51GMAo8+3HBBkA08/b7bB5xL7h 0y9eML+jU5kz7Mq8JXZsTGzJg7kQ4EZgHE1NGHGt+4hzwGLBU4QUYceDZdRfhJGa 1l+mXiAeRI9sKs2BVWSsrO2EbQ4rJS0zneWcLxedELzhcw9A6i/of3NOAqXE43Es fCNmbqVQ7YgUi4/HqlTqueO9pz+vlYqoFhJHMJM7vriVzmqZ481S/6deCzwYfRUL zfGIGZLtN0SHjA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejgedggeekucetufdoteggodetrfdotf 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; Fri, 21 May 2021 21:33:10 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 3/6] ALSA: firewire-lib: code refactoring for generation of packet descriptors Date: Sat, 22 May 2021 10:33:00 +0900 Message-Id: <20210522013303.49596-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210522013303.49596-1-o-takashi@sakamocchi.jp> References: <20210522013303.49596-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 the arguments of helper function to generate the descriptors of packet. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index cf4fbbd18756..354512a350b7 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -851,11 +851,11 @@ static unsigned int compute_syt(unsigned int syt_offset, unsigned int cycle, return syt & CIP_SYT_MASK; } -static void generate_pkt_descs(struct amdtp_stream *s, struct pkt_desc *descs, - const __be32 *ctx_header, unsigned int packets, - const struct seq_desc *seq_descs, - unsigned int seq_size) +static void generate_pkt_descs(struct amdtp_stream *s, const __be32 *ctx_header, unsigned int packets) { + struct pkt_desc *descs = s->pkt_descs; + const struct seq_desc *seq_descs = s->ctx_data.rx.seq.descs; + const unsigned int seq_size = s->ctx_data.rx.seq.size; unsigned int dbc = s->data_block_counter; unsigned int seq_head = s->ctx_data.rx.seq.head; bool aware_syt = !(s->flags & CIP_UNAWARE_SYT); @@ -937,8 +937,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ pool_ideal_seq_descs(s, packets); - generate_pkt_descs(s, s->pkt_descs, ctx_header, packets, s->ctx_data.rx.seq.descs, - s->ctx_data.rx.seq.size); + generate_pkt_descs(s, ctx_header, packets); process_ctx_payloads(s, s->pkt_descs, packets); From patchwork Sat May 22 01:33:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 12274277 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=-13.9 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,UNWANTED_LANGUAGE_BODY, 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 056A7C04FF3 for ; Sat, 22 May 2021 01:36:10 +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 7CF4F613F4 for ; Sat, 22 May 2021 01:36:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CF4F613F4 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 1A46716D2; Sat, 22 May 2021 03:35:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1A46716D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621647368; bh=4lqtPJKntEEoHiEt0WRGi/Njm/Q4NAk0D9CBxDqpQQ4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=YSQabBWHCvKQzWqBHETp6PphLj8nO2MNTGbcrFzTK7HLRqt13a/AKrlNmpW75M6yJ o8ViYjmLCGL1Guks6cF0mLmUJSjd6u5fcWa2UdkXRpB0bsl55LGATYEPbdkq5sOiYw tK+uMHczL/g6Pe9jULdD04iGoMcOqi7JCTM64vf4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8517FF804AB; Sat, 22 May 2021 03:33:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 42DD4F80257; Sat, 22 May 2021 03:33: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 9F46CF80257 for ; Sat, 22 May 2021 03:33:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9F46CF80257 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="rFPzfe6r"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="WIcKOtQ2" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C87685C024F; Fri, 21 May 2021 21:33:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 21 May 2021 21:33:13 -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=c5jfPQEYgI17v h0PEdvC8vVx6rTAzyhbrZqcibr7AxE=; b=rFPzfe6r+jxSbQXtOdE/JRjopduza OLO+4FVwOixb3SHCGGMLtwkDzUmXG//GzN3dBVPlhAG/W3gIXNNBaPVK2Q0UIgya 9JToUrYwgQy8LlCdzT7YKT7LLVbW9nBpeqXrz9GuycHjtCmLUXaQCXMl3v/xEpOC iJ+NL+3tkMdQuZGfxykiNOW3eWWRfYl6mC3BjO+Fv76LT8otgUWKkLhlF2j+LQmX 9IGJCIOYiwd73GqJhpwI1ha6gNxJANrGC2ftzUWPzAVoEhz3MbOvv1ZmWLVLHzOK I7FFdMJJ7h648Hg9kaFtg3HSzleGzaMqr5Km0RaVlK3/CgAcPGlREp/PQ== 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=c5jfPQEYgI17vh0PEdvC8vVx6rTAzyhbrZqcibr7AxE=; b=WIcKOtQ2 Eoke9GmI2NHGqYp3DnNHzKlxP+Tk1lxpM6nZMAuHgIFEYOyJhakCCL4XFnSfVnc2 yhQt46/Rw2gYRBqM6WJVS7iFW1WvkUPF07l9eD3wibjm1szpBhOatlQHQnW+qkvL OJK2BiorC0ySxxCOIFv1Az911EK35/zQ+ZbcgSAggkUHJX1+lyE52wOLD+V2Gzrq niciWBd5Dj5EChPgL1Lxbhvep97ij76Ftj1cK9UncaAtcj8rTth6qd4/6sd7XjKI k1slg2HBbGTVKEGqhhKCzx8qROqCoJihjhBul1RsuHu9tw8I4uoGlUerAAnU27dy lHj7wmR4nFEYfg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejgedggeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepieetueeuvd elfedvteejteeiheeugeelvedvkeeffeffuedutdeifeeukeeutefgnecuffhomhgrihhn pehrgidruggrthgrnecukfhppedugedrfedrieehrddujeehnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgr mhhotggthhhirdhjph 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; Fri, 21 May 2021 21:33:12 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 4/6] ALSA: firewire-lib: code refactoring for generation of syt sequence Date: Sat, 22 May 2021 10:33:01 +0900 Message-Id: <20210522013303.49596-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210522013303.49596-1-o-takashi@sakamocchi.jp> References: <20210522013303.49596-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 dissolves sequence generator in terms of syt offsets for packet. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 354512a350b7..77ae75e79a43 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -441,8 +441,30 @@ static unsigned int calculate_syt_offset(unsigned int *last_syt_offset, return syt_offset; } +static void pool_ideal_syt_offsets(struct amdtp_stream *s, struct seq_desc *descs, + const unsigned int seq_size, unsigned int seq_tail, + unsigned int count) +{ + const enum cip_sfc sfc = s->sfc; + unsigned int last = s->ctx_data.rx.last_syt_offset; + unsigned int state = s->ctx_data.rx.syt_offset_state; + int i; + + for (i = 0; i < count; ++i) { + struct seq_desc *desc = descs + seq_tail; + + desc->syt_offset = calculate_syt_offset(&last, &state, sfc); + + seq_tail = (seq_tail + 1) % seq_size; + } + + s->ctx_data.rx.last_syt_offset = last; + s->ctx_data.rx.syt_offset_state = state; +} + static void pool_ideal_seq_descs(struct amdtp_stream *s, unsigned int count) { + struct seq_desc *descs = s->ctx_data.rx.seq.descs; unsigned int seq_tail = s->ctx_data.rx.seq.tail; const unsigned int seq_size = s->ctx_data.rx.seq.size; const unsigned int syt_interval = s->syt_interval; @@ -450,11 +472,11 @@ static void pool_ideal_seq_descs(struct amdtp_stream *s, unsigned int count) const bool is_blocking = !!(s->flags & CIP_BLOCKING); int i; + pool_ideal_syt_offsets(s, descs, seq_size, seq_tail, count); + for (i = 0; i < count; ++i) { struct seq_desc *desc = s->ctx_data.rx.seq.descs + seq_tail; - desc->syt_offset = calculate_syt_offset(&s->ctx_data.rx.last_syt_offset, - &s->ctx_data.rx.syt_offset_state, sfc); desc->data_blocks = calculate_data_blocks(&s->ctx_data.rx.data_block_state, is_blocking, desc->syt_offset == CIP_SYT_NO_INFO, syt_interval, sfc); From patchwork Sat May 22 01:33:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 12274281 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 AE4C1C04FF3 for ; Sat, 22 May 2021 01:36:54 +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 354AD610A8 for ; Sat, 22 May 2021 01:36:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 354AD610A8 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 C34EC16C7; Sat, 22 May 2021 03:36:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C34EC16C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621647412; bh=H2ZwPCej+fErmRUM5KUY7uww8ZQMbn42untcqDwztUo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Ug5G5BlpQBynjbA0Y0Z4k7U/ssl2/Vi0eQACb0+0tLLy13PIfVNvGWduPmM+/m3Ke lH8sXCkEcsWJRQlwdoC2f/nPhi4MamSoROYis53ILkLgo1JyrYTdRosWLhdHgj0ILl 6V5OrkFMMa2v23PqrUKGrTg0DkM4q6h3QRzEmy/g= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F00A7F804CF; Sat, 22 May 2021 03:33:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0E39DF80257; Sat, 22 May 2021 03:33: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 D744CF800DF for ; Sat, 22 May 2021 03:33:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D744CF800DF Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="F3ohb6cU"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="plYguljF" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 1B9DC5C011A; Fri, 21 May 2021 21:33:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 21 May 2021 21:33:15 -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=bZZywP0mtjbMB QmsPlCcjWAkEBdwxMscO6uarEuPA1w=; b=F3ohb6cUGKYr84JfOJMCeYOAD3B+y 9XR5ePSmncegekUE+nnUc2yrlXIWyH8oVps5drVCssMOs5YrSyDZ3J+6koMtsJ+U wEBdd2ak0fJUGxwjM4iiJXD34e2lyk9WKjef+J3uTVV75Qiyvs8k78wQtI7dKUpw FJOyBWGoyRVYJFLP3T4/G5yUb7XpnUoakhkDgjp6NHgB0mu/IjMXgQnTLa1c/KR9 Xh6jxfFx/AKGfgaRcKhvJ7Wg72f67qrM/1u1I03dJqUst6peN9eV+jUuJ48ykuBE LqybEDte/YgQsyNwJZr4qPYq6sHM7A6PHfO0IgE54rTibvez8kiN8oicg== 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=bZZywP0mtjbMBQmsPlCcjWAkEBdwxMscO6uarEuPA1w=; b=plYguljF /07zYTWKrfBmZ8GUZ39IKgbAIB/TOoOE8PgaZ29lTbWj+TrzAF/xAOZz15IFHv6k nRI8Bc8PLXTU6wO5sRIEfBpHowIjiXhoe1henFmNOGWKqjuF2V8QOdY1ZkQ+WqoI UB174FzaaBDo4/rQnPcI6/YS1NsuXSv0SeVosRgbNcyn2BxgLUPeS9zSSqXg4s+O 6u+hDorXnn/eRumZC5WWJwXiCOyx6eLQp6gYbCifZ5HOB1gVQtK5WolmLKcmDF44 cCT5pktfXB1sHbsHq7WvIQddQrrzBIaTIhwSGHKUXiSh699Efj6Wsqb1NRHhiQU9 be5E7XrgibvqCQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejgedggeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepieetueeuvd elfedvteejteeiheeugeelvedvkeeffeffuedutdeifeeukeeutefgnecuffhomhgrihhn pehrgidruggrthgrnecukfhppedugedrfedrieehrddujeehnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgr mhhotggthhhirdhjph 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; Fri, 21 May 2021 21:33:14 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 5/6] ALSA: firewire-lib: code refactoring for generation of data block sequence Date: Sat, 22 May 2021 10:33:02 +0900 Message-Id: <20210522013303.49596-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210522013303.49596-1-o-takashi@sakamocchi.jp> References: <20210522013303.49596-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 dissolves sequence generator in terms of the number of data blocks per packet. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 73 +++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 77ae75e79a43..26209513199a 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -357,26 +357,41 @@ void amdtp_stream_pcm_prepare(struct amdtp_stream *s) } EXPORT_SYMBOL(amdtp_stream_pcm_prepare); -static unsigned int calculate_data_blocks(unsigned int *data_block_state, - bool is_blocking, bool is_no_info, - unsigned int syt_interval, enum cip_sfc sfc) +static void pool_blocking_data_blocks(struct amdtp_stream *s, struct seq_desc *descs, + const unsigned int seq_size, unsigned int seq_tail, + unsigned int count) { - unsigned int data_blocks; + const unsigned int syt_interval = s->syt_interval; + int i; + + for (i = 0; i < count; ++i) { + struct seq_desc *desc = descs + seq_tail; - /* Blocking mode. */ - if (is_blocking) { - /* This module generate empty packet for 'no data'. */ - if (is_no_info) - data_blocks = 0; + if (desc->syt_offset != CIP_SYT_NO_INFO) + desc->data_blocks = syt_interval; else - data_blocks = syt_interval; - /* Non-blocking mode. */ - } else { + desc->data_blocks = 0; + + seq_tail = (seq_tail + 1) % seq_size; + } +} + +static void pool_ideal_nonblocking_data_blocks(struct amdtp_stream *s, struct seq_desc *descs, + const unsigned int seq_size, unsigned int seq_tail, + unsigned int count) +{ + const enum cip_sfc sfc = s->sfc; + unsigned int state = s->ctx_data.rx.data_block_state; + int i; + + for (i = 0; i < count; ++i) { + struct seq_desc *desc = descs + seq_tail; + if (!cip_sfc_is_base_44100(sfc)) { // Sample_rate / 8000 is an integer, and precomputed. - data_blocks = *data_block_state; + desc->data_blocks = state; } else { - unsigned int phase = *data_block_state; + unsigned int phase = state; /* * This calculates the number of data blocks per packet so that @@ -388,18 +403,19 @@ static unsigned int calculate_data_blocks(unsigned int *data_block_state, */ if (sfc == CIP_SFC_44100) /* 6 6 5 6 5 6 5 ... */ - data_blocks = 5 + ((phase & 1) ^ - (phase == 0 || phase >= 40)); + desc->data_blocks = 5 + ((phase & 1) ^ (phase == 0 || phase >= 40)); else /* 12 11 11 11 11 ... or 23 22 22 22 22 ... */ - data_blocks = 11 * (sfc >> 1) + (phase == 0); + desc->data_blocks = 11 * (sfc >> 1) + (phase == 0); if (++phase >= (80 >> (sfc >> 1))) phase = 0; - *data_block_state = phase; + state = phase; } + + seq_tail = (seq_tail + 1) % seq_size; } - return data_blocks; + s->ctx_data.rx.data_block_state = state; } static unsigned int calculate_syt_offset(unsigned int *last_syt_offset, @@ -467,24 +483,15 @@ static void pool_ideal_seq_descs(struct amdtp_stream *s, unsigned int count) struct seq_desc *descs = s->ctx_data.rx.seq.descs; unsigned int seq_tail = s->ctx_data.rx.seq.tail; const unsigned int seq_size = s->ctx_data.rx.seq.size; - const unsigned int syt_interval = s->syt_interval; - const enum cip_sfc sfc = s->sfc; - const bool is_blocking = !!(s->flags & CIP_BLOCKING); - int i; pool_ideal_syt_offsets(s, descs, seq_size, seq_tail, count); - for (i = 0; i < count; ++i) { - struct seq_desc *desc = s->ctx_data.rx.seq.descs + seq_tail; - - desc->data_blocks = calculate_data_blocks(&s->ctx_data.rx.data_block_state, - is_blocking, desc->syt_offset == CIP_SYT_NO_INFO, - syt_interval, sfc); - - seq_tail = (seq_tail + 1) % seq_size; - } + if (s->flags & CIP_BLOCKING) + pool_blocking_data_blocks(s, descs, seq_size, seq_tail, count); + else + pool_ideal_nonblocking_data_blocks(s, descs, seq_size, seq_tail, count); - s->ctx_data.rx.seq.tail = seq_tail; + s->ctx_data.rx.seq.tail = (seq_tail + count) % seq_size; } static void update_pcm_pointers(struct amdtp_stream *s, From patchwork Sat May 22 01:33:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 12274279 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 972FAC04FF3 for ; Sat, 22 May 2021 01:36:41 +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 5F8AE610A8 for ; Sat, 22 May 2021 01:36:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F8AE610A8 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 B58F216CD; Sat, 22 May 2021 03:35:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B58F216CD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621647398; bh=TR0cErReRtApcHkyAKlcCdq18dXUl25mpM+aydXckCM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=W1ju9AiH3vyAXnAzw/+FousPW1u9D5MKvviuITVbmDWgM19MeaVWi6lNZNe0aaRvw baMoEth6Ta+oYkh+BjTDk8HhdU1CoNifnZ9jIGPXuYhRAiqLSWTQVJ/aCzTHCWw/Hw FrB/wsP+nEs+y/arBkiXYNnhLWQZoEkUlxHx8NUg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 44F58F804B2; Sat, 22 May 2021 03:33:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8B8D2F80229; Sat, 22 May 2021 03:33: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 23884F80272 for ; Sat, 22 May 2021 03:33:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 23884F80272 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="FilX2mAW"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="kPVGbcOV" Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5C80A5C0136; Fri, 21 May 2021 21:33:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 21 May 2021 21:33:16 -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=jatAEoUb4MRny R8XSwqqEWDxkjc5gyrlNYOQnlbSxRQ=; b=FilX2mAWvrgxRW92amKWmXG0Q/grW 1Pk2JHgZQEhP3ew41Cp3AhKDxALI/L32fvv0SCO2ZaNZHxCUupwx+i9l1WhdRhYZ g28e7tr3YZtYruV8elsW+bfMto1h5sw9LSa7XyUOnbGZsoC03coNOiTH9NT0NwMm jz5TqgibpFMgn/72GF5OJc4/z0NC+hyjq4IHN2eqmk7HcO0oi4ITLmWt/Y015jth tgn9Haj69/bpRJTY5Fx7WlPgmc0jykAIeG9UhRHovb3n06hAne2dJM3FcP+MsqpN NpF0rdhU5sui4xx1619o3p+Gl9tTqvkB65WKwC7AHbmQ2kMM4AcdcpYFg== 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=jatAEoUb4MRnyR8XSwqqEWDxkjc5gyrlNYOQnlbSxRQ=; b=kPVGbcOV 0b6XzT0lyTfcO/lrwlFe5Fsw6pGWTML3usWKcx9ycRh4x2iKz5+PK5X+4vSV4C8y A+fGuHAYbELIPBUaEXor+nKQEs3LVN6ATmxnv/ozYucsNUFwqj8w60KsIwRTDkMe DgomeAL2ydQoFlN8DRl+1bjbJKri3HLybVvZD46bXcfwFVRxe3vwd1jgCcj3M0DV 7qdlocnl4OGx2iE5xD9z3A+9qXwmyeP4GBWP4hZ62fW59t4m/JwXVclXIKogEF8D rwkNlYs1XzLhC7fJfLytqDbBibo47aG+vPkrjWll/hVtfc0xKqDezG//paMtBsRd IZPi7sZMepTZew== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejgedggeekucetufdoteggodetrfdotf 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; Fri, 21 May 2021 21:33:15 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 6/6] ALSA: firewire-lib: code refactoring for transfer delay Date: Sat, 22 May 2021 10:33:03 +0900 Message-Id: <20210522013303.49596-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210522013303.49596-1-o-takashi@sakamocchi.jp> References: <20210522013303.49596-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" In later commit, transfer delay is used in both IR and IT contexts. This commit refactors regardless of transfer delay. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 24 ++++++++---------------- sound/firewire/amdtp-stream.h | 7 +++---- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 26209513199a..6dceb8cd6e0c 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -294,17 +294,11 @@ int amdtp_stream_set_parameters(struct amdtp_stream *s, unsigned int rate, s->syt_interval = amdtp_syt_intervals[sfc]; // default buffering in the device. - if (s->direction == AMDTP_OUT_STREAM) { - s->ctx_data.rx.transfer_delay = - TRANSFER_DELAY_TICKS - TICKS_PER_CYCLE; - - if (s->flags & CIP_BLOCKING) { - // additional buffering needed to adjust for no-data - // packets. - s->ctx_data.rx.transfer_delay += - TICKS_PER_SECOND * s->syt_interval / rate; - } - } + s->transfer_delay = TRANSFER_DELAY_TICKS - TICKS_PER_CYCLE; + + // additional buffering needed to adjust for no-data packets. + if (s->flags & CIP_BLOCKING) + s->transfer_delay += TICKS_PER_SECOND * s->syt_interval / rate; return 0; } @@ -897,12 +891,10 @@ static void generate_pkt_descs(struct amdtp_stream *s, const __be32 *ctx_header, desc->cycle = compute_ohci_it_cycle(*ctx_header, s->queue_size); - if (aware_syt && seq->syt_offset != CIP_SYT_NO_INFO) { - desc->syt = compute_syt(seq->syt_offset, desc->cycle, - s->ctx_data.rx.transfer_delay); - } else { + if (aware_syt && seq->syt_offset != CIP_SYT_NO_INFO) + desc->syt = compute_syt(seq->syt_offset, desc->cycle, s->transfer_delay); + else desc->syt = CIP_SYT_NO_INFO; - } desc->data_blocks = seq->data_blocks; diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index fc653fe95405..467d5021624b 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h @@ -140,15 +140,13 @@ struct amdtp_stream { unsigned int dbc_interval; } tx; struct { - // To calculate CIP data blocks and tstamp. - unsigned int transfer_delay; - // To generate CIP header. unsigned int fdf; // To generate constant hardware IRQ. unsigned int event_count; + // To calculate CIP data blocks and tstamp. struct { struct seq_desc *descs; unsigned int size; @@ -169,7 +167,8 @@ struct amdtp_stream { unsigned int sph; unsigned int fmt; - /* Internal flags. */ + // Internal flags. + unsigned int transfer_delay; enum cip_sfc sfc; unsigned int syt_interval;