From: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
To: <broonie@kernel.org>
Cc: <vijendar.mukunda@amd.com>, <Basavaraj.Hiregoudar@amd.com>,
<Sunil-kumar.Dommati@amd.com>, <alsa-devel@alsa-project.org>,
<pierre-louis.bossart@linux.intel.com>,
<venkataprasad.potturu@amd.com>,
<yung-chuan.liao@linux.intel.com>, <linux-sound@vger.kernel.org>,
"Vijendar Mukunda" <Vijendar.Mukunda@amd.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
"Cezary Rojewski" <cezary.rojewski@intel.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Charles Keepax <ckeepax@opensource.cirrus.com>,
open list <linux-kernel@vger.kernel.org>
Subject: [PATCH RESEND 26/31] ASoC: intel/sdw_utils: refactor init_dai_link() and init_simple_dai_link()
Date: Thu, 1 Aug 2024 16:48:12 +0530 [thread overview]
Message-ID: <20240801111821.18076-6-Vijendar.Mukunda@amd.com> (raw)
In-Reply-To: <20240801111821.18076-1-Vijendar.Mukunda@amd.com>
To make it generic, refactor existing implementation for
init_dai_link() and init_simple_dai_link() as mentioned below.
- Move init_dai_link() and init_simple_dai_link() to common place holder
- Rename the functions with "asoc_sdw" as prefix.
- Pass the platform specific 'platform_component' structure and its size as
arguments for init_simple_dai_link() function and allocate one more
extra dlc for platform component.
- Pass the 'platform_component' and 'num_platforms' as arguments for
init_dai_link().
Link: https://github.com/thesofproject/linux/pull/5068
Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
include/sound/soc_sdw_utils.h | 16 +++++
sound/soc/intel/boards/sof_sdw.c | 105 +++++++++-------------------
sound/soc/sdw_utils/soc_sdw_utils.c | 54 ++++++++++++++
3 files changed, 104 insertions(+), 71 deletions(-)
diff --git a/include/sound/soc_sdw_utils.h b/include/sound/soc_sdw_utils.h
index 14e21a992f56..e366b7968c2d 100644
--- a/include/sound/soc_sdw_utils.h
+++ b/include/sound/soc_sdw_utils.h
@@ -124,6 +124,22 @@ void asoc_sdw_mc_dailink_exit_loop(struct snd_soc_card *card);
int asoc_sdw_card_late_probe(struct snd_soc_card *card);
+void asoc_sdw_init_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links,
+ int *be_id, char *name, int playback, int capture,
+ struct snd_soc_dai_link_component *cpus, int cpus_num,
+ struct snd_soc_dai_link_component *platform_component,
+ int num_platforms, struct snd_soc_dai_link_component *codecs,
+ int codecs_num, int (*init)(struct snd_soc_pcm_runtime *rtd),
+ const struct snd_soc_ops *ops);
+
+int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links,
+ int *be_id, char *name, int playback, int capture,
+ const char *cpu_dai_name, const char *platform_comp_name,
+ int num_platforms, const char *codec_name,
+ const char *codec_dai_name,
+ int (*init)(struct snd_soc_pcm_runtime *rtd),
+ const struct snd_soc_ops *ops);
+
int asoc_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd);
/* DMIC support */
diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index 65b15f594aed..d258728d64cf 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -557,54 +557,6 @@ static const struct snd_soc_ops sdw_ops = {
.shutdown = asoc_sdw_shutdown,
};
-static void init_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links,
- int *be_id, char *name, int playback, int capture,
- struct snd_soc_dai_link_component *cpus, int cpus_num,
- struct snd_soc_dai_link_component *codecs, int codecs_num,
- int (*init)(struct snd_soc_pcm_runtime *rtd),
- const struct snd_soc_ops *ops)
-{
- dev_dbg(dev, "create dai link %s, id %d\n", name, *be_id);
- dai_links->id = (*be_id)++;
- dai_links->name = name;
- dai_links->platforms = platform_component;
- dai_links->num_platforms = ARRAY_SIZE(platform_component);
- dai_links->no_pcm = 1;
- dai_links->cpus = cpus;
- dai_links->num_cpus = cpus_num;
- dai_links->codecs = codecs;
- dai_links->num_codecs = codecs_num;
- dai_links->dpcm_playback = playback;
- dai_links->dpcm_capture = capture;
- dai_links->init = init;
- dai_links->ops = ops;
-}
-
-static int init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links,
- int *be_id, char *name, int playback, int capture,
- const char *cpu_dai_name,
- const char *codec_name, const char *codec_dai_name,
- int (*init)(struct snd_soc_pcm_runtime *rtd),
- const struct snd_soc_ops *ops)
-{
- struct snd_soc_dai_link_component *dlc;
-
- /* Allocate two DLCs one for the CPU, one for the CODEC */
- dlc = devm_kcalloc(dev, 2, sizeof(*dlc), GFP_KERNEL);
- if (!dlc || !name || !cpu_dai_name || !codec_name || !codec_dai_name)
- return -ENOMEM;
-
- dlc[0].dai_name = cpu_dai_name;
-
- dlc[1].name = codec_name;
- dlc[1].dai_name = codec_dai_name;
-
- init_dai_link(dev, dai_links, be_id, name, playback, capture,
- &dlc[0], 1, &dlc[1], 1, init, ops);
-
- return 0;
-}
-
struct sof_sdw_endpoint {
struct list_head list;
@@ -897,9 +849,10 @@ static int create_sdw_dailink(struct snd_soc_card *card,
playback = (stream == SNDRV_PCM_STREAM_PLAYBACK);
capture = (stream == SNDRV_PCM_STREAM_CAPTURE);
- init_dai_link(dev, *dai_links, be_id, name, playback, capture,
- cpus, num_cpus, codecs, num_codecs,
- asoc_sdw_rtd_init, &sdw_ops);
+ asoc_sdw_init_dai_link(dev, *dai_links, be_id, name, playback, capture,
+ cpus, num_cpus, platform_component,
+ ARRAY_SIZE(platform_component), codecs, num_codecs,
+ asoc_sdw_rtd_init, &sdw_ops);
/*
* SoundWire DAILINKs use 'stream' functions and Bank Switch operations
@@ -969,10 +922,12 @@ static int create_ssp_dailinks(struct snd_soc_card *card,
int playback = ssp_info->dais[0].direction[SNDRV_PCM_STREAM_PLAYBACK];
int capture = ssp_info->dais[0].direction[SNDRV_PCM_STREAM_CAPTURE];
- ret = init_simple_dai_link(dev, *dai_links, be_id, name,
- playback, capture, cpu_dai_name,
- codec_name, ssp_info->dais[0].dai_name,
- NULL, ssp_info->ops);
+ ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
+ playback, capture, cpu_dai_name,
+ platform_component->name,
+ ARRAY_SIZE(platform_component), codec_name,
+ ssp_info->dais[0].dai_name, NULL,
+ ssp_info->ops);
if (ret)
return ret;
@@ -992,20 +947,24 @@ static int create_dmic_dailinks(struct snd_soc_card *card,
struct device *dev = card->dev;
int ret;
- ret = init_simple_dai_link(dev, *dai_links, be_id, "dmic01",
- 0, 1, // DMIC only supports capture
- "DMIC01 Pin", "dmic-codec", "dmic-hifi",
- asoc_sdw_dmic_init, NULL);
+ ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, "dmic01",
+ 0, 1, // DMIC only supports capture
+ "DMIC01 Pin", platform_component->name,
+ ARRAY_SIZE(platform_component),
+ "dmic-codec", "dmic-hifi",
+ asoc_sdw_dmic_init, NULL);
if (ret)
return ret;
(*dai_links)++;
- ret = init_simple_dai_link(dev, *dai_links, be_id, "dmic16k",
- 0, 1, // DMIC only supports capture
- "DMIC16k Pin", "dmic-codec", "dmic-hifi",
- /* don't call asoc_sdw_dmic_init() twice */
- NULL, NULL);
+ ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, "dmic16k",
+ 0, 1, // DMIC only supports capture
+ "DMIC16k Pin", platform_component->name,
+ ARRAY_SIZE(platform_component),
+ "dmic-codec", "dmic-hifi",
+ /* don't call asoc_sdw_dmic_init() twice */
+ NULL, NULL);
if (ret)
return ret;
@@ -1037,10 +996,12 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
codec_dai_name = "snd-soc-dummy-dai";
}
- ret = init_simple_dai_link(dev, *dai_links, be_id, name,
- 1, 0, // HDMI only supports playback
- cpu_dai_name, codec_name, codec_dai_name,
- i == 0 ? sof_sdw_hdmi_init : NULL, NULL);
+ ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
+ 1, 0, // HDMI only supports playback
+ cpu_dai_name, platform_component->name,
+ ARRAY_SIZE(platform_component),
+ codec_name, codec_dai_name,
+ i == 0 ? sof_sdw_hdmi_init : NULL, NULL);
if (ret)
return ret;
@@ -1060,9 +1021,11 @@ static int create_bt_dailinks(struct snd_soc_card *card,
char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", port);
int ret;
- ret = init_simple_dai_link(dev, *dai_links, be_id, name,
- 1, 1, cpu_dai_name, snd_soc_dummy_dlc.name,
- snd_soc_dummy_dlc.dai_name, NULL, NULL);
+ ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
+ 1, 1, cpu_dai_name, platform_component->name,
+ ARRAY_SIZE(platform_component),
+ snd_soc_dummy_dlc.name, snd_soc_dummy_dlc.dai_name,
+ NULL, NULL);
if (ret)
return ret;
diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c
index 613ecc3bed92..6183629d1754 100644
--- a/sound/soc/sdw_utils/soc_sdw_utils.c
+++ b/sound/soc/sdw_utils/soc_sdw_utils.c
@@ -932,5 +932,59 @@ int asoc_sdw_card_late_probe(struct snd_soc_card *card)
}
EXPORT_SYMBOL_NS(asoc_sdw_card_late_probe, SND_SOC_SDW_UTILS);
+void asoc_sdw_init_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links,
+ int *be_id, char *name, int playback, int capture,
+ struct snd_soc_dai_link_component *cpus, int cpus_num,
+ struct snd_soc_dai_link_component *platform_component,
+ int num_platforms, struct snd_soc_dai_link_component *codecs,
+ int codecs_num, int (*init)(struct snd_soc_pcm_runtime *rtd),
+ const struct snd_soc_ops *ops)
+{
+ dev_dbg(dev, "create dai link %s, id %d\n", name, *be_id);
+ dai_links->id = (*be_id)++;
+ dai_links->name = name;
+ dai_links->platforms = platform_component;
+ dai_links->num_platforms = num_platforms;
+ dai_links->no_pcm = 1;
+ dai_links->cpus = cpus;
+ dai_links->num_cpus = cpus_num;
+ dai_links->codecs = codecs;
+ dai_links->num_codecs = codecs_num;
+ dai_links->dpcm_playback = playback;
+ dai_links->dpcm_capture = capture;
+ dai_links->init = init;
+ dai_links->ops = ops;
+}
+EXPORT_SYMBOL_NS(asoc_sdw_init_dai_link, SND_SOC_SDW_UTILS);
+
+int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *dai_links,
+ int *be_id, char *name, int playback, int capture,
+ const char *cpu_dai_name, const char *platform_comp_name,
+ int num_platforms, const char *codec_name,
+ const char *codec_dai_name,
+ int (*init)(struct snd_soc_pcm_runtime *rtd),
+ const struct snd_soc_ops *ops)
+{
+ struct snd_soc_dai_link_component *dlc;
+
+ /* Allocate three DLCs one for the CPU, one for platform and one for the CODEC */
+ dlc = devm_kcalloc(dev, 3, sizeof(*dlc), GFP_KERNEL);
+ if (!dlc || !name || !cpu_dai_name || !platform_comp_name || !codec_name || !codec_dai_name)
+ return -ENOMEM;
+
+ dlc[0].dai_name = cpu_dai_name;
+ dlc[1].name = platform_comp_name;
+
+ dlc[2].name = codec_name;
+ dlc[2].dai_name = codec_dai_name;
+
+ asoc_sdw_init_dai_link(dev, dai_links, be_id, name, playback, capture,
+ &dlc[0], 1, &dlc[1], num_platforms,
+ &dlc[2], 1, init, ops);
+
+ return 0;
+}
+EXPORT_SYMBOL_NS(asoc_sdw_init_simple_dai_link, SND_SOC_SDW_UTILS);
+
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("SoundWire ASoC helpers");
--
2.34.1
next prev parent reply other threads:[~2024-08-01 11:20 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240801091446.10457-1-Vijendar.Mukunda@amd.com>
2024-08-01 9:14 ` [PATCH RESEND 01/31] ASoC: intel: rename codec_info and dai_info structures names Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 02/31] ASoC: intel: rename soundwire common header macros Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 03/31] ASoC: intel: rename soundwire machine driver soc ops Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 04/31] ASoC: intel: rename soundwire codec helper functions Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 05/31] ASoC: intel: rename maxim codec macros Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 06/31] ASoC: intel: rename ignore_pch_dmic variable name Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 07/31] ASoC: intel/sdw-utils: move soundwire machine driver soc ops Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 08/31] ASoC: intel: move soundwire machine driver common structures Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 09/31] ASoC: intel/sdw_utils: move soundwire machine driver helper functions Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 10/31] ASoC: intel/sdw_utils: move dmic codec helper function Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 11/31] ASoC: intel/sdw_utils: move rtk dmic helper functions Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 12/31] ASoC: intel/sdw_utils: move rt712 sdca " Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 13/31] ASoC: intel/sdw_utils: move rt722 " Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 14/31] ASoC: intel: split soundwire machine driver private data Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 15/31] ASoC: intel/sdw_utils: move rt5682 codec helper function Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 16/31] ASoC: intel/sdw_utils: move rtk jack common helper functions Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 17/31] ASoC: intel/sdw_utils: move rt700 and rt711 codec " Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 18/31] ASoC: intel/sdw_utils: move rtk amp " Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 19/31] ASoC: intel/sdw_utils: move cirrus soundwire " Vijendar Mukunda
2024-08-01 9:14 ` [PATCH RESEND 20/31] ASoC: intel/sdw_utils: move maxim " Vijendar Mukunda
2024-08-01 11:18 ` [PATCH RESEND 21/31] ASoC: intel/sdw_utils: move dai id common macros Vijendar Mukunda
2024-08-01 11:18 ` [PATCH RESEND 22/31] ASoC: intel/sdw_utils: move soundwire dai type macros Vijendar Mukunda
2024-08-01 11:18 ` [PATCH RESEND 23/31] ASoC: intel/sdw_utils: move soundwire codec_info_list structure Vijendar Mukunda
2024-08-01 11:18 ` [PATCH RESEND 24/31] ASoC: intel/sdw_utils: move machine driver dai link helper functions Vijendar Mukunda
2024-08-01 11:18 ` [PATCH RESEND 25/31] ASoC: sdw_utils: refactor sof_sdw_card_late_probe function Vijendar Mukunda
2024-08-01 11:18 ` Vijendar Mukunda [this message]
2024-08-01 11:18 ` [PATCH RESEND 27/31] ASoC: soc-acpi: add pci revision id field in mach params structure Vijendar Mukunda
2024-08-01 11:18 ` [PATCH RESEND 28/31] ASoC: amd: acp: add soundwire machines for acp6.3 based platform Vijendar Mukunda
2024-08-01 11:18 ` [PATCH RESEND 29/31] ASoC: SOF: amd: add alternate " Vijendar Mukunda
2024-08-01 11:18 ` [PATCH RESEND 30/31] ASoC: SOF: amd: update mach params subsystem_rev variable Vijendar Mukunda
2024-08-01 11:18 ` [PATCH RESEND 31/31] ASoC: amd/sdw_utils: add sof based soundwire generic machine driver Vijendar Mukunda
2024-08-02 8:37 ` Krzysztof Kozlowski
2024-08-02 8:45 ` Mukunda,Vijendar
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=20240801111821.18076-6-Vijendar.Mukunda@amd.com \
--to=vijendar.mukunda@amd.com \
--cc=Basavaraj.Hiregoudar@amd.com \
--cc=Sunil-kumar.Dommati@amd.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=ckeepax@opensource.cirrus.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=tiwai@suse.com \
--cc=venkataprasad.potturu@amd.com \
--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
all inboxes | Powered by JetHome®