* [PATCH] [v2] ASoC: Intel: sof_cs42l42: adding support for ADL configuration and BT offload audio
@ 2022-05-10 10:48 Terry Chen
2022-05-10 14:40 ` Pierre-Louis Bossart
0 siblings, 1 reply; 4+ messages in thread
From: Terry Chen @ 2022-05-10 10:48 UTC (permalink / raw)
To: alsa-devel
Cc: cezary.rojewski, pierre-louis.bossart, liam.r.girdwood, yang.jie,
broonie, perex, tiwai, brent.lu, cujomalainey, seanpaul,
terry_chen, casey.g.bowman, mark_hsieh, vamshi.krishna.gopal,
mac.chiang, kai.vehmanen, linux-kernel
To be able to do driver data for adl_mx98360a_cs4242 which supports
two max98360a speaker amplifiers on SSP1 and cs42l42 headphone codec
on SSP0 running on ADL platform. Also add the capability to machine driver
of creating DAI Link for BT offload. Although BT offload always uses SSP2
port but we reserve the flexibility to assign the port number in macro.
Signed-off-by: Terry Chen <terry_chen@wistron.corp-partner.google.com>
---
sound/soc/intel/boards/sof_cs42l42.c | 88 ++++++++++++++++++-
.../intel/common/soc-acpi-intel-adl-match.c | 8 ++
2 files changed, 92 insertions(+), 4 deletions(-)
diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c
index ce78c18798876..4ac4f51c7c115 100644
--- a/sound/soc/intel/boards/sof_cs42l42.c
+++ b/sound/soc/intel/boards/sof_cs42l42.c
@@ -41,8 +41,13 @@
#define SOF_CS42L42_DAILINK_MASK (GENMASK(24, 10))
#define SOF_CS42L42_DAILINK(link1, link2, link3, link4, link5) \
((((link1) | ((link2) << 3) | ((link3) << 6) | ((link4) << 9) | ((link5) << 12)) << SOF_CS42L42_DAILINK_SHIFT) & SOF_CS42L42_DAILINK_MASK)
-#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(25)
-#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(26)
+#define SOF_BT_OFFLOAD_PRESENT BIT(25)
+#define SOF_CS42L42_SSP_BT_SHIFT 26
+#define SOF_CS42L42_SSP_BT_MASK (GENMASK(28, 26))
+#define SOF_CS42L42_SSP_BT(quirk) \
+ (((quirk) << SOF_CS42L42_SSP_BT_SHIFT) & SOF_CS42L42_SSP_BT_MASK)
+#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(29)
+#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(30)
enum {
LINK_NONE = 0,
@@ -50,6 +55,7 @@ enum {
LINK_SPK = 2,
LINK_DMIC = 3,
LINK_HDMI = 4,
+ LINK_BT = 5,
};
/* Default: SSP2 */
@@ -278,6 +284,13 @@ static struct snd_soc_dai_link_component dmic_component[] = {
}
};
+static struct snd_soc_dai_link_component dummy_component[] = {
+ {
+ .name = "snd-soc-dummy",
+ .dai_name = "snd-soc-dummy-dai",
+ }
+};
+
static int create_spk_amp_dai_links(struct device *dev,
struct snd_soc_dai_link *links,
struct snd_soc_dai_link_component *cpus,
@@ -467,9 +480,52 @@ static int create_hdmi_dai_links(struct device *dev,
return -ENOMEM;
}
+static int create_bt_offload_dai_links(struct device *dev,
+ struct snd_soc_dai_link *links,
+ struct snd_soc_dai_link_component *cpus,
+ int *id, int ssp_bt)
+{
+ int ret = 0;
+
+ /* bt offload */
+ if (!(sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT))
+ return 0;
+
+ links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT",
+ ssp_bt);
+ if (!links[*id].name)
+ goto devm_err;
+
+ links[*id].id = *id;
+ links[*id].codecs = dummy_component;
+ links[*id].num_codecs = ARRAY_SIZE(dummy_component);
+ links[*id].platforms = platform_component;
+ links[*id].num_platforms = ARRAY_SIZE(platform_component);
+
+ 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_bt);
+ if (!links[*id].cpus->dai_name)
+ goto devm_err;
+
+ (*id)++;
+
+ return 0;
+
+devm_err:
+ return ret;
+}
+
static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
int ssp_codec,
int ssp_amp,
+ int ssp_bt,
int dmic_be_num,
int hdmi_num)
{
@@ -522,6 +578,14 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
goto devm_err;
}
break;
+ case LINK_BT:
+ ret = create_bt_offload_dai_links(dev, links, cpus, &id, ssp_bt);
+ if (ret < 0) {
+ dev_err(dev, "fail to create bt offload dai links, ret %d\n",
+ ret);
+ goto devm_err;
+ }
+ break;
case LINK_NONE:
/* caught here if it's not used as terminator in macro */
default:
@@ -543,7 +607,7 @@ static int sof_audio_probe(struct platform_device *pdev)
struct snd_soc_acpi_mach *mach;
struct sof_card_private *ctx;
int dmic_be_num, hdmi_num;
- int ret, ssp_amp, ssp_codec;
+ int ret, ssp_bt, ssp_amp, ssp_codec;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
@@ -568,6 +632,9 @@ static int sof_audio_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "sof_cs42l42_quirk = %lx\n", sof_cs42l42_quirk);
+ ssp_bt = (sof_cs42l42_quirk & SOF_CS42L42_SSP_BT_MASK) >>
+ SOF_CS42L42_SSP_BT_SHIFT;
+
ssp_amp = (sof_cs42l42_quirk & SOF_CS42L42_SSP_AMP_MASK) >>
SOF_CS42L42_SSP_AMP_SHIFT;
@@ -578,9 +645,11 @@ static int sof_audio_probe(struct platform_device *pdev)
if (sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT)
sof_audio_card_cs42l42.num_links++;
+ if (sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT)
+ sof_audio_card_cs42l42.num_links++;
dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp,
- dmic_be_num, hdmi_num);
+ ssp_bt, dmic_be_num, hdmi_num);
if (!dai_links)
return -ENOMEM;
@@ -621,6 +690,17 @@ static const struct platform_device_id board_ids[] = {
SOF_CS42L42_SSP_AMP(1)) |
SOF_CS42L42_DAILINK(LINK_HP, LINK_DMIC, LINK_HDMI, LINK_SPK, LINK_NONE),
},
+ {
+ .name = "adl_mx98360a_cs4242",
+ .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_NUM_HDMIDEV(4) |
+ SOF_BT_OFFLOAD_PRESENT |
+ SOF_CS42L42_SSP_BT(2)) |
+ SOF_CS42L42_DAILINK(LINK_HP, LINK_DMIC, LINK_HDMI, LINK_SPK, LINK_BT),
+ },
{ }
};
MODULE_DEVICE_TABLE(platform, board_ids);
diff --git a/sound/soc/intel/common/soc-acpi-intel-adl-match.c b/sound/soc/intel/common/soc-acpi-intel-adl-match.c
index 7c8cd00457f81..3f40519250a90 100644
--- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c
@@ -384,6 +384,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
.sof_fw_filename = "sof-adl.ri",
.sof_tplg_filename = "sof-adl-cs35l41.tplg",
},
+ {
+ .id = "10134242",
+ .drv_name = "adl_mx98360a_cs4242",
+ .machine_quirk = snd_soc_acpi_codec_list,
+ .quirk_data = &adl_max98360a_amp,
+ .sof_fw_filename = "sof-adl.ri",
+ .sof_tplg_filename = "sof-adl-max98360a-rt5682.tplg",
+ },
{},
};
EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines);
--
2.31.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [v2] ASoC: Intel: sof_cs42l42: adding support for ADL configuration and BT offload audio
2022-05-10 10:48 [PATCH] [v2] ASoC: Intel: sof_cs42l42: adding support for ADL configuration and BT offload audio Terry Chen
@ 2022-05-10 14:40 ` Pierre-Louis Bossart
2022-05-11 6:49 ` Lu, Brent
[not found] ` <CAMmR3bFad5ODKYUCg8Tp8GVk__AdaQHcpLnRmFyAGXu8Wpycog@mail.gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Pierre-Louis Bossart @ 2022-05-10 14:40 UTC (permalink / raw)
To: Terry Chen, alsa-devel
Cc: cezary.rojewski, liam.r.girdwood, yang.jie, broonie, perex,
tiwai, brent.lu, cujomalainey, seanpaul, casey.g.bowman,
mark_hsieh, vamshi.krishna.gopal, mac.chiang, kai.vehmanen,
linux-kernel
> +static int create_bt_offload_dai_links(struct device *dev,
> + struct snd_soc_dai_link *links,
> + struct snd_soc_dai_link_component *cpus,
> + int *id, int ssp_bt)
> +{
> + int ret = 0;
this variable is not used in the rest of this function, something's not
right here...
> + /* bt offload */
> + if (!(sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT))
> + return 0;
> +
> + links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT",
> + ssp_bt);
> + if (!links[*id].name)
> + goto devm_err;
is this missing ret = -ENOMEM?
> +
> + links[*id].id = *id;
> + links[*id].codecs = dummy_component;
> + links[*id].num_codecs = ARRAY_SIZE(dummy_component);
> + links[*id].platforms = platform_component;
> + links[*id].num_platforms = ARRAY_SIZE(platform_component);
> +
> + 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_bt);
> + if (!links[*id].cpus->dai_name)
> + goto devm_err;
same here, ret = -ENOMEM; ?
> +
> + (*id)++;
> +
> + return 0;
> +
> +devm_err:
> + return ret;
or use what the existing code does for other links:
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 ssp_bt,
> int dmic_be_num,
> int hdmi_num)
> {
> @@ -522,6 +578,14 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
> goto devm_err;
> }
> break;
> + case LINK_BT:
> + ret = create_bt_offload_dai_links(dev, links, cpus, &id, ssp_bt);
> + if (ret < 0) {
> + dev_err(dev, "fail to create bt offload dai links, ret %d\n",
> + ret);
one line?
> + goto devm_err;
> + }
> + break;
> case LINK_NONE:
> /* caught here if it's not used as terminator in macro */
> default:
> @@ -543,7 +607,7 @@ static int sof_audio_probe(struct platform_device *pdev)
> struct snd_soc_acpi_mach *mach;
> struct sof_card_private *ctx;
> int dmic_be_num, hdmi_num;
> - int ret, ssp_amp, ssp_codec;
> + int ret, ssp_bt, ssp_amp, ssp_codec;
>
> ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
> if (!ctx)
> @@ -568,6 +632,9 @@ static int sof_audio_probe(struct platform_device *pdev)
>
> dev_dbg(&pdev->dev, "sof_cs42l42_quirk = %lx\n", sof_cs42l42_quirk);
>
> + ssp_bt = (sof_cs42l42_quirk & SOF_CS42L42_SSP_BT_MASK) >>
> + SOF_CS42L42_SSP_BT_SHIFT;
> +
> ssp_amp = (sof_cs42l42_quirk & SOF_CS42L42_SSP_AMP_MASK) >>
> SOF_CS42L42_SSP_AMP_SHIFT;
>
> @@ -578,9 +645,11 @@ static int sof_audio_probe(struct platform_device *pdev)
>
> if (sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT)
> sof_audio_card_cs42l42.num_links++;
> + if (sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT)
> + sof_audio_card_cs42l42.num_links++;
>
> dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp,
> - dmic_be_num, hdmi_num);
> + ssp_bt, dmic_be_num, hdmi_num);
> if (!dai_links)
> return -ENOMEM;
>
> @@ -621,6 +690,17 @@ static const struct platform_device_id board_ids[] = {
> SOF_CS42L42_SSP_AMP(1)) |
> SOF_CS42L42_DAILINK(LINK_HP, LINK_DMIC, LINK_HDMI, LINK_SPK, LINK_NONE),
> },
> + {
> + .name = "adl_mx98360a_cs4242",
> + .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_NUM_HDMIDEV(4) |
> + SOF_BT_OFFLOAD_PRESENT |
> + SOF_CS42L42_SSP_BT(2)) |
> + SOF_CS42L42_DAILINK(LINK_HP, LINK_DMIC, LINK_HDMI, LINK_SPK, LINK_BT),
> + },
> { }
> };
> MODULE_DEVICE_TABLE(platform, board_ids);
> diff --git a/sound/soc/intel/common/soc-acpi-intel-adl-match.c b/sound/soc/intel/common/soc-acpi-intel-adl-match.c
> index 7c8cd00457f81..3f40519250a90 100644
> --- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c
> +++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c
> @@ -384,6 +384,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
> .sof_fw_filename = "sof-adl.ri",
> .sof_tplg_filename = "sof-adl-cs35l41.tplg",
> },
> + {
> + .id = "10134242",
> + .drv_name = "adl_mx98360a_cs4242",
> + .machine_quirk = snd_soc_acpi_codec_list,
> + .quirk_data = &adl_max98360a_amp,
> + .sof_fw_filename = "sof-adl.ri",
no longer necessary, and probably will not compile. please remove this
field.
> + .sof_tplg_filename = "sof-adl-max98360a-rt5682.tplg",
Why would you refer to a topology that uses a different codec?
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] [v2] ASoC: Intel: sof_cs42l42: adding support for ADL configuration and BT offload audio
2022-05-10 14:40 ` Pierre-Louis Bossart
@ 2022-05-11 6:49 ` Lu, Brent
[not found] ` <CAMmR3bFad5ODKYUCg8Tp8GVk__AdaQHcpLnRmFyAGXu8Wpycog@mail.gmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: Lu, Brent @ 2022-05-11 6:49 UTC (permalink / raw)
To: Pierre-Louis Bossart, Terry Chen, alsa-devel
Cc: Rojewski, Cezary, liam.r.girdwood, yang.jie, broonie, perex,
tiwai, cujomalainey, seanpaul, Bowman, Casey G, mark_hsieh,
Gopal, Vamshi Krishna, Chiang, Mac, kai.vehmanen, linux-kernel
> > a/sound/soc/intel/common/soc-acpi-intel-adl-match.c
> > b/sound/soc/intel/common/soc-acpi-intel-adl-match.c
> > index 7c8cd00457f81..3f40519250a90 100644
> > --- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c
> > +++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c
> > @@ -384,6 +384,14 @@ struct snd_soc_acpi_mach
> snd_soc_acpi_intel_adl_machines[] = {
> > .sof_fw_filename = "sof-adl.ri",
> > .sof_tplg_filename = "sof-adl-cs35l41.tplg",
> > },
> > + {
> > + .id = "10134242",
> > + .drv_name = "adl_mx98360a_cs4242",
> > + .machine_quirk = snd_soc_acpi_codec_list,
> > + .quirk_data = &adl_max98360a_amp,
> > + .sof_fw_filename = "sof-adl.ri",
>
> no longer necessary, and probably will not compile. please remove this field.
>
> > + .sof_tplg_filename = "sof-adl-max98360a-rt5682.tplg",
>
> Why would you refer to a topology that uses a different codec?
>
We asked cirrus logic to support bclk 2.4MHz, 50fs so all topologies for alc5682 could
be used directly.
Brent
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CAMmR3bFad5ODKYUCg8Tp8GVk__AdaQHcpLnRmFyAGXu8Wpycog@mail.gmail.com>]
* Re: [PATCH] [v2] ASoC: Intel: sof_cs42l42: adding support for ADL configuration and BT offload audio
[not found] ` <CAMmR3bFad5ODKYUCg8Tp8GVk__AdaQHcpLnRmFyAGXu8Wpycog@mail.gmail.com>
@ 2022-05-11 14:02 ` Pierre-Louis Bossart
0 siblings, 0 replies; 4+ messages in thread
From: Pierre-Louis Bossart @ 2022-05-11 14:02 UTC (permalink / raw)
To: Terry Chen
Cc: alsa-devel, cezary.rojewski, liam.r.girdwood, yang.jie, broonie,
perex, tiwai, brent.lu, cujomalainey, Sean Paul, casey.g.bowman,
Mark Hsieh, vamshi.krishna.gopal, Mac Chiang, kai.vehmanen,
linux-kernel
On 5/11/22 01:33, Terry Chen wrote:
> Hi Pierre-Louis
>
>> @@ -522,6 +578,14 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
>> goto devm_err;
>> }
>> break;
>> + case LINK_BT:
>> + ret = create_bt_offload_dai_links(dev, links, cpus, &id, ssp_bt);
>> + if (ret < 0) {
>> + dev_err(dev, "fail to create bt offload dai links, ret %d\n",
>> + ret);
>
> For this point, we just follow Intel member to write for this coding
> style. The other component also was the same style.
the magic of copy-paste, eh? Please update this, thanks.
> > @@ -384,6 +384,14 @@ struct snd_soc_acpi_mach
> snd_soc_acpi_intel_adl_machines[] = {
> > .sof_fw_filename = "sof-adl.ri",
> > .sof_tplg_filename = "sof-adl-cs35l41.tplg",
> > },
> > + {
> > + .id = "10134242",
> > + .drv_name = "adl_mx98360a_cs4242",
> > + .machine_quirk = snd_soc_acpi_codec_list,
> > + .quirk_data = &adl_max98360a_amp,
> > + .sof_fw_filename = "sof-adl.ri",
>
> This also was the same style with others.
No, it's not a matter of style but rather that this field was *REMOVED*,
this cannot possibly compile.
see commit a6264056b39ee ("ASoC: soc-acpi: remove sof_fw_filename
")
If you had submitted this patch through the SOF tree, you would have
seen a compilation error.
>
> > + .sof_tplg_filename = "sof-adl-max98360a-rt5682.tplg",
>
> Why would you refer to a topology that uses a different codec?
>
>
> Because Intel college use the same naming style for the same audio codec.
It's bad practice to use the same topology name for different platforms
based on different codecs. One evolution of the topology would impact an
unrelated platform. Please use a symlink or duplicate the topology with
a different name, this is not future-proof and will be problematic for
releases.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-11 14:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 10:48 [PATCH] [v2] ASoC: Intel: sof_cs42l42: adding support for ADL configuration and BT offload audio Terry Chen
2022-05-10 14:40 ` Pierre-Louis Bossart
2022-05-11 6:49 ` Lu, Brent
[not found] ` <CAMmR3bFad5ODKYUCg8Tp8GVk__AdaQHcpLnRmFyAGXu8Wpycog@mail.gmail.com>
2022-05-11 14:02 ` Pierre-Louis Bossart
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).