From patchwork Thu May 23 15:14:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10957977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6BE4176 for ; Thu, 23 May 2019 15:15:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54D6728498 for ; Thu, 23 May 2019 15:15:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 492832867C; Thu, 23 May 2019 15:15:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1F91628498 for ; Thu, 23 May 2019 15:15:46 +0000 (UTC) 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 E1EFC1612; Thu, 23 May 2019 17:14:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E1EFC1612 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1558624545; bh=eF3I6phcHsStD3ZIKhP7GnJ9es73E1imaGzr1B3PLTo=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PQwIzPIB8lTZEGiw33RaCvUUCYg+psoyb/ZrOnQD0KxSK83m3rlEXJHSHoWdxHWBl 1FuwhZnymdCuC9zWtc1q0ua671HxdD74ZZ1sTzfvJGW91YWIr7XhN830bQSqOSnU0d A1C7zswa7tPbqM0frIV0s166vvIBk2H3jNidtazs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5352BF89674; Thu, 23 May 2019 17:14:54 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1EACAF8079B; Thu, 23 May 2019 17:14:52 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id ABC0FF80C0F for ; Thu, 23 May 2019 17:14:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz ABC0FF80C0F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="fSAgoKBX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="a6cbG1y+" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 0D5FC37DDC; Thu, 23 May 2019 11:14:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 23 May 2019 11:14:47 -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=+ES85RX80tVDi 6mCI4BZCDSoT+9xAXAkgtSrOyrL8i4=; b=fSAgoKBXHkWjYfxfa2MgjA9jUorGq 6XGOiGOvna16CULjCyd5+xVjthSCOPMKXGFZMGBLWysfRxZNKaJh0HPcvxyUkQOY sicWoKiIcm9oUPyAByZ2q9Ci0UtqugXYdAdXBdcn1TvknlIv3JW4vak5HpK+4cI0 DBXNiaNcwdIhKD98cfu5YXwbiOIYiLPnKzEIkhraybsZ+3Piae2tYnivjtJLEdSr mk7mkLIm9VHDBTBSAmT7oyMx6ObaeOrte0WXzURweOhfSVZUwvI9O/I6ZwGvz7Bf c5rfylmlmJ3v6OZ6HeWwLPbRC1Jj5lW7wDbiAWBABp9Aqhdkwlk2aVyNA== 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=+ES85RX80tVDi6mCI4BZCDSoT+9xAXAkgtSrOyrL8i4=; b=a6cbG1y+ jJIUA+Y2kv8FNW+UA2YyeBhZ+IBBmO/PS01Yvfi6yqeAZGnL+vAV/1cwAvRw3Kfi R6H853lAN3U/sbrjUbrNuUKX3Q1cy/GwSBZ2GW/X7B3cN+se6E//O5m0UaryBofw fnbyLPXIij2UhmHPc+I5cObz0IN7gL/y+SApQi30zpL9pWDMUOjit4yFM5w2Uzjy 5PP9FM47QoQ8Lm1ZMih0HAVFWHOzLagTfY4FzLZcXKv4pmYqpQ6Ti7MTnpVL64mm FJqraalAqOvmHcUn9qPgCu6KDF1+C6McyIh06iCM8hcL9lO6SXECAh6EwyACgu1c ghObVs9/sKR2Wg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddugedgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost.localdomain (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 92FA938008B; Thu, 23 May 2019 11:14:45 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Fri, 24 May 2019 00:14:37 +0900 Message-Id: <20190523151440.5127-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523151440.5127-1-o-takashi@sakamocchi.jp> References: <20190523151440.5127-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 1/4] ALSA: firewire-lib: split helper function to generate CIP header 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" X-Virus-Scanned: ClamAV using ClamSMTP This is minor code refactoring to split a function to generate CIP header. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 2d9c764061d1..25985663bb2b 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -477,6 +477,19 @@ static inline int queue_in_packet(struct amdtp_stream *s) return queue_packet(s, s->ctx_data.tx.max_ctx_payload_length); } +static void generate_cip_header(struct amdtp_stream *s, __be32 cip_header[2], + unsigned int syt) +{ + cip_header[0] = cpu_to_be32(READ_ONCE(s->source_node_id_field) | + (s->data_block_quadlets << CIP_DBS_SHIFT) | + ((s->sph << CIP_SPH_SHIFT) & CIP_SPH_MASK) | + s->data_block_counter); + cip_header[1] = cpu_to_be32(CIP_EOH | + ((s->fmt << CIP_FMT_SHIFT) & CIP_FMT_MASK) | + ((s->ctx_data.rx.fdf << CIP_FDF_SHIFT) & CIP_FDF_MASK) | + (syt & CIP_SYT_MASK)); +} + static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle, const __be32 *ctx_header, __be32 *buffer, unsigned int index) @@ -495,14 +508,7 @@ static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle, s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff; - buffer[0] = cpu_to_be32(READ_ONCE(s->source_node_id_field) | - (s->data_block_quadlets << CIP_DBS_SHIFT) | - ((s->sph << CIP_SPH_SHIFT) & CIP_SPH_MASK) | - s->data_block_counter); - buffer[1] = cpu_to_be32(CIP_EOH | - ((s->fmt << CIP_FMT_SHIFT) & CIP_FMT_MASK) | - ((s->ctx_data.rx.fdf << CIP_FDF_SHIFT) & CIP_FDF_MASK) | - (syt & CIP_SYT_MASK)); + generate_cip_header(s, buffer, syt); if (!(s->flags & CIP_DBC_IS_END_EVENT)) s->data_block_counter = From patchwork Thu May 23 15:14:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10957993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4985924 for ; Thu, 23 May 2019 15:18:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDDCC283EE for ; Thu, 23 May 2019 15:18:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B260A28630; Thu, 23 May 2019 15:18:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D41A0285D2 for ; Thu, 23 May 2019 15:18:06 +0000 (UTC) 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 226031664; Thu, 23 May 2019 17:17:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 226031664 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1558624685; bh=SQBOw1bi2c0IE1hHQNpfPs1ZCLIB6HGPypH7cL+a8qk=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=XfbTRwXmQWhwN+wDBbUItJfbehiYlDcUblfPCB8j3SIvTJJjri6hWS1NBd5Y50O3i ubMHTF9c8oBs6rjL0TbgW3ZqyiIwSim2O2pK09BhlyYvpw87vCgifmDv7HELLZkoPG BP7cphVRJaf4DzJFNhajuPJPovF9ucyP4c7Xfpts= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DC857F8972F; Thu, 23 May 2019 17:15:03 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id D2EDEF89707; Thu, 23 May 2019 17:14:53 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C694BF89674 for ; Thu, 23 May 2019 17:14:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C694BF89674 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="G6d4IeWy"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="L9hzU4VF" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 8A22437DAB; Thu, 23 May 2019 11:14:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 23 May 2019 11:14:48 -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=XntJvue0Smulw a9zkUNITnZe46BRfTgn17lwV5xcSwk=; b=G6d4IeWyfn7K5jiFgqY92Yh/HRoCK qZd595lR+cWujZMXW6cdOXH4Hn8MfwOF3S+oUKLOnVo5Q5r/81LIO7ea1vxqr4GH HgGst/RZe8gGG3S5lg5S6txXvXIA+0iI4pli60fjpugB4+NgTBwPy+k4Uj8S0EMP hqUwiRHcTXrQ5RI+MwZeX2iNjY9Ly2IgMaZwUKxqHFXxt0k2VUYgryKs6/ZxJ7m1 xPkUoMtBQwNZsQUWDn93zW3T2Yjsif8XlTIZPkOQtMxjGegSCOnxPCV8Ey0y66hG dRfZV1qu20f2KdJY9iq05F2zbklHepD8EGQPjvXRUlF1hVW3k0EkfpkDA== 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=XntJvue0Smulwa9zkUNITnZe46BRfTgn17lwV5xcSwk=; b=L9hzU4VF djftEnVXLSCdWIXlyK1UEOPX4Qk0xT+yhHZC4Q7P+YRMT/EpZcOoYlTjpbas8vJk 7G21dYjB64INqKfid6dKGN9/RhzMAzPP8Dl4scyc0yfJgOEtldsNWyB05RrIv/Xr n20HxaCaTVb0JTJJy48SBnRmrQRM4wKhIWGITw+vn8Xkb0w4jesQ0IsH3WYrxHh2 Go8hXeKDjAWdx0C03dbyRUyqkARwyUFCPrUGuz3IRUayrb6KwglaTGt1JCzi7F/x /q+Drwy+6+D/1esKzgZINgwszPHnQ+Imk03an5jH4XSgdWjOiIxxZZQbnH9JGPMP efoCDRsylKtv2w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddugedgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost.localdomain (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 21B9E38008B; Thu, 23 May 2019 11:14:46 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Fri, 24 May 2019 00:14:38 +0900 Message-Id: <20190523151440.5127-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523151440.5127-1-o-takashi@sakamocchi.jp> References: <20190523151440.5127-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 2/4] ALSA: firewire-lib: unify packet handler for IT context 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" X-Virus-Scanned: ClamAV using ClamSMTP The handlers for packet with CIP and without CIP include common codes. This commit unifies them and remove an member for pointer to callback function from data structure. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 59 +++++++++++------------------------ sound/firewire/amdtp-stream.h | 3 -- 2 files changed, 18 insertions(+), 44 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 25985663bb2b..b11a8d244f89 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -496,56 +496,38 @@ static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle, { unsigned int syt; unsigned int data_blocks; - unsigned int pcm_frames; unsigned int payload_length; + __be32 *cip_header; + unsigned int pcm_frames; struct snd_pcm_substream *pcm; syt = calculate_syt(s, cycle); data_blocks = calculate_data_blocks(s, syt); - pcm_frames = s->process_data_blocks(s, buffer + 2, data_blocks, &syt); + + payload_length = data_blocks * sizeof(__be32) * s->data_block_quadlets; + if (!(s->flags & CIP_NO_HEADER)) { + cip_header = buffer; + buffer += 2; + payload_length += 2 * sizeof(__be32); + } else { + cip_header = NULL; + } + + pcm_frames = s->process_data_blocks(s, buffer, data_blocks, &syt); if (s->flags & CIP_DBC_IS_END_EVENT) s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff; - generate_cip_header(s, buffer, syt); + if (cip_header) + generate_cip_header(s, cip_header, syt); if (!(s->flags & CIP_DBC_IS_END_EVENT)) s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff; - payload_length = 8 + data_blocks * 4 * s->data_block_quadlets; - trace_amdtp_packet(s, cycle, buffer, payload_length, data_blocks, index); - - if (queue_out_packet(s, payload_length) < 0) - return -EIO; - - pcm = READ_ONCE(s->pcm); - if (pcm && pcm_frames > 0) - update_pcm_pointers(s, pcm, pcm_frames); - - /* No need to return the number of handled data blocks. */ - return 0; -} - -static int handle_out_packet_without_header(struct amdtp_stream *s, - unsigned int cycle, const __be32 *ctx_header, - __be32 *buffer, unsigned int index) -{ - unsigned int syt; - unsigned int data_blocks; - unsigned int pcm_frames; - unsigned int payload_length; - struct snd_pcm_substream *pcm; - - syt = calculate_syt(s, cycle); - data_blocks = calculate_data_blocks(s, syt); - pcm_frames = s->process_data_blocks(s, buffer, data_blocks, &syt); - s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff; - - payload_length = data_blocks * 4 * s->data_block_quadlets; - - trace_amdtp_packet(s, cycle, NULL, payload_length, data_blocks, index); + trace_amdtp_packet(s, cycle, cip_header, payload_length, data_blocks, + index); if (queue_out_packet(s, payload_length) < 0) return -EIO; @@ -554,7 +536,6 @@ static int handle_out_packet_without_header(struct amdtp_stream *s, if (pcm && pcm_frames > 0) update_pcm_pointers(s, pcm, pcm_frames); - /* No need to return the number of handled data blocks. */ return 0; } @@ -766,7 +747,7 @@ static void out_stream_callback(struct fw_iso_context *context, u32 tstamp, cycle = compute_it_cycle(*ctx_header); buffer = s->buffer.packets[s->packet_index].buffer; - if (s->handle_packet(s, cycle, ctx_header, buffer, i) < 0) { + if (handle_out_packet(s, cycle, ctx_header, buffer, i) < 0) { cancel_stream(s); return; } @@ -837,10 +818,6 @@ static void amdtp_stream_first_callback(struct fw_iso_context *context, cycle = compute_it_cycle(*ctx_header); context->callback.sc = out_stream_callback; - if (s->flags & CIP_NO_HEADER) - s->handle_packet = handle_out_packet_without_header; - else - s->handle_packet = handle_out_packet; } s->start_cycle = cycle; diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index 234483a31df5..3942894c11ac 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h @@ -108,9 +108,6 @@ struct amdtp_stream { struct iso_packets_buffer buffer; int packet_index; int tag; - int (*handle_packet)(struct amdtp_stream *s, unsigned int cycle, - const __be32 *ctx_header, __be32 *buffer, - unsigned int index); union { struct { unsigned int ctx_header_size; From patchwork Thu May 23 15:14:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10957983 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4E44924 for ; Thu, 23 May 2019 15:17:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEF682863F for ; Thu, 23 May 2019 15:17:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD5BB2864A; Thu, 23 May 2019 15:17:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CD59F28681 for ; Thu, 23 May 2019 15:17:27 +0000 (UTC) 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 15120167D; Thu, 23 May 2019 17:16:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 15120167D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1558624646; bh=mlRxytvKbxS/lwwkmBml+3uAvYICl5uKTeUVb9GMZ1I=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LXg3tf0MY+ChH1L0kWyajq2+y+b/UtTuvkKQw1tzNuzmgjui7c9i4A8rl8wg644lc OMivZQNuPIedZnVvPeQ8HwmSgTXUPuapJEZwF/5EQqCqaUOMXX2wVuztteD3rjOPXT mbaFtLHGnie9DYxRmZN1S1tM6G2TX7+CoSQqf01k= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C5F1FF89728; Thu, 23 May 2019 17:15:02 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id A9FE4F89709; Thu, 23 May 2019 17:14:53 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BD783F89670 for ; Thu, 23 May 2019 17:14:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BD783F89670 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="VhxKx3QW"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dmH8ZNdB" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id F21F437DD4; Thu, 23 May 2019 11:14:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 23 May 2019 11:14:49 -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=omoFkryS/jHEj W9aALbE4VHBB1vfXBzmjgCiOnFFxPs=; b=VhxKx3QWv/3mKR7SiS31KHl+rHhan RHeDqXnn3nXsDsYFWvZakWFli/5gMKzLa1YQh3neMUWdFOIvufLrpubm4rR2MEZJ It4t6/If0THfFxvaAHzQY9JIpYEc1sy3X9NpgMuFPVz3Aqew+Sro3wWjamEX4IFH UTKSqiXAK/EEhyt6C1SWwE8n1gsgGvFogaGtj+5xmtTnyYHjJ+dJPi71dn7+X9Bi XuJmlK3gUNLqQxxJl4gnLKwehWMuZ1mQTCd9k0yOX4L/1fPKOihuLP1E4J5EVhmf 86Lkj4V47mRve5XkWoZFlkdDVfqlfygnX8V25nLfq7PND121qwwHiwiMA== 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=omoFkryS/jHEjW9aALbE4VHBB1vfXBzmjgCiOnFFxPs=; b=dmH8ZNdB hHB6jPtnW9CVubmSr/A9FKH7mjenUSewdNiOw0t96OE92hipqcOXVu8yGjylzq0K VKiAKahC/b7bwWtSrtTSeEfrcNTkc2CY669o+viCUxsZQDgrfvH41qJ6WR+fDayf cz2EvW8rkoMLTcWmTnKZmWcuoDRHZI0W/qOIk4dynhLcYyUkDqKnGdaL8h3KpeOG 3KrZPlQO0dQgK0WIpryNCee4jFlwpNK58L+95ebTrn7Aa+6T0YXRzq6UpyVe6OT6 R8kHrb68DXc8Vgpuqa2fkyvq3IHhuxcyAs+/bz64TI9vHji2JAKocltm2imy9+8w od/IyEva72kzIQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddugedgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost.localdomain (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 932EA380088; Thu, 23 May 2019 11:14:48 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Fri, 24 May 2019 00:14:39 +0900 Message-Id: <20190523151440.5127-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523151440.5127-1-o-takashi@sakamocchi.jp> References: <20190523151440.5127-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 3/4] ALSA: firewire-lib: code refactoring to queueing packets 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" X-Virus-Scanned: ClamAV using ClamSMTP This commit is a preparation to queue IT packet with header. To enable packet handler to fill the header, this commit uses kernel stack for data structure of packet parameter in several part of this file. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 54 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index b11a8d244f89..e813d31ff2ad 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -430,30 +430,15 @@ static void pcm_period_tasklet(unsigned long data) snd_pcm_period_elapsed(pcm); } -static int queue_packet(struct amdtp_stream *s, unsigned int payload_length) +static int queue_packet(struct amdtp_stream *s, struct fw_iso_packet *params) { - struct fw_iso_packet p = {0}; - int err = 0; - - if (IS_ERR(s->context)) - goto end; - - p.interrupt = IS_ALIGNED(s->packet_index + 1, INTERRUPT_INTERVAL); - p.tag = s->tag; + int err; - if (s->direction == AMDTP_IN_STREAM) { - // Queue one packet for IR context. - p.header_length = s->ctx_data.tx.ctx_header_size; - } else { - // No header for this packet. - p.header_length = 0; - } + params->interrupt = IS_ALIGNED(s->packet_index + 1, INTERRUPT_INTERVAL); + params->tag = s->tag; + params->sy = 0; - if (payload_length > 0) - p.payload_length = payload_length; - else - p.skip = true; - err = fw_iso_context_queue(s->context, &p, &s->buffer.iso_buffer, + err = fw_iso_context_queue(s->context, params, &s->buffer.iso_buffer, s->buffer.packets[s->packet_index].offset); if (err < 0) { dev_err(&s->unit->device, "queueing error: %d\n", err); @@ -467,14 +452,24 @@ static int queue_packet(struct amdtp_stream *s, unsigned int payload_length) } static inline int queue_out_packet(struct amdtp_stream *s, + struct fw_iso_packet *params, unsigned int payload_length) { - return queue_packet(s, payload_length); + // No header for this packet. + params->header_length = 0; + params->payload_length = payload_length; + params->skip = !!(payload_length == 0); + return queue_packet(s, params); } -static inline int queue_in_packet(struct amdtp_stream *s) +static inline int queue_in_packet(struct amdtp_stream *s, + struct fw_iso_packet *params) { - return queue_packet(s, s->ctx_data.tx.max_ctx_payload_length); + // Queue one packet for IR context. + params->header_length = s->ctx_data.tx.ctx_header_size; + params->payload_length = s->ctx_data.tx.max_ctx_payload_length; + params->skip = false; + return queue_packet(s, params); } static void generate_cip_header(struct amdtp_stream *s, __be32 cip_header[2], @@ -500,6 +495,7 @@ static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle, __be32 *cip_header; unsigned int pcm_frames; struct snd_pcm_substream *pcm; + struct fw_iso_packet params = {0}; syt = calculate_syt(s, cycle); data_blocks = calculate_data_blocks(s, syt); @@ -529,7 +525,7 @@ static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle, trace_amdtp_packet(s, cycle, cip_header, payload_length, data_blocks, index); - if (queue_out_packet(s, payload_length) < 0) + if (queue_out_packet(s, ¶ms, payload_length) < 0) return -EIO; pcm = READ_ONCE(s->pcm); @@ -651,6 +647,7 @@ static int handle_in_packet(struct amdtp_stream *s, unsigned int cycle, unsigned int data_blocks; struct snd_pcm_substream *pcm; unsigned int pcm_frames; + struct fw_iso_packet params = {0}; int err; payload_length = be32_to_cpu(ctx_header[0]) >> ISO_DATA_LENGTH_SHIFT; @@ -684,7 +681,7 @@ static int handle_in_packet(struct amdtp_stream *s, unsigned int cycle, pcm_frames = s->process_data_blocks(s, buffer, data_blocks, &syt); end: - if (queue_in_packet(s) < 0) + if (queue_in_packet(s, ¶ms) < 0) return -EIO; pcm = READ_ONCE(s->pcm); @@ -920,10 +917,11 @@ int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed) s->packet_index = 0; do { + struct fw_iso_packet params; if (s->direction == AMDTP_IN_STREAM) - err = queue_in_packet(s); + err = queue_in_packet(s, ¶ms); else - err = queue_out_packet(s, 0); + err = queue_out_packet(s, ¶ms, 0); if (err < 0) goto err_context; } while (s->packet_index > 0); From patchwork Thu May 23 15:14:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10958025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6ADB1708 for ; Thu, 23 May 2019 15:18:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBF0328613 for ; Thu, 23 May 2019 15:18:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0B2128671; Thu, 23 May 2019 15:18:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DCD2A28685 for ; Thu, 23 May 2019 15:18:46 +0000 (UTC) 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 187071657; Thu, 23 May 2019 17:17:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 187071657 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1558624725; bh=qbspKpb0HGer/kftASrSCvVxwdldFHyvdz0Yo1dJvCA=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=gOEaEyHB6vylx1pOTELcDh1AM9jzk/5VZd3JJMKt2v9L8OAbpH9fEM9/0tWHiDCgp 9zhxBuQ1X7p+eT4trBhEONkRbMANqk1+tlvCeix821GXVi9CY5EHtbDvb7HMMGyy2t ctLRxE3nec2b2qMiHzcNGnjouWoog/WsjKGjLZs0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4D2E8F89734; Thu, 23 May 2019 17:15:06 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9A94FF8970D; Thu, 23 May 2019 17:14:55 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2F208F80C0F for ; Thu, 23 May 2019 17:14:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2F208F80C0F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="QaIoMZrj"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="3Dg1/jlK" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 5BECF37DAB; Thu, 23 May 2019 11:14:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 23 May 2019 11:14:51 -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=99il51+DrxaeM MP7JfK1YyXn8XT8SHbC6PirE6gxxFw=; b=QaIoMZrjm6sT1EWtnLrf3FPwsXAC6 xmr0Dl8dev/D6uYye7ZeakDemEf0bEsFEx6o4+C4pUqjKJywehxuOVj1aCBaKFdQ WuurCu1k1qc6u2DuHmFqFAg5dP3LA7phi83xU2oBPS8E3FnwT8FcZpX2LaMDdoxX 1ny3bIKWzK/myID8k6hZ5dCrezLY4Sl8F7HUbY00a0bFt5KfI25SmOEmv5zUceOM 7+NG7YC3p1QUcTIKMKh9O8E5YUW7NfdWhRwk6p4D+arVAagTfGn5XBE+Bl95yZwj BxjaHVBdv0RhTQjFr+Yx7UKsTN9jgr7RypnpQ5lTqya7hzJg9774D4ZrQ== 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=99il51+DrxaeMMP7JfK1YyXn8XT8SHbC6PirE6gxxFw=; b=3Dg1/jlK N6Dfan7CB5ELsDVdH9YlDK6k7oZP5DvowbYtHAKClV+2WmrRQpGGwe+COPCump9o H03OZNEbLE0AeqAUqt3RJZf3hFj+coyfGiEObK0pYJVI2rWmGSCz2k3P4IHGKjSS 4LXkGF2uarQ7W4aFplJVr8kVnGJVaqgXuxEgYyKdFfoNRkBN89J60LFYuZp5YHKL dfgQw9zcMr2oRLZCw+1xRw9oRVJZ3CiZKs5++mp1yvOsZM9aWMiGt7L8TOV3OCFI MpCrn81cfjy27D74ffurU7bF83ykpZFoSvconlnL+rUTP5YfjQcfUkGqMcyGUyPH OxlGYsUPoCgWMQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddugedgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost.localdomain (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 0DB35380088; Thu, 23 May 2019 11:14:49 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Fri, 24 May 2019 00:14:40 +0900 Message-Id: <20190523151440.5127-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523151440.5127-1-o-takashi@sakamocchi.jp> References: <20190523151440.5127-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 4/4] ALSA: firewire-lib: use 8 byte packet header for IT context to separate CIP header from CIP payload 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" X-Virus-Scanned: ClamAV using ClamSMTP In Linux firewire subsystem, for IT context, some quadlets of isochronous packet payload can be indicated as a part of packet header to queue to the context. This commit uses the packet header to split CIP headers from CIP payload. As a result, regardless of CIP or non-CIP, context payload includes data blocks only. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 63 +++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index e813d31ff2ad..791efa5585c2 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -62,6 +62,9 @@ #define IR_CTX_HEADER_SIZE_NO_CIP 8 #define HEADER_TSTAMP_MASK 0x0000ffff +#define IT_PKT_HEADER_SIZE_CIP 8 // For 2 CIP header. +#define IT_PKT_HEADER_SIZE_NO_CIP 0 // Nothing. + static void pcm_period_tasklet(unsigned long data); /** @@ -452,13 +455,10 @@ static int queue_packet(struct amdtp_stream *s, struct fw_iso_packet *params) } static inline int queue_out_packet(struct amdtp_stream *s, - struct fw_iso_packet *params, - unsigned int payload_length) + struct fw_iso_packet *params) { - // No header for this packet. - params->header_length = 0; - params->payload_length = payload_length; - params->skip = !!(payload_length == 0); + params->skip = + !!(params->header_length == 0 && params->payload_length == 0); return queue_packet(s, params); } @@ -491,41 +491,41 @@ static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle, { unsigned int syt; unsigned int data_blocks; - unsigned int payload_length; __be32 *cip_header; unsigned int pcm_frames; struct snd_pcm_substream *pcm; - struct fw_iso_packet params = {0}; + struct { + struct fw_iso_packet params; + __be32 header[IT_PKT_HEADER_SIZE_CIP / sizeof(__be32)]; + } template = { {0}, {0} }; syt = calculate_syt(s, cycle); data_blocks = calculate_data_blocks(s, syt); - - payload_length = data_blocks * sizeof(__be32) * s->data_block_quadlets; - if (!(s->flags & CIP_NO_HEADER)) { - cip_header = buffer; - buffer += 2; - payload_length += 2 * sizeof(__be32); - } else { - cip_header = NULL; - } - pcm_frames = s->process_data_blocks(s, buffer, data_blocks, &syt); if (s->flags & CIP_DBC_IS_END_EVENT) s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff; - if (cip_header) + if (!(s->flags & CIP_NO_HEADER)) { + cip_header = (__be32 *)template.params.header; generate_cip_header(s, cip_header, syt); + template.params.header_length = 2 * sizeof(__be32); + } else { + cip_header = NULL; + } if (!(s->flags & CIP_DBC_IS_END_EVENT)) s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff; - trace_amdtp_packet(s, cycle, cip_header, payload_length, data_blocks, - index); + template.params.payload_length = + data_blocks * sizeof(__be32) * s->data_block_quadlets; + + trace_amdtp_packet(s, cycle, cip_header, template.params.payload_length, + data_blocks, index); - if (queue_out_packet(s, ¶ms, payload_length) < 0) + if (queue_out_packet(s, &template.params) < 0) return -EIO; pcm = READ_ONCE(s->pcm); @@ -878,14 +878,18 @@ int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed) ctx_header_size = IR_CTX_HEADER_SIZE_CIP; else ctx_header_size = IR_CTX_HEADER_SIZE_NO_CIP; + + max_ctx_payload_size = amdtp_stream_get_max_payload(s) - + ctx_header_size; } else { dir = DMA_TO_DEVICE; type = FW_ISO_CONTEXT_TRANSMIT; ctx_header_size = 0; // No effect for IT context. - } - max_ctx_payload_size = amdtp_stream_get_max_payload(s) - - ctx_header_size; + max_ctx_payload_size = amdtp_stream_get_max_payload(s); + if (!(s->flags & CIP_NO_HEADER)) + max_ctx_payload_size -= IT_PKT_HEADER_SIZE_CIP; + } err = iso_packets_buffer_init(&s->buffer, s->unit, QUEUE_LENGTH, max_ctx_payload_size, dir); @@ -918,10 +922,13 @@ int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed) s->packet_index = 0; do { struct fw_iso_packet params; - if (s->direction == AMDTP_IN_STREAM) + if (s->direction == AMDTP_IN_STREAM) { err = queue_in_packet(s, ¶ms); - else - err = queue_out_packet(s, ¶ms, 0); + } else { + params.header_length = 0; + params.payload_length = 0; + err = queue_out_packet(s, ¶ms); + } if (err < 0) goto err_context; } while (s->packet_index > 0);