From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Vinod Koul <vinod.koul@intel.com>, Greg KH <gregkh@linuxfoundation.org>
Cc: ALSA <alsa-devel@alsa-project.org>,
tiwai@suse.de, liam.r.girdwood@linux.intel.com,
patches.audio@intel.com, broonie@kernel.org,
Sanyog Kale <sanyog.r.kale@intel.com>
Subject: Re: [PATCH v2 07/13] soundwire: Add stream configuration APIs
Date: Thu, 5 Apr 2018 18:40:20 -0500 [thread overview]
Message-ID: <06b35225-232a-7220-ffda-e42b5c6c9366@linux.intel.com> (raw)
In-Reply-To: <1522946904-2089-8-git-send-email-vinod.koul@intel.com>
> +/**
> + * sdw_prepare_stream: Prepare SoundWire stream
> + *
> + * @stream: Soundwire stream
> + *
> + * Documentation/soundwire/stream.txt explains this API in detail
> + */
> +int sdw_prepare_stream(struct sdw_stream_runtime *stream)
> +{
> + int ret = 0;
> +
> + if (!stream) {
> + pr_err("SoundWire: Handle not found for stream");
> + return -EINVAL;
> + }
> +
> + mutex_lock(&stream->m_rt->bus->bus_lock);
> +
> + if (stream->state == SDW_STREAM_DISABLED)
> + goto error;
> +
> + if (stream->state != SDW_STREAM_CONFIGURED) {
> + ret = -EINVAL;
> + goto error;
> + }
this seems to be a new pattern in this file.
Why is the first test even needed?
> +
> + ret = _sdw_prepare_stream(stream);
> + if (ret < 0) {
> + pr_err("Prepare for stream:%s failed: %d", stream->name, ret);
> + goto error;
> + }
> +
> +error:
> + mutex_unlock(&stream->m_rt->bus->bus_lock);
> + return ret;
> +}
> +EXPORT_SYMBOL(sdw_prepare_stream);
> +
> +static int _sdw_enable_stream(struct sdw_stream_runtime *stream)
> +{
> + struct sdw_master_runtime *m_rt = stream->m_rt;
> + struct sdw_bus *bus = m_rt->bus;
> + int ret;
> +
> + /* Program params */
> + ret = sdw_program_params(bus);
> + if (ret < 0) {
> + dev_err(bus->dev, "Program params failed: %d", ret);
> + return ret;
> + }
> +
> + /* Enable port(s) */
> + ret = sdw_enable_disable_ports(m_rt, true);
> + if (ret < 0) {
> + dev_err(bus->dev, "Enable port(s) failed ret: %d", ret);
> + return ret;
> + }
> +
> + ret = do_bank_switch(stream);
> + if (ret < 0) {
> + dev_err(bus->dev, "Bank switch failed: %d", ret);
> + return ret;
> + }
> +
> + stream->state = SDW_STREAM_ENABLED;
> + return 0;
> +}
> +
> +/**
> + * sdw_enable_stream: Enable SoundWire stream
> + *
> + * @stream: Soundwire stream
> + *
> + * Documentation/soundwire/stream.txt explains this API in detail
> + */
> +int sdw_enable_stream(struct sdw_stream_runtime *stream)
> +{
> + int ret = 0;
> +
> + if (!stream) {
> + pr_err("SoundWire: Handle not found for stream");
> + return -EINVAL;
> + }
> +
> + mutex_lock(&stream->m_rt->bus->bus_lock);
> +
> + if (stream->state == SDW_STREAM_ENABLED)
> + goto error;
> +
> + if ((stream->state != SDW_STREAM_PREPARED) &&
> + (stream->state != SDW_STREAM_DISABLED)) {
> + ret = -EINVAL;
> + goto error;
> + }
same here, why would you enable a stream that's already enabled? Why is
this an error that returns 0?
> +
> + ret = _sdw_enable_stream(stream);
> + if (ret < 0) {
> + pr_err("Enable for stream:%s failed: %d", stream->name, ret);
> + goto error;
> + }
> +
> +error:
> + mutex_unlock(&stream->m_rt->bus->bus_lock);
> + return ret;
> +}
> +EXPORT_SYMBOL(sdw_enable_stream);
> +
> +static int _sdw_disable_stream(struct sdw_stream_runtime *stream)
> +{
> + struct sdw_master_runtime *m_rt = stream->m_rt;
> + struct sdw_bus *bus = m_rt->bus;
> + int ret;
> +
> + /* Disable port(s) */
> + ret = sdw_enable_disable_ports(m_rt, false);
> + if (ret < 0) {
> + dev_err(bus->dev, "Disable port(s) failed: %d", ret);
> + return ret;
> + }
> +
> + stream->state = SDW_STREAM_DISABLED;
> +
> + /* Program params */
> + ret = sdw_program_params(bus);
> + if (ret < 0) {
> + dev_err(bus->dev, "Program params failed: %d", ret);
> + return ret;
> + }
> +
> + return do_bank_switch(stream);
> +}
> +
> +/**
> + * sdw_disable_stream: Disable SoundWire stream
> + *
> + * @stream: Soundwire stream
> + *
> + * Documentation/soundwire/stream.txt explains this API in detail
> + */
> +int sdw_disable_stream(struct sdw_stream_runtime *stream)
> +{
> + int ret = 0;
> +
> + if (!stream) {
> + pr_err("SoundWire: Handle not found for stream");
> + return -EINVAL;
> + }
> +
> + mutex_lock(&stream->m_rt->bus->bus_lock);
> +
> + if (stream->state == SDW_STREAM_DISABLED)
> + goto error;
> +
> + if (stream->state != SDW_STREAM_ENABLED) {
> + ret = -EINVAL;
> + goto error;
> + }
and here to.
> +
> + ret = _sdw_disable_stream(stream);
> + if (ret < 0) {
> + pr_err("Disable for stream:%s failed: %d", stream->name, ret);
> + goto error;
> + }
> +
> +error:
> + mutex_unlock(&stream->m_rt->bus->bus_lock);
> + return ret;
> +}
> +EXPORT_SYMBOL(sdw_disable_stream);
> +
> +static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)
> +{
> + struct sdw_master_runtime *m_rt = stream->m_rt;
> + struct sdw_bus *bus = m_rt->bus;
> + int ret = 0;
> +
> + /* De-prepare port(s) */
> + ret = sdw_prep_deprep_ports(m_rt, false);
> + if (ret < 0) {
> + dev_err(bus->dev, "De-prepare port(s) failed: %d", ret);
> + return ret;
> + }
> +
> + bus->params.bandwidth -= m_rt->stream->params.rate *
> + m_rt->ch_count * m_rt->stream->params.bps;
> +
> + if (!bus->params.bandwidth) {
> + bus->params.row = 0;
> + bus->params.col = 0;
> + goto exit;
> +
> + }
> +
> + /* Program params */
> + ret = sdw_program_params(bus);
> + if (ret < 0) {
> + dev_err(bus->dev, "Program params failed: %d", ret);
> + return ret;
> + }
> +
> + return do_bank_switch(stream);
> +
> +exit:
> + stream->state = SDW_STREAM_DEPREPARED;
> +
> + return ret;
> +}
> +
> +/**
> + * sdw_deprepare_stream: Deprepare SoundWire stream
> + *
> + * @stream: Soundwire stream
> + *
> + * Documentation/soundwire/stream.txt explains this API in detail
> + */
> +int sdw_deprepare_stream(struct sdw_stream_runtime *stream)
> +{
> + int ret = 0;
> +
> + if (!stream) {
> + pr_err("SoundWire: Handle not found for stream");
> + return -EINVAL;
> + }
> +
> + mutex_lock(&stream->m_rt->bus->bus_lock);
> +
> + if (stream->state != SDW_STREAM_DISABLED) {
> + ret = -EINVAL;
> + goto error;
> + }
> +
> + ret = _sdw_deprepare_stream(stream);
> + if (ret < 0) {
> + pr_err("De-prepare for stream:%d failed: %d", ret, ret);
> + goto error;
> + }
> +
> +error:
> + mutex_unlock(&stream->m_rt->bus->bus_lock);
> + return ret;
> +}
> +EXPORT_SYMBOL(sdw_deprepare_stream);
> diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
> index 4120a220ae42..4d9c3f86d0f0 100644
> --- a/include/linux/soundwire/sdw.h
> +++ b/include/linux/soundwire/sdw.h
> @@ -791,6 +791,10 @@ int sdw_stream_remove_master(struct sdw_bus *bus,
> struct sdw_stream_runtime *stream);
> int sdw_stream_remove_slave(struct sdw_slave *slave,
> struct sdw_stream_runtime *stream);
> +int sdw_prepare_stream(struct sdw_stream_runtime *stream);
> +int sdw_enable_stream(struct sdw_stream_runtime *stream);
> +int sdw_disable_stream(struct sdw_stream_runtime *stream);
> +int sdw_deprepare_stream(struct sdw_stream_runtime *stream);
>
> /* messaging and data APIs */
>
>
next prev parent reply other threads:[~2018-04-05 23:40 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-05 16:48 [PATCH v2 00/13] soundwire: Add stream support Vinod Koul
2018-04-05 16:48 ` [PATCH v2 01/13] soundwire: Add more documentation Vinod Koul
2018-04-05 21:37 ` Pierre-Louis Bossart
2018-04-06 3:24 ` Vinod Koul
2018-04-06 15:24 ` Pierre-Louis Bossart
2018-04-10 4:04 ` Vinod Koul
2018-04-05 16:48 ` [PATCH v2 02/13] soundwire: Add support for SoundWire stream management Vinod Koul
2018-04-05 22:34 ` Pierre-Louis Bossart
2018-04-06 4:53 ` Vinod Koul
2018-04-06 15:21 ` Pierre-Louis Bossart
2018-04-10 4:43 ` Vinod Koul
2018-04-10 15:47 ` Pierre-Louis Bossart
2018-04-11 3:41 ` [alsa-devel] " Vinod Koul
2018-04-05 16:48 ` [PATCH v2 03/13] soundwire: Add support for port management Vinod Koul
2018-04-05 23:04 ` Pierre-Louis Bossart
2018-04-06 5:00 ` Vinod Koul
2018-04-06 15:26 ` Pierre-Louis Bossart
2018-04-05 16:48 ` [PATCH v2 04/13] soundwire: Add Master and Slave port programming Vinod Koul
2018-04-05 23:14 ` Pierre-Louis Bossart
2018-04-06 5:01 ` Vinod Koul
2018-04-05 16:48 ` [PATCH v2 05/13] soundwire: Add helpers for ports operations Vinod Koul
2018-04-05 23:27 ` Pierre-Louis Bossart
2018-04-06 5:05 ` Vinod Koul
2018-04-05 16:48 ` [PATCH v2 06/13] soundwire: Add bank switch routine Vinod Koul
2018-04-05 23:35 ` Pierre-Louis Bossart
2018-04-06 8:33 ` Vinod Koul
2018-04-05 16:48 ` [PATCH v2 07/13] soundwire: Add stream configuration APIs Vinod Koul
2018-04-05 23:40 ` Pierre-Louis Bossart [this message]
2018-04-06 8:48 ` Vinod Koul
2018-04-06 15:28 ` Pierre-Louis Bossart
2018-04-05 16:48 ` [PATCH v2 08/13] ASoC: Add SoundWire stream programming interface Vinod Koul
2018-04-05 23:42 ` Pierre-Louis Bossart
2018-04-06 8:49 ` Vinod Koul
2018-04-05 16:48 ` [PATCH v2 09/13] soundwire: Remove cdns_master_ops Vinod Koul
2018-04-05 16:48 ` [PATCH v2 10/13] soundwire: cdns: Add port routines Vinod Koul
2018-04-06 0:19 ` Pierre-Louis Bossart
2018-04-06 8:55 ` Vinod Koul
2018-04-06 15:29 ` Pierre-Louis Bossart
2018-04-05 16:48 ` [PATCH v2 11/13] soundwire: cdns: Add stream routines Vinod Koul
2018-04-06 0:29 ` Pierre-Louis Bossart
2018-04-06 8:57 ` Vinod Koul
2018-04-05 16:48 ` [PATCH v2 12/13] soundwire: intel: Add stream initialization Vinod Koul
2018-04-05 16:48 ` [PATCH v2 13/13] soundwire: intel: Add audio DAI ops Vinod Koul
2018-04-06 0:46 ` [PATCH v2 00/13] soundwire: Add stream support Pierre-Louis Bossart
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=06b35225-232a-7220-ffda-e42b5c6c9366@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=liam.r.girdwood@linux.intel.com \
--cc=patches.audio@intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=tiwai@suse.de \
--cc=vinod.koul@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox