From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, "Bard Liao" <yung-chuan.liao@linux.intel.com>,
"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
broonie@kernel.org,
"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
Subject: [PATCH 10/18] ASoC: SOF: change comp_dai to a pointer in struct snd_sof_dai
Date: Mon, 7 Mar 2022 10:11:03 -0800 [thread overview]
Message-ID: <20220307181111.49392-11-ranjani.sridharan@linux.intel.com> (raw)
In-Reply-To: <20220307181111.49392-1-ranjani.sridharan@linux.intel.com>
This will avoid having to add the extended data for DAI components during
sof_widget_setup() as an extra step.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
sound/soc/sof/pcm.c | 6 +++---
sound/soc/sof/sof-audio.c | 18 +++---------------
sound/soc/sof/sof-audio.h | 2 +-
sound/soc/sof/topology.c | 17 +++++------------
4 files changed, 12 insertions(+), 31 deletions(-)
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
index a312ed855f1a..1d04f75e6d32 100644
--- a/sound/soc/sof/pcm.c
+++ b/sound/soc/sof/pcm.c
@@ -717,7 +717,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
/* read format from topology */
snd_mask_none(fmt);
- switch (dai->comp_dai.config.frame_fmt) {
+ switch (dai->comp_dai->config.frame_fmt) {
case SOF_IPC_FRAME_S16_LE:
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
break;
@@ -752,10 +752,10 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
break;
case SOF_DAI_INTEL_DMIC:
/* DMIC only supports 16 or 32 bit formats */
- if (dai->comp_dai.config.frame_fmt == SOF_IPC_FRAME_S24_4LE) {
+ if (dai->comp_dai->config.frame_fmt == SOF_IPC_FRAME_S24_4LE) {
dev_err(component->dev,
"error: invalid fmt %d for DAI type %d\n",
- dai->comp_dai.config.frame_fmt,
+ dai->comp_dai->config.frame_fmt,
dai->dai_config->type);
}
break;
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index e39f18e824b4..b49d8e348077 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -170,7 +170,6 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
struct sof_ipc_cmd_hdr *hdr;
struct sof_ipc_comp *comp;
struct snd_sof_dai *dai;
- size_t ipc_size;
int ret;
/* skip if there is no private data */
@@ -192,23 +191,12 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
switch (swidget->id) {
case snd_soc_dapm_dai_in:
case snd_soc_dapm_dai_out:
- ipc_size = sizeof(struct sof_ipc_comp_dai) + sizeof(struct sof_ipc_comp_ext);
- comp = kzalloc(ipc_size, GFP_KERNEL);
- if (!comp) {
- ret = -ENOMEM;
- goto core_put;
- }
-
dai = swidget->private;
+ comp = &dai->comp_dai->comp;
dai->configured = false;
- memcpy(comp, &dai->comp_dai, sizeof(struct sof_ipc_comp_dai));
- /* append extended data to the end of the component */
- memcpy((u8 *)comp + sizeof(struct sof_ipc_comp_dai), &swidget->comp_ext,
- sizeof(swidget->comp_ext));
-
- ret = sof_ipc_tx_message(sdev->ipc, comp->hdr.cmd, comp, ipc_size, &r, sizeof(r));
- kfree(comp);
+ ret = sof_ipc_tx_message(sdev->ipc, comp->hdr.cmd, dai->comp_dai, comp->hdr.size,
+ &r, sizeof(r));
if (ret < 0) {
dev_err(sdev->dev, "error: failed to load widget %s\n",
swidget->widget->name);
diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h
index feda5793b589..a8eeffc12b24 100644
--- a/sound/soc/sof/sof-audio.h
+++ b/sound/soc/sof/sof-audio.h
@@ -134,7 +134,7 @@ struct snd_sof_dai {
struct snd_soc_component *scomp;
const char *name;
- struct sof_ipc_comp_dai comp_dai;
+ struct sof_ipc_comp_dai *comp_dai;
int number_configs;
int current_config;
bool configured; /* DAI configured during BE hw_params */
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index dd1cc6e26686..41927e99ace2 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -1478,7 +1478,7 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
if (ret != 0) {
dev_err(scomp->dev, "error: parse dai tokens failed %d\n",
le32_to_cpu(private->size));
- goto finish;
+ return ret;
}
ret = sof_parse_tokens(scomp, &comp_dai->config, comp_tokens,
@@ -1487,7 +1487,7 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
if (ret != 0) {
dev_err(scomp->dev, "error: parse dai.cfg tokens failed %d\n",
private->size);
- goto finish;
+ return ret;
}
dev_dbg(scomp->dev, "dai %s: type %d index %d\n",
@@ -1496,17 +1496,9 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
if (dai) {
dai->scomp = scomp;
-
- /*
- * copy only the sof_ipc_comp_dai to avoid collapsing
- * the snd_sof_dai, the extended data is kept in the
- * snd_sof_widget.
- */
- memcpy(&dai->comp_dai, comp_dai, sizeof(*comp_dai));
+ dai->comp_dai = comp_dai;
}
-finish:
- kfree(comp_dai);
return ret;
}
@@ -2429,6 +2421,7 @@ static int sof_widget_unload(struct snd_soc_component *scomp,
dai = swidget->private;
if (dai) {
+ kfree(dai->comp_dai);
/* free dai config */
kfree(dai->dai_config);
list_del(&dai->list);
@@ -2668,7 +2661,7 @@ static int sof_set_dai_config_multi(struct snd_sof_dev *sdev, u32 size,
* dai_index.
*/
for (i = 0; i < num_conf; i++)
- config[i].dai_index = dai->comp_dai.dai_index;
+ config[i].dai_index = dai->comp_dai->dai_index;
dev_dbg(sdev->dev, "set DAI config for %s index %d\n",
dai->name, config[curr_conf].dai_index);
--
2.25.1
next prev parent reply other threads:[~2022-03-07 18:15 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 18:10 [PATCH 00/18] Clean ups and preparation for IPC abstraction in the SOF driver Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 01/18] ASoC: SOF: remove snd_sof_pipeline_find() Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 02/18] ASoC: SOF: simplify snd_sof_device_remove() Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 03/18] ASoC: SOF: set swidget's core for scheduler widget Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 04/18] ASoC: SOF: sof-audio: removed unused function Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 05/18] ASoC: SOF: topology: remove redundant code Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 06/18] ASoC: SOF: topology: remove redundant code in sof_link_afe_load() Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 07/18] ASoC: SOF: topology: Drop the size parameter from struct sof_topology_token Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 08/18] ASoC: SOF: topology: Modify the get_token op for string tokens Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 09/18] ASoC: SOF: topology: expose some get_token ops Ranjani Sridharan
2022-03-07 18:11 ` Ranjani Sridharan [this message]
2022-03-07 18:11 ` [PATCH 11/18] ASoC: SOF: make struct snd_sof_widget IPC agnostic Ranjani Sridharan
2022-03-07 18:55 ` Amadeusz Sławiński
2022-03-07 19:51 ` Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 12/18] ASoC: SOF: topology: make sof_route_load() " Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 13/18] ASoC: SOF: Add a tuples array to struct snd_sof_widget Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 14/18] ASoC: SOF: topology: Modify signature for token parsing functions Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 15/18] ASoC: SOF: topology: Rename arguments in sof_parse_token_sets() Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 16/18] ASoC: SOF: topology: Rename arguments in sof_parse_tokens() Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 17/18] ASoC: SOF: make struct snd_sof_dai IPC agnostic Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 18/18] ASoC: SOF: move definition of snd_sof_ipc to header file Ranjani Sridharan
2022-03-08 17:20 ` [PATCH 00/18] Clean ups and preparation for IPC abstraction in the SOF driver 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=20220307181111.49392-11-ranjani.sridharan@linux.intel.com \
--to=ranjani.sridharan@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=tiwai@suse.de \
--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