Skip to content
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
1 change: 1 addition & 0 deletions include/sound/soc-acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct snd_soc_acpi_mach_params {
u32 acpi_ipc_irq_index;
const char *platform;
u32 codec_mask;
u32 dmic_num;
};

/**
Expand Down
10 changes: 5 additions & 5 deletions sound/soc/intel/boards/kbl_rt5663_max98927.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include "../../codecs/rt5663.h"
#include "../../codecs/hdac_hdmi.h"
#include "../skylake/skl.h"
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/clkdev.h>
Expand Down Expand Up @@ -969,7 +969,7 @@ static struct snd_soc_card kabylake_audio_card_rt5663 = {
static int kabylake_audio_probe(struct platform_device *pdev)
{
struct kbl_rt5663_private *ctx;
struct skl_machine_pdata *pdata;
struct snd_soc_acpi_mach *mach;
int ret;

ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
Expand All @@ -984,9 +984,9 @@ static int kabylake_audio_probe(struct platform_device *pdev)
kabylake_audio_card->dev = &pdev->dev;
snd_soc_card_set_drvdata(kabylake_audio_card, ctx);

pdata = dev_get_drvdata(&pdev->dev);
if (pdata)
dmic_constraints = pdata->dmic_num == 2 ?
mach = (&pdev->dev)->platform_data;
if (mach)
dmic_constraints = mach->mach_params.dmic_num == 2 ?
&constraints_dmic_2ch : &constraints_dmic_channels;

ctx->mclk = devm_clk_get(&pdev->dev, "ssp1_mclk");
Expand Down
10 changes: 5 additions & 5 deletions sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include "../../codecs/rt5514.h"
#include "../../codecs/rt5663.h"
#include "../../codecs/hdac_hdmi.h"
#include "../skylake/skl.h"

#define KBL_REALTEK_CODEC_DAI "rt5663-aif"
#define KBL_REALTEK_DMIC_CODEC_DAI "rt5514-aif1"
Expand Down Expand Up @@ -648,7 +648,7 @@ static struct snd_soc_card kabylake_audio_card = {
static int kabylake_audio_probe(struct platform_device *pdev)
{
struct kbl_codec_private *ctx;
struct skl_machine_pdata *pdata;
struct snd_soc_acpi_mach *mach;

ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
Expand All @@ -659,9 +659,9 @@ static int kabylake_audio_probe(struct platform_device *pdev)
kabylake_audio_card.dev = &pdev->dev;
snd_soc_card_set_drvdata(&kabylake_audio_card, ctx);

pdata = dev_get_drvdata(&pdev->dev);
if (pdata)
dmic_constraints = pdata->dmic_num == 2 ?
mach = (&pdev->dev)->platform_data;
if (mach)
dmic_constraints = mach->mach_params.dmic_num == 2 ?
&constraints_dmic_2ch : &constraints_dmic_channels;

return devm_snd_soc_register_card(&pdev->dev, &kabylake_audio_card);
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/intel/boards/skl_hda_dsp_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static int skl_hda_audio_probe(struct platform_device *pdev)

INIT_LIST_HEAD(&ctx->hdmi_pcm_list);

mach = dev_get_drvdata(&pdev->dev);
mach = (&pdev->dev)->platform_data;
if (!mach)
return -EINVAL;

Expand Down
10 changes: 5 additions & 5 deletions sound/soc/intel/boards/skl_nau88l25_max98357a.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include "../../codecs/nau8825.h"
#include "../../codecs/hdac_hdmi.h"
#include "../skylake/skl.h"

#define SKL_NUVOTON_CODEC_DAI "nau8825-hifi"
#define SKL_MAXIM_CODEC_DAI "HiFi"
Expand Down Expand Up @@ -641,7 +641,7 @@ static struct snd_soc_card skylake_audio_card = {
static int skylake_audio_probe(struct platform_device *pdev)
{
struct skl_nau8825_private *ctx;
struct skl_machine_pdata *pdata;
struct snd_soc_acpi_mach *mach;

ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
Expand All @@ -652,9 +652,9 @@ static int skylake_audio_probe(struct platform_device *pdev)
skylake_audio_card.dev = &pdev->dev;
snd_soc_card_set_drvdata(&skylake_audio_card, ctx);

pdata = dev_get_drvdata(&pdev->dev);
if (pdata)
dmic_constraints = pdata->dmic_num == 2 ?
mach = (&pdev->dev)->platform_data;
if (mach)
dmic_constraints = mach->mach_params.dmic_num == 2 ?
&constraints_dmic_2ch : &constraints_dmic_channels;

return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card);
Expand Down
10 changes: 5 additions & 5 deletions sound/soc/intel/boards/skl_nau88l25_ssm4567.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include <sound/jack.h>
#include <sound/pcm_params.h>
#include "../../codecs/nau8825.h"
#include "../../codecs/hdac_hdmi.h"
#include "../skylake/skl.h"

#define SKL_NUVOTON_CODEC_DAI "nau8825-hifi"
#define SKL_SSM_CODEC_DAI "ssm4567-hifi"
Expand Down Expand Up @@ -694,7 +694,7 @@ static struct snd_soc_card skylake_audio_card = {
static int skylake_audio_probe(struct platform_device *pdev)
{
struct skl_nau88125_private *ctx;
struct skl_machine_pdata *pdata;
struct snd_soc_acpi_mach *mach;

ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
Expand All @@ -705,9 +705,9 @@ static int skylake_audio_probe(struct platform_device *pdev)
skylake_audio_card.dev = &pdev->dev;
snd_soc_card_set_drvdata(&skylake_audio_card, ctx);

pdata = dev_get_drvdata(&pdev->dev);
if (pdata)
dmic_constraints = pdata->dmic_num == 2 ?
mach = (&pdev->dev)->platform_data;
if (mach)
dmic_constraints = mach->mach_params.dmic_num == 2 ?
&constraints_dmic_2ch : &constraints_dmic_channels;

return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card);
Expand Down
15 changes: 11 additions & 4 deletions sound/soc/intel/skylake/skl.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ static int skl_find_machine(struct skl *skl, void *driver_data)

if (pdata) {
skl->use_tplg_pcm = pdata->use_tplg_pcm;
pdata->dmic_num = skl_get_dmic_geo(skl);
mach->mach_params.dmic_num = skl_get_dmic_geo(skl);
}

return 0;
Expand All @@ -534,16 +534,23 @@ static int skl_machine_device_register(struct skl *skl)
return -EIO;
}

mach->mach_params.platform = dev_name(bus->dev);
mach->mach_params.codec_mask = bus->codec_mask;

ret = platform_device_add_data(pdev, (const void *)mach, sizeof(*mach));
if (ret) {
dev_err(bus->dev, "failed to add machine device platform data\n");
platform_device_put(pdev);
return ret;
}

ret = platform_device_add(pdev);
if (ret) {
dev_err(bus->dev, "failed to add machine device\n");
platform_device_put(pdev);
return -EIO;
}

mach->mach_params.platform = dev_name(bus->dev);
mach->mach_params.codec_mask = bus->codec_mask;
dev_set_drvdata(&pdev->dev, mach);

skl->i2s_dev = pdev;

Expand Down
3 changes: 0 additions & 3 deletions sound/soc/intel/skylake/skl.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ struct skl_dma_params {
};

struct skl_machine_pdata {
u32 dmic_num;
bool use_tplg_pcm; /* use dais and dai links from topology */
const char *platform;
unsigned long codec_mask;
};

