From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org,
vkoul@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com,
srinivas.kandagatla@linaro.org, slawomir.blauciak@intel.com,
Bard liao <yung-chuan.liao@linux.intel.com>,
Rander Wang <rander.wang@linux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Sanyog Kale <sanyog.r.kale@intel.com>
Subject: [RFC PATCH 06/11] soundwire: cadence_master: improve PDI allocation
Date: Wed, 21 Aug 2019 15:05:16 -0500 [thread overview]
Message-ID: <20190821200521.17283-7-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20190821200521.17283-1-pierre-louis.bossart@linux.intel.com>
From: Bard Liao <yung-chuan.liao@linux.intel.com>
PDI number should match dai->id, there is no need to track if a PDI is
allocated or not.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
drivers/soundwire/cadence_master.c | 27 ++++++++++++++-------------
drivers/soundwire/cadence_master.h | 4 +---
drivers/soundwire/intel.c | 5 ++---
3 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
index 8510d4ee8044..1e8cc14fc2ec 100644
--- a/drivers/soundwire/cadence_master.c
+++ b/drivers/soundwire/cadence_master.c
@@ -875,7 +875,6 @@ static int cdns_allocate_pdi(struct sdw_cdns *cdns,
for (i = 0; i < num; i++) {
pdi[i].num = i + pdi_offset;
- pdi[i].assigned = false;
}
*stream = pdi;
@@ -1229,21 +1228,20 @@ EXPORT_SYMBOL(cdns_set_sdw_stream);
* @num: Number of PDIs
* @pdi: PDI instances
*
- * Find and return a free PDI for a given PDI array
+ * Find a PDI for a given PDI array. The PDI num and dai_id are
+ * expected to match, return NULL otherwise.
*/
static struct sdw_cdns_pdi *cdns_find_pdi(struct sdw_cdns *cdns,
unsigned int offset,
unsigned int num,
- struct sdw_cdns_pdi *pdi)
+ struct sdw_cdns_pdi *pdi,
+ int dai_id)
{
int i;
- for (i = offset; i < num; i++) {
- if (pdi[i].assigned)
- continue;
- pdi[i].assigned = true;
- return &pdi[i];
- }
+ for (i = offset; i < offset + num; i++)
+ if (pdi[i].num == dai_id)
+ return &pdi[i];
return NULL;
}
@@ -1283,18 +1281,21 @@ EXPORT_SYMBOL(sdw_cdns_config_stream);
*/
struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
struct sdw_cdns_streams *stream,
- u32 ch, u32 dir)
+ u32 ch, u32 dir, int dai_id)
{
struct sdw_cdns_pdi *pdi = NULL;
if (dir == SDW_DATA_DIR_RX)
- pdi = cdns_find_pdi(cdns, 0, stream->num_in, stream->in);
+ pdi = cdns_find_pdi(cdns, 0, stream->num_in, stream->in,
+ dai_id);
else
- pdi = cdns_find_pdi(cdns, 0, stream->num_out, stream->out);
+ pdi = cdns_find_pdi(cdns, 0, stream->num_out, stream->out,
+ dai_id);
/* check if we found a PDI, else find in bi-directional */
if (!pdi)
- pdi = cdns_find_pdi(cdns, 2, stream->num_bd, stream->bd);
+ pdi = cdns_find_pdi(cdns, 2, stream->num_bd, stream->bd,
+ dai_id);
if (pdi) {
pdi->l_ch_num = 0;
diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence_master.h
index 43493fc3d2ee..001457cbe5ad 100644
--- a/drivers/soundwire/cadence_master.h
+++ b/drivers/soundwire/cadence_master.h
@@ -8,7 +8,6 @@
/**
* struct sdw_cdns_pdi: PDI (Physical Data Interface) instance
*
- * @assigned: pdi assigned
* @num: pdi number
* @intel_alh_id: link identifier
* @l_ch_num: low channel for PDI
@@ -18,7 +17,6 @@
* @type: stream type, PDM or PCM
*/
struct sdw_cdns_pdi {
- bool assigned;
int num;
int intel_alh_id;
int l_ch_num;
@@ -155,7 +153,7 @@ int sdw_cdns_get_stream(struct sdw_cdns *cdns,
u32 ch, u32 dir);
struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
struct sdw_cdns_streams *stream,
- u32 ch, u32 dir);
+ u32 ch, u32 dir, int dai_id);
void sdw_cdns_config_stream(struct sdw_cdns *cdns,
u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c
index e21c994d46b9..0001f433e848 100644
--- a/drivers/soundwire/intel.c
+++ b/drivers/soundwire/intel.c
@@ -700,11 +700,10 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
if (dma->stream_type == SDW_STREAM_PDM)
pcm = false;
- /* FIXME: We would need to get PDI info from topology */
if (pcm)
- pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir);
+ pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir, dai->id);
else
- pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pdm, ch, dir);
+ pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pdm, ch, dir, dai->id);
if (!pdi) {
ret = -EINVAL;
--
2.20.1
next prev parent reply other threads:[~2019-08-21 20:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-21 20:05 [RFC PATCH 00/11] soundwire: intel: simplify DAI/PDI handling Pierre-Louis Bossart
2019-08-21 20:05 ` [RFC PATCH 01/11] soundwire: intel: fix intel_register_dai PDI offsets and numbers Pierre-Louis Bossart
2019-08-21 20:05 ` [RFC PATCH 02/11] soundwire: remove DAI_ID_RANGE definitions Pierre-Louis Bossart
2019-08-21 20:05 ` [RFC PATCH 03/11] soundwire: intel: remove playback/capture stream_name Pierre-Louis Bossart
2019-08-21 20:05 ` [RFC PATCH 04/11] soundwire: cadence/intel: simplify PDI/port mapping Pierre-Louis Bossart
2019-08-21 20:05 ` [RFC PATCH 05/11] soundwire: intel: don't filter out PDI0/1 Pierre-Louis Bossart
2019-08-21 20:05 ` Pierre-Louis Bossart [this message]
2019-08-21 20:05 ` [RFC PATCH 07/11] soundwire: intel: improve .config_stream callback, add .free_stream Pierre-Louis Bossart
2019-08-21 20:05 ` [RFC PATCH 08/11] soundwire: intel: add prepare support in sdw dai driver Pierre-Louis Bossart
2019-08-21 20:05 ` [RFC PATCH 09/11] soundwire: intel: add trigger " Pierre-Louis Bossart
2019-08-21 20:05 ` [RFC PATCH 10/11] soundwire: intel: do sdw stream setup in setup function Pierre-Louis Bossart
2019-08-21 20:05 ` [RFC PATCH 11/11] soundwire: intel: free all resources on hw_free() 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=20190821200521.17283-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=gregkh@linuxfoundation.org \
--cc=jank@cadence.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rander.wang@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=slawomir.blauciak@intel.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.de \
--cc=vkoul@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).