All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, broonie@kernel.org,
	Bard Liao <yung-chuan.liao@linux.intel.com>,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [PATCH 02/28] ASoC: Intel: sof_sdw: add dai info
Date: Fri,  2 Jun 2023 15:21:59 -0500	[thread overview]
Message-ID: <20230602202225.249209-3-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20230602202225.249209-1-pierre-louis.bossart@linux.intel.com>

From: Bard Liao <yung-chuan.liao@linux.intel.com>

The existing code create a dailink for a codec. However, we may need
multi dailinks for a codec. This commit adds a new struct in
sof_sdw_codec_info{} to store the dai info of a codec.
The initial assumption if that we will create at most 3 dailink types
for a codec, since this is the max known with upcoming SDCA devices. We
may need to increase this number as new SDCA 'functions' become available.

One strong assumption is that all dailinks exposed are independent, as per
SDCA directions.

This commit just moves some items into the new sof_sdw_dai_info struct.
There is no function changed. Multi dais supported will be added in the
follow up commits.

Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/boards/sof_sdw.c        | 225 +++++++++++++++++-------
 sound/soc/intel/boards/sof_sdw_common.h |  31 +++-
 2 files changed, 183 insertions(+), 73 deletions(-)

diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index 2dadde7a7ab9..cf12f1ae67c1 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -563,134 +563,231 @@ static const struct snd_soc_ops sdw_ops = {
 static struct sof_sdw_codec_info codec_info_list[] = {
 	{
 		.part_id = 0x700,
-		.direction = {true, true},
-		.dai_name = "rt700-aif1",
-		.init = sof_sdw_rt700_init,
+		.dais = {
+			{
+				.direction = {true, true},
+				.dai_name = "rt700-aif1",
+				.dai_type = SOF_SDW_DAI_TYPE_JACK,
+				.init = sof_sdw_rt700_init,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_JACK,
 	},
 	{
 		.part_id = 0x711,
 		.version_id = 3,
-		.direction = {true, true},
-		.dai_name = "rt711-sdca-aif1",
-		.init = sof_sdw_rt711_sdca_init,
-		.exit = sof_sdw_rt711_sdca_exit,
+		.dais = {
+			{
+				.direction = {true, true},
+				.dai_name = "rt711-sdca-aif1",
+				.dai_type = SOF_SDW_DAI_TYPE_JACK,
+				.init = sof_sdw_rt711_sdca_init,
+				.exit = sof_sdw_rt711_sdca_exit,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_JACK,
 	},
 	{
 		.part_id = 0x711,
 		.version_id = 2,
-		.direction = {true, true},
-		.dai_name = "rt711-aif1",
-		.init = sof_sdw_rt711_init,
-		.exit = sof_sdw_rt711_exit,
+		.dais = {
+			{
+				.direction = {true, true},
+				.dai_name = "rt711-aif1",
+				.dai_type = SOF_SDW_DAI_TYPE_JACK,
+				.init = sof_sdw_rt711_init,
+				.exit = sof_sdw_rt711_exit,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_JACK,
 	},
 	{
 		.part_id = 0x1308,
 		.acpi_id = "10EC1308",
-		.direction = {true, false},
-		.dai_name = "rt1308-aif",
+		.dais = {
+			{
+				.direction = {true, false},
+				.dai_name = "rt1308-aif",
+				.dai_type = SOF_SDW_DAI_TYPE_AMP,
+				.init = sof_sdw_rt_amp_init,
+				.exit = sof_sdw_rt_amp_exit,
+			},
+		},
+		.dai_num = 1,
 		.ops = &sof_sdw_rt1308_i2s_ops,
-		.init = sof_sdw_rt_amp_init,
-		.exit = sof_sdw_rt_amp_exit,
 		.codec_type = SOF_SDW_CODEC_TYPE_AMP,
 	},
 	{
 		.part_id = 0x1316,
-		.direction = {true, true},
-		.dai_name = "rt1316-aif",
-		.init = sof_sdw_rt_amp_init,
-		.exit = sof_sdw_rt_amp_exit,
+		.dais = {
+			{
+				.direction = {true, true},
+				.dai_name = "rt1316-aif",
+				.dai_type = SOF_SDW_DAI_TYPE_AMP,
+				.init = sof_sdw_rt_amp_init,
+				.exit = sof_sdw_rt_amp_exit,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_AMP,
 	},
 	{
 		.part_id = 0x1318,
-		.direction = {true, true},
-		.dai_name = "rt1318-aif",
-		.init = sof_sdw_rt_amp_init,
-		.exit = sof_sdw_rt_amp_exit,
+		.dais = {
+			{
+				.direction = {true, true},
+				.dai_name = "rt1318-aif",
+				.dai_type = SOF_SDW_DAI_TYPE_AMP,
+				.init = sof_sdw_rt_amp_init,
+				.exit = sof_sdw_rt_amp_exit,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_AMP,
 	},
 	{
 		.part_id = 0x714,
 		.version_id = 3,
-		.direction = {false, true},
 		.ignore_pch_dmic = true,
-		.dai_name = "rt715-aif2",
-		.init = sof_sdw_rt715_sdca_init,
+		.dais = {
+			{
+				.direction = {false, true},
+				.dai_name = "rt715-aif2",
+				.dai_type = SOF_SDW_DAI_TYPE_MIC,
+				.init = sof_sdw_rt715_sdca_init,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_MIC,
 	},
 	{
 		.part_id = 0x715,
 		.version_id = 3,
-		.direction = {false, true},
 		.ignore_pch_dmic = true,
-		.dai_name = "rt715-aif2",
-		.init = sof_sdw_rt715_sdca_init,
+		.dais = {
+			{
+				.direction = {false, true},
+				.dai_name = "rt715-aif2",
+				.dai_type = SOF_SDW_DAI_TYPE_MIC,
+				.init = sof_sdw_rt715_sdca_init,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_MIC,
 	},
 	{
 		.part_id = 0x714,
 		.version_id = 2,
-		.direction = {false, true},
 		.ignore_pch_dmic = true,
-		.dai_name = "rt715-aif2",
-		.init = sof_sdw_rt715_init,
+		.dais = {
+			{
+				.direction = {false, true},
+				.dai_name = "rt715-aif2",
+				.dai_type = SOF_SDW_DAI_TYPE_MIC,
+				.init = sof_sdw_rt715_init,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_MIC,
 	},
 	{
 		.part_id = 0x715,
 		.version_id = 2,
-		.direction = {false, true},
 		.ignore_pch_dmic = true,
-		.dai_name = "rt715-aif2",
-		.init = sof_sdw_rt715_init,
+		.dais = {
+			{
+				.direction = {false, true},
+				.dai_name = "rt715-aif2",
+				.dai_type = SOF_SDW_DAI_TYPE_MIC,
+				.init = sof_sdw_rt715_init,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_MIC,
 	},
 	{
 		.part_id = 0x8373,
-		.direction = {true, true},
-		.dai_name = "max98373-aif1",
-		.init = sof_sdw_mx8373_init,
+		.dais = {
+			{
+				.direction = {true, true},
+				.dai_name = "max98373-aif1",
+				.dai_type = SOF_SDW_DAI_TYPE_AMP,
+				.init = sof_sdw_mx8373_init,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_AMP,
 	},
 	{
 		.part_id = 0x5682,
-		.direction = {true, true},
-		.dai_name = "rt5682-sdw",
-		.init = sof_sdw_rt5682_init,
+		.dais = {
+			{
+				.direction = {true, true},
+				.dai_name = "rt5682-sdw",
+				.dai_type = SOF_SDW_DAI_TYPE_JACK,
+				.init = sof_sdw_rt5682_init,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_JACK,
 	},
 	{
 		.part_id = 0xaaaa, /* generic codec mockup */
 		.version_id = 0,
-		.direction = {true, true},
-		.dai_name = "sdw-mockup-aif1",
-		.init = NULL,
+		.dais = {
+			{
+				.direction = {true, true},
+				.dai_name = "sdw-mockup-aif1",
+				.dai_type = SOF_SDW_DAI_TYPE_JACK,
+				.init = NULL,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_JACK,
 	},
 	{
 		.part_id = 0xaa55, /* headset codec mockup */
 		.version_id = 0,
-		.direction = {true, true},
-		.dai_name = "sdw-mockup-aif1",
-		.init = NULL,
+		.dais = {
+			{
+				.direction = {true, true},
+				.dai_name = "sdw-mockup-aif1",
+				.dai_type = SOF_SDW_DAI_TYPE_JACK,
+				.init = NULL,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_JACK,
 	},
 	{
 		.part_id = 0x55aa, /* amplifier mockup */
 		.version_id = 0,
-		.direction = {true, false},
-		.dai_name = "sdw-mockup-aif1",
-		.init = NULL,
+		.dais = {
+			{
+				.direction = {true, false},
+				.dai_name = "sdw-mockup-aif1",
+				.dai_type = SOF_SDW_DAI_TYPE_AMP,
+				.init = NULL,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_AMP,
 	},
 	{
 		.part_id = 0x5555,
 		.version_id = 0,
-		.direction = {false, true},
-		.dai_name = "sdw-mockup-aif1",
+		.dais = {
+			{
+				.dai_name = "sdw-mockup-aif1",
+				.direction = {false, true},
+				.dai_type = SOF_SDW_DAI_TYPE_MIC,
+				.init = NULL,
+			},
+		},
+		.dai_num = 1,
 		.codec_type = SOF_SDW_CODEC_TYPE_MIC,
 	},
 };
@@ -780,7 +877,7 @@ static int get_sdw_dailink_info(struct device *dev, const struct snd_soc_acpi_li
 
 			/* count DAI number for playback and capture */
 			for_each_pcm_streams(stream) {
-				if (!codec_info_list[codec_index].direction[stream])
+				if (!codec_info_list[codec_index].dais[0].direction[stream])
 					continue;
 
 				(*sdw_cpu_dai_num)++;
@@ -920,7 +1017,7 @@ static int create_codec_dai_name(struct device *dev,
 		_codec_index = codec_index;
 
 		codec[comp_index].dai_name =
-			codec_info_list[codec_index].dai_name;
+			codec_info_list[codec_index].dais[0].dai_name;
 
 		codec_conf[*codec_conf_index].dlc = codec[comp_index];
 		codec_conf[*codec_conf_index].name_prefix = link->adr_d[i].name_prefix;
@@ -957,8 +1054,8 @@ static int set_codec_init_func(struct snd_soc_card *card,
 			/* The group_id is > 0 iff the codec is aggregated */
 			if (link->adr_d[i].endpoints->group_id != group_id)
 				continue;
-			if (codec_info_list[codec_index].init)
-				codec_info_list[codec_index].init(card,
+			if (codec_info_list[codec_index].dais[0].init)
+				codec_info_list[codec_index].dais[0].init(card,
 						link,
 						dai_links,
 						&codec_info_list[codec_index],
@@ -1154,7 +1251,7 @@ static int create_sdw_dailink(struct snd_soc_card *card,
 			"SDW%d-Capture-%s",
 		};
 
-		if (!codec_info_list[codec_index].direction[stream])
+		if (!codec_info_list[codec_index].dais[0].direction[stream])
 			continue;
 
 		/* create stream name according to first link id */
@@ -1458,18 +1555,18 @@ static int sof_card_dai_links_create(struct device *dev,
 			return -ENOMEM;
 
 		ssp_components->name = codec_name;
-		ssp_components->dai_name = info->dai_name;
+		ssp_components->dai_name = info->dais[0].dai_name;
 		cpus[cpu_id].dai_name = cpu_name;
 
-		playback = info->direction[SNDRV_PCM_STREAM_PLAYBACK];
-		capture = info->direction[SNDRV_PCM_STREAM_CAPTURE];
+		playback = info->dais[0].direction[SNDRV_PCM_STREAM_PLAYBACK];
+		capture = info->dais[0].direction[SNDRV_PCM_STREAM_CAPTURE];
 		init_dai_link(dev, links + link_index, be_id, name,
 			      playback, capture,
 			      cpus + cpu_id, 1,
 			      ssp_components, 1,
 			      NULL, info->ops);
 
-		ret = info->init(card, NULL, links + link_index, info, 0);
+		ret = info->dais[0].init(card, NULL, links + link_index, info, 0);
 		if (ret < 0)
 			return ret;
 
@@ -1606,7 +1703,7 @@ static void mc_dailink_exit_loop(struct snd_soc_card *card)
 	int i, j;
 
 	for (i = 0; i < ARRAY_SIZE(codec_info_list); i++) {
-		if (!codec_info_list[i].exit)
+		if (!codec_info_list[i].dais[0].exit)
 			continue;
 		/*
 		 * We don't need to call .exit function if there is no matched
@@ -1614,8 +1711,8 @@ static void mc_dailink_exit_loop(struct snd_soc_card *card)
 		 */
 		for_each_card_prelinks(card, j, link) {
 			if (!strcmp(link->codecs[0].dai_name,
-				    codec_info_list[i].dai_name)) {
-				ret = codec_info_list[i].exit(card, link);
+				    codec_info_list[i].dais[0].dai_name)) {
+				ret = codec_info_list[i].dais[0].exit(card, link);
 				if (ret)
 					dev_warn(card->dev,
 						 "codec exit failed %d\n",
diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h
index 081ab7eac5b6..e6d539bd63ec 100644
--- a/sound/soc/intel/boards/sof_sdw_common.h
+++ b/sound/soc/intel/boards/sof_sdw_common.h
@@ -56,24 +56,37 @@ enum {
 #define SOF_SDW_CODEC_TYPE_AMP		1
 #define SOF_SDW_CODEC_TYPE_MIC		2
 
+#define SOF_SDW_DAI_TYPE_JACK		0
+#define SOF_SDW_DAI_TYPE_AMP		1
+#define SOF_SDW_DAI_TYPE_MIC		2
+
+#define SOF_SDW_MAX_DAI_NUM		3
+
+struct sof_sdw_codec_info;
+
+struct sof_sdw_dai_info {
+	const bool direction[2]; /* playback & capture support */
+	const char *dai_name;
+	const int dai_type;
+	int  (*init)(struct snd_soc_card *card,
+		     const struct snd_soc_acpi_link_adr *link,
+		     struct snd_soc_dai_link *dai_links,
+		     struct sof_sdw_codec_info *info,
+		     bool playback);
+	int (*exit)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
+};
+
 struct sof_sdw_codec_info {
 	const int part_id;
 	const int version_id;
 	const int codec_type;
 	int amp_num;
 	const u8 acpi_id[ACPI_ID_LEN];
-	const bool direction[2]; // playback & capture support
 	const bool ignore_pch_dmic;
-	const char *dai_name;
 	const struct snd_soc_ops *ops;
+	struct sof_sdw_dai_info dais[SOF_SDW_MAX_DAI_NUM];
+	const int dai_num;
 
-	int  (*init)(struct snd_soc_card *card,
-		     const struct snd_soc_acpi_link_adr *link,
-		     struct snd_soc_dai_link *dai_links,
-		     struct sof_sdw_codec_info *info,
-		     bool playback);
-
-	int (*exit)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
 	int (*codec_card_late_probe)(struct snd_soc_card *card);
 };
 
-- 
2.37.2


  parent reply	other threads:[~2023-06-02 20:25 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 20:21 [PATCH 00/28] ASoC: Intel: machine driver updates for 6.5 Pierre-Louis Bossart
2023-06-02 20:21 ` [PATCH 01/28] ASoC: Intel: sof_sdw: add missing exit callback Pierre-Louis Bossart
2023-06-02 20:21 ` Pierre-Louis Bossart [this message]
2023-06-02 20:22 ` [PATCH 03/28] ASoC: Intel: sof_sdw: use predefine dailink id Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 04/28] ASoC: Intel: sof_sdw: add codec_info pointer Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 05/28] ASoC: Intel: sdw_sof: append dai_type and remove codec_type Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 06/28] ASoC: Intel: sof_sdw: add multi dailink support for a codec Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 07/28] ASoC: Intel: sof_sdw_rt_sdca_jack_common: test SOF_JACK_JDSRC in _exit Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 08/28] ASoC: Intel: sof_sdw: rename SOF_RT711_JDSRC to SOF_JACK_JDSRC Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 09/28] ASoC: Intel: sof_sdw: make rt711_sdca be generic Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 10/28] ASoC: Intel: sof_sdw: add rt712 support Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 11/28] ASoC: Intel: soc-acpi-intel-tgl-match: add rt712 ID Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 12/28] ASoC: Intel: soc-acpi-intel-mtl-match: " Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 13/28] ASoC: Intel: sof_sdw: add rt713 support Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 14/28] ASoC: Intel: sof_sdw: increase sdw pin index for each sdw link Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 15/28] ASoC: Intel: soc-acpi: add table for RPL Dell SKU 0BDA Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 16/28] ASoC: Intel: sof_sdw: add quick for " Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 17/28] ASoC: Intel: soc-acpi: add tables for Dell SKU 0B34 Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 18/28] ASoC: Intel: sof-sdw: add " Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 19/28] ASoC: Intel: ADL: Enable HDMI-In capture feature support for non-I2S codec boards Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 20/28] ASoC: Intel: ADL: Moving amp only boards into end of the table Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 21/28] ASoC: Intel: Sof_ssp_amp: Correcting author name Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 22/28] ASoC: Intel: Add rpl_rt1019_rt5682 driver Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 23/28] ASoC: Intel: sof_sdw: Add helper function for cs42l42 codec Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 24/28] ASoC: Intel: sof_sdw: Rename sof_sdw_max98373.c file to sof_sdw_maxim.c Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 25/28] ASoC: Intel: sof_sdw: Modify maxim helper functions and structure names Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 26/28] ASoC: Intel: sof_sdw: Add support for MAX98363 codec Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 27/28] ASoC: Intel: sof_sdw: Add support for Rex soundwire Pierre-Louis Bossart
2023-06-02 20:22 ` [PATCH 28/28] ASoC: Intel: soc-acpi: add Rex CS42l42 and MAX98363 SoundWire entries Pierre-Louis Bossart
2023-06-06 15:42 ` [PATCH 00/28] ASoC: Intel: machine driver updates for 6.5 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=20230602202225.249209-3-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ranjani.sridharan@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.