2021-06-06 01:07:35

by Brent Lu

[permalink] [raw]
Subject: [PATCH 0/4] Support CS42L42 on JSL platform

This series consists four patches. Patch 1 adds dai sequence support
for cml/jsl/tgl platforms which is different from the sequence on glk
platform. Patch 2 adds max98360a support to the maxim-common module.
Patch 3 adds driver data for jsl_cs4242_mx98360a which supports
cs42l42 and max98360a running on jsl boards. Patch 4 refactor the
sof_rt5682 to use the max98360 code in the maxim-common module.


Brent Lu (4):
ASoC: Intel: sof_cs42l42: support JSL DAI link sequence
ASoC: Intel: maxim-common: support max98360a
ASoC: intel: sof_cs42l42: add support for jsl_cs4242_mx98360a
ASoC: Intel: sof_rt5682: code refactor for max98360a

sound/soc/intel/boards/sof_cs42l42.c | 340 ++++++++++++------
sound/soc/intel/boards/sof_maxim_common.c | 17 +-
sound/soc/intel/boards/sof_maxim_common.h | 4 +-
sound/soc/intel/boards/sof_rt5682.c | 52 +--
.../intel/common/soc-acpi-intel-jsl-match.c | 8 +
5 files changed, 254 insertions(+), 167 deletions(-)

--
2.17.1


2021-06-06 01:08:12

by Brent Lu

[permalink] [raw]
Subject: [PATCH 1/4] ASoC: Intel: sof_cs42l42: support JSL DAI link sequence

The backend DAI link sequence of GLK platform is different from the
sequence of other platforms. We refactor the sof_card_dai_links_create()
function to support both style.

GLK: SPK - HP - DMIC - HDMI
Other: HP - DMIC - HDMI - SPK

Signed-off-by: Brent Lu <[email protected]>
---
sound/soc/intel/boards/sof_cs42l42.c | 318 ++++++++++++++++++---------
1 file changed, 208 insertions(+), 110 deletions(-)

diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c
index 8919d3ba3c89..e3171242f612 100644
--- a/sound/soc/intel/boards/sof_cs42l42.c
+++ b/sound/soc/intel/boards/sof_cs42l42.c
@@ -259,133 +259,166 @@ static struct snd_soc_dai_link_component dmic_component[] = {
}
};

-static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
- int ssp_codec,
- int ssp_amp,
- int dmic_be_num,
- int hdmi_num)
+static int create_spk_amp_dai_links(struct device *dev,
+ struct snd_soc_dai_link *links,
+ struct snd_soc_dai_link_component *cpus,
+ int *id, int ssp_amp)
{
- struct snd_soc_dai_link_component *idisp_components;
- struct snd_soc_dai_link_component *cpus;
- struct snd_soc_dai_link *links;
- int i, id = 0;
-
- links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) *
- sof_audio_card_cs42l42.num_links, GFP_KERNEL);
- cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component) *
- sof_audio_card_cs42l42.num_links, GFP_KERNEL);
- if (!links || !cpus)
- goto devm_err;
+ int ret = 0;

/* speaker amp */
- if (sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT) {
- links[id].name = devm_kasprintf(dev, GFP_KERNEL,
- "SSP%d-Codec", ssp_amp);
- if (!links[id].name)
- goto devm_err;
+ if (!(sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT))
+ return 0;

- links[id].id = id;
+ links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec",
+ ssp_amp);
+ if (!links[*id].name) {
+ ret = -ENOMEM;
+ goto devm_err;
+ }

- if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) {
- max_98357a_dai_link(&links[id]);
- } else {
- dev_err(dev, "no amp defined\n");
- goto devm_err;
- }
+ links[*id].id = *id;

- links[id].platforms = platform_component;
- links[id].num_platforms = ARRAY_SIZE(platform_component);
- links[id].dpcm_playback = 1;
- links[id].no_pcm = 1;
- links[id].cpus = &cpus[id];
- links[id].num_cpus = 1;
-
- links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
- "SSP%d Pin",
- ssp_amp);
- if (!links[id].cpus->dai_name)
- goto devm_err;
+ if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) {
+ max_98357a_dai_link(&links[*id]);
+ } else {
+ dev_err(dev, "no amp defined\n");
+ ret = -EINVAL;
+ goto devm_err;
+ }

- id++;
+ links[*id].platforms = platform_component;
+ links[*id].num_platforms = ARRAY_SIZE(platform_component);
+ links[*id].dpcm_playback = 1;
+ links[*id].no_pcm = 1;
+ links[*id].cpus = &cpus[*id];
+ links[*id].num_cpus = 1;
+
+ links[*id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
+ "SSP%d Pin", ssp_amp);
+ if (!links[*id].cpus->dai_name) {
+ ret = -ENOMEM;
+ goto devm_err;
}

+ (*id)++;
+
+devm_err:
+ return ret;
+}
+
+static int create_hp_codec_dai_links(struct device *dev,
+ struct snd_soc_dai_link *links,
+ struct snd_soc_dai_link_component *cpus,
+ int *id, int ssp_codec)
+{
/* codec SSP */
- links[id].name = devm_kasprintf(dev, GFP_KERNEL,
- "SSP%d-Codec", ssp_codec);
- if (!links[id].name)
+ links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec",
+ ssp_codec);
+ if (!links[*id].name)
goto devm_err;

- links[id].id = id;
- links[id].codecs = cs42l42_component;
- links[id].num_codecs = ARRAY_SIZE(cs42l42_component);
- links[id].platforms = platform_component;
- links[id].num_platforms = ARRAY_SIZE(platform_component);
- links[id].init = sof_cs42l42_init;
- links[id].exit = sof_cs42l42_exit;
- links[id].ops = &sof_cs42l42_ops;
- links[id].dpcm_playback = 1;
- links[id].dpcm_capture = 1;
- links[id].no_pcm = 1;
- links[id].cpus = &cpus[id];
- links[id].num_cpus = 1;
-
- links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
- "SSP%d Pin",
- ssp_codec);
- if (!links[id].cpus->dai_name)
+ links[*id].id = *id;
+ links[*id].codecs = cs42l42_component;
+ links[*id].num_codecs = ARRAY_SIZE(cs42l42_component);
+ links[*id].platforms = platform_component;
+ links[*id].num_platforms = ARRAY_SIZE(platform_component);
+ links[*id].init = sof_cs42l42_init;
+ links[*id].exit = sof_cs42l42_exit;
+ links[*id].ops = &sof_cs42l42_ops;
+ links[*id].dpcm_playback = 1;
+ links[*id].dpcm_capture = 1;
+ links[*id].no_pcm = 1;
+ links[*id].cpus = &cpus[*id];
+ links[*id].num_cpus = 1;
+
+ links[*id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
+ "SSP%d Pin",
+ ssp_codec);
+ if (!links[*id].cpus->dai_name)
goto devm_err;

- id++;
+ (*id)++;
+
+ return 0;
+
+devm_err:
+ return -ENOMEM;
+}
+
+static int create_dmic_dai_links(struct device *dev,
+ struct snd_soc_dai_link *links,
+ struct snd_soc_dai_link_component *cpus,
+ int *id, int dmic_be_num)
+{
+ int i;

/* dmic */
- if (dmic_be_num > 0) {
- /* at least we have dmic01 */
- links[id].name = "dmic01";
- links[id].cpus = &cpus[id];
- links[id].cpus->dai_name = "DMIC01 Pin";
- links[id].init = dmic_init;
- if (dmic_be_num > 1) {
- /* set up 2 BE links at most */
- links[id + 1].name = "dmic16k";
- links[id + 1].cpus = &cpus[id + 1];
- links[id + 1].cpus->dai_name = "DMIC16k Pin";
- dmic_be_num = 2;
- }
+ if (dmic_be_num <= 0)
+ return 0;
+
+ /* at least we have dmic01 */
+ links[*id].name = "dmic01";
+ links[*id].cpus = &cpus[*id];
+ links[*id].cpus->dai_name = "DMIC01 Pin";
+ links[*id].init = dmic_init;
+ if (dmic_be_num > 1) {
+ /* set up 2 BE links at most */
+ links[*id + 1].name = "dmic16k";
+ links[*id + 1].cpus = &cpus[*id + 1];
+ links[*id + 1].cpus->dai_name = "DMIC16k Pin";
+ dmic_be_num = 2;
}

for (i = 0; i < dmic_be_num; i++) {
- links[id].id = id;
- links[id].num_cpus = 1;
- links[id].codecs = dmic_component;
- links[id].num_codecs = ARRAY_SIZE(dmic_component);
- links[id].platforms = platform_component;
- links[id].num_platforms = ARRAY_SIZE(platform_component);
- links[id].ignore_suspend = 1;
- links[id].dpcm_capture = 1;
- links[id].no_pcm = 1;
- id++;
+ links[*id].id = *id;
+ links[*id].num_cpus = 1;
+ links[*id].codecs = dmic_component;
+ links[*id].num_codecs = ARRAY_SIZE(dmic_component);
+ links[*id].platforms = platform_component;
+ links[*id].num_platforms = ARRAY_SIZE(platform_component);
+ links[*id].ignore_suspend = 1;
+ links[*id].dpcm_capture = 1;
+ links[*id].no_pcm = 1;
+
+ (*id)++;
}

+ return 0;
+}
+
+static int create_hdmi_dai_links(struct device *dev,
+ struct snd_soc_dai_link *links,
+ struct snd_soc_dai_link_component *cpus,
+ int *id, int hdmi_num)
+{
+ struct snd_soc_dai_link_component *idisp_components;
+ int i;
+
/* HDMI */
- if (hdmi_num > 0) {
- idisp_components = devm_kzalloc(dev,
- sizeof(struct snd_soc_dai_link_component) *
- hdmi_num, GFP_KERNEL);
- if (!idisp_components)
- goto devm_err;
- }
+ if (hdmi_num <= 0)
+ return 0;
+
+ idisp_components = devm_kzalloc(dev,
+ sizeof(struct snd_soc_dai_link_component) *
+ hdmi_num, GFP_KERNEL);
+ if (!idisp_components)
+ goto devm_err;
+
for (i = 1; i <= hdmi_num; i++) {
- links[id].name = devm_kasprintf(dev, GFP_KERNEL,
- "iDisp%d", i);
- if (!links[id].name)
+ links[*id].name = devm_kasprintf(dev, GFP_KERNEL,
+ "iDisp%d", i);
+ if (!links[*id].name)
goto devm_err;

- links[id].id = id;
- links[id].cpus = &cpus[id];
- links[id].num_cpus = 1;
- links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
- "iDisp%d Pin", i);
- if (!links[id].cpus->dai_name)
+ links[*id].id = *id;
+ links[*id].cpus = &cpus[*id];
+ links[*id].num_cpus = 1;
+ links[*id].cpus->dai_name = devm_kasprintf(dev,
+ GFP_KERNEL,
+ "iDisp%d Pin",
+ i);
+ if (!links[*id].cpus->dai_name)
goto devm_err;

idisp_components[i - 1].name = "ehdaudio0D2";
@@ -396,14 +429,79 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
if (!idisp_components[i - 1].dai_name)
goto devm_err;

- links[id].codecs = &idisp_components[i - 1];
- links[id].num_codecs = 1;
- links[id].platforms = platform_component;
- links[id].num_platforms = ARRAY_SIZE(platform_component);
- links[id].init = sof_hdmi_init;
- links[id].dpcm_playback = 1;
- links[id].no_pcm = 1;
- id++;
+ links[*id].codecs = &idisp_components[i - 1];
+ links[*id].num_codecs = 1;
+ links[*id].platforms = platform_component;
+ links[*id].num_platforms = ARRAY_SIZE(platform_component);
+ links[*id].init = sof_hdmi_init;
+ links[*id].dpcm_playback = 1;
+ links[*id].no_pcm = 1;
+
+ (*id)++;
+ }
+
+ return 0;
+
+devm_err:
+ return -ENOMEM;
+}
+
+static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
+ int ssp_codec,
+ int ssp_amp,
+ int dmic_be_num,
+ int hdmi_num)
+{
+ struct snd_soc_dai_link_component *cpus;
+ struct snd_soc_dai_link *links;
+ int ret, id = 0;
+
+ links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) *
+ sof_audio_card_cs42l42.num_links, GFP_KERNEL);
+ cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component) *
+ sof_audio_card_cs42l42.num_links, GFP_KERNEL);
+ if (!links || !cpus)
+ goto devm_err;
+
+ if (soc_intel_is_glk()) {
+ /* gemini lake starts from spk link */
+ ret = create_spk_amp_dai_links(dev, links, cpus, &id, ssp_amp);
+ if (ret < 0) {
+ dev_err(dev, "fail to create spk amp dai links, ret %d\n",
+ ret);
+ goto devm_err;
+ }
+ }
+
+ ret = create_hp_codec_dai_links(dev, links, cpus, &id, ssp_codec);
+ if (ret < 0) {
+ dev_err(dev, "fail to create hp codec dai links, ret %d\n",
+ ret);
+ goto devm_err;
+ }
+
+ ret = create_dmic_dai_links(dev, links, cpus, &id, dmic_be_num);
+ if (ret < 0) {
+ dev_err(dev, "fail to create dmic dai links, ret %d\n",
+ ret);
+ goto devm_err;
+ }
+
+ ret = create_hdmi_dai_links(dev, links, cpus, &id, hdmi_num);
+ if (ret < 0) {
+ dev_err(dev, "fail to create hdmi dai links, ret %d\n",
+ ret);
+ goto devm_err;
+ }
+
+ if (!soc_intel_is_glk()) {
+ /* other platforms end with spk link */
+ ret = create_spk_amp_dai_links(dev, links, cpus, &id, ssp_amp);
+ if (ret < 0) {
+ dev_err(dev, "fail to create spk amp dai links, ret %d\n",
+ ret);
+ goto devm_err;
+ }
}

return links;
--
2.17.1

2021-06-06 01:08:25

by Brent Lu

[permalink] [raw]
Subject: [PATCH 3/4] ASoC: intel: sof_cs42l42: add support for jsl_cs4242_mx98360a

This patch adds driver data for jsl_cs4242_mx98360a which supports two
max98360a speaker amplifiers on SSP1 and cs42l42 headphone codec on
SSP0 running on JSL platform. DAI format is leveraged from sof_rt5682
machine driver to reuse the topology.

Also use module device table to replace module alias.

Signed-off-by: Brent Lu <[email protected]>
---
sound/soc/intel/boards/sof_cs42l42.c | 22 +++++++++++++++----
.../intel/common/soc-acpi-intel-jsl-match.c | 8 +++++++
2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c
index e3171242f612..d712cfb91fd1 100644
--- a/sound/soc/intel/boards/sof_cs42l42.c
+++ b/sound/soc/intel/boards/sof_cs42l42.c
@@ -36,7 +36,9 @@
#define SOF_CS42L42_NUM_HDMIDEV_MASK (GENMASK(9, 7))
#define SOF_CS42L42_NUM_HDMIDEV(quirk) \
(((quirk) << SOF_CS42L42_NUM_HDMIDEV_SHIFT) & SOF_CS42L42_NUM_HDMIDEV_MASK)
-#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(10)
+#define SOF_CS42L42_BCLK_2400000 BIT(10)
+#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(11)
+#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(12)

/* Default: SSP2 */
static unsigned long sof_cs42l42_quirk = SOF_CS42L42_SSP_CODEC(2);
@@ -122,7 +124,10 @@ static int sof_cs42l42_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
int clk_freq, ret;

- clk_freq = 3072000; /* BCLK freq */
+ if (sof_cs42l42_quirk & SOF_CS42L42_BCLK_2400000)
+ clk_freq = 2400000; /* BCLK freq */
+ else
+ clk_freq = 3072000; /* BCLK freq */

/* Configure sysclk for codec */
ret = snd_soc_dai_set_sysclk(codec_dai, 0,
@@ -281,6 +286,8 @@ static int create_spk_amp_dai_links(struct device *dev,

if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) {
max_98357a_dai_link(&links[*id]);
+ } else if (sof_cs42l42_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) {
+ max_98360a_dai_link(&links[*id]);
} else {
dev_err(dev, "no amp defined\n");
ret = -EINVAL;
@@ -584,8 +591,17 @@ static const struct platform_device_id board_ids[] = {
SOF_MAX98357A_SPEAKER_AMP_PRESENT |
SOF_CS42L42_SSP_AMP(1)),
},
+ {
+ .name = "jsl_cs4242_mx98360a",
+ .driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) |
+ SOF_SPEAKER_AMP_PRESENT |
+ SOF_MAX98360A_SPEAKER_AMP_PRESENT |
+ SOF_CS42L42_SSP_AMP(1)) |
+ SOF_CS42L42_BCLK_2400000,
+ },
{ }
};
+MODULE_DEVICE_TABLE(platform, board_ids);

static struct platform_driver sof_audio = {
.probe = sof_audio_probe,
@@ -601,7 +617,5 @@ module_platform_driver(sof_audio)
MODULE_DESCRIPTION("SOF Audio Machine driver for CS42L42");
MODULE_AUTHOR("Brent Lu <[email protected]>");
MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:sof_cs42l42");
-MODULE_ALIAS("platform:glk_cs4242_max98357a");
MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
diff --git a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c
index 73fe4f89a82d..8e86476d48de 100644
--- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c
@@ -73,6 +73,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = {
.quirk_data = &mx98360a_spk,
.sof_tplg_filename = "sof-jsl-rt5682-mx98360a.tplg",
},
+ {
+ .id = "10134242",
+ .drv_name = "jsl_cs4242_mx98360a",
+ .sof_fw_filename = "sof-jsl.ri",
+ .machine_quirk = snd_soc_acpi_codec_list,
+ .quirk_data = &mx98360a_spk,
+ .sof_tplg_filename = "sof-jsl-rt5682-mx98360a.tplg",
+ },
{},
};
EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_jsl_machines);
--
2.17.1

2021-06-06 01:08:45

by Brent Lu

[permalink] [raw]
Subject: [PATCH 4/4] ASoC: Intel: sof_rt5682: code refactor for max98360a

Refactor the machine driver by using the common code in maxim-common
module to support max98360a.

Signed-off-by: Brent Lu <[email protected]>
---
sound/soc/intel/boards/sof_rt5682.c | 52 +----------------------------
1 file changed, 1 insertion(+), 51 deletions(-)

diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c
index 3e69feaf052b..910c054b0b42 100644
--- a/sound/soc/intel/boards/sof_rt5682.c
+++ b/sound/soc/intel/boards/sof_rt5682.c
@@ -456,10 +456,6 @@ static const struct snd_kcontrol_new sof_controls[] = {

};

-static const struct snd_kcontrol_new speaker_controls[] = {
- SOC_DAPM_PIN_SWITCH("Spk"),
-};
-
static const struct snd_soc_dapm_widget sof_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
@@ -467,10 +463,6 @@ static const struct snd_soc_dapm_widget sof_widgets[] = {
SND_SOC_DAPM_SPK("Right Spk", NULL),
};

-static const struct snd_soc_dapm_widget speaker_widgets[] = {
- SND_SOC_DAPM_SPK("Spk", NULL),
-};
-
static const struct snd_soc_dapm_widget dmic_widgets[] = {
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
};
@@ -484,11 +476,6 @@ static const struct snd_soc_dapm_route sof_map[] = {
{ "IN1P", NULL, "Headset Mic" },
};

-static const struct snd_soc_dapm_route speaker_map[] = {
- /* speaker */
- { "Spk", NULL, "Speaker" },
-};
-
static const struct snd_soc_dapm_route speaker_map_lr[] = {
{ "Left Spk", NULL, "Left SPO" },
{ "Right Spk", NULL, "Right SPO" },
@@ -505,34 +492,6 @@ static int speaker_codec_init_lr(struct snd_soc_pcm_runtime *rtd)
ARRAY_SIZE(speaker_map_lr));
}

-static int speaker_codec_init(struct snd_soc_pcm_runtime *rtd)
-{
- struct snd_soc_card *card = rtd->card;
- int ret;
-
- ret = snd_soc_dapm_new_controls(&card->dapm, speaker_widgets,
- ARRAY_SIZE(speaker_widgets));
- if (ret) {
- dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret);
- /* Don't need to add routes if widget addition failed */
- return ret;
- }
-
- ret = snd_soc_add_card_controls(card, speaker_controls,
- ARRAY_SIZE(speaker_controls));
- if (ret) {
- dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
- return ret;
- }
-
- ret = snd_soc_dapm_add_routes(&card->dapm, speaker_map,
- ARRAY_SIZE(speaker_map));
-
- if (ret)
- dev_err(rtd->dev, "Speaker map addition failed: %d\n", ret);
- return ret;
-}
-
static int dmic_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
@@ -594,13 +553,6 @@ static struct snd_soc_dai_link_component dmic_component[] = {
}
};

-static struct snd_soc_dai_link_component max98360a_component[] = {
- {
- .name = "MX98360A:00",
- .dai_name = "HiFi",
- }
-};
-
static struct snd_soc_dai_link_component rt1015_components[] = {
{
.name = "i2c-10EC1015:00",
@@ -775,9 +727,7 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
links[id].dpcm_capture = 1;
} else if (sof_rt5682_quirk &
SOF_MAX98360A_SPEAKER_AMP_PRESENT) {
- links[id].codecs = max98360a_component;
- links[id].num_codecs = ARRAY_SIZE(max98360a_component);
- links[id].init = speaker_codec_init;
+ max_98360a_dai_link(&links[id]);
} else if (sof_rt5682_quirk &
SOF_RT1011_SPEAKER_AMP_PRESENT) {
sof_rt1011_dai_link(&links[id]);
--
2.17.1

2021-06-07 14:00:40

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH 3/4] ASoC: intel: sof_cs42l42: add support for jsl_cs4242_mx98360a



On 6/5/21 7:41 PM, Brent Lu wrote:
> This patch adds driver data for jsl_cs4242_mx98360a which supports two
> max98360a speaker amplifiers on SSP1 and cs42l42 headphone codec on
> SSP0 running on JSL platform. DAI format is leveraged from sof_rt5682
> machine driver to reuse the topology.

This also looks like we have two topologies configuring the same DAIs
differently on different platforms.

Why can't we pick one configuration that would work in all cases?

> Also use module device table to replace module alias.

Humm, this looks like a missing dependency, I modified this a while ago.

>
> Signed-off-by: Brent Lu <[email protected]>
> ---
> sound/soc/intel/boards/sof_cs42l42.c | 22 +++++++++++++++----
> .../intel/common/soc-acpi-intel-jsl-match.c | 8 +++++++
> 2 files changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c
> index e3171242f612..d712cfb91fd1 100644
> --- a/sound/soc/intel/boards/sof_cs42l42.c
> +++ b/sound/soc/intel/boards/sof_cs42l42.c
> @@ -36,7 +36,9 @@
> #define SOF_CS42L42_NUM_HDMIDEV_MASK (GENMASK(9, 7))
> #define SOF_CS42L42_NUM_HDMIDEV(quirk) \
> (((quirk) << SOF_CS42L42_NUM_HDMIDEV_SHIFT) & SOF_CS42L42_NUM_HDMIDEV_MASK)
> -#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(10)
> +#define SOF_CS42L42_BCLK_2400000 BIT(10)
> +#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(11)
> +#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(12)
>
> /* Default: SSP2 */
> static unsigned long sof_cs42l42_quirk = SOF_CS42L42_SSP_CODEC(2);
> @@ -122,7 +124,10 @@ static int sof_cs42l42_hw_params(struct snd_pcm_substream *substream,
> struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
> int clk_freq, ret;
>
> - clk_freq = 3072000; /* BCLK freq */
> + if (sof_cs42l42_quirk & SOF_CS42L42_BCLK_2400000)
> + clk_freq = 2400000; /* BCLK freq */
> + else
> + clk_freq = 3072000; /* BCLK freq */
>
> /* Configure sysclk for codec */
> ret = snd_soc_dai_set_sysclk(codec_dai, 0,
> @@ -281,6 +286,8 @@ static int create_spk_amp_dai_links(struct device *dev,
>
> if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) {
> max_98357a_dai_link(&links[*id]);
> + } else if (sof_cs42l42_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) {
> + max_98360a_dai_link(&links[*id]);
> } else {
> dev_err(dev, "no amp defined\n");
> ret = -EINVAL;
> @@ -584,8 +591,17 @@ static const struct platform_device_id board_ids[] = {
> SOF_MAX98357A_SPEAKER_AMP_PRESENT |
> SOF_CS42L42_SSP_AMP(1)),
> },
> + {
> + .name = "jsl_cs4242_mx98360a",
> + .driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) |
> + SOF_SPEAKER_AMP_PRESENT |
> + SOF_MAX98360A_SPEAKER_AMP_PRESENT |
> + SOF_CS42L42_SSP_AMP(1)) |
> + SOF_CS42L42_BCLK_2400000,
> + },
> { }
> };
> +MODULE_DEVICE_TABLE(platform, board_ids);
>
> static struct platform_driver sof_audio = {
> .probe = sof_audio_probe,
> @@ -601,7 +617,5 @@ module_platform_driver(sof_audio)
> MODULE_DESCRIPTION("SOF Audio Machine driver for CS42L42");
> MODULE_AUTHOR("Brent Lu <[email protected]>");
> MODULE_LICENSE("GPL");
> -MODULE_ALIAS("platform:sof_cs42l42");
> -MODULE_ALIAS("platform:glk_cs4242_max98357a");
> MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
> MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
> diff --git a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c
> index 73fe4f89a82d..8e86476d48de 100644
> --- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c
> +++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c
> @@ -73,6 +73,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = {
> .quirk_data = &mx98360a_spk,
> .sof_tplg_filename = "sof-jsl-rt5682-mx98360a.tplg",
> },
> + {
> + .id = "10134242",
> + .drv_name = "jsl_cs4242_mx98360a",
> + .sof_fw_filename = "sof-jsl.ri",
> + .machine_quirk = snd_soc_acpi_codec_list,
> + .quirk_data = &mx98360a_spk,
> + .sof_tplg_filename = "sof-jsl-rt5682-mx98360a.tplg",
> + },
> {},
> };
> EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_jsl_machines);
>

