Skip to content

ALSA/ASoC: hdac_hda: hdmi: Avoid duplicated dai registration - #4620

Merged
plbossart merged 2 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/hdac-hda-conditional-dais-01
Oct 10, 2023
Merged

plbossart merged 2 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/hdac-hda-conditional-dais-01

Conversation

@ujfalusi

@ujfalusi ujfalusi commented Oct 6, 2023

Copy link
Copy Markdown
Collaborator

Hi,

in the kernel log we always have warnings like these printed regardless of the platform:

snd_hda_codec_realtek ehdaudio0D0: ASoC: sink widget AIF1TX overwritten
snd_hda_codec_realtek ehdaudio0D0: ASoC: source widget AIF1RX overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget hifi3 overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget hifi2 overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget hifi1 overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Codec Output Pin1 overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Codec Input Pin1 overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Analog Codec Playback overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Digital Codec Playback overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Alt Analog Codec Playback overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Analog Codec Capture overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Digital Codec Capture overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Alt Analog Codec Capture overwritten

The reason is that the hdac_hda driver registers the dais multiple time for each hdev, thus we end up with duplicated widgets.

This PR fixes the issue by conditionally registering the dais for HDMI and not HDMI hdev.

Partially addresses #4509, the ASoC: Parent card not yet available, widget card binding deferred print cannot be 'fixed', it is part of the normal flow. We could try to lover the log level of that print to silence it in enduser machines.

The snd_hda_device_is_hdmi() can be used in drivers to check if the hdev
belongs to a display audio device.

Signed-off-by: Peter Ujfalusi <[email protected]>
The current driver is registering the same dais for each hdev found in the
system which results duplicated widgets to be registered and the kernel
log contains similar prints:
snd_hda_codec_realtek ehdaudio0D0: ASoC: sink widget AIF1TX overwritten
snd_hda_codec_realtek ehdaudio0D0: ASoC: source widget AIF1RX overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget hifi3 overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget hifi2 overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget hifi1 overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Codec Output Pin1 overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Codec Input Pin1 overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Analog Codec Playback overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Digital Codec Playback overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Alt Analog Codec Playback overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Analog Codec Capture overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Digital Codec Capture overwritten
skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Alt Analog Codec Capture overwritten

To avoid such issue, split the dai array into HDMI and non HDMI array and
register them conditionally:
for HDMI hdev only register the dais needed for HDMI
for non HDMI hdev do not  register the HDMI dais.

Link: thesofproject#4509
Signed-off-by: Peter Ujfalusi <[email protected]>
@ujfalusi
ujfalusi force-pushed the peter/sof/pr/hdac-hda-conditional-dais-01 branch from 415123f to 778999d Compare October 6, 2023 12:20
@ujfalusi

ujfalusi commented Oct 6, 2023

Copy link
Copy Markdown
Collaborator Author

Changes since v1:

  • the nocodec config have CONFIG_SND_SOC_HDAC_HDA=m with CONFIG_SND_HDA_CODEC_HDMI=n, ugly fix for now to get the PR to run on the devices

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is actually problem caused by me originally, so thank you @ujfalusi for the fix!

ret = devm_snd_soc_register_component(&hdev->dev,
&hdac_hda_codec, hdac_hda_dais,
ARRAY_SIZE(hdac_hda_dais));
if (snd_hda_device_is_hdmi(hdev))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, "if (hdev->addr == HDA_IDISP_ADDR)" would be an option, but I think for codec in soc/codecs/ , this is actually nicer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is Intel only, (AMD's HDMI is addr=0 in some cases for example).

I'm looking at a different method, something like this:
hcodec = hdac_to_hda_codec(hdac);
and from there try to find some way. So far no leads in there.
There is a guessing local function in hda_bind.c: is_likely_hdmi_codec() but that might be even more questionable.

I'll try to find a better way or make this a bit nicer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify: I'm not sure about addr == 2, I just only saw it in code for Intel platforms, it might be universal HDA convention, but I'm not certain if it is correct or not

@plbossart
plbossart merged commit a2d0f50 into thesofproject:topic/sof-dev Oct 10, 2023
@ujfalusi
ujfalusi deleted the peter/sof/pr/hdac-hda-conditional-dais-01 branch October 24, 2023 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants