From patchwork Mon Jun 17 08:15:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10998309 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 C327A6C5 for ; Mon, 17 Jun 2019 08:16:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4F59287FF for ; Mon, 17 Jun 2019 08:16:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A650128841; Mon, 17 Jun 2019 08:16:19 +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 9F6D5287FF for ; Mon, 17 Jun 2019 08:16:18 +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 418021756; Mon, 17 Jun 2019 10:15:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 418021756 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560759376; bh=QHZujfd6QmSwbX9fMXN+mRtsUEki64JYpX/IxNH2Ja4=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Y0uIELacc0sjpQQUFs7K5d8fbQF6EgfRvC5iZTtNKR+eSCtARW0+F/GA+hOXQzB0h wXERwwRr2+fErfh539VsSYo1G6T3IA87C4TCfMtHf7HyZKxAfQtIQhjZTUQVtv8dCo wZy0NfmV4KymhovVK0UT1Ozju5pcfj6O7OQ1NRkc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 89D2EF896DA; Mon, 17 Jun 2019 10:15:25 +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 83BBAF896F9; Mon, 17 Jun 2019 10:15:23 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 78241F89693 for ; Mon, 17 Jun 2019 10:15:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 78241F89693 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="NxNhg9VY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="07Bh9gGB" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 66F7A731; Mon, 17 Jun 2019 04:15:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 17 Jun 2019 04:15:17 -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=9QLFgYnfN0NIZ J91VRhjLxlm6zRtmHE2az5Sx/cCtuI=; b=NxNhg9VYvdfpB+pFh5yDxPI/iTLKT 9eCkHI19YfZ/OJZpNNrKSnxk5XItgVcatYQYge387iBp5KF40BRHQqHlwE+1Jqxn x2nEVc2jLxQfDFUfVmyCCK5PBHCLk/05FkWZF/Yl7XCcPE942KDn55bL6OpMRDsL 7Nc8ngqqIvXQpcHlRvmVKYiXeIvdWR7+SKTHyAX9rBY92Yot1tbcLocVIb1pH6ci OoR41koGWOWK8jfquW1CzpBuJr2fL0AvOhYirB+9mjyCHUgxKQNX4IxY+CriFD6h ooeS+2+JUDO+d8JBkEpAV85PXMRTCyV+VSc2j5LpxcNaVpwXKZLl+a/XA== 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= fm3; bh=9QLFgYnfN0NIZJ91VRhjLxlm6zRtmHE2az5Sx/cCtuI=; b=07Bh9gGB TACvNiuFJ2sazT429T3mzm8nq46cTVekvEAmQ+i6XpSnqILF5ZbitloYMgB/sEeU xTErKE2NnPb0lBe+bd6ZzeDU4EldFiRcYcpbagVaXVzTpVmBzhfxrvO8lXOJWgVs AF0pumI2SHWxl21PtEALrISrIdKmqdADHc68V4uLD7mI8JQBUex1HX+cs6VUuQ5t DP9cAg+6+64tYS9e8Kayhpnpe6Bri86fl8Wch2+uCROSvpk/AqFgNQd2IbG/F8X/ q/G+RgDBB+ame0l3uvfNs7xiOPCsYdGkJm7huxXdvqDHtwzhJz+fUQug/jXlYJjJ 5GCbwnbEk0lVMQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeijedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 92A6480062; Mon, 17 Jun 2019 04:15:15 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Jun 2019 17:15:01 +0900 Message-Id: <20190617081510.11025-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp> References: <20190617081510.11025-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 01/10] ALSA: firewire-motu: unify the count of subscriber for packet streaming 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 Two counters are used to maintain isochronous packet streaming for both directions. However, like the other drivers, they can be replaced with one counter. This commit unifies them. Signed-off-by: Takashi Sakamoto --- sound/firewire/motu/motu-midi.c | 8 ++++---- sound/firewire/motu/motu-pcm.c | 8 ++++---- sound/firewire/motu/motu-stream.c | 17 ++++++----------- sound/firewire/motu/motu.h | 3 +-- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/sound/firewire/motu/motu-midi.c b/sound/firewire/motu/motu-midi.c index e55cab6d79c7..b2d339a8ef3f 100644 --- a/sound/firewire/motu/motu-midi.c +++ b/sound/firewire/motu/motu-midi.c @@ -18,7 +18,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) mutex_lock(&motu->mutex); - motu->capture_substreams++; + motu->substreams_counter++; err = snd_motu_stream_start_duplex(motu, 0); mutex_unlock(&motu->mutex); @@ -40,7 +40,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream) mutex_lock(&motu->mutex); - motu->playback_substreams++; + motu->substreams_counter++; err = snd_motu_stream_start_duplex(motu, 0); mutex_unlock(&motu->mutex); @@ -57,7 +57,7 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream) mutex_lock(&motu->mutex); - motu->capture_substreams--; + motu->substreams_counter--; snd_motu_stream_stop_duplex(motu); mutex_unlock(&motu->mutex); @@ -72,7 +72,7 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream) mutex_lock(&motu->mutex); - motu->playback_substreams--; + motu->substreams_counter--; snd_motu_stream_stop_duplex(motu); mutex_unlock(&motu->mutex); diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c index ab69d7e6ac05..b0e5ebf05bec 100644 --- a/sound/firewire/motu/motu-pcm.c +++ b/sound/firewire/motu/motu-pcm.c @@ -203,7 +203,7 @@ static int capture_hw_params(struct snd_pcm_substream *substream, if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { mutex_lock(&motu->mutex); - motu->capture_substreams++; + motu->substreams_counter++; mutex_unlock(&motu->mutex); } @@ -222,7 +222,7 @@ static int playback_hw_params(struct snd_pcm_substream *substream, if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { mutex_lock(&motu->mutex); - motu->playback_substreams++; + motu->substreams_counter++; mutex_unlock(&motu->mutex); } @@ -236,7 +236,7 @@ static int capture_hw_free(struct snd_pcm_substream *substream) mutex_lock(&motu->mutex); if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) - motu->capture_substreams--; + motu->substreams_counter--; snd_motu_stream_stop_duplex(motu); @@ -252,7 +252,7 @@ static int playback_hw_free(struct snd_pcm_substream *substream) mutex_lock(&motu->mutex); if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) - motu->playback_substreams--; + motu->substreams_counter--; snd_motu_stream_stop_duplex(motu); diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index 73e7a5e527fc..c136d7f8c49c 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -207,7 +207,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) unsigned int curr_rate; int err = 0; - if (motu->capture_substreams == 0 && motu->playback_substreams == 0) + if (motu->substreams_counter == 0) return 0; /* Some packet queueing errors. */ @@ -271,8 +271,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) } } - if (!amdtp_stream_running(&motu->tx_stream) && - motu->capture_substreams > 0) { + if (!amdtp_stream_running(&motu->tx_stream)) { err = start_isoc_ctx(motu, &motu->tx_stream); if (err < 0) { dev_err(&motu->unit->device, @@ -291,15 +290,12 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) void snd_motu_stream_stop_duplex(struct snd_motu *motu) { - if (motu->capture_substreams == 0) { + if (motu->substreams_counter == 0) { if (amdtp_stream_running(&motu->tx_stream)) stop_isoc_ctx(motu, &motu->tx_stream); - if (motu->playback_substreams == 0) { - if (amdtp_stream_running(&motu->rx_stream)) - stop_isoc_ctx(motu, &motu->rx_stream); - stop_both_streams(motu); - } + if (amdtp_stream_running(&motu->rx_stream)) + stop_isoc_ctx(motu, &motu->rx_stream); } } @@ -372,8 +368,7 @@ void snd_motu_stream_destroy_duplex(struct snd_motu *motu) destroy_stream(motu, AMDTP_IN_STREAM); destroy_stream(motu, AMDTP_OUT_STREAM); - motu->playback_substreams = 0; - motu->capture_substreams = 0; + motu->substreams_counter = 0; } static void motu_lock_changed(struct snd_motu *motu) diff --git a/sound/firewire/motu/motu.h b/sound/firewire/motu/motu.h index 1cd112be7dad..ae4b37cdfade 100644 --- a/sound/firewire/motu/motu.h +++ b/sound/firewire/motu/motu.h @@ -60,8 +60,7 @@ struct snd_motu { struct amdtp_stream rx_stream; struct fw_iso_resources tx_resources; struct fw_iso_resources rx_resources; - unsigned int capture_substreams; - unsigned int playback_substreams; + unsigned int substreams_counter; /* For notification. */ struct fw_address_handler async_handler; From patchwork Mon Jun 17 08:15:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10998313 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 A3FED6C5 for ; Mon, 17 Jun 2019 08:18:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96A67287FF for ; Mon, 17 Jun 2019 08:18:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AB7028837; Mon, 17 Jun 2019 08:18:08 +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 D471F287FF for ; Mon, 17 Jun 2019 08:18:07 +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 25A3E1755; Mon, 17 Jun 2019 10:17:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 25A3E1755 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560759486; bh=D5G7eQBEn7oLuESCFPo5wNkBPrIppDBpeUKM3nUYr4w=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=L3/RxG0470iK9MCbYcjnnfbe3oWvnylnijXKW9KdU+rG4EdX/yzSnGugdj45vO6cz +k4S/5emNiaWvgFithWjGNgXI2ICJ9h0Ji9P6QXnhkF+Ak7xr3eThJdldOSI/ByLOw 1cKgM7ffMz/8rwzbxdVxMTxrLB9epf4cwwaV5lfk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 92D65F89737; Mon, 17 Jun 2019 10:15:33 +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 4A483F896DF; Mon, 17 Jun 2019 10:15:25 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 41E6BF896C7 for ; Mon, 17 Jun 2019 10:15:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 41E6BF896C7 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="d9XMYLO/"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OrQNFWPo" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 50A79733; Mon, 17 Jun 2019 04:15:19 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 17 Jun 2019 04:15:19 -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=cdn31kMuapOah X8du0ABkm3PVe74ZvYkTvBlUtLQrEg=; b=d9XMYLO/XLtFGfSKp+scHsJaGfgD8 YpG4Nx456lSmUo4cfx5m2hdmPe2w9kG6JqqHdW0vyPbLG+oVWoVSxEA0owf0Jn31 LUPYbdvIDLzHjUULt2zZONgbFhge+ZBPq/1yaKrSsbY2gJfVJkCt4kRV5sBR5PdY 7cC2YsqI1UoprshLrKvZuQcWjho0kRT14bC1S2v05uPYOoBp+E4kBdBY7L3Zkbs3 fpXlafM+VazE0sPQgFFKDKpvyNc8IIV3o4WPBaWaWOrqW7KsxkkdANLXd26c54aK kN3QQNKVhm4EEWOybKwcbwyhj4584boadUEZV/VOT/6185ie1NDTC7ITQ== 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= fm3; bh=cdn31kMuapOahX8du0ABkm3PVe74ZvYkTvBlUtLQrEg=; b=OrQNFWPo ByYd4rjtbO5wuSIsp9E41TcUXAE6LRlwYs7rozywquLOJSIU4lNcHH7CyhAZx0Xy EsaDAGr2EIftG9Vr7wFv3BsIUbt4pdftRBmYVuIqVLbxIFmtZ3nuTWwF6z3Kkh/U wBa7ufT3xxFWONiVhVe6lIsJODY9+Ns7eKQZmWFybsyvAokiHPZypHLAewcfJ3Ud 7MaBtVFzsiotipf1x0XptZvfFKNfBOIB0WyHH1wJk83b7BYzk0xI+R0yUu//N8Lv yp2D3sNHIby8n1Xk3yMD7zW373Fy+0YYlYFOfocOL4nOI/o+cS6mJeQiIKTGyV1N HzbdcZ2WsnyAIg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeijedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuffhomhgrihhnpehrrgifmhhiughird hophgvnhenucfkphepudegrdefrdejhedrudekudenucfrrghrrghmpehmrghilhhfrhho mhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjphenucevlhhushhtvghruf hiiigvpedt X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 1D56E80065; Mon, 17 Jun 2019 04:15:16 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Jun 2019 17:15:02 +0900 Message-Id: <20190617081510.11025-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp> References: <20190617081510.11025-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 02/10] ALSA: firewire-motu: unify midi callback function 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 Two sets of callbacks for rawmidi.open/close but they have the same codes. This commit unifies each of the callbacks. Signed-off-by: Takashi Sakamoto --- sound/firewire/motu/motu-midi.c | 49 ++++----------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/sound/firewire/motu/motu-midi.c b/sound/firewire/motu/motu-midi.c index b2d339a8ef3f..3b205386ed24 100644 --- a/sound/firewire/motu/motu-midi.c +++ b/sound/firewire/motu/motu-midi.c @@ -7,7 +7,7 @@ */ #include "motu.h" -static int midi_capture_open(struct snd_rawmidi_substream *substream) +static int midi_open(struct snd_rawmidi_substream *substream) { struct snd_motu *motu = substream->rmidi->private_data; int err; @@ -29,44 +29,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) return err; } -static int midi_playback_open(struct snd_rawmidi_substream *substream) -{ - struct snd_motu *motu = substream->rmidi->private_data; - int err; - - err = snd_motu_stream_lock_try(motu); - if (err < 0) - return err; - - mutex_lock(&motu->mutex); - - motu->substreams_counter++; - err = snd_motu_stream_start_duplex(motu, 0); - - mutex_unlock(&motu->mutex); - - if (err < 0) - snd_motu_stream_lock_release(motu); - - return err; -} - -static int midi_capture_close(struct snd_rawmidi_substream *substream) -{ - struct snd_motu *motu = substream->rmidi->private_data; - - mutex_lock(&motu->mutex); - - motu->substreams_counter--; - snd_motu_stream_stop_duplex(motu); - - mutex_unlock(&motu->mutex); - - snd_motu_stream_lock_release(motu); - return 0; -} - -static int midi_playback_close(struct snd_rawmidi_substream *substream) +static int midi_close(struct snd_rawmidi_substream *substream) { struct snd_motu *motu = substream->rmidi->private_data; @@ -129,13 +92,13 @@ static void set_midi_substream_names(struct snd_motu *motu, int snd_motu_create_midi_devices(struct snd_motu *motu) { static const struct snd_rawmidi_ops capture_ops = { - .open = midi_capture_open, - .close = midi_capture_close, + .open = midi_open, + .close = midi_close, .trigger = midi_capture_trigger, }; static const struct snd_rawmidi_ops playback_ops = { - .open = midi_playback_open, - .close = midi_playback_close, + .open = midi_open, + .close = midi_close, .trigger = midi_playback_trigger, }; struct snd_rawmidi *rmidi; From patchwork Mon Jun 17 08:15:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10998315 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 C1F7D924 for ; Mon, 17 Jun 2019 08:18:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2B8D28755 for ; Mon, 17 Jun 2019 08:18:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A655928807; Mon, 17 Jun 2019 08:18:40 +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 D523528755 for ; Mon, 17 Jun 2019 08:18:39 +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 2F5191765; Mon, 17 Jun 2019 10:17:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2F5191765 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560759518; bh=8J85jK8JTj++sWVRZPXkrIcOJpOyZnOEd2UTdeK7BmU=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rkl4QzbmfxFaBMLGuZSeC1UYYd6quhudtdUzM0gA591Aym1O1ene7aIGN/DiCVvpi 18UHWEGdQLsVE1PLE7nIMkgGrHWmd8GR2U9vDtek8peoMR3e7LUS28YD1VaKSLSWcB 7hjpYfdBobDBWHTdA5KXahuSpNUFcLHOnu/OoAAU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9228AF8973D; Mon, 17 Jun 2019 10:15:35 +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 EC312F89717; Mon, 17 Jun 2019 10:15:25 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 69644F8075C for ; Mon, 17 Jun 2019 10:15:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 69644F8075C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="vlFS7LTE"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Lb7Tn/OZ" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 7FBDF739; Mon, 17 Jun 2019 04:15:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 17 Jun 2019 04:15:20 -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=1CJUjR1BL5jys ezE31dA1k61vTLzH5cO59Q7otywyPQ=; b=vlFS7LTEFBres/Vr9DifGj8Zr3tjT aVQDkiOq/i1NC+1z8uNrdNgo2wcF7vrTaYl3HkH65DeWHOBoSZmQrLk2imYELSOv B8r2b7Vu5YcXfhxJp2Q7CAcXg7/bQHwbKAq+7y12kkhMSmNOByomgYHiJQSPPfHS f+ZBDDk6r/0X9HVmIelmtshQn23MuPlx+1JEJhuuu6cp7njCecRP1vvNzvdvGeZj ovPochA+qkXdvq1N5Tg07YPytEscYncgx07x/iXPHW4C0viIcfvMwc9+hFZZDX+X Idj+TfOOSf6UaAITqbF3OYl5FfnqtREnSY7Pi4Xldpw7oYAPJaZ6UDNtg== 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= fm3; bh=1CJUjR1BL5jysezE31dA1k61vTLzH5cO59Q7otywyPQ=; b=Lb7Tn/OZ 6J3VnZGvGLBwQnOxGEzFAuYBzZLSXRh2ghyOzAIDAdbCUFZgb6H0dhB6MQ2Lbuwk /mA3BBX99hWt/lE+uiBgU//Bu8uo8vfAkUeoVzdED4am/qonFiohm/OoEkZudxdO e8iNNKEq5S6+u7gu0nNCsqv+V9jUGpUA8B+ObIidDFL+0axPrvmrTbGe+tu6nWkc JiCZ0rIcRPyMBNWW//xVJPJb4poToIyE6ndYwrYdVtboU8byxrPbKuyrW1/kH/+q EO0fUWZ20H2I8/tEus6bK9oxg7/pByP/0CN6SRL3GU5rxEg0pnnnPGmq5C+UWKWC qC+J+IZ4DtC5qw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeijedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id BA14F80062; Mon, 17 Jun 2019 04:15:18 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Jun 2019 17:15:03 +0900 Message-Id: <20190617081510.11025-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp> References: <20190617081510.11025-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 03/10] ALSA: firewire-motu: add helper function to keep isochronous resources 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 part of preparation to perform allocation/release of isochronous resources in pcm.hw_params/hw_free callbacks. This commit adds a helper function to allocate isochronous resources. Signed-off-by: Takashi Sakamoto --- sound/firewire/motu/motu-stream.c | 57 +++++++++++++++++-------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index c136d7f8c49c..35b4e0f72fe2 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -26,48 +26,55 @@ #define RX_PACKET_EXCLUDE_DIFFERED_DATA_CHUNKS 0x00000040 #define TX_PACKET_TRANSMISSION_SPEED_MASK 0x0000000f -static int start_both_streams(struct snd_motu *motu, unsigned int rate) +static int keep_resources(struct snd_motu *motu, unsigned int rate, + struct amdtp_stream *stream) { + struct fw_iso_resources *resources; + struct snd_motu_packet_format *packet_format; unsigned int midi_ports = 0; - __be32 reg; - u32 data; int err; - if ((motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) || - (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q)) - midi_ports = 1; + if (stream == &motu->rx_stream) { + resources = &motu->rx_resources; + packet_format = &motu->rx_packet_formats; - /* Set packet formation to our packet streaming engine. */ - err = amdtp_motu_set_parameters(&motu->rx_stream, rate, midi_ports, - &motu->rx_packet_formats); - if (err < 0) - return err; + if ((motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) || + (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q)) + midi_ports = 1; + } else { + resources = &motu->tx_resources; + packet_format = &motu->tx_packet_formats; - if ((motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) || - (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q)) - midi_ports = 1; - else - midi_ports = 0; + if ((motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) || + (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q)) + midi_ports = 1; + } - err = amdtp_motu_set_parameters(&motu->tx_stream, rate, midi_ports, - &motu->tx_packet_formats); + err = amdtp_motu_set_parameters(stream, rate, midi_ports, + packet_format); if (err < 0) return err; - /* Get isochronous resources on the bus. */ - err = fw_iso_resources_allocate(&motu->rx_resources, - amdtp_stream_get_max_payload(&motu->rx_stream), + return fw_iso_resources_allocate(resources, + amdtp_stream_get_max_payload(stream), fw_parent_device(motu->unit)->max_speed); +} + +static int start_both_streams(struct snd_motu *motu, unsigned int rate) +{ + __be32 reg; + u32 data; + int err; + + err = keep_resources(motu, rate, &motu->tx_stream); if (err < 0) return err; - err = fw_iso_resources_allocate(&motu->tx_resources, - amdtp_stream_get_max_payload(&motu->tx_stream), - fw_parent_device(motu->unit)->max_speed); + err = keep_resources(motu, rate, &motu->rx_stream); if (err < 0) return err; - /* Configure the unit to start isochronous communication. */ + // Configure the unit to start isochronous communication. err = snd_motu_transaction_read(motu, ISOC_COMM_CONTROL_OFFSET, ®, sizeof(reg)); if (err < 0) From patchwork Mon Jun 17 08:15:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10998321 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 030156C5 for ; Mon, 17 Jun 2019 08:19:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1A762888B for ; Mon, 17 Jun 2019 08:19:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E088B2886C; Mon, 17 Jun 2019 08:19:17 +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 3EAC228874 for ; Mon, 17 Jun 2019 08:19:17 +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 88C6F1780; Mon, 17 Jun 2019 10:18:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 88C6F1780 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560759555; bh=lbpi9P2y0hPOwROve69yTeROkXQesBbTUT7xVssy85I=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bQfgCsrMSjmh5wXjIGBom6thxbg2yFH3mBlJGeXyiFyfvQD45m4gnz/G8P0/2coSo fiEbi055JP/zd1W8cTr6o7IgqG3XcdDL5iCcb5h7CpS/bsOWJYfQrrRuDreR7K9b+Z Wewr29llNjAV3KgkCFGuLq38h4S6MR/yJLb5HAac= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C221FF89741; Mon, 17 Jun 2019 10:15:36 +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 4D459F8075C; Mon, 17 Jun 2019 10:15:26 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 673DFF89693 for ; Mon, 17 Jun 2019 10:15:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 673DFF89693 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="r9ZC2Ns3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="N8+bqi/M" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id DAF0C73C; Mon, 17 Jun 2019 04:15:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 17 Jun 2019 04:15:22 -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=IEfeAsGODTUg1 1X/LCFLcNN0hWFrdO8BUOCmHwwVUxg=; b=r9ZC2Ns3WoHcWOAVlNXZzECi/x+xf Q8R3og1KJUZiS77/Txh2UZXDbG5Zy0j7m2V3+plh8YWizboqTvtoJfI78Mpn9Nhw ndGmLsPuv8oihlnHybEGtZHBxmpHKamRVCOfGLsCzU0g4VMVNq+tQYf9D82MXN/x iUpDbxlC/ekRASzeXVBNngrYMqDmD2UhqXgzuxRrC0RbFWUUhdZZTpWYLDyUwAwk V5nAlKm4ymLCSSojxZ8c4ebHyMoTKD90Yu2n/WR6qZgeQ3QWKLGn3U4C2fkMKzu5 8uayM+pFsWYukc0RmXsop05l3yUQE1vy+7GleXY3MRdO+USWCLw1GbGOA== 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= fm3; bh=IEfeAsGODTUg11X/LCFLcNN0hWFrdO8BUOCmHwwVUxg=; b=N8+bqi/M NBg9dWEMGo/X4rFX6RwNLKpwQPKU/E1ftwgtw81dW28FbBJCgwXcNwgWKcXXgf68 Vk2IgrXZgptcbjj8j+72isqLEq2lQBdiQ2tnwfVI2/kw5k+cd07+K98O6hIfXQ30 ifE51mE3y4F3OLUl0WC4yRaxPbTaR/yCVDCZASj2+M1mVcJbUO96SfvIF12a2Fre n9CpfIQHXzocCiAjTb66jg2M0jvS/dSVj1+I3skEKUdyhGWxPWDSl8BucI/lk/w5 iXOlaLQwlR5bPY2jfKx9NCQU7I9VG6LMoTE9c80wcJdD27j7DGqv0msGe32qWhRP eiDiC0DXHpyWvQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeijedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepvd X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 3D2D380061; Mon, 17 Jun 2019 04:15:20 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Jun 2019 17:15:04 +0900 Message-Id: <20190617081510.11025-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp> References: <20190617081510.11025-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 04/10] ALSA: firewire-motu: code refactoring for condition to stop streaming 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 snd_motu_stream_start_duplex() function, there're two points to stop packet streaming, however they can be merged. This commit merges them. Signed-off-by: Takashi Sakamoto --- sound/firewire/motu/motu-stream.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index 35b4e0f72fe2..a3f45f2c817c 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -217,19 +217,11 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) if (motu->substreams_counter == 0) return 0; - /* Some packet queueing errors. */ - if (amdtp_streaming_error(&motu->rx_stream) || - amdtp_streaming_error(&motu->tx_stream)) { - amdtp_stream_stop(&motu->rx_stream); - amdtp_stream_stop(&motu->tx_stream); - stop_both_streams(motu); - } - err = snd_motu_stream_cache_packet_formats(motu); if (err < 0) return err; - /* Stop stream if rate is different. */ + // Stop stream if rate is different. err = protocol->get_clock_rate(motu, &curr_rate); if (err < 0) { dev_err(&motu->unit->device, @@ -238,7 +230,9 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) } if (rate == 0) rate = curr_rate; - if (rate != curr_rate) { + if (rate != curr_rate || + amdtp_streaming_error(&motu->rx_stream) || + amdtp_streaming_error(&motu->tx_stream)) { amdtp_stream_stop(&motu->rx_stream); amdtp_stream_stop(&motu->tx_stream); stop_both_streams(motu); From patchwork Mon Jun 17 08:15:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10998323 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 AFA7A6C5 for ; Mon, 17 Jun 2019 08:20:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A071727FA8 for ; Mon, 17 Jun 2019 08:20:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 949112857D; Mon, 17 Jun 2019 08:20: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 E426E27FA8 for ; Mon, 17 Jun 2019 08:20:17 +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 25FB31782; Mon, 17 Jun 2019 10:19:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 25FB31782 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560759606; bh=Vq6viaMugPt1fkEYuZxFOcHq/XoEbeozrx2x0MQ8GHw=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hMvYnmamAr6kI+y9U/wlqA0Oh1KVyUAtBnmyZ/ur91UiN8MbTl2vqcsN9LZY5CKyV ZUZAbkUOSSgvCq8ySdXxRi3uyS4jyE90QbrDo0VFUVzSijzDVfHlfkpgJfAGQ5Sy/p o3UHpKqTLIdjHshq+7gf4/Ugzpkh/Q+NsuACUVv4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B01AEF89745; Mon, 17 Jun 2019 10:15:40 +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 21CB1F89733; Mon, 17 Jun 2019 10:15:28 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 316D2F896F9 for ; Mon, 17 Jun 2019 10:15:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 316D2F896F9 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="cYb3PIeT"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="k7lRGM7n" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 853666DA; Mon, 17 Jun 2019 04:15:23 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 17 Jun 2019 04:15:23 -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=39j9KP1ZRI77/ ozYN1Sd5CHsUml3bBGYWhg6XYt/yFc=; b=cYb3PIeThBYX7YspuWeJoBf36ZLHr bft6utcK9tCzpViYLhRuC2msmalSLDoZEJW69kKcaizJC1eGpidj0LAQugowFbRz ZU2c0/xT0IuFNIj4XUJzghYuQkfL/0f7xIwhXxlpG2HcHxZA0R8HOCAXkYVQZsXY 9l/M/d86C1sfYQFNIJcwOhWhXzlpBncbQH5eM7eZLJ2x2sJAheYwAeq9D/RK7njP pGGHptiinMe21awJtOIVMnPCQFlUAYPX2cwbNpI8hTaV19GAJHWajLSYSpYtbIfV YtAreQjgi9tIi092nKpN5Ri3xaXfMlvja2gGxsJUSVs3ZMHmcju1fI5tg== 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= fm3; bh=39j9KP1ZRI77/ozYN1Sd5CHsUml3bBGYWhg6XYt/yFc=; b=k7lRGM7n O0YYGEdoOsT9C7eSY7DVlYknMUiERd42bEAsoe5XbOAFhQWd3a7uN4PEc1zjPS2x 34EPFohf3H7ykY2VvLmZN+ICPsdtHdSmTiimt+av5kqpk5NThl/cujYC0zkn+dLU Uh1cykyoD/3BrEs3Kcq8+06mM9LoYJ0sGsJRHdm9eJQe2+TgvGrwRUTlu/zOdJ4O i5Iwnrew1TSYfrBObRkI19u4xBEfVM1ETdZaLtgSTi7ZLOcoz86EuNf3TD75UAh7 q/kO2UFBfSQExrEIxjNj0BF08jHYSYwsrbZVhzOBzsK78IVpDBqxF5DqTrLqEerV wvdnHIg0Zf4fpg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeijedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepvd X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id B5AE98005B; Mon, 17 Jun 2019 04:15:21 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Jun 2019 17:15:05 +0900 Message-Id: <20190617081510.11025-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp> References: <20190617081510.11025-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 05/10] ALSA: firewire-motu: rename helper functions to begin/finish streaming session 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 Like the other drivers in ALSA firewire stack, this commit renames functions to begin/finish packet streaming. Signed-off-by: Takashi Sakamoto --- sound/firewire/motu/motu-stream.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index a3f45f2c817c..cb01f1d784f1 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -60,7 +60,7 @@ static int keep_resources(struct snd_motu *motu, unsigned int rate, fw_parent_device(motu->unit)->max_speed); } -static int start_both_streams(struct snd_motu *motu, unsigned int rate) +static int begin_session(struct snd_motu *motu, unsigned int rate) { __be32 reg; u32 data; @@ -91,7 +91,7 @@ static int start_both_streams(struct snd_motu *motu, unsigned int rate) sizeof(reg)); } -static void stop_both_streams(struct snd_motu *motu) +static void finish_session(struct snd_motu *motu) { __be32 reg; u32 data; @@ -235,7 +235,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) amdtp_streaming_error(&motu->tx_stream)) { amdtp_stream_stop(&motu->rx_stream); amdtp_stream_stop(&motu->tx_stream); - stop_both_streams(motu); + finish_session(motu); } if (!amdtp_stream_running(&motu->rx_stream)) { @@ -250,7 +250,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) if (err < 0) return err; - err = start_both_streams(motu, rate); + err = begin_session(motu, rate); if (err < 0) { dev_err(&motu->unit->device, "fail to start isochronous comm: %d\n", err); @@ -285,7 +285,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) return 0; stop_streams: - stop_both_streams(motu); + finish_session(motu); return err; } From patchwork Mon Jun 17 08:15:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10998325 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 7FD676C5 for ; Mon, 17 Jun 2019 08:20:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 718E32886E for ; Mon, 17 Jun 2019 08:20:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FEF72887E; Mon, 17 Jun 2019 08:20:34 +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 B94992887D for ; Mon, 17 Jun 2019 08:20:33 +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 1BDE817A1; Mon, 17 Jun 2019 10:19:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1BDE817A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560759632; bh=yweMTpNjLVcXU88gXZuvrDaAUNTjGFJtEpVzVT5iqUU=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=R17KELFcHWN9ev/dwk/cbTgrkT1adHgj4llxEFrZpCbcRE0mSqXjM0GV2mtBz7kQt b7lBYJ8wSK+3hE9AweTpmEoZFZDnhAg7TsJXHrgEh+EL2W1XsP5tgsqm3hQpfb1Ise VljJLaRZAxH6J01PUfCbp76kmwiHYQGppcmWR+ck= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 197B6F89747; Mon, 17 Jun 2019 10:15:42 +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 0F0AAF89739; Mon, 17 Jun 2019 10:15:30 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D969FF89731 for ; Mon, 17 Jun 2019 10:15:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D969FF89731 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="QgKW+Bpt"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="AtbjV6wU" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 4D9BB742; Mon, 17 Jun 2019 04:15:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 17 Jun 2019 04:15:25 -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=YB3QTVDnUAnY3 Q89JRB1kmvXMxhD63jaAITcj1CM6Xg=; b=QgKW+Bpt4nbDVGw3U3Ha9VOCzIj8E TWVh0LtatQGkVJAYYNK3vwFnq9t5qZ+t/YEDDsZdHDr4J4P/ruLK6kbRSzoi5Egy bMmFEE79eTFWpGbkppXLjDbi1mnMuuQg0LYb2OX1GK1gGAXy6Wbl0cX9AoaCvope Em6ZtXN00CHE89Mb2VflFHrnROOyJ0rdzCAP5J8a1cMbwMdMWGRsvLXoT41YUUhs PQaqAHhAR52RzDNGoXoVHK5ci9qOQnvOgzAUjK6uBdZxw/zFZ2TU76msKvBZIogn Lb8tsFJ2sMMsz9bWXTQYn1r/ZbicfHz/F32q9md1xDA8YTb3fgsbNGGyQ== 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= fm3; bh=YB3QTVDnUAnY3Q89JRB1kmvXMxhD63jaAITcj1CM6Xg=; b=AtbjV6wU 5cmx0NFmXRkZMKD4d8dhXdGoxKyjsU3fHA+RHrF4nYz3W1ZcNxEAf6FCcqvFWd8e tE7zbnGJZk1Hc30EnsitNq7N43XpayQGl80ho9mrbcchL4pw9ttaw0kUqQ0OOQy/ 3fdBZtZCu2/k/vzS5A3+1EFNINopHK/cB4BPiw/engYXj+woUTLke40B1Irynn+e IctN9u+ONKQUq5daQD3LiwB1ThyvNhqhJgjA6dtCQe5IWGg/33cAj5E/bQPkYDQL k6Tj5uKSqtuUFbpzR9eX+28iIkM072yfJ1j8ek6MJ6bNvmjSaUz+R+DP3RMIhHD/ UFlxM7zak/LUbg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeijedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepvd X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 3C01080065; Mon, 17 Jun 2019 04:15:23 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Jun 2019 17:15:06 +0900 Message-Id: <20190617081510.11025-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp> References: <20190617081510.11025-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 06/10] ALSA: firewire-motu: minor code refactoring to stop isochronous 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 helper function to stop isochronous context is superfluous. This commit removes it with simpler codes. Signed-off-by: Takashi Sakamoto --- sound/firewire/motu/motu-stream.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index cb01f1d784f1..4fbec35eaad5 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -142,19 +142,6 @@ static int start_isoc_ctx(struct snd_motu *motu, struct amdtp_stream *stream) return 0; } -static void stop_isoc_ctx(struct snd_motu *motu, struct amdtp_stream *stream) -{ - struct fw_iso_resources *resources; - - if (stream == &motu->rx_stream) - resources = &motu->rx_resources; - else - resources = &motu->tx_resources; - - amdtp_stream_stop(stream); - fw_iso_resources_free(resources); -} - int snd_motu_stream_cache_packet_formats(struct snd_motu *motu) { int err; @@ -292,11 +279,11 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) void snd_motu_stream_stop_duplex(struct snd_motu *motu) { if (motu->substreams_counter == 0) { - if (amdtp_stream_running(&motu->tx_stream)) - stop_isoc_ctx(motu, &motu->tx_stream); + amdtp_stream_stop(&motu->tx_stream); + amdtp_stream_stop(&motu->rx_stream); - if (amdtp_stream_running(&motu->rx_stream)) - stop_isoc_ctx(motu, &motu->rx_stream); + fw_iso_resources_free(&motu->tx_resources); + fw_iso_resources_free(&motu->rx_resources); } } From patchwork Mon Jun 17 08:15:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10998327 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 AB5C314BB for ; Mon, 17 Jun 2019 08:21:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FBF92887D for ; Mon, 17 Jun 2019 08:21:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DC4D28874; Mon, 17 Jun 2019 08:21:17 +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 E1EE02887D for ; Mon, 17 Jun 2019 08:21:16 +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 C448D1778; Mon, 17 Jun 2019 10:20:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C448D1778 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560759674; bh=4HDuqkeIVw+nnCDNCrCYxJPs9Pn1gMbZaayMxfKGLqo=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Gqb6RjfWWAlnhziLvyaLojZxd9g7guOirxrxI5p/c1HPY/8rrlwnAS6bUa3if7dal 0EDF+VOJ45Qhu87UU8I2AGRaBzFluj+/evbv90xkknlPtpuy/7b18zgGpicjkBabbf B4ju7G6W4QcjZZj6oV+ovdRVGG9o511yJtBtv5is= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 60076F8974F; Mon, 17 Jun 2019 10:15:43 +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 E9442F89738; Mon, 17 Jun 2019 10:15:30 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 18A34F896F9 for ; Mon, 17 Jun 2019 10:15:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 18A34F896F9 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="iwH4R7wE"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="vfT1194M" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 8C10174B; Mon, 17 Jun 2019 04:15:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 17 Jun 2019 04:15:26 -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=IT1hXbmsFMmC8 QQh/FFYRwviAynmCpCr7xWXPe/yZ8Q=; b=iwH4R7wEZALmClJYKzBO2x+jV1Szn 0cox6zRLABKGegTRatgnaE+U4WNLDr3kHU/l5ZzaiokfEyxJ6BEYfkyuvXm4YImp ugngwN0QnrpEch6CVSGzuuM7Ve821jfgnarNnKrlageZ9IqqHTcqtspO1gKERQMr ytbcdv3J1u5XASnYKlleT5oKXSs/4DnAHWqoML9MkoWezk+4DxiDbNB3UZpXE4Jz F9xtQoUbH0fXLcuyiFcyPEJMFEQJjhHOLmgaQu+n1HMr0CrPbkTR3OfQrKOJEHUI 45JPbJUCfUrtoM+Ipi0e071dhM/Kfv9GtKAK7m9z1H+sZ+JzsG/UlORLQ== 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= fm3; bh=IT1hXbmsFMmC8QQh/FFYRwviAynmCpCr7xWXPe/yZ8Q=; b=vfT1194M ocXAjlgnRG8ySVVXP4m9izrrOsHgAriv19XEbXXg9lPt6DOoMYTMejbZxhaGsXVx Cv01mUYTwngpmuvkxJ6Iladx05vskOZHSqaa49LVbhvL7yo2N3WQJHh4AH1VcNuN zc5GkmYNkiCs57D7EH6MNvsCRukCqfD8SuKKxNbX3uhEW4OSxACBZUHRe3753MQE NCLYdBNPU6P5sI23Y9SKVac8+RR7z8/ENOUCh/pK+80VEii6ncQcfoHLjDjRdBbD 7O2wG/Dea9NrtTgL6M7Mo+pJeShjDTFUgv30UlxMiYig/eSIW0wZlqPH9j9f4+QA uvJrwAwq4dh/Dw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeijedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepvd X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id B2C0680059; Mon, 17 Jun 2019 04:15:24 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Jun 2019 17:15:07 +0900 Message-Id: <20190617081510.11025-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp> References: <20190617081510.11025-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 07/10] ALSA: firewire-motu: code refactoring to finish streaming session 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 operation to finish packet streaming includes stopping isochronous contexts. This commit merges it to the helper function. Signed-off-by: Takashi Sakamoto --- sound/firewire/motu/motu-stream.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index 4fbec35eaad5..53c43848b137 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -101,6 +101,9 @@ static void finish_session(struct snd_motu *motu) if (err < 0) return; + amdtp_stream_stop(&motu->tx_stream); + amdtp_stream_stop(&motu->rx_stream); + err = snd_motu_transaction_read(motu, ISOC_COMM_CONTROL_OFFSET, ®, sizeof(reg)); if (err < 0) @@ -219,11 +222,8 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) rate = curr_rate; if (rate != curr_rate || amdtp_streaming_error(&motu->rx_stream) || - amdtp_streaming_error(&motu->tx_stream)) { - amdtp_stream_stop(&motu->rx_stream); - amdtp_stream_stop(&motu->tx_stream); + amdtp_streaming_error(&motu->tx_stream)) finish_session(motu); - } if (!amdtp_stream_running(&motu->rx_stream)) { err = protocol->set_clock_rate(motu, rate); @@ -278,13 +278,8 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) void snd_motu_stream_stop_duplex(struct snd_motu *motu) { - if (motu->substreams_counter == 0) { - amdtp_stream_stop(&motu->tx_stream); - amdtp_stream_stop(&motu->rx_stream); - - fw_iso_resources_free(&motu->tx_resources); - fw_iso_resources_free(&motu->rx_resources); - } + if (motu->substreams_counter == 0) + finish_session(motu); } static int init_stream(struct snd_motu *motu, enum amdtp_stream_direction dir) From patchwork Mon Jun 17 08:15:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10998331 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 8774C76 for ; Mon, 17 Jun 2019 08:22:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78781287AA for ; Mon, 17 Jun 2019 08:22:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C32328807; Mon, 17 Jun 2019 08:22:05 +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 5B4DB287AA for ; Mon, 17 Jun 2019 08:22:04 +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 78D4C1764; Mon, 17 Jun 2019 10:21:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 78D4C1764 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560759722; bh=YeYl9UhMUKlxZ3EeHEeh+okA+3C9h7/Xi5Ty1M/zNcU=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=imA82eWjz8+CA9dE0bEvpZntCw6dpms0KA4RugmTJa/T9F5MJoHtG+UJlOLcuEmCq HYT50qxSa8m4PHEdNI2eFPP+Yo/e2Gz1FFRzMmBlmWO78KRGNcTdm0XGwXuy2Z3A2q LRukLbp4mTYE/Gb9iEUaFCVV2c64q2DPvalcHYo8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2BAA2F896C7; Mon, 17 Jun 2019 10:16:17 +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 39933F89738; Mon, 17 Jun 2019 10:15:33 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E4B55F80764 for ; Mon, 17 Jun 2019 10:15:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E4B55F80764 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="Omx+M1bd"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="wjubzjvU" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 5B3A873A; Mon, 17 Jun 2019 04:15:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 17 Jun 2019 04:15:28 -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=i1j3E5kI5MXiR NQ5ZfbwLtvsWCfsKVF/JY8Jpp+ZZZQ=; b=Omx+M1bdm4FvZ95lcNzajZ2KPpipK tuNzvVAu1RTbaFBaXv9PKXLQGBcprbL4unEd1tuKmz/HiJ5yLaRSmpY/WiUfYnv3 QVO66pfkMveLYLu5gW/G8agN1G/h44/0e/z6yw9ksgrMMDgqMIs2/y7h/BXipzpn Cqi4jP0TijHk0X9sb+YlOoNlU/dlVPSgmqG78NCXD4OwoB73hi2Nmh3D8bBMOwzy pmWAgobXAmsRiDCeOIfONg0FyrhBh6/aBb00YckPbuY7MPdEjGF9vay537amyJ9w O/mRaUSNHRArwWUd9+Ixh8t4Yamo+EXUWJiGZSZdOp261lVkqF68AgghA== 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= fm3; bh=i1j3E5kI5MXiRNQ5ZfbwLtvsWCfsKVF/JY8Jpp+ZZZQ=; b=wjubzjvU HchuP2+K97LA1JYRtPHnc4NcnTA9yx9ESTuatVCwKoACe/H+YLq7dkon0d3xuWf3 E/2ZcAKawxaGz/HfXKLIZjpgVz6UXCG36wFBMAt9TLZRnYvkJeL349q65tAvMa0q ItdnPXGEh5uJXOtYWIHEwRecvSHxZrzGga1PBnJxO/ylr3KPXjF2RhYbeh5G3N9H UY0vF6dJgLxCitgxtvdUS6spukBkzx5WJI5cwQmaFV0qgGX1kT+VSfyc42gWLs/K SAE99sWzepmYMlF0pu8kjHPsuxDbC6YcwOVigg9J/DF3eQi8ltcSU2CEqFgEvzzD sWDuiE1hOr90/Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeijedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepie X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 3919880068; Mon, 17 Jun 2019 04:15:26 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Jun 2019 17:15:08 +0900 Message-Id: <20190617081510.11025-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp> References: <20190617081510.11025-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 08/10] ALSA: firewire-motu: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks 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 Once allocated, isochronous resources are available for packet streaming, even if the streaming is cancelled. For this reason, current implementation handles allocation of the resources and starting packet streaming at the same time. However, this brings complicated procedure to start packet streaming. This commit separates the allocation and starting. The allocation is done in pcm.hw_params callback and available till pcm.hw_free callback. Even if any XRUN occurs, pcm.prepare callback is done to restart packet streaming without releasing/allocating the resources. There are two points to stop packet streaming; in pcm.hw_params and pcm.prepare callbacks. The former point is a case that packet streaming is already started for any MIDI substream then packet streaming is requested with different sampling transfer frequency for any PCM substream. The latter point is cases of any XRUN or packet queueing error. Signed-off-by: Takashi Sakamoto --- sound/firewire/motu/motu-midi.c | 10 ++- sound/firewire/motu/motu-pcm.c | 26 +++++--- sound/firewire/motu/motu-stream.c | 100 +++++++++++++++++------------- sound/firewire/motu/motu.h | 4 +- 4 files changed, 84 insertions(+), 56 deletions(-) diff --git a/sound/firewire/motu/motu-midi.c b/sound/firewire/motu/motu-midi.c index 3b205386ed24..a463730c72bc 100644 --- a/sound/firewire/motu/motu-midi.c +++ b/sound/firewire/motu/motu-midi.c @@ -18,8 +18,11 @@ static int midi_open(struct snd_rawmidi_substream *substream) mutex_lock(&motu->mutex); - motu->substreams_counter++; - err = snd_motu_stream_start_duplex(motu, 0); + err = snd_motu_stream_reserve_duplex(motu, 0); + if (err >= 0) { + ++motu->substreams_counter; + err = snd_motu_stream_start_duplex(motu); + } mutex_unlock(&motu->mutex); @@ -35,8 +38,9 @@ static int midi_close(struct snd_rawmidi_substream *substream) mutex_lock(&motu->mutex); - motu->substreams_counter--; + --motu->substreams_counter; snd_motu_stream_stop_duplex(motu); + snd_motu_stream_release_duplex(motu); mutex_unlock(&motu->mutex); diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c index b0e5ebf05bec..d4e75d3ee928 100644 --- a/sound/firewire/motu/motu-pcm.c +++ b/sound/firewire/motu/motu-pcm.c @@ -202,12 +202,16 @@ static int capture_hw_params(struct snd_pcm_substream *substream, return err; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { + unsigned int rate = params_rate(hw_params); + mutex_lock(&motu->mutex); - motu->substreams_counter++; + err = snd_motu_stream_reserve_duplex(motu, rate); + if (err >= 0) + ++motu->substreams_counter; mutex_unlock(&motu->mutex); } - return 0; + return err; } static int playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) @@ -221,12 +225,16 @@ static int playback_hw_params(struct snd_pcm_substream *substream, return err; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { + unsigned int rate = params_rate(hw_params); + mutex_lock(&motu->mutex); - motu->substreams_counter++; + err = snd_motu_stream_reserve_duplex(motu, rate); + if (err >= 0) + ++motu->substreams_counter; mutex_unlock(&motu->mutex); } - return 0; + return err; } static int capture_hw_free(struct snd_pcm_substream *substream) @@ -236,9 +244,10 @@ static int capture_hw_free(struct snd_pcm_substream *substream) mutex_lock(&motu->mutex); if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) - motu->substreams_counter--; + --motu->substreams_counter; snd_motu_stream_stop_duplex(motu); + snd_motu_stream_release_duplex(motu); mutex_unlock(&motu->mutex); @@ -252,9 +261,10 @@ static int playback_hw_free(struct snd_pcm_substream *substream) mutex_lock(&motu->mutex); if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) - motu->substreams_counter--; + --motu->substreams_counter; snd_motu_stream_stop_duplex(motu); + snd_motu_stream_release_duplex(motu); mutex_unlock(&motu->mutex); @@ -267,7 +277,7 @@ static int capture_prepare(struct snd_pcm_substream *substream) int err; mutex_lock(&motu->mutex); - err = snd_motu_stream_start_duplex(motu, substream->runtime->rate); + err = snd_motu_stream_start_duplex(motu); mutex_unlock(&motu->mutex); if (err >= 0) amdtp_stream_pcm_prepare(&motu->tx_stream); @@ -280,7 +290,7 @@ static int playback_prepare(struct snd_pcm_substream *substream) int err; mutex_lock(&motu->mutex); - err = snd_motu_stream_start_duplex(motu, substream->runtime->rate); + err = snd_motu_stream_start_duplex(motu); mutex_unlock(&motu->mutex); if (err >= 0) amdtp_stream_pcm_prepare(&motu->rx_stream); diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index 53c43848b137..5630a8f1f2f1 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -60,20 +60,12 @@ static int keep_resources(struct snd_motu *motu, unsigned int rate, fw_parent_device(motu->unit)->max_speed); } -static int begin_session(struct snd_motu *motu, unsigned int rate) +static int begin_session(struct snd_motu *motu) { __be32 reg; u32 data; int err; - err = keep_resources(motu, rate, &motu->tx_stream); - if (err < 0) - return err; - - err = keep_resources(motu, rate, &motu->rx_stream); - if (err < 0) - return err; - // Configure the unit to start isochronous communication. err = snd_motu_transaction_read(motu, ISOC_COMM_CONTROL_OFFSET, ®, sizeof(reg)); @@ -116,9 +108,6 @@ static void finish_session(struct snd_motu *motu) reg = cpu_to_be32(data); snd_motu_transaction_write(motu, ISOC_COMM_CONTROL_OFFSET, ®, sizeof(reg)); - - fw_iso_resources_free(&motu->tx_resources); - fw_iso_resources_free(&motu->rx_resources); } static int start_isoc_ctx(struct snd_motu *motu, struct amdtp_stream *stream) @@ -136,11 +125,8 @@ static int start_isoc_ctx(struct snd_motu *motu, struct amdtp_stream *stream) if (err < 0) return err; - if (!amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT)) { - amdtp_stream_stop(stream); - fw_iso_resources_free(resources); + if (!amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT)) return -ETIMEDOUT; - } return 0; } @@ -172,6 +158,56 @@ int snd_motu_stream_cache_packet_formats(struct snd_motu *motu) return 0; } +int snd_motu_stream_reserve_duplex(struct snd_motu *motu, unsigned int rate) +{ + unsigned int curr_rate; + int err; + + err = motu->spec->protocol->get_clock_rate(motu, &curr_rate); + if (err < 0) + return err; + if (rate == 0) + rate = curr_rate; + + if (motu->substreams_counter == 0 || curr_rate != rate) { + finish_session(motu); + + fw_iso_resources_free(&motu->tx_resources); + fw_iso_resources_free(&motu->rx_resources); + + err = motu->spec->protocol->set_clock_rate(motu, rate); + if (err < 0) { + dev_err(&motu->unit->device, + "fail to set sampling rate: %d\n", err); + return err; + } + + err = snd_motu_stream_cache_packet_formats(motu); + if (err < 0) + return err; + + err = keep_resources(motu, rate, &motu->tx_stream); + if (err < 0) + return err; + + err = keep_resources(motu, rate, &motu->rx_stream); + if (err < 0) { + fw_iso_resources_free(&motu->tx_resources); + return err; + } + } + + return 0; +} + +void snd_motu_stream_release_duplex(struct snd_motu *motu) +{ + if (motu->substreams_counter == 0) { + fw_iso_resources_free(&motu->tx_resources); + fw_iso_resources_free(&motu->rx_resources); + } +} + static int ensure_packet_formats(struct snd_motu *motu) { __be32 reg; @@ -198,46 +234,23 @@ static int ensure_packet_formats(struct snd_motu *motu) sizeof(reg)); } -int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) +int snd_motu_stream_start_duplex(struct snd_motu *motu) { - const struct snd_motu_protocol *protocol = motu->spec->protocol; - unsigned int curr_rate; int err = 0; if (motu->substreams_counter == 0) return 0; - err = snd_motu_stream_cache_packet_formats(motu); - if (err < 0) - return err; - - // Stop stream if rate is different. - err = protocol->get_clock_rate(motu, &curr_rate); - if (err < 0) { - dev_err(&motu->unit->device, - "fail to get sampling rate: %d\n", err); - return err; - } - if (rate == 0) - rate = curr_rate; - if (rate != curr_rate || - amdtp_streaming_error(&motu->rx_stream) || + if (amdtp_streaming_error(&motu->rx_stream) || amdtp_streaming_error(&motu->tx_stream)) finish_session(motu); if (!amdtp_stream_running(&motu->rx_stream)) { - err = protocol->set_clock_rate(motu, rate); - if (err < 0) { - dev_err(&motu->unit->device, - "fail to set sampling rate: %d\n", err); - return err; - } - err = ensure_packet_formats(motu); if (err < 0) return err; - err = begin_session(motu, rate); + err = begin_session(motu); if (err < 0) { dev_err(&motu->unit->device, "fail to start isochronous comm: %d\n", err); @@ -251,7 +264,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) goto stop_streams; } - err = protocol->switch_fetching_mode(motu, true); + err = motu->spec->protocol->switch_fetching_mode(motu, true); if (err < 0) { dev_err(&motu->unit->device, "fail to enable frame fetching: %d\n", err); @@ -264,7 +277,6 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) if (err < 0) { dev_err(&motu->unit->device, "fail to start IR context: %d", err); - amdtp_stream_stop(&motu->rx_stream); goto stop_streams; } } diff --git a/sound/firewire/motu/motu.h b/sound/firewire/motu/motu.h index ae4b37cdfade..32cd42873fd0 100644 --- a/sound/firewire/motu/motu.h +++ b/sound/firewire/motu/motu.h @@ -153,7 +153,9 @@ void snd_motu_transaction_unregister(struct snd_motu *motu); int snd_motu_stream_init_duplex(struct snd_motu *motu); void snd_motu_stream_destroy_duplex(struct snd_motu *motu); int snd_motu_stream_cache_packet_formats(struct snd_motu *motu); -int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate); +int snd_motu_stream_reserve_duplex(struct snd_motu *motu, unsigned int rate); +void snd_motu_stream_release_duplex(struct snd_motu *motu); +int snd_motu_stream_start_duplex(struct snd_motu *motu); void snd_motu_stream_stop_duplex(struct snd_motu *motu); int snd_motu_stream_lock_try(struct snd_motu *motu); void snd_motu_stream_lock_release(struct snd_motu *motu); From patchwork Mon Jun 17 08:15:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10998341 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 186B7924 for ; Mon, 17 Jun 2019 08:23:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A4F4287AA for ; Mon, 17 Jun 2019 08:23:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F287E28807; Mon, 17 Jun 2019 08:23:31 +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 4797D287AA for ; Mon, 17 Jun 2019 08:23:31 +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 8662517A8; Mon, 17 Jun 2019 10:22:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8662517A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560759809; bh=e/QEfBdDc9ccrRaligMx+VFj4RpELKUDxJrDKfuG/gU=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TwBoCjKB3KNU49yM+w63L2u2Q2aDxOim4wgkIMWIDBv35wqqkeslilIbaqS+7vKyX LCj+BLKQMjSZB05VYc0Mnv+4wpVSo9IdvxakNmhNDToU0UQQBni3NIlR+Af84yHFbY iNdVrsIhzGT4sL+maKjm4gYZN1KWSe93jnwGTzJs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 888EBF89761; Mon, 17 Jun 2019 10:16:26 +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 103F2F8973B; Mon, 17 Jun 2019 10:15:33 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 44AD6F896F9 for ; Mon, 17 Jun 2019 10:15:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 44AD6F896F9 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="vb7JLbHh"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nFAOLjjz" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id A0F44735; Mon, 17 Jun 2019 04:15:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 17 Jun 2019 04:15:29 -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=TWnX/+x+L6MGp Ln74MxPYPkukErCID7QKB4H0QvPw+U=; b=vb7JLbHhebaCKGn3rh+K2IlPVn8r7 FkqFdcmZbQNZI476jKOWx9QwORgsM4JBImdc8fworWfFNEw/YCM8Q5oyAABlfWcK IoT4aM/gFTRICQPqD3Xvb2XWXNCeYyfYKb1PuSUfymLWgWW2LmtUSlsOi02R8LXC 8reSUppOgPp/mus6sXYtJSaAUGmWQaapxgvNTguc9lDWN5SM+tN4U/fI3hUp1wPh OkgHHhAzH1E8kJ2EazPC8nsNnS8WPU8DIubla94MJhIk83zONsaAFlACZPntXjuz sS6ew/lAMvz16MvJe6r2YAQJD6o+KBAvIOblUt+ZTx0iffnSxGhN4ctuw== 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= fm3; bh=TWnX/+x+L6MGpLn74MxPYPkukErCID7QKB4H0QvPw+U=; b=nFAOLjjz UGIYlUzaxW4DU0Q1PyHp3ppZO/teSWP/L/AzSDwiw3r4vvC3vF/MW/lGQnX8N9K6 bbpYQhjjcgNi3tPw6ywsiu/G9CnY7bm++Z7GqI4euHygCnAQXAwrKApywnWQUAUl wGXn3KRnk41FmyC8pRW4GNNtWZV9sGE15Nv8HaKucCHe1YxpGXf93YZtoWot1PFj keM7acPseuhfncoomKX4bzDSf2oY0FAfWrKOp6Ec6BkJSIHWeiP9ecHit1FadMlC CUA9xHMcIX/TDsm3K4NtwrYwQ4IX8bktfii/2crer7Ck1TmMIHiQeDysRLrmxf9/ A4w6MTOE4EZetg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeijedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepie X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id E1F0D80062; Mon, 17 Jun 2019 04:15:27 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Jun 2019 17:15:09 +0900 Message-Id: <20190617081510.11025-10-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp> References: <20190617081510.11025-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 09/10] ALSA: firewire-motu: update isochronous resources when starting packet streaming after bus-reset 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 After bus reset, isochronous resource manager releases all of allocated isochronous resources. The nodes to transfer isochronous packet should request reallocation of the resources. However, between the bus-reset and invocation of 'struct fw_driver.update' handler, ALSA PCM application can detect this situation by XRUN because the target device cancelled to transmit packets once bus-reset occurs. Due to the above mechanism, ALSA fireface driver just stops packet streaming in the update handler, thus pcm.prepare handler should request the reallocation. This commit requests the reallocation in pcm.prepare callback when bus generation is changed. Signed-off-by: Takashi Sakamoto --- sound/firewire/motu/motu-stream.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index 5630a8f1f2f1..82891583b736 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -236,6 +236,7 @@ static int ensure_packet_formats(struct snd_motu *motu) int snd_motu_stream_start_duplex(struct snd_motu *motu) { + unsigned int generation = motu->rx_resources.generation; int err = 0; if (motu->substreams_counter == 0) @@ -245,6 +246,16 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu) amdtp_streaming_error(&motu->tx_stream)) finish_session(motu); + if (generation != fw_parent_device(motu->unit)->card->generation) { + err = fw_iso_resources_update(&motu->rx_resources); + if (err < 0) + return err; + + err = fw_iso_resources_update(&motu->tx_resources); + if (err < 0) + return err; + } + if (!amdtp_stream_running(&motu->rx_stream)) { err = ensure_packet_formats(motu); if (err < 0) From patchwork Mon Jun 17 08:15:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10998337 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 D4929924 for ; Mon, 17 Jun 2019 08:22:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7027287AA for ; Mon, 17 Jun 2019 08:22:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB80328807; Mon, 17 Jun 2019 08:22:44 +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 0CB03287AA for ; Mon, 17 Jun 2019 08:22:44 +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 5B7941781; Mon, 17 Jun 2019 10:21:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5B7941781 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560759762; bh=OgxFAh6JwjgCwh3uPqU5QcWHTHxh1awle0SPYqDmvjc=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bcQApNLiKTUib0wAJBkRkM8JtdzfgJQcO5T5XoblnRIDlduFqhSo6+HSj2sf8SRDw sbaSIgBwcKd7dSx95Xsu5xhXF05ZnFNoifeBUdU47Diu57/uqYRpQUv/SdqIPMA4qH /TkGYNVoDopVQ9laKt+mcg7xNVCs54rRzX86AKKs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EA973F89757; Mon, 17 Jun 2019 10:16:18 +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 0DA37F80764; Mon, 17 Jun 2019 10:15:35 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BB153F89739 for ; Mon, 17 Jun 2019 10:15:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BB153F89739 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="Yn+22299"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="zo1nCidY" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 29FD5755; Mon, 17 Jun 2019 04:15:31 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 17 Jun 2019 04:15:31 -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=U23GM6M3i9NKb CDjWX/JHbaBL7DmpVhKMru0EUgAZqY=; b=Yn+22299z6aZHDwUF8tG7D7bgxejl Hvq/5mY7mnTMdm+zJCFexX1f4jxSPUb3slr/+7Qw4KliwPvauGUbp3wgfWEkUwz6 Jqh06ep+Kz+RkbL3M5Fwf+1XoC4tvjoj35peqqQyWA3x/vhl5MgzNhi8dkWtDLhM J7co+3joe8nVKZ7e0xoMdSZup9OiWjn9gi+7BEaJuqpa5JxOZwImYAGPdx7Oo9/Z 6GAUCK2ewbZRLAmL/EFuDOIpKUEy8aWf+WBYRAl/2mI7TFcxcVuEc5ueVXsOLq4M AlbHoGqRWhMiRL0qhO/ie74Z+iqMR+5ouodmknSdHBWQqywCSAXwVkxzg== 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= fm3; bh=U23GM6M3i9NKbCDjWX/JHbaBL7DmpVhKMru0EUgAZqY=; b=zo1nCidY 6LCDMdfPa7NmeArdUNHb+2JZB4cMNlt+6pyjM6TlcY/5OZZkrRDivqIrTnmWZgnF 05WypnqnD+q7m6kecK+cMwESUO4q3qdrYgHvReXlWLqBdZY/rUEtxQ7f2rkzkIn7 3VyBUjm+VRAOWxMmeN+8o0UK/dPACFMGmVDV0KAo5pVAq9dNKBBiNE8mLwwf6Xs4 q3kkVtScZ09EbzFIV6qxsrR/it3GZsvyrWSwPm8PNoYggjPzL64XfyzrIdeZQalt wIi1x+l0d1pUtwhAamydypMHxkjqugiItK2NEniJU6roHMy95Z+eV7ArH6QCdWs7 ArSRbBhTQDRwxA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeijedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepie X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 6529580063; Mon, 17 Jun 2019 04:15:29 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Mon, 17 Jun 2019 17:15:10 +0900 Message-Id: <20190617081510.11025-11-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp> References: <20190617081510.11025-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 10/10] ALSA: firewire-motu: code refactoring for pcm.hw_params/hw_free callbacks 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 pairs of pcm.hw_params callbacks and .hw_free callbacks for both direction have no differences. This commit unifies the pairs. Signed-off-by: Takashi Sakamoto --- sound/firewire/motu/motu-pcm.c | 54 +++++----------------------------- 1 file changed, 7 insertions(+), 47 deletions(-) diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c index d4e75d3ee928..b9852c911b98 100644 --- a/sound/firewire/motu/motu-pcm.c +++ b/sound/firewire/motu/motu-pcm.c @@ -190,8 +190,8 @@ static int pcm_close(struct snd_pcm_substream *substream) return 0; } -static int capture_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) +static int pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { struct snd_motu *motu = substream->private_data; int err; @@ -213,48 +213,8 @@ static int capture_hw_params(struct snd_pcm_substream *substream, return err; } -static int playback_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - struct snd_motu *motu = substream->private_data; - int err; - - err = snd_pcm_lib_alloc_vmalloc_buffer(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; - - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { - unsigned int rate = params_rate(hw_params); - - mutex_lock(&motu->mutex); - err = snd_motu_stream_reserve_duplex(motu, rate); - if (err >= 0) - ++motu->substreams_counter; - mutex_unlock(&motu->mutex); - } - - return err; -} - -static int capture_hw_free(struct snd_pcm_substream *substream) -{ - struct snd_motu *motu = substream->private_data; - - mutex_lock(&motu->mutex); - - if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) - --motu->substreams_counter; - - snd_motu_stream_stop_duplex(motu); - snd_motu_stream_release_duplex(motu); - - mutex_unlock(&motu->mutex); - - return snd_pcm_lib_free_vmalloc_buffer(substream); -} -static int playback_hw_free(struct snd_pcm_substream *substream) +static int pcm_hw_free(struct snd_pcm_substream *substream) { struct snd_motu *motu = substream->private_data; @@ -366,8 +326,8 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu) .open = pcm_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = capture_hw_params, - .hw_free = capture_hw_free, + .hw_params = pcm_hw_params, + .hw_free = pcm_hw_free, .prepare = capture_prepare, .trigger = capture_trigger, .pointer = capture_pointer, @@ -378,8 +338,8 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu) .open = pcm_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = playback_hw_params, - .hw_free = playback_hw_free, + .hw_params = pcm_hw_params, + .hw_free = pcm_hw_free, .prepare = playback_prepare, .trigger = playback_trigger, .pointer = playback_pointer,