-
Notifications
You must be signed in to change notification settings - Fork 140
ASoC: SOF: refine the selection of machine drivers #321
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| #include <sound/hdaudio.h> | ||
| #include <sound/hda_i915.h> | ||
| #include <sound/sof/xtensa.h> | ||
| #include <sound/soc-acpi-intel-match.h> | ||
|
|
||
| #include "../sof-priv.h" | ||
| #include "../ops.h" | ||
|
|
@@ -438,8 +439,11 @@ static int hda_init_caps(struct snd_sof_dev *sdev) | |
| struct pci_dev *pci = sdev->pci; | ||
| struct hdac_ext_link *hlink = NULL; | ||
| struct snd_soc_acpi_mach_params *mach_params; | ||
| struct snd_soc_acpi_mach *mach; | ||
| struct snd_sof_pdata *pdata; | ||
| int codec_num = 0; | ||
| int ret = 0; | ||
| int err; | ||
| int err, i; | ||
|
|
||
| device_disable_async_suspend(bus->dev); | ||
|
|
||
|
|
@@ -472,10 +476,37 @@ static int hda_init_caps(struct snd_sof_dev *sdev) | |
| else | ||
| dev_info(bus->dev, "hda codecs found, mask %lx!\n", bus->codec_mask); | ||
|
|
||
| /* used by hda machine driver to create dai links */ | ||
| mach_params = (struct snd_soc_acpi_mach_params *) | ||
| &sdev->pdata->machine->mach_params; | ||
| mach_params->codec_mask = bus->codec_mask; | ||
| if (bus->codec_mask) { | ||
| for (i = 0; i < HDA_MAX_CODECS; i++) { | ||
| if (bus->codec_mask & (1 << i)) | ||
| codec_num++; | ||
| } | ||
|
|
||
| /* if there are HDMI codec and HDA codecs, hda machine | ||
| * is applied. For I2S codec + HDMI codec, there is only one | ||
| * hda codec. For other cases, the value should be zero. | ||
| */ | ||
| if (codec_num > 1) { | ||
| /* used by hda machine driver to create dai links */ | ||
| pdata = sdev->pdata; | ||
|
|
||
| mach = snd_soc_acpi_intel_hda_machines; | ||
| mach->pdata = pdata->machine->pdata; | ||
| mach->sof_fw_filename = | ||
| pdata->desc->nocodec_fw_filename; | ||
| mach->new_mach_data = | ||
| pdata->machine->new_mach_data; | ||
|
|
||
| mach_params = &mach->mach_params; | ||
| mach_params->codec_mask = bus->codec_mask; | ||
| mach_params->platform = pdata->platform; | ||
|
|
||
| devm_kfree(sdev->dev, (void *)pdata->machine); | ||
| pdata->machine = mach; | ||
|
|
||
| dev_info(sdev->dev, "Find hda codecs, use hda machine driver\n"); | ||
| } | ||
|
||
| } | ||
|
|
||
| /* create codec instances */ | ||
| hda_codec_probe_bus(sdev); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -224,18 +224,12 @@ static int sof_acpi_probe(struct platform_device *pdev) | |
| /* find machine */ | ||
| mach = snd_soc_acpi_find_machine(desc->machines); | ||
| if (!mach) { | ||
| #if IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC) | ||
| /* fallback to nocodec mode */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are you changing this? This has nothing to do with HDaudio?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, but you need to add If I don't delete it, it should be selected for HDaudio, or pci_probe or acpic_probe will quit with error. And CONFIG_SND_SOC_SOF_NOCODEC has nothing to do with HDaudio, so it is by no means to keep it here. |
||
| dev_warn(dev, "No matching ASoC machine driver found - using nocodec\n"); | ||
| mach = devm_kzalloc(dev, sizeof(*mach), GFP_KERNEL); | ||
| ret = sof_nocodec_setup(dev, sof_pdata, mach, desc, ops); | ||
| if (ret < 0) | ||
| return ret; | ||
| #else | ||
| dev_warn(dev, "No matching ASoC machine driver found - falling back to HDA codec\n"); | ||
| mach = snd_soc_acpi_intel_hda_machines; | ||
| mach->sof_fw_filename = desc->nocodec_fw_filename; | ||
| #endif | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that was a bug though, not sure why we had HDaudio codec mentioned in that file. |
||
| } | ||
| #endif | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,20 +222,6 @@ static int sof_pci_probe(struct pci_dev *pci, | |
| #else | ||
| /* find machine */ | ||
| mach = snd_soc_acpi_find_machine(desc->machines); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get the flow here. For HDaudio this will fail, so how do you not end-up in the error case. Does this even work?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For HDaudio, nocodec is setup here. in sof_probe, if hd codec is detected , HDaudio machine driver would be applied. platform driver is registered after HDaudio machine driver is applied. I test it on WHL, it works.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @plbossart , I will wait for your PR to be merged and do it based on it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RanderWang Is this clearer?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @plbossart Please forgive me about my English, I should improve it. This is my idea, I am sure is not wrong. I will close my PR |
||
| #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) | ||
| if (!mach) { | ||
| dev_warn(dev, "No matching ASoC machine driver found - falling back to HDA codec\n"); | ||
| mach = snd_soc_acpi_intel_hda_machines; | ||
| mach->sof_fw_filename = desc->nocodec_fw_filename; | ||
|
|
||
| /* | ||
| * TODO: we need to find a way to check if codecs are actually | ||
| * present | ||
| */ | ||
| } | ||
| #endif /* CONFIG_SND_SOC_SOF_HDA */ | ||
|
|
||
| #if IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC) | ||
| if (!mach) { | ||
| /* fallback to nocodec mode */ | ||
| dev_warn(dev, "No matching ASoC machine driver found - using nocodec\n"); | ||
|
|
@@ -244,8 +230,6 @@ static int sof_pci_probe(struct pci_dev *pci, | |
| if (ret < 0) | ||
| goto release_regions; | ||
| } | ||
| #endif /* CONFIG_SND_SOC_SOF_NOCODEC */ | ||
|
|
||
| #endif /* CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE */ | ||
|
|
||
| mach->pdata = ops; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is wrong. Is there is a single codec, the skl_hda_generic_machine driver can work
this should be codec_num > 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, one case