On 10/28/21 1:19 AM, Mac Chiang wrote:
From: David Lin CTLIN0@nuvoton.com
The machine driver is a generic machine driver for SOF with nau8825 codec w or w/o speaker additionally. Depending on the SOC HDMI, DMIC, Bluetooth offload support are added dynamically.
Only add information related to SOF since the machine driver was only tested with SOF.
There are currently 4 i2s machine variants of ADL. This supports the headphone NUA8825(SSP0) alone or with smart or dumb speakers. Board 2,3,4 use SSP2 for Bluetooth offload support except board 1.
Board 1 : NAU8825 + RT1019P(SSP2) Board 2 : NAU8825 + MAX98373(SSP1) Board 3 : NAU8825 + MAX98360A(SSP1) Board 4 : NAU8825
Signed-off-by: David Lin CTLIN0@nuvoton.com Co-developed-by: Mac Chiang mac.chiang@intel.com Signed-off-by: Mac Chiang mac.chiang@intel.com
The code looks mostly good, just a couple of minor things to update, see below
+struct sof_card_private {
- struct clk *mclk;
- struct snd_soc_jack sof_headset;
- struct list_head hdmi_pcm_list;
- bool common_hdmi_codec_drv;
we no longer need this 'common_hdmi_codec_drv' for new drivers, this was a transition step that we've removed for newer machine drivers.
Please look at the sof_es8336 example.
+static int sof_card_late_probe(struct snd_soc_card *card) +{
- struct sof_card_private *ctx = snd_soc_card_get_drvdata(card);
- struct snd_soc_component *component = NULL;
- struct snd_soc_dapm_context *dapm = &card->dapm;
- char jack_name[NAME_SIZE];
- struct sof_hdmi_pcm *pcm;
- int err;
- int i = 0;
- if (list_empty(&ctx->hdmi_pcm_list))
return -EINVAL;
- if (ctx->common_hdmi_codec_drv) {
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm,
head);
component = pcm->codec_dai->component;
return hda_dsp_hdmi_build_controls(card, component);
- }
no longer needed.
- /* speaker amp */
- if (sof_nau8825_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;
links[id].id = id;
if (sof_nau8825_quirk & SOF_RT1019P_SPEAKER_AMP_PRESENT) {
links[id].codecs = rt1019p_component;
links[id].num_codecs = ARRAY_SIZE(rt1019p_component);
links[id].init = speaker_codec_init;
} else if (sof_nau8825_quirk &
SOF_MAX98373_SPEAKER_AMP_PRESENT) {
links[id].codecs = max_98373_components;
links[id].num_codecs = ARRAY_SIZE(max_98373_components);
links[id].init = max_98373_spk_codec_init;
links[id].ops = &max_98373_ops;
/* feedback stream */
links[id].dpcm_capture = 1;
} else if (sof_nau8825_quirk &
SOF_MAX98360A_SPEAKER_AMP_PRESENT) {
max_98360a_dai_link(&links[id]);
} else {
max_98360a_dai_link(&links[id]);
}
cppcheck complains that the two last branches are identical.
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;
id++;
- }
- /* BT audio offload */
- if (sof_nau8825_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) {
int port = (sof_nau8825_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
SOF_BT_OFFLOAD_SSP_SHIFT;
links[id].id = id;
links[id].cpus = &cpus[id];
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
"SSP%d Pin", port);
if (!links[id].cpus->dai_name)
goto devm_err;
links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port);
if (!links[id].name)
goto devm_err;
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].num_cpus = 1;
- }
- return links;
+devm_err:
- return NULL;
+}
[...]
- /* set platform name for each dailink */
- ret = snd_soc_fixup_dai_links_platform_name(&sof_audio_card_nau8825,
mach->mach_params.platform);
- if (ret)
return ret;
- ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
not needed.
- snd_soc_card_set_drvdata(&sof_audio_card_nau8825, ctx);
- return devm_snd_soc_register_card(&pdev->dev,
&sof_audio_card_nau8825);
+}
+MODULE_AUTHOR("Mac Chiang mac.chiang@intel.com"); +MODULE_LICENSE("GPL v2");
"GPL"