2021-06-07 14:01:03

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH 1/4] ASoC: Intel: sof_cs42l42: support JSL DAI link sequence



On 6/5/21 7:40 PM, Brent Lu wrote:
> The backend DAI link sequence of GLK platform is different from the
> sequence of other platforms. We refactor the sof_card_dai_links_create()
> function to support both style.
>
> GLK: SPK - HP - DMIC - HDMI
> Other: HP - DMIC - HDMI - SPK

I am really confused here.
The dailink sequence is whatever we want it to be. What matters is that
the dailink ID matches what is in the topology.

Is this saying that the GLK and JSL topologies did not follow any sort
of convention? Can you elaborate more on what is the issue?

Put differently, why can't we fix the topology instead with a reorder of
the dailinks?

>
> Signed-off-by: Brent Lu <[email protected]>
> ---
> sound/soc/intel/boards/sof_cs42l42.c | 318 ++++++++++++++++++---------
> 1 file changed, 208 insertions(+), 110 deletions(-)
>
> diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c
> index 8919d3ba3c89..e3171242f612 100644
> --- a/sound/soc/intel/boards/sof_cs42l42.c
> +++ b/sound/soc/intel/boards/sof_cs42l42.c
> @@ -259,133 +259,166 @@ static struct snd_soc_dai_link_component dmic_component[] = {
> }
> };
>
> -static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
> - int ssp_codec,
> - int ssp_amp,
> - int dmic_be_num,
> - int hdmi_num)
> +static int create_spk_amp_dai_links(struct device *dev,
> + struct snd_soc_dai_link *links,
> + struct snd_soc_dai_link_component *cpus,
> + int *id, int ssp_amp)
> {
> - struct snd_soc_dai_link_component *idisp_components;
> - struct snd_soc_dai_link_component *cpus;
> - struct snd_soc_dai_link *links;
> - int i, id = 0;
> -
> - links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) *
> - sof_audio_card_cs42l42.num_links, GFP_KERNEL);
> - cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component) *
> - sof_audio_card_cs42l42.num_links, GFP_KERNEL);
> - if (!links || !cpus)
> - goto devm_err;
> + int ret = 0;
>
> /* speaker amp */
> - if (sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT) {
> - links[id].name = devm_kasprintf(dev, GFP_KERNEL,
> - "SSP%d-Codec", ssp_amp);
> - if (!links[id].name)
> - goto devm_err;
> + if (!(sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT))
> + return 0;
>
> - links[id].id = id;
> + links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec",
> + ssp_amp);
> + if (!links[*id].name) {
> + ret = -ENOMEM;
> + goto devm_err;
> + }
>
> - if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) {
> - max_98357a_dai_link(&links[id]);
> - } else {
> - dev_err(dev, "no amp defined\n");
> - goto devm_err;
> - }
> + links[*id].id = *id;
>
> - links[id].platforms = platform_component;
> - links[id].num_platforms = ARRAY_SIZE(platform_component);
> - links[id].dpcm_playback = 1;
> - links[id].no_pcm = 1;
> - links[id].cpus = &cpus[id];
> - links[id].num_cpus = 1;
> -
> - links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
> - "SSP%d Pin",
> - ssp_amp);
> - if (!links[id].cpus->dai_name)
> - goto devm_err;
> + if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) {
> + max_98357a_dai_link(&links[*id]);
> + } else {
> + dev_err(dev, "no amp defined\n");
> + ret = -EINVAL;
> + goto devm_err;
> + }
>
> - id++;
> + links[*id].platforms = platform_component;
> + links[*id].num_platforms = ARRAY_SIZE(platform_component);
> + links[*id].dpcm_playback = 1;
> + links[*id].no_pcm = 1;
> + links[*id].cpus = &cpus[*id];
> + links[*id].num_cpus = 1;
> +
> + links[*id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
> + "SSP%d Pin", ssp_amp);
> + if (!links[*id].cpus->dai_name) {
> + ret = -ENOMEM;
> + goto devm_err;
> }
>
> + (*id)++;
> +
> +devm_err:
> + return ret;
> +}
> +
> +static int create_hp_codec_dai_links(struct device *dev,
> + struct snd_soc_dai_link *links,
> + struct snd_soc_dai_link_component *cpus,
> + int *id, int ssp_codec)
> +{
> /* codec SSP */
> - links[id].name = devm_kasprintf(dev, GFP_KERNEL,
> - "SSP%d-Codec", ssp_codec);
> - if (!links[id].name)
> + links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec",
> + ssp_codec);
> + if (!links[*id].name)
> goto devm_err;
>
> - links[id].id = id;
> - links[id].codecs = cs42l42_component;
> - links[id].num_codecs = ARRAY_SIZE(cs42l42_component);
> - links[id].platforms = platform_component;
> - links[id].num_platforms = ARRAY_SIZE(platform_component);
> - links[id].init = sof_cs42l42_init;
> - links[id].exit = sof_cs42l42_exit;
> - links[id].ops = &sof_cs42l42_ops;
> - links[id].dpcm_playback = 1;
> - links[id].dpcm_capture = 1;
> - links[id].no_pcm = 1;
> - links[id].cpus = &cpus[id];
> - links[id].num_cpus = 1;
> -
> - links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
> - "SSP%d Pin",
> - ssp_codec);
> - if (!links[id].cpus->dai_name)
> + links[*id].id = *id;
> + links[*id].codecs = cs42l42_component;
> + links[*id].num_codecs = ARRAY_SIZE(cs42l42_component);
> + links[*id].platforms = platform_component;
> + links[*id].num_platforms = ARRAY_SIZE(platform_component);
> + links[*id].init = sof_cs42l42_init;
> + links[*id].exit = sof_cs42l42_exit;
> + links[*id].ops = &sof_cs42l42_ops;
> + links[*id].dpcm_playback = 1;
> + links[*id].dpcm_capture = 1;
> + links[*id].no_pcm = 1;
> + links[*id].cpus = &cpus[*id];
> + links[*id].num_cpus = 1;
> +
> + links[*id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
> + "SSP%d Pin",
> + ssp_codec);
> + if (!links[*id].cpus->dai_name)
> goto devm_err;
>
> - id++;
> + (*id)++;
> +
> + return 0;
> +
> +devm_err:
> + return -ENOMEM;
> +}
> +
> +static int create_dmic_dai_links(struct device *dev,
> + struct snd_soc_dai_link *links,
> + struct snd_soc_dai_link_component *cpus,
> + int *id, int dmic_be_num)
> +{
> + int i;
>
> /* dmic */
> - if (dmic_be_num > 0) {
> - /* at least we have dmic01 */
> - links[id].name = "dmic01";
> - links[id].cpus = &cpus[id];
> - links[id].cpus->dai_name = "DMIC01 Pin";
> - links[id].init = dmic_init;
> - if (dmic_be_num > 1) {
> - /* set up 2 BE links at most */
> - links[id + 1].name = "dmic16k";
> - links[id + 1].cpus = &cpus[id + 1];
> - links[id + 1].cpus->dai_name = "DMIC16k Pin";
> - dmic_be_num = 2;
> - }
> + if (dmic_be_num <= 0)
> + return 0;
> +
> + /* at least we have dmic01 */
> + links[*id].name = "dmic01";
> + links[*id].cpus = &cpus[*id];
> + links[*id].cpus->dai_name = "DMIC01 Pin";
> + links[*id].init = dmic_init;
> + if (dmic_be_num > 1) {
> + /* set up 2 BE links at most */
> + links[*id + 1].name = "dmic16k";
> + links[*id + 1].cpus = &cpus[*id + 1];
> + links[*id + 1].cpus->dai_name = "DMIC16k Pin";
> + dmic_be_num = 2;
> }
>
> for (i = 0; i < dmic_be_num; i++) {
> - links[id].id = id;
> - links[id].num_cpus = 1;
> - links[id].codecs = dmic_component;
> - links[id].num_codecs = ARRAY_SIZE(dmic_component);
> - links[id].platforms = platform_component;
> - links[id].num_platforms = ARRAY_SIZE(platform_component);
> - links[id].ignore_suspend = 1;
> - links[id].dpcm_capture = 1;
> - links[id].no_pcm = 1;
> - id++;
> + links[*id].id = *id;
> + links[*id].num_cpus = 1;
> + links[*id].codecs = dmic_component;
> + links[*id].num_codecs = ARRAY_SIZE(dmic_component);
> + links[*id].platforms = platform_component;
> + links[*id].num_platforms = ARRAY_SIZE(platform_component);
> + links[*id].ignore_suspend = 1;
> + links[*id].dpcm_capture = 1;
> + links[*id].no_pcm = 1;
> +
> + (*id)++;
> }
>
> + return 0;
> +}
> +
> +static int create_hdmi_dai_links(struct device *dev,
> + struct snd_soc_dai_link *links,
> + struct snd_soc_dai_link_component *cpus,
> + int *id, int hdmi_num)
> +{
> + struct snd_soc_dai_link_component *idisp_components;
> + int i;
> +
> /* HDMI */
> - if (hdmi_num > 0) {
> - idisp_components = devm_kzalloc(dev,
> - sizeof(struct snd_soc_dai_link_component) *
> - hdmi_num, GFP_KERNEL);
> - if (!idisp_components)
> - goto devm_err;
> - }
> + if (hdmi_num <= 0)
> + return 0;
> +
> + idisp_components = devm_kzalloc(dev,
> + sizeof(struct snd_soc_dai_link_component) *
> + hdmi_num, GFP_KERNEL);
> + if (!idisp_components)
> + goto devm_err;
> +
> for (i = 1; i <= hdmi_num; i++) {
> - links[id].name = devm_kasprintf(dev, GFP_KERNEL,
> - "iDisp%d", i);
> - if (!links[id].name)
> + links[*id].name = devm_kasprintf(dev, GFP_KERNEL,
> + "iDisp%d", i);
> + if (!links[*id].name)
> goto devm_err;
>
> - links[id].id = id;
> - links[id].cpus = &cpus[id];
> - links[id].num_cpus = 1;
> - links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
> - "iDisp%d Pin", i);
> - if (!links[id].cpus->dai_name)
> + links[*id].id = *id;
> + links[*id].cpus = &cpus[*id];
> + links[*id].num_cpus = 1;
> + links[*id].cpus->dai_name = devm_kasprintf(dev,
> + GFP_KERNEL,
> + "iDisp%d Pin",
> + i);
> + if (!links[*id].cpus->dai_name)
> goto devm_err;
>
> idisp_components[i - 1].name = "ehdaudio0D2";
> @@ -396,14 +429,79 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
> if (!idisp_components[i - 1].dai_name)
> goto devm_err;
>
> - links[id].codecs = &idisp_components[i - 1];
> - links[id].num_codecs = 1;
> - links[id].platforms = platform_component;
> - links[id].num_platforms = ARRAY_SIZE(platform_component);
> - links[id].init = sof_hdmi_init;
> - links[id].dpcm_playback = 1;
> - links[id].no_pcm = 1;
> - id++;
> + links[*id].codecs = &idisp_components[i - 1];
> + links[*id].num_codecs = 1;
> + links[*id].platforms = platform_component;
> + links[*id].num_platforms = ARRAY_SIZE(platform_component);
> + links[*id].init = sof_hdmi_init;
> + links[*id].dpcm_playback = 1;
> + links[*id].no_pcm = 1;
> +
> + (*id)++;
> + }
> +
> + return 0;
> +
> +devm_err:
> + return -ENOMEM;
> +}
> +
> +static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
> + int ssp_codec,
> + int ssp_amp,
> + int dmic_be_num,
> + int hdmi_num)
> +{
> + struct snd_soc_dai_link_component *cpus;
> + struct snd_soc_dai_link *links;
> + int ret, id = 0;
> +
> + links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) *
> + sof_audio_card_cs42l42.num_links, GFP_KERNEL);
> + cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component) *
> + sof_audio_card_cs42l42.num_links, GFP_KERNEL);
> + if (!links || !cpus)
> + goto devm_err;
> +
> + if (soc_intel_is_glk()) {
> + /* gemini lake starts from spk link */
> + ret = create_spk_amp_dai_links(dev, links, cpus, &id, ssp_amp);
> + if (ret < 0) {
> + dev_err(dev, "fail to create spk amp dai links, ret %d\n",
> + ret);
> + goto devm_err;
> + }
> + }
> +
> + ret = create_hp_codec_dai_links(dev, links, cpus, &id, ssp_codec);
> + if (ret < 0) {
> + dev_err(dev, "fail to create hp codec dai links, ret %d\n",
> + ret);
> + goto devm_err;
> + }
> +
> + ret = create_dmic_dai_links(dev, links, cpus, &id, dmic_be_num);
> + if (ret < 0) {
> + dev_err(dev, "fail to create dmic dai links, ret %d\n",
> + ret);
> + goto devm_err;
> + }
> +
> + ret = create_hdmi_dai_links(dev, links, cpus, &id, hdmi_num);
> + if (ret < 0) {
> + dev_err(dev, "fail to create hdmi dai links, ret %d\n",
> + ret);
> + goto devm_err;
> + }
> +
> + if (!soc_intel_is_glk()) {
> + /* other platforms end with spk link */
> + ret = create_spk_amp_dai_links(dev, links, cpus, &id, ssp_amp);
> + if (ret < 0) {
> + dev_err(dev, "fail to create spk amp dai links, ret %d\n",
> + ret);
> + goto devm_err;
> + }
> }
>
> return links;
>

2021-06-07 14:24:34

by Brent Lu

[permalink] [raw]
Subject: RE: [PATCH 1/4] ASoC: Intel: sof_cs42l42: support JSL DAI link sequence

> On 6/5/21 7:40 PM, Brent Lu wrote:
> > The backend DAI link sequence of GLK platform is different from the
> > sequence of other platforms. We refactor the
> > sof_card_dai_links_create() function to support both style.
> >
> > GLK: SPK - HP - DMIC - HDMI
> > Other: HP - DMIC - HDMI - SPK
>
> I am really confused here.
> The dailink sequence is whatever we want it to be. What matters is that the
> dailink ID matches what is in the topology.
>
> Is this saying that the GLK and JSL topologies did not follow any sort of
> convention? Can you elaborate more on what is the issue?
>
> Put differently, why can't we fix the topology instead with a reorder of the
> dailinks?
>

snd_soc_find_dai_link() checked both dai link name and id when matching
topology and machine driver. Soundcard registration would fail if their id
doesn't match.

Cs42l42 is sharing topology with DA7219's topology source file sof-glk-da7219.m4
on GLK platform. The configuration is:

dai link id 0 is for spk
#SSP 1 (ID: 0) with 19.2 MHz mclk with MCLK_ID 1 (unused), 1.536 MHz blck
DAI_CONFIG(SSP, 1, 0, SSP1-Codec,

dai link id 1 is for headphone
#SSP 2 (ID: 1) with 19.2 MHz mclk with MCLK_ID 1, 1.92 MHz bclk
DAI_CONFIG(SSP, 2, 1, SSP2-Codec,

dai link id 2 is for dmic
DAI_CONFIG(DMIC, 0, 2, dmic01,

dai link id 3/4/5 is for hdmi
DAI_CONFIG(HDA, 3, 3, iDisp1,
DAI_CONFIG(HDA, 4, 4, iDisp2,
DAI_CONFIG(HDA, 5, 5, iDisp3,

When on JSL, we plan to share topology with rt5682 which has different dai link
sequence:
sof-jsl-rt5682.m4:

dai link id 0 is for headphone
DAI_CONFIG(SSP, 0, 0, SSP0-Codec,

dai link id 6 is for spk
# SSP 1 (ID: 6)
DAI_CONFIG(SSP, SPK_INDEX, 6, SPK_NAME,
SET_SSP_CONFIG)

dai link id 3/4/5 is for hdmi
# 4 HDMI/DP outputs (ID: 3,4,5)
DAI_CONFIG(HDA, 0, 3, iDisp1,
DAI_CONFIG(HDA, 1, 4, iDisp2,
DAI_CONFIG(HDA, 2, 5, iDisp3,

I'm not sure if there is convention about the sequence to follow?


Regards,
Brent

2021-06-07 14:30:55

by Brent Lu

[permalink] [raw]
Subject: RE: [PATCH 3/4] ASoC: intel: sof_cs42l42: add support for jsl_cs4242_mx98360a

> On 6/5/21 7:41 PM, Brent Lu wrote:
> > This patch adds driver data for jsl_cs4242_mx98360a which supports two
> > max98360a speaker amplifiers on SSP1 and cs42l42 headphone codec on
> > SSP0 running on JSL platform. DAI format is leveraged from sof_rt5682
> > machine driver to reuse the topology.
>
> This also looks like we have two topologies configuring the same DAIs
> differently on different platforms.
>
> Why can't we pick one configuration that would work in all cases?
>

The comment just say we are reusing rt5685's sof-jsl-rt5682-mx98360a.tplg.
This patch does not care about the dai sequence. Maybe I should reword the
commit log.


Regards,
Brent

> > Also use module device table to replace module alias.
>
> Humm, this looks like a missing dependency, I modified this a while ago.
>


2021-06-07 14:47:02

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH 3/4] ASoC: intel: sof_cs42l42: add support for jsl_cs4242_mx98360a



On 6/7/21 9:29 AM, Lu, Brent wrote:
>> On 6/5/21 7:41 PM, Brent Lu wrote:
>>> This patch adds driver data for jsl_cs4242_mx98360a which supports two
>>> max98360a speaker amplifiers on SSP1 and cs42l42 headphone codec on
>>> SSP0 running on JSL platform. DAI format is leveraged from sof_rt5682
>>> machine driver to reuse the topology.
>>
>> This also looks like we have two topologies configuring the same DAIs
>> differently on different platforms.
>>
>> Why can't we pick one configuration that would work in all cases?
>>
>
> The comment just say we are reusing rt5685's sof-jsl-rt5682-mx98360a.tplg.
> This patch does not care about the dai sequence. Maybe I should reword the
> commit log.

I was referring to the bclk frequency, one case uses 2.4 and the other
3.072MHz.

2021-06-07 16:34:52

by Brent Lu

[permalink] [raw]
Subject: RE: [PATCH 3/4] ASoC: intel: sof_cs42l42: add support for jsl_cs4242_mx98360a

> >>
> >> This also looks like we have two topologies configuring the same DAIs
> >> differently on different platforms.
> >>
> >> Why can't we pick one configuration that would work in all cases?
> >>
> >
> > The comment just say we are reusing rt5685's sof-jsl-rt5682-mx98360a.tplg.
> > This patch does not care about the dai sequence. Maybe I should reword
> > the commit log.
>
> I was referring to the bclk frequency, one case uses 2.4 and the other
> 3.072MHz.

The 2.4MHz setting isn't ready when we enabled this codec so we selected
3.072MHz. Since we are updating topology for PLL issue soon, we can change
bclk frequency to 2.4MHz as well. How do you think?

Regards,
Brent

2021-06-07 18:34:15

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH 3/4] ASoC: intel: sof_cs42l42: add support for jsl_cs4242_mx98360a



On 6/7/21 11:28 AM, Lu, Brent wrote:
>>>>
>>>> This also looks like we have two topologies configuring the same DAIs
>>>> differently on different platforms.
>>>>
>>>> Why can't we pick one configuration that would work in all cases?
>>>>
>>>
>>> The comment just say we are reusing rt5685's sof-jsl-rt5682-mx98360a.tplg.
>>> This patch does not care about the dai sequence. Maybe I should reword
>>> the commit log.
>>
>> I was referring to the bclk frequency, one case uses 2.4 and the other
>> 3.072MHz.
>
> The 2.4MHz setting isn't ready when we enabled this codec so we selected
> 3.072MHz. Since we are updating topology for PLL issue soon, we can change
> bclk frequency to 2.4MHz as well. How do you think?

The 3.072MHz clock will require the 24.576MHz PLL to be on on the
SOC/PCH. If you can use 2.4 MHz without any loss of quality and the
codec can deal with 25 bit slots with 24-bit data it's better power-wise.

We try to use 64.fs only when it's absolutely mandatory, e.g. if the
codec or amplifier doesn't support the 25/24 configuration. IIRC this
was the case with TI PCM512x and Maxim amps.

We've also used the 3.072 MHz bit clock when there are constraints on
the clock sources and selectors. This isn't the case on GLK but the SOF
commit 0a97c1a92f2d93bd4d45bc99d61e362cd214748c clarified the clock
selection for newer platforms, including JSL. In the end we may be
forced to use the 3.072 MHz PLL, you'd need to look at the various
topologies used with this machine driver.

2021-06-07 20:51:40

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH 1/4] ASoC: Intel: sof_cs42l42: support JSL DAI link sequence


> Cs42l42 is sharing topology with DA7219's topology source file sof-glk-da7219.m4
> on GLK platform. The configuration is:
>
> dai link id 0 is for spk
> #SSP 1 (ID: 0) with 19.2 MHz mclk with MCLK_ID 1 (unused), 1.536 MHz blck
> DAI_CONFIG(SSP, 1, 0, SSP1-Codec,
>
> dai link id 1 is for headphone
> #SSP 2 (ID: 1) with 19.2 MHz mclk with MCLK_ID 1, 1.92 MHz bclk
> DAI_CONFIG(SSP, 2, 1, SSP2-Codec,
>
> dai link id 2 is for dmic
> DAI_CONFIG(DMIC, 0, 2, dmic01,
>
> dai link id 3/4/5 is for hdmi
> DAI_CONFIG(HDA, 3, 3, iDisp1,
> DAI_CONFIG(HDA, 4, 4, iDisp2,
> DAI_CONFIG(HDA, 5, 5, iDisp3,
>
> When on JSL, we plan to share topology with rt5682 which has different dai link
> sequence:
> sof-jsl-rt5682.m4:
>
> dai link id 0 is for headphone
> DAI_CONFIG(SSP, 0, 0, SSP0-Codec,
>
> dai link id 6 is for spk
> # SSP 1 (ID: 6)
> DAI_CONFIG(SSP, SPK_INDEX, 6, SPK_NAME,
> SET_SSP_CONFIG)
>
> dai link id 3/4/5 is for hdmi
> # 4 HDMI/DP outputs (ID: 3,4,5)
> DAI_CONFIG(HDA, 0, 3, iDisp1,
> DAI_CONFIG(HDA, 1, 4, iDisp2,
> DAI_CONFIG(HDA, 2, 5, iDisp3,
>
> I'm not sure if there is convention about the sequence to follow?

ok, now I get what you are trying to do.

Unfortunately there are no conventions so far, and since we have to be
backwards-compatible with topology files already released we will need
to deal with the different configurations in this machine driver, you're
right about this.

The code you suggested is fine, but we can future-proof it a bit.

Instead of assuming any order depending on GLK or !GLK, we can add a BE
'base' for headphone, amp, DMIC and DMIC each (represented as a constant
structure) and point to different configurations depending on a quirk.
That way we can deal with other permutations such as HP - SPK - HDMI - DMIC