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 06/12] ASoC: SOF: Intel: Account for compress streams when servicing IRQs
Date: Fri, 24 Jan 2020 20:04:07 +0100	[thread overview]
Message-ID: <20200124190413.18154-7-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20200124190413.18154-1-cezary.rojewski@intel.com>

Update stream irq handler definition to correctly set hdac_stream
current position when servicing stream interrupts for compress streams.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 include/sound/hdaudio.h          |  1 +
 sound/soc/sof/intel/hda-stream.c | 26 ++++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 91aabda56c96..4238eee7f593 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -499,6 +499,7 @@ struct hdac_stream {
 	bool locked:1;
 	bool stripe:1;			/* apply stripe control */
 
+	unsigned long curr_pos;
 	/* timestamp */
 	unsigned long start_wallclk;	/* start + minimum wallclk */
 	unsigned long period_wallclk;	/* wallclk for period */
diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c
index c0ab9bb2a797..c8920a60e346 100644
--- a/sound/soc/sof/intel/hda-stream.c
+++ b/sound/soc/sof/intel/hda-stream.c
@@ -571,6 +571,23 @@ bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev)
 	return ret;
 }
 
+static void hda_dsp_set_bytes_transferred(struct hdac_stream *hstream,
+					  u64 buffer_size)
+{
+	unsigned int prev_pos;
+	int pos, num_bytes;
+
+	div_u64_rem(hstream->curr_pos, buffer_size, &prev_pos);
+	pos = snd_hdac_stream_get_pos_posbuf(hstream);
+
+	if (pos < prev_pos)
+		num_bytes = (buffer_size - prev_pos) +  pos;
+	else
+		num_bytes = pos - prev_pos;
+
+	hstream->curr_pos += num_bytes;
+}
+
 static bool hda_dsp_stream_check(struct hdac_bus *bus, u32 status)
 {
 	struct sof_intel_hda_dev *sof_hda = bus_to_sof_hda(bus);
@@ -588,14 +605,19 @@ static bool hda_dsp_stream_check(struct hdac_bus *bus, u32 status)
 			snd_hdac_stream_writeb(s, SD_STS, sd_status);
 
 			active = true;
-			if (!s->substream ||
+			if ((!s->substream && !s->cstream) ||
 			    !s->running ||
 			    (sd_status & SOF_HDA_CL_DMA_SD_INT_COMPLETE) == 0)
 				continue;
 
 			/* Inform ALSA only in case not do that with IPC */
-			if (sof_hda->no_ipc_position)
+			if (s->substream && sof_hda->no_ipc_position) {
 				snd_sof_pcm_period_elapsed(s->substream);
+			} else if (s->cstream) {
+				hda_dsp_set_bytes_transferred(s,
+					s->cstream->runtime->buffer_size);
+				snd_compr_fragment_elapsed(s->cstream);
+			}
 		}
 	}
 
-- 
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-24 19:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 19:04 [alsa-devel] [PATCH 00/12] ASoC: SOF: Data probing Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 01/12] ALSA: hda: Allow for compress stream to hdac_ext_stream assignment Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 02/12] ALSA: hda: Prepare for compress stream support Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 03/12] ALSA: hda: Interrupt servicing and BDL setup for compress streams Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 04/12] ALSA: core: Expand DMA buffer information Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 05/12] ALSA: core: Implement compress page allocation and free routines Cezary Rojewski
2020-01-24 19:04 ` Cezary Rojewski [this message]
2020-01-24 19:04 ` [alsa-devel] [PATCH 07/12] ASoC: SOF: Implement Probe IPC API Cezary Rojewski
2020-01-24 19:28   ` Pierre-Louis Bossart
2020-01-27 12:16     ` Cezary Rojewski
2020-01-24 19:55   ` Pierre-Louis Bossart
2020-01-27 12:20     ` Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 08/12] ASoC: SOF: Generic probe compress operations Cezary Rojewski
2020-01-24 19:41   ` Pierre-Louis Bossart
2020-01-27 12:23     ` Cezary Rojewski
2020-01-24 20:00   ` Pierre-Louis Bossart
2020-01-27 12:28     ` Cezary Rojewski
2020-01-27 15:56       ` Pierre-Louis Bossart
2020-01-24 19:04 ` [alsa-devel] [PATCH 09/12] ASoC: SOF: Intel: Probe " Cezary Rojewski
2020-01-24 20:07   ` Pierre-Louis Bossart
2020-01-27 12:28     ` Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 10/12] ASoC: SOF: Provide probe debugfs support Cezary Rojewski
2020-01-24 20:22   ` Pierre-Louis Bossart
2020-01-27 12:31     ` Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 11/12] ASoC: SOF: Intel: Add Probe compress CPU DAIs Cezary Rojewski
2020-01-24 19:04 ` [alsa-devel] [PATCH 12/12] ASoC: Intel: sof_rt5682: Add compress probe DAI links Cezary Rojewski
2020-01-24 19:31   ` Pierre-Louis Bossart
2020-01-27 12:32     ` Cezary Rojewski
2020-01-25 10:49 ` [alsa-devel] [PATCH 00/12] ASoC: SOF: Data probing 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=20200124190413.18154-7-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.