struct skl_dsp_ops {
Expand Down
10 changes: 8 additions & 2 deletions sound/soc/soc-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ struct snd_soc_acpi_mach *
snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines)
{
struct snd_soc_acpi_mach *mach;
struct snd_soc_acpi_mach *mach_alt;

for (mach = machines; mach->id[0]; mach++) {
if (acpi_dev_present(mach->id, NULL, -1)) {
if (mach->machine_quirk)
mach = mach->machine_quirk(mach);
if (mach->machine_quirk) {
mach_alt = mach->machine_quirk(mach);
if (!mach_alt)
continue; /* not full match, ignore */
mach = mach_alt;
}

return mach;
}
}
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ static int sof_probe(struct platform_device *pdev)
plat_data->machine->new_mach_data(plat_data);
} else {

@ranj063 ranj063 Nov 14, 2018

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.

@plbossart sorry to ask a very basic question here( for my benefit)
Why do we have the new_mach_data at all? Maybe I missed something but as far as I could tell, it is only set for Baytrail to be mfld_new_mach_data and this function seems to be doing exactly what we do in the else part below. Sorry again if I missed something obvious here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@ranj063 it's not obvious to me either, one of those things that only Keyon and Liam understand.

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.

@keyonjie @lgirdwood could you please shed some light on this? Thanks!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this was added by Liam to make it compatible to byt/cht sst driver, @lgirdwood can you confirm if we can discard this part and remove *new_data from struct sof_ops_table ?

drv_name = plat_data->machine->drv_name;
mach = (const void *)plat_data;
size = sizeof(*plat_data);
mach = (const void *)plat_data->machine;
size = sizeof(*plat_data->machine);

/* register machine driver, pass machine info as pdata */
plat_data->pdev_mach =
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/sof/intel/hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
/* codec detection */
if (!bus->codec_mask)
dev_info(bus->dev, "no hda codecs found!\n");
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 *)
Expand Down
22 changes: 16 additions & 6 deletions sound/soc/sof/sof-pci-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,31 @@ static int sof_pci_probe(struct pci_dev *pci,
#else
/* find machine */
mach = snd_soc_acpi_find_machine(desc->machines);
#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 */
Comment thread
plbossart marked this conversation as resolved.
Outdated
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)
goto release_regions;
#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
}
#endif
#endif /* CONFIG_SND_SOC_SOF_NOCODEC */

#endif /* CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE */

mach->pdata = ops;

Expand Down