From patchwork Wed Jun 12 08:44: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: 10988979 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 1D55014E5 for ; Wed, 12 Jun 2019 08:46:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08922289DD for ; Wed, 12 Jun 2019 08:46:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0E72289E2; Wed, 12 Jun 2019 08:46:25 +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 C6476289DD for ; Wed, 12 Jun 2019 08:46:24 +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 37E7F170F; Wed, 12 Jun 2019 10:45:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 37E7F170F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329182; bh=J/jnDmGyeDXyU4s8ewyFXKrwjHjGynofEcp7Is3OlRE=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GfeTs0FwaNE+CdLTXLpbZ1tVNrg5rqjYh3U+OZ8VNHpUgGXqvG0v6YCtUrp7/6wJK 8yiOZylx4czAWF3vVjXFjSaGrfsuYKl/vT2n/pKuKvflmmKeZp73uzlU0Rwed0Uq6Z ya4egHhTZQouGUdnPSH46ue9GecYmCvQXPwCEYac= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 55AD1F8970C; Wed, 12 Jun 2019 10:44:38 +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 34DA4F896FA; Wed, 12 Jun 2019 10:44:35 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 05856F80794 for ; Wed, 12 Jun 2019 10:44:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 05856F80794 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="cdkbC09A"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="xPYqGtUB" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 00507571; Wed, 12 Jun 2019 04:44:28 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44: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=N80KTrc1b8G38 zVDczRaf9RvO1ea5Q1NNcP0I34ICT4=; b=cdkbC09AcqtCzYb06nJdCTFTfXrZ1 RYqDbJLDB9XI0pWlKxO7TS+qTEYzDXpnJazmgyayrIxbRNxY2HgYR0B3mE5sQYVQ 0kr0/hO8hr5F92CmbmwuF/SWw2hY3TqnmrQkZykX+Ot11iNa1CbuIq1iMU/guPNe 7DHNcPgMh0IcRx8ISB6aNQfAfYX8K2nX0Frwo99YkEuuR/z8eXQHMibXxVDJSYTa K3mYExrEkuYQgthW8HxraTfKmk2bJK1lHvPwq7ozIKVdkAYVewW3i42j3FCiEWTy 65acea7BMm0EkGUI1E813MmSALfZyxxccNnIfEYHM4m6UVWop2veAFFYQ== 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=N80KTrc1b8G38zVDczRaf9RvO1ea5Q1NNcP0I34ICT4=; b=xPYqGtUB eLASsNDnrMB42JtnfiqRD5+IYj7KBkTvGilQtTi01bqF02lm2ahfljOcbDLg82NC Kfnz6lON7QAS9lR4eCo5BYjuX9BE4WpSwT7gar5BznHMmUoCuHXGHSrsMU0Jft48 VSZvJ2VaxLssW/NPLBshUbpoH3hLO3nW6PahIoY5QK/2+xqTFLgtLaWrefPixbmp N6pr0OaUOK1JYikS9MzKbybABzI5mnpepfQIRM+/ddmKL96cDi7EeKe2Deds9cHp zzI+OvSaStqXKZOtCTFXdNej3/raZIs0V/zsxmRJlooLsOQ5KR7oy+huAO3T1D8n nTst+2KTRnBh3A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf 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 E4A3A380087; Wed, 12 Jun 2019 04:44:26 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:04 +0900 Message-Id: <20190612084422.5344-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 01/19] ALSA: bebob: configure sampling transfer frequency in pcm.hw_params callback 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. At present, several operations are done in pcm.prepare callback. To reduce load of the callback, This commit splits out an operation to set sampling transfer frequency in pcm.hw_params callback. Signed-off-by: Takashi Sakamoto --- sound/firewire/bebob/bebob.h | 3 +- sound/firewire/bebob/bebob_midi.c | 22 +-- sound/firewire/bebob/bebob_pcm.c | 22 +-- sound/firewire/bebob/bebob_stream.c | 212 ++++++++++++++-------------- 4 files changed, 136 insertions(+), 123 deletions(-) diff --git a/sound/firewire/bebob/bebob.h b/sound/firewire/bebob/bebob.h index df1b1e94c43c..c30ed44aced9 100644 --- a/sound/firewire/bebob/bebob.h +++ b/sound/firewire/bebob/bebob.h @@ -218,7 +218,8 @@ int snd_bebob_stream_get_clock_src(struct snd_bebob *bebob, enum snd_bebob_clock_type *src); int snd_bebob_stream_discover(struct snd_bebob *bebob); int snd_bebob_stream_init_duplex(struct snd_bebob *bebob); -int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, unsigned int rate); +int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate); +int snd_bebob_stream_start_duplex(struct snd_bebob *bebob); void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob); void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob); diff --git a/sound/firewire/bebob/bebob_midi.c b/sound/firewire/bebob/bebob_midi.c index 3befa3eca6ef..e2d3cad39d28 100644 --- a/sound/firewire/bebob/bebob_midi.c +++ b/sound/firewire/bebob/bebob_midi.c @@ -15,15 +15,18 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) err = snd_bebob_stream_lock_try(bebob); if (err < 0) - goto end; + return err; mutex_lock(&bebob->mutex); - bebob->substreams_counter++; - err = snd_bebob_stream_start_duplex(bebob, 0); + err = snd_bebob_stream_reserve_duplex(bebob, 0); + if (err >= 0) { + ++bebob->substreams_counter; + err = snd_bebob_stream_start_duplex(bebob); + } mutex_unlock(&bebob->mutex); if (err < 0) snd_bebob_stream_lock_release(bebob); -end: + return err; } @@ -34,15 +37,18 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream) err = snd_bebob_stream_lock_try(bebob); if (err < 0) - goto end; + return err; mutex_lock(&bebob->mutex); - bebob->substreams_counter++; - err = snd_bebob_stream_start_duplex(bebob, 0); + err = snd_bebob_stream_reserve_duplex(bebob, 0); + if (err >= 0) { + ++bebob->substreams_counter; + err = snd_bebob_stream_start_duplex(bebob); + } mutex_unlock(&bebob->mutex); if (err < 0) snd_bebob_stream_lock_release(bebob); -end: + return err; } diff --git a/sound/firewire/bebob/bebob_pcm.c b/sound/firewire/bebob/bebob_pcm.c index ea9b86450580..71b6ede31bb2 100644 --- a/sound/firewire/bebob/bebob_pcm.c +++ b/sound/firewire/bebob/bebob_pcm.c @@ -198,12 +198,16 @@ pcm_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(&bebob->mutex); - bebob->substreams_counter++; + err = snd_bebob_stream_reserve_duplex(bebob, rate); + if (err >= 0) + ++bebob->substreams_counter; mutex_unlock(&bebob->mutex); } - return 0; + return err; } static int pcm_playback_hw_params(struct snd_pcm_substream *substream, @@ -218,12 +222,16 @@ pcm_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(&bebob->mutex); - bebob->substreams_counter++; + err = snd_bebob_stream_reserve_duplex(bebob, rate); + if (err >= 0) + ++bebob->substreams_counter; mutex_unlock(&bebob->mutex); } - return 0; + return err; } static int @@ -261,10 +269,9 @@ static int pcm_capture_prepare(struct snd_pcm_substream *substream) { struct snd_bebob *bebob = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; int err; - err = snd_bebob_stream_start_duplex(bebob, runtime->rate); + err = snd_bebob_stream_start_duplex(bebob); if (err >= 0) amdtp_stream_pcm_prepare(&bebob->tx_stream); @@ -274,10 +281,9 @@ static int pcm_playback_prepare(struct snd_pcm_substream *substream) { struct snd_bebob *bebob = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; int err; - err = snd_bebob_stream_start_duplex(bebob, runtime->rate); + err = snd_bebob_stream_start_duplex(bebob); if (err >= 0) amdtp_stream_pcm_prepare(&bebob->rx_stream); diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index 4d3034a68bdf..fcc93156d0b7 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c @@ -418,49 +418,28 @@ check_connection_used_by_others(struct snd_bebob *bebob, struct amdtp_stream *s) return err; } -static int -make_both_connections(struct snd_bebob *bebob, unsigned int rate) +static int make_both_connections(struct snd_bebob *bebob) { - int index, pcm_channels, midi_channels, err = 0; + int err = 0; if (bebob->connected) - goto end; - - /* confirm params for both streams */ - err = get_formation_index(rate, &index); - if (err < 0) - goto end; - pcm_channels = bebob->tx_stream_formations[index].pcm; - midi_channels = bebob->tx_stream_formations[index].midi; - err = amdtp_am824_set_parameters(&bebob->tx_stream, rate, - pcm_channels, midi_channels * 8, - false); - if (err < 0) - goto end; - - pcm_channels = bebob->rx_stream_formations[index].pcm; - midi_channels = bebob->rx_stream_formations[index].midi; - err = amdtp_am824_set_parameters(&bebob->rx_stream, rate, - pcm_channels, midi_channels * 8, - false); - if (err < 0) - goto end; + return 0; - /* establish connections for both streams */ err = cmp_connection_establish(&bebob->out_conn, amdtp_stream_get_max_payload(&bebob->tx_stream)); if (err < 0) - goto end; + return err; + err = cmp_connection_establish(&bebob->in_conn, amdtp_stream_get_max_payload(&bebob->rx_stream)); if (err < 0) { cmp_connection_break(&bebob->out_conn); - goto end; + return err; } bebob->connected = true; -end: - return err; + + return 0; } static void @@ -484,8 +463,7 @@ destroy_both_connections(struct snd_bebob *bebob) } static int -start_stream(struct snd_bebob *bebob, struct amdtp_stream *stream, - unsigned int rate) +start_stream(struct snd_bebob *bebob, struct amdtp_stream *stream) { struct cmp_connection *conn; int err = 0; @@ -555,132 +533,154 @@ int snd_bebob_stream_init_duplex(struct snd_bebob *bebob) return err; } -int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, unsigned int rate) +static int keep_resources(struct snd_bebob *bebob, struct amdtp_stream *stream, + unsigned int rate, unsigned int index) { - const struct snd_bebob_rate_spec *rate_spec = bebob->spec->rate; - unsigned int curr_rate; - int err = 0; + struct snd_bebob_stream_formation *formation; - /* Need no substreams */ - if (bebob->substreams_counter == 0) - goto end; + if (stream == &bebob->tx_stream) + formation = bebob->tx_stream_formations + index; + else + formation = bebob->rx_stream_formations + index; - /* - * Considering JACK/FFADO streaming: - * TODO: This can be removed hwdep functionality becomes popular. - */ + return amdtp_am824_set_parameters(stream, rate, formation->pcm, + formation->midi, false); +} + +int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate) +{ + unsigned int curr_rate; + int err; + + // Considering JACK/FFADO streaming: + // TODO: This can be removed hwdep functionality becomes popular. err = check_connection_used_by_others(bebob, &bebob->rx_stream); if (err < 0) - goto end; + return err; - /* - * packet queueing error or detecting discontinuity - * - * At bus reset, connections should not be broken here. So streams need - * to be re-started. This is a reason to use SKIP_INIT_DBC_CHECK flag. - */ - if (amdtp_streaming_error(&bebob->rx_stream)) - amdtp_stream_stop(&bebob->rx_stream); - if (amdtp_streaming_error(&bebob->tx_stream)) + err = bebob->spec->rate->get(bebob, &curr_rate); + if (err < 0) + return err; + if (rate == 0) + rate = curr_rate; + if (curr_rate != rate) { amdtp_stream_stop(&bebob->tx_stream); - if (!amdtp_stream_running(&bebob->rx_stream) && - !amdtp_stream_running(&bebob->tx_stream)) + amdtp_stream_stop(&bebob->rx_stream); + break_both_connections(bebob); + } - /* stop streams if rate is different */ - err = rate_spec->get(bebob, &curr_rate); - if (err < 0) { - dev_err(&bebob->unit->device, - "fail to get sampling rate: %d\n", err); - goto end; + if (bebob->substreams_counter == 0 || curr_rate != rate) { + unsigned int index; + + // NOTE: + // If establishing connections at first, Yamaha GO46 + // (and maybe Terratec X24) don't generate sound. + // + // For firmware customized by M-Audio, refer to next NOTE. + err = bebob->spec->rate->set(bebob, rate); + if (err < 0) { + dev_err(&bebob->unit->device, + "fail to set sampling rate: %d\n", + err); + return err; + } + + err = get_formation_index(rate, &index); + if (err < 0) + return err; + + err = keep_resources(bebob, &bebob->tx_stream, rate, index); + if (err < 0) + return err; + + err = keep_resources(bebob, &bebob->rx_stream, rate, index); + if (err < 0) + return err; } - if (rate == 0) - rate = curr_rate; - if (rate != curr_rate) { + + return 0; +} + +int snd_bebob_stream_start_duplex(struct snd_bebob *bebob) +{ + int err; + + // Need no substreams. + if (bebob->substreams_counter == 0) + return -EIO; + + // packet queueing error or detecting discontinuity + if (amdtp_streaming_error(&bebob->rx_stream) || + amdtp_streaming_error(&bebob->tx_stream)) { amdtp_stream_stop(&bebob->rx_stream); amdtp_stream_stop(&bebob->tx_stream); + break_both_connections(bebob); } - /* master should be always running */ if (!amdtp_stream_running(&bebob->rx_stream)) { - /* - * NOTE: - * If establishing connections at first, Yamaha GO46 - * (and maybe Terratec X24) don't generate sound. - * - * For firmware customized by M-Audio, refer to next NOTE. - */ - if (bebob->maudio_special_quirk == NULL) { - err = rate_spec->set(bebob, rate); - if (err < 0) { - dev_err(&bebob->unit->device, - "fail to set sampling rate: %d\n", - err); - goto end; - } + unsigned int curr_rate; + + if (bebob->maudio_special_quirk) { + err = bebob->spec->rate->get(bebob, &curr_rate); + if (err < 0) + return err; } - err = make_both_connections(bebob, rate); + err = make_both_connections(bebob); if (err < 0) - goto end; + return err; - err = start_stream(bebob, &bebob->rx_stream, rate); + err = start_stream(bebob, &bebob->rx_stream); if (err < 0) { dev_err(&bebob->unit->device, "fail to run AMDTP master stream:%d\n", err); - break_both_connections(bebob); - goto end; + goto error; } - /* - * NOTE: - * The firmware customized by M-Audio uses these commands to - * start transmitting stream. This is not usual way. - */ - if (bebob->maudio_special_quirk != NULL) { - err = rate_spec->set(bebob, rate); + // NOTE: + // The firmware customized by M-Audio uses these commands to + // start transmitting stream. This is not usual way. + if (bebob->maudio_special_quirk) { + err = bebob->spec->rate->set(bebob, curr_rate); if (err < 0) { dev_err(&bebob->unit->device, "fail to ensure sampling rate: %d\n", err); - amdtp_stream_stop(&bebob->rx_stream); - break_both_connections(bebob); - goto end; + goto error; } } - /* wait first callback */ if (!amdtp_stream_wait_callback(&bebob->rx_stream, CALLBACK_TIMEOUT)) { amdtp_stream_stop(&bebob->rx_stream); break_both_connections(bebob); err = -ETIMEDOUT; - goto end; + goto error; } } - /* start slave if needed */ if (!amdtp_stream_running(&bebob->tx_stream)) { - err = start_stream(bebob, &bebob->tx_stream, rate); + err = start_stream(bebob, &bebob->tx_stream); if (err < 0) { dev_err(&bebob->unit->device, "fail to run AMDTP slave stream:%d\n", err); - amdtp_stream_stop(&bebob->rx_stream); - break_both_connections(bebob); - goto end; + goto error; } - /* wait first callback */ if (!amdtp_stream_wait_callback(&bebob->tx_stream, CALLBACK_TIMEOUT)) { - amdtp_stream_stop(&bebob->tx_stream); - amdtp_stream_stop(&bebob->rx_stream); - break_both_connections(bebob); err = -ETIMEDOUT; + goto error; } } -end: + + return 0; +error: + amdtp_stream_stop(&bebob->tx_stream); + amdtp_stream_stop(&bebob->rx_stream); + break_both_connections(bebob); return err; } From patchwork Wed Jun 12 08:44: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: 10988989 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 8FD0B13AD for ; Wed, 12 Jun 2019 08:47:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BCCC289DD for ; Wed, 12 Jun 2019 08:47:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 701FF289E2; Wed, 12 Jun 2019 08:47: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 C7C52289DD for ; Wed, 12 Jun 2019 08:47: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 1BD291706; Wed, 12 Jun 2019 10:46:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1BD291706 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329237; bh=uEGoTSHa4+0uRZo5/KpUrpLY7uuUa1g8WSoclMsRmiY=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qMt9G98p5Z/ZH0kA7XKtoHSulvscJXCO0lkra6MRbjxH50+vpApp+einZzTPI5uKe Jwj9ZsuWkPKq7MTLZpg0Lynj//b3Dsje9g2icJ467Lfln2YLLy12ZTs/choq+glXUe tQss0+pPVLBqI8vJQoiLTI8JoIzNGFegRdKsN9AU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0DB9DF89735; Wed, 12 Jun 2019 10:44: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 91727F896FA; Wed, 12 Jun 2019 10:44:36 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3AADEF896E0 for ; Wed, 12 Jun 2019 10:44:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3AADEF896E0 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="HcSOhFpN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dDNn9uZ+" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 5913921D; Wed, 12 Jun 2019 04:44:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:30 -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=rQPw2br47iJmu AB9R7SwY+syNnr+IhPNRTSQq5YT2hI=; b=HcSOhFpN5aG910+30ipfuGNoWxJZX NR6Hod52Lq8I/DJ6yiNHpNVQbyOuzzeLq6LP7Pwy6LKTlLWsfrvs6JUj/vSTKWCC kJR4AQuhl47HZEw/Qrg3W4ZHTQoaEM0Q1mVn9ieq/beyONggWgKlW1Bx/s3bDib0 pzo5MSS+XnLglGER3Xjhzt3whQJQItZ6elJkdqa7BMA72V5yK4OXQk9Lj9SUW7O/ gb7NtIPLTp3O4Y5+oca+osAmZto+Pe0PVpkF1FQP4yMI6LPPeINxXTO3hxB/x2q0 7x+IeYMbXZYo3n6Iski02xRH9t/9akdmp9T31Hm9N6dL3Q9oFmVBWJx2Q== 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=rQPw2br47iJmuAB9R7SwY+syNnr+IhPNRTSQq5YT2hI=; b=dDNn9uZ+ IBYtWkJwxMa26rxGRHdXdwr8L+21DV7SLTsz/KdDpdyqj9NM61tZ+l/CNPB7Mulh VmYAq5QXQ+W1dDq8QmBS+phy3hLMrFIBWwP/T/jvPfjeSk/GW/y9iLXc9ER/NQWU 7whFyYU3yeHdOZ65qe5diXrpZSczHUtWsUT/DTSd6yiQ6sy9hhtlbCtYEZR6FdYR GGwaoq+L0d6GR2dZNqSwSUvtJhNcqTBuD62yjMocNkNWA3JaYDCtHGZH6t4Nvg2z z/uDJU2IR62jk9frFR2oyltp2j2VhQ4TcWinSb+OWn6kTaZqjoRshDYWqMo0eBnZ cBPVZSquYYN6ag== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf 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 A5719380089; Wed, 12 Jun 2019 04:44:28 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:05 +0900 Message-Id: <20190612084422.5344-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 02/19] ALSA: bebob: don't set XRUN in 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 When stopping packet streaming, no need to stop PCM substream with XRUN state. This commit suppresses it. Signed-off-by: Takashi Sakamoto --- sound/firewire/bebob/bebob_stream.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index fcc93156d0b7..d6e7f13ef42d 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c @@ -687,10 +687,7 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob) void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob) { if (bebob->substreams_counter == 0) { - amdtp_stream_pcm_abort(&bebob->rx_stream); amdtp_stream_stop(&bebob->rx_stream); - - amdtp_stream_pcm_abort(&bebob->tx_stream); amdtp_stream_stop(&bebob->tx_stream); break_both_connections(bebob); From patchwork Wed Jun 12 08:44: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: 10988991 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 2DF4413AD for ; Wed, 12 Jun 2019 08:47:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B2D1289DD for ; Wed, 12 Jun 2019 08:47:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EBA9289E2; Wed, 12 Jun 2019 08:47:59 +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 5DC7E289DD for ; Wed, 12 Jun 2019 08:47:58 +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 B28BF1741; Wed, 12 Jun 2019 10:47:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B28BF1741 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329276; bh=0qKNc6+cLBq70Y8YGkt8epmZtJszzou3r9k9mOu+7go=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Iy/ZzrpdQGXItJfjhagHSxsWnsahe9HOvkYhRhk/nuD3wlPsBmAe0igLsD3PGA1tk VQSfGwUhRlK36qJRV358dPXovmnDPfeRu+aH5pnO9oELrYbKCuSnAeix59/x9s9Ir0 znLi7RjKDMonQ7XCeiA59czYEp/GvKK6x2bBapho= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 52BE4F8973A; Wed, 12 Jun 2019 10:44:46 +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 7C18CF89716; Wed, 12 Jun 2019 10:44:37 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0B7B5F896CE for ; Wed, 12 Jun 2019 10:44:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0B7B5F896CE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="rykl7k7u"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cPNuGqG6" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id E0FD4582; Wed, 12 Jun 2019 04:44:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:32 -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=zUidyvmODaEuX 5OyBSELjKVAHIV4sHecrkd0SlmOwGU=; b=rykl7k7u/uQZ1dpFCpvaoQksYi+XH RdahUZgbZFRzJfrigNoXqZkw9Ld/Vapi0/wqeE0EGbEnGZfeJkJF4WhfQuDN+wWJ rxUWAUbL00r432iho3YdXGr9yZxelYRnFa52rJBvkiuCkxRrZEJfuBd+TvUTqBD+ DYxOv9OyFnWD3KL7FHm5ut5iyLDDpj/4y69I3GDybRSqmNPqnjyaTVfabDvIlKYg 3+8x5KUmXfL/zPQcSC59q8WBrNi9HodyGFjm9NCNVfqC9DAe44H88jz5Vg+HH5wd 8MvwOpmkDvuv4OjS60PkPlrMRRR3MbO+huVbBIMZKBOEgoNqQKjr8MlyA== 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=zUidyvmODaEuX5OyBSELjKVAHIV4sHecrkd0SlmOwGU=; b=cPNuGqG6 nTv4/+767C+IgfwB/AKQ6cV9KmKJ23uc6rRTeWLvWVRsWhwNRuLbZizTP/jQAckz i7r34lZfDn/tzXQphtIBzN2/LBeaFX7rNOX116dOvnreRxjBHEmhfw1HDHoZrguK heoaytg0Zdo/S7Lo1gBU+Cmcxzkvgmv/mp1n+WER1hSpGLblsAWjgMYpG+08H+Im myYXaTyvbobD16IGi9bm6Q5eCg+vOKzi6L3FDqsx5XxLUAGVdNZyWRgUQWBVZgzc d+7LbPmvv5iHCu2sZM4a8cAXmeXssHB0BkRMzeKI7PtH8Efo0G9kJbbue8AFati8 /aChqF78COtg8A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf 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 3165738008E; Wed, 12 Jun 2019 04:44:29 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:06 +0900 Message-Id: <20190612084422.5344-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 03/19] ALSA: bebob: obsolete useless member of private structure 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 private structure of this driver has 'connected' member but nowadays it's useless. This commit removes it. Signed-off-by: Takashi Sakamoto --- sound/firewire/bebob/bebob.h | 2 -- sound/firewire/bebob/bebob_stream.c | 7 ------- 2 files changed, 9 deletions(-) diff --git a/sound/firewire/bebob/bebob.h b/sound/firewire/bebob/bebob.h index c30ed44aced9..20ed2dbd8d61 100644 --- a/sound/firewire/bebob/bebob.h +++ b/sound/firewire/bebob/bebob.h @@ -93,8 +93,6 @@ struct snd_bebob { unsigned int midi_input_ports; unsigned int midi_output_ports; - bool connected; - struct amdtp_stream tx_stream; struct amdtp_stream rx_stream; struct cmp_connection out_conn; diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index d6e7f13ef42d..c3cc31df49e0 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c @@ -422,9 +422,6 @@ static int make_both_connections(struct snd_bebob *bebob) { int err = 0; - if (bebob->connected) - return 0; - err = cmp_connection_establish(&bebob->out_conn, amdtp_stream_get_max_payload(&bebob->tx_stream)); if (err < 0) @@ -437,8 +434,6 @@ static int make_both_connections(struct snd_bebob *bebob) return err; } - bebob->connected = true; - return 0; } @@ -448,8 +443,6 @@ break_both_connections(struct snd_bebob *bebob) cmp_connection_break(&bebob->in_conn); cmp_connection_break(&bebob->out_conn); - bebob->connected = false; - /* These models seems to be in transition state for a longer time. */ if (bebob->maudio_special_quirk != NULL) msleep(200); From patchwork Wed Jun 12 08:44: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: 10988993 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 86A8B13AD for ; Wed, 12 Jun 2019 08:48:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 728C2289DD for ; Wed, 12 Jun 2019 08:48:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65F93289E2; Wed, 12 Jun 2019 08:48:41 +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 8EC39289DD for ; Wed, 12 Jun 2019 08:48:40 +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 BDDB01744; Wed, 12 Jun 2019 10:47:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BDDB01744 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329318; bh=gEolTqHm5x6zCVrm7uB8G1xWYqa69Lj/mbBw3e0C0Dk=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=APDXk9FYJ/YkJlvhrmYQHIVHjAv5++K8YH9AKhf/82rtMEP9ghc4ZLp1cwnP0cE0i M6ojYRysA8Qp9dVAvyWUcufCCfPrEg8f2wQ9JFvQ5gPlekG1JF3PbyErN1PjtUQjtu RV+wQ4bCsmOcqZuqB2gjXlNiM/ncINBCZNkFnoAY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A53DCF89742; Wed, 12 Jun 2019 10:44:48 +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 12470F89732; Wed, 12 Jun 2019 10:44:38 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1CA8EF806F5 for ; Wed, 12 Jun 2019 10:44:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1CA8EF806F5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="OFUNBiAD"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mOrd7ucP" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 82E4E46C; Wed, 12 Jun 2019 04:44:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:33 -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=+3clEX46uyahU PVl8agzk/dT6ePWzIyvM33o4X55loo=; b=OFUNBiADovT4/Dc8RT/hZ8lyjj+RT 8CNOnf8zR+adzo7IhncIa7fm8l8qDI1ReC8mSPU5DZ9+eFjVeIIEjBL4A9VfESZZ +ZMrYOajZUZVDoXGx/Y4RgyOH1Z0NhPBshm5rifg94ZsLtdlOpgckyg6fyIlDzxK yc2nJVwzQ7ls+hOx3EwK6eZqYt8jliNenLZc8JfR3VE6tvhUWkKILfrgyuKj/wM8 BL4B4j/qnB8hNBDPtAqIg8mxtYV9+uCQF9xH70u3ljOkj0HgSh0aBw4kS9rqvVFA V41iHyENJzwwj98aSErAi9tqHcO6YBF7I74ZDdKRj8BN8aQZ6ATGPTmEA== 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=+3clEX46uyahUPVl8agzk/dT6ePWzIyvM33o4X55loo=; b=mOrd7ucP sNDBdTFpIUjOyvNS2FxjUchzFARDt3c96Op3jQ8FIdrsFnywsPNrh59YAgoleLxC aktsBN1Qst8N1xGK8HrGFErH18GB3s8y+GV6oz1TlCh3Ui3uwLFwuyIfVR254OXe /XtIJ07Lau0CfixfGL7Ca9UDZI+JJuTXyrvUPiFLSpqChl1ESL3tN2AtvI9qauYY P+gxVJq0qGxjhDMdKHhn/Z57IemZX67BEhq1Q9hnExd2XFH84W/sQf0aJ4xZtAEY 8HcuWWD8VKh9wcSSlT4Q6ZCr1sexmE/IKZu4OWYLa+urOaQl2Dw8Rp9S1OXdAA+G +F/uvbqtE3XA/g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf 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 B567938008A; Wed, 12 Jun 2019 04:44:31 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:07 +0900 Message-Id: <20190612084422.5344-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 04/19] ALSA: bebob: code refactoring to initialize/destroy stream data 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 changes helper functions to initialize/destroy stream data so that it has an argument for direction. Signed-off-by: Takashi Sakamoto --- sound/firewire/bebob/bebob_stream.c | 121 ++++++++++++++-------------- 1 file changed, 61 insertions(+), 60 deletions(-) diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index c3cc31df49e0..6aab3dc99bef 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c @@ -376,24 +376,6 @@ map_data_channels(struct snd_bebob *bebob, struct amdtp_stream *s) return err; } -static int -init_both_connections(struct snd_bebob *bebob) -{ - int err; - - err = cmp_connection_init(&bebob->in_conn, - bebob->unit, CMP_INPUT, 0); - if (err < 0) - goto end; - - err = cmp_connection_init(&bebob->out_conn, - bebob->unit, CMP_OUTPUT, 0); - if (err < 0) - cmp_connection_destroy(&bebob->in_conn); -end: - return err; -} - static int check_connection_used_by_others(struct snd_bebob *bebob, struct amdtp_stream *s) { @@ -448,13 +430,6 @@ break_both_connections(struct snd_bebob *bebob) msleep(200); } -static void -destroy_both_connections(struct snd_bebob *bebob) -{ - cmp_connection_destroy(&bebob->in_conn); - cmp_connection_destroy(&bebob->out_conn); -} - static int start_stream(struct snd_bebob *bebob, struct amdtp_stream *stream) { @@ -481,49 +456,77 @@ start_stream(struct snd_bebob *bebob, struct amdtp_stream *stream) return err; } -int snd_bebob_stream_init_duplex(struct snd_bebob *bebob) +static int init_stream(struct snd_bebob *bebob, struct amdtp_stream *stream) { + enum amdtp_stream_direction dir_stream; + struct cmp_connection *conn; + enum cmp_direction dir_conn; int err; - err = init_both_connections(bebob); + if (stream == &bebob->tx_stream) { + dir_stream = AMDTP_IN_STREAM; + conn = &bebob->out_conn; + dir_conn = CMP_OUTPUT; + } else { + dir_stream = AMDTP_OUT_STREAM; + conn = &bebob->in_conn; + dir_conn = CMP_INPUT; + } + + err = cmp_connection_init(conn, bebob->unit, dir_conn, 0); if (err < 0) - goto end; + return err; - err = amdtp_am824_init(&bebob->tx_stream, bebob->unit, - AMDTP_IN_STREAM, CIP_BLOCKING); + err = amdtp_am824_init(stream, bebob->unit, dir_stream, CIP_BLOCKING); if (err < 0) { - amdtp_stream_destroy(&bebob->tx_stream); - destroy_both_connections(bebob); - goto end; + cmp_connection_destroy(conn); + return err; } - /* - * BeBoB v3 transfers packets with these qurks: - * - In the beginning of streaming, the value of dbc is incremented - * even if no data blocks are transferred. - * - The value of dbc is reset suddenly. - */ - if (bebob->version > 2) - bebob->tx_stream.flags |= CIP_EMPTY_HAS_WRONG_DBC | - CIP_SKIP_DBC_ZERO_CHECK; + if (stream == &bebob->tx_stream) { + // BeBoB v3 transfers packets with these qurks: + // - In the beginning of streaming, the value of dbc is + // incremented even if no data blocks are transferred. + // - The value of dbc is reset suddenly. + if (bebob->version > 2) + bebob->tx_stream.flags |= CIP_EMPTY_HAS_WRONG_DBC | + CIP_SKIP_DBC_ZERO_CHECK; + + // At high sampling rate, M-Audio special firmware transmits + // empty packet with the value of dbc incremented by 8 but the + // others are valid to IEC 61883-1. + if (bebob->maudio_special_quirk) + bebob->tx_stream.flags |= CIP_EMPTY_HAS_WRONG_DBC; + } - /* - * At high sampling rate, M-Audio special firmware transmits empty - * packet with the value of dbc incremented by 8 but the others are - * valid to IEC 61883-1. - */ - if (bebob->maudio_special_quirk) - bebob->tx_stream.flags |= CIP_EMPTY_HAS_WRONG_DBC; + return 0; +} + +static void destroy_stream(struct snd_bebob *bebob, struct amdtp_stream *stream) +{ + amdtp_stream_destroy(stream); + + if (stream == &bebob->tx_stream) + cmp_connection_destroy(&bebob->out_conn); + else + cmp_connection_destroy(&bebob->in_conn); +} - err = amdtp_am824_init(&bebob->rx_stream, bebob->unit, - AMDTP_OUT_STREAM, CIP_BLOCKING); +int snd_bebob_stream_init_duplex(struct snd_bebob *bebob) +{ + int err; + + err = init_stream(bebob, &bebob->tx_stream); + if (err < 0) + return err; + + err = init_stream(bebob, &bebob->rx_stream); if (err < 0) { - amdtp_stream_destroy(&bebob->tx_stream); - amdtp_stream_destroy(&bebob->rx_stream); - destroy_both_connections(bebob); + destroy_stream(bebob, &bebob->tx_stream); + return err; } -end: - return err; + + return 0; } static int keep_resources(struct snd_bebob *bebob, struct amdtp_stream *stream, @@ -693,10 +696,8 @@ void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob) */ void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob) { - amdtp_stream_destroy(&bebob->rx_stream); - amdtp_stream_destroy(&bebob->tx_stream); - - destroy_both_connections(bebob); + destroy_stream(bebob, &bebob->tx_stream); + destroy_stream(bebob, &bebob->rx_stream); } /* From patchwork Wed Jun 12 08:44: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: 10988995 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 95CDD13AD for ; Wed, 12 Jun 2019 08:49:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FBCE289DD for ; Wed, 12 Jun 2019 08:49:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7100B289E2; Wed, 12 Jun 2019 08:49:13 +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 8EB27289DD for ; Wed, 12 Jun 2019 08:49:12 +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 AC992172F; Wed, 12 Jun 2019 10:48:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AC992172F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329350; bh=IOyQYNpdBoximlAnkXwi8GBcjDd4Xc0iRF7dQfZBtiA=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=b2Nw3fC4aZgmCNOFqrElw0jehZAENuT3uWQynGAOlmy9/86vGW8hAdUmebm3aoI7+ zTNEh+Cd/jMvQMVlHVqlk7d37v9syjvlQ5DQPFKGEqf8AW4HI63d3mx4BbtRtuWxAD stMHuqWu2f/S34Ebn/N7LFPnef5YumhZ/YpLYWXI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5BCA4F89745; Wed, 12 Jun 2019 10:44:51 +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 5147BF89716; Wed, 12 Jun 2019 10:44:40 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9A050F896CE for ; Wed, 12 Jun 2019 10:44:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9A050F896CE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="dCWnkJ1f"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Mt2TXBlQ" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 0B4205B1; Wed, 12 Jun 2019 04:44:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:35 -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=D0ZU6+diY2e/I 3r6fUQsOs3GJLrYSPNjCBdUcJLPm9A=; b=dCWnkJ1fVtOIvTR47nJDV2fkHl5gf H/Jf4GPAIjj8Dl5k1MFEKcu1j9CNAPWlUathU1ZsEpgaN/LK7eIw2B90Xe2UGy4i UXfS8554hbOn9fDZ4BHyEVL5Q2AGBX0EtaaURONyu1glqhYQTvpAunQNBo6ySVeg MQ76McvDKTv8kogyyNUzn6iJig+hnlw/dhWB6t1j1/aBK+ouSm3JvnpZ0JokZsS8 2+EBpkzyLCDUv3YwhhRWdjdICKKfSsK8AkFYZQeNCNYk323Bl3AqHj/ddiRPzKqI 9FU7O66XV0CSVWZjrfylW0EDRToLEnU9l/mRXtp1e3UmVMQ8qD4hzm4Ag== 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=D0ZU6+diY2e/I3r6fUQsOs3GJLrYSPNjCBdUcJLPm9A=; b=Mt2TXBlQ wk0dDgYCgb5Ok3W2zOr5lztbPR0zP2hdxyPVThUcxbWLOV0eTSm1nCfGj/RYnALf x/zHF3T4vliCnceG6gsbduNWr8ZO3oINFraQ5+qmvucyIyLzh1OjhosLixJSllZs GjkHtx4ivO3YESiZVobHeMKyUi3xgT1Xr7PuqCt9U1tU2MdWLTdsjtAFRZAOulKs Run9pnSdOM0Z5AHifEM+MtTX/3FWJQG5fV18ztahX3x22mwLz0uBSSTrg7YXrvjX i0E/9buJv9KWWxfNwDpYxXmC2lMxhtX2ffrXWjZ/RbV7/NSIDpiYrhHoTGnVWGws K5eUXrML62wVOA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepge 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 40721380087; Wed, 12 Jun 2019 04:44:33 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:08 +0900 Message-Id: <20190612084422.5344-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 05/19] ALSA: fireworks: unify substream counter 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. It's inconvenient to handle two isochronous context separately each other. This commit unifies the counters to handle the two at the same time. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireworks/fireworks.h | 3 +-- sound/firewire/fireworks/fireworks_midi.c | 8 +++--- sound/firewire/fireworks/fireworks_pcm.c | 8 +++--- sound/firewire/fireworks/fireworks_stream.c | 27 ++++++++------------- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/sound/firewire/fireworks/fireworks.h b/sound/firewire/fireworks/fireworks.h index 9b19c7f05d57..42a73038ba4d 100644 --- a/sound/firewire/fireworks/fireworks.h +++ b/sound/firewire/fireworks/fireworks.h @@ -89,8 +89,7 @@ struct snd_efw { struct amdtp_stream rx_stream; struct cmp_connection out_conn; struct cmp_connection in_conn; - unsigned int capture_substreams; - unsigned int playback_substreams; + unsigned int substreams_counter; /* hardware metering parameters */ unsigned int phys_out; diff --git a/sound/firewire/fireworks/fireworks_midi.c b/sound/firewire/fireworks/fireworks_midi.c index f5da2cd4ce42..7e78cdfe699e 100644 --- a/sound/firewire/fireworks/fireworks_midi.c +++ b/sound/firewire/fireworks/fireworks_midi.c @@ -18,7 +18,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) goto end; mutex_lock(&efw->mutex); - efw->capture_substreams++; + ++efw->substreams_counter; err = snd_efw_stream_start_duplex(efw, 0); mutex_unlock(&efw->mutex); if (err < 0) @@ -38,7 +38,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream) goto end; mutex_lock(&efw->mutex); - efw->playback_substreams++; + ++efw->substreams_counter; err = snd_efw_stream_start_duplex(efw, 0); mutex_unlock(&efw->mutex); if (err < 0) @@ -52,7 +52,7 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream) struct snd_efw *efw = substream->rmidi->private_data; mutex_lock(&efw->mutex); - efw->capture_substreams--; + --efw->substreams_counter; snd_efw_stream_stop_duplex(efw); mutex_unlock(&efw->mutex); @@ -65,7 +65,7 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream) struct snd_efw *efw = substream->rmidi->private_data; mutex_lock(&efw->mutex); - efw->playback_substreams--; + --efw->substreams_counter; snd_efw_stream_stop_duplex(efw); mutex_unlock(&efw->mutex); diff --git a/sound/firewire/fireworks/fireworks_pcm.c b/sound/firewire/fireworks/fireworks_pcm.c index aed566d82726..a66f6a381dac 100644 --- a/sound/firewire/fireworks/fireworks_pcm.c +++ b/sound/firewire/fireworks/fireworks_pcm.c @@ -232,7 +232,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream, if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { mutex_lock(&efw->mutex); - efw->capture_substreams++; + ++efw->substreams_counter; mutex_unlock(&efw->mutex); } @@ -251,7 +251,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream, if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { mutex_lock(&efw->mutex); - efw->playback_substreams++; + ++efw->substreams_counter; mutex_unlock(&efw->mutex); } @@ -264,7 +264,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream) if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) { mutex_lock(&efw->mutex); - efw->capture_substreams--; + --efw->substreams_counter; mutex_unlock(&efw->mutex); } @@ -278,7 +278,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream) if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) { mutex_lock(&efw->mutex); - efw->playback_substreams--; + --efw->substreams_counter; mutex_unlock(&efw->mutex); } diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index 74e122e6e68a..2df39befcde0 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c @@ -194,9 +194,9 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate) unsigned int curr_rate; int err = 0; - /* Need no substreams */ - if (efw->playback_substreams == 0 && efw->capture_substreams == 0) - goto end; + // Need no substreams. + if (efw->substreams_counter == 0) + return -EIO; /* * Considering JACK/FFADO streaming: @@ -206,19 +206,15 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate) if (err < 0) goto end; - /* packet queueing error */ - if (amdtp_streaming_error(&efw->tx_stream)) - stop_stream(efw, &efw->tx_stream); - if (amdtp_streaming_error(&efw->rx_stream)) - stop_stream(efw, &efw->rx_stream); - /* stop streams if rate is different */ err = snd_efw_command_get_sampling_rate(efw, &curr_rate); if (err < 0) goto end; if (rate == 0) rate = curr_rate; - if (rate != curr_rate) { + if (rate != curr_rate || + amdtp_streaming_error(&efw->tx_stream) || + amdtp_streaming_error(&efw->rx_stream)) { stop_stream(efw, &efw->tx_stream); stop_stream(efw, &efw->rx_stream); } @@ -237,13 +233,12 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate) } } - /* start slave if needed */ - if (efw->capture_substreams > 0 && - !amdtp_stream_running(&efw->tx_stream)) { + if (!amdtp_stream_running(&efw->tx_stream)) { err = start_stream(efw, &efw->tx_stream, rate); if (err < 0) { dev_err(&efw->unit->device, "fail to start AMDTP slave stream:%d\n", err); + stop_stream(efw, &efw->tx_stream); stop_stream(efw, &efw->rx_stream); } } @@ -253,11 +248,9 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate) void snd_efw_stream_stop_duplex(struct snd_efw *efw) { - if (efw->capture_substreams == 0) { + if (efw->substreams_counter == 0) { stop_stream(efw, &efw->tx_stream); - - if (efw->playback_substreams == 0) - stop_stream(efw, &efw->rx_stream); + stop_stream(efw, &efw->rx_stream); } } From patchwork Wed Jun 12 08:44: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: 10988997 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 1A1B014E5 for ; Wed, 12 Jun 2019 08:50:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0294C289DD for ; Wed, 12 Jun 2019 08:50:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E615F289E2; Wed, 12 Jun 2019 08:50:03 +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 31B1E289DD for ; Wed, 12 Jun 2019 08:50:03 +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 7B148175C; Wed, 12 Jun 2019 10:49:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7B148175C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329401; bh=9GTK2Dy4UJDlH+zfHdqV3Zm9tLhtt9YimHm9WI5wts4=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=HnTPuibC0yMUbNY9UOweA+hM1Xmi6Be9YpeCq4pWnDbMQb6Mr4iv6+08blrrMh4fG XVAvYiWGonv+xx0L3nAIC0+3UBKuBkSxOiXzU9TLBLr/xdZRjYUzokcPrWb0Et3Yw5 qlGwC6ZVEPYEaVNrvXltSCcr7biIcc3+X4ME7Fis= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 245CFF89751; Wed, 12 Jun 2019 10:44: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 BB644F89738; Wed, 12 Jun 2019 10:44:42 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 07B05F89731 for ; Wed, 12 Jun 2019 10:44:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 07B05F89731 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="NjXvHJO8"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="gRibVIKi" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 761B95B3; Wed, 12 Jun 2019 04:44:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:36 -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=fvU/ADFICi6Q8 mSRBV3xog/q6Xd0VjtIxX3GW4nA64o=; b=NjXvHJO8PszS7E2tPtEsCNX5S9kZO cZ4lZ9gK8UGSWNxMKx7v7w/QLdXH/vOZplWxjsO9+dE91ZxH9OKA9G9fgsbQ2pq9 LThnF7h0Sr8wsQfbz0D+AOZeA9RGFZaeBTdxaC1k9n1FSHs7NX1HEKvfwViYMgHM 1ANajBtWFoUM/PHjB2e7bQ4VmUitzIUlfwVkR95LhDVLpb7GyrmjGEwCqqUpsvq7 Od4my+X7t+NPilcYdCTR4zdIIKi31XduoJ9rmgnCth+TvP7JjddmR9T1XaarUwMy rm3LMOEHE5Bl5HOxfHatees3qKUSNYrq/5WqFwbrx2NiH0sUn4HqydPcw== 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=fvU/ADFICi6Q8mSRBV3xog/q6Xd0VjtIxX3GW4nA64o=; b=gRibVIKi TW/gb9YlwMWfrE9SUrw7qjAJl2+l1CIqro0+mhEJ6L4l4E8lTBIiaAnfbiS7cpmY q1e2GR6cxgMC04mD4JxrX5KA/HLVqpW6rBwz5jr3cbQ7fv7o94guT2NmIiHHuCeX R6DE0SCuyNcX2m90+GPNqenBGOUDCcAzeO0WYAHLnClBd93YtylQwv4704UsQmvo JDgpJBMd1aBjNyet91B1fC1O9ZUQT9Jl3rQgn5cszcK4CstvGN3gjCRu8RS8ljzh Lma0Dxnl6bVhJKhmmwRZZ7iUH2MRvlfMBCcuXAoEqT7fzfexApNfo/3cXKNZcyif 5VxU4/RWG0M5xQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuffhomhgrihhnpehrrgifmhhiughird hophgvnhenucfkphepudegrdefrdejhedrudekudenucfrrghrrghmpehmrghilhhfrhho mhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjphenucevlhhushhtvghruf hiiigvpedt 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 BD04E380089; Wed, 12 Jun 2019 04:44:34 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:09 +0900 Message-Id: <20190612084422.5344-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 06/19] ALSA: fireworks: code refactoring for rawmidi.open/close 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/fireworks/fireworks_midi.c | 45 +++-------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/sound/firewire/fireworks/fireworks_midi.c b/sound/firewire/fireworks/fireworks_midi.c index 7e78cdfe699e..ee5dc7be70b6 100644 --- a/sound/firewire/fireworks/fireworks_midi.c +++ b/sound/firewire/fireworks/fireworks_midi.c @@ -8,7 +8,7 @@ */ #include "fireworks.h" -static int midi_capture_open(struct snd_rawmidi_substream *substream) +static int midi_open(struct snd_rawmidi_substream *substream) { struct snd_efw *efw = substream->rmidi->private_data; int err; @@ -23,44 +23,11 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) mutex_unlock(&efw->mutex); if (err < 0) snd_efw_stream_lock_release(efw); - end: return err; } -static int midi_playback_open(struct snd_rawmidi_substream *substream) -{ - struct snd_efw *efw = substream->rmidi->private_data; - int err; - - err = snd_efw_stream_lock_try(efw); - if (err < 0) - goto end; - - mutex_lock(&efw->mutex); - ++efw->substreams_counter; - err = snd_efw_stream_start_duplex(efw, 0); - mutex_unlock(&efw->mutex); - if (err < 0) - snd_efw_stream_lock_release(efw); -end: - return err; -} - -static int midi_capture_close(struct snd_rawmidi_substream *substream) -{ - struct snd_efw *efw = substream->rmidi->private_data; - - mutex_lock(&efw->mutex); - --efw->substreams_counter; - snd_efw_stream_stop_duplex(efw); - mutex_unlock(&efw->mutex); - - snd_efw_stream_lock_release(efw); - return 0; -} - -static int midi_playback_close(struct snd_rawmidi_substream *substream) +static int midi_close(struct snd_rawmidi_substream *substream) { struct snd_efw *efw = substream->rmidi->private_data; @@ -121,13 +88,13 @@ static void set_midi_substream_names(struct snd_efw *efw, int snd_efw_create_midi_devices(struct snd_efw *efw) { 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 Wed Jun 12 08:44: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: 10988999 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 EBEB813AD for ; Wed, 12 Jun 2019 08:50:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D728828646 for ; Wed, 12 Jun 2019 08:50:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CABB528673; Wed, 12 Jun 2019 08:50: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 2193E28646 for ; Wed, 12 Jun 2019 08:50:40 +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 72DBF1762; Wed, 12 Jun 2019 10:49:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 72DBF1762 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329438; bh=hXwI+8KvpxW+6u/iJfEflRVMBLLKWC9gaIh/RJuIFR4=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=pJ1SR2uUkhdpcStONHw4xKKKcHBKIN/zaNCZbUk29brIgF25OizGNMmEq23VkL+9P JFDsLwM78UsyonFd1yaESDQ+n5JzJV76K5s9+ktk8DsgX/o6xbcB/31oaY8j9TxbUW ztYuY8J2B+aotZqwWoVTdQ9nNSMx+zsk9pnxXPro= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5F4F0F89757; Wed, 12 Jun 2019 10:44:55 +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 552E1F8973A; Wed, 12 Jun 2019 10:44:43 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B78E5F896CE for ; Wed, 12 Jun 2019 10:44:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B78E5F896CE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="GAunMQoe"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="UwWgLdDM" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 1DEA3571; Wed, 12 Jun 2019 04:44:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:38 -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=FUTGoQ7x1584K MF/g9Rzh6+f5kYFFKQqfEaEGsNUfSg=; b=GAunMQoePSdvcNCC1pbBhKCfYv9cq w0DV/qSel2bEo3skEaueWy3vtXS/kE8iKik3nbD2Scx+86AlngXLwQ1yQrUCxZbl Ewfno7fN+CQ00KHvH/ROyeA+LFRHm2I4fe8mACNqt+VTqNfbi8wx2NxZlEFXiRGw syyDOj4DvKfvnKXBWIzkdZ9cAC0VWZKi9NiYqXnSAsM6whl6437BsrW7g7csj+9G YDCog2EtmY1wgnI59vJNJo988/2m7xiyEdCUIr1CVelQnM7Ocq180Ehs/1Xry6q1 67pCaAMCg0KUggX1RVyu2TOM8jHBOjFQQ3SeoCPBsEoRWdALMFrbFOWxA== 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=FUTGoQ7x1584KMF/g9Rzh6+f5kYFFKQqfEaEGsNUfSg=; b=UwWgLdDM pwu71P+3Bzlt0S34ZuBBP+1Y9OX0Upn8hSBwws1M2ZuUd+K0buD+lrLtNV3T9MbQ bK1NwdAmV+HRY7qOv3kEQ5D2TVJptnslWiysfVQWZFZjGRMkUJp7Wl6MUvuIABsT ZJUrOY74psEu9msbHpfMf39KmrJrSUz1IuXhUIbDlgMZuaNi0J8rJ/4FZpdkmAnR ALFxvtR5bK0UaA7bjWnMXDc0vqGpX48ZpfCqD5vWCAHOHi2HwTn369csxvkFjmTs 6WqjTOf5LEGfjiwCHH/z4K6a0//vuxgWmu2GI3UAG4SUmTBYFAiOTS4UsQeLG0Sl jgo6uwuWjrXFyw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepge 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 47F1038008A; Wed, 12 Jun 2019 04:44:36 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:10 +0900 Message-Id: <20190612084422.5344-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 07/19] ALSA: fireworks: code refactoring for pcm.hw_params/hw_free 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 pcm.hw_params/hw_free but they have the same codes. This commit unifies each of the callbacks. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireworks/fireworks_pcm.c | 45 ++++-------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/sound/firewire/fireworks/fireworks_pcm.c b/sound/firewire/fireworks/fireworks_pcm.c index a66f6a381dac..398a6ad04c5f 100644 --- a/sound/firewire/fireworks/fireworks_pcm.c +++ b/sound/firewire/fireworks/fireworks_pcm.c @@ -219,7 +219,7 @@ static int pcm_close(struct snd_pcm_substream *substream) return 0; } -static int pcm_capture_hw_params(struct snd_pcm_substream *substream, +static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_efw *efw = substream->private_data; @@ -238,41 +238,8 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream, return 0; } -static int pcm_playback_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - struct snd_efw *efw = 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) { - mutex_lock(&efw->mutex); - ++efw->substreams_counter; - mutex_unlock(&efw->mutex); - } - - return 0; -} - -static int pcm_capture_hw_free(struct snd_pcm_substream *substream) -{ - struct snd_efw *efw = substream->private_data; - if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) { - mutex_lock(&efw->mutex); - --efw->substreams_counter; - mutex_unlock(&efw->mutex); - } - - snd_efw_stream_stop_duplex(efw); - - return snd_pcm_lib_free_vmalloc_buffer(substream); -} -static int pcm_playback_hw_free(struct snd_pcm_substream *substream) +static int pcm_hw_free(struct snd_pcm_substream *substream) { struct snd_efw *efw = substream->private_data; @@ -378,8 +345,8 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw) .open = pcm_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = pcm_capture_hw_params, - .hw_free = pcm_capture_hw_free, + .hw_params = pcm_hw_params, + .hw_free = pcm_hw_free, .prepare = pcm_capture_prepare, .trigger = pcm_capture_trigger, .pointer = pcm_capture_pointer, @@ -390,8 +357,8 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw) .open = pcm_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = pcm_playback_hw_params, - .hw_free = pcm_playback_hw_free, + .hw_params = pcm_hw_params, + .hw_free = pcm_hw_free, .prepare = pcm_playback_prepare, .trigger = pcm_playback_trigger, .pointer = pcm_playback_pointer, From patchwork Wed Jun 12 08:44:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989001 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 5896A1398 for ; Wed, 12 Jun 2019 08:51:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EC26289E0 for ; Wed, 12 Jun 2019 08:51:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F3322862A; Wed, 12 Jun 2019 08:51:21 +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 49CF12862A for ; Wed, 12 Jun 2019 08:51:20 +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 AC9701766; Wed, 12 Jun 2019 10:50:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AC9701766 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329478; bh=15nw8OcJKuc/e7Pq5IA331+OOh9uHL+pQCApGiHDMT0=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=S6oUJjoWZ0EuyC6DTvMx6jGT2t34oZMFnqzsXGbNwG70Qu9PMsQ9TOJVznIzc0Wzc Oa9ECyw+v3nHCI4SXsXCvRFIxi5qH0yOY+iass40zMBsDalOkF/xqEo3BJj0r7QQ6e MHyQw9ZDBixGGT/KanifiPYKFxrfX/pxiLDvbmuM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6F023F8975C; Wed, 12 Jun 2019 10:44:56 +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 7857DF89740; Wed, 12 Jun 2019 10:44:46 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 45CFDF89737 for ; Wed, 12 Jun 2019 10:44:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 45CFDF89737 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="nSqwZny1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="e8RierQN" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id AF31C46C; Wed, 12 Jun 2019 04:44:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:39 -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=5poLbrQ3fO81p dNt8Mvc1UEs8/ubtlQpMUCQK6VMLGo=; b=nSqwZny14Lsi6lsev9aIG5lGPkwFK OUNorWoRSUqRQzHWchyoOd9ltu+gB3wIPSF9L6s3r0exSitfmSLTAGofd65OxMGo kdwECsxRgP1tVYeQ2vokEGcq73/3nK9p4y1YB0tdqcRtg31D4sZAsFal9jwWah4G xXfATqUlXvhEHVKYCzqsoE3Xe3xpEXtzE2KTw6W7fGqTKyltwT0IvXNpchF89KHr ovSrFW5sNzjnTndcpPWjl3NWiWmNK+FZy0FuOWeyOx5iZ7dgWdMPKlw/mzawkOEF sOeuwdTWtjf/kdAoXfSR0LP8C1eIHWpVKkgrOz03WOn6lVHqmcIjRMlMA== 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=5poLbrQ3fO81pdNt8Mvc1UEs8/ubtlQpMUCQK6VMLGo=; b=e8RierQN T4z5iyESLwl310orsPSknFKjQFFDTdTk59+0LALUngYpln1FlIpcqdmGVNXb+Hrt At76bNBpjJbKpOZnKZuF1Ms5iB0iOcvaWgKQwCIiKUqC4EgYnHehr7esyi6oURlr 9hwy5Qpe2QIqQTSxInse6Wgg9vJ3pM+3Oce7//cYwEkNFBoA/czKdLPxyqhvhKlS hktD7qT2W5CYkxIfK4vU1Jd0ITEA7FDWGUspJFcXuuDUBK9A5H0H7CJAIy1nYEpt SwdMBfZC6aEruxAq4L3Zx3qOZeXW7dwAlMck+MKW7XUHSgX6AuiTNzc++l/Twc2W zO6uL7ipxTgjBQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepge 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 CB81D380087; Wed, 12 Jun 2019 04:44:37 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:11 +0900 Message-Id: <20190612084422.5344-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 08/19] ALSA: fireworks: configure sampling transfer frequency in pcm.hw_params callback 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. At present, several operations are done in pcm.prepare callback. To reduce load of the callback, This commit splits out an operation to set sampling transfer frequency in pcm.hw_params callback. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireworks/fireworks.h | 3 +- sound/firewire/fireworks/fireworks_midi.c | 7 ++- sound/firewire/fireworks/fireworks_pcm.c | 14 +++-- sound/firewire/fireworks/fireworks_stream.c | 65 +++++++++++++-------- 4 files changed, 57 insertions(+), 32 deletions(-) diff --git a/sound/firewire/fireworks/fireworks.h b/sound/firewire/fireworks/fireworks.h index 42a73038ba4d..0c1802aa7923 100644 --- a/sound/firewire/fireworks/fireworks.h +++ b/sound/firewire/fireworks/fireworks.h @@ -206,7 +206,8 @@ int snd_efw_command_get_sampling_rate(struct snd_efw *efw, unsigned int *rate); int snd_efw_command_set_sampling_rate(struct snd_efw *efw, unsigned int rate); int snd_efw_stream_init_duplex(struct snd_efw *efw); -int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate); +int snd_efw_stream_reserve_duplex(struct snd_efw *efw, unsigned int rate); +int snd_efw_stream_start_duplex(struct snd_efw *efw); void snd_efw_stream_stop_duplex(struct snd_efw *efw); void snd_efw_stream_update_duplex(struct snd_efw *efw); void snd_efw_stream_destroy_duplex(struct snd_efw *efw); diff --git a/sound/firewire/fireworks/fireworks_midi.c b/sound/firewire/fireworks/fireworks_midi.c index ee5dc7be70b6..6d3d942e2dce 100644 --- a/sound/firewire/fireworks/fireworks_midi.c +++ b/sound/firewire/fireworks/fireworks_midi.c @@ -18,8 +18,11 @@ static int midi_open(struct snd_rawmidi_substream *substream) goto end; mutex_lock(&efw->mutex); - ++efw->substreams_counter; - err = snd_efw_stream_start_duplex(efw, 0); + err = snd_efw_stream_reserve_duplex(efw, 0); + if (err >= 0) { + ++efw->substreams_counter; + err = snd_efw_stream_start_duplex(efw); + } mutex_unlock(&efw->mutex); if (err < 0) snd_efw_stream_lock_release(efw); diff --git a/sound/firewire/fireworks/fireworks_pcm.c b/sound/firewire/fireworks/fireworks_pcm.c index 398a6ad04c5f..287fc05d5917 100644 --- a/sound/firewire/fireworks/fireworks_pcm.c +++ b/sound/firewire/fireworks/fireworks_pcm.c @@ -231,12 +231,16 @@ static int pcm_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(&efw->mutex); - ++efw->substreams_counter; + err = snd_efw_stream_reserve_duplex(efw, rate); + if (err >= 0) + ++efw->substreams_counter; mutex_unlock(&efw->mutex); } - return 0; + return err; } static int pcm_hw_free(struct snd_pcm_substream *substream) @@ -257,10 +261,9 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) static int pcm_capture_prepare(struct snd_pcm_substream *substream) { struct snd_efw *efw = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; int err; - err = snd_efw_stream_start_duplex(efw, runtime->rate); + err = snd_efw_stream_start_duplex(efw); if (err >= 0) amdtp_stream_pcm_prepare(&efw->tx_stream); @@ -269,10 +272,9 @@ static int pcm_capture_prepare(struct snd_pcm_substream *substream) static int pcm_playback_prepare(struct snd_pcm_substream *substream) { struct snd_efw *efw = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; int err; - err = snd_efw_stream_start_duplex(efw, runtime->rate); + err = snd_efw_stream_start_duplex(efw); if (err >= 0) amdtp_stream_pcm_prepare(&efw->rx_stream); diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index 2df39befcde0..e1ebead583e9 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c @@ -189,47 +189,63 @@ int snd_efw_stream_init_duplex(struct snd_efw *efw) return err; } -int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate) +int snd_efw_stream_reserve_duplex(struct snd_efw *efw, unsigned int rate) { unsigned int curr_rate; - int err = 0; - - // Need no substreams. - if (efw->substreams_counter == 0) - return -EIO; + int err; - /* - * Considering JACK/FFADO streaming: - * TODO: This can be removed hwdep functionality becomes popular. - */ + // Considering JACK/FFADO streaming: + // TODO: This can be removed hwdep functionality becomes popular. err = check_connection_used_by_others(efw, &efw->rx_stream); if (err < 0) - goto end; + return err; - /* stop streams if rate is different */ + // stop streams if rate is different. err = snd_efw_command_get_sampling_rate(efw, &curr_rate); if (err < 0) - goto end; + return err; if (rate == 0) rate = curr_rate; - if (rate != curr_rate || - amdtp_streaming_error(&efw->tx_stream) || - amdtp_streaming_error(&efw->rx_stream)) { + if (rate != curr_rate) { stop_stream(efw, &efw->tx_stream); stop_stream(efw, &efw->rx_stream); } - /* master should be always running */ - if (!amdtp_stream_running(&efw->rx_stream)) { + if (efw->substreams_counter == 0 || rate != curr_rate) { err = snd_efw_command_set_sampling_rate(efw, rate); if (err < 0) - goto end; + return err; + } + + return 0; +} + +int snd_efw_stream_start_duplex(struct snd_efw *efw) +{ + unsigned int rate; + int err = 0; + + // Need no substreams. + if (efw->substreams_counter == 0) + return -EIO; + + err = snd_efw_command_get_sampling_rate(efw, &rate); + if (err < 0) + return err; + if (amdtp_streaming_error(&efw->rx_stream) || + amdtp_streaming_error(&efw->tx_stream)) { + stop_stream(efw, &efw->rx_stream); + stop_stream(efw, &efw->tx_stream); + } + + /* master should be always running */ + if (!amdtp_stream_running(&efw->rx_stream)) { err = start_stream(efw, &efw->rx_stream, rate); if (err < 0) { dev_err(&efw->unit->device, "fail to start AMDTP master stream:%d\n", err); - goto end; + goto error; } } @@ -238,11 +254,14 @@ int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate) if (err < 0) { dev_err(&efw->unit->device, "fail to start AMDTP slave stream:%d\n", err); - stop_stream(efw, &efw->tx_stream); - stop_stream(efw, &efw->rx_stream); + goto error; } } -end: + + return 0; +error: + stop_stream(efw, &efw->rx_stream); + stop_stream(efw, &efw->tx_stream); return err; } From patchwork Wed Jun 12 08:44:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989005 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 5B17618A6 for ; Wed, 12 Jun 2019 08:52:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 456282862A for ; Wed, 12 Jun 2019 08:52:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39BEA289E2; Wed, 12 Jun 2019 08:52:00 +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 6CF6D2862A for ; Wed, 12 Jun 2019 08:51:59 +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 C1F7E174E; Wed, 12 Jun 2019 10:51:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C1F7E174E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329517; bh=Dimhi0Dx7tU3+aZPoIUiVvEx/vzwiGP0qOZqUQKPdvg=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=g5BlxNuxhAH5sLjy8G+xBN2xThLgwCmYeCeD66hySCF92Nc+K6gzBrlixonWnlpfi OKhku0QntGMT1JGpQYdLG5hHXlLgOGn6bAmROt0Zbf70Pb0LByfyDHwNhUt3BTFHaI lLXz7NORvVskK7/eFcg9FaXAZqEYOkq85z/3lRwA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 18281F89762; Wed, 12 Jun 2019 10:44:59 +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 8AA5DF8973E; Wed, 12 Jun 2019 10:44:46 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9815EF89731 for ; Wed, 12 Jun 2019 10:44:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9815EF89731 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="Iaau/Th+"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="lIdXnUW/" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 0D21B5B1; Wed, 12 Jun 2019 04:44:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:41 -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=pCQU+kDFwttBr v3B04Mbo1hyII5etQNZYUUiI0OlZ/E=; b=Iaau/Th+2OgGOmQ03RnjhYZKv6xxp v4PgriXdtdJKIMizb4yARS6ijTRUyoxJv1jXnsSqYogL3vJfSXOAQB2+J+fjhWss VNh98/5TfHP5WXFqIb0gaGmGoYrOq3pkxXBZzSrYhCvgnkDm5nsq2SJjV/UNKgLZ /hYO4h9PSDlwyqx6I4XtfnzWFFeoqE8BX+5DW3bBKW8CCupy3/j2S5VwPFKJshHy LwcvG8lVhjGnOEWO9YLajYlnLwJXjHmMYefVQLCzI0gGWdvCNB+t19Intl7GpxJa 27EppmzgBp27557lvD4CZiVWHkpajAxS5Ogz/gMYa78/pu4kxq1j86hoA== 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=pCQU+kDFwttBrv3B04Mbo1hyII5etQNZYUUiI0OlZ/E=; b=lIdXnUW/ im2rTMN5R8t21GKcbrih/x2PuN6ko0OdB96OxQ9RzzgKqiQfBUj2tP50JhAvJ4cX djSkPnuw6ZVh7/Cs7UVGob36LKC4ENzS6NCWcHXIX+T1j1mdWVJL8E1EP/inqcui HKZdOZQRfRbW3JZuB9hi2MjafzWa2LBqXA4onhbfvG1sZ7sEA+c/1W1v3O2TqOPE P/CNClO/1UA5wDhvyhIayyv97QsE6DI16p/ocb9JdtISO+8xZgsNsmBKIQd9PDwc tSKrliRTAU07ZXGZikvvTGb1BHkIMYnsfrp7Fpl9XwEgbVZDJjsgZ021YzQt2Aqj pd0ZjdIin7Z0Vg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepje 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 5562E38008B; Wed, 12 Jun 2019 04:44:39 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:12 +0900 Message-Id: <20190612084422.5344-10-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 09/19] ALSA: fireworks: configure stream parameters in pcm.hw_params callback 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 splits out an operation to configure stream parameters into pcm.hw_params callback. In pcm.prepare callback, establishing connections and start isochronous contexts. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireworks/fireworks_stream.c | 82 ++++++++++++--------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index e1ebead583e9..1abc15760513 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c @@ -52,54 +52,38 @@ stop_stream(struct snd_efw *efw, struct amdtp_stream *stream) cmp_connection_break(&efw->in_conn); } -static int -start_stream(struct snd_efw *efw, struct amdtp_stream *stream, - unsigned int sampling_rate) +static int start_stream(struct snd_efw *efw, struct amdtp_stream *stream, + unsigned int rate) { struct cmp_connection *conn; - unsigned int mode, pcm_channels, midi_ports; int err; - err = snd_efw_get_multiplier_mode(sampling_rate, &mode); - if (err < 0) - goto end; - if (stream == &efw->tx_stream) { + if (stream == &efw->tx_stream) conn = &efw->out_conn; - pcm_channels = efw->pcm_capture_channels[mode]; - midi_ports = efw->midi_out_ports; - } else { + else conn = &efw->in_conn; - pcm_channels = efw->pcm_playback_channels[mode]; - midi_ports = efw->midi_in_ports; - } - err = amdtp_am824_set_parameters(stream, sampling_rate, - pcm_channels, midi_ports, false); - if (err < 0) - goto end; - - /* establish connection via CMP */ + // Establish connection via CMP. err = cmp_connection_establish(conn, - amdtp_stream_get_max_payload(stream)); + amdtp_stream_get_max_payload(stream)); if (err < 0) - goto end; + return err; - /* start amdtp stream */ - err = amdtp_stream_start(stream, - conn->resources.channel, - conn->speed); + // Start amdtp stream. + err = amdtp_stream_start(stream, conn->resources.channel, conn->speed); if (err < 0) { - stop_stream(efw, stream); - goto end; + cmp_connection_break(conn); + return err; } - /* wait first callback */ + // Wait first callback. if (!amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT)) { - stop_stream(efw, stream); - err = -ETIMEDOUT; + amdtp_stream_stop(stream); + cmp_connection_break(conn); + return -ETIMEDOUT; } -end: - return err; + + return 0; } /* @@ -189,6 +173,24 @@ int snd_efw_stream_init_duplex(struct snd_efw *efw) return err; } +static int keep_resources(struct snd_efw *efw, struct amdtp_stream *stream, + unsigned int rate, unsigned int mode) +{ + unsigned int pcm_channels; + unsigned int midi_ports; + + if (stream == &efw->tx_stream) { + pcm_channels = efw->pcm_capture_channels[mode]; + midi_ports = efw->midi_out_ports; + } else { + pcm_channels = efw->pcm_playback_channels[mode]; + midi_ports = efw->midi_in_ports; + } + + return amdtp_am824_set_parameters(stream, rate, pcm_channels, + midi_ports, false); +} + int snd_efw_stream_reserve_duplex(struct snd_efw *efw, unsigned int rate) { unsigned int curr_rate; @@ -212,9 +214,23 @@ int snd_efw_stream_reserve_duplex(struct snd_efw *efw, unsigned int rate) } if (efw->substreams_counter == 0 || rate != curr_rate) { + unsigned int mode; + err = snd_efw_command_set_sampling_rate(efw, rate); if (err < 0) return err; + + err = snd_efw_get_multiplier_mode(rate, &mode); + if (err < 0) + return err; + + err = keep_resources(efw, &efw->tx_stream, rate, mode); + if (err < 0) + return err; + + err = keep_resources(efw, &efw->rx_stream, rate, mode); + if (err < 0) + return err; } return 0; From patchwork Wed Jun 12 08:44:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989015 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 E466514B6 for ; Wed, 12 Jun 2019 08:52:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D07E62862A for ; Wed, 12 Jun 2019 08:52:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C53B4289E2; Wed, 12 Jun 2019 08:52:39 +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 2EA422862A for ; Wed, 12 Jun 2019 08:52: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 7F0B8176E; Wed, 12 Jun 2019 10:51:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7F0B8176E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329557; bh=EwW0rhFznz/mT4GOOuVTjSRumAmplZILuYcTfWNn5Yw=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=l7+xBny62JPvaFM3YFkqB+SCu2fmHNst6CdI0JsOtylP1/qHfDEgL6xZoqNUGqyWQ 4YY00v8whzeYry3Kv4x2rAdG4Vlo2ihS2sZZOrSWQB6h3Ss6gxJCTKCeGEZuokEpbv feGUmvTYxvKKoF2dsXFtzyM5foMUu1/QSTQzXAHY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0F465F89766; Wed, 12 Jun 2019 10:45: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 B6287F89745; Wed, 12 Jun 2019 10:44:48 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 12936F8973B for ; Wed, 12 Jun 2019 10:44:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 12936F8973B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="rs2XmIfz"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="IxNs3VzF" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 6E0D9582; Wed, 12 Jun 2019 04:44:42 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:42 -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=OQbk5DVWuYm8n lFxcIB+Ho18mpF1tPogpwy7L3e6avs=; b=rs2XmIfz3FBmBnXbjzwW++m/Yqm+j BrFD/IJgMQ/KxmDjbpFda10GsvdgMubFsIVPncLJIcDuUi8d/yueC+mVUSY3LT1V 3iY0FSU/rXqhyvv4qp63L9KT8S34YGQJiWqVza3YV29AjWJTJOd1b8mihSiRk3aU 5e4TlhQrH89Nncrbf+9FBhoaA/TBs6qMmNqzfqB7n92kpt2QzO3+ZiSbnl9mCOmy ek3LP+5WI8iN5h9/ywBiubn2Jf4vUac2DkJfr/BNgaQJ1bwY4ZWpPQG2DzCZgLBG XkeTcCva7UD4H3unync0IabWDBiKagWhYEksKG4KredHTI8HDYfj7APyA== 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=OQbk5DVWuYm8nlFxcIB+Ho18mpF1tPogpwy7L3e6avs=; b=IxNs3VzF 4WcqR4AFo8K7zwAfLQ4+mOvMyapAxJuMd864WKk5RoVSqt2/53Fbn2gywSflvZyj 4rIN6XSrBE8Dm1/8rEitVuQCiCTfgS6M/8S0nKql3ZlFtejqPv6KuYdl/5+r9032 eOkqiQzXhe7bIbs+IQyF7l9BpwcGNf3SeTa7Hz5qb/yO603iqq8UidoUppmSuzV1 tSonR+EovwqFAqi5Dat5ITurOopmzMquVprX6QwlYJh+Z6e6/WTeeo0XCqPpeT2r pXZDKp2VuIeRZrhR7Uh+bv4BgobtaesiXrrisVa6+smby96tvZhjEpeTNv7pm7RH OQXAAXPJfaNRDw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepje 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 D2B20380087; Wed, 12 Jun 2019 04:44:40 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:13 +0900 Message-Id: <20190612084422.5344-11-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 10/19] ALSA: fireworks: don't set XRUN in 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 When stopping packet streaming, no need to stop PCM substream with XRUN state. This commit suppresses it. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireworks/fireworks_stream.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index 1abc15760513..61342c49dc38 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c @@ -43,7 +43,6 @@ init_stream(struct snd_efw *efw, struct amdtp_stream *stream) static void stop_stream(struct snd_efw *efw, struct amdtp_stream *stream) { - amdtp_stream_pcm_abort(stream); amdtp_stream_stop(stream); if (stream == &efw->tx_stream) From patchwork Wed Jun 12 08:44:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989019 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 8D40514B6 for ; Wed, 12 Jun 2019 08:53:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7957D2862A for ; Wed, 12 Jun 2019 08:53:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D752289E2; Wed, 12 Jun 2019 08:53: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 C08252862A for ; Wed, 12 Jun 2019 08:53: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 25FE41776; Wed, 12 Jun 2019 10:52:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 25FE41776 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329597; bh=3FMCvuAfA1C+gWJ9XvciRWUZvJG94OB2JRqQ/kbd9sE=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ovGPsWKapw0jYT2WRsy1hfaSdSHa/ykMrCebdPtNHwYFqlC7ActYlbBGd+jkfgRWZ 4yqF4nXzFqfLytiDyoaZx+bHCEY7TunkXoyl5wWDhITg8ACXq5DqUmQDqDX6vCJe+b /Yy77OceynsaBIGe0AOgjWCmmsx0t9hWt6r5Utzo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CC90EF89769; Wed, 12 Jun 2019 10:45: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 84835F89744; Wed, 12 Jun 2019 10:44:49 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A7518F89731 for ; Wed, 12 Jun 2019 10:44:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A7518F89731 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="baqRpTgv"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JVDf+S2H" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 191225BE; Wed, 12 Jun 2019 04:44:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:44 -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=z429J1gr81FSj QsYImPQL48QLQpChb+pYFVuy0T8TtI=; b=baqRpTgvsi4/sLVcf758HNgxluVYh SKgpAvPZtXGxsdrMv8aLY7RejTDutX8QyC9dE9/6Nn7Y/pNH7+7GoLLmH4qY+xbe ScLM1l8LI1tggGihak0sssxzcr7glcJDNGdeNLbAsLN1PR8CJrit+GL5b4OH1o/I ZGQyTF2ZmgbmBBErPnep8DLRhMjri2mFDf9EnNgNMoLmOmeEyHRI4ZKGI5NKR0xz 279GxOOIoOUAR+W4L4HnrZToJaHrzy0kA8fBCrgzR93/ZjZszMm/9yydOlg9Qe4T x3bJfh6HGnatGvI2jBB1j2bwWf1swn1d5AMpXoLGEOWDcWhcEZLHcekRw== 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=z429J1gr81FSjQsYImPQL48QLQpChb+pYFVuy0T8TtI=; b=JVDf+S2H tP04nqkJDwQDr7vi5Ch9i1syEHJOHMnQb2r6KVSrRmiteIY3v1oEByfv4i5QGvlZ dZYD1rwd9rd4bkvJaPmUfqhlrAP1c2EGZVfnokRfB1dA19rxS9r3PYeY7d/T0J+2 4wpgZt7CMFMCwMJhVUX8CEuksLXfSiqWx73vTMqhZbzAOyhRrYe9j0mQ2YKkDH6k Ygshl5iLC6+/sbsW1VB8WswoUgQapHXk8qvH0pP7iT9eHYcUEB0Ml/+tpttMe8RN zHjzBSeU3FElWdgbjXRQoX8IdsWtvaAV6hrwQie+qlleHfLU2h4WGvEuGv0IK6Zl akuJKlyrLjX2ng== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepje 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 5BE57380089; Wed, 12 Jun 2019 04:44:42 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:14 +0900 Message-Id: <20190612084422.5344-12-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 11/19] ALSA: oxfw: code refactoring for stop condition of 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 This commit unifies stop condition due to queueing error and unmatched state of the target device. Signed-off-by: Takashi Sakamoto --- sound/firewire/oxfw/oxfw-stream.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index f230a9e44c3c..34ff673e6ff8 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -288,10 +288,6 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, if (err < 0) goto end; - /* packet queueing error */ - if (amdtp_streaming_error(stream)) - stop_stream(oxfw, stream); - err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation); if (err < 0) goto end; @@ -300,7 +296,8 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, if (pcm_channels == 0) pcm_channels = formation.pcm; - if ((formation.rate != rate) || (formation.pcm != pcm_channels)) { + if (formation.rate != rate || formation.pcm != pcm_channels || + amdtp_streaming_error(stream)) { if (opposite != NULL) { err = check_connection_used_by_others(oxfw, opposite); if (err < 0) From patchwork Wed Jun 12 08:44:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989021 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 0F2E214E5 for ; Wed, 12 Jun 2019 08:53:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF4492862A for ; Wed, 12 Jun 2019 08:53:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3242289E2; Wed, 12 Jun 2019 08:53:56 +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 318C82862A for ; Wed, 12 Jun 2019 08:53:56 +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 8BCF31760; Wed, 12 Jun 2019 10:53:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8BCF31760 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329634; bh=ZXshM73MR0whN04joHbPM2qU+axYL3yha/XD2SBI6mU=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LYa1yKVXWalzLIYD3ah/RgGzDBU1qr6pe/0f/CHmUvocwhH3TpXmsLeGY2qb76nL4 Y0vtCQVi39EeC+r5JPWQC8PTIS4n4MjH1a7775NPbWq/fBy8tuyrRtOvn7d4i7G2eO fQ8sGykggbaJjABEKN84jnspGUpNNNFVix4ypog4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0772FF8976B; Wed, 12 Jun 2019 10:45:05 +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 E3593F89747; Wed, 12 Jun 2019 10:44:50 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 36BD5F8973E for ; Wed, 12 Jun 2019 10:44:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 36BD5F8973E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="grn4B++T"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ylPOInIA" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id A06A5582; Wed, 12 Jun 2019 04:44:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:45 -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=9o2ZugNByvYIm X2Ez1CkNdQM+5ynNc33CaJ+UqqYRwU=; b=grn4B++TEfggXsFx+P1NeN0G+I1r7 RH8YEN6pDSU3Vn+fazM36ipp4havdEORPwAerrCqSbmtQhkEL2MxKRiC22N2fq8v AY78B/BHSu9p3IiUbdaDtkQt6nPxEBmewrH05LX9kqXl4jJJHy3wyI+p4Da/LLQc ZPhvI0xg4Jfg0DviwRSOjmq4OD7co8pLnfCu7zgRmDHjg2GokMRFofsij4t8U94R wIyH197KdsmJrbt/LzIembVWDwTZhS74Eg4/7Kg52N9Cem7tp5pGbp0yn5wSPbWZ ONbr/a7U783M/e7z7CjWK8zY4SvOecU2WdmcazHsZrgOrI9plTmhy6v8g== 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=9o2ZugNByvYImX2Ez1CkNdQM+5ynNc33CaJ+UqqYRwU=; b=ylPOInIA YPGhBSVUWF8iPAmg2kKW4xvy8XRhyM6+NnA3HRTAZi1f5GgTH7yT4lhGmKX0dDFI a+DSsFqShMMlWYHhVlJA9BcuqvFQZwMb/Az/zeipj4x6nNy12axbh17enPAxdFBy GZc7b9tz+Qg77TwxI1pUNs2sNRYC300ByPePcgzuHdVDtFu2dy0OSbFvlFGSzro9 xeOFa0RhgDKk0reQJGP5KS2n5tDfDZbGUVzq7J7rllvYUiS99O5c+I6t+wP/WccH XWU0ISYemu9Z/gljAJ1clw8/SJc+eNrcgqICrpzCic4jwj4OuhzRE2fhWsP0KRzC bsc8swuuYfMx+g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepje 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 D89AB380087; Wed, 12 Jun 2019 04:44:43 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:15 +0900 Message-Id: <20190612084422.5344-13-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 12/19] ALSA: oxfw: set packet parameter according to current configuration 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 a call of pcm.hw_params, the state of target device is expected for applications. This commit retrieves the state and start packet streaming. Signed-off-by: Takashi Sakamoto --- sound/firewire/oxfw/oxfw-stream.c | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 34ff673e6ff8..1691fdc1a575 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -112,51 +112,51 @@ static void stop_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) cmp_connection_break(&oxfw->in_conn); } -static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream, - unsigned int rate, unsigned int pcm_channels) +static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) { u8 **formats; + enum avc_general_plug_dir dir; struct cmp_connection *conn; struct snd_oxfw_stream_formation formation; - unsigned int i, midi_ports; + int i; int err; if (stream == &oxfw->rx_stream) { + dir = AVC_GENERAL_PLUG_DIR_IN; formats = oxfw->rx_stream_formats; conn = &oxfw->in_conn; } else { + dir = AVC_GENERAL_PLUG_DIR_OUT; formats = oxfw->tx_stream_formats; conn = &oxfw->out_conn; } - /* Get stream format */ + err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation); + if (err < 0) + return err; + for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { + struct snd_oxfw_stream_formation fmt; + if (formats[i] == NULL) break; - err = snd_oxfw_stream_parse_format(formats[i], &formation); + err = snd_oxfw_stream_parse_format(formats[i], &fmt); if (err < 0) - goto end; - if (rate != formation.rate) - continue; - if (pcm_channels == 0 || pcm_channels == formation.pcm) + return err; + if (fmt.rate == formation.rate && fmt.pcm == formation.pcm && + fmt.midi == formation.midi) break; } - if (i == SND_OXFW_STREAM_FORMAT_ENTRIES) { - err = -EINVAL; - goto end; - } + if (i == SND_OXFW_STREAM_FORMAT_ENTRIES) + return -EINVAL; - pcm_channels = formation.pcm; - midi_ports = formation.midi * 8; + // The stream should have one pcm channels at least. + if (formation.pcm == 0) + return -EINVAL; - /* The stream should have one pcm channels at least */ - if (pcm_channels == 0) { - err = -EINVAL; - goto end; - } - err = amdtp_am824_set_parameters(stream, rate, pcm_channels, midi_ports, - false); + err = amdtp_am824_set_parameters(stream, formation.rate, formation.pcm, + formation.midi * 8, false); if (err < 0) goto end; @@ -316,7 +316,7 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, /* Start opposite stream if needed. */ if (opposite && !amdtp_stream_running(opposite) && (opposite_substreams > 0)) { - err = start_stream(oxfw, opposite, rate, 0); + err = start_stream(oxfw, opposite); if (err < 0) { dev_err(&oxfw->unit->device, "fail to restart stream: %d\n", err); @@ -327,7 +327,7 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, /* Start requested stream. */ if (!amdtp_stream_running(stream)) { - err = start_stream(oxfw, stream, rate, pcm_channels); + err = start_stream(oxfw, stream); if (err < 0) dev_err(&oxfw->unit->device, "fail to start stream: %d\n", err); From patchwork Wed Jun 12 08:44:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989031 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 31FF114B6 for ; Wed, 12 Jun 2019 08:54:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DC942862A for ; Wed, 12 Jun 2019 08:54:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 120ED289E2; Wed, 12 Jun 2019 08:54:46 +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 3B7E62862A for ; Wed, 12 Jun 2019 08:54:45 +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 932561785; Wed, 12 Jun 2019 10:53:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 932561785 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329683; bh=UzHoGJGJHQoJTKDt71c9BpDUUgRDlx0PmCrNtaGJhLo=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=M8q2X/OoeZ37qwiDfW8TTVMpijoiqIS5z+xYdbGNVutGnB6AqLfXQrwBLxeSlmix0 WWHd2je3QIu13dTPsvGAmtmN+wp+NnD4aclysnko19cDE8vSclAcN2worgj7MBGriF 4U51uOiw1exoMsUTJB//O0AmY1amZTO+6Q9ZHH5U= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D87FDF89779; Wed, 12 Jun 2019 10:45: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 EABD0F8974D; Wed, 12 Jun 2019 10:44:52 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id F29DCF89743 for ; Wed, 12 Jun 2019 10:44:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F29DCF89743 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="r7byWZIo"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="xKhcS4vi" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 229215BF; Wed, 12 Jun 2019 04:44:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44: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=g8+Qqh/9bnxeg Su9gduOIS5HQ9i6iULxNGeGJEYQ+rE=; b=r7byWZIoQ1pjn1rexYYNgPsjORobu Q1DEy/djzUjjpjJR3SOCljso/4qgtIWZz1dkzlvb/j1PP1yifU1OhgLB0zd3t5mv 1O42UwbdtQuqlnU6cLSfiFTQQhQebT1TsYM4j0/SAFKOWjIbl9lpKxTiVc+52mWr 9KNQQChNx0eLsX1GPoB9E1grpegB8NUI56iAGepEGanvS9ZhUxfK6wuJCTMJuvVd s6hQMQ7aiEN0W5a28nF3iRYMEh2e8fUWXPPtPN9HGBImfws4dj3+i7pO9iZ9Un1R bcpCx7njiYcU8RoiuObctaPPzbij/uVB6sFO4GnEcK5zQe5I2Rv4QOh5A== 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=g8+Qqh/9bnxegSu9gduOIS5HQ9i6iULxNGeGJEYQ+rE=; b=xKhcS4vi RgJAAgtk/oU1rChDWFh2LLhYOnxJEJ1mezaXv46CxQG5/Hsw+qCGmD7ONQsxx56Y sRoLnHNaoNympb/4yztRPJkstrvPe+o+eTy/+BRa1u+pnF7O0PnH6A64AElns/4S RR3mclFWoRf2oQVVX9sfyzi5MCEUjvpowg8aOIKaIDRJHXdbXUvQSYTVNDHr6f7g V/PV6rPPukzHJuQN3n7idaBqZHDJr/RlMQL0r3+Rtxda9/kwlT8FEHUgtLN7rbY8 0k2PCuzuOGy/B2YaFKMaTEIdKa2eVnVC6cPjlTT2hjkqU/+Q0GMcUj/5yw1/NB37 t5lvbFtYVKO+8w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepuddu 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 5FAF0380089; Wed, 12 Jun 2019 04:44:45 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:16 +0900 Message-Id: <20190612084422.5344-14-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 13/19] ALSA: oxfw: start duplex streams if supported 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 It's inconvenient to handle two isochronous context separately each other. This commit unifies the counters to handle the two at the same time. Signed-off-by: Takashi Sakamoto --- sound/firewire/oxfw/oxfw-stream.c | 102 ++++++++++++++---------------- 1 file changed, 49 insertions(+), 53 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 1691fdc1a575..bb4ba6c196ea 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -254,96 +254,92 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, struct amdtp_stream *stream, unsigned int rate, unsigned int pcm_channels) { - struct amdtp_stream *opposite; struct snd_oxfw_stream_formation formation; enum avc_general_plug_dir dir; - unsigned int substreams, opposite_substreams; int err = 0; - if (stream == &oxfw->tx_stream) { - substreams = oxfw->capture_substreams; - opposite = &oxfw->rx_stream; - opposite_substreams = oxfw->playback_substreams; - dir = AVC_GENERAL_PLUG_DIR_OUT; - } else { - substreams = oxfw->playback_substreams; - opposite_substreams = oxfw->capture_substreams; + if (oxfw->capture_substreams == 0 && oxfw->playback_substreams == 0) + return -EIO; - if (oxfw->has_output) - opposite = &oxfw->rx_stream; - else - opposite = NULL; - - dir = AVC_GENERAL_PLUG_DIR_IN; + // Considering JACK/FFADO streaming: + // TODO: This can be removed hwdep functionality becomes popular. + err = check_connection_used_by_others(oxfw, &oxfw->rx_stream); + if (err < 0) + return err; + if (oxfw->has_output) { + err = check_connection_used_by_others(oxfw, &oxfw->tx_stream); + if (err < 0) + return err; } - if (substreams == 0) - goto end; - - /* - * Considering JACK/FFADO streaming: - * TODO: This can be removed hwdep functionality becomes popular. - */ - err = check_connection_used_by_others(oxfw, stream); - if (err < 0) - goto end; + if (stream == &oxfw->tx_stream) + dir = AVC_GENERAL_PLUG_DIR_OUT; + else + dir = AVC_GENERAL_PLUG_DIR_IN; err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation); if (err < 0) - goto end; + return err; if (rate == 0) rate = formation.rate; if (pcm_channels == 0) pcm_channels = formation.pcm; if (formation.rate != rate || formation.pcm != pcm_channels || - amdtp_streaming_error(stream)) { - if (opposite != NULL) { - err = check_connection_used_by_others(oxfw, opposite); - if (err < 0) - goto end; - stop_stream(oxfw, opposite); - } - stop_stream(oxfw, stream); + amdtp_streaming_error(&oxfw->rx_stream) || + amdtp_streaming_error(&oxfw->tx_stream)) { + stop_stream(oxfw, &oxfw->rx_stream); + if (oxfw->has_output) + stop_stream(oxfw, &oxfw->tx_stream); err = set_stream_format(oxfw, stream, rate, pcm_channels); if (err < 0) { dev_err(&oxfw->unit->device, "fail to set stream format: %d\n", err); - goto end; + return err; + } + } + + if (!amdtp_stream_running(&oxfw->rx_stream)) { + err = start_stream(oxfw, &oxfw->rx_stream); + if (err < 0) { + dev_err(&oxfw->unit->device, + "fail to start rx stream: %d\n", err); + goto error; } + } - /* Start opposite stream if needed. */ - if (opposite && !amdtp_stream_running(opposite) && - (opposite_substreams > 0)) { - err = start_stream(oxfw, opposite); + if (oxfw->has_output) { + if (!amdtp_stream_running(&oxfw->tx_stream)) { + err = start_stream(oxfw, &oxfw->tx_stream); if (err < 0) { dev_err(&oxfw->unit->device, - "fail to restart stream: %d\n", err); - goto end; + "fail to start tx stream: %d\n", err); + goto error; } } } - /* Start requested stream. */ - if (!amdtp_stream_running(stream)) { - err = start_stream(oxfw, stream); - if (err < 0) - dev_err(&oxfw->unit->device, - "fail to start stream: %d\n", err); + return 0; +error: + stop_stream(oxfw, &oxfw->rx_stream); + cmp_connection_break(&oxfw->in_conn); + if (oxfw->has_output) { + stop_stream(oxfw, &oxfw->tx_stream); + cmp_connection_break(&oxfw->out_conn); } -end: return err; } void snd_oxfw_stream_stop_simplex(struct snd_oxfw *oxfw, struct amdtp_stream *stream) { - if (((stream == &oxfw->tx_stream) && (oxfw->capture_substreams > 0)) || - ((stream == &oxfw->rx_stream) && (oxfw->playback_substreams > 0))) - return; + if (oxfw->capture_substreams == 0 && oxfw->playback_substreams == 0) { + stop_stream(oxfw, &oxfw->rx_stream); - stop_stream(oxfw, stream); + if (oxfw->has_output) + stop_stream(oxfw, &oxfw->tx_stream); + } } /* From patchwork Wed Jun 12 08:44:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989043 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 4E0D914B6 for ; Wed, 12 Jun 2019 08:55:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38EB82862A for ; Wed, 12 Jun 2019 08:55:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D3EB289E2; Wed, 12 Jun 2019 08:55:13 +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 7C5992862A for ; Wed, 12 Jun 2019 08:55:12 +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 CA5271745; Wed, 12 Jun 2019 10:54:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CA5271745 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329710; bh=CPyt8ZWlsqTGaHW3316Iv8WM30Ib7p02BV88nAH7Fhk=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=uIf97ew4SZe9imd5bNuDg8BQvjw5Mn0JMSEuVLb8ThBdZX4vUS0Pxv+IaAzb7kYGQ DgIROM50MBThm7LStg8l087n+YMeO1bAJohkH7vf7kOTVZ6FvygIqIpO0ZNQC+0ZPe amJ/FMGQLZGEHK7dUVvOVoQQJda2WL7eakmKaOsk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7909AF8977E; Wed, 12 Jun 2019 10:45:08 +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 C6AD1F89751; Wed, 12 Jun 2019 10:44:53 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 231CCF8973E for ; Wed, 12 Jun 2019 10:44:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 231CCF8973E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="GUlDf4xM"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="1N6f5wMH" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 8BDA421D; Wed, 12 Jun 2019 04:44:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44: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=WyHxZZP1vSBSn aX6JUP4Oeis0hAsDQE8+WylllKiCnI=; b=GUlDf4xM3fXN/dvJdu7OfJb8Wa/ZG PUz2nZRsvJB+UhDPB5fmrS6l9wQy282/WrpH55/xgXtgr1u2oldhdMtucVXQXIZl Lv3NQo5k+PzJw7ahfK4iT9PzLDmDZM/XT3q/pV5pFnsByuzTj9PWSRbhnxs7ZRtk FwuHALMiGrK/KHpqMmo9hDij2f/3A6cnPVL9y8oABbaHvXrxkLw73VeKS0coJsGd oaWSyCKlpGT47iiuUisH4tZz4ch0DlO5C1/GIOq9+gWdzogwwKNUqQswU1Mz0m6o dy51WmxJCcqGFr6jpjHNigHQ845TnykcP5rI2G56Ly75ici4pPCkL43Ng== 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=WyHxZZP1vSBSnaX6JUP4Oeis0hAsDQE8+WylllKiCnI=; b=1N6f5wMH ZHsJ3Qze869sQWsRb8Ot98+AQWLzka13A9Ou+dNveo+t0ooDH45o8FczU42W17no mJ7TkklFejlIEdfqlWBZbmUxMuLgTy6jXCqgCVHpydL9SUFIGTC5Op9+XHt/2hn5 fUlHQ5Zs3G8NjyNc87RDMUhQb5tMZTJBcx/OdR4Xe0dOBq/DRnMWCFppu9LxTJ9u /Rrz+/EunuRL/CMwgjhBI4M93tNc3+1atcSJxzPAxMbQMyI4K1CGt4MTiTiPJpsk oRMSbHR6kchV7K717rFZCX61nJa0d6b44x9dWBBZAtaeHcZrnr1DIeEo5I3NG+ez f3tfaqWJf1gBpQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepuddu 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 DE330380083; Wed, 12 Jun 2019 04:44:46 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:17 +0900 Message-Id: <20190612084422.5344-15-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 14/19] ALSA: oxfw: break packet streaming at bus-reset handler 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 most cases, recovery from bus reset is not successful. This commit aborts packet streaming in bus reset handler. Signed-off-by: Takashi Sakamoto --- sound/firewire/oxfw/oxfw-stream.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index bb4ba6c196ea..806a7fded99d 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -363,17 +363,10 @@ void snd_oxfw_stream_destroy_simplex(struct snd_oxfw *oxfw, void snd_oxfw_stream_update_simplex(struct snd_oxfw *oxfw, struct amdtp_stream *stream) { - struct cmp_connection *conn; - - if (stream == &oxfw->tx_stream) - conn = &oxfw->out_conn; - else - conn = &oxfw->in_conn; + stop_stream(oxfw, &oxfw->rx_stream); - if (cmp_connection_update(conn) < 0) - stop_stream(oxfw, stream); - else - amdtp_stream_update(stream); + if (oxfw->has_output) + stop_stream(oxfw, &oxfw->tx_stream); } int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw, From patchwork Wed Jun 12 08:44:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989049 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 0A70614B6 for ; Wed, 12 Jun 2019 08:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBA6B289DC for ; Wed, 12 Jun 2019 08:55:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF34A289E2; Wed, 12 Jun 2019 08:55:53 +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 0D6E1289DC for ; Wed, 12 Jun 2019 08:55:53 +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 6498F1783; Wed, 12 Jun 2019 10:55:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6498F1783 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329751; bh=3YgI+qrdBTq3XYPSFsU+VGfiX/CofvFE6wVE3bYrI84=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Fl5ydrjVHkTKXywCCUQblal9ykH0H5W96/sNOYVTnPs/CPPCM4WKdpEJXTtZz05up 4bbI7VPlOgGbymTnMcrqDTFaRRBNvO7kiHOcutSQJT1C17PVwx/CmKXr+mHoRz8wNd baKxvjV1EpElSD4KHEMCUvI3uIDALNylZML/9lP0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E385FF89780; Wed, 12 Jun 2019 10:45:09 +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 07F96F89755; Wed, 12 Jun 2019 10:44:55 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C2A8FF8974B for ; Wed, 12 Jun 2019 10:44:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C2A8FF8974B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="JdjXrchn"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="0liaYlv5" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 30E755BE; Wed, 12 Jun 2019 04:44:50 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:50 -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=A0qwqHoFsaSB+ D41n7uiPfx2eXXUyor27ucHlopk74w=; b=JdjXrchn9D09bob3dPhbKd7c72Ias fdh4w/tA3jQVK0r+MsrqH/1HFx6L897flyW0Az05X1df6j5Q2Qa2d1d4RRf1mzG1 FrHMpc1EUYYNAsYGGVc7ZIKPIBzByO3Yel6GWbHNR+qg7ReVhNVTDxLlkodL+CVf QDb0L+N6KxOh4gxqcndPcPLJVo2Sl8R/GCNAs3vVBq/GYrlVZwfiO6mjMisLt9Lo +oIHFdYhzRJIpdReh0FiESBHJ5QgeHQGDwzAzOlfq1v0uYV5zgTXFWSGFF4FV2H4 KjtE4w7Yc++4vhJs5oRHduHqbJx2wF0pXkJW6y5+Oh5auUwHiFNB1m7pQ== 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=A0qwqHoFsaSB+D41n7uiPfx2eXXUyor27ucHlopk74w=; b=0liaYlv5 wVRaTkds+8cLjxLAkAwl67I/PtqV+e1OjAQZqYW1oUX97W3TkWuRKCXvAFDzk3xC kgA1Y6Bfp+1R7Wlk/1MSPvcbEola9DPjRyUquu54//csLBjoWIx9EaNM6BFbBDPw 4x2cjKNDPIjKzBp6E6W1BRRh690cCClJTnceM+572ycJV9Q+jIiTWugb+pkQb7rZ ytRFi+gbteVbT/BElgz4b7qWYGhBgsThyGM0o9gyKp02B+4LF9R59FZy6KYPF2Q0 VEW6PgRQkuywCkJUmoxVoTInQzfDZmpieqJtibCarR1PwD4zP/cIWDrF3CmmMBN/ 3vD9w3ARD3pzsg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepuddu 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 654A8380087; Wed, 12 Jun 2019 04:44:48 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:18 +0900 Message-Id: <20190612084422.5344-16-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 15/19] ALSA: oxfw: expand stop procedure 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 The helper function stop packet streaming is not enough useful. This commit obsoletes it and expands its code. Signed-off-by: Takashi Sakamoto --- sound/firewire/oxfw/oxfw-stream.c | 68 ++++++++++++++++--------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 806a7fded99d..561ceb09d927 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -101,17 +101,6 @@ static int set_stream_format(struct snd_oxfw *oxfw, struct amdtp_stream *s, return 0; } -static void stop_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) -{ - amdtp_stream_pcm_abort(stream); - amdtp_stream_stop(stream); - - if (stream == &oxfw->tx_stream) - cmp_connection_break(&oxfw->out_conn); - else - cmp_connection_break(&oxfw->in_conn); -} - static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) { u8 **formats; @@ -158,28 +147,27 @@ static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) err = amdtp_am824_set_parameters(stream, formation.rate, formation.pcm, formation.midi * 8, false); if (err < 0) - goto end; + return err; err = cmp_connection_establish(conn, amdtp_stream_get_max_payload(stream)); if (err < 0) - goto end; + return err; - err = amdtp_stream_start(stream, - conn->resources.channel, - conn->speed); + err = amdtp_stream_start(stream, conn->resources.channel, conn->speed); if (err < 0) { cmp_connection_break(conn); - goto end; + return err; } - /* Wait first packet */ + // Wait first packet. if (!amdtp_stream_wait_callback(stream, CALLBACK_TIMEOUT)) { - stop_stream(oxfw, stream); - err = -ETIMEDOUT; + amdtp_stream_stop(stream); + cmp_connection_break(conn); + return -ETIMEDOUT; } -end: - return err; + + return 0; } static int check_connection_used_by_others(struct snd_oxfw *oxfw, @@ -288,9 +276,13 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, if (formation.rate != rate || formation.pcm != pcm_channels || amdtp_streaming_error(&oxfw->rx_stream) || amdtp_streaming_error(&oxfw->tx_stream)) { - stop_stream(oxfw, &oxfw->rx_stream); - if (oxfw->has_output) - stop_stream(oxfw, &oxfw->tx_stream); + amdtp_stream_stop(&oxfw->rx_stream); + cmp_connection_break(&oxfw->in_conn); + + if (oxfw->has_output) { + amdtp_stream_stop(&oxfw->tx_stream); + cmp_connection_break(&oxfw->out_conn); + } err = set_stream_format(oxfw, stream, rate, pcm_channels); if (err < 0) { @@ -322,10 +314,10 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, return 0; error: - stop_stream(oxfw, &oxfw->rx_stream); + amdtp_stream_stop(&oxfw->rx_stream); cmp_connection_break(&oxfw->in_conn); if (oxfw->has_output) { - stop_stream(oxfw, &oxfw->tx_stream); + amdtp_stream_stop(&oxfw->tx_stream); cmp_connection_break(&oxfw->out_conn); } return err; @@ -335,10 +327,13 @@ void snd_oxfw_stream_stop_simplex(struct snd_oxfw *oxfw, struct amdtp_stream *stream) { if (oxfw->capture_substreams == 0 && oxfw->playback_substreams == 0) { - stop_stream(oxfw, &oxfw->rx_stream); + amdtp_stream_stop(&oxfw->rx_stream); + cmp_connection_break(&oxfw->in_conn); - if (oxfw->has_output) - stop_stream(oxfw, &oxfw->tx_stream); + if (oxfw->has_output) { + amdtp_stream_stop(&oxfw->tx_stream); + cmp_connection_break(&oxfw->out_conn); + } } } @@ -363,10 +358,17 @@ void snd_oxfw_stream_destroy_simplex(struct snd_oxfw *oxfw, void snd_oxfw_stream_update_simplex(struct snd_oxfw *oxfw, struct amdtp_stream *stream) { - stop_stream(oxfw, &oxfw->rx_stream); + amdtp_stream_stop(&oxfw->rx_stream); + cmp_connection_break(&oxfw->in_conn); - if (oxfw->has_output) - stop_stream(oxfw, &oxfw->tx_stream); + amdtp_stream_pcm_abort(&oxfw->rx_stream); + + if (oxfw->has_output) { + amdtp_stream_stop(&oxfw->tx_stream); + cmp_connection_break(&oxfw->out_conn); + + amdtp_stream_pcm_abort(&oxfw->tx_stream); + } } int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw, From patchwork Wed Jun 12 08:44:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989061 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 039AC14B6 for ; Wed, 12 Jun 2019 08:56:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0E97289DC for ; Wed, 12 Jun 2019 08:56:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2536289E2; Wed, 12 Jun 2019 08:56:41 +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 CF13C289DC for ; Wed, 12 Jun 2019 08:56:40 +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 2C1C8177C; Wed, 12 Jun 2019 10:55:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2C1C8177C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329799; bh=HLRd+vt459t1LFpfB2wj3y7jj0gAuvKhXEvxfi3icDI=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LkenmK+nzsCrJhKDF0GpQkPUYKgP8k2kziER7zYAcdxqCwdnhaPdDMNagaXYjKoBw f0vxiGSSoalRzAMdCIK7ywVsl8AY5AwBOP2bpgMQPYnccE++xt5zFgLezEF1GjMphe R6q1ug2O9grSzeL0g1ju6G2TJRngAKB7LjJNgcMk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A0755F89788; Wed, 12 Jun 2019 10:45:11 +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 2E364F89760; Wed, 12 Jun 2019 10:44:57 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 89C94F89754 for ; Wed, 12 Jun 2019 10:44:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 89C94F89754 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="CSfDKcrM"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fptUbOoR" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id EC40D21D; Wed, 12 Jun 2019 04:44:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:52 -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=cWYalOXHWASkL ZajJvE2lTioZizjGQTYczjF9jXX6vc=; b=CSfDKcrM0RLAWiVPWovDQ80qsxl0J tv+jhm1gNUGbsw5EWWr2aoWX3s1/Cz0fbWZtAFGfPEQOtKYeMWBvSb8cAsq1W/7K hQ+DefOzqjOFqaWpnJoaJPDfHtRgmpVQJ1KMPpHK8PfiBy7rBwmajijGa9AIzipw 4VwgWhZDi6j/ozm04rqbMLvnmBWlrXJqUtbzqPFa13LBWoCeYDJr60bu2QUlcujQ gE3yeLoSgVwhZ+V+0AU35Z0FOKzFkC3hC7cls7CLaF1scR/XMhbtpH9bLr8Lfvsx RsqOTpyEx60N3QFBdG1Zqoyhpk2GXZd0FJePG/Fvib9oDyJeqLS3HMu2A== 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=cWYalOXHWASkLZajJvE2lTioZizjGQTYczjF9jXX6vc=; b=fptUbOoR s/hI2FQd5cjmg1zJk+gvmVTvjvjvz9hwEdKZSGkEjiYDbrLNnUp8j+yEo3+0vSIi v2tNIcmW+jlQNTsqHPsQ6KTh6LSNVYb/829bvkUabRAvkitGl9jJpvVWO+PIT/fF eblbiA1VN8IHnQWb63hV3/oAfpXW+WanBfSQ2VDn43fSoxHnARW24m3kO50Btf1s JIQxhbrtGWayBi+s+pXi/tT7JWmWJBphccrtL4F1ERixOgntx8MAtqIinjwpqK8I aN9IQkeD6XwXfB/x/N9Dg0rKj8Dq6aMAQkKCjnIufctbW6f9hYWo70q4cdtjPAVQ FSqR1ewptnX5Rw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepuddu 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 E2CC7380083; Wed, 12 Jun 2019 04:44:49 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:19 +0900 Message-Id: <20190612084422.5344-17-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 16/19] ALSA: oxfw: rename helper functions for duplex streams 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 former commits, ALSA oxfw driver handles two isochronous contexts at the same time, except for some devices which supports one endpoint of isochronous packet stream. This commit renames some helper functions so that they handles duplex streams. Signed-off-by: Takashi Sakamoto --- sound/firewire/oxfw/oxfw-midi.c | 8 ++--- sound/firewire/oxfw/oxfw-pcm.c | 12 +++---- sound/firewire/oxfw/oxfw-stream.c | 60 ++++++++++++++++++++----------- sound/firewire/oxfw/oxfw.c | 17 ++------- sound/firewire/oxfw/oxfw.h | 14 +++----- 5 files changed, 58 insertions(+), 53 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-midi.c b/sound/firewire/oxfw/oxfw-midi.c index b7bbd77dfff1..31352cebdfe9 100644 --- a/sound/firewire/oxfw/oxfw-midi.c +++ b/sound/firewire/oxfw/oxfw-midi.c @@ -20,7 +20,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) mutex_lock(&oxfw->mutex); oxfw->capture_substreams++; - err = snd_oxfw_stream_start_simplex(oxfw, &oxfw->tx_stream, 0, 0); + err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->tx_stream, 0, 0); mutex_unlock(&oxfw->mutex); @@ -42,7 +42,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream) mutex_lock(&oxfw->mutex); oxfw->playback_substreams++; - err = snd_oxfw_stream_start_simplex(oxfw, &oxfw->rx_stream, 0, 0); + err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->rx_stream, 0, 0); mutex_unlock(&oxfw->mutex); @@ -59,7 +59,7 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream) mutex_lock(&oxfw->mutex); oxfw->capture_substreams--; - snd_oxfw_stream_stop_simplex(oxfw, &oxfw->tx_stream); + snd_oxfw_stream_stop_duplex(oxfw); mutex_unlock(&oxfw->mutex); @@ -74,7 +74,7 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream) mutex_lock(&oxfw->mutex); oxfw->playback_substreams--; - snd_oxfw_stream_stop_simplex(oxfw, &oxfw->rx_stream); + snd_oxfw_stream_stop_duplex(oxfw); mutex_unlock(&oxfw->mutex); diff --git a/sound/firewire/oxfw/oxfw-pcm.c b/sound/firewire/oxfw/oxfw-pcm.c index b3f6503dd34d..253d79607bdf 100644 --- a/sound/firewire/oxfw/oxfw-pcm.c +++ b/sound/firewire/oxfw/oxfw-pcm.c @@ -255,7 +255,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream) if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) oxfw->capture_substreams--; - snd_oxfw_stream_stop_simplex(oxfw, &oxfw->tx_stream); + snd_oxfw_stream_stop_duplex(oxfw); mutex_unlock(&oxfw->mutex); @@ -270,7 +270,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream) if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) oxfw->playback_substreams--; - snd_oxfw_stream_stop_simplex(oxfw, &oxfw->rx_stream); + snd_oxfw_stream_stop_duplex(oxfw); mutex_unlock(&oxfw->mutex); @@ -284,8 +284,8 @@ static int pcm_capture_prepare(struct snd_pcm_substream *substream) int err; mutex_lock(&oxfw->mutex); - err = snd_oxfw_stream_start_simplex(oxfw, &oxfw->tx_stream, - runtime->rate, runtime->channels); + err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->tx_stream, + runtime->rate, runtime->channels); mutex_unlock(&oxfw->mutex); if (err < 0) goto end; @@ -301,8 +301,8 @@ static int pcm_playback_prepare(struct snd_pcm_substream *substream) int err; mutex_lock(&oxfw->mutex); - err = snd_oxfw_stream_start_simplex(oxfw, &oxfw->rx_stream, - runtime->rate, runtime->channels); + err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->rx_stream, + runtime->rate, runtime->channels); mutex_unlock(&oxfw->mutex); if (err < 0) goto end; diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 561ceb09d927..52cf815c27f7 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -194,8 +194,7 @@ static int check_connection_used_by_others(struct snd_oxfw *oxfw, return err; } -int snd_oxfw_stream_init_simplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream) +static int init_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) { struct cmp_connection *conn; enum cmp_direction c_dir; @@ -214,13 +213,12 @@ int snd_oxfw_stream_init_simplex(struct snd_oxfw *oxfw, err = cmp_connection_init(conn, oxfw->unit, c_dir, 0); if (err < 0) - goto end; + return err; err = amdtp_am824_init(stream, oxfw->unit, s_dir, CIP_NONBLOCKING); if (err < 0) { - amdtp_stream_destroy(stream); cmp_connection_destroy(conn); - goto end; + return err; } /* @@ -234,13 +232,13 @@ int snd_oxfw_stream_init_simplex(struct snd_oxfw *oxfw, if (oxfw->wrong_dbs) oxfw->tx_stream.flags |= CIP_WRONG_DBS; } -end: - return err; + + return 0; } -int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream, - unsigned int rate, unsigned int pcm_channels) +int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw, + struct amdtp_stream *stream, + unsigned int rate, unsigned int pcm_channels) { struct snd_oxfw_stream_formation formation; enum avc_general_plug_dir dir; @@ -323,8 +321,7 @@ int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, return err; } -void snd_oxfw_stream_stop_simplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream) +void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw) { if (oxfw->capture_substreams == 0 && oxfw->playback_substreams == 0) { amdtp_stream_stop(&oxfw->rx_stream); @@ -337,12 +334,7 @@ void snd_oxfw_stream_stop_simplex(struct snd_oxfw *oxfw, } } -/* - * This function should be called before starting the stream or after stopping - * the streams. - */ -void snd_oxfw_stream_destroy_simplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream) +static void destroy_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) { struct cmp_connection *conn; @@ -355,8 +347,36 @@ void snd_oxfw_stream_destroy_simplex(struct snd_oxfw *oxfw, cmp_connection_destroy(conn); } -void snd_oxfw_stream_update_simplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream) +int snd_oxfw_stream_init_duplex(struct snd_oxfw *oxfw) +{ + int err; + + err = init_stream(oxfw, &oxfw->rx_stream); + if (err < 0) + return err; + + if (oxfw->has_output) { + err = init_stream(oxfw, &oxfw->tx_stream); + if (err < 0) { + destroy_stream(oxfw, &oxfw->rx_stream); + return err; + } + } + + return 0; +} + +// This function should be called before starting the stream or after stopping +// the streams. +void snd_oxfw_stream_destroy_duplex(struct snd_oxfw *oxfw) +{ + destroy_stream(oxfw, &oxfw->rx_stream); + + if (oxfw->has_output) + destroy_stream(oxfw, &oxfw->tx_stream); +} + +void snd_oxfw_stream_update_duplex(struct snd_oxfw *oxfw) { amdtp_stream_stop(&oxfw->rx_stream); cmp_connection_break(&oxfw->in_conn); diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c index 3d27f3378d5d..2de26a9987f8 100644 --- a/sound/firewire/oxfw/oxfw.c +++ b/sound/firewire/oxfw/oxfw.c @@ -118,9 +118,7 @@ static void oxfw_card_free(struct snd_card *card) { struct snd_oxfw *oxfw = card->private_data; - snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream); - if (oxfw->has_output) - snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream); + snd_oxfw_stream_destroy_duplex(oxfw); } static int detect_quirks(struct snd_oxfw *oxfw) @@ -211,14 +209,9 @@ static void do_registration(struct work_struct *work) if (err < 0) goto error; - err = snd_oxfw_stream_init_simplex(oxfw, &oxfw->rx_stream); + err = snd_oxfw_stream_init_duplex(oxfw); if (err < 0) goto error; - if (oxfw->has_output) { - err = snd_oxfw_stream_init_simplex(oxfw, &oxfw->tx_stream); - if (err < 0) - goto error; - } err = snd_oxfw_create_pcm(oxfw); if (err < 0) @@ -285,11 +278,7 @@ static void oxfw_bus_reset(struct fw_unit *unit) if (oxfw->registered) { mutex_lock(&oxfw->mutex); - - snd_oxfw_stream_update_simplex(oxfw, &oxfw->rx_stream); - if (oxfw->has_output) - snd_oxfw_stream_update_simplex(oxfw, &oxfw->tx_stream); - + snd_oxfw_stream_update_duplex(oxfw); mutex_unlock(&oxfw->mutex); if (oxfw->entry->vendor_id == OUI_STANTON) diff --git a/sound/firewire/oxfw/oxfw.h b/sound/firewire/oxfw/oxfw.h index d54d4a9ac4a1..911a452f94db 100644 --- a/sound/firewire/oxfw/oxfw.h +++ b/sound/firewire/oxfw/oxfw.h @@ -99,17 +99,13 @@ int avc_general_inquiry_sig_fmt(struct fw_unit *unit, unsigned int rate, enum avc_general_plug_dir dir, unsigned short pid); -int snd_oxfw_stream_init_simplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream); -int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, +int snd_oxfw_stream_init_duplex(struct snd_oxfw *oxfw); +int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw, struct amdtp_stream *stream, unsigned int rate, unsigned int pcm_channels); -void snd_oxfw_stream_stop_simplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream); -void snd_oxfw_stream_destroy_simplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream); -void snd_oxfw_stream_update_simplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream); +void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw); +void snd_oxfw_stream_destroy_duplex(struct snd_oxfw *oxfw); +void snd_oxfw_stream_update_duplex(struct snd_oxfw *oxfw); struct snd_oxfw_stream_formation { unsigned int rate; From patchwork Wed Jun 12 08:44:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989075 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 70E811515 for ; Wed, 12 Jun 2019 08:57:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AD75289DC for ; Wed, 12 Jun 2019 08:57:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EC70289E2; Wed, 12 Jun 2019 08:57:32 +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 860D6289DC for ; Wed, 12 Jun 2019 08:57: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 B22371791; Wed, 12 Jun 2019 10:56:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B22371791 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329849; bh=5EwQOQp/BwMJ6LDxfvTclZT2d4fE+buqi/gq56Hsuew=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OrZdStvYD7MJuuomkLmmVrIxPslsVoZrlZGwgAgaR8gPibpki8DBSWGx7vFxqTJlu V1qzmRso56/XPMXcCkAHsv1lu+q82ETk+cypasWDq/Ell1Eb6yHuVRauh4KuqdgKs2 vPA0MHkygKJ/rM40gctbg43HNe4ZaZ2I2m0YiJMw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7881DF89793; Wed, 12 Jun 2019 10:45:14 +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 334BAF89764; Wed, 12 Jun 2019 10:44:59 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D33FDF89759 for ; Wed, 12 Jun 2019 10:44:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D33FDF89759 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="ggPWv8zH"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rh0p4dpw" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 4732D5B1; Wed, 12 Jun 2019 04:44:53 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:53 -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=fqFmvPAiCbq3u CuDpmR1GoW82G22IpRp25VQfrE1DqU=; b=ggPWv8zHI6j4HCxyFeyGcWqA2IjGE HwDX8bwbBSl8wG2UVgNVeC21pknPnDs6hmMHlqcxvGzaZX5ZGZfdgYpYpSjJyzvp SbpEF4cLHyeS9EcdSAyvQz5TtKuRRj591HyGEVxCOspWswY3U9sBfgpDuaKKGitF JBfwKyLP2dZdJo/XDk2RuzSQg0RXdUL7m90DXfNvzPYWFDWOoXDaSchNM3QT4ZRR 3X5g/mvEmQlA7JFRnxLEUqdUY4noE1yyyx88Ho4muCZnaB98T7uVI6uO5K+VcR9W WpvzWJkzQF5v9eZxWFvNnje3slkuPfk4CLMMJ2bJEaH2CmJOAC710c+Dg== 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=fqFmvPAiCbq3uCuDpmR1GoW82G22IpRp25VQfrE1DqU=; b=rh0p4dpw iJZWcwve8KwH2FhKEWy300eyT5CWQt5KW3cL7tJFSb4ZIYSlT7wwc/8fU2rEA7lS gw3aG0hpo0NGejz1Y682jSVnacDSYEuuAcBq6J6487/1/2lZGTIVdaLK6FHT0ZkT D+IwW1gz/G6x0/wlvZt4tiTs30LubMBN0PUqywjae6M61AQpqTUCvY5NRJAV4doV d52suZWuHkTycOmG8hQkm90C1W2IGjajU6lU8RPxFQlKyCUL5x8hK7qVbr4s4okv dNF7/nUh1vDChxRjNKNPjEEZlf6je2mhx7O/7w9RLzhbsEc6HVICI19WhsG/5tmG za6wQI3TkuOq5w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepudeh 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 9DB8238008B; Wed, 12 Jun 2019 04:44:51 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:20 +0900 Message-Id: <20190612084422.5344-18-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 17/19] ALSA: oxfw: unify substreams counter 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 former commits, two isochronous contexts are handles at the same time. This commit unifies stream counters to obsolete them. Signed-off-by: Takashi Sakamoto --- sound/firewire/oxfw/oxfw-midi.c | 8 ++++---- sound/firewire/oxfw/oxfw-pcm.c | 8 ++++---- sound/firewire/oxfw/oxfw-stream.c | 4 ++-- sound/firewire/oxfw/oxfw.h | 3 +-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-midi.c b/sound/firewire/oxfw/oxfw-midi.c index 31352cebdfe9..092493497f1a 100644 --- a/sound/firewire/oxfw/oxfw-midi.c +++ b/sound/firewire/oxfw/oxfw-midi.c @@ -19,7 +19,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) mutex_lock(&oxfw->mutex); - oxfw->capture_substreams++; + ++oxfw->substreams_count; err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->tx_stream, 0, 0); mutex_unlock(&oxfw->mutex); @@ -41,7 +41,7 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream) mutex_lock(&oxfw->mutex); - oxfw->playback_substreams++; + ++oxfw->substreams_count; err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->rx_stream, 0, 0); mutex_unlock(&oxfw->mutex); @@ -58,7 +58,7 @@ static int midi_capture_close(struct snd_rawmidi_substream *substream) mutex_lock(&oxfw->mutex); - oxfw->capture_substreams--; + --oxfw->substreams_count; snd_oxfw_stream_stop_duplex(oxfw); mutex_unlock(&oxfw->mutex); @@ -73,7 +73,7 @@ static int midi_playback_close(struct snd_rawmidi_substream *substream) mutex_lock(&oxfw->mutex); - oxfw->playback_substreams--; + --oxfw->substreams_count; snd_oxfw_stream_stop_duplex(oxfw); mutex_unlock(&oxfw->mutex); diff --git a/sound/firewire/oxfw/oxfw-pcm.c b/sound/firewire/oxfw/oxfw-pcm.c index 253d79607bdf..79c8e514bed9 100644 --- a/sound/firewire/oxfw/oxfw-pcm.c +++ b/sound/firewire/oxfw/oxfw-pcm.c @@ -220,7 +220,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream, if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { mutex_lock(&oxfw->mutex); - oxfw->capture_substreams++; + ++oxfw->substreams_count; mutex_unlock(&oxfw->mutex); } @@ -239,7 +239,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream, if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { mutex_lock(&oxfw->mutex); - oxfw->playback_substreams++; + ++oxfw->substreams_count; mutex_unlock(&oxfw->mutex); } @@ -253,7 +253,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream) mutex_lock(&oxfw->mutex); if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) - oxfw->capture_substreams--; + --oxfw->substreams_count; snd_oxfw_stream_stop_duplex(oxfw); @@ -268,7 +268,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream) mutex_lock(&oxfw->mutex); if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) - oxfw->playback_substreams--; + --oxfw->substreams_count; snd_oxfw_stream_stop_duplex(oxfw); diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 52cf815c27f7..ebfe0777773b 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -244,7 +244,7 @@ int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir; int err = 0; - if (oxfw->capture_substreams == 0 && oxfw->playback_substreams == 0) + if (oxfw->substreams_count == 0) return -EIO; // Considering JACK/FFADO streaming: @@ -323,7 +323,7 @@ int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw, void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw) { - if (oxfw->capture_substreams == 0 && oxfw->playback_substreams == 0) { + if (oxfw->substreams_count == 0) { amdtp_stream_stop(&oxfw->rx_stream); cmp_connection_break(&oxfw->in_conn); diff --git a/sound/firewire/oxfw/oxfw.h b/sound/firewire/oxfw/oxfw.h index 911a452f94db..e0c825288a24 100644 --- a/sound/firewire/oxfw/oxfw.h +++ b/sound/firewire/oxfw/oxfw.h @@ -52,8 +52,7 @@ struct snd_oxfw { struct cmp_connection in_conn; struct amdtp_stream tx_stream; struct amdtp_stream rx_stream; - unsigned int capture_substreams; - unsigned int playback_substreams; + unsigned int substreams_count; unsigned int midi_input_ports; unsigned int midi_output_ports; From patchwork Wed Jun 12 08:44:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989081 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 4FB3414E5 for ; Wed, 12 Jun 2019 08:57:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AD8A289DC for ; Wed, 12 Jun 2019 08:57:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F176289E2; Wed, 12 Jun 2019 08:57:53 +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 43D7E289DC for ; Wed, 12 Jun 2019 08:57:52 +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 8BA651796; Wed, 12 Jun 2019 10:57:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8BA651796 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329870; bh=4sV4kKcBSjQ4sHdqpZjqxyuWUiFnmpuDuCKg5U4cZtM=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=VLPUFVBj6VbRDshadHA1BtFs0dKqevc256cnx1b72Sy/7tJ2il2SjViq2VmFH70VO tSDBEscjiIANFiAT8RKfLUzH9ac8KuVAaOwoLhxpXPU0F3uKycZuMnvndbi76xCedz u6qovDJ63tKfR63Gjnuen2quyCwKkLMCZIYAxXMw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6C05EF89798; Wed, 12 Jun 2019 10:45:15 +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 8B60FF89765; Wed, 12 Jun 2019 10:45:00 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 826AAF89754 for ; Wed, 12 Jun 2019 10:44:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 826AAF89754 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="bKLUHUJg"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bAD26GgW" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id EEF37571; Wed, 12 Jun 2019 04:44:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:55 -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=wsXljU9fCnHuF ogmyU2MF+ejcM6GeWCHxf7I2mVyXv0=; b=bKLUHUJg/jgfU52Bg20fxre2QIMlF dtJaFnjO+pDtqehRkwt1a5az6SG8Rwv259rk5X4jioWp878C2u1r02dvj/+xXVkH pjOoaWNq3T77/UlSfCFTd/VpugzFJ771PL6zkJH7EtKaeCUX6D0kPtkqe4ItM1it ojf2UoPSMtJoIMq6x5n9VEVPprN+6+s8vUzKGvJh8DfzQUC2Rp4s7kacD52xfOIq eacZHai9ml5rBDz/1yhCqvhech8MZ0kKvJjewtYoYoLfCAlCYyBAvx/6NpQARUc/ QBhJ3S0fhDUJ8sCxAquKAOkoOE6sP6zfEvw6qIfFxDsXiRMENx0DjpFnw== 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=wsXljU9fCnHuFogmyU2MF+ejcM6GeWCHxf7I2mVyXv0=; b=bAD26GgW gZqFA52wurXDsvl/pZmovyuicm92lmqC7xxNqVpsgsqZHrTqlolDakh2ysMOnkVf eLKIHdUIYBuZTxrQj9X8JAJ06fxW6jB4oa612zqkIgavPV6sWIldp++OXdwvnfhM 88Z/x/0JnPmv4K5XGw67ZhX3w4OzSa3UTALhfpzjKS/au2IwwK+7dwo8R5PojtU3 i02DG3Pamh6ozmrOpePq7bFWwynVBuC2R96M59NJo5jAJ20zuuPaa+2Km+LVj7ua YwVy3eqbqA6+vB6dTSedwCHkolbpYoOdf5A8bgIC5PW672Xdfw5D2n6sYxryJKnM RCOsUajY/VObFw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepudeh 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 25F67380083; Wed, 12 Jun 2019 04:44:52 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:21 +0900 Message-Id: <20190612084422.5344-19-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 18/19] ALSA: oxfw: configure packet format in pcm.hw_params callback 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. At present, several operations are done in pcm.prepare callback. To reduce load of the callback, This commit splits out an operation to set packet format in pcm.hw_params callback. Signed-off-by: Takashi Sakamoto --- sound/firewire/oxfw/oxfw-midi.c | 14 +++++++--- sound/firewire/oxfw/oxfw-pcm.c | 26 +++++++++++------- sound/firewire/oxfw/oxfw-stream.c | 44 ++++++++++++++++++++++--------- sound/firewire/oxfw/oxfw.h | 7 ++--- 4 files changed, 62 insertions(+), 29 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-midi.c b/sound/firewire/oxfw/oxfw-midi.c index 092493497f1a..9ba62778add2 100644 --- a/sound/firewire/oxfw/oxfw-midi.c +++ b/sound/firewire/oxfw/oxfw-midi.c @@ -19,8 +19,11 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) mutex_lock(&oxfw->mutex); - ++oxfw->substreams_count; - err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->tx_stream, 0, 0); + err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->tx_stream, 0, 0); + if (err >= 0) { + ++oxfw->substreams_count; + err = snd_oxfw_stream_start_duplex(oxfw); + } mutex_unlock(&oxfw->mutex); @@ -41,8 +44,11 @@ static int midi_playback_open(struct snd_rawmidi_substream *substream) mutex_lock(&oxfw->mutex); - ++oxfw->substreams_count; - err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->rx_stream, 0, 0); + err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->rx_stream, 0, 0); + if (err >= 0) { + ++oxfw->substreams_count; + err = snd_oxfw_stream_start_duplex(oxfw); + } mutex_unlock(&oxfw->mutex); diff --git a/sound/firewire/oxfw/oxfw-pcm.c b/sound/firewire/oxfw/oxfw-pcm.c index 79c8e514bed9..b08b850d53ea 100644 --- a/sound/firewire/oxfw/oxfw-pcm.c +++ b/sound/firewire/oxfw/oxfw-pcm.c @@ -219,12 +219,18 @@ static int pcm_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); + unsigned int channels = params_channels(hw_params); + mutex_lock(&oxfw->mutex); - ++oxfw->substreams_count; + err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->tx_stream, + rate, channels); + if (err >= 0) + ++oxfw->substreams_count; mutex_unlock(&oxfw->mutex); } - return 0; + return err; } static int pcm_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) @@ -238,8 +244,14 @@ static int pcm_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); + unsigned int channels = params_channels(hw_params); + mutex_lock(&oxfw->mutex); - ++oxfw->substreams_count; + err = snd_oxfw_stream_reserve_duplex(oxfw, &oxfw->tx_stream, + rate, channels); + if (err >= 0) + ++oxfw->substreams_count; mutex_unlock(&oxfw->mutex); } @@ -280,12 +292,10 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream) static int pcm_capture_prepare(struct snd_pcm_substream *substream) { struct snd_oxfw *oxfw = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; int err; mutex_lock(&oxfw->mutex); - err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->tx_stream, - runtime->rate, runtime->channels); + err = snd_oxfw_stream_start_duplex(oxfw); mutex_unlock(&oxfw->mutex); if (err < 0) goto end; @@ -297,12 +307,10 @@ static int pcm_capture_prepare(struct snd_pcm_substream *substream) static int pcm_playback_prepare(struct snd_pcm_substream *substream) { struct snd_oxfw *oxfw = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; int err; mutex_lock(&oxfw->mutex); - err = snd_oxfw_stream_start_duplex(oxfw, &oxfw->rx_stream, - runtime->rate, runtime->channels); + err = snd_oxfw_stream_start_duplex(oxfw); mutex_unlock(&oxfw->mutex); if (err < 0) goto end; diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index ebfe0777773b..373154d8ee0e 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -236,16 +236,13 @@ static int init_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) return 0; } -int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream, - unsigned int rate, unsigned int pcm_channels) +int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw, + struct amdtp_stream *stream, + unsigned int rate, unsigned int pcm_channels) { struct snd_oxfw_stream_formation formation; enum avc_general_plug_dir dir; - int err = 0; - - if (oxfw->substreams_count == 0) - return -EIO; + int err; // Considering JACK/FFADO streaming: // TODO: This can be removed hwdep functionality becomes popular. @@ -266,14 +263,11 @@ int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw, err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation); if (err < 0) return err; - if (rate == 0) + if (rate == 0) { rate = formation.rate; - if (pcm_channels == 0) pcm_channels = formation.pcm; - - if (formation.rate != rate || formation.pcm != pcm_channels || - amdtp_streaming_error(&oxfw->rx_stream) || - amdtp_streaming_error(&oxfw->tx_stream)) { + } + if (formation.rate != rate || formation.pcm != pcm_channels) { amdtp_stream_stop(&oxfw->rx_stream); cmp_connection_break(&oxfw->in_conn); @@ -281,7 +275,10 @@ int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw, amdtp_stream_stop(&oxfw->tx_stream); cmp_connection_break(&oxfw->out_conn); } + } + if (oxfw->substreams_count == 0 || + formation.rate != rate || formation.pcm != pcm_channels) { err = set_stream_format(oxfw, stream, rate, pcm_channels); if (err < 0) { dev_err(&oxfw->unit->device, @@ -290,6 +287,27 @@ int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw, } } + return 0; +} + +int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw) +{ + int err; + + if (oxfw->substreams_count == 0) + return -EIO; + + if (amdtp_streaming_error(&oxfw->rx_stream) || + amdtp_streaming_error(&oxfw->tx_stream)) { + amdtp_stream_stop(&oxfw->rx_stream); + cmp_connection_break(&oxfw->in_conn); + + if (oxfw->has_output) { + amdtp_stream_stop(&oxfw->tx_stream); + cmp_connection_break(&oxfw->out_conn); + } + } + if (!amdtp_stream_running(&oxfw->rx_stream)) { err = start_stream(oxfw, &oxfw->rx_stream); if (err < 0) { diff --git a/sound/firewire/oxfw/oxfw.h b/sound/firewire/oxfw/oxfw.h index e0c825288a24..d4d4926c28cf 100644 --- a/sound/firewire/oxfw/oxfw.h +++ b/sound/firewire/oxfw/oxfw.h @@ -99,9 +99,10 @@ int avc_general_inquiry_sig_fmt(struct fw_unit *unit, unsigned int rate, unsigned short pid); int snd_oxfw_stream_init_duplex(struct snd_oxfw *oxfw); -int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw, - struct amdtp_stream *stream, - unsigned int rate, unsigned int pcm_channels); +int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw, + struct amdtp_stream *stream, + unsigned int rate, unsigned int pcm_channels); +int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw); void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw); void snd_oxfw_stream_destroy_duplex(struct snd_oxfw *oxfw); void snd_oxfw_stream_update_duplex(struct snd_oxfw *oxfw); From patchwork Wed Jun 12 08:44:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10989091 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 9300D14B6 for ; Wed, 12 Jun 2019 08:58:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E7CA289E0 for ; Wed, 12 Jun 2019 08:58:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7305C289E8; Wed, 12 Jun 2019 08:58:36 +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 A6AED289E0 for ; Wed, 12 Jun 2019 08:58:35 +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 0703D1794; Wed, 12 Jun 2019 10:57:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0703D1794 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560329914; bh=mXt7mC0ORZjukfJNrn8m+RVzU9Rf+uZ1zYc+0rufvAU=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=jnPUlTEn6UedNW8aXWtBuR0cSqmL2LFENJ62l99inJoTDJmOJq3AxIQi2W57gNb1A +dXcbVdDmvWIRgNWSu+7034ZOLF3tnnj23CENsNUSghtMTRucWRN+ZCsjpOh+eNOT9 t7nyiHskH0BQUZL0WOXqnqF1s5Oi5wrVcAeYYaxs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 55414F8979B; Wed, 12 Jun 2019 10:45:16 +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 15E2AF89767; Wed, 12 Jun 2019 10:45:02 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0E7CEF89761 for ; Wed, 12 Jun 2019 10:44:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0E7CEF89761 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="VGL9B+34"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="F85ioAMa" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 6E87F46C; Wed, 12 Jun 2019 04:44:56 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 12 Jun 2019 04:44:56 -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=SsMTKb8f/KA/T b5onWnz77zhoDf48lC8sVdZ7KH82E4=; b=VGL9B+34sgk5OJ4l01vkjePJkJBDv o71NJ0jyXbXHRFmiQNHUnxD5GztJSv7iKHxMnHeTvPg1wr1ZhWX8fqBam9bumdmu bWJcTgr8hXDTCG+3ekkvMJ+KEMlFo1uh5NYoxkquwu610D1AAtWnf26qDATFvehE Gi1pTzk5k0qMoTmq+KkirV1HqrUycug7KoEa79S8SwkWay7XC3DzsZUA31xuCH/y 53+KB1hmvuxwcOFF634ZimpNUkHR5ggX0yigdydvbir3CAv2kI0O4k3jHcwhUjrf aH1Y5oum5cOJAPfpx90jvRThuhhzEZui/6eYIvPyL0tEvM1Hj7tkQotXA== 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=SsMTKb8f/KA/Tb5onWnz77zhoDf48lC8sVdZ7KH82E4=; b=F85ioAMa jXijrUZ6HdUmmcyO6Tlx6d/iwcWqeGlLTpfqlYZQ8UyTLcBRpveQ+t4a6T2LgDai xmE6am8bA0OdoKVOi4+RE16Qnw1TDC4iPoYDh7N2JvoHmJm4w38NZS7tKJoldxSG wH4J+xRt4wa1pPEyT64nyIlfcPbdjKZ871kh4wBpMtZFBOM70E2esl0gMB3KxuIR 6JzFC98Kd5X8wTswRpGgVJrN/SQ0NBuodUpjtP4YQM2EZPZc4iq+qmnBdXkiO0iy baRLDkmVkamvX1LyHgcTK5BJfTtabz04oT/CIZXolt+Vb273VQsfXERLmkoPwYiQ VMSau7vF+HyN0g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehjedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgepudeh 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 A0D4C380089; Wed, 12 Jun 2019 04:44:54 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 12 Jun 2019 17:44:22 +0900 Message-Id: <20190612084422.5344-20-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612084422.5344-1-o-takashi@sakamocchi.jp> References: <20190612084422.5344-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 19/19] ALSA: oxfw: configure stream parameter in pcm.hw_params callback 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 splits out an operation to configure stream parameters into pcm.hw_params callback. In pcm.prepare callback, establishing connections and start isochronous contexts. Signed-off-by: Takashi Sakamoto --- sound/firewire/oxfw/oxfw-stream.c | 97 ++++++++++++++++++------------- 1 file changed, 57 insertions(+), 40 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 373154d8ee0e..837733f10736 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -103,51 +103,13 @@ static int set_stream_format(struct snd_oxfw *oxfw, struct amdtp_stream *s, static int start_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) { - u8 **formats; - enum avc_general_plug_dir dir; struct cmp_connection *conn; - struct snd_oxfw_stream_formation formation; - int i; int err; - if (stream == &oxfw->rx_stream) { - dir = AVC_GENERAL_PLUG_DIR_IN; - formats = oxfw->rx_stream_formats; + if (stream == &oxfw->rx_stream) conn = &oxfw->in_conn; - } else { - dir = AVC_GENERAL_PLUG_DIR_OUT; - formats = oxfw->tx_stream_formats; + else conn = &oxfw->out_conn; - } - - err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation); - if (err < 0) - return err; - - for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { - struct snd_oxfw_stream_formation fmt; - - if (formats[i] == NULL) - break; - - err = snd_oxfw_stream_parse_format(formats[i], &fmt); - if (err < 0) - return err; - if (fmt.rate == formation.rate && fmt.pcm == formation.pcm && - fmt.midi == formation.midi) - break; - } - if (i == SND_OXFW_STREAM_FORMAT_ENTRIES) - return -EINVAL; - - // The stream should have one pcm channels at least. - if (formation.pcm == 0) - return -EINVAL; - - err = amdtp_am824_set_parameters(stream, formation.rate, formation.pcm, - formation.midi * 8, false); - if (err < 0) - return err; err = cmp_connection_establish(conn, amdtp_stream_get_max_payload(stream)); @@ -236,6 +198,51 @@ static int init_stream(struct snd_oxfw *oxfw, struct amdtp_stream *stream) return 0; } +static int keep_resources(struct snd_oxfw *oxfw, struct amdtp_stream *stream) +{ + enum avc_general_plug_dir dir; + u8 **formats; + struct snd_oxfw_stream_formation formation; + int i; + int err; + + if (stream == &oxfw->rx_stream) { + dir = AVC_GENERAL_PLUG_DIR_IN; + formats = oxfw->rx_stream_formats; + } else { + dir = AVC_GENERAL_PLUG_DIR_OUT; + formats = oxfw->tx_stream_formats; + } + + err = snd_oxfw_stream_get_current_formation(oxfw, dir, &formation); + if (err < 0) + return err; + + for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { + struct snd_oxfw_stream_formation fmt; + + if (formats[i] == NULL) + break; + + err = snd_oxfw_stream_parse_format(formats[i], &fmt); + if (err < 0) + return err; + + if (fmt.rate == formation.rate && fmt.pcm == formation.pcm && + fmt.midi == formation.midi) + break; + } + if (i == SND_OXFW_STREAM_FORMAT_ENTRIES) + return -EINVAL; + + // The stream should have one pcm channels at least. + if (formation.pcm == 0) + return -EINVAL; + + return amdtp_am824_set_parameters(stream, formation.rate, formation.pcm, + formation.midi * 8, false); +} + int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw, struct amdtp_stream *stream, unsigned int rate, unsigned int pcm_channels) @@ -285,6 +292,16 @@ int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw, "fail to set stream format: %d\n", err); return err; } + + err = keep_resources(oxfw, &oxfw->rx_stream); + if (err < 0) + return err; + + if (oxfw->has_output) { + err = keep_resources(oxfw, &oxfw->tx_stream); + if (err < 0) + return err; + } } return 0;