All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: "Cezary Rojewski" <cezary.rojewski@intel.com>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	tiwai@suse.de, "Bard Liao" <yung-chuan.liao@linux.intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	broonie@kernel.org,
	"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
Subject: [PATCH 6/8] ALSA: hda: ext: simplify logic for stream assignment
Date: Mon, 19 Sep 2022 14:10:39 +0200	[thread overview]
Message-ID: <20220919121041.43463-7-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20220919121041.43463-1-pierre-louis.bossart@linux.intel.com>

The logic is needlessly complicated, the basic rule is:

The host streams can be found by checking the 'opened' boolean.
The link streams can be found by checking the 'link_locked' boolean.

Once a stream is found, it can be unconditionally decoupled. The
snd_hdac_ext_stream_decouple_locked() routine will make sure the
register status is modified as needed and the 'decoupled' boolean set.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
 sound/hda/ext/hdac_ext_stream.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/sound/hda/ext/hdac_ext_stream.c b/sound/hda/ext/hdac_ext_stream.c
index 9419abd7fc036..254df9a67bd2b 100644
--- a/sound/hda/ext/hdac_ext_stream.c
+++ b/sound/hda/ext/hdac_ext_stream.c
@@ -267,19 +267,15 @@ hdac_ext_link_stream_assign(struct hdac_bus *bus,
 		if (hstream->direction != substream->stream)
 			continue;
 
-		/* check if decoupled stream and not in use is available */
-		if (hext_stream->decoupled && !hext_stream->link_locked) {
-			res = hext_stream;
-			break;
-		}
-
+		/* check if link stream is available */
 		if (!hext_stream->link_locked) {
-			snd_hdac_ext_stream_decouple_locked(bus, hext_stream, true);
 			res = hext_stream;
 			break;
 		}
+
 	}
 	if (res) {
+		snd_hdac_ext_stream_decouple_locked(bus, res, true);
 		res->link_locked = 1;
 		res->link_substream = substream;
 	}
@@ -308,13 +304,12 @@ hdac_ext_host_stream_assign(struct hdac_bus *bus,
 			continue;
 
 		if (!hstream->opened) {
-			if (!hext_stream->decoupled)
-				snd_hdac_ext_stream_decouple_locked(bus, hext_stream, true);
 			res = hext_stream;
 			break;
 		}
 	}
 	if (res) {
+		snd_hdac_ext_stream_decouple_locked(bus, res, true);
 		res->hstream.opened = 1;
 		res->hstream.running = 0;
 		res->hstream.substream = substream;
-- 
2.34.1


  parent reply	other threads:[~2022-09-19 12:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 12:10 [PATCH 0/8] ALSA: hda: document/simplify hdac_ext handling Pierre-Louis Bossart
2022-09-19 12:10 ` [PATCH 1/8] ALSA: hda: make snd_hdac_stream_clear() static Pierre-Louis Bossart
2022-09-19 12:10 ` [PATCH 2/8] ALSA: hda: document state machine for hdac_streams Pierre-Louis Bossart
2022-09-19 12:10 ` [PATCH 3/8] ALSA: hda: ext: make snd_hdac_ext_stream_init() static Pierre-Louis Bossart
2022-09-19 12:10 ` [PATCH 4/8] ALSA: hda: Use hdac_ext prefix in snd_hdac_stream_free_all() for clarity Pierre-Louis Bossart
2022-09-19 12:10 ` [PATCH 5/8] ALSA: hda: add snd_hdac_stop_streams() helper Pierre-Louis Bossart
2022-09-19 12:10 ` Pierre-Louis Bossart [this message]
2022-09-19 12:10 ` [PATCH 7/8] ALSA: hda: ext: fix locking in stream_release Pierre-Louis Bossart
2022-09-19 12:10 ` [PATCH 8/8] ALSA: hda: ext: remove always-true conditions on host and link release Pierre-Louis Bossart
2022-09-20  6:13 ` [PATCH 0/8] ALSA: hda: document/simplify hdac_ext handling Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220919121041.43463-7-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=tiwai@suse.de \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.