All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org
Cc: lgirdwood@gmail.com, Cezary Rojewski <cezary.rojewski@intel.com>,
	broonie@kernel.org, tiwai@suse.com,
	pierre-louis.bossart@linux.intel.com
Subject: [alsa-devel] [PATCH v3 02/11] ALSA: hda: Prepare for compress stream support
Date: Tue, 28 Jan 2020 11:43:47 +0100	[thread overview]
Message-ID: <20200128104356.16570-3-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20200128104356.16570-1-cezary.rojewski@intel.com>

Before introducing compress specific changes, adjust BDL and parameters
setup functions so these are not tightly coupled with PCM streams.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/hda/hdac_stream.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c
index 682ed39f79b0..5259cf366011 100644
--- a/sound/hda/hdac_stream.c
+++ b/sound/hda/hdac_stream.c
@@ -408,11 +408,15 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
 {
 	struct hdac_bus *bus = azx_dev->bus;
 	struct snd_pcm_substream *substream = azx_dev->substream;
-	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct snd_pcm_runtime *runtime;
+	struct snd_dma_buffer *dmab;
 	__le32 *bdl;
 	int i, ofs, periods, period_bytes;
 	int pos_adj, pos_align;
 
+	runtime = substream->runtime;
+	dmab = snd_pcm_get_dma_buf(substream);
+
 	/* reset BDL address */
 	snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0);
 	snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0);
@@ -426,7 +430,7 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
 	azx_dev->frags = 0;
 
 	pos_adj = bus->bdl_pos_adj;
-	if (!azx_dev->no_period_wakeup && pos_adj > 0) {
+	if (runtime && !azx_dev->no_period_wakeup && pos_adj > 0) {
 		pos_align = pos_adj;
 		pos_adj = (pos_adj * runtime->rate + 47999) / 48000;
 		if (!pos_adj)
@@ -440,8 +444,7 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
 				 pos_adj);
 			pos_adj = 0;
 		} else {
-			ofs = setup_bdle(bus, snd_pcm_get_dma_buf(substream),
-					 azx_dev,
+			ofs = setup_bdle(bus, dmab, azx_dev,
 					 &bdl, ofs, pos_adj, true);
 			if (ofs < 0)
 				goto error;
@@ -451,13 +454,11 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
 
 	for (i = 0; i < periods; i++) {
 		if (i == periods - 1 && pos_adj)
-			ofs = setup_bdle(bus, snd_pcm_get_dma_buf(substream),
-					 azx_dev, &bdl, ofs,
-					 period_bytes - pos_adj, 0);
+			ofs = setup_bdle(bus, dmab, azx_dev,
+					 &bdl, ofs, period_bytes - pos_adj, 0);
 		else
-			ofs = setup_bdle(bus, snd_pcm_get_dma_buf(substream),
-					 azx_dev, &bdl, ofs,
-					 period_bytes,
+			ofs = setup_bdle(bus, dmab, azx_dev,
+					 &bdl, ofs, period_bytes,
 					 !azx_dev->no_period_wakeup);
 		if (ofs < 0)
 			goto error;
@@ -482,26 +483,25 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_setup_periods);
 int snd_hdac_stream_set_params(struct hdac_stream *azx_dev,
 				 unsigned int format_val)
 {
-
-	unsigned int bufsize, period_bytes;
 	struct snd_pcm_substream *substream = azx_dev->substream;
-	struct snd_pcm_runtime *runtime;
+	unsigned int bufsize, period_bytes;
+	unsigned int no_period_wakeup;
 	int err;
 
 	if (!substream)
 		return -EINVAL;
-	runtime = substream->runtime;
 	bufsize = snd_pcm_lib_buffer_bytes(substream);
 	period_bytes = snd_pcm_lib_period_bytes(substream);
+	no_period_wakeup = substream->runtime->no_period_wakeup;
 
 	if (bufsize != azx_dev->bufsize ||
 	    period_bytes != azx_dev->period_bytes ||
 	    format_val != azx_dev->format_val ||
-	    runtime->no_period_wakeup != azx_dev->no_period_wakeup) {
+	    no_period_wakeup != azx_dev->no_period_wakeup) {
 		azx_dev->bufsize = bufsize;
 		azx_dev->period_bytes = period_bytes;
 		azx_dev->format_val = format_val;
-		azx_dev->no_period_wakeup = runtime->no_period_wakeup;
+		azx_dev->no_period_wakeup = no_period_wakeup;
 		err = snd_hdac_stream_setup_periods(azx_dev);
 		if (err < 0)
 			return err;
-- 
2.17.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  parent reply	other threads:[~2020-01-28 10:46 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28 10:43 [alsa-devel] [PATCH v3 00/11] ASoC: SOF: Data probing Cezary Rojewski
2020-01-28 10:43 ` [alsa-devel] [PATCH v3 01/11] ALSA: hda: Allow for compress stream to hdac_ext_stream assignment Cezary Rojewski
2020-01-28 10:43 ` Cezary Rojewski [this message]
2020-01-28 10:43 ` [alsa-devel] [PATCH v3 03/11] ALSA: hda: Interrupt servicing and BDL setup for compress streams Cezary Rojewski
2020-01-28 10:43 ` [alsa-devel] [PATCH v3 04/11] ALSA: core: Expand DMA buffer information Cezary Rojewski
2020-01-28 10:59   ` Vinod Koul
2020-01-28 11:58     ` Cezary Rojewski
2020-01-29  9:08       ` Takashi Iwai
2020-01-28 10:43 ` [alsa-devel] [PATCH v3 05/11] ALSA: core: Implement compress page allocation and free routines Cezary Rojewski
2020-01-28 11:05   ` Vinod Koul
2020-01-28 10:43 ` [alsa-devel] [PATCH v3 06/11] ASoC: SOF: Intel: Account for compress streams when servicing IRQs Cezary Rojewski
2020-01-28 10:43 ` [alsa-devel] [PATCH v3 07/11] ASoC: SOF: Implement Probe IPC API Cezary Rojewski
2020-01-28 10:43 ` [alsa-devel] [PATCH v3 08/11] ASoC: SOF: Generic probe compress operations Cezary Rojewski
2020-01-29  7:48   ` Daniel Baluta
2020-01-29  9:04     ` Cezary Rojewski
2020-01-28 10:43 ` [alsa-devel] [PATCH v3 09/11] ASoC: SOF: Intel: Probe " Cezary Rojewski
2020-01-29  7:55   ` Daniel Baluta
2020-01-29  9:09     ` Cezary Rojewski
2020-01-28 10:43 ` [alsa-devel] [PATCH v3 10/11] ASoC: SOF: Provide probe debugfs support Cezary Rojewski
2020-01-28 17:54   ` Sridharan, Ranjani
2020-01-28 18:59     ` Cezary Rojewski
2020-01-29 11:43     ` Mark Brown
2020-01-28 10:43 ` [alsa-devel] [PATCH v3 11/11] ASoC: SOF: Intel: Add Probe compress CPU DAIs Cezary Rojewski
2020-01-29  8:04   ` Daniel Baluta
2020-01-29  9:24     ` Cezary Rojewski
2020-01-29  9:46       ` Daniel Baluta
2020-01-31 12:34         ` Cezary Rojewski
2020-01-28 17:55 ` [alsa-devel] [PATCH v3 00/11] ASoC: SOF: Data probing Pierre-Louis Bossart
2020-01-28 19:29   ` Cezary Rojewski
2020-01-28 21:11     ` Pierre-Louis Bossart
2020-01-31 12:44       ` Cezary Rojewski

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=20200128104356.16570-3-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.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.