From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
pierre-louis.bossart@linux.intel.com, tiwai@suse.com,
hdegoede@redhat.com, amadeuszx.slawinski@linux.intel.com
Subject: [PATCH v4 3/9] ALSA: hda: Introduce snd_hdac_stream_wait_drsm()
Date: Thu, 27 Oct 2022 14:46:56 +0200 [thread overview]
Message-ID: <20221027124702.1761002-4-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20221027124702.1761002-1-cezary.rojewski@intel.com>
Allow for waiting for DRSM bit for specified stream to be cleared from
HDAudio library level. Drivers may utilize this optional step during the
stream resume procedure.
Suggested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
Changes in v4:
- replaced readb_poll_timeout() with read_poll_timeout() for the DRSM
polling function as the register is u32 wide, not u8
include/sound/hdaudio.h | 1 +
sound/hda/hdac_stream.c | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 78f1809a4ad6..a6872537724d 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -597,6 +597,7 @@ int snd_hdac_stream_get_spbmaxfifo(struct hdac_bus *bus,
struct hdac_stream *azx_dev);
void snd_hdac_stream_drsm_enable(struct hdac_bus *bus,
bool enable, int index);
+int snd_hdac_stream_wait_drsm(struct hdac_stream *azx_dev);
int snd_hdac_stream_set_dpibr(struct hdac_bus *bus,
struct hdac_stream *azx_dev, u32 value);
int snd_hdac_stream_set_lpib(struct hdac_stream *azx_dev, u32 value);
diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c
index 35fe2bd582ac..3b250ee7f6a7 100644
--- a/sound/hda/hdac_stream.c
+++ b/sound/hda/hdac_stream.c
@@ -821,6 +821,28 @@ void snd_hdac_stream_drsm_enable(struct hdac_bus *bus,
}
EXPORT_SYMBOL_GPL(snd_hdac_stream_drsm_enable);
+/*
+ * snd_hdac_stream_wait_drsm - wait for HW to clear RSM for a stream
+ * @azx_dev: HD-audio core stream to await RSM for
+ *
+ * Returns 0 on success and -ETIMEDOUT upon a timeout.
+ */
+int snd_hdac_stream_wait_drsm(struct hdac_stream *azx_dev)
+{
+ struct hdac_bus *bus = azx_dev->bus;
+ u32 mask, reg;
+ int ret;
+
+ mask = 1 << azx_dev->index;
+
+ ret = read_poll_timeout(snd_hdac_reg_readl, reg, !(reg & mask), 250, 2000, false, bus,
+ bus->drsmcap + AZX_REG_DRSM_CTL);
+ if (ret)
+ dev_dbg(bus->dev, "polling RSM 0x%08x failed: %d\n", mask, ret);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(snd_hdac_stream_wait_drsm);
+
/**
* snd_hdac_stream_set_dpibr - sets the dpibr value of a stream
* @bus: HD-audio core bus
--
2.25.1
next prev parent reply other threads:[~2022-10-27 12:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 12:46 [PATCH v4 0/9] ASoC: Intel: avs: PCM power management Cezary Rojewski
2022-10-27 12:46 ` [PATCH v4 1/9] ASoC: Intel: avs: Split pcm pages freeing operation from hw_free() Cezary Rojewski
2022-10-27 12:46 ` [PATCH v4 2/9] ASoC: Intel: avs: Introduce PCM power management routines Cezary Rojewski
2022-10-27 12:46 ` Cezary Rojewski [this message]
2022-10-27 13:31 ` [PATCH v4 3/9] ALSA: hda: Introduce snd_hdac_stream_wait_drsm() Takashi Iwai
2022-10-27 12:46 ` [PATCH v4 4/9] ASoC: Intel: avs: Handle SUSPEND and RESUME triggers Cezary Rojewski
2022-10-27 12:46 ` [PATCH v4 5/9] ASoC: Intel: avs: Restart instead of resuming HDA capture streams Cezary Rojewski
2022-10-27 12:46 ` [PATCH v4 6/9] ASoC: Intel: avs: Count low power streams Cezary Rojewski
2022-10-27 12:47 ` [PATCH v4 7/9] ASoC: Intel: avs: Standby power-state support Cezary Rojewski
2022-10-27 12:47 ` [PATCH v4 8/9] ASoC: Intel: avs: Power and clock gating policy overriding Cezary Rojewski
2022-10-27 12:47 ` [PATCH v4 9/9] ASoC: Intel: avs: Enact power gating policy Cezary Rojewski
2022-10-28 16:40 ` [PATCH v4 0/9] ASoC: Intel: avs: PCM power management Mark Brown
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=20221027124702.1761002-4-cezary.rojewski@intel.com \
--to=cezary.rojewski@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=amadeuszx.slawinski@linux.intel.com \
--cc=broonie@kernel.org \
--cc=hdegoede@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox