Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALSA/ASoC: hdac_hda: hdmi: Avoid duplicated dai registration - take 2 #4659

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/sound/hdaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ bool snd_hdac_check_power_state(struct hdac_device *hdac,
hda_nid_t nid, unsigned int target_state);
unsigned int snd_hdac_sync_power_state(struct hdac_device *hdac,
hda_nid_t nid, unsigned int target_state);

#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
bool snd_hda_device_is_hdmi(struct hdac_device *hdev);
#else
static inline bool snd_hda_device_is_hdmi(struct hdac_device *hdev)
{
return false;
}
#endif

/**
* snd_hdac_read_parm - read a codec parameter
* @codec: the codec object
Expand Down
13 changes: 13 additions & 0 deletions sound/pci/hda/patch_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4645,6 +4645,19 @@ HDA_CODEC_ENTRY(HDA_CODEC_ID_GENERIC_HDMI, "Generic HDMI", patch_generic_hdmi),
};
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_hdmi);

bool snd_hda_device_is_hdmi(struct hdac_device *hdev)
{
int i;

for (i = 0; i < ARRAY_SIZE(snd_hda_id_hdmi); i++) {
if (snd_hda_id_hdmi[i].vendor_id == hdev->vendor_id)
return true;
}

return false;
}
EXPORT_SYMBOL_GPL(snd_hda_device_is_hdmi);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("HDMI HD-audio codec");
MODULE_ALIAS("snd-hda-codec-intelhdmi");
Expand Down
22 changes: 19 additions & 3 deletions sound/soc/codecs/hdac_hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ static struct snd_soc_dai_driver hdac_hda_dais[] = {
.sig_bits = 24,
},
},
};

static struct snd_soc_dai_driver hdac_hda_hdmi_dais[] = {
{
.id = HDAC_HDMI_0_DAI_ID,
.name = "intel-hdmi-hifi1",
Expand Down Expand Up @@ -607,6 +610,13 @@ static const struct snd_soc_component_driver hdac_hda_codec = {
.endianness = 1,
};

static const struct snd_soc_component_driver hdac_hda_hdmi_codec = {
.probe = hdac_hda_codec_probe,
.remove = hdac_hda_codec_remove,
.idle_bias_on = false,
.endianness = 1,
};

static int hdac_hda_dev_probe(struct hdac_device *hdev)
{
struct hdac_ext_link *hlink;
Expand All @@ -621,9 +631,15 @@ static int hdac_hda_dev_probe(struct hdac_device *hdev)
snd_hdac_ext_bus_link_get(hdev->bus, hlink);

/* ASoC specific initialization */
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))
ret = devm_snd_soc_register_component(&hdev->dev,
&hdac_hda_hdmi_codec, hdac_hda_hdmi_dais,
ARRAY_SIZE(hdac_hda_hdmi_dais));
else
ret = devm_snd_soc_register_component(&hdev->dev,
&hdac_hda_codec, hdac_hda_dais,
ARRAY_SIZE(hdac_hda_dais));

if (ret < 0) {
dev_err(&hdev->dev, "failed to register HDA codec %d\n", ret);
return ret;
Expand Down