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
4 changes: 4 additions & 0 deletions include/sound/sof.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct snd_sof_pdata {
const struct firmware *fw;
const char *drv_name;
const char *name;
const char *platform;

/* parent device */
struct device *dev;
Expand All @@ -59,6 +60,9 @@ struct snd_sof_pdata {
unsigned int gpio;
unsigned int active;

/* hda codec */
unsigned long codec_mask;

/* machine */
struct platform_device *pdev_mach;
union {
Expand Down
7 changes: 5 additions & 2 deletions sound/soc/intel/boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ config SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH
create an alsa sound card for DA7219 + MAX98357A I2S audio codec.
Say Y if you have such a device.

endif ## SND_SOC_INTEL_SKYLAKE

if SND_SOC_INTEL_SKYLAKE || SND_SOC_SOF_HDA

Choose a reason for hiding this comment

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

better to use SND_SOC_SOF_HDA

Copy link
Author

Choose a reason for hiding this comment

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

get it

config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH
tristate "SKL/KBL/BXT/APL with HDA Codecs"
select SND_SOC_HDAC_HDMI
Expand All @@ -335,8 +339,7 @@ config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH
SKL/KBL/BXT/APL with iDisp, HDA audio codecs.
Say Y or m if you have such a device. This is a recommended option.
If unsure select "N".

endif ## SND_SOC_INTEL_SKYLAKE
endif ## SND_SOC_INTEL_SKYLAKE || SND_SOC_SOF_HDA

if SND_SOC_INTEL_SKYLAKE || SND_SOC_SOF_CANNONLAKE

Expand Down
21 changes: 13 additions & 8 deletions sound/soc/intel/boards/skl_hda_dsp_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/sof.h>
#include "../../codecs/hdac_hdmi.h"
#include "../skylake/skl.h"
#include "skl_hda_dsp_common.h"
Expand Down Expand Up @@ -101,16 +102,16 @@ static struct snd_soc_card hda_soc_card = {
#define IDISP_ROUTE_COUNT (IDISP_DAI_COUNT * 2)
#define IDISP_CODEC_MASK 0x4

static int skl_hda_fill_card_info(struct skl_machine_pdata *pdata)
static int skl_hda_fill_card_info(const char *platform,
unsigned long codec_mask)
{
struct snd_soc_card *card = &hda_soc_card;
u32 codec_count, codec_mask;
u32 codec_count;
int i, num_links, num_route;

codec_mask = pdata->codec_mask;
codec_count = hweight_long(codec_mask);

if (codec_count == 1 && pdata->codec_mask & IDISP_CODEC_MASK) {
if (codec_count == 1 && codec_mask & IDISP_CODEC_MASK) {
num_links = IDISP_DAI_COUNT;
num_route = IDISP_ROUTE_COUNT;
} else if (codec_count == 2 && codec_mask & IDISP_CODEC_MASK) {
Expand All @@ -126,17 +127,22 @@ static int skl_hda_fill_card_info(struct skl_machine_pdata *pdata)
card->num_dapm_routes = num_route;

for (i = 0; i < num_links; i++)
skl_hda_be_dai_links[i].platform_name = pdata->platform;
skl_hda_be_dai_links[i].platform_name = platform;

return 0;
}

static int skl_hda_audio_probe(struct platform_device *pdev)
{
struct skl_machine_pdata *pdata;
struct skl_hda_private *ctx;
int ret;

#if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL)
struct snd_sof_pdata *pdata = dev_get_platdata(&pdev->dev);
#else
struct skl_machine_pdata *pdata = dev_get_drvdata(&pdev->dev);
#endif

dev_dbg(&pdev->dev, "%s: entry\n", __func__);

ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
Expand All @@ -145,11 +151,10 @@ static int skl_hda_audio_probe(struct platform_device *pdev)

INIT_LIST_HEAD(&ctx->hdmi_pcm_list);

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

ret = skl_hda_fill_card_info(pdata);
ret = skl_hda_fill_card_info(pdata->platform, pdata->codec_mask);
if (ret < 0) {
dev_err(&pdev->dev, "Unsupported HDAudio/iDisp configuration found\n");
return ret;
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/intel/skylake/skl.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct skl_machine_pdata {
u32 dmic_num;
bool use_tplg_pcm; /* use dais and dai links from topology */
const char *platform;
u32 codec_mask;
unsigned long codec_mask;
};

struct skl_dsp_ops {
Expand Down
14 changes: 14 additions & 0 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@ static int sof_probe(struct platform_device *pdev)
goto comp_err;
}

/* register machine driver */
plat_data->pdev_mach =
platform_device_register_data(sdev->dev,
plat_data->machine->drv_name,
-1, plat_data,
sizeof(*plat_data));
if (IS_ERR(plat_data->pdev_mach)) {
ret = PTR_ERR(plat_data->pdev_mach);
goto comp_err;
}

dev_dbg(sdev->dev, "created machine %s\n",
dev_name(&plat_data->pdev_mach->dev));

/* init DMA trace */
ret = snd_sof_init_trace(sdev);
if (ret < 0) {
Expand Down
3 changes: 3 additions & 0 deletions sound/soc/sof/intel/hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
if (!bus->codec_mask)
dev_info(bus->dev, "no hda codecs found!\n");

/* used by hda machine driver to create dai links */
sdev->pdata->codec_mask = bus->codec_mask;

/* create codec instances */
hda_codec_probe_bus(sdev);

Expand Down
24 changes: 11 additions & 13 deletions sound/soc/sof/sof-acpi-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ static int sof_acpi_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
#else
dev_err(dev, "No matching ASoC machine driver found - aborting probe\n");
return -ENODEV;
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
Expand All @@ -251,21 +252,18 @@ static int sof_acpi_probe(struct platform_device *pdev)
priv->sof_pdata = sof_pdata;
sof_pdata->dev = &pdev->dev;
sof_pdata->type = SOF_DEVICE_APCI;
sof_pdata->platform = "sof-audio";
dev_set_drvdata(&pdev->dev, priv);

/* do we need to generate any machine plat data ? */
if (mach->new_mach_data)
if (mach->new_mach_data) {
sof_pdata->pdev_mach = mach->new_mach_data(sof_pdata);
else
/* register machine driver, pass machine info as pdata */
sof_pdata->pdev_mach =
platform_device_register_data(dev, mach->drv_name, -1,
(const void *)mach,
sizeof(*mach));
if (IS_ERR(sof_pdata->pdev_mach))
return PTR_ERR(sof_pdata->pdev_mach);
dev_dbg(dev, "created machine %s\n",
dev_name(&sof_pdata->pdev_mach->dev));

if (IS_ERR(sof_pdata->pdev_mach))
return PTR_ERR(sof_pdata->pdev_mach);
dev_dbg(dev, "created machine %s\n",
dev_name(&sof_pdata->pdev_mach->dev));
}

/* register sof-audio platform driver */
ret = sof_create_platform_device(priv);
Expand Down
20 changes: 4 additions & 16 deletions sound/soc/sof/sof-pci-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ static int sof_pci_probe(struct pci_dev *pci,
if (ret < 0)
goto release_regions;
#else
dev_err(dev, "No matching ASoC machine driver found - aborting probe\n");
ret = -ENODEV;
goto release_regions;
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
Expand All @@ -245,23 +245,11 @@ static int sof_pci_probe(struct pci_dev *pci,
priv->sof_pdata = sof_pdata;
sof_pdata->dev = &pci->dev;
sof_pdata->type = SOF_DEVICE_PCI;

/* register machine driver */
sof_pdata->pdev_mach =
platform_device_register_data(dev, mach->drv_name, -1,
sof_pdata, sizeof(*sof_pdata));
if (IS_ERR(sof_pdata->pdev_mach)) {
ret = PTR_ERR(sof_pdata->pdev_mach);
goto release_regions;
}

dev_dbg(dev, "created machine %s\n",
dev_name(&sof_pdata->pdev_mach->dev));
sof_pdata->platform = "sof-audio";

/* register sof-audio platform driver */
ret = sof_create_platform_device(priv);
if (ret) {
platform_device_unregister(sof_pdata->pdev_mach);
dev_err(dev, "error: failed to create platform device!\n");
goto release_regions;
}

Choose a reason for hiding this comment

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

please add machine device register change for sof-spi-dev.c also.

Copy link
Author

Choose a reason for hiding this comment

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

get it

Expand Down
11 changes: 0 additions & 11 deletions sound/soc/sof/sof-spi-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,9 @@ static int sof_spi_probe(struct spi_device *spi)
sof_pdata->dev = dev;
sof_pdata->type = SOF_DEVICE_SPI;

/* register machine driver */
sof_pdata->pdev_mach =
platform_device_register_data(dev, mach->drv_name, -1,
sof_pdata, sizeof(*sof_pdata));
if (IS_ERR(sof_pdata->pdev_mach))
return PTR_ERR(sof_pdata->pdev_mach);

dev_dbg(dev, "created machine %s\n",
dev_name(&sof_pdata->pdev_mach->dev));

/* register sof-audio platform driver */
ret = sof_create_platform_device(priv);
if (ret) {
platform_device_unregister(sof_pdata->pdev_mach);
dev_err(dev, "error: failed to create platform device!\n");
return ret;
}
Expand Down