Skip to content
116 changes: 63 additions & 53 deletions sound/soc/intel/boards/bxt_pcm512x.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "../../codecs/pcm512x.h"
#include "../atom/sst-atom-controls.h"

#ifdef CONFIG_SND_SOC_HDAC_HDMI
static struct snd_soc_jack broxton_hdmi[3];

struct bxt_hdmi_pcm {
Expand All @@ -40,6 +41,64 @@ struct bxt_hdmi_pcm {
int device;
};

static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd)
{
struct bxt_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_dai *dai = rtd->codec_dai;
struct bxt_hdmi_pcm *pcm;

pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
if (!pcm)
return -ENOMEM;

pcm->device = dai->id;
pcm->codec_dai = dai;

list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);

return 0;
}

#define NAME_SIZE 32
static int bxt_card_late_probe(struct snd_soc_card *card)
{
struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card);
struct bxt_hdmi_pcm *pcm;
struct snd_soc_component *component = NULL;
int err, i = 0;
char jack_name[NAME_SIZE];

list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name),
"HDMI/DP, pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name,
SND_JACK_AVOUT, &broxton_hdmi[i],
NULL, 0);

if (err)
return err;

err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
&broxton_hdmi[i]);
if (err < 0)
return err;

i++;
}

if (!component)
return -EINVAL;

return hdac_hdmi_jack_port_init(component, &card->dapm);
}
#else
static int bxt_card_late_probe(struct snd_soc_card *card)
{
return 0;
}
#endif

struct bxt_card_private {
struct list_head hdmi_pcm_list;
};
Expand Down Expand Up @@ -114,24 +173,6 @@ static const struct snd_soc_ops aif1_ops = {
.shutdown = aif1_shutdown,
};

static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd)
{
struct bxt_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_dai *dai = rtd->codec_dai;
struct bxt_hdmi_pcm *pcm;

pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
if (!pcm)
return -ENOMEM;

pcm->device = dai->id;
pcm->codec_dai = dai;

list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);

return 0;
}

static struct snd_soc_dai_link dailink[] = {
/* CODEC<->CODEC link */
/* back ends */
Expand All @@ -151,6 +192,7 @@ static struct snd_soc_dai_link dailink[] = {
.dpcm_playback = 1,
.dpcm_capture = 1,
},
#ifdef CONFIG_SND_SOC_HDAC_HDMI
{
.name = "iDisp1",
.id = 1,
Expand Down Expand Up @@ -184,42 +226,9 @@ static struct snd_soc_dai_link dailink[] = {
.dpcm_playback = 1,
.no_pcm = 1,
},

#endif
};

#define NAME_SIZE 32
static int bxt_card_late_probe(struct snd_soc_card *card)
{
struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card);
struct bxt_hdmi_pcm *pcm;
struct snd_soc_component *component = NULL;
int err, i = 0;
char jack_name[NAME_SIZE];

list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name),
"HDMI/DP, pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name,
SND_JACK_AVOUT, &broxton_hdmi[i],
NULL, 0);

if (err)
return err;

err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
&broxton_hdmi[i]);
if (err < 0)
return err;

i++;
}

if (!component)
return -EINVAL;

return hdac_hdmi_jack_port_init(component, &card->dapm);
}

/* SoC card */
static struct snd_soc_card bxt_pcm512x_card = {
Expand Down Expand Up @@ -250,7 +259,8 @@ static int bxt_pcm512x_probe(struct platform_device *pdev)
if (!ctx)
return -ENOMEM;

INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
INIT_LIST_HEAD(&ctx->hdmi_pcm_list);

mach = (&pdev->dev)->platform_data;
card = &bxt_pcm512x_card;
Expand Down
4 changes: 4 additions & 0 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ static int sof_probe(struct platform_device *pdev)
static int sof_remove(struct platform_device *pdev)
{
struct snd_sof_dev *sdev = dev_get_drvdata(&pdev->dev);
struct snd_sof_pdata *pdata = sdev->pdata;

if (pdata && !IS_ERR(pdata->pdev_mach))
platform_device_unregister(pdata->pdev_mach);

snd_soc_unregister_component(&pdev->dev);
snd_sof_fw_unload(sdev);
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/intel/hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)
struct pci_dev *pci = sdev->pci;
const struct sof_intel_dsp_desc *chip = sdev->hda->desc;

if (sdev->hda && (!IS_ERR_OR_NULL(sdev->hda->dmic_dev)))
if (sdev->hda && (!IS_ERR(sdev->hda->dmic_dev)))
platform_device_unregister(sdev->hda->dmic_dev);

/* disable DSP IRQ */
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/nocodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "sof-priv.h"

static struct snd_soc_card sof_nocodec_card = {
.name = "sof-nocodec",
.name = "nocodec", /* the sof- prefix is added by the core */
};

int sof_nocodec_setup(struct device *dev,
Expand Down
4 changes: 1 addition & 3 deletions sound/soc/sof/sof-acpi-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ static int sof_acpi_probe(struct platform_device *pdev)
/* 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 All @@ -281,8 +280,7 @@ static int sof_acpi_remove(struct platform_device *pdev)
struct sof_platform_priv *priv = dev_get_drvdata(&pdev->dev);
struct snd_sof_pdata *sof_pdata = priv->sof_pdata;

platform_device_unregister(sof_pdata->pdev_mach);
if (!IS_ERR_OR_NULL(priv->pdev_pcm))
if (!IS_ERR(priv->pdev_pcm))
platform_device_unregister(priv->pdev_pcm);
release_firmware(sof_pdata->fw);

Expand Down
5 changes: 1 addition & 4 deletions sound/soc/sof/sof-pci-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,8 @@ static void sof_pci_remove(struct pci_dev *pci)
struct sof_platform_priv *priv = pci_get_drvdata(pci);
struct snd_sof_pdata *sof_pdata = priv->sof_pdata;

/* unregister machine driver */
platform_device_unregister(sof_pdata->pdev_mach);

/* unregister sof-audio platform driver */
if (!IS_ERR_OR_NULL(priv->pdev_pcm))
if (!IS_ERR(priv->pdev_pcm))
platform_device_unregister(priv->pdev_pcm);

/* release firmware */
Expand Down
3 changes: 1 addition & 2 deletions sound/soc/sof/sof-spi-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ static int sof_spi_remove(struct spi_device *spi)
struct sof_platform_priv *priv = spi_get_drvdata(spi);
struct snd_sof_pdata *sof_pdata = priv->sof_pdata;

platform_device_unregister(sof_pdata->pdev_mach);
if (!IS_ERR_OR_NULL(priv->pdev_pcm))
if (!IS_ERR(priv->pdev_pcm))
platform_device_unregister(priv->pdev_pcm);
release_firmware(sof_pdata->fw);

Expand